Actions

## Bug #8485

closed  ### Tax rule "A fixed amount added/substracted from the item price, plus a percentage" does not function correctly

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
28 April 2021
Due date:
% Done:

100%

Estimated time:

Description

This tax rule functions the same as "A percentage of the item price, added/substracted by a fixed amount" instead of as described. It should behave as following for example.

Item Price: 100
Fixed Amount: -75
Percentage: 5%

Math: 100 - 75 = 25 * 0.05 = 1.25

So our tax would be \$1.25 as we're only taxing \$25 of the \$100 since we want to ignore the first \$75.

Actions #1

#### Updated by beatabout 1 year ago

• Description updated (diff)
• Status changed from New to Assigned
• Assignee set to beat
Actions #2

#### Updated by beatabout 1 year ago

• % Done changed from 0 to 70

commit 4557d62ddc41a34933797d525fbfc75d957b4340 fixes the bug that both settings had same result with non-autorecurring baskets.

commit e95ec5be4f195994105fa932285b191924e9c71b clarifies the 2 settings for amount+tax and tax+amount for taxes:

- A fixed amount A, plus a percentage R of the item price P (A+(R*P))
- A fixed amount A, plus a percentage R of the sum of the item price P and of the fixed amount A (A+(R*(P+A)))

To implement the above use-case, following settings are working already fine, without this fix too:

A. Create a tax rule for your special partly taxed items
B. Create 4 tax rates, assigned to your tax rules:
1. Priority 1: remove fixed amount of 75 (fixed amount of -75)
2. Priority 2 (ordering: first of priority 2 for that tax rule): add federal tax of 8%
3. Priority 2 (if the local tax applies on same amount as federal tax, otherwise choose different priority): province tax
4. Priority 3: Add back the removed 75 (fixed amount of 75)

I am leaving this bug open, as I need to test the cases of auto-recurring baskets with same or different initial prices before closing this bug.

Actions #3

## Complement of explanations:¶

The general taxes and promotions compounder formula is:

```(P+B)*(1+R)+A - P
```

where:

- P is the item Price
- B is the amount Before
- R is the rate in computed percents
- A is the amount After

The different settings are for:

1. R (with A=0 and B=0) for Percentage R setting
2. A (with R=0 and B=0) for Amount A setting
3. A and R (with B=0) for "A fixed amount A, plus a percentage R of the item price P (A+(R*P))" setting
4. B and R (with A=0) for "A fixed amount A, plus a percentage R of the sum of the item price P and of the fixed amount A (A+(R*(P+A)))" setting
5. B or R (never both same time, so when B is used then R=0, and always A=0) for "A fixed amount or percentage depending on the corresponding items price" setting

So with case 3 we have with B=0_

```(P*(1+R)+A)-P
P + PR + A -P
PR + A
```

And for case 4 we have with A=0 (and in text above "A" is "B" in the generic formula:

``````
(P + B) * (1 + R) - P
P + PR + B + BR - p
PR + B  + BR
PR + B(1+R)
B+R(P+B)
``````
Actions #4

### To reply to the question:¶

Can't we do a part of the price not taxed with a single tax rate ?

Wanted (S is the tax Percentage ("R" renamed here to "S"):

```S(P+C)
```

### 1st method to transform the formula into generic compounder:¶

```(P+B)*(1+S)+A - P
```

Developing:

```S(P+C)
P+S(P+C) -P
S(P+C)+P -P
(P+C)*S+P -P
(P+C)*(1 + (S-1) +P -P
```

In our generic compounder, we would need to have:

```B=C
R=S-1
A=P
```

### Another way to achieve same:¶

```(P+C)S
P + (P+C) S -P
P(1+S) + SC - P
```

In that case:

```B=0
R=S
A=SC
```

### Check with an example:¶

E.g. Wanted 5% tax on 200-70 = 130, means 130*0.05=6.50.

We have P=200, S=5%, C=-70:

1st method:

Applying it to:

```(P+C)*(1 + (S-1)) +P -P
```

gives:

```(200+(-70))*(1+(0.05-1))+200-200 = 6.5
```

2nd method:

Applying it to:

```P(1+S) + SC - P
```

gives:

```200*(1+0.05) + (-70*0.05) - 200 = 6.50
```

So that would work, but would be yet a new mode.

However, in case of promotions, it could be useful, so tempted to implement it as a new feature.

Actions #5

#### Updated by beatabout 1 year ago

• Status changed from Assigned to Resolved
• % Done changed from 70 to 100
Actions #6

#### Updated by beatabout 1 year ago

• Status changed from Resolved to Closed
Actions

Also available in: Atom PDF