foreach (qw ( city county state zip ) ) {
my $method = "$prefix$_";
if ( $self->$method ) {
- $line .= '(' if $method eq 'county';
+ $line .= ' (' if $method eq 'county';
$line .= ($notfirst ? ' ' : $separator). &$escape($self->$method);
- $line .= ')' if $method eq 'county';
+ $line .= ' )' if $method eq 'county';
$notfirst++;
}
}
# This should be generalized to use config options to determine order.
sub sort_packages {
- my $locationsort = $a->locationnum <=> $b->locationnum;
+ my $locationsort = ( $a->locationnum || 0 ) <=> ( $b->locationnum || 0 );
return $locationsort if $locationsort;
if ( $a->get('cancel') xor $b->get('cancel') ) {
$error = $self->cancel_expired_pkgs( $options{actual_time} );
if ( $error ) {
$error = "Error expiring custnum ". $self->custnum. ": $error";
- if ( $options{'fatal'} eq 'return' ) { return $error; }
- elsif ( $options{'fatal'} ) { die $error; }
- else { warn $error; }
+ if ( $options{fatal} && $options{fatal} eq 'return' ) { return $error; }
+ elsif ( $options{fatal} ) { die $error; }
+ else { warn $error; }
}
$error = $self->suspend_adjourned_pkgs( $options{actual_time} );
if ( $error ) {
$error = "Error adjourning custnum ". $self->custnum. ": $error";
- if ( $options{'fatal'} eq 'return' ) { return $error; }
- elsif ( $options{'fatal'} ) { die $error; }
- else { warn $error; }
+ if ( $options{fatal} && $options{fatal} eq 'return' ) { return $error; }
+ elsif ( $options{fatal} ) { die $error; }
+ else { warn $error; }
}
$error = $self->bill( %options );
if ( $error ) {
$error = "Error billing custnum ". $self->custnum. ": $error";
- if ( $options{'fatal'} eq 'return' ) { return $error; }
- elsif ( $options{'fatal'} ) { die $error; }
- else { warn $error; }
+ if ( $options{fatal} && $options{fatal} eq 'return' ) { return $error; }
+ elsif ( $options{fatal} ) { die $error; }
+ else { warn $error; }
}
$error = $self->apply_payments_and_credits;
if ( $error ) {
$error = "Error applying custnum ". $self->custnum. ": $error";
- if ( $options{'fatal'} eq 'return' ) { return $error; }
- elsif ( $options{'fatal'} ) { die $error; }
- else { warn $error; }
+ if ( $options{fatal} && $options{fatal} eq 'return' ) { return $error; }
+ elsif ( $options{fatal} ) { die $error; }
+ else { warn $error; }
}
unless ( $conf->exists('cancelled_cust-noevents')
$error = $self->collect( %options );
if ( $error ) {
$error = "Error collecting custnum ". $self->custnum. ": $error";
- if ( $options{'fatal'} eq 'return' ) { return $error; }
- elsif ( $options{'fatal'} ) { die $error; }
- else { warn $error; }
+ if ($options{fatal} && $options{fatal} eq 'return') { return $error; }
+ elsif ($options{fatal} ) { die $error; }
+ else { warn $error; }
}
}
my $old_cust_pkg = new FS::cust_pkg \%hash;
my @details = ();
-
+ my @discounts = ();
my $lineitems = 0;
$cust_pkg->pkgpart($part_pkg->pkgpart);
);
my %param = ( 'precommit_hooks' => $precommit_hooks,
'increment_next_bill' => $increment_next_bill,
+ 'discounts' => \@discounts,
);
my $method = $options{cancel} ? 'calc_cancel' : 'calc_recur';
'unitrecur' => $unitrecur,
'quantity' => $cust_pkg->quantity,
'details' => \@details,
+ 'discounts' => \@discounts,
'hidden' => $part_pkg->hidden,
};
warn " invalid conditions not eliminated with condition_sql:\n".
join('', map " $_: ".$unsat{$_}."\n", keys %unsat )
- if $DEBUG; # > 1;
+ if keys %unsat && $DEBUG; # > 1;
##
# insert
warn " $_ => $options{$_}\n" foreach keys %options;
}
+ return "Amount must be greater than 0" unless $amount > 0;
+
unless ( $options{'description'} ) {
if ( $conf->exists('business-onlinepayment-description') ) {
my $dtempl = $conf->config('business-onlinepayment-description');
my $botpp = 'Business::OnlineThirdPartyPayment';
return 1
- if ( $conf->config('business-onlinepayment-namespace') eq $botpp ||
- scalar( grep { $_->gateway_namespace eq $botpp }
- qsearch( 'payment_gateway', { 'disabled' => '' } )
- )
+ if ( ( $conf->exists('business-onlinepayment-namespace')
+ && $conf->config('business-onlinepayment-namespace') eq $botpp
+ )
+ or scalar( grep { $_->gateway_namespace eq $botpp }
+ qsearch( 'payment_gateway', { 'disabled' => '' } )
+ )
)
;
? 'ship_'
: '';
- my ($zip,$plus4) = split /-/, $self->get("${prefix}zip")
+ my($zip,$plus4) = split /-/, $self->get("${prefix}zip")
if $self->country eq 'US';
+ $zip ||= '';
+ $plus4 ||= '';
#CCH specific location stuff
my $extra_sql = "AND plus4lo <= '$plus4' AND plus4hi >= '$plus4'";
(Class method)
-Returns a qsearch hash expression to search for parameters specified in HREF.
-Valid parameters are
+Returns a qsearch hash expression to search for parameters specified in
+HASHREF. Valid parameters are
=over 4