summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2012-12-20 23:01:16 -0800
committerIvan Kohler <ivan@freeside.biz>2012-12-20 23:01:16 -0800
commit52fcd2eb6f389fa8223d6d10d24aed4595c801db (patch)
tree7ce350baae00ca888d19cc0c51fc41853b6a450f /FS
parentada138aaa35f8d843c6e9b6acc83bae70fa13ef3 (diff)
credit line items interface: set credit amounts, RT#18676
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/cust_credit.pm13
1 files changed, 10 insertions, 3 deletions
diff --git a/FS/FS/cust_credit.pm b/FS/FS/cust_credit.pm
index 1f5477787..83e5d6049 100644
--- a/FS/FS/cust_credit.pm
+++ b/FS/FS/cust_credit.pm
@@ -5,6 +5,7 @@ use base qw( FS::otaker_Mixin FS::cust_main_Mixin FS::Record );
use vars qw( $conf $unsuspendauto $me $DEBUG
$otaker_upgrade_kludge $ignore_empty_reasonnum
);
+use List::Util qw( min );
use Date::Format;
use FS::UID qw( dbh getotaker );
use FS::Misc qw(send_email);
@@ -878,13 +879,19 @@ sub credit_lineitems {
my $old_loc = $xlocation_map{$taxid};
if ( $old_loc ) {
# then apply the amount of $new_loc to it
- $amount -= $new_loc->amount;
- $cust_credit_bill{$invnum} += $new_loc->amount;
+ #support partial credits: use $amount if smaller
+ # (so just distribute to the first location? perhaps should
+ # do so evenly...)
+ my $loc_amount = min( $amount, $new_loc->amount);
+
+ $amount -= $loc_amount;
+
+ $cust_credit_bill{$invnum} += $loc_amount;
push @{ $cust_credit_bill_pkg{$invnum} },
new FS::cust_credit_bill_pkg {
'billpkgnum' => $tax_cust_bill_pkg->billpkgnum,
- 'amount' => $new_loc->amount,
+ 'amount' => $loc_amount,
'setuprecur' => 'setup',
'billpkgtaxlocationnum' => $old_loc->billpkgtaxlocationnum,
'billpkgtaxratelocationnum' => $old_loc->billpkgtaxratelocationnum,