From 44263842f53e15ebaeb726bec64a764034cb2554 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Sun, 29 Sep 2024 09:18:52 +0530 Subject: [PATCH 1/9] fix: Stock Ledger Invariant Check report (cherry picked from commit d7daedc5b21a952c0bfa46079595f016179bcca0) --- .../stock_ledger_invariant_check.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.py b/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.py index ca15afe444d..77e81fcbb4d 100644 --- a/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.py +++ b/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.py @@ -51,7 +51,7 @@ def add_invariant_check_fields(sles): balance_qty = 0.0 balance_stock_value = 0.0 for idx, sle in enumerate(sles): - queue = json.loads(sle.stock_queue) + queue = json.loads(sle.stock_queue) if sle.stock_queue else [] fifo_qty = 0.0 fifo_value = 0.0 From 57925a1315353ec2c5f2b1d251cbaffa80d38fc4 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 30 Sep 2024 13:38:54 +0530 Subject: [PATCH 2/9] fix: adjustmen entry for stock reco (cherry picked from commit 4e463b7d6deffc33bdd793322cfaf82c0e86fb63) --- .../stock/doctype/stock_reconciliation/stock_reconciliation.py | 2 +- erpnext/stock/stock_ledger.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index 0201321785f..adc67c6bb44 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -406,7 +406,7 @@ class StockReconciliation(StockController): from erpnext.stock.stock_ledger import get_stock_value_difference difference_amount = get_stock_value_difference( - row.item_code, row.warehouse, self.posting_date, self.posting_time + row.item_code, row.warehouse, self.posting_date, self.posting_time, self.name ) if not difference_amount: diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index 63e5d858b5a..8ebc2aa9c04 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -652,7 +652,7 @@ class update_entries_after: sle.stock_value = self.wh_data.stock_value sle.stock_queue = json.dumps(self.wh_data.stock_queue) - if not sle.is_adjustment_entry or not self.args.get("sle_id"): + if not sle.is_adjustment_entry: sle.stock_value_difference = stock_value_difference sle.doctype = "Stock Ledger Entry" From 3cb85028d00e75368e3a561611b290e4810dd4f1 Mon Sep 17 00:00:00 2001 From: Nihantra Patel Date: Tue, 1 Oct 2024 10:50:43 +0530 Subject: [PATCH 3/9] fix: add company filter in Warehouse wise Item Balance Age and Value (cherry picked from commit 75950f86cff9e456693947b530ce257d354648bd) --- .../warehouse_wise_item_balance_age_and_value.js | 15 +++++++++++++++ .../warehouse_wise_item_balance_age_and_value.py | 2 -- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/report/warehouse_wise_item_balance_age_and_value/warehouse_wise_item_balance_age_and_value.js b/erpnext/stock/report/warehouse_wise_item_balance_age_and_value/warehouse_wise_item_balance_age_and_value.js index 8a0c1a7af6d..7a0d9a7d168 100644 --- a/erpnext/stock/report/warehouse_wise_item_balance_age_and_value/warehouse_wise_item_balance_age_and_value.js +++ b/erpnext/stock/report/warehouse_wise_item_balance_age_and_value/warehouse_wise_item_balance_age_and_value.js @@ -4,6 +4,15 @@ frappe.query_reports["Warehouse wise Item Balance Age and Value"] = { filters: [ + { + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + width: "80", + options: "Company", + reqd: 1, + default: frappe.defaults.get_user_default("Company"), + }, { fieldname: "from_date", label: __("From Date"), @@ -40,6 +49,12 @@ frappe.query_reports["Warehouse wise Item Balance Age and Value"] = { fieldtype: "Link", width: "80", options: "Warehouse", + get_query: function () { + const company = frappe.query_report.get_filter_value("company"); + return { + filters: { company: company }, + }; + }, }, { fieldname: "filter_total_zero_qty", diff --git a/erpnext/stock/report/warehouse_wise_item_balance_age_and_value/warehouse_wise_item_balance_age_and_value.py b/erpnext/stock/report/warehouse_wise_item_balance_age_and_value/warehouse_wise_item_balance_age_and_value.py index f5a059a7f61..ffcfb6a970a 100644 --- a/erpnext/stock/report/warehouse_wise_item_balance_age_and_value/warehouse_wise_item_balance_age_and_value.py +++ b/erpnext/stock/report/warehouse_wise_item_balance_age_and_value/warehouse_wise_item_balance_age_and_value.py @@ -109,8 +109,6 @@ def validate_filters(filters): sle_count = flt(frappe.qb.from_("Stock Ledger Entry").select(Count("name")).run()[0][0]) if sle_count > 500000: frappe.throw(_("Please set filter based on Item or Warehouse")) - if not filters.get("company"): - filters["company"] = frappe.defaults.get_user_default("Company") def get_warehouse_list(filters): From 1c0843caeeff69e67b92de994ed71a739f3ea5dd Mon Sep 17 00:00:00 2001 From: Corentin Forler Date: Wed, 2 Oct 2024 10:06:44 +0200 Subject: [PATCH 4/9] fix: Fix API endpoint for Frankfurter (cherry picked from commit 33e72111c7d7f60dbe041282026f607230624f52) --- .../currency_exchange_settings/currency_exchange_settings.py | 2 +- erpnext/setup/install.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/currency_exchange_settings/currency_exchange_settings.py b/erpnext/accounts/doctype/currency_exchange_settings/currency_exchange_settings.py index 39aff032b3d..2af06a17367 100644 --- a/erpnext/accounts/doctype/currency_exchange_settings/currency_exchange_settings.py +++ b/erpnext/accounts/doctype/currency_exchange_settings/currency_exchange_settings.py @@ -84,7 +84,7 @@ def get_api_endpoint(service_provider: str | None = None, use_http: bool = False if service_provider == "exchangerate.host": api = "api.exchangerate.host/convert" elif service_provider == "frankfurter.app": - api = "frankfurter.app/{transaction_date}" + api = "api.frankfurter.app/{transaction_date}" protocol = "https://" if use_http: diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py index 2e26117ef33..dcf086f2d05 100644 --- a/erpnext/setup/install.py +++ b/erpnext/setup/install.py @@ -80,7 +80,7 @@ def setup_currency_exchange(): ces.set("result_key", []) ces.set("req_params", []) - ces.api_endpoint = "https://frankfurter.app/{transaction_date}" + ces.api_endpoint = "https://api.frankfurter.app/{transaction_date}" ces.append("result_key", {"key": "rates"}) ces.append("result_key", {"key": "{to_currency}"}) ces.append("req_params", {"key": "base", "value": "{from_currency}"}) From b18b4c1e3567459c6f3833df5ae1652d6f19125d Mon Sep 17 00:00:00 2001 From: Sagar Vora Date: Wed, 2 Oct 2024 14:28:54 +0530 Subject: [PATCH 5/9] test: update test for API change (cherry picked from commit c444de017aee1cfa6e4e214dbddbc2543dccd966) --- .../setup/doctype/currency_exchange/test_currency_exchange.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py b/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py index d8e223fe12b..12240dc6595 100644 --- a/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py +++ b/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py @@ -68,9 +68,9 @@ def patched_requests_get(*args, **kwargs): if kwargs["params"].get("date") and kwargs["params"].get("from") and kwargs["params"].get("to"): if test_exchange_values.get(kwargs["params"]["date"]): return PatchResponse({"result": test_exchange_values[kwargs["params"]["date"]]}, 200) - elif args[0].startswith("https://frankfurter.app") and kwargs.get("params"): + elif args[0].startswith("https://api.frankfurter.app") and kwargs.get("params"): if kwargs["params"].get("base") and kwargs["params"].get("symbols"): - date = args[0].replace("https://frankfurter.app/", "") + date = args[0].replace("https://api.frankfurter.app/", "") if test_exchange_values.get(date): return PatchResponse( {"rates": {kwargs["params"].get("symbols"): test_exchange_values.get(date)}}, 200 From b4706db816768d386f1c213ae588f0effd09fd41 Mon Sep 17 00:00:00 2001 From: Sagar Vora Date: Wed, 2 Oct 2024 15:09:07 +0530 Subject: [PATCH 6/9] fix: patch to update Currency Exchange Settings for `frankfurter.app` (cherry picked from commit c5889c5d2ed0773dbc55173ddbcf8c817f654357) # Conflicts: # erpnext/patches.txt --- erpnext/patches.txt | 19 +++++++++++++++++++ ...rency_exchange_settings_for_frankfurter.py | 11 +++++++++++ 2 files changed, 30 insertions(+) create mode 100644 erpnext/patches/v14_0/update_currency_exchange_settings_for_frankfurter.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index c1f930e5dd4..212e072f79f 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -366,3 +366,22 @@ execute:frappe.db.set_single_value('E Commerce Settings', 'show_actual_qty', 1) erpnext.patches.v14_0.delete_orphaned_asset_movement_item_records erpnext.patches.v14_0.remove_cancelled_asset_capitalization_from_asset erpnext.patches.v14_0.enable_set_priority_for_pricing_rules #1 +<<<<<<< HEAD +======= +erpnext.patches.v15_0.rename_number_of_depreciations_booked_to_opening_booked_depreciations +erpnext.patches.v15_0.add_default_operations +erpnext.patches.v15_0.enable_old_serial_batch_fields +erpnext.patches.v15_0.update_warehouse_field_in_asset_repair_consumed_item_doctype +erpnext.patches.v15_0.update_asset_repair_field_in_stock_entry +erpnext.patches.v15_0.update_total_number_of_booked_depreciations +erpnext.patches.v15_0.do_not_use_batchwise_valuation +erpnext.patches.v15_0.update_invoice_remarks +erpnext.patches.v14_0.update_reports_with_range +erpnext.patches.v15_0.drop_index_posting_datetime_from_sle +erpnext.patches.v15_0.add_disassembly_order_stock_entry_type #1 +erpnext.patches.v15_0.set_standard_stock_entry_type +erpnext.patches.v15_0.set_difference_amount_in_asset_value_adjustment +erpnext.patches.v15_0.link_purchase_item_to_asset_doc +erpnext.patches.v15_0.migrate_to_utm_analytics +erpnext.patches.v14_0.update_currency_exchange_settings_for_frankfurter +>>>>>>> c5889c5d2e (fix: patch to update Currency Exchange Settings for `frankfurter.app`) diff --git a/erpnext/patches/v14_0/update_currency_exchange_settings_for_frankfurter.py b/erpnext/patches/v14_0/update_currency_exchange_settings_for_frankfurter.py new file mode 100644 index 00000000000..a67c5a26237 --- /dev/null +++ b/erpnext/patches/v14_0/update_currency_exchange_settings_for_frankfurter.py @@ -0,0 +1,11 @@ +import frappe + + +def execute(): + settings = frappe.get_doc("Currency Exchange Settings") + if settings.service_provider != "frankfurter.app": + return + + settings.set_parameters_and_result() + settings.flags.ignore_validate = True + settings.save() From 02ce52850189493cb37a8eef4389c9cea1fb712f Mon Sep 17 00:00:00 2001 From: Sagar Vora Date: Wed, 2 Oct 2024 15:14:16 +0530 Subject: [PATCH 7/9] fix: conflicts --- erpnext/patches.txt | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 212e072f79f..4c5094b2fd2 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -366,22 +366,4 @@ execute:frappe.db.set_single_value('E Commerce Settings', 'show_actual_qty', 1) erpnext.patches.v14_0.delete_orphaned_asset_movement_item_records erpnext.patches.v14_0.remove_cancelled_asset_capitalization_from_asset erpnext.patches.v14_0.enable_set_priority_for_pricing_rules #1 -<<<<<<< HEAD -======= -erpnext.patches.v15_0.rename_number_of_depreciations_booked_to_opening_booked_depreciations -erpnext.patches.v15_0.add_default_operations -erpnext.patches.v15_0.enable_old_serial_batch_fields -erpnext.patches.v15_0.update_warehouse_field_in_asset_repair_consumed_item_doctype -erpnext.patches.v15_0.update_asset_repair_field_in_stock_entry -erpnext.patches.v15_0.update_total_number_of_booked_depreciations -erpnext.patches.v15_0.do_not_use_batchwise_valuation -erpnext.patches.v15_0.update_invoice_remarks -erpnext.patches.v14_0.update_reports_with_range -erpnext.patches.v15_0.drop_index_posting_datetime_from_sle -erpnext.patches.v15_0.add_disassembly_order_stock_entry_type #1 -erpnext.patches.v15_0.set_standard_stock_entry_type -erpnext.patches.v15_0.set_difference_amount_in_asset_value_adjustment -erpnext.patches.v15_0.link_purchase_item_to_asset_doc -erpnext.patches.v15_0.migrate_to_utm_analytics erpnext.patches.v14_0.update_currency_exchange_settings_for_frankfurter ->>>>>>> c5889c5d2e (fix: patch to update Currency Exchange Settings for `frankfurter.app`) From 97edadfc4b4d41567110ab75f57d7d06de0bbc86 Mon Sep 17 00:00:00 2001 From: Sagar Vora Date: Wed, 2 Oct 2024 13:11:13 +0530 Subject: [PATCH 8/9] fix: set margin fields for purchase documents when updating items (cherry picked from commit 7be4d56be2714446525b93acce961f04ca1bd2d6) --- erpnext/controllers/accounts_controller.py | 23 +++++++++------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index ab7ee773158..54984f17d0c 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -3124,7 +3124,6 @@ def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, chil items_added_or_removed = False # updated to true if any new item is added or removed any_conversion_factor_changed = False - sales_doctypes = ["Sales Order", "Sales Invoice", "Delivery Note", "Quotation"] parent = frappe.get_doc(parent_doctype, parent_doctype_name) check_doc_permissions(parent, "write") @@ -3226,25 +3225,21 @@ def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, chil # if rate is greater than price_list_rate, set margin # or set discount child_item.discount_percentage = 0 - - if parent_doctype in sales_doctypes: - child_item.margin_type = "Amount" - child_item.margin_rate_or_amount = flt( - child_item.rate - child_item.price_list_rate, - child_item.precision("margin_rate_or_amount"), - ) - child_item.rate_with_margin = child_item.rate + child_item.margin_type = "Amount" + child_item.margin_rate_or_amount = flt( + child_item.rate - child_item.price_list_rate, + child_item.precision("margin_rate_or_amount"), + ) + child_item.rate_with_margin = child_item.rate else: child_item.discount_percentage = flt( (1 - flt(child_item.rate) / flt(child_item.price_list_rate)) * 100.0, child_item.precision("discount_percentage"), ) child_item.discount_amount = flt(child_item.price_list_rate) - flt(child_item.rate) - - if parent_doctype in sales_doctypes: - child_item.margin_type = "" - child_item.margin_rate_or_amount = 0 - child_item.rate_with_margin = 0 + child_item.margin_type = "" + child_item.margin_rate_or_amount = 0 + child_item.rate_with_margin = 0 child_item.flags.ignore_validate_update_after_submit = True if new_child_flag: From 31ecdb21040f6ccb3d22dd47adcfade6f96ccc4b Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 3 Oct 2024 20:28:59 +0100 Subject: [PATCH 9/9] fix(Dunning): logic for fetching text (backport #43160) (#43489) Co-authored-by: Raffael Meyer <14891507+barredterra@users.noreply.github.com> fix(Dunning): logic for fetching text (#43160) --- erpnext/accounts/doctype/dunning/dunning.py | 38 ++++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/erpnext/accounts/doctype/dunning/dunning.py b/erpnext/accounts/doctype/dunning/dunning.py index 7347865563a..a0206d424e2 100644 --- a/erpnext/accounts/doctype/dunning/dunning.py +++ b/erpnext/accounts/doctype/dunning/dunning.py @@ -129,19 +129,31 @@ def calculate_interest_and_amount(outstanding_amount, rate_of_interest, dunning_ @frappe.whitelist() -def get_dunning_letter_text(dunning_type, doc, language=None): +def get_dunning_letter_text(dunning_type: str, doc: str | dict, language: str | None = None) -> dict: + DOCTYPE = "Dunning Letter Text" + FIELDS = ["body_text", "closing_text", "language"] + if isinstance(doc, str): doc = json.loads(doc) + + if not language: + language = doc.get("language") + if language: - filters = {"parent": dunning_type, "language": language} - else: - filters = {"parent": dunning_type, "is_default_language": 1} - letter_text = frappe.db.get_value( - "Dunning Letter Text", filters, ["body_text", "closing_text", "language"], as_dict=1 - ) - if letter_text: - return { - "body_text": frappe.render_template(letter_text.body_text, doc), - "closing_text": frappe.render_template(letter_text.closing_text, doc), - "language": letter_text.language, - } + letter_text = frappe.db.get_value( + DOCTYPE, {"parent": dunning_type, "language": language}, FIELDS, as_dict=1 + ) + + if not letter_text: + letter_text = frappe.db.get_value( + DOCTYPE, {"parent": dunning_type, "is_default_language": 1}, FIELDS, as_dict=1 + ) + + if not letter_text: + return {} + + return { + "body_text": frappe.render_template(letter_text.body_text, doc), + "closing_text": frappe.render_template(letter_text.closing_text, doc), + "language": letter_text.language, + }