push @$details, $self->option( 'additional_info' . $i++ );
}
- my $quantity = $cust_pkg->quantity || 1;
-
- my $charge = $quantity * $self->unit_setup($cust_pkg, $sdate, $details);
+ my $charge = $self->base_setup($cust_pkg, $sdate, $details);
my $discount = 0;
if ( $charge > 0 ) {
delete $param->{'setup_charge'};
}
- sprintf('%.2f', $charge - $discount);
+ sprintf( '%.2f', ($cust_pkg->quantity || 1) * ($charge - $discount) );
}
-sub unit_setup {
+sub base_setup {
my($self, $cust_pkg, $sdate, $details ) = @_;
$self->option('setup_fee') || 0;
if $self->recur_temporality eq 'preceding' && !$last_bill;
my $charge = $self->base_recur($cust_pkg, $sdate);
- if ( my $cutoff_day = $self->cutoff_day($cust_pkg) ) {
- $charge = $self->calc_prorate(@_, $cutoff_day);
+ # always treat cutoff_day as a list
+ if ( my @cutoff_day = $self->cutoff_day($cust_pkg) ) {
+ $charge = $self->calc_prorate(@_, @cutoff_day);
}
elsif ( $param->{freq_override} ) {
# XXX not sure if this should be mutually exclusive with sync_bill_date.
$charge *= $param->{freq_override} if $param->{freq_override};
}
- my $quantity = $cust_pkg->quantity || 1;
- $charge *= $quantity;
-
my $discount = $self->calc_discount($cust_pkg, $sdate, $details, $param);
- return sprintf('%.2f', $charge - $discount);
+
+ sprintf( '%.2f', ($cust_pkg->quantity || 1) * ($charge - $discount) );
}
sub cutoff_day {
return (localtime($next_bill))[3];
}
}
- return 0;
+ return ();
}
sub base_recur {