Add new fields for tax and depreciation in receipt processing

- Introduced fields: receipt_location, calculated_tax, is_depreciable, cca_rate, useful_life, and residual_value in DBReceipt model.
- Updated process_document function to handle new receipt data attributes.
- Enhanced DocumentProcessResponse schema to include new fields.
- Updated document processing rules to incorporate tax calculation based on location and depreciation rules.
This commit is contained in:
bolade
2025-10-07 11:15:26 +01:00
parent 823c05f78d
commit d8315f13ac
5 changed files with 172 additions and 23 deletions
+14
View File
@@ -410,6 +410,14 @@ async def process_document(file_id: str, db: db_dependency):
extraction_success=str(receipt_data.get("extraction_success", False)),
error_message=receipt_data.get("error"),
receipt_currency=receipt_data.get("currency"),
receipt_location=receipt_data.get("location"),
calculated_tax=receipt_data.get("calculated_tax"),
is_depreciable=str(receipt_data.get("is_depreciable"))
if receipt_data.get("is_depreciable") is not None
else None,
cca_rate=receipt_data.get("cca_rate"),
useful_life=receipt_data.get("useful_life"),
residual_value=receipt_data.get("residual_value"),
)
# Add to database
@@ -429,6 +437,12 @@ async def process_document(file_id: str, db: db_dependency):
confidence=receipt_data.get("confidence", 0.0),
error=receipt_data.get("error", None),
receipt_currency=receipt_data.get("currency"),
receipt_location=receipt_data.get("location"),
calculated_tax=receipt_data.get("calculated_tax"),
is_depreciable=receipt_data.get("is_depreciable"),
cca_rate=receipt_data.get("cca_rate"),
useful_life=receipt_data.get("useful_life"),
residual_value=receipt_data.get("residual_value"),
)
except Exception as e: