AllToolKits.com Posted July 23, 2015 Report Share Posted July 23, 2015 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 ? Quote Link to comment Share on other sites More sharing options...
0 Blesta Addons Posted July 23, 2015 Report Share Posted July 23, 2015 normally you should pass the extra as a line of invoice . that way the invoice will have two lines . 1 first for base price. 2 for extra price . Quote Link to comment Share on other sites More sharing options...
0 AllToolKits.com Posted July 24, 2015 Author Report Share Posted July 24, 2015 We can do that uisng module or plugin, that's without touching the blesta code? Quote Link to comment Share on other sites More sharing options...
0 Blesta Addons Posted July 24, 2015 Report Share Posted July 24, 2015 We can do that uisng module or plugin, that's without touching the blesta code? yes of course .. check my quote plugin , has the exemple and proof . Quote Link to comment Share on other sites More sharing options...
0 AllToolKits.com Posted July 25, 2015 Author Report Share Posted July 25, 2015 Can you get me a link to that plugin? If possible some code snippet too will help a lot. Quote Link to comment Share on other sites More sharing options...
0 Blesta Addons Posted July 25, 2015 Report Share Posted July 25, 2015 check my signature for quote plugin . you can inspire from how blesta create invoice . check the invoice.php model . Michael 1 Quote Link to comment Share on other sites More sharing options...
0 AllToolKits.com Posted August 3, 2015 Author Report Share Posted August 3, 2015 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? Quote Link to comment Share on other sites More sharing options...
0 Tyson Posted August 3, 2015 Report Share Posted August 3, 2015 Have you checked for errors? e.g. $this->Invoices->edit($invoice_id, $vars); print_r($this->Invoices->errors()); Quote Link to comment Share on other sites More sharing options...
0 AllToolKits.com Posted August 3, 2015 Author Report Share Posted August 3, 2015 Thanks for that, i got below error Array ( [client_id] => Array ( [exists] => Invalid client ID. ) [lines[0][service_id]] => Array ( [exists] => Invalid service ID. ) ) Quote Link to comment Share on other sites More sharing options...
0 Blesta Addons Posted August 3, 2015 Report Share Posted August 3, 2015 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 ? Quote Link to comment Share on other sites More sharing options...
0 AllToolKits.com Posted August 3, 2015 Author Report Share Posted August 3, 2015 How i can get the clientid from plugin, i just hard coded the client id as 1501, that i picked from admin side manually. Do you have any code snippet to get client_id? Quote Link to comment Share on other sites More sharing options...
0 Tyson Posted August 3, 2015 Report Share Posted August 3, 2015 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); Quote Link to comment Share on other sites More sharing options...
Question
AllToolKits.com
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 ?
Link to comment
Share on other sites
11 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.