Refactor document processing endpoint to accept file_id as a path parameter and update related logic; modify DocumentProcessRequest to make file_id optional; add clarification to tax processing rules in DocumentProcessor.

This commit is contained in:
bolade
2025-10-07 12:36:04 +01:00
parent 659ca4ff15
commit b2bf631448
4 changed files with 26 additions and 25 deletions
+1
View File
@@ -108,6 +108,7 @@ class DocumentProcessor:
* 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
DEPRECIATION RULES:
- Determine if item is a depreciable asset (vehicles, machinery, equipment, computers, furniture, buildings)
+15 -15
View File
@@ -51,22 +51,22 @@ class MatchingEngine:
enhanced_matches = self._apply_manual_tax_analysis(
ai_matches, user_location
)
else:
# Use LLM-based tax analysis in a SINGLE batch call
try:
enhanced_matches = (
self.llm_tax_analyzer.analyze_and_apply_tax_rules_batch(
ai_matches, user_location
)
)
except Exception as e:
# If batch LLM analysis fails, log it and continue with matches as-is
import logging
# else:
# # Use LLM-based tax analysis in a SINGLE batch call
# try:
# enhanced_matches = (
# self.llm_tax_analyzer.analyze_and_apply_tax_rules_batch(
# ai_matches, user_location
# )
# )
# except Exception as e:
# # If batch LLM analysis fails, log it and continue with matches as-is
# import logging
logging.error(f"Batch LLM tax analysis failed: {str(e)}")
for match in ai_matches:
match.match_reason += " (Note: Advanced tax analysis unavailable)"
enhanced_matches = ai_matches
# logging.error(f"Batch LLM tax analysis failed: {str(e)}")
# for match in ai_matches:
# match.match_reason += " (Note: Advanced tax analysis unavailable)"
# enhanced_matches = ai_matches
return enhanced_matches