mirror of
https://github.com/pretix/pretix-servicefees.git
synced 2025-04-17 13:32:36 +02:00
Fix fee_calc tax-splitting with products having no tax-rule
This commit is contained in:
commit
0f81aa42dd
1 changed files with 11 additions and 6 deletions
|
@ -141,21 +141,26 @@ def get_fees(
|
|||
if split_taxes:
|
||||
# split taxes based on products ordered
|
||||
d = defaultdict(lambda: Decimal("0.00"))
|
||||
trs = {}
|
||||
for p in positions:
|
||||
if isinstance(p, CartPosition):
|
||||
tr = p.item.tax_rule
|
||||
else:
|
||||
tr = p.tax_rule
|
||||
d[tr] += p.price - p.tax_value
|
||||
if not tr:
|
||||
tr = tax_rule_zero
|
||||
# use tr.pk as key as tax_rule_zero is not hashable
|
||||
d[tr.pk] += p.price - p.tax_value
|
||||
trs[tr.pk] = tr
|
||||
|
||||
base_values = sorted([tuple(t) for t in d.items()], key=lambda t: t[0].rate)
|
||||
sum_base = sum(t[1] for t in base_values)
|
||||
base_values = sorted([(trs[key], value) for key, value in d.items()], key=lambda t: t[0].rate)
|
||||
sum_base = sum(value for key, value in base_values)
|
||||
if sum_base:
|
||||
fee_values = [
|
||||
(t[0], round_decimal(fee * t[1] / sum_base, event.currency))
|
||||
for t in base_values
|
||||
(key, round_decimal(fee * value / sum_base, event.currency))
|
||||
for key, value in base_values
|
||||
]
|
||||
sum_fee = sum(t[1] for t in fee_values)
|
||||
sum_fee = sum(value for key, value in fee_values)
|
||||
|
||||
# If there are rounding differences, we fix them up, but always leaning to the benefit of the tax
|
||||
# authorities
|
||||
|
|
Loading…
Add table
Reference in a new issue