Invoice auto creation and updating is based on the opportunity create, edit and condition mentioned in Process builder.
Conditions are based on use cases such as Opportunity Stage = “Closed won” or as required by the business.
Following configuration is for an example where Opportunity Stage = “Closed won” and is applicable in two different scenarios.
Scenario 1: New Invoice Creation
Invoice auto-creation is based on creating of new opportunity, condition being Opportunity Stage = “Closed won”
Scenario 2: Edit Opportunity line item (for an opportunity with existing Invoice)
In a scenario where the opportunity line items have to be modified, the Invoice is auto updated, only upon editing the opportunity
To setup a Process Builder, click on <Setup> and search for “Process Builder” in the quick find box found on the left panel.
Click on <New> button to create a new process.
Add a Process name as “Create Invoice on Opportunity – Stage”
Select the Object, in this case “Opportunity “
Add the Criteria as shown in the diagram below, in this case Opportunity Stage = “Closed Won”
Next add Action. For the action select “Apex”, provide a name and select the Apex class “SFX-AutoInvoice”
Followed by “Set Apex Variable”
Select Field as OpportunityIds
Select Type as reference and
Select Value as Opportunity.ID
Save and Activate the Process builder
Pre-requisite on Opportunity Create or Update:
- Opportunity should be linked to Account
- Opportunity should have line items with Xero Tax code values (Refer Index#13)
- Opportunity contact role with primary contact
- Opportunity should have “Xero Branding Theme” values updated
- Editing of opportunity line items of an existing Invoice is based on editing the Opportunity
- Any Invoice with Status as “Authorised” cannot be edited or modified via Process builder
- Incase of an additional invoice existing on the opportunity object, the invoice with latest date/time stamp is updated via the Process builder upon editing and saving the Opportunity