fix: rollback document if reconciliation fails in Documents & Reconcile mode
Previously a JE/PE was left in the database even when reconcile_vouchers threw an error. Now the whole transaction (document creation + failed reconciliation) is rolled back so no orphaned document is created. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
87d4578927
commit
97b57c8572
|
|
@ -369,11 +369,13 @@ def _create_and_reconcile_doc(txn, paid_from, paid_to, document_type, multi_curr
|
||||||
)
|
)
|
||||||
return {"success": True, "doc_name": doc_name, "reconciled": True}
|
return {"success": True, "doc_name": doc_name, "reconciled": True}
|
||||||
except Exception as re:
|
except Exception as re:
|
||||||
|
frappe.db.rollback()
|
||||||
|
frappe.local.message_log = []
|
||||||
frappe.log_error(
|
frappe.log_error(
|
||||||
f"reconcile_vouchers failed for {doc_name}: {re}\n{frappe.get_traceback()}",
|
f"reconcile_vouchers failed for {doc_name}: {re}\n{frappe.get_traceback()}",
|
||||||
"Kapital Bank Mapping",
|
"Kapital Bank Mapping",
|
||||||
)
|
)
|
||||||
return {"success": True, "doc_name": doc_name, "reconciled": False, "error": str(re)}
|
return {"success": False, "error": str(re)}
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
frappe.db.rollback()
|
frappe.db.rollback()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue