From a36a835749be78cafefb4f8a408b98ec6b0565f4 Mon Sep 17 00:00:00 2001 From: Irka Date: Sun, 10 Aug 2014 22:50:25 +0200 Subject: [PATCH] MT#5879 Allow to skip empty invoices generation with option no_empty. (cherry picked from commit ae8515d6024df6ac01140a1fd15f209fbcdab33c) --- share/tools/generate_invoices.pl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/share/tools/generate_invoices.pl b/share/tools/generate_invoices.pl index 6f997d3d60..221746660e 100755 --- a/share/tools/generate_invoices.pl +++ b/share/tools/generate_invoices.pl @@ -89,6 +89,7 @@ Getopt::Long::GetOptions($opt, 'update_contract_balance', 'update_contract_balance_nonzero', 'force_unrated', + 'no_empty', 'help|?', 'man' ) or pod2usage(2); @@ -329,6 +330,14 @@ sub check_unrated_calls{ sub generate_invoice_data{ my($provider_contract,$provider_contact,$client_contract,$client_contact,$billing_profile, $stime, $etime) = @_; + my($invoice_data) = get_invoice_data_raw($client_contract, $stime, $etime); + if((@{$invoice_data->{invoice_details_calls}} < 1) && $billing_profile->{interval_charge} == 0 ){ + if($opt->{no_empty}){ + $logger->debug("Contract_id=$client_contract->{id}. No_empty invoice generation requested - skiped."); + return; + } + } + state($t); if(!$t){ $t = NGCP::Panel::Utils::InvoiceTemplate::get_tt(); @@ -358,7 +367,6 @@ sub generate_invoice_data{ %$invoice, %$invoice_amounts, }; - my($invoice_data) = get_invoice_data_raw($client_contract, $stime, $etime); my $out = ''; my $pdf = ''; $invoice->{data} = '';