diff --git a/india_compliance/gst_india/doctype/purchase_reconciliation_tool/__init__.py b/india_compliance/gst_india/doctype/purchase_reconciliation_tool/__init__.py index 849cfed6cf..f9e134a4b5 100644 --- a/india_compliance/gst_india/doctype/purchase_reconciliation_tool/__init__.py +++ b/india_compliance/gst_india/doctype/purchase_reconciliation_tool/__init__.py @@ -1037,26 +1037,6 @@ def get(self, purchase_names: list = None, inward_supply_names: list = None): self.process_data(reconciliation_data, retain_doc=retain_doc) - periods = BaseUtil._get_periods( - self.inward_supply_from_date, self.inward_supply_to_date - ) - - purchase_invoices = frappe.get_all( - "GST Inward Supply", - filters={ - "action": "No Action", - "link_name": ["!=", ""], - "sup_return_period": ["in", periods], - }, - pluck="link_name", - ) - frappe.db.set_value( - "Purchase Invoice", - {"name": ("in", purchase_invoices)}, - "reconciliation_status", - "Match Found", - ) - return reconciliation_data def get_all_inward_supply( @@ -1157,6 +1137,8 @@ def process_data(self, reconciliation_data: list, retain_doc: bool = False): "classification": "", } + match_found = [] + for data in reconciliation_data: data.update(default_dict) method = data.get if retain_doc else data.pop @@ -1164,6 +1146,14 @@ def process_data(self, reconciliation_data: list, retain_doc: bool = False): purchase = method("_purchase_invoice", frappe._dict()) inward_supply = method("_inward_supply", frappe._dict()) + if ( + inward_supply + and purchase + and inward_supply.get("action") == "No Action" + and inward_supply.get("link_name") != "" + ): + match_found.append(purchase.get("name")) + self.update_fields(data, purchase, inward_supply) self.update_amount_difference(data, purchase, inward_supply) self.update_differences(data, purchase, inward_supply) @@ -1171,6 +1161,14 @@ def process_data(self, reconciliation_data: list, retain_doc: bool = False): if retain_doc and purchase: BaseUtil.update_cess_amount(purchase) + for doc in ("Purchase Invoice", "Bill of Entry"): + frappe.db.set_value( + doc, + {"name": ("in", match_found)}, + "reconciliation_status", + "Match Found", + ) + def update_fields(self, data, purchase, inward_supply): for field in ("supplier_name", "supplier_gstin", "bill_no", "bill_date"): data[field] = purchase.get(field) or inward_supply.get(field) diff --git a/india_compliance/patches.txt b/india_compliance/patches.txt index a583aa9ef6..22666d7f91 100644 --- a/india_compliance/patches.txt +++ b/india_compliance/patches.txt @@ -43,8 +43,8 @@ india_compliance.patches.post_install.update_gst_treatment_for_taxable_nil_trans india_compliance.patches.post_install.update_default_gstr3b_status india_compliance.patches.v14.update_gst_details_for_invoices_with_same_item_multiple_times india_compliance.patches.v14.update_e_invoice_status -india_compliance.patches.v14.add_match_found_in_purchase_reconciliation_status execute:from erpnext.stock.doctype.repost_item_valuation.repost_item_valuation import execute_repost_item_valuation; execute_repost_item_valuation() india_compliance.patches.v14.set_item_details_from_purchase_invoice_to_bill_of_entry india_compliance.patches.v14.update_item_gst_details_and_gst_trearment_in_bill_of_entry india_compliance.patches.v14.update_default_auto_reconciliation_settings +india_compliance.patches.v14.add_match_found_in_purchase_reconciliation_status diff --git a/india_compliance/patches/v14/add_match_found_in_purchase_reconciliation_status.py b/india_compliance/patches/v14/add_match_found_in_purchase_reconciliation_status.py index a3a7240d77..f92c22aa4b 100644 --- a/india_compliance/patches/v14/add_match_found_in_purchase_reconciliation_status.py +++ b/india_compliance/patches/v14/add_match_found_in_purchase_reconciliation_status.py @@ -2,14 +2,16 @@ def execute(): - purchase_invoices = frappe.get_all( + pi_and_boe_list = frappe.get_all( "GST Inward Supply", - filters={"action": "No Action", "link_name": ["!=", ""]}, + filters={"action": "No Action", "link_name": ("!=", "")}, pluck="link_name", ) - frappe.db.set_value( - "Purchase Invoice", - {"name": ("in", purchase_invoices)}, - "reconciliation_status", - "Match Found", - ) + if pi_and_boe_list: + for doc in ("Purchase Invoice", "Bill of Entry"): + frappe.db.set_value( + doc, + {"name": ("in", pi_and_boe_list)}, + "reconciliation_status", + "Match Found", + )