From 1230127d24cc1ae97129ad8e592ca3cdf8f59c32 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Wed, 19 Feb 2025 13:03:45 +0530 Subject: [PATCH] fix: patch --- erpnext/patches.txt | 4 ++-- .../v15_0}/recalculate_amount_difference_field.py | 9 +++++++-- ...me_field_from_rate_difference_to_amount_difference.py | 0 .../doctype/purchase_receipt_item/patches/__init__.py | 0 4 files changed, 9 insertions(+), 4 deletions(-) rename erpnext/{stock/doctype/purchase_receipt_item/patches => patches/v15_0}/recalculate_amount_difference_field.py (88%) rename erpnext/{stock/doctype/purchase_receipt_item/patches => patches/v15_0}/rename_field_from_rate_difference_to_amount_difference.py (100%) delete mode 100644 erpnext/stock/doctype/purchase_receipt_item/patches/__init__.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index bc5d1fe8352..4f74e2fdfe6 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -400,5 +400,5 @@ erpnext.patches.v15_0.migrate_checkbox_to_select_for_reconciliation_effect erpnext.patches.v15_0.sync_auto_reconcile_config execute:frappe.db.set_single_value("Accounts Settings", "exchange_gain_loss_posting_date", "Payment") erpnext.patches.v14_0.disable_add_row_in_gross_profit -erpnext.stock.doctype.purchase_receipt_item.patches.rename_field_from_rate_difference_to_amount_difference -erpnext.stock.doctype.purchase_receipt_item.patches.recalculate_amount_difference_field \ No newline at end of file +erpnext.patches.v15_0.rename_field_from_rate_difference_to_amount_difference +erpnext.patches.v15_0.recalculate_amount_difference_field \ No newline at end of file diff --git a/erpnext/stock/doctype/purchase_receipt_item/patches/recalculate_amount_difference_field.py b/erpnext/patches/v15_0/recalculate_amount_difference_field.py similarity index 88% rename from erpnext/stock/doctype/purchase_receipt_item/patches/recalculate_amount_difference_field.py rename to erpnext/patches/v15_0/recalculate_amount_difference_field.py index fc904baa927..5ece5f08ddb 100644 --- a/erpnext/stock/doctype/purchase_receipt_item/patches/recalculate_amount_difference_field.py +++ b/erpnext/patches/v15_0/recalculate_amount_difference_field.py @@ -31,6 +31,8 @@ def execute(): if result := query.run(as_dict=True): item_wise_billed_qty = get_billed_qty_against_purchase_receipt([item.name for item in result]) + purchase_receipts = set() + precision = frappe.get_precision("Purchase Receipt Item", "amount") for item in result: adjusted_amt = 0.0 @@ -44,7 +46,7 @@ def execute(): ) * item.qty adjusted_amt = flt( adjusted_amt * flt(item.conversion_rate), - frappe.get_precision("Purchase Receipt Item", "amount"), + precision, ) if adjusted_amt != item.amount_difference_with_purchase_invoice: @@ -55,7 +57,10 @@ def execute(): adjusted_amt, update_modified=False, ) - adjust_incoming_rate_for_pr(frappe.get_doc("Purchase Receipt", item.parent)) + purchase_receipts.add(item.parent) + + for pr in purchase_receipts: + adjust_incoming_rate_for_pr(frappe.get_doc("Purchase Receipt", pr)) def get_billed_qty_against_purchase_receipt(pr_names): diff --git a/erpnext/stock/doctype/purchase_receipt_item/patches/rename_field_from_rate_difference_to_amount_difference.py b/erpnext/patches/v15_0/rename_field_from_rate_difference_to_amount_difference.py similarity index 100% rename from erpnext/stock/doctype/purchase_receipt_item/patches/rename_field_from_rate_difference_to_amount_difference.py rename to erpnext/patches/v15_0/rename_field_from_rate_difference_to_amount_difference.py diff --git a/erpnext/stock/doctype/purchase_receipt_item/patches/__init__.py b/erpnext/stock/doctype/purchase_receipt_item/patches/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000