summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authormark <mark>2011-03-08 01:47:03 +0000
committermark <mark>2011-03-08 01:47:03 +0000
commit2a7db34383fbce13cb5bc6a9d7aee9242f544400 (patch)
treeb179fc29c8460bcc64f2c26e3c1dd76f9ce24459 /FS
parent77611d0838f839fb9f85279799717c7fbdb55fe9 (diff)
show credit balance on invoices, #11564
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Conf.pm7
-rw-r--r--FS/FS/cust_bill.pm28
2 files changed, 35 insertions, 0 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 6856ccf7e..338e264f5 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -3435,6 +3435,13 @@ and customer address. Include units.',
},
{
+ 'key' => 'previous_balance-show_credit',
+ 'section' => 'invoicing',
+ 'description' => 'Show the customer\'s credit balance on invoices when applicable.',
+ 'type' => 'checkbox',
+ },
+
+ {
'key' => 'balance_due_below_line',
'section' => 'invoicing',
'description' => 'Place the balance due message below a line. Only meaningful when when invoice_sections is false.',
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index ef0a2984e..461403a7b 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -2402,6 +2402,12 @@ sub print_generic {
);
my $embolden_function = $embolden_functions{$format};
+ my %newline_tokens = ( 'latex' => '\\\\',
+ 'html' => '<br>',
+ 'template' => "\n",
+ );
+ my $newline_token = $newline_tokens{$format};
+
warn "$me generating template variables\n"
if $DEBUG > 1;
@@ -3086,6 +3092,26 @@ sub print_generic {
push @buf,[$self->balance_due_msg, $money_char.
sprintf("%10.2f", $balance_due ) ];
}
+
+ if ( $conf->exists('previous_balance-show_credit')
+ and $cust_main->balance < 0 ) {
+ my $credit_total = {
+ 'total_item' => &$embolden_function($self->credit_balance_msg),
+ 'total_amount' => &$embolden_function(
+ $other_money_char. sprintf('%.2f', -$cust_main->balance)
+ ),
+ };
+ if ( $multisection ) {
+ $adjust_section->{'posttotal'} .= $newline_token .
+ $credit_total->{'total_item'} . ' ' . $credit_total->{'total_amount'};
+ }
+ else {
+ push @total_items, $credit_total;
+ }
+ push @buf,['','-----------'];
+ push @buf,[$self->credit_balance_msg, $money_char.
+ sprintf("%10.2f", -$cust_main->balance ) ];
+ }
}
if ( $multisection ) {
@@ -3445,6 +3471,8 @@ sub balance_due_date {
$duedate;
}
+sub credit_balance_msg { 'Credit Balance Remaining' }
+
=item invnum_date_pretty
Returns a string with the invoice number and date, for example: