mirror of
https://github.com/pretix/pretix.git
synced 2026-08-08 10:27:49 +00:00
Allow more decimal places for tax rates (#6092)
* Allow more decimal places for tax rates * Fix normalization * More tax rate handling * Add uncommitted tests * Rebase migration * Update src/pretix/base/migrations/0304_tax_rate_decimals.py Co-authored-by: robbi5 <richt@rami.io> --------- Co-authored-by: robbi5 <richt@rami.io>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# This file is part of pretix (Community Edition).
|
||||
#
|
||||
# Copyright (C) 2014-2020 Raphael Michel and contributors
|
||||
# Copyright (C) 2020-today pretix GmbH and contributors
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
|
||||
# Public License as published by the Free Software Foundation in version 3 of the License.
|
||||
#
|
||||
# ADDITIONAL TERMS APPLY: Pursuant to Section 7 of the GNU Affero General Public License, additional terms are
|
||||
# applicable granting you additional permissions and placing additional restrictions on your usage of this software.
|
||||
# Please refer to the pretix LICENSE file to obtain the full terms applicable to this work. If you did not receive
|
||||
# this file, see <https://pretix.eu/about/en/license>.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
from decimal import Decimal
|
||||
|
||||
from pretix.helpers.models import _normalize_decimal
|
||||
|
||||
|
||||
def test_normalize_decimal():
|
||||
assert str(_normalize_decimal(Decimal("20.0000"))) == "20"
|
||||
assert str(_normalize_decimal(Decimal("20.0001"))) == "20.0001"
|
||||
assert str(_normalize_decimal(Decimal("20.0100"))) == "20.01"
|
||||
assert str(_normalize_decimal(Decimal("2000000.0000"))) == "2000000"
|
||||
assert str(_normalize_decimal(Decimal("0.0001"))) == "0.0001"
|
||||
@@ -189,8 +189,8 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
"current_unavailability_reason": None,
|
||||
"order_min": None,
|
||||
"max_price": None,
|
||||
"price": {"gross": "23.00", "net": "19.33", "tax": "3.67", "name": "", "rate": "19.00", "includes_mixed_tax_rate": False},
|
||||
"suggested_price": {"gross": "23.00", "net": "19.33", "tax": "3.67", "name": "", "rate": "19.00", "includes_mixed_tax_rate": False},
|
||||
"price": {"gross": "23.00", "net": "19.33", "tax": "3.67", "name": "", "rate": "19", "includes_mixed_tax_rate": False},
|
||||
"suggested_price": {"gross": "23.00", "net": "19.33", "tax": "3.67", "name": "", "rate": "19", "includes_mixed_tax_rate": False},
|
||||
"picture": None,
|
||||
"picture_fullsize": None,
|
||||
"has_variations": False,
|
||||
@@ -226,9 +226,9 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
"id": self.shirt_red.pk,
|
||||
'original_price': None,
|
||||
"price": {"gross": "14.00", "net": "11.76", "tax": "2.24", "name": "",
|
||||
"rate": "19.00", "includes_mixed_tax_rate": False},
|
||||
"rate": "19", "includes_mixed_tax_rate": False},
|
||||
"suggested_price": {"gross": "14.00", "net": "11.76", "tax": "2.24", "name": "",
|
||||
"rate": "19.00", "includes_mixed_tax_rate": False},
|
||||
"rate": "19", "includes_mixed_tax_rate": False},
|
||||
"description": None,
|
||||
"avail": [100, None],
|
||||
"order_max": 2,
|
||||
@@ -239,9 +239,9 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
"id": self.shirt_blue.pk,
|
||||
'original_price': None,
|
||||
"price": {"gross": "12.00", "net": "10.08", "tax": "1.92", "name": "",
|
||||
"rate": "19.00", "includes_mixed_tax_rate": False},
|
||||
"rate": "19", "includes_mixed_tax_rate": False},
|
||||
"suggested_price": {"gross": "12.00", "net": "10.08", "tax": "1.92", "name": "",
|
||||
"rate": "19.00", "includes_mixed_tax_rate": False},
|
||||
"rate": "19", "includes_mixed_tax_rate": False},
|
||||
"description": None,
|
||||
"avail": [100, None],
|
||||
"order_max": 2,
|
||||
@@ -278,9 +278,9 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
"current_unavailability_reason": None,
|
||||
"order_min": None,
|
||||
"max_price": None,
|
||||
"price": {"gross": "23.00", "net": "19.33", "tax": "3.67", "name": "", "rate": "19.00",
|
||||
"price": {"gross": "23.00", "net": "19.33", "tax": "3.67", "name": "", "rate": "19",
|
||||
"includes_mixed_tax_rate": False},
|
||||
"suggested_price": {"gross": "23.00", "net": "19.33", "tax": "3.67", "name": "", "rate": "19.00",
|
||||
"suggested_price": {"gross": "23.00", "net": "19.33", "tax": "3.67", "name": "", "rate": "19",
|
||||
"includes_mixed_tax_rate": False},
|
||||
"picture": None,
|
||||
"picture_fullsize": None,
|
||||
@@ -343,9 +343,9 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
"id": self.shirt_red.pk,
|
||||
'original_price': None,
|
||||
"price": {"gross": "14.00", "net": "11.76", "tax": "2.24", "name": "",
|
||||
"rate": "19.00", "includes_mixed_tax_rate": False},
|
||||
"rate": "19", "includes_mixed_tax_rate": False},
|
||||
"suggested_price": {"gross": "14.00", "net": "11.76", "tax": "2.24", "name": "",
|
||||
"rate": "19.00", "includes_mixed_tax_rate": False},
|
||||
"rate": "19", "includes_mixed_tax_rate": False},
|
||||
"description": None,
|
||||
"avail": [100, None],
|
||||
"order_max": 2,
|
||||
@@ -395,8 +395,8 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
"current_unavailability_reason": None,
|
||||
"order_min": None,
|
||||
"max_price": None,
|
||||
"price": {"gross": "23.00", "net": "19.33", "tax": "3.67", "name": "", "rate": "19.00", "includes_mixed_tax_rate": False},
|
||||
"suggested_price": {"gross": "23.00", "net": "19.33", "tax": "3.67", "name": "", "rate": "19.00", "includes_mixed_tax_rate": False},
|
||||
"price": {"gross": "23.00", "net": "19.33", "tax": "3.67", "name": "", "rate": "19", "includes_mixed_tax_rate": False},
|
||||
"suggested_price": {"gross": "23.00", "net": "19.33", "tax": "3.67", "name": "", "rate": "19", "includes_mixed_tax_rate": False},
|
||||
"picture": None,
|
||||
"picture_fullsize": None,
|
||||
"has_variations": False,
|
||||
@@ -481,7 +481,7 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
'gross': '14.00',
|
||||
'net': '11.76',
|
||||
'tax': '2.24',
|
||||
'rate': '19.00',
|
||||
'rate': '19',
|
||||
'name': '',
|
||||
'includes_mixed_tax_rate': False
|
||||
},
|
||||
@@ -489,7 +489,7 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
'gross': '14.00',
|
||||
'net': '11.76',
|
||||
'tax': '2.24',
|
||||
'rate': '19.00',
|
||||
'rate': '19',
|
||||
'name': '',
|
||||
'includes_mixed_tax_rate': False
|
||||
},
|
||||
@@ -601,7 +601,7 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
"net": "19.52",
|
||||
"tax": "3.48",
|
||||
"name": "MIXED!",
|
||||
"rate": "19.00",
|
||||
"rate": "19",
|
||||
"includes_mixed_tax_rate": True
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user