Skip to content

Commit 91cc6d4

Browse files
committed
Added simple test for decimal amounts in Bill
1 parent 248104f commit 91cc6d4

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/unit/test_decimal.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from decimal import Decimal
2+
import unittest
3+
from quickbooks.objects.bill import Bill
4+
from quickbooks.objects.detailline import DetailLine
5+
6+
7+
class DecimalTestCase(unittest.TestCase):
8+
def test_bill_with_decimal_amount(self):
9+
"""Test that a Bill with decimal line amounts can be converted to JSON without errors"""
10+
bill = Bill()
11+
line = DetailLine()
12+
line.Amount = Decimal('42.42')
13+
line.DetailType = "AccountBasedExpenseLineDetail"
14+
15+
bill.Line.append(line)
16+
17+
# This should not raise any exceptions
18+
json_data = bill.to_json()
19+
20+
# Verify the amount was converted correctly
21+
self.assertIn('"Amount": "42.42"', json_data)

0 commit comments

Comments
 (0)