Enhance tax extraction rules in DocumentProcessor to clarify handling of explicit and unclear tax amounts on receipts

This commit is contained in:
bolade
2025-10-07 12:44:27 +01:00
parent b2bf631448
commit 5116fb5efb
+14 -7
View File
@@ -97,7 +97,12 @@ class DocumentProcessor:
- Format location as "Province/State, Country" (e.g., "Ontario, Canada" or "California, USA")
- If location not shown on receipt, return null for location (system will use user location as fallback)
- If tax_amount is NOT clearly shown on receipt, calculate it based on location:
TAX EXTRACTION RULES (IMPORTANT):
- If tax is EXPLICITLY shown on receipt (even if $0 or 0%), use that exact value:
* If receipt shows "Tax: $0", "Tax: $0.00", "Tax (0%)", or similar → set tax_amount to 0.00 and calculated_tax to null
* If receipt shows any other tax amount → set tax_amount to that value and calculated_tax to null
- If tax_amount is NOT shown or UNCLEAR on receipt, calculate it based on location:
* Ontario, Canada: 13% HST
* Quebec, Canada: 9.975% QST + 5% GST = 14.975% total
* British Columbia, Canada: 12% (5% GST + 7% PST)
@@ -106,9 +111,7 @@ class DocumentProcessor:
* New York, USA: ~8.875% (varies by locality)
* Texas, USA: 6.25%
* For other locations, estimate based on typical rates
- Store calculated tax in "calculated_tax" field (set to null if tax clearly shown)
- If tax is clearly shown on receipt, use that value for tax_amount and set calculated_tax to null
- If tax is clearly shown on the receipt as 0%, set tax_amount to 0 and calculated_tax to null
* Store calculated tax in "calculated_tax" field and set tax_amount to the calculated value
DEPRECIATION RULES:
- Determine if item is a depreciable asset (vehicles, machinery, equipment, computers, furniture, buildings)
@@ -250,7 +253,12 @@ class DocumentProcessor:
- Format location as "Province/State, Country" (e.g., "Ontario, Canada" or "California, USA")
- If location not shown on receipt, return null for location (system will use user location as fallback)
- If tax_amount is NOT clearly shown on receipt, calculate it based on location:
TAX EXTRACTION RULES (IMPORTANT):
- If tax is EXPLICITLY shown on receipt (even if $0 or 0%), use that exact value:
* If receipt shows "Tax: $0", "Tax: $0.00", "Tax (0%)", or similar → set tax_amount to 0.00 and calculated_tax to null
* If receipt shows any other tax amount → set tax_amount to that value and calculated_tax to null
- If tax_amount is NOT shown or UNCLEAR on receipt, calculate it based on location:
* Ontario, Canada: 13% HST
* Quebec, Canada: 9.975% QST + 5% GST = 14.975% total
* British Columbia, Canada: 12% (5% GST + 7% PST)
@@ -259,8 +267,7 @@ class DocumentProcessor:
* New York, USA: ~8.875% (varies by locality)
* Texas, USA: 6.25%
* For other locations, estimate based on typical rates
- Store calculated tax in "calculated_tax" field (set to null if tax clearly shown)
- If tax is clearly shown on receipt, use that value for tax_amount and set calculated_tax to null
* Store calculated tax in "calculated_tax" field and set tax_amount to the calculated value
DEPRECIATION RULES:
- Determine if item is a depreciable asset (vehicles, machinery, equipment, computers, furniture, buildings)