[freeside-commits] freeside/FS/FS/ClientAPI MyAccount.pm, 1.139, 1.140
Ivan,,,
ivan at wavetail.420.am
Fri Sep 16 08:50:05 PDT 2011
Update of /home/cvs/cvsroot/freeside/FS/FS/ClientAPI
In directory wavetail.420.am:/tmp/cvs-serv3141/FS/FS/ClientAPI
Modified Files:
MyAccount.pm
Log Message:
add invoice_pdf to selfservice, RT#13656
Index: MyAccount.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/ClientAPI/MyAccount.pm,v
retrieving revision 1.139
retrieving revision 1.140
diff -u -w -d -r1.139 -r1.140
--- MyAccount.pm 15 Sep 2011 21:41:27 -0000 1.139
+++ MyAccount.pm 16 Sep 2011 15:50:02 -0000 1.140
@@ -936,6 +936,28 @@
}
+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;
@@ -981,12 +1003,24 @@
my @cust_bill = $cust_main->cust_bill;
+ my $balance = 0;
+
return { 'error' => '',
- 'invoices' => [ map { { 'invnum' => $_->invnum,
+ '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
+ }
+ @cust_bill
]
};
}
More information about the freeside-commits
mailing list