Jump to content

Detect invoice origin


wandros

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 .

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...