}
+sub invoice_pdf {
+ my $p = shift;
+ my $session = _cache->get($p->{'session_id'})
+ or return { 'error' => "Can't resume session" }; #better error message
+
+ my $custnum = $session->{'custnum'};
+
+ my $invnum = $p->{'invnum'};
+
+ my $cust_bill = qsearchs('cust_bill', { 'invnum' => $invnum,
+ 'custnum' => $custnum } )
+ or return { 'error' => "Can't find invnum" };
+
+ #my %return;
+
+ return { 'error' => '',
+ 'invnum' => $invnum,
+ 'invoice_pdf' => $cust_bill->print_pdf( { unsquelch_cdr => 1 } ),
+ };
+
+}
+
sub invoice_logo {
my $p = shift;
my @cust_bill = $cust_main->cust_bill;
+ my $balance = 0;
+
return { 'error' => '',
- 'invoices' => [ map { { 'invnum' => $_->invnum,
- '_date' => $_->_date,
- 'date' => time2str("%b %o, %Y", $_->_date),
- }
- } @cust_bill
- ]
+ 'invoices' => [
+ map {
+ my $owed = $_->owed;
+ $balance += $owed;
+ +{ 'invnum' => $_->invnum,
+ '_date' => $_->_date,
+ 'date' => time2str("%b %o, %Y", $_->_date),
+ 'date_short' => time2str("%m-%d-%Y", $_->_date),
+ 'previous' => sprintf('%.2f', ($_->previous)[0]),
+ 'charged' => sprintf('%.2f', $_->charged),
+ 'owed' => sprintf('%.2f', $owed),
+ 'balance' => sprintf('%.2f', $balance),
+ }
+ }
+ @cust_bill
+ ]
};
}
'customer_info' => 'MyAccount/customer_info',
'edit_info' => 'MyAccount/edit_info', #add to ss cgi!
'invoice' => 'MyAccount/invoice',
+ 'invoice_pdf' => 'MyAccount/invoice_pdf',
'invoice_logo' => 'MyAccount/invoice_logo',
'list_invoices' => 'MyAccount/list_invoices', #?
'cancel' => 'MyAccount/cancel', #add to ss cgi!
'customer_info' => 'MyAccount/customer_info',
'edit_info' => 'MyAccount/edit_info', #add to ss cgi!
'invoice' => 'MyAccount/invoice',
+ 'invoice_pdf' => 'MyAccount/invoice_pdf',
'invoice_logo' => 'MyAccount/invoice_logo',
'list_invoices' => 'MyAccount/list_invoices', #?
'cancel' => 'MyAccount/cancel', #add to ss cgi!