From e18263db61c9695eb4c139f23c79730fd7659ad6 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Thu, 19 Mar 2015 13:43:34 -0700 Subject: correctly void invoices with fees, #32862 --- httemplate/view/cust_bill.cgi | 56 ++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 19 deletions(-) (limited to 'httemplate') diff --git a/httemplate/view/cust_bill.cgi b/httemplate/view/cust_bill.cgi index 6bc499a35..f1bcf4d52 100755 --- a/httemplate/view/cust_bill.cgi +++ b/httemplate/view/cust_bill.cgi @@ -2,26 +2,37 @@ emt("View this customer (#[_1])",$display_custnum) => "${p}view/cust_main.cgi?$custnum", ) &> -% if ( $conf->exists('deleteinvoices') -% && $curuser->access_right('Delete invoices' ) -% ) -% { - - - - <% mt('Delete this invoice') |h %> -

+ +% if ( !$cust_bill->closed ) { # otherwise allow no changes +% my $can_delete = $conf->exists('deleteinvoices') +% && $curuser->access_right('Delete invoices'); +% my $can_void = $curuser->access_right('Void invoices'); +% if ( $can_void ) { + <& /elements/popup_link.html, + 'label' => emt('Void this invoice'), + 'actionlabel' => emt('Void this invoice'), + 'action' => $p.'misc/void-cust_bill.html?invnum='.$invnum, + &> +% } +% if ( $can_void and $can_delete ) { +  |  +% } +% if ( $can_delete ) { + \ + <% emt('Delete this invoice') |h %> +% } +% if ( $can_void or $can_delete ) { +

+% } % } % if ( $cust_bill->owed > 0 @@ -185,6 +196,13 @@ my $cust_bill = qsearchs({ 'hashref' => { 'invnum' => $invnum }, 'extra_sql' => ' AND '. $curuser->agentnums_sql, }); +# if we're asked for a voided invnum, redirect appropriately +if (!$cust_bill and FS::cust_bill_void->row_exists("invnum = $invnum") ) { + $m->clear_buffer; + my $url = $p.'view/cust_bill_void.html?'.$cgi->query_string; + $m->print( $cgi->redirect($url) ); + $m->abort; +} die "Invoice #$invnum not found!" unless $cust_bill; $cust_bill->set('mode' => $mode); -- cgit v1.2.1