From: Ivan Kohler Date: Fri, 21 Dec 2012 07:01:16 +0000 (-0800) Subject: credit line items interface: set credit amounts, RT#18676 X-Git-Url: http://git.freeside.biz/gitweb/?a=commitdiff_plain;h=52fcd2eb6f389fa8223d6d10d24aed4595c801db;p=freeside.git credit line items interface: set credit amounts, RT#18676 --- 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, diff --git a/httemplate/edit/credit-cust_bill_pkg.html b/httemplate/edit/credit-cust_bill_pkg.html index 1c6d5e5c7..77453a1cc 100644 --- a/httemplate/edit/credit-cust_bill_pkg.html +++ b/httemplate/edit/credit-cust_bill_pkg.html @@ -20,18 +20,18 @@ % next unless $amount > 0; % if ( $cust_bill_pkg->invnum ne $old_invnum ) { -   - Invoice #<% $cust_bill_pkg->invnum %> - <% time2str($date_format, $cust_bill_pkg->cust_bill->_date) %> +   + Invoice #<% $cust_bill_pkg->invnum %> - <% time2str($date_format, $cust_bill_pkg->cust_bill->_date) %> % $old_invnum = $cust_bill_pkg->invnum; % } +% my $el_name = 'billpkgnum'. $cust_bill_pkg->billpkgnum. '-'. $setuprecur; @@ -39,24 +39,35 @@ <% $cust_bill_pkg->desc |h %> %# show one-time/setup vs recur vs usage? <% $money_char. $amount %> + + <% $money_char %> + % } -  +  - Subtotal: + Subtotal: <% $money_char %><% sprintf('%.2f', 0) %> - Taxes: + Taxes: <% $money_char %><% sprintf('%.2f', 0) %> - Total credit amount: + Total credit amount: <% $money_char %><% sprintf('%.2f', 0) %> @@ -188,12 +199,21 @@ function calc_total(what) { var setuprecurs = []; var amounts = []; for (var i=0; iparam("billpkgnum$billpkgnum_setuprecur"); + my $amount = $cgi->param("billpkgnum$billpkgnum_setuprecur-amount"); my( $billpkgnum, $setuprecur ) = split('-', $billpkgnum_setuprecur); push @billpkgnums, $billpkgnum; push @setuprecurs, $setuprecur; diff --git a/httemplate/view/cust_main/payment_history.html b/httemplate/view/cust_main/payment_history.html index ed07577c6..821309dd5 100644 --- a/httemplate/view/cust_main/payment_history.html +++ b/httemplate/view/cust_main/payment_history.html @@ -77,7 +77,7 @@ 'action' => "${p}edit/credit-cust_bill_pkg.html", 'cust_main' => $cust_main, 'actionlabel' => emt('Credit line items'), - 'width' => 884, #763, + 'width' => 968, #763, 'height' => 575, &>