Accounting Apex API Developer Reference
Posting Documents That Have Their Tax Value Calculated by AvaTax

Posting Documents That Have Their Tax Value Calculated by AvaTax

FinancialForce Accounting can be enabled to use Avalara's AvaTax product for the calculation of Sales and Use Tax (SUT). But it is important to note that Salesforce imposes a restriction that prevents callouts to external systems when there are pending operations in the same database transaction. (You can get more information about this restriction from the Salesforce Help topic www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts_timeouts.htm.) So if your FinancialForce Accounting org is enabled to use AvaTax, any existing code you have written to post sales invoices and sales credit notes may run into unexpected errors if, for example, it undertakes database updates before making the call to PostInvoice, PostCreditNote, BulkPostInvoice or BulkPostCreditNote.

If you are in this position, you can work around the issue by doing either of the following:

  • The recommended workaround is to use the new ScheduleInvoicesForPosting and ScheduleCreditNotesForPosting services to post your sales documents (either singly or in bulk). These services batch up the documents for posting by a scheduled job, and will deal with error handling and retry for the end user.
  • Alternatively you can modify your code to use asynchronous Apex, such as Batch Apex or @future, to separate pending operations (e.g. database updates) from the posting calls

For information about how to setup FinancialForce Accounting to use AvaTax for SUT calculation, see the FinancialForce Accounting Help topic "Setting up External Tax Calculation".

Note

The ScheduleInvoicesForPosting and ScheduleCreditNotesForPosting services can be used to post sales documents even when the org is not integrated with AvaTax. But remember that the documents are batched up for posting by a scheduled job; they are not posted immediately. For details of how to set up the scheduler, see the FinancialForce Accounting Help topic "Setting up the Background Posting Scheduler".

Note

From V15, AvaTax can also be used to calculate tax for companies with VAT, GST and Combined record types.

© Copyright 2009–2022 FinancialForce.com, inc. All rights reserved. Various trademarks held by their respective owners.