From b85de39cd765164d5a31836cb7ca106ad6e328a7 Mon Sep 17 00:00:00 2001 From: xengineering Date: Wed, 4 Sep 2024 20:16:15 +0200 Subject: Switch to decimal.Decimal for money Floating point data types are not suitable to represent money since rounding issues will sum up. --- finance/test_income.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'finance/test_income.py') diff --git a/finance/test_income.py b/finance/test_income.py index 0ce3507..fc75bef 100644 --- a/finance/test_income.py +++ b/finance/test_income.py @@ -1,16 +1,17 @@ from datetime import datetime +from decimal import Decimal from finance import income def test_income_integration() -> None: - inc = income.Income(amount=3000.0) + inc = income.Income(amount=Decimal(3000.0)) tests = ( - (datetime(2024, 3, 12), datetime(2024, 4, 2), 3000.0), - (datetime(2024, 3, 1), datetime(2024, 3, 15), 3000.0), - (datetime(2024, 2, 25), datetime(2024, 3, 1), 3000.0), - (datetime(2024, 2, 25), datetime(2024, 6, 12), 12000.0), + (datetime(2024, 3, 12), datetime(2024, 4, 2), Decimal(3000.0)), + (datetime(2024, 3, 1), datetime(2024, 3, 15), Decimal(3000.0)), + (datetime(2024, 2, 25), datetime(2024, 3, 1), Decimal(3000.0)), + (datetime(2024, 2, 25), datetime(2024, 6, 12), Decimal(12000.0)), ) for test in tests: -- cgit v1.2.3-70-g09d2