From 61e988d7675346395d24f1d7a2e89f4d90b95a6c Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Thu, 20 Dec 2012 23:01:07 -0800 Subject: [PATCH] credit line items interface: set credit amounts, RT#18676 --- FS/FS/cust_credit.pm | 14 ++++--- httemplate/edit/credit-cust_bill_pkg.html | 48 ++++++++++++++++------- httemplate/edit/process/credit-cust_bill_pkg.html | 2 +- httemplate/view/cust_main/payment_history.html | 2 +- 4 files changed, 45 insertions(+), 21 deletions(-) diff --git a/FS/FS/cust_credit.pm b/FS/FS/cust_credit.pm index dfe55fb63..9fd2d01a4 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); @@ -806,19 +807,22 @@ sub credit_lineitems { foreach my $location ( $tax_cust_bill_pkg->cust_bill_pkg_tax_Xlocation ) { - $location->cust_bill_pkg_desc($taxline->desc); #ugh @ that kludge + #support partial credits: use $amount if smaller + # (so just distribute to the first location? perhaps should + # do so evenly...) + my $loc_amount = min( $amount, $location->amount); - #$taxtotal += $location->amount; - $amount -= $location->amount; + #$taxtotal += $loc_amount + $amount -= $loc_amount; #push @taxlines, # #[ $location->desc, $taxline->setup, $taxlocnum, $taxratelocnum ]; # [ $location->desc, $location->amount, $taxlocnum, $taxratelocnum ]; - $cust_credit_bill{$invnum} += $location->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' => $location->amount, + 'amount' => $loc_amount, 'setuprecur' => 'setup', 'billpkgtaxlocationnum' => $location->billpkgtaxlocationnum, 'billpkgtaxratelocationnum' => $location->billpkgtaxratelocationnum, diff --git a/httemplate/edit/credit-cust_bill_pkg.html b/httemplate/edit/credit-cust_bill_pkg.html index e317936b3..f5c4eefbf 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) %> @@ -183,12 +194,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 6630d12a5..942b42f54 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, &>
-- 2.11.0