wandros Posted March 31, 2017 Report Posted March 31, 2017 Hello! I'd like to know if there is any way out of the box to differentiate if an invoice is created by the system or a staff member via the interface. I'm building a plugin which needs to know wether the invoice that triggered an invoice.add event was created by the system or a staff member. Thanks! /Wandros
evolvewh Posted March 31, 2017 Report Posted March 31, 2017 There may be a way to retrieve this information already (someone else will have to chime in) but there is a task that I think is similar to this: CORE-2158 Blesta Addons 1
Paul Posted March 31, 2017 Report Posted March 31, 2017 As suggested, CORE-2158. Currently there are a couple things you can consider: Invoices have line items that are linked to the service ID for new and renewing services. Manual invoices are not linked to services, with the only exception being new services that are invoiced during service creation Invoices generated by the system will be generated at the scheduled time (Settings > Company > Automation) So, it's not foolproof, but you can usually tell based on those things whether the system created it or a staff member.
Blesta Addons Posted March 31, 2017 Report Posted March 31, 2017 1 hour ago, Paul said: Manual invoices are not linked to services, with the only exception being new services that are invoiced during service creation this point is the only point we have based on it to identify the creator of invoice , we haven't found any issue at the moment with a custom plugin . to achieve the gaol, you need to make a loop for each line in the invoice, and check if service_id is null , sample code $invoice_system = false; foreach ($invoice_lines as $line) { if ($line->service_id != null) { $invoice_system = true; } } if ($invoice_system) { // invoice was created by the system, so do this } else { // invoice was created manually, so do this } Hope it help you . Paul, evolvewh and activa 3
wandros Posted April 3, 2017 Author Report Posted April 3, 2017 Ok! Thanks for the answers! I'm going to pursue the solution of checking if the invoice lines have service ids and see how it works out. Paul 1
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now