# When to commit

Source: https://developer.avalara.com/avatax-dm-combined-erp/sales-tax-badge/design-transaction-workflow/when-to-commit/

# When to commit

As [indicated previously](/avatax-dm-combined-erp/common-setup/design-the-user-experience/sales-and-use/disable-document-recording) your design should include the ability to disable document committing by setting these transactions to `SalesOrder`. This indicates that the transactions are temporary estimates that aren’t recorded to AvaTax. This is useful, for example, for showing the current cost in a shopping cart before taxes are calculated. In this section, we’ll take a look at how the `commit` field works.

## Transaction state

When you create a transaction, the information about that transaction is referred to as a “Document”. You will see many comments or articles that refer to “Documents” rather than transactions - it helps if you think of the “Transaction” as the API call and the “Document” as the data that is stored on disk.

Once created, a document moves through a few different states before it is collected and reported on a tax return:

![](https://www.avalara.com/content/dam/assets/illustrations/diagrams/erp-with-posting.png)

As you can see from the lifecycle document above, a transaction can go through a number of steps before it is finalized. We have designed these steps to be flexible enough to solve problems for a variety of different customers and different types of tax processes. Let’s start with a few common use cases.

In a typical transaction, your first task is to provide a sales tax estimate for the user. To do this, call [CreateTransaction](https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Transactions/CreateTransaction/) with the transaction `type` set to `SalesOrder`. This gives you an accurate estimate of tax (assuming the address is entered correctly!), but it won’t record any tax data yet because the user hasn’t bought anything.

When you are ready to complete the transaction, your application should call [CreateTransaction](https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Transactions/CreateTransaction/) again, but this time you should set the transaction `type` to `SalesInvoice` and the `commit` value to `true`. These two values cause the transaction to be recorded into AvaTax, and it can then be collected and filed on a tax return.

The reason you have to contact the API a second time may not be immediately obvious - but the user may have waited long enough that the tax rates might have changed, or their address may have changed, or your company configuration may have changed. Any one of these small changes can affect the accuracy of a tax calculation.

**Advice:** If you calculate tax on a `SalesInvoice` and nothing has changed, you can use the [VerifyTransaction](https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Transactions/VerifyTransaction/) and [CommitTransaction](https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Transactions/CommitTransaction/) methods to make sure your data is in exactly the same state between your ERP and AvaTax. This is more efficient than creating a transaction using `commit=true`.

[Previous](/avatax-dm-combined-erp/sales-tax-badge/design-transaction-workflow/calculating-tax)

[Next](/avatax-dm-combined-erp/sales-tax-badge/design-transaction-workflow/ratio-of-determination-and-address-validation)