Jump to content
  • 0

Add Call Charge To Monthly Generating Invoice


Question

Posted

Assume that customer bought a packgae of  cost $40 per month. Using cron we are generating monthly invoice for this package.

But we need to add  some extra amount to this. We have to check cdr table and see cost of calls in the current month.

 

If it's $12 in the last month, the invoice should show total as   $40 + $12 = $52.

 

How i can  do that ?

11 answers to this question

Recommended Posts

  • 0
Posted

I tried below code, but it's not working. any idea why it's so?

    Loader::loadModels($this, array("Invoices"));
    $params = $event->getParams();
    $invoice_id = $params['invoice_id'];

    
    $vars = array(
        "client_id"  => "1501",
        "lines" => array(
            array(
                "description" => "test item",
                "qty" => "1",
                "amount" => "10"
                
            )
        )
        
    );
    $this->Invoices->edit($invoice_id, $vars);

The item with cost 10 is not added to that invoice, any idea how we can add the row?

  • 0
Posted

Thanks for that, i got below error

 

Array ( [client_id] => Array ( [exists] => Invalid client ID. ) [lines[0][service_id]] => Array ( [exists] => Invalid service ID. ) )

 

 

are you sur the client id exist 1501 ?

  • 0
Posted

I think the Invalid client ID error is encountered because you're probably using the client ID number rather than the system-level client ID. The number shown in the client profile is the client ID number, e.g. "Client #1501". However, the ID that you must use is unrelated to that number. If you look in the URL when you view a client's profile, the number at the end is the ID you want to use.

 

e.g. The client ID in this example would be "2":

/admin/clients/view/2/
    $vars = array(
        "client_id"  => 2,
        "lines" => array(
            array(
                "description" => "test item",
                "qty" => "1",
                "amount" => "10"
                
            )
        )
        
    );
    $this->Invoices->edit($invoice_id, $vars);

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...