my @errors = ();
+ my @really_cancel_pkgs;
+ my @cancel_reasons;
+
CUST_PKG: foreach my $cust_pkg ( @cancel_pkgs ) {
my $cpr = $cust_pkg->last_cust_pkg_reason('expire');
my $error;
$error = '' if ref $error eq 'FS::cust_pkg';
} else { # just cancel it
- $error = $cust_pkg->cancel($cpr ? ( 'reason' => $cpr->reasonnum,
- 'reason_otaker' => $cpr->otaker,
- 'time' => $time,
- )
- : ()
- );
+
+ push @really_cancel_pkgs, $cust_pkg;
+ push @cancel_reasons, $cpr;
+
}
- push @errors, 'pkgnum '.$cust_pkg->pkgnum.": $error" if $error;
+ }
+
+ if (@really_cancel_pkgs) {
+
+ my %cancel_opt = ( 'cust_pkg' => \@really_cancel_pkgs,
+ 'cust_pkg_reason' => \@cancel_reasons,
+ 'time' => $time,
+ );
+
+ push @errors, $self->cancel_pkgs(%cancel_opt);
+
}
join(' / ', @errors);
my $unitrecur = 0;
my @recur_discounts = ();
my $sdate;
+
+ my $override_quantity;
+
# Conditions for billing the recurring fee:
# - the package doesn't have a future start date
# - and it's not suspended
#base_cancel???
$unitrecur = $cust_pkg->base_recur( \$sdate ) || $recur; #XXX uuh, better
+ if ( $param{'override_quantity'} ) {
+ $override_quantity = $param{'override_quantity'};
+ $unitrecur = $recur / $override_quantity;
+ }
+
if ( $increment_next_bill ) {
my $next_bill;
}
}
- }
+ } # end of recurring fee
warn "\$setup is undefined" unless defined($setup);
warn "\$recur is undefined" unless defined($recur);
'unitsetup' => sprintf('%.2f', $unitsetup),
'recur' => $recur,
'unitrecur' => sprintf('%.2f', $unitrecur),
- 'quantity' => $cust_pkg->quantity,
+ 'quantity' => $override_quantity || $cust_pkg->quantity,
'details' => \@details,
'discounts' => [ @setup_discounts, @recur_discounts ],
'hidden' => $part_pkg->hidden,
# We fetch taxes even if the customer is completely exempt,
# because we need to record that fact.
- my @loc_keys = qw( district city county state country );
- my %taxhash = map { $_ => $location->$_ } @loc_keys;
+ my %taxhash = map { $_ => $location->get($_) }
+ qw( district county state country );
+ # city names in cust_main_county are uppercase
+ $taxhash{'city'} = uc($location->get('city'));
$taxhash{'taxclass'} = $part_item->taxclass;