[freeside-commits] branch FREESIDE_3_BRANCH updated. a9a38c344a6cba8c8bdf1b29a5be3c1c262aa8b8
Mark Wells
mark at 420.am
Thu Jan 16 20:41:14 PST 2014
The branch, FREESIDE_3_BRANCH has been updated
via a9a38c344a6cba8c8bdf1b29a5be3c1c262aa8b8 (commit)
from 6ba52ddb56dd7dfffdf39206bac6bbbcb0bb416e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit a9a38c344a6cba8c8bdf1b29a5be3c1c262aa8b8
Author: Mark Wells <mark at freeside.biz>
Date: Thu Jan 16 20:39:56 2014 -0800
when sending statements as payment receipts, ensure the payment appears on the statement, #24850
diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index 2d9be61..990f31f 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -1223,7 +1223,9 @@ sub print_generic {
# credits
my $credittotal = 0;
- foreach my $credit ( $self->_items_credits('trim_len'=>60) ) {
+ foreach my $credit (
+ $self->_items_credits( 'template' => $template, 'trim_len' => 60 )
+ ) {
my $total;
$total->{'total_item'} = &$escape_function($credit->{'description'});
@@ -1249,13 +1251,17 @@ sub print_generic {
$invoice_data{'credittotal'} = sprintf('%.2f', $credittotal);
#credits (again)
- foreach my $credit ( $self->_items_credits('trim_len'=>32) ) {
+ foreach my $credit (
+ $self->_items_credits( 'template' => $template, 'trim_len'=>32 )
+ ) {
push @buf, [ $credit->{'description'}, $money_char.$credit->{'amount'} ];
}
# payments
my $paymenttotal = 0;
- foreach my $payment ( $self->_items_payments ) {
+ foreach my $payment (
+ $self->_items_payments( 'template' => $template )
+ ) {
my $total = {};
$total->{'total_item'} = &$escape_function($payment->{'description'});
$paymenttotal += $payment->{'amount'};
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index a14e69b..8f1e07e 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -1989,7 +1989,7 @@ sub print_csv {
my $pmt_cr_applied = 0;
$pmt_cr_applied += $_->{'amount'}
- foreach ( $self->_items_payments, $self->_items_credits ) ;
+ foreach ( $self->_items_payments(%opt), $self->_items_credits(%opt) ) ;
my $totaldue = sprintf('%.2f', $self->owed + $previous_balance);
@@ -3016,14 +3016,22 @@ sub _items_credits {
#credits
my @objects;
if ( $self->conf->exists('previous_balance-payments_since') ) {
- my $date = 0;
- $date = $self->previous_bill->_date if $self->previous_bill;
- @objects = qsearch('cust_credit', {
- 'custnum' => $self->custnum,
- '_date' => {op => '>=', value => $date},
+ if ( $opt{'template'} eq 'statement' ) {
+ # then the current bill is a "statement" (i.e. an invoice sent as
+ # a payment receipt)
+ # and in that case we want to see payments on or after THIS invoice
+ @objects = qsearch('cust_credit', {
+ 'custnum' => $self->custnum,
+ '_date' => {op => '>=', value => $self->_date},
});
- # hard to do this in the qsearch...
- @objects = grep { $_->_date < $self->_date } @objects;
+ } else {
+ my $date = 0;
+ $date = $self->previous_bill->_date if $self->previous_bill;
+ @objects = qsearch('cust_credit', {
+ 'custnum' => $self->custnum,
+ '_date' => {op => '>=', value => $date},
+ });
+ }
} else {
@objects = $self->cust_credited;
}
@@ -3051,18 +3059,32 @@ sub _items_credits {
sub _items_payments {
my $self = shift;
+ my %opt = @_;
my @b;
my $detailed = $self->conf->exists('invoice_payment_details');
my @objects;
if ( $self->conf->exists('previous_balance-payments_since') ) {
- my $date = 0;
- $date = $self->previous_bill->_date if $self->previous_bill;
- @objects = qsearch('cust_pay', {
+ # then show payments dated on/after the previous bill...
+ if ( $opt{'template'} eq 'statement' ) {
+ # then the current bill is a "statement" (i.e. an invoice sent as
+ # a payment receipt)
+ # and in that case we want to see payments on or after THIS invoice
+ @objects = qsearch('cust_pay', {
+ 'custnum' => $self->custnum,
+ '_date' => {op => '>=', value => $self->_date},
+ });
+ } else {
+ # the normal case: payments on or after the previous invoice
+ my $date = 0;
+ $date = $self->previous_bill->_date if $self->previous_bill;
+ @objects = qsearch('cust_pay', {
'custnum' => $self->custnum,
'_date' => {op => '>=', value => $date},
});
- @objects = grep { $_->_date < $self->_date } @objects;
+ # and before the current bill...
+ @objects = grep { $_->_date < $self->_date } @objects;
+ }
} else {
@objects = $self->cust_bill_pay;
}
-----------------------------------------------------------------------
Summary of changes:
FS/FS/Template_Mixin.pm | 12 +++++++++---
FS/FS/cust_bill.pm | 46 ++++++++++++++++++++++++++++++++++------------
2 files changed, 43 insertions(+), 15 deletions(-)
More information about the freeside-commits
mailing list