diff options
author | Ivan Kohler <ivan@freeside.biz> | 2014-01-18 14:33:48 -0800 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2014-01-18 14:33:48 -0800 |
commit | 965d64dbe634d499face4cea77c8b73188282a46 (patch) | |
tree | eee7e61a5caa7692977298b7166daa920e199921 | |
parent | 544ca6128192e61a38a431cff8d732bd767ed09f (diff) | |
parent | 074ab75187e3575674941a72ea50205c2ec42595 (diff) |
Merge branch 'master' of git.freeside.biz:/home/git/freeside
-rw-r--r-- | FS/FS/Schema.pm | 4 | ||||
-rw-r--r-- | FS/FS/Template_Mixin.pm | 12 | ||||
-rw-r--r-- | FS/FS/cust_bill.pm | 46 | ||||
-rw-r--r-- | httemplate/search/cust_bill_pkg.cgi | 16 |
4 files changed, 52 insertions, 26 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 30a35deb0..3cb1b773a 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -988,7 +988,7 @@ sub tables_hashref { 'format', 'char', 'NULL', 1, '', '', 'classnum', 'int', 'NULL', '', '', '', 'duration', 'int', 'NULL', '', 0, '', - 'phonenum', 'varchar', 'NULL', 25, '', '', + 'phonenum', 'varchar', 'NULL', 255, '', '', # has to hold a service label 'accountcode', 'varchar', 'NULL', 20, '', '', 'startdate', @date_type, '', '', 'regionname', 'varchar', 'NULL', $char_d, '', '', @@ -1163,7 +1163,7 @@ sub tables_hashref { 'format', 'char', 'NULL', 1, '', '', 'classnum', 'int', 'NULL', '', '', '', 'duration', 'int', 'NULL', '', 0, '', - 'phonenum', 'varchar', 'NULL', 25, '', '', + 'phonenum', 'varchar', 'NULL', 255, '', '', 'accountcode', 'varchar', 'NULL', 20, '', '', 'startdate', @date_type, '', '', 'regionname', 'varchar', 'NULL', $char_d, '', '', diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm index 2d9be618f..990f31fbc 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 9a971dd3a..63ae88471 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -1971,7 +1971,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); @@ -2998,14 +2998,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; } @@ -3033,18 +3041,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; } diff --git a/httemplate/search/cust_bill_pkg.cgi b/httemplate/search/cust_bill_pkg.cgi index 61093d262..6b7a5e6e2 100644 --- a/httemplate/search/cust_bill_pkg.cgi +++ b/httemplate/search/cust_bill_pkg.cgi @@ -20,12 +20,10 @@ 'fields' => [ @pkgnum, sub { $_[0]->pkgnum > 0 - # possibly use override.pkg but i think this correct ? $_[0]->get('pkgpart') : '' }, sub { $_[0]->pkgnum > 0 - # possibly use override.pkg but i think this correct ? $_[0]->get('pkg') : $_[0]->get('itemdesc') }, @@ -246,7 +244,6 @@ if ( $conf->exists('enable_taxclasses') ) { push @post_desc, 'taxclass'; push @post_desc_null, ''; $post_desc_align .= 'l'; - push @select, 'part_pkg.taxclass'; # or should this use override? } # valid in both the tax and non-tax cases @@ -321,7 +318,8 @@ if ( $use_override ) { )"; $part_pkg = 'override'; } -push @select, 'part_pkg.pkgpart', 'part_pkg.pkg'; # or should this use override? +push @select, "$part_pkg.pkgpart", "$part_pkg.pkg"; +push @select, "$part_pkg.taxclass" if $conf->exists('enable_taxclasses'); # the non-tax case if ( $cgi->param('nottax') ) { @@ -436,12 +434,12 @@ if ( $cgi->param('nottax') ) { $join_pkg .= " LEFT JOIN ($exempt_sub) AS item_exempt USING (billpkgnum)"; - } - # process tax restrictions - unshift @tax_where, - 'cust_bill_pkg_tax_location.taxable_billpkgnum = cust_bill_pkg.billpkgnum', - 'cust_main_county.tax > 0'; + # process tax restrictions + unshift @tax_where, + 'cust_bill_pkg_tax_location.taxable_billpkgnum = cust_bill_pkg.billpkgnum', + 'cust_main_county.tax > 0'; + } my $tax_sub = "SELECT 1 FROM cust_bill_pkg_tax_location |