Revenue Cloud project notebook, written by two Meir IT consultants who implement it.

What is Revenue Cloud?

Billing and Tax·Admin

Country-Driven Tax Code, Without Apex

A subscription sold abroad came out with no tax, because its tax code was pinned to one country. No native setting varies the code by country. A flow on the quote line does it, with no Apex.

Nathan Altmann · Revenue Cloud consultant at Meir IT

Published 3 min read

In 3 linesfor leadership

  1. A subscription sold to a customer abroad went out on an invoice with no VAT and no error.
  2. Its VAT code was locked to one country, and no standard setting changes it by customer.
  3. A flow, with no Apex, sets the code by country; accounting signs off on the zone-to-code table.
In this article (6 sections)
  1. The problem
  2. The solution
  3. Setting it up
  4. The choice and its cost
  5. In practice
  6. Sources

The problem

Step: the tax code on the quote line, which then follows the order and the invoice. The catalog mixed two product families with opposite tax rules. Some products impose their own tax code because the taxable event happens in a specific place, such as where an event is held. The others must take the code of the customer’s country.

The second family broke. A subscription product was pinned to a single tax code. Sold to a customer in another country, no rate matched, and the invoice came out with no tax at all and no error. Event products were fine, which made the bug look random.

The solution

A rate is found from a tax code and a country. When the product’s code has no rate for the customer’s country, the lookup finds nothing, and the invoice goes out untaxed instead of failing. Event products never hit this because their code is supposed to stay fixed wherever the customer is. Only the products whose code should follow the customer were exposed, and only when sold abroad.

The obvious fix would be a setting that changes the code by country, and there is no native one. A tax treatment item (TaxTreatmentItem) carries a product and a tax code, with no geographic field. The standard tax decision table takes a code as input and returns a rate, so it can never produce a code.

The code therefore has to be set on the line before calculation, and survive repricing. What works is TaxPolicy.TreatmentSelection = Manual: a treatment set on the line then drives the calculation and is not derived again.

Setting it up

  1. Declare the rule on the product. A picklist with two values is enough: the product imposes its code, or the code comes from the customer.
  2. Keep the tax zone on the account as a picklist maintained by finance, not derived from the address, so finance can override it.
  3. Set the treatment from a flow when a quote line is created or updated, mapping zone to code.
  4. Set the policy to Manual so the treatment survives Reprice All.
  5. Don’t write a second flow for the order. The context service carries the treatment from the quote line to the order item on its own.

The choice and its cost

The flow won over Apex. The other route, a custom Apex tax adapter, needs a test class and enough code coverage to deploy. On one project, coverage was the only thing blocking a production release, so staying out of Apex was worth real money.

In return, Manual selection makes the line the source of truth. If the flow sets the wrong code, nothing downstream corrects it. That puts the weight on the zone-to-code mapping, which finance owns since the tax zone sits on the account.

In practice

  • Set the tax code on the line, since no native setting varies it by country.
  • Use TaxPolicy.TreatmentSelection = Manual so repricing keeps your treatment.
  • Write the zone-to-code mapping as a table, one row per tax zone with the code the flow sets, and have finance sign it.
  • Write flow criteria on API values, never on displayed labels.

Sources

  1. TaxPolicy
  2. TaxTreatment
  3. Billing Fields on QuoteLineItem
A technical question about this article?

A question about this article? I reply within 48 hours.

Something unclear, a mistake, or different behavior in your Salesforce org? Write to me.

Prefer email? Write to nathan@meir-it.com

Get notified of new articles

KeywordsInvoiceQuote

Type at least two letters.