It is now possible to automate pre-invoice generation using APEX which will run the batch job and create Pre-Invoices for Media Campaigns based on certain pre-defined criteria and following the payment criteria set out in the Media Campaign.
Additionally, from version 2.118, you can also determine a recipient email address for the result email from the batch job. This is particularly useful for managing the invoicing of different legal entities within the same org.
To find out more, please talk to your Account Manager about creating pre-invoices using APEX.
Create Pre-Invoices (using APEX)
Build your own way to create Pre-Invoices by using APEX code. The global class ADvendio.GenerateInvoiceBatch can be used to start a batch job that will create Pre-Invoices for Media Campaigns.
Simple call
Code Block | ||
---|---|---|
| ||
new ADvendio.GenerateInvoiceBatch().startBatch(); |
...
Payment Interval
Payment Start
Payment Due to
Advanced call
Code Block | ||
---|---|---|
| ||
ADvendio.GenerateInvoiceBatch generateInvoiceBatch = new ADvendio.GenerateInvoiceBatch(); generateInvoiceBatch.query = 'SELECT Id, Name FROM ADvendio__MediaCampaign__c WHERE ADvendio__LegalEntity__c = \'a1EA000000FfEBSMA3\'AND ADvendio__BillMe__c = True'; Database.executeBatch(generateInvoiceBatch, 1); |
...
You can change the query WHERE condition as you like (see Salesforce SOQL documentation). Linking variables using a colon (:) will not work, because the query will be executed in a different context.
Email Recipients
Code Block | ||
---|---|---|
| ||
ADvendio.GenerateInvoiceBatch generateInvoiceBatch = new ADvendio.GenerateInvoiceBatch(); generateInvoiceBatch.query = 'SELECT Id, Name FROM ADvendio__MediaCampaign__c WHERE ADvendio__LegalEntity__c = \'a1EA000000FfEBSMA3\'AND ADvendio__BillMe__c = True'; generateInvoiceBatch.resultEmailAddress = 'mail1@advendio.com, mail2@advendio.com'; Database.executeBatch(generateInvoiceBatch, 1); |
...