@@ -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
@@ -129,12 +129,12 @@ which determines whether the sales price should be treated as tax-excluded or ta
129129.. tabs ::
130130 .. tab :: Tax-excluded
131131
132- If :guilabel: `Included in Price ` is disabled , the computation is :math: ` \text {tax amount}
133- = \text {sales price} \times \text {tax rate}`.
132+ If :guilabel: `Included in Price ` is :guilabel: ` Tax Excluded ` , the computation is
133+ :math: ` \text {tax amount} = \text {sales price} \times \text {tax rate}`.
134134
135135 .. example ::
136136 A product has a sales price of $1000, and we apply a 10% :guilabel: `Percentage of Price `
137- tax that is not :guilabel: `Included in Price `. We then have:
137+ tax that is :guilabel: `Tax Excluded `. We then have:
138138
139139 +-------------+-------------+----------+----------+
140140 | Product | Price | Tax | Total |
@@ -145,12 +145,13 @@ which determines whether the sales price should be treated as tax-excluded or ta
145145
146146 .. tab :: Tax-included
147147
148- If :guilabel: `Included in Price ` is enabled, the computation is :math: `\text {tax amount} =
149- \text {sales price} \times \frac {\text {tax rate}}{1 + \text {tax rate}}`.
148+ If :guilabel: `Included in Price ` is :guilabel: `Tax Included `, the computation is
149+ :math: `\text {tax amount} = \text {sales price} \times \frac {\text {tax rate}}{1 +
150+ \text {tax rate}}`.
150151
151152 .. example ::
152153 A product has a sales price of $1000, and we apply a 10% :guilabel: `Percentage of Price `
153- tax that is :guilabel: `Included in Price `. We then have:
154+ tax that is :guilabel: `Tax Included `. We then have:
154155
155156 +-------------+-------------+----------+----------+
156157 | Product | Price | Tax | Total |
@@ -168,8 +169,8 @@ Percentage of price tax included
168169 This tax computation is rarely used and only useful in countries (e.g., Brazil, Bolivia) that
169170 quote tax rates as a percentage of the tax-included total.
170171 For the more common need to compute tax amounts from a tax-included price, use the
171- :ref: `Percentage of Price <taxes/computation/percentage-of-price >` tax computation with the
172- :ref: `Included in Price <taxes/included-in-price >` option .
172+ :ref: `Percentage of Price <taxes/computation/percentage-of-price >` tax computation with
173+ :ref: `Included in Price <taxes/included-in-price >` set to :guilabel: ` Tax Included ` .
173174
174175The tax rate is a percentage of the **tax-included ** total.
175176
@@ -178,12 +179,13 @@ which determines whether the sales price should be treated as tax-excluded or ta
178179
179180.. tabs ::
180181 .. tab :: Tax-excluded
181- If :guilabel: `Included in Price ` is disabled, the computation is :math: `\text {tax amount}
182- = \text {sales price} \times \frac {\text {tax rate}}{1 - \text {tax rate}}`.
182+ If :guilabel: `Included in Price ` is set to :guilabel: `Tax Excluded `, the computation is
183+ :math: `\text {tax amount} = \text {sales price} \times \frac {\text {tax rate}}{1 -
184+ \text {tax rate}}`.
183185
184186 .. example ::
185187 A product has a sales price of $1000, and we apply a 10% :guilabel: `Percentage of Price
186- Tax Included ` tax that is not :guilabel: `Included in Price `. We then have:
188+ Tax Included ` tax that is :guilabel: `Tax Excluded `. We then have:
187189
188190 +-------------+-------------+----------+----------+
189191 | Product | Price | Tax | Total |
@@ -197,12 +199,12 @@ which determines whether the sales price should be treated as tax-excluded or ta
197199
198200 .. tab :: Tax-included
199201
200- If :guilabel: `Included in Price ` is enabled, the computation is :math: ` \text {tax amount} =
201- \text {sales price} \times \text {tax rate}`.
202+ If :guilabel: `Included in Price ` is set to :guilabel: ` Tax Included `, the computation is
203+ :math: ` \text {tax amount} = \text {sales price} \times \text {tax rate}`.
202204
203205 .. example ::
204206 A product has a sales price of $1000, and we apply a 10%
205- :guilabel: `Percentage of Price Tax Included ` tax that is :guilabel: `Included in Price `.
207+ :guilabel: `Percentage of Price Tax Included ` tax that is :guilabel: `Tax Included `.
206208 We then have:
207209
208210 +-------------+-------------+----------+----------+
@@ -217,34 +219,45 @@ which determines whether the sales price should be treated as tax-excluded or ta
217219
218220.. _taxes/computation/python-code :
219221
220- Python code
221- ***********
222+ Custom formula
223+ **************
222224
223225.. important ::
224226 If a tax can be expressed as a multiple of the quantity of the product to which it applies, it
225227 can be defined as a :ref: `Fixed <taxes/computation/fixed >` tax. Doing so is strongly recommended
226- over defining a :guilabel: `Python Code ` tax.
228+ over defining a :guilabel: `Custom Formula ` tax.
227229
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.
230+ .. note ::
231+ To use :guilabel: `Custom Formula ` taxes, :ref: `install <general/install >` the :guilabel: `Define
232+ Taxes as Python Code ` (`account_python_tax `) module.
233233
234- .. example ::
235- A product has a sales price of $1000, and we apply a :guilabel: `Python Code ` tax with the
236- following configuration:
234+ For a :guilabel: `Custom Formula ` tax, the tax amount is computed according to a Python expression
235+ defined in the :guilabel: `Formula ` field. The Python expression may contain the following tokens:
236+
237+ - any of the following variables:
238+
239+ - `price_unit `: the unit price of the product
240+ - `base `: the taxable basis on which the tax is applied - may differ from the `price_unit ` if
241+ other taxes are applied first
242+ - `quantity `: the quantity of the product
243+ - `product `: the product record - product fields can also be accessed
244+
245+ - integers and floating-point numbers
237246
238- - :guilabel: `Python Code `: `result = price_unit * 0.10 ` and
239- - :guilabel: `Applicable Code `: `result = True `.
247+ - the following permitted tokens: `( `, `) `, `+ `, `- `, `* `, `/ `, `, `, `< `, `> `, `<= `, `>= `, `and `,
248+ `or `, `None `, `min `, and `max `
249+
250+ .. example ::
251+ A product has a sales price of $1000, and we apply a :guilabel: `Custom Formula ` tax with a
252+ :guilabel: `Formula ` of `max(base, 500) * 0.10 + min(base - 500, 0) * 0.20 `
240253
241254 We then have:
242255
243256 +-------------+-------------+----------+----------+
244257 | Product | Price | Tax | Total |
245258 | sales price | without tax | | |
246259 +=============+=============+==========+==========+
247- | 1,000 | 1,000 | 100 | 1,100 .00 |
260+ | 1,000 | 1,000 | 150 | 1,150 .00 |
248261 +-------------+-------------+----------+----------+
249262
250263.. _taxes/active :
@@ -405,16 +418,25 @@ invoice line.
405418Included in price
406419~~~~~~~~~~~~~~~~~
407420
408- With this option activated, the tax will treat the sales price on which it is applied as a total
409- including the tax amount. The tax computation will split the sales price into a base amount and a
410- tax amount. This makes it suitable for B2C sales in most countries where prices are quoted
411- tax-inclusive.
421+ .. tip ::
422+ To set a company-wide default for this setting, go to :menuselection: `Accounting -->
423+ Configuration --> Settings `, find the :guilabel: `Taxes ` section, and set the :guilabel: `Prices `
424+ setting to :guilabel: `Tax Excluded ` or :guilabel: `Tax Included `. This setting cannot be changed
425+ once invoices have been created.
426+
427+ When set to :guilabel: `Default `, the company-wide default will be used.
428+
429+ When set to :guilabel: `Tax Excluded `, the tax will always treat the sales price on which it is
430+ applied as a price excluding the tax amount.
412431
413- `Total = Sales Price = Computed Tax-Excluded price + Tax `
432+ When set to :guilabel: `Tax Included `, the tax will always treat the sales price on which it is
433+ applied as a total including the tax amount. The tax computation will split the sales price into a
434+ base amount and a tax amount. This makes it suitable for B2C sales in most countries where prices
435+ are quoted tax-inclusive.
414436
415437.. example ::
416438 A product has a sales price of $1000, and we apply a 10% :guilabel: `Percentage of Price ` tax
417- with :guilabel: `Included in Price `. We then have:
439+ with :guilabel: `Included in Price ` set to :guilabel: ` Tax Included ` . We then have:
418440
419441 +-------------+-------------+----------+----------+
420442 | Product | Price | Tax | Total |
@@ -427,23 +449,21 @@ tax-inclusive.
427449 For a guide on configuring tax-excluded and tax-included prices for B2B and B2C customers,
428450 see :doc: `taxes/B2B_B2C `.
429451
430- .. image :: taxes/toggle-button.png
431-
432452.. _taxes/base-subsequent :
433453
434454Affect base of subsequent taxes
435455~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
436456
437457If this setting is enabled, any subsequent tax applied on the same product line that has
438458:ref: `taxes/base-affected ` will be based on a modified sales price. The exact behavior depends on
439- whether the tax with :guilabel: ` Affect base of subsequent taxes` is :ref: ` taxes /included-in-price`
440- or not .
459+ the :ref: ` Included in Price < taxes/included-in-price >` setting of the tax with :guilabel: ` Affect
460+ base of subsequent taxes ` .
441461
442462.. tabs ::
443463 .. tab :: Tax-excluded
444- If :guilabel: `Included in Price ` is disabled, subsequent taxes with :guilabel: `Base affected
445- by preceding taxes ` will be based on a modified sales price equal to the original sales price
446- plus the tax amount.
464+ If :guilabel: `Included in Price ` is set to :guilabel: `Tax Excluded `, subsequent taxes with
465+ :guilabel: ` Base affected by preceding taxes ` will be based on a modified sales price equal to
466+ the original sales price plus the tax amount.
447467
448468 .. example ::
449469 A product has a sales price of $1000, and we apply a 10% :guilabel: `Percentage of Price `
@@ -452,13 +472,13 @@ or not.
452472 $1100.
453473
454474 .. tab :: Tax-included
455- If :guilabel: `Included in Price ` is enabled, subsequent taxes with :guilabel: `Base affected
456- by preceding taxes ` will be based on a modified sales price equal to the original sales price
457- minus the tax amount.
475+ If :guilabel: `Included in Price ` is set to :guilabel: `Tax Included `, subsequent taxes with
476+ :guilabel: ` Base affected by preceding taxes ` will be based on a modified sales price equal to
477+ the original sales price minus the tax amount.
458478
459479 .. example ::
460480 A product has a sales price of $1100, and we apply a 10% :guilabel: `Percentage of Price `
461- tax with :guilabel: `Included in Price ` and :guilabel: `Affect base of subsequent taxes `.
481+ tax that has :guilabel: `Tax Included ` and :guilabel: `Affect base of subsequent taxes `.
462482 Any subsequent tax with :guilabel: `Base affected by preceding taxes ` will be based on a
463483 modified sales price of $1000.
464484
0 commit comments