table = tables_dict.get("INVOICE_TABLE")
if table:
add_table_column(table, "TAX_CODE", "S1")
# Ora impostare i valori per ogni riga
for row in table["rows"]:
amount = float(get_column_value(row, "LINE_TOTAL", "0"))
if amount == 0:
set_column_value(row, "TAX_CODE", "Z0")
# Mantenere solo la 3a riga
remove_all_rows_except_one_from_table(document_data, 3)
delete_tables(document_data)
# Eliminare le tabelle (es. per fatture di costo senza voci)
delete_tables(document_data)
restore_tables(document_data)
restore_tables(document_data)
table = tables_dict.get("INVOICE_TABLE")
total = 0
if table:
for row in table["rows"]:
val = get_column_value(row, "LINE_TOTAL", "0")
try:
total += float(val)
except ValueError:
pass
set_field_value(document_data, "calculated_total", str(round(total, 2)))
table = tables_dict.get("INVOICE_TABLE")
if table:
empty_indices = []
for i, row in enumerate(table["rows"]):
desc = get_column_value(row, "DESCRIPTION", "")
if not desc.strip():
empty_indices.append(i)
# Rimuovere dal fondo verso l'inizio
for idx in reversed(empty_indices):
remove_rows_from_table(document_data, "INVOICE_TABLE", 1, idx)
table = tables_dict.get("INVOICE_TABLE")
if table:
add_table_column(table, "TAX_AMOUNT", "0")
for row in table["rows"]:
net = float(get_column_value(row, "NET_AMOUNT", "0"))
tax_rate = float(get_column_value(row, "TAX_RATE", "0"))
tax = net * tax_rate / 100
set_column_amount_value(document_data, row, "TAX_AMOUNT", tax)