@@ -81,7 +81,7 @@ price. The following options are available:
8181 tax-excluded sales price
8282- :ref: `Percentage of Price Tax Included <taxes/computation/percentage-of-price-tax-included >`: a
8383 percentage of the tax-included total
84- - :ref: `Python Code <taxes/computation/python-code >`: a custom user-defined formula
84+ - :ref: `Custom Formula <taxes/computation/python-code >`: a custom user-defined formula
8585
8686.. _taxes/computation/group-of-taxes :
8787
@@ -217,34 +217,45 @@ which determines whether the sales price should be treated as tax-excluded or ta
217217
218218.. _taxes/computation/python-code :
219219
220- Python code
221- ***********
220+ Custom formula
221+ **************
222222
223223.. important ::
224224 If a tax can be expressed as a multiple of the quantity of the product to which it applies, it
225225 can be defined as a :ref: `Fixed <taxes/computation/fixed >` tax. Doing so is strongly recommended
226- over defining a :guilabel: `Python Code ` tax.
226+ over defining a :guilabel: `Custom Formula ` tax.
227+
228+ .. note ::
229+ To use :guilabel: `Custom Formula ` taxes, :ref: `install <general/install >` the :guilabel: `Define
230+ Taxes as Python Code ` (`account_python_tax `) module.
227231
228- A tax defined as :guilabel: `Python Code ` consists of two snippets of Python code that are executed
229- in a local environment that can access the unit price, quantity, product, and partner.
230- :guilabel: `Python Code ` defines the amount of the tax, and :guilabel: `Applicable Code ` defines
231- whether the tax is applied. Enter a formula for each field at the bottom of the
232- :guilabel: `Definition ` tab.
232+ For a :guilabel: `Custom Formula ` tax, the tax amount is computed according to a Python expression
233+ defined in the :guilabel: `Formula ` field. The Python expression may contain the following tokens:
233234
234- .. example ::
235- A product has a sales price of $1000, and we apply a :guilabel: `Python Code ` tax with the
236- following configuration:
235+ - any of the following variables:
237236
238- - :guilabel: `Python Code `: `result = price_unit * 0.10 ` and
239- - :guilabel: `Applicable Code `: `result = True `.
237+ - `price_unit `: the unit price of the product
238+ - `base `: the taxable basis on which the tax is applied - may differ from the `price_unit ` if
239+ other taxes are applied first
240+ - `quantity `: the quantity of the product
241+ - `product `: the product record - product fields can also be accessed
242+
243+ - integers and floating-point numbers
244+
245+ - the following permitted tokens: `( `, `) `, `+ `, `- `, `* `, `/ `, `, `, `< `, `> `, `<= `, `>= `, `and `,
246+ `or `, `None `, `min `, and `max `
247+
248+ .. example ::
249+ A product has a sales price of $1000, and we apply a :guilabel: `Custom Formula ` tax with a
250+ :guilabel: `Formula ` of `max(base, 500) * 0.10 + min(base - 500, 0) * 0.20 `
240251
241252 We then have:
242253
243254 +-------------+-------------+----------+----------+
244255 | Product | Price | Tax | Total |
245256 | sales price | without tax | | |
246257 +=============+=============+==========+==========+
247- | 1,000 | 1,000 | 100 | 1,100 .00 |
258+ | 1,000 | 1,000 | 150 | 1,150 .00 |
248259 +-------------+-------------+----------+----------+
249260
250261.. _taxes/active :
@@ -365,10 +376,21 @@ invoice line.
365376Included in price
366377~~~~~~~~~~~~~~~~~
367378
368- With this option activated, the tax will treat the sales price on which it is applied as a total
369- including the tax amount. The tax computation will split the sales price into a base amount and a
370- tax amount. This makes it suitable for B2C sales in most countries where prices are quoted
371- tax-inclusive.
379+ .. tip ::
380+ To set a company-wide default for this setting, go to :menuselection: `Accounting -->
381+ Configuration --> Settings `, find the :guilabel: `Taxes ` section, and set the :guilabel: `Prices `
382+ setting to :guilabel: `Tax Excluded ` or :guilabel: `Tax Included `. This setting cannot be changed
383+ once invoices have been created.
384+
385+ When set to :guilabel: `Tax Included `, the tax will always treat the sales price on which it is
386+ applied as a total including the tax amount. The tax computation will split the sales price into a
387+ base amount and a tax amount. This makes it suitable for B2C sales in most countries where prices
388+ are quoted tax-inclusive.
389+
390+ When set to :guilabel: `Tax Excluded `, the tax will always treat the sales price on which it is
391+ applied as a price excluding the tax amount.
392+
393+ When set to :guilabel: `Default `, the company-wide default will be used.
372394
373395`Total = Sales Price = Computed Tax-Excluded price + Tax `
374396
@@ -387,8 +409,6 @@ tax-inclusive.
387409 For a guide on configuring tax-excluded and tax-included prices for B2B and B2C customers,
388410 see :doc: `taxes/B2B_B2C `.
389411
390- .. image :: taxes/toggle-button.png
391-
392412.. _taxes/base-subsequent :
393413
394414Affect base of subsequent taxes
0 commit comments