Skip to content

Commit 49ccc20

Browse files
committed
Merge branch 'develop'
2 parents a1c9c0b + b57fdf2 commit 49ccc20

File tree

4 files changed

+72
-9
lines changed

4 files changed

+72
-9
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.7.2] - 2025-05-08
11+
12+
### Fixed
13+
14+
- Increase decimal rounding accuracy ([dc4b8a4](https://github.com/City-of-Helsinki/parking-permits/commit/dc4b8a4e0b0c5bad86ee35af55b53854544b2e91))
15+
1016
## [1.7.1] - 2025-05-01
1117

1218
### Fixed

parking_permits/tests/models/test_product.py

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def test_get_talpa_pricing(self):
109109
"vat_percentage": "25.50",
110110
}
111111

112-
def test_get_talpa_pricing_prev_vat(self):
112+
def test_get_talpa_pricing_other_vat(self):
113113
product = ProductFactory(
114114
unit_price=Decimal(20),
115115
vat=0.24,
@@ -125,18 +125,74 @@ def test_get_talpa_pricing_prev_vat(self):
125125
def test_get_talpa_pricing_with_discount(self):
126126
product = ProductFactory(
127127
unit_price=Decimal(60),
128-
low_emission_discount=Decimal(0.5),
128+
low_emission_discount=Decimal(0.25),
129+
vat=0.255,
130+
)
131+
pricing = product.get_talpa_pricing(True, False)
132+
assert pricing == {
133+
"price_gross": "45.00",
134+
"price_net": "35.86",
135+
"price_vat": "9.14",
136+
"vat_percentage": "25.50",
137+
}
138+
139+
def test_get_talpa_pricing_with_secondary_vehicle(self):
140+
product = ProductFactory(
141+
unit_price=Decimal(60),
142+
low_emission_discount=Decimal(0.25),
143+
vat=0.255,
144+
)
145+
pricing = product.get_talpa_pricing(False, True)
146+
assert pricing == {
147+
"price_gross": "90.00",
148+
"price_net": "71.71",
149+
"price_vat": "18.29",
150+
"vat_percentage": "25.50",
151+
}
152+
153+
def test_get_talpa_pricing_with_discount_secondary_vehicle(self):
154+
product = ProductFactory(
155+
unit_price=Decimal(60),
156+
low_emission_discount=Decimal(0.25),
157+
vat=0.255,
158+
)
159+
pricing = product.get_talpa_pricing(True, True)
160+
assert pricing == {
161+
"price_gross": "67.50",
162+
"price_net": "53.78",
163+
"price_vat": "13.72",
164+
"vat_percentage": "25.50",
165+
}
166+
167+
def test_get_talpa_pricing_with_precise_discount(self):
168+
product = ProductFactory(
169+
unit_price=Decimal(64.50),
170+
low_emission_discount=Decimal(0.2496124031),
129171
vat=0.255,
130172
)
131173
pricing = product.get_talpa_pricing(True, False)
132174
assert pricing == {
133-
"price_gross": "30.00",
134-
"price_net": "23.90",
135-
"price_vat": "6.10",
175+
"price_gross": "48.40",
176+
"price_net": "38.57",
177+
"price_vat": "9.83",
178+
"vat_percentage": "25.50",
179+
}
180+
181+
def test_get_talpa_pricing_with_precise_discount_secondary_vehicle(self):
182+
product = ProductFactory(
183+
unit_price=Decimal(64.50),
184+
low_emission_discount=Decimal(0.2496124031),
185+
vat=0.255,
186+
)
187+
pricing = product.get_talpa_pricing(True, True)
188+
assert pricing == {
189+
"price_gross": "72.60",
190+
"price_net": "57.85",
191+
"price_vat": "14.75",
136192
"vat_percentage": "25.50",
137193
}
138194

139-
def test_get_talpa_pricing_with_discount_prev_vat(self):
195+
def test_get_talpa_pricing_with_discount_other_vat(self):
140196
product = ProductFactory(
141197
unit_price=Decimal(20),
142198
low_emission_discount=Decimal(0.5),

parking_permits/tests/services/test_talpa.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
pytest.param(0, "0.00", "0.00", "0.00", id="gross: 0"),
1616
pytest.param(30, "30.00", "23.90", "6.10", id="gross: 30"),
1717
pytest.param(30.50, "30.50", "24.30", "6.20", id="gross: 30.50"),
18+
pytest.param(48.40, "48.40", "38.57", "9.83", id="gross: 48.50"),
1819
pytest.param(60, "60.00", "47.81", "12.19", id="gross: 60"),
1920
pytest.param(100, "100.00", "79.68", "20.32", id="gross: 100"),
2021
pytest.param(120, "120.00", "95.62", "24.38", id="gross: 120"),
@@ -38,8 +39,8 @@ def test_add_pricing():
3839
total_pricing += Pricing.calculate(120, 0.255)
3940

4041
assert total_pricing.format_gross() == "180.00"
41-
assert total_pricing.format_net() == "143.42"
42-
assert total_pricing.format_vat() == "36.58"
42+
assert total_pricing.format_net() == "143.43"
43+
assert total_pricing.format_vat() == "36.57"
4344

4445

4546
class TestTalpaOrderManager(TestCase):

parking_permits/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ def calc_vat_price(gross_price: Currency, vat: Currency) -> Decimal:
423423

424424

425425
def quantize(value) -> Decimal:
426-
return Decimal(value or 0).quantize(Decimal(".001"), rounding=ROUND_UP)
426+
return Decimal(value or 0).quantize(Decimal(".0001"), rounding=ROUND_UP)
427427

428428

429429
def format_currency(value) -> str:

0 commit comments

Comments
 (0)