fix: Convert Decimal to float for JSONB serialization in KRS audit
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
a909af4754
commit
3069a232ca
14
app.py
14
app.py
@ -8782,7 +8782,19 @@ def api_krs_audit_trigger():
|
||||
audit.prokurenci_count = len(parsed_data.get('prokurenci', []))
|
||||
audit.pkd_count = 1 if parsed_data.get('pkd_przewazajacy') else 0
|
||||
audit.pkd_count += len(parsed_data.get('pkd_pozostale', []))
|
||||
audit.parsed_data = parsed_data
|
||||
|
||||
# Convert Decimal values to float for JSON serialization
|
||||
def decimal_to_float(obj):
|
||||
from decimal import Decimal
|
||||
if isinstance(obj, Decimal):
|
||||
return float(obj)
|
||||
elif isinstance(obj, dict):
|
||||
return {k: decimal_to_float(v) for k, v in obj.items()}
|
||||
elif isinstance(obj, list):
|
||||
return [decimal_to_float(i) for i in obj]
|
||||
return obj
|
||||
|
||||
audit.parsed_data = decimal_to_float(parsed_data)
|
||||
audit.pdf_downloaded_at = datetime.now()
|
||||
|
||||
# Update company with parsed data
|
||||
|
||||
Loading…
Reference in New Issue
Block a user