Table Sum Validation
What does this script do?
Trigger
Full Script
table = tables_dict.get("INVOICE_TABLE")
if table:
# Calculate sum of all line totals
total = 0
for row in table["rows"]:
line_total = get_column_value(row, "LINE_TOTAL", "0")
try:
total += float(line_total)
except ValueError:
pass
# Compare with extracted net amount
net_amount = get_field_value(document_data, "net_amount", "0")
try:
if abs(float(net_amount) - total) > 0.01:
# Line sum differs from header — update net amount
set_amount_value(document_data, "net_amount", str(round(total, 2)))
except ValueError:
passVariation: Mark as invalid instead of overwriting
Step-by-Step Explanation
Functions Used
Last updated
Was this helpful?