From 8b67527900df9ea6279451bc887eef7d88ac4f60 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Sat, 8 Mar 2025 11:31:33 +0530 Subject: [PATCH 1/3] fix: consider account freeze date in recalculate_amount_difference_field patch (cherry picked from commit 696f931678d955fcc6b87d689343b2900f7ba9ca) # Conflicts: # erpnext/patches/v15_0/recalculate_amount_difference_field.py --- .../v15_0/recalculate_amount_difference_field.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/erpnext/patches/v15_0/recalculate_amount_difference_field.py b/erpnext/patches/v15_0/recalculate_amount_difference_field.py index 7d3d957fe62..e4e1add6949 100644 --- a/erpnext/patches/v15_0/recalculate_amount_difference_field.py +++ b/erpnext/patches/v15_0/recalculate_amount_difference_field.py @@ -62,6 +62,7 @@ def execute(): ): posting_date = period_closing_voucher[0].period_end_date +<<<<<<< HEAD try: fiscal_year = get_fiscal_year(frappe.utils.datetime.date.today()) except Exception: @@ -69,6 +70,15 @@ def execute(): else: if fiscal_year and getdate(fiscal_year[1]) > getdate(posting_date): posting_date = fiscal_year[1] +======= + acc_frozen_upto = frappe.db.get_single_value("Accounts Settings", "acc_frozen_upto") + if acc_frozen_upto and getdate(acc_frozen_upto) > getdate(posting_date): + posting_date = acc_frozen_upto + + fiscal_year = get_fiscal_year(frappe.utils.datetime.date.today(), raise_on_missing=False) + if fiscal_year and getdate(fiscal_year[1]) > getdate(posting_date): + posting_date = fiscal_year[1] +>>>>>>> 696f931678 (fix: consider account freeze date in recalculate_amount_difference_field patch) query = query.where(parent.posting_date > posting_date) if result := query.run(as_dict=True): From 8264d42cd9083f71752a303fded52d698d819c57 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Sat, 8 Mar 2025 11:38:28 +0530 Subject: [PATCH 2/3] fix: consider stock freeze date in recalculate_amount_difference_field patch (cherry picked from commit cd7253278937f66f2c5b52bebc54f137b03068a7) --- erpnext/patches/v15_0/recalculate_amount_difference_field.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erpnext/patches/v15_0/recalculate_amount_difference_field.py b/erpnext/patches/v15_0/recalculate_amount_difference_field.py index e4e1add6949..0f8083d8b14 100644 --- a/erpnext/patches/v15_0/recalculate_amount_difference_field.py +++ b/erpnext/patches/v15_0/recalculate_amount_difference_field.py @@ -75,6 +75,10 @@ def execute(): if acc_frozen_upto and getdate(acc_frozen_upto) > getdate(posting_date): posting_date = acc_frozen_upto + stock_frozen_upto = frappe.db.get_single_value("Stock Settings", "stock_frozen_upto") + if stock_frozen_upto and getdate(stock_frozen_upto) > getdate(posting_date): + posting_date = stock_frozen_upto + fiscal_year = get_fiscal_year(frappe.utils.datetime.date.today(), raise_on_missing=False) if fiscal_year and getdate(fiscal_year[1]) > getdate(posting_date): posting_date = fiscal_year[1] From 985fb5dfdc2cae524b77694fc73859667907449b Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Sat, 8 Mar 2025 22:22:12 +0530 Subject: [PATCH 3/3] chore: resolve conflicts --- .../recalculate_amount_difference_field.py | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/erpnext/patches/v15_0/recalculate_amount_difference_field.py b/erpnext/patches/v15_0/recalculate_amount_difference_field.py index 0f8083d8b14..2891ac16c44 100644 --- a/erpnext/patches/v15_0/recalculate_amount_difference_field.py +++ b/erpnext/patches/v15_0/recalculate_amount_difference_field.py @@ -62,15 +62,6 @@ def execute(): ): posting_date = period_closing_voucher[0].period_end_date -<<<<<<< HEAD - try: - fiscal_year = get_fiscal_year(frappe.utils.datetime.date.today()) - except Exception: - return - else: - if fiscal_year and getdate(fiscal_year[1]) > getdate(posting_date): - posting_date = fiscal_year[1] -======= acc_frozen_upto = frappe.db.get_single_value("Accounts Settings", "acc_frozen_upto") if acc_frozen_upto and getdate(acc_frozen_upto) > getdate(posting_date): posting_date = acc_frozen_upto @@ -79,10 +70,14 @@ def execute(): if stock_frozen_upto and getdate(stock_frozen_upto) > getdate(posting_date): posting_date = stock_frozen_upto - fiscal_year = get_fiscal_year(frappe.utils.datetime.date.today(), raise_on_missing=False) - if fiscal_year and getdate(fiscal_year[1]) > getdate(posting_date): - posting_date = fiscal_year[1] ->>>>>>> 696f931678 (fix: consider account freeze date in recalculate_amount_difference_field patch) + try: + fiscal_year = get_fiscal_year(frappe.utils.datetime.date.today()) + except Exception: + return + else: + if fiscal_year and getdate(fiscal_year[1]) > getdate(posting_date): + posting_date = fiscal_year[1] + query = query.where(parent.posting_date > posting_date) if result := query.run(as_dict=True):