ej2 / python-quickbooks

A Python library for accessing the Quickbooks API.
MIT License
407 stars 195 forks source link

Convert to Using Decimal and Fix Related Test #356

Closed laf-rge closed 4 months ago

laf-rge commented 6 months ago

This pull request changes the datatype returned from the library to Decimal where floats are returned in the current version.

Rationale:

Using Decimal ensures precise handling of financial data, which is critical for the integrity of financial applications. The json library provides support through parse_float on decode and a helper cls for encoding. I have used a monkeypatched version and decided to contribute a clean version upstream. Here is what I did:

Convert to Using Decimal with json:

UPDATE:

Changed json parsing and added a decimaldecorder helper to seamlessly convert into and out of Decimal type when encoding an decoding json.

Update Tests:

Modified the existing tests to align with the changes introduced. Specifically, fixed the test_make_request to ensure compatibility with handling of Decimal.

Changes Made:

Testing:

Additional Notes:

laf-rge commented 6 months ago

Added toggle to enable the decoding to decimals as per @justmobilize suggestion