-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #364 from laf-rge/master
handle Decimal on amount values
- Loading branch information
Showing
3 changed files
with
27 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from decimal import Decimal | ||
import unittest | ||
from quickbooks.objects.bill import Bill | ||
from quickbooks.objects.detailline import DetailLine | ||
|
||
|
||
class DecimalTestCase(unittest.TestCase): | ||
def test_bill_with_decimal_amount(self): | ||
"""Test that a Bill with decimal line amounts can be converted to JSON without errors""" | ||
bill = Bill() | ||
line = DetailLine() | ||
line.Amount = Decimal('42.42') | ||
line.DetailType = "AccountBasedExpenseLineDetail" | ||
|
||
bill.Line.append(line) | ||
|
||
# This should not raise any exceptions | ||
json_data = bill.to_json() | ||
|
||
# Verify the amount was converted correctly | ||
self.assertIn('"Amount": "42.42"', json_data) |