Skip to content

Commit

Permalink
fix: handle_on_cancel_for_reco_tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanket322 committed Apr 16, 2024
1 parent 2a34abf commit 45c19f6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
13 changes: 13 additions & 0 deletions india_compliance/gst_india/doctype/bill_of_entry/bill_of_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,19 @@ def on_cancel(self):
self.ignore_linked_doctypes = ("GL Entry",)
make_reverse_gl_entries(voucher_type=self.doctype, voucher_no=self.name)

if self.reconciliation_status == "Reconciled":
doc_name = frappe.get_list(
"GST Inward Supply", filters={"link_name": self.name}, pluck="name"
)
updated_data = {
"match_status": "",
"link_name": "",
"link_doctype": "",
}
if doc_name:
for name in doc_name:
frappe.db.set_value("GST Inward Supply", name, updated_data)

# Code adapted from AccountsController.on_trash
def on_trash(self):
if not frappe.db.get_single_value(
Expand Down
15 changes: 15 additions & 0 deletions india_compliance/gst_india/overrides/purchase_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,21 @@ def validate(doc, method=None):
set_reconciliation_status(doc)


def on_cancel(doc, method=None):
if doc.reconciliation_status == "Reconciled":
doc_name = frappe.get_list(
"GST Inward Supply", filters={"link_name": doc.name}, pluck="name"
)
updated_data = {
"match_status": "",
"link_name": "",
"link_doctype": "",
}
if doc_name:
for name in doc_name:
frappe.db.set_value("GST Inward Supply", name, updated_data)


def set_reconciliation_status(doc):
reconciliation_status = "Not Applicable"

Expand Down
1 change: 1 addition & 0 deletions india_compliance/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
"before_gl_preview": "india_compliance.gst_india.overrides.ineligible_itc.update_valuation_rate",
"before_sl_preview": "india_compliance.gst_india.overrides.ineligible_itc.update_valuation_rate",
"after_mapping": "india_compliance.gst_india.overrides.transaction.after_mapping",
"on_cancel": "india_compliance.gst_india.overrides.purchase_invoice.on_cancel",
},
"Purchase Order": {
"onload": "india_compliance.gst_india.overrides.transaction.onload",
Expand Down

0 comments on commit 45c19f6

Please sign in to comment.