After the introduction of tariff on all imported goods, a requirement was to add tariff as a line item on invoices that has items with Class = coffee.
Tariff
A tariff is a tax or duty imposed by a government on imported or sometimes exported goods and services. Governments use tariffs to generate revenue, protect domestic industries by making foreign goods more expensive, and influence trade policy. For example, a country might impose a high tariff on imported steel to make domestically produced steel more competitive.
Tariff On Invoices
A “tariff on invoices” refers to a government-imposed tax on imported goods that is either explicitly listed on the invoice as a separate charge or is included in the final price. For businesses, this means tariffs can appear as surcharges on supplier invoices, and their cost must be tracked and accounted for, sometimes requiring specific adjustments to financial reporting. For consumers, unexpected tariffs can lead to surprise charges on e-commerce orders, often resulting from inaccurate shipment data.
Tariff as Line Item on Invoices
The requirement was to add Tariff as a line item on invoices. The system calculates the tariff value in a custom record based on the provided values. A user-event script fetches the calculated tariff value to the invoice. The tariff amount is based on the total of all items with Class = coffee (discounted items in this class are not considered). The calculated tariff amount is then used for the total invoice amount.
- Tariff Item
The tariff was created as an Other Charge Item For sale, mapped to the account mentioned by the client. The item was Non-Taxable.

- Custom Record: Tariff Configuration
The custom record will store the Tariff Value, calculated from the values entered in the specified fields.
User can select customer categories for which the tariff calculation does not apply from the “Excluded Customer Categories” field. When creating an invoice for a customer in one of these categories, the tariff calculation will not be applied.
Users can update these values as needed. Only designated users can access this custom record.
Whenever the Tariff Value needs adjustment, updates occur in the same record without creating new ones.
The final Tariff Value calculated here is fetched into a field added to the invoice by a User-Event Script and used for further calculations.

- Custom Field on Invoice: Tariff Percentage
A custom field of type Percent was added to the Invoice.
The value from the custom record is stored in this field, which calculates the tariff amount for the invoice.
This field remains editable even when the record is reedited.
This percentage will also calculate the tariff amount in future updates of the invoice.

- Script: User Event Script (before Submit)
A user event script was deployed in the invoice record to calculate the tariff amount using the following formula:
Tariff amount = Total coffee amount × Tariff percentage.
Tariff percentage: Value from the calculation In the Custom record.
Total coffee amount: Total Amount of the Items with Class = coffee
(If Tariff Percent value calculated =3.45% and the total amount of Items with class = coffee on invoice is $100, Then the Tariff Amount = 3.45% *100 = $3.45.)
(For the existing open invoices, 0 is added as tariff percentage and the tariff amount is calculated with 0 value.)
Note:
- This customization applies to all standalone invoices created through websites or CSV.
- When a new invoice record is created, the tariff item and tariff percent are added after saving.
- In the edit view of an updated invoice record, the previous tariff amount displays. Users can edit the tariff value, and if changed, the tariff amount recalculates based on the new value upon saving.
- If a user adds a value to the tariff percent field when creating a new invoice, the tariff amount is calculated using that value.
- For existing open invoices, a tariff percentage of 0 is applied, resulting in a tariff amount calculated with a value of 0.
- If no value is entered in the tariff percentage field, the script retrieves the value from the custom record to calculate the tariff amount.
- If 0 is entered in the tariff percentage field, the tariff amount is calculated as 0. This applies to open invoices created before the script deployment.
- When copying an invoice, the tariff item is also copied to the new invoice.
