Skip to content

Tax Rules

Certain business use cases require support for complex tax rules. With this respect, the following concepts are important:

Tax rules provide for tax rate lookups along various combinations of account region, merchant or tenant region, product tax class, etc.

A tax detail represents an individual tax data set that is determined for a specific combination of region, tax class, etc., and that is included in the tax calculation for an invoice line item.

Info

For general information about JustOn's tax capabilities, see JustOn Tax Handling.

Tax Rule Concepts

JustOn implements tax rules using the custom setting Tax Rules. Tax rules include controlling, source and result parameter fields:

  • Controlling fields affect the behavior of the tax calculation.
  • Source fields are used to select the best matching tax rule for the current context.
  • Result fields are copied to the invoice line item and its tax details.

The following fields are available:

Field Field Type Required Description
Name Result The name of the tax rule, will be copied to the field Applied Tax Rule on the line item or tax detail.
JustOn recommends to keep the name of each tax rule unique and to never change it.
Type Controlling () Custom name of a tax rule type. Types are used to group tax rules to support multiple tax rates per invoice line item. Each group of types is evaluated individually and results in a different tax rate.
Required if you use multiple tax rates.
Tenant Source () Corresponds to the field Tenant on the invoice.
If you use the tenant feature, all tax rules for the particular tenant must have the tenant field set.
Invoice Region Source Corresponds to the field Region on the invoice.
Invoice Country Source Corresponds either to the field Shipping Country or to the field Billing Country on the invoice, see Using Billing Address for Tax Calculation.
To guarantee the correct spelling of countries, JustOn recommends to use Salesforce's state and country picklists.
If you have state and country picklists enabled, make sure to use the country code instead of the country name.
Invoice State Source Corresponds either to the field Shipping State or to the field Billing State on the invoice, see Using Billing Address for Tax Calculation.
To guarantee the correct spelling of states, JustOn recommends to use Salesforce's state and country picklists.
If you have state and country picklists enabled, make sure to use the state code instead of the state name.
Account Tax Class Source Corresponds to the field Account Tax Class on the invoice.
Product Tax Class Source Corresponds to the field Product Tax Class on the invoice line item.
Product Group Source Corresponds to the field Product Group on the invoice line item.
Tax Rate Result The actual tax rate that will be applied with this rule. The tax rate is written to the field Tax Rate on the invoice line item or the field Rate on the tax detail.
Tax Code Result The actual tax code that will be applied with this rule. The tax code is written to the field Tax Code on the invoice line item or the field Tax Code on the tax detail.

Tax-Relevant Fields on Invoices and Invoice Line Items

All tax-relevant data that is required to determine the tax for a specific line item is written to the invoice and invoice line item records when the invoice is created.

The source objects for the invoice data include the Opportunity, Subscription and Account objects (in this order). Which data is used depends on the source object that is the first to hold the corresponding information: For example, if the invoice builder first tries to get the data from the subscription and the data is not available, the builder then tries to retrieve the data from the account.

Invoice Field Opportunity Subscription Account Example
Region ON_Region ON_Region ON_Region EU
EMEA
State ON_ShippingState or
ON_BillingState
Legal State Shipping State or
Billing State
Country ON_ShippingCountry or
ON_BillingCountry
Legal Country Shipping Country or
Billing Country
Account Tax Class ON_AccountTaxClass ON_AccountTaxClass ON_AccountTaxClass retail
business

The data for the invoice line item is taken from the object that is used to build the invoice line item, like an opportunity product or a product record.

Invoice Line Item Field Description Source Field Name Example
Product Tax Class The tax class of the product ON_ProductTaxClass (tax) free
reduced
full
luxury
Product Tax Rate The tax rate of the product ON_ProductTaxRate 19%

Info

Depending on your given data, you can use either the product tax class or the product tax rate.

How Tax Rules Are Applied

Tax rules are applied to invoice line items each time you create or update an invoice line item. JustOn writes the values for the fields Tax Rate, Applied Tax Rule and Tax Code either directly to the invoice line item (like for the VAT) or creates a tax detail for each applicable tax type (like sales tax).

Tax Rule Evaluation During the Invoice Run

First, JustOn loads the values of the tax-relevant fields from the account, the subscription, the opportunity, the item, the opportunity product and the product. Then, it evaluates all tax rules that may apply for the tenant of the invoice: They are grouped by type, where each group is evaluated individually. This may result in a best matching tax rule (or none) for each group. When there is only a matching rule from one group, the result is written to the invoice line item. When there are multiple rules, that is, from different groups, JustOn creates tax details instead.

Manual Creation/Modification of Invoice Line Items

There are currently three ways for creating and editing invoice line items manually (see Modifying Invoice Line Items):

  • New Invoice Line Item or Edit at the line item related list,
  • Edit All, and
  • New Line Item from Product.

Each page allows to select the tax rules automatically, force a tax rule or specify a tax rate manually. The available UI options are determined by the number of the matching tax rules and their types.

The following table illustrates this:

Tax Rate Definition Tenant Tax Rule Configuration Description
Drop-down list set to Automatic (w/o user interaction) Multiple tax rules for the invoice tenant with multiple types, like:
Rule 1: Type=GST, Tax Rate=5%, Tenant=CA
Rule 2: Type=PST, Tax Rate=7%, Tenant=CA
If JustOn detects that the current configuration will result in multiple taxes for the current invoice line item, it will switch to the automatic mode, which does not allow user interaction.
Drop-down list set to Automatic or Full (19%) or Reduced (7%) Multiple tax rules for the invoice tenant with a single type, like:
Rule 1: Type=VAT, Tax Rate=19%, Tenant=DE, Name=Full
Rule 2: Type=VAT, Tax Rate=7%, Tenant=DE, Name=Reduced
If JustOn detects that the current configuration will result in a single tax rate, it allows the user to leave it on automatic mode or force JustOn to apply a particular tax rule to the invoice line item.
Automatic is preselected for new line items, a particular rule is preselected for existing line items.
Input field for the tax rate No applicable tax rules for the tenant found If there are no applicable tax rules, JustOn allows to specify the tax rate manually.
JustOn recommends to create tax rules, because a manual input of the tax rate may result in errors.

Info

When using New Line Item from Product, JustOn takes the value from the field Product2.ON_TaxRate to specify the tax rate for the invoice line item if there are no applicable tax rules for the tenant.

Cloning Invoices

JustOn does not recalculate taxes when you use the following business processes:

  • Clone invoice
  • Clone invoice line item
  • Cancel invoice
  • Create partial credit

The tax Information on the invoice line item and the tax details are copied to the resulting records.

Determining Best Matching Rule

The best matching tax rule is determined based on the following order of precedence:

  • Account Tax Class
  • Product Tax Class
  • Invoice Region
  • Invoice Country
  • Invoice State
  • Product Group

If a rule field is empty, the field is ignored.

Assume the following configuration:

Tax Rule Account Region Account Country Product Group
Rule 1 EU Germany PG1, PG2
Rule 2 EU PG1, PG2
Rule 3 PG3

Some given values produce the following rule match:

Values Matching Rule
EU, Germany, PG1 Rule 1
EU, PG1 Rule 2
EU, France, PG2 Rule 2
PG3 Rule 3
EU, PG4 no match

Single Tax Rate per Invoice Line Item (VAT)

If you do not use the Type field on the tax rules or use rules only of the same type, JustOn determines a single best matching tax rule and copies its values directly to the invoice line item.

The fields relate in the following way:

Invoice Line Item Field Tax Rule Field Example Value
Tax Rate Tax Rate 19%
Applied Tax Rule Name Full
Tax Code Tax Code a1396
Tax Type Type VAT
Tax Provider - Internal

Multiple Tax Rates per Invoice Line Item (Sales Tax)

JustOn supports multiple tax rates per invoice line item. This allows for configuring sales taxes for countries like the United States or Canada.

To this end, you need to

For each tax rate of an invoice line item, JustOn creates a separate tax detail.

Example Tax Calculation: Sales Tax in British Columbia/Canada

Tax rules:

Name Tenant Invoice Country Invoice State Type Tax Rate Tax Code
GST CA Canada BC GST 5% a1
PST BC CA Canada BC PST 7% b2

Applying these rules, the invoice line item will have two tax details.

Resulting invoice line item:

Invoice Line Item Field Tax Rule Field Value Description
Tax Rate Tax Rate 12% The sum of the two tax rates (5%+7%=12%)
Applied Tax Rule Name GST,PST BC Comma-separated list of all applied rules (sorted alphabetically)
Tax Code Tax Code a1,b2 Comma-separated list of all tax codes (sorted alphabetically)
Tax Type Type Combined In case of tax details, always set to Combined
Tax Provider - Internal The provider that calculates the taxes.

Resulting tax detail 1:

Tax Rule Field Tax Detail Field Value
- Invoice Line Item <ID>
Type Name GST
Tax Rate Rate 5%
Name Applied Tax Rule GST
Tax Code Tax Code a1
- Provider Internal

Resulting tax detail 2:

Tax Rule Field Tax Detail Field Value
- Invoice Line Item <ID>
Type Name PST
Tax Rate Rate 7%
Name Applied Tax Rule PST
Tax Code Tax Code b2
- Provider Internal
Example Tax Rules: Sales Tax Configuration for Canada
Name Tenant Invoice Country Invoice State Type Tax Rate
GST CA Canada AB,ON,BC,MB,NT,NU,QC,SK,YT GST 5.0%
HST CA Canada NB,NL,NS,PE HST 15.0%
HST ON CA Canada ON HST ON 13.0%
PST BC CA Canada BC PST BC 7.0%
PST SK CA Canada SK PST SK 6.0%
QST CA Canada QC QST 9.975%
RST MB CA Canada MB RST MB 8.0%

Defining Tax Rules

Depending on your organization's requirements, you must define tax rules.

  1. In Setup, open Custom Settings.

    In Salesforce Lightning, navigate to Custom Code > Custom Settings.

    In Salesforce Classic, navigate to Develop > Custom Settings.

  2. Click Manage in the row of Tax Rules.

  3. Click New.
  4. Specify the details as necessary.

    See Tax Rule Concepts.

  5. Click Save.

Using Billing Address for Tax Calculation

By default, JustOn matches the fields Invoice Region, Invoice Country and Invoice State against the shipping address fields of the invoice. This is useful if you sell non-digital goods and use the shipping address fields to determine the physical location of the buyer.

If you sell digital goods, however, and use the billing address only, you can tell JustOn to match against the billing address fields:

  1. In Setup, open Custom Settings.

    In Salesforce Lightning, navigate to Custom Code > Custom Settings.

    In Salesforce Classic, navigate to Develop > Custom Settings.

  2. Click Manage in the row of Global Settings.

  3. Click Edit in the Default row.
  4. Select the checkbox Use Billing Address for Tax.
  5. Click Save.

Note

This is a global option that cannot be reversed for a single invoice, subscription or account.

Adding Tax Type to Tax Label

If multiple taxes are applied, you can add the tax type to the invoice PDF by adding the placeholder [TaxType] to the Tax Label field of the invoice template.

  1. Open the template to be edited.
  2. In the Line Items section, double-click the Tax Label field and modify the tax label as required.

    Alternatively, you can click Edit in the detail view to edit the field.

    To display, for example, the tax rate and the tax type, specify this string:

    Tax ([TaxRate] [TaxType])
    
  3. Click Save.

Displaying Tax Breakdown Table

If multiple taxes are applied, JustOn can print the tax breakdown table on the invoice PDF. This table contains one line for each applied tax rule. The amount is the sum of all taxes of the same rule. The table is sorted first by the tax type and then by the applied tax rule.

To configure the tax breakdown table display in the invoice template, use the following fields:

Field Description Default Value
Tax Table Checkbox to enable or disable the tax table display on the invoice
Tax Table Text An introductory text for the tax table The composition of the taxes is presented on the following table.
Tax Table Columns Defines the tax detail fields (API names) to be displayed as columns in the tax table, separated by semicolon.
To display the local currency, add LocalAmount.
Name;AppliedTaxRule__c;Rate__c;Amount__c

Before using the tax breakdown table, you may have to add the corresponding fields to the template layout:

  1. Navigate to the object management settings of the Template object.
  2. Click Page Layouts.
  3. In the row of Template Layout, click Edit.
  4. Drag the fields Tax Table, Tax Table Columns and Tax Table Text to the Line Items section.
  5. Click Save to save the modified page layout.

For help about modifying page layouts, see Managing Pages.

To configure the tax table display:

  1. Open the template to be edited.
  2. Click Edit in the detail view.
  3. Modify the values for Tax Table, Tax Table Text and Tax Table Columns as required.
  4. Click Save.

Setting Tax Rates on Opportunity Product, Product or Item

If there is no matching tax rule, it is still possible to set the tax rate from the opportunity product, the product or the subscription item. To do so, add the ON fields ON_TaxRate and ON_TaxClass to one of the objects.

  1. Navigate to the fields list for the intended object.
  2. Create the following new fields.

    API Name Data Type Description
    ON_TaxRate Percent (3,3) The value will be copied to the field Product Tax Rate on the invoice line item.
    ON_TaxClass Text (255) The value will be copied to the field Product Tax Class on the invoice line item.

    For help about creating fields, see Managing Object Fields.

Info

If the tax rate fields are available on multiple objects, the values defined on the opportunity product take precedence.

Using Invoice Region to Control Tax Rules

Your business may require to use individual tax rules for specific invoice regions. To do so, you determine the invoice region based on certain criteria. Consequently, you can apply the tax rule as defined for the region.

Assume the following example: There are four tax situations, for which you need individual tax rules that yield a specific tax rate.

Tax Situation Tax Rule Tax Rate Invoice Region
Germany, tax ID available or not available DE-VAT 19% DE
EU country, tax ID not available EU-VAT 19% EU
Reverse charge applicable, tax ID available RC 0% RC
Non-EU country, tax ID not available NON-EU 0% NON-EU

Now, the invoice region determines the tax rule to apply for an account. So you must identify the region based on the account's billing country.

To this end, you create the formula field ON_Region on the Account object:

  1. Navigate to the fields list for the Account object.
  2. Create the following new field.

    API Name Data Type Description
    ON_Region Formula (Text) Determines the invoice region. The produced value will be copied to the field Region on the invoice.

    For help about creating fields, see Managing Object Fields.

Following the example, you can use this formula to determine the invoice region (given that ONB2__TaxNumber__c specifies the tax ID):

IF(NOT(ISBLANK(ONB2__TaxNumber__c)),
    IF(ISPICKVAL(BillingCountryCode,"DE"), "DE", "RC"),
    CASE(TEXT(BillingCountryCode),
        "BE","EU",
        "BG","EU",
        "DE","DE",
        "DK","EU",
        "EE","EU",
        "FI","EU",
        "FR","EU",
        "GR","EU",
        "IE","EU",
        "IT","EU",
        "HR","EU",
        "LV","EU",
        "LT","EU",
        "LU","EU",
        "MT","EU",
        "NL","EU",
        "AT","EU",
        "PL","EU",
        "PT","EU",
        "RO","EU",
        "SM","EU",
        "SE","EU",
        "SK","EU",
        "SI","EU",
        "ES","EU",
        "CZ","EU",
        "HU","EU",
        "GB","EU",
        "CY","EU",
        "NON-EU")
)

Based on the billing country as defined for the account, this formula produces either DE, EU, RC or NON-EU as the value for the region.

Note

This functionality requires Salesforce's state and country picklist to be enabled for your org.

Configuring G/L Account

You can configure the G/L account to respect the fields Applied Tax Rule and Tax Code on the invoice line item.

Be aware of the following aspects:

  • The fields are not set if there is no best matching tax rule or the tax rate has been taken from the product.
  • Applied Tax Rule and Tax Code hold a comma-separated list in case of multiple taxes per line item.