gava-connect-plus v0.2.1
Release Notes - v0.2.1
Overview
Bug fix release addressing Pydantic validation errors and JSON serialization issues in the KRA invoice checker library.
Fixes
1. Nullable Field Validation Error
Issue: Pydantic validation was failing with Input should be a valid string error when the KRA API returned null values for optional fields.
Fix: Updated InvoiceDetails model to make the following fields Optional[str]:
customer_pincustomer_nameexemption_certificate_notrader_system_invoice_numberrelevant_invoice_daterelevant_invoice_number
These fields now correctly accept null values per KRA API documentation.
2. Decimal Serialization Error
Issue: JSON serialization was failing with Object of type Decimal is not JSON serializable when calling json.dumps() on invoice records containing monetary values.
Fix:
- Configured monetary fields (
total_invoice_amount,total_taxable_amount,total_tax_amount,total_discount_amount) to useDecimaltype for precision. - Added
model_config = ConfigDict(json_encoders={Decimal: str})toInvoiceDetailsmodel to serializeDecimalobjects as strings, preventing floating-point precision loss. - Updated client-side serialization to use
model_dump_json(indent=4)instead ofjson.dumps(record.model_dump())to respect Pydantic's JSON encoder configuration.
Migration Guide
If you're serializing invoice responses, update your code:
Before:
json.dumps(record.model_dump(), indent=4)After
record.model_dump_json(indent=4)Tested With
- Pydantic v2
- httpx (with 20s timeout)
- KRA API Sandbox