[Spce-user] invoice

Irina Peshinskaya ipeshinskaya at sipwise.com
Thu Apr 9 14:01:41 EDT 2015


Hello Fry,

As a extended debug I can suggest following:

1. Could you please apply attached patch.txt:

#create backup
cp /usr/share/perl5/NGCP/Panel/Controller/Invoice.pm 
/usr/share/perl5/NGCP/Panel/Controller/Invoice_2015_04_09_00.pm

#apply patch
patch -p0 < patch.txt


2. Enable mysql general log, if it is off now. Kindly look at example below:

mysql> show variables like '%general_log%';
+------------------+-------------------------+
| Variable_name    | Value                   |
+------------------+-------------------------+
| general_log      | OFF                     |
| general_log_file | /var/lib/mysql/spce.log |
+------------------+-------------------------+
2 rows in set (0.00 sec)

mysql> set global general_log='ON';
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like '%general_log%';
+------------------+-------------------------+
| Variable_name    | Value                   |
+------------------+-------------------------+
| general_log      | ON                      |
| general_log_file | /var/lib/mysql/spce.log |
+------------------+-------------------------+
2 rows in set (0.00 sec)
----------------------------------------------------------


After invoice creation failed, you can inspect your mysql general log 
file against query looking  like:


SELECT `me`.`id`, `me`.`customer_id`, `me`.`contact_id`, 
`me`.`order_id`, `me`.`status`,
  `me`.`external_id`, `me`.`send_invoice`, `me`.`modify_timestamp`, 
`me`.`create_timestamp`, `me`.`activate_timestamp`, `
me`.`terminate_timestamp`, `me`.`max_subscribers`, 
`me`.`subscriber_email_template_id`, `me`.`passreset_email_template_i
d`, `me`.`invoice_email_template_id`, `me`.`invoice_template_id`, 
`me`.`vat_rate`, `me`.`add_vat`, `billing_mappings`.`i
d`, `billing_mappings`.`start_date`, `billing_mappings`.`product_id`, 
`billing_mappings`.`id` FROM `billing`.`contracts`
  `me` LEFT JOIN `billing`.`billing_mappings` `billing_mappings` ON 
`billing_mappings`.`contract_id` = `me`.`id` LEFT JOI
N `billing`.`products` `product` ON `product`.`id` = 
`billing_mappings`.`product_id` LEFT JOIN `billing`.`contacts` `con
tact` ON `contact`.`id` = `me`.`contact_id` WHERE ( ( `me`.`id` = '5' 
AND ( ( `product`.`class` = 'sipaccount' OR `produ
ct`.`class` = 'pbxaccount' ) AND ( `contact`.`reseller_id` IS NOT NULL 
AND ( `billing_mappings`.`id` = (SELECT `bilmap`.
`id` FROM `billing`.`billing_mappings` `bilmap` WHERE ( ( `contract_id` 
= `me`.`id` AND ( `end_date` >= '2015-04-09 19:4
8:09' OR `end_date` IS NULL ) AND ( `start_date` <= '2015-04-09 
19:48:09' OR `start_date` IS NULL ) ) ) ORDER BY `bilmap
`.`start_date` DESC, `bilmap`.`id` DESC LIMIT 1) AND `me`.`status` != 
'terminated' ) ) ) ) )

In place of "5" will be your customer id.
It is possible that you will not find the query in the log if your mysql 
server gone away due to timeout.

kindly let me know results.

Best regards,
Irina


On 08.04.2015 Wednesday 19:09, fry wrote:
> Hi Irina,
>
> thanks for your reply - but i can't understand the whole e-mail.
>
> Yes, the time-out was the problem, but I was able to change the values
> for the timeout on nginx and so now i can handle that.. on my lab-server
> i saw that he had problems with the amount of pdf-sites (i guess the
> command was too large) so i changed the text-size and was able to
> generate an invoice with a lot of numbers.. but on the other system i
> get this error.
>
> if i generate a invoice (for the same customer) for the actual month
> this works fine..
>
> is there any possibility to enable more a deeper log-mode?
>
> thanks
> fry
>
> Am 07.04.2015 um 22:01 schrieb Irina Peshinskaya:
>> Hello Fry,
>>
>>  From your letter from 09.03.2015, I got that by some strange way mysql
>> timeout was the reason of this error.
>>
>> Field contract is required and if you don't specify it - you wouldn't
>> pass form validation and get to this line and thus to this error.
>> I couldn't request invoice generation on 3.4.2 code with empty
>> contract (no selected contract).
>>
>> Is invoice generated OK for the same contract for other periods?
>>
>> Thanks in advance.
>>
>> Best regards,
>> Irina

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sipwise.com/pipermail/spce-user_lists.sipwise.com/attachments/20150409/7d1a0c96/attachment-0001.html>
-------------- next part --------------
diff --git lib/NGCP/Panel/Controller/Invoice.pm lib/NGCP/Panel/Controller/Invoice.pm
index e10f68b..b356c89 100644
--- /usr/share/perl5/NGCP/Panel/Controller/Invoice.pm
+++ /usr/share/perl5/NGCP/Panel/Controller/Invoice.pm
@@ -157,12 +157,13 @@ sub create :Chained('inv_list') :PathPart('create') :Args() :Does(ACL) :ACLDetac
             my $schema = $c->model('DB');
             $schema->txn_do(sub {
                 my $contract_id = $form->params->{contract}{id};
+                use Carp qw/longmess/;
                 my $customer_rs = NGCP::Panel::Utils::Contract::get_customer_rs(c => $c);
                 my $customer = $customer_rs->find({ 'me.id' => $contract_id });
                 unless($customer) {
                     NGCP::Panel::Utils::Message->error(
                         c => $c,
-                        error => "invalid contract_id $contract_id",
+                        error => "invalid contract_id: ".longmess(),
                         desc  => $c->loc('Customer not found'),
                     );
                     die;


More information about the Spce-user mailing list