X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_bill.pm;h=c404b8b01f7a3d756e8f71dd09fde360470eae4b;hb=bb5907148eb298e2e509fa37e23dcbe63619db9d;hp=06eec57ae550568d85cf230c3e88ec77be68bf63;hpb=e77f5d7c3812a65be18c5fc4ede509c42c5e3358;p=freeside.git diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 06eec57ae..c404b8b01 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -557,19 +557,27 @@ sub apply_payments_and_credits { } -=item generate_email PARAMHASH +=item generate_email OPTION => VALUE ... -PARAMHASH can contain the following: +Options: =over 4 -=item from => sender address, required +=item from -=item tempate => alternate template name, optional +sender address, required -=item print_text => text attachment arrayref, optional +=item tempate -=item subject => email subject, optional +alternate template name, optional + +=item print_text + +text attachment arrayref, optional + +=item subject + +email subject, optional =back @@ -1847,20 +1855,24 @@ sub print_generic { 'conf_dir' => "$FS::UID::conf_dir/conf.$FS::UID::datasrc", 'page' => 1, 'total_pages' => 1, + 'current_charges' => sprintf("%.2f", $self->charged), + 'duedate' => $self->due_date2str('%m/%d/%Y'), #date_format? 'ship_enable' => $conf->exists('invoice-ship_address'), 'unitprices' => $conf->exists('invoice-unitprice'), ); + my $countrydefault = $conf->config('countrydefault') || 'US'; my $prefix = $cust_main->has_ship_address ? 'ship_' : ''; foreach ( qw( contact company address1 address2 city state zip country fax) ){ my $method = $prefix.$_; $invoice_data{"ship_$_"} = _latex_escape($cust_main->$method); } + $invoice_data{'ship_country'} = '' + if ( $invoice_data{'ship_country'} eq $countrydefault ); $invoice_data{'cid'} = $params{'cid'} if $params{'cid'}; - my $countrydefault = $conf->config('countrydefault') || 'US'; if ( $cust_main->country eq $countrydefault ) { $invoice_data{'country'} = ''; } else { @@ -1895,7 +1907,8 @@ sub print_generic { # my( $cr_total, @cr_cust_credit ) = $self->cust_credit; #credits #my $balance_due = $self->owed + $pr_total - $cr_total; my $balance_due = $self->owed + $pr_total; - $invoice_data{'balance'} = $balance_due; + $invoice_data{'previous_balance'} = sprintf("%.2f", $pr_total); + $invoice_data{'balance'} = sprintf("%.2f", $balance_due); #do variable substitution in notes, footer, smallfooter foreach my $include (qw( notes footer smallfooter coupon )) { @@ -2119,6 +2132,7 @@ sub print_generic { unshift @total_items, $total; } } + $invoice_data{'taxtotal'} = sprintf('%.2f', $taxtotal); push @buf,['','-----------']; push @buf,[( $conf->exists('disable_previous_balance') @@ -2164,10 +2178,11 @@ sub print_generic { #foreach my $thing ( sort { $a->_date <=> $b->_date } $self->_items_credits, $self->_items_payments # credits + my $credittotal = 0; foreach my $credit ( $self->_items_credits ) { my $total; $total->{'total_item'} = &$escape_function($credit->{'description'}); - #$credittotal + $credittotal += $credit->{'amount'}; $total->{'total_amount'} = '-'. $other_money_char. $credit->{'amount'}; $adjusttotal += $credit->{'amount'}; if ( $multisection ) { @@ -2185,6 +2200,7 @@ sub print_generic { push @total_items, $total; } } + $invoice_data{'credittotal'} = sprintf('%.2f', $credittotal); # credits (again) foreach ( $self->cust_credited ) { @@ -2201,10 +2217,11 @@ sub print_generic { } # payments + my $paymenttotal = 0; foreach my $payment ( $self->_items_payments ) { my $total = {}; $total->{'total_item'} = &$escape_function($payment->{'description'}); - #$paymenttotal + $paymenttotal += $payment->{'amount'}; $total->{'total_amount'} = '-'. $other_money_char. $payment->{'amount'}; $adjusttotal += $payment->{'amount'}; if ( $multisection ) { @@ -2225,6 +2242,7 @@ sub print_generic { $money_char. sprintf("%10.2f", $payment->{'amount'}), ]; } + $invoice_data{'paymenttotal'} = sprintf('%.2f', $paymenttotal); if ( $multisection ) { $adjust_section->{'subtotal'} = $other_money_char. @@ -2486,6 +2504,16 @@ sub balance_due_msg { $msg; } +sub balance_due_date { + my $self = shift; + my $duedate = ''; + if ( $conf->exists('invoice_default_terms') + && $conf->config('invoice_default_terms')=~ /^\s*Net\s*(\d+)\s*$/ ) { + $duedate = time2str("%m/%d/%Y", $self->_date + ($1*86400) ); + } + $duedate; +} + =item invnum_date_pretty Returns a string with the invoice number and date, for example: @@ -2506,7 +2534,7 @@ sub _items_sections { if ( $cust_bill_pkg->pkgnum > 0 ) { - my $desc = $cust_bill_pkg->part_pkg->classname; + my $desc = $cust_bill_pkg->part_pkg->categoryname; $s{$desc} += $cust_bill_pkg->setup if ( $cust_bill_pkg->setup != 0 ); @@ -2576,7 +2604,7 @@ sub _items_pkg { my @cust_bill_pkg = grep { $_->pkgnum && ( defined($section) - ? $_->part_pkg->classname eq $section->{'description'} + ? $_->part_pkg->categoryname eq $section->{'description'} : 1 ) } $self->cust_bill_pkg;