- my %sec = (
- 'h' => 3600, # 60 * 60
- 'd' => 86400, # 60 * 60 * 24
- 'w' => 604800, # 60 * 60 * 24 * 7
- 'm' => 2629744, # 60 * 60 * 24 * 365.2422 / 12
- );
+ # Use actual charge for this period, not base_recur (for discounts).
+ # Use sdate < $time and edate >= $time because when billing on
+ # cancellation, edate = $time.
+ my $credit = 0;
+ foreach my $cust_bill_pkg (
+ qsearch('cust_bill_pkg', {
+ pkgnum => $cust_pkg->pkgnum,
+ edate => {op => '>=', value => $time},
+ recur => {op => '>' , value => 0},
+ })
+ ) {
+
+ # hack to deal with the weird behavior of edate on package cancellation
+ my $edate = $cust_bill_pkg->edate;
+ if ( $self->recur_temporality eq 'preceding' ) {
+ $edate = $self->add_freq($cust_bill_pkg->sdate);
+ }