forked from CGM_Public/pretix_original
More tax rate handling
This commit is contained in:
@@ -66,11 +66,14 @@ def _normalize_decimal(d: Decimal) -> Decimal:
|
|||||||
20.010 → 20.01
|
20.010 → 20.01
|
||||||
20.100 → 20.1
|
20.100 → 20.1
|
||||||
|
|
||||||
But unlike of Decimal.normalize(), 20.000 will not become 2e+1
|
But unlike of Decimal.normalize(), 20.000 will not become 2e+1. Very small decimals might still be represented
|
||||||
|
in scientific notation when printed.
|
||||||
"""
|
"""
|
||||||
normalized = d.normalize()
|
normalized = d.normalize()
|
||||||
sign, digit, exponent = normalized.as_tuple()
|
sign, digit, exponent = normalized.as_tuple()
|
||||||
return normalized if exponent <= 0 else normalized.quantize(1)
|
if exponent > 0:
|
||||||
|
return normalized.quantize(1)
|
||||||
|
return normalized
|
||||||
|
|
||||||
|
|
||||||
class NormalizedDecimalField(DecimalField):
|
class NormalizedDecimalField(DecimalField):
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ from decimal import Decimal
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.db.models import F, Sum
|
from django.db.models import F, Sum
|
||||||
from django.db.models.functions import Coalesce
|
from django.db.models.functions import Coalesce
|
||||||
from django.utils.formats import date_format, localize
|
from django.utils.formats import date_format
|
||||||
from django.utils.html import escape
|
from django.utils.html import escape
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
from django.utils.translation import gettext as _, gettext_lazy, pgettext_lazy
|
from django.utils.translation import gettext as _, gettext_lazy, pgettext_lazy
|
||||||
@@ -43,7 +43,7 @@ from pretix.base.exporter import BaseExporter
|
|||||||
from pretix.base.models import (
|
from pretix.base.models import (
|
||||||
GiftCardTransaction, OrderFee, OrderPayment, OrderRefund, Transaction,
|
GiftCardTransaction, OrderFee, OrderPayment, OrderRefund, Transaction,
|
||||||
)
|
)
|
||||||
from pretix.base.templatetags.money import money_filter
|
from pretix.base.templatetags.money import money_filter, tax_rate_format
|
||||||
from pretix.base.timeframes import (
|
from pretix.base.timeframes import (
|
||||||
DateFrameField,
|
DateFrameField,
|
||||||
resolve_timeframe_to_datetime_start_inclusive_end_exclusive,
|
resolve_timeframe_to_datetime_start_inclusive_end_exclusive,
|
||||||
@@ -382,7 +382,7 @@ class ReportExporter(ReportlabExportMixin, BaseExporter):
|
|||||||
else "",
|
else "",
|
||||||
tstyle_right,
|
tstyle_right,
|
||||||
),
|
),
|
||||||
Paragraph(localize(r["tax_rate"].normalize()) + " %", tstyle_right),
|
Paragraph(tax_rate_format(r["tax_rate"]) + " %", tstyle_right),
|
||||||
Paragraph(str(r["sum_cont"]), tstyle_right),
|
Paragraph(str(r["sum_cont"]), tstyle_right),
|
||||||
Paragraph(
|
Paragraph(
|
||||||
money_filter(r["sum_price"] - r["sum_tax"], currency), tstyle_right
|
money_filter(r["sum_price"] - r["sum_tax"], currency), tstyle_right
|
||||||
@@ -408,7 +408,7 @@ class ReportExporter(ReportlabExportMixin, BaseExporter):
|
|||||||
[
|
[
|
||||||
FontFallbackParagraph(_("Sum"), tstyle),
|
FontFallbackParagraph(_("Sum"), tstyle),
|
||||||
Paragraph("", tstyle_right),
|
Paragraph("", tstyle_right),
|
||||||
Paragraph(localize(tax_rate.normalize()) + " %", tstyle_right),
|
Paragraph(tax_rate_format(tax_rate) + " %", tstyle_right),
|
||||||
Paragraph("", tstyle_right),
|
Paragraph("", tstyle_right),
|
||||||
Paragraph(
|
Paragraph(
|
||||||
money_filter(
|
money_filter(
|
||||||
|
|||||||
Reference in New Issue
Block a user