X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg%2Fflat.pm;h=97d4363da910c5b16bf81943db2946ea98c166c9;hp=f23717bc5649bb43e9f86d85d80450d27d487d6e;hb=44dcd4a1ff335a85a6babf0e007be57e6ec4f525;hpb=8f56a7435988ef9952c2b3f1f08450c63961becb diff --git a/FS/FS/part_pkg/flat.pm b/FS/FS/part_pkg/flat.pm index f23717bc5..97d4363da 100644 --- a/FS/FS/part_pkg/flat.pm +++ b/FS/FS/part_pkg/flat.pm @@ -225,6 +225,8 @@ sub calc_cancel { } } +# no longer used; see credit_remaining in FS::cust_pkg + sub calc_remain { my ($self, $cust_pkg, %options) = @_; @@ -235,8 +237,6 @@ sub calc_remain { $time = time; } - my $sources = $options{'cust_credit_source_bill_pkg'}; - my $next_bill = $cust_pkg->getfield('bill') || 0; return 0 if ! $self->base_recur($cust_pkg, \$time) @@ -272,30 +272,17 @@ sub calc_remain { $amount = $amount * ($edate - $time) / ($edate - $cust_bill_pkg->sdate); } - # calculate tax adjustment. we're not doing full credit_lineitems here - # (e.g. not applying the credit to the past billing of this package) - # so just include the adjustment in the source record with the rest - # of the credit - my %tax_adjust = FS::cust_credit->calculate_tax_adjustment( - 'custnum' => $cust_pkg->custnum, - 'billpkgnums' => [ $cust_bill_pkg->billpkgnum ], - 'setuprecurs' => [ 'recur' ], - 'amounts' => [ $amount ], - ); - $amount += $tax_adjust{taxtotal}; - - $amount = sprintf('%.2f', $amount); # ensure that amounts add up right $credit += $amount; - if ( $sources ) { - push @$sources, - FS::cust_credit_source_bill_pkg->new( { - 'billpkgnum' => $cust_bill_pkg->billpkgnum, - 'amount' => $amount, - 'currency' => $cust_bill_pkg->cust_bill->currency, - } ); - } - } # foreach $cust_bill_pkg + push @{ $options{'cust_credit_source_bill_pkg'} }, + new FS::cust_credit_source_bill_pkg { + 'billpkgnum' => $cust_bill_pkg->billpkgnum, + 'amount' => sprintf('%.2f', $amount), + 'currency' => $cust_bill_pkg->cust_bill->currency, + } + if $options{'cust_credit_source_bill_pkg'}; + + } sprintf('%.2f', $credit);