action.skip

How to allow creating invoices for testing purposes?

← Billing & Invoice Management FAQ

Depending on your business requirements, your system setup may involve some custom development and corresponding tests in a sandbox.

With custom test scenarios that require invoices to be created, JustOn shows the following error:

ONB2.BillON.ValidationException: Please use the InvoiceBuilder to create Invoice__c sObjects!

To circumvent this error and execute the test as intended, you must deactivate the triggers on invoices and invoice line items. To do so, add the following code at the beginning of your test code:

insert new List<ONB2__TriggerSettings__c>{
    new ONB2__TriggerSettings__c(
        Name = 'InvoiceBeforeInsert'
    ),
    new ONB2__TriggerSettings__c(
        Name = 'InvoiceBeforeUpdate'
    ),
    new ONB2__TriggerSettings__c(
        Name = 'InvoiceLineItemBeforeInsert'
    ),
    new ONB2__TriggerSettings__c(
        Name = 'InvoiceLineItemBeforeUpdate'
    )
};

Info

This does not apply for test classes that are delivered with the JustOn package, which are designed to cover the standard JustOn development and may fail in your customized system.