diff options
| author | ivan <ivan> | 2011-09-16 15:50:33 +0000 | 
|---|---|---|
| committer | ivan <ivan> | 2011-09-16 15:50:33 +0000 | 
| commit | b278e5d654ee0e1a429fa6177e69c8ab793181bb (patch) | |
| tree | 4893492053c665cca6a797b7f45c6815d62722a3 | |
| parent | 9c866ccad0f187f29d21f12b93f15f2787aa9843 (diff) | |
add invoice_pdf to selfservice, RT#13656
| -rw-r--r-- | FS/FS/ClientAPI/MyAccount.pm | 46 | ||||
| -rw-r--r-- | FS/FS/ClientAPI_XMLRPC.pm | 1 | ||||
| -rw-r--r-- | fs_selfservice/FS-SelfService/SelfService.pm | 1 | 
3 files changed, 42 insertions, 6 deletions
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index a1fd4b36e..fa667c0c0 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -936,6 +936,28 @@ sub invoice {  } +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,13 +1003,25 @@ sub list_invoices {    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 +            ]            };  } diff --git a/FS/FS/ClientAPI_XMLRPC.pm b/FS/FS/ClientAPI_XMLRPC.pm index 5cfb7d15c..33638f840 100644 --- a/FS/FS/ClientAPI_XMLRPC.pm +++ b/FS/FS/ClientAPI_XMLRPC.pm @@ -69,6 +69,7 @@ sub ss2clientapi {    '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! diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index 5b215f10b..b45cf16a7 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -31,6 +31,7 @@ $socket .= '.'.$tag if defined $tag && length($tag);    '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!  | 
