From 76a233e1b7e995b8d0d56332b33c2507cd7fe392 Mon Sep 17 00:00:00 2001 From: venkat102 Date: Tue, 15 Jul 2025 18:24:54 +0530 Subject: [PATCH 1/6] fix(period closing voucher): closing account head debit and debit in account currency should be equal --- .../period_closing_voucher.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py index 5119562382f..24ba4af5482 100644 --- a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py +++ b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py @@ -206,6 +206,9 @@ class PeriodClosingVoucher(AccountsController): return gl_entry def get_gle_for_closing_account(self, acc): + debit = abs(flt(acc.bal_in_company_currency)) if flt(acc.bal_in_company_currency) > 0 else 0 + credit = abs(flt(acc.bal_in_company_currency)) if flt(acc.bal_in_company_currency) < 0 else 0 + gl_entry = self.get_gl_dict( { "company": self.company, @@ -214,16 +217,10 @@ class PeriodClosingVoucher(AccountsController): "cost_center": acc.cost_center, "finance_book": acc.finance_book, "account_currency": acc.account_currency, - "debit_in_account_currency": abs(flt(acc.bal_in_account_currency)) - if flt(acc.bal_in_account_currency) > 0 - else 0, - "debit": abs(flt(acc.bal_in_company_currency)) if flt(acc.bal_in_company_currency) > 0 else 0, - "credit_in_account_currency": abs(flt(acc.bal_in_account_currency)) - if flt(acc.bal_in_account_currency) < 0 - else 0, - "credit": abs(flt(acc.bal_in_company_currency)) - if flt(acc.bal_in_company_currency) < 0 - else 0, + "debit_in_account_currency": debit, + "debit": debit, + "credit_in_account_currency": credit, + "credit": credit, "is_period_closing_voucher_entry": 1, }, item=acc, From 4fe09fd7e8c04805b9637fa5862a908754ff8bd2 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 16 Jul 2025 15:55:21 +0530 Subject: [PATCH 2/6] fix: performance issue while submitting the purchase invoice (cherry picked from commit 47979871def9642f7fa1de0b46e95ea406b49173) --- erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 71c753c0adc..b3b18b088ad 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -1016,6 +1016,9 @@ class PurchaseInvoice(BuyingController): def get_provisional_accounts(self): self.provisional_accounts = frappe._dict() linked_purchase_receipts = set([d.purchase_receipt for d in self.items if d.purchase_receipt]) + if not linked_purchase_receipts: + return + pr_items = frappe.get_all( "Purchase Receipt Item", filters={"parent": ("in", linked_purchase_receipts)}, From 9e7a5bb1bb9747ddf6c1797a8d879171def54a87 Mon Sep 17 00:00:00 2001 From: Sudharsanan Ashok <135326972+Sudharsanan11@users.noreply.github.com> Date: Wed, 12 Mar 2025 16:10:14 +0530 Subject: [PATCH 3/6] fix: calculate due date based on payment term (#46416) (cherry picked from commit 9e808c832f4cce536fe5d4f16d3f550352ba6f49) --- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 8 +++++++- erpnext/accounts/party.py | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 7f1f47a74c1..dbeeda00f49 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -498,7 +498,13 @@ class SalesInvoice(SellingController): "Account", self.debit_to, "account_currency", cache=True ) if not self.due_date and self.customer: - self.due_date = get_due_date(self.posting_date, "Customer", self.customer, self.company) + self.due_date = get_due_date( + self.posting_date, + "Customer", + self.customer, + self.company, + template_name=self.payment_terms_template, + ) super().set_missing_values(for_validate) diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index acd21da5a7f..d5867b65df6 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -552,12 +552,13 @@ def validate_party_accounts(doc): @frappe.whitelist() -def get_due_date(posting_date, party_type, party, company=None, bill_date=None): +def get_due_date(posting_date, party_type, party, company=None, bill_date=None, template_name=None): """Get due date from `Payment Terms Template`""" due_date = None if (bill_date or posting_date) and party: due_date = bill_date or posting_date - template_name = get_payment_terms_template(party, party_type, company) + if not template_name: + template_name = get_payment_terms_template(party, party_type, company) if template_name: due_date = get_due_date_from_template(template_name, posting_date, bill_date).strftime("%Y-%m-%d") From 8934adfef48d0202efdb3750ba5f3444bb3f46ab Mon Sep 17 00:00:00 2001 From: ravibharathi656 Date: Sat, 19 Jul 2025 08:15:18 +0530 Subject: [PATCH 4/6] fix(production plan): add company filter to sub assembly warehouse (cherry picked from commit 1728a9511160458c224fde827751a6d4ac92ddf6) --- .../doctype/production_plan/production_plan.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.js b/erpnext/manufacturing/doctype/production_plan/production_plan.js index 6db901c71a4..221c3bd6ae4 100644 --- a/erpnext/manufacturing/doctype/production_plan/production_plan.js +++ b/erpnext/manufacturing/doctype/production_plan/production_plan.js @@ -37,6 +37,14 @@ frappe.ui.form.on("Production Plan", { }; }); + frm.set_query("sub_assembly_warehouse", function (doc) { + return { + filters: { + company: doc.company, + }, + }; + }); + frm.set_query("material_request", "material_requests", function () { return { filters: { From 581221f1ec0ec77af30c27a9988288a338764a77 Mon Sep 17 00:00:00 2001 From: l0gesh29 Date: Thu, 17 Jul 2025 18:15:06 +0530 Subject: [PATCH 5/6] fix: show amount for exchange gain or loss account (cherry picked from commit 4f90f50eb2b7f5ad5bafcefe2823cf9e35738870) --- .../report/general_ledger/general_ledger.py | 2 +- erpnext/accounts/report/utils.py | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py index 76069c6fbe7..0ae8a6070a1 100644 --- a/erpnext/accounts/report/general_ledger/general_ledger.py +++ b/erpnext/accounts/report/general_ledger/general_ledger.py @@ -205,7 +205,7 @@ def get_gl_entries(filters, accounting_dimensions): ) if filters.get("presentation_currency"): - return convert_to_presentation_currency(gl_entries, currency_map) + return convert_to_presentation_currency(gl_entries, currency_map, filters) else: return gl_entries diff --git a/erpnext/accounts/report/utils.py b/erpnext/accounts/report/utils.py index 5d606f648fa..35c04b1af8c 100644 --- a/erpnext/accounts/report/utils.py +++ b/erpnext/accounts/report/utils.py @@ -86,7 +86,7 @@ def get_rate_as_at(date, from_currency, to_currency): return rate -def convert_to_presentation_currency(gl_entries, currency_info): +def convert_to_presentation_currency(gl_entries, currency_info, filters=None): """ Take a list of GL Entries and change the 'debit' and 'credit' values to currencies in `currency_info`. @@ -99,6 +99,13 @@ def convert_to_presentation_currency(gl_entries, currency_info): company_currency = currency_info["company_currency"] account_currencies = list(set(entry["account_currency"] for entry in gl_entries)) + exchange_gain_or_loss = False + + if filters: + account_filter = filters.get("account") + gain_loss_account = frappe.db.get_value("Company", filters.company, "exchange_gain_loss_account") + + exchange_gain_or_loss = len(account_filter) == 1 and account_filter[0] == gain_loss_account for entry in gl_entries: debit = flt(entry["debit"]) @@ -107,7 +114,11 @@ def convert_to_presentation_currency(gl_entries, currency_info): credit_in_account_currency = flt(entry["credit_in_account_currency"]) account_currency = entry["account_currency"] - if len(account_currencies) == 1 and account_currency == presentation_currency: + if ( + len(account_currencies) == 1 + and account_currency == presentation_currency + and not exchange_gain_or_loss + ): entry["debit"] = debit_in_account_currency entry["credit"] = credit_in_account_currency else: From 360f3b7c259d8b7510c80d9c0b55cbdcf4b45652 Mon Sep 17 00:00:00 2001 From: l0gesh29 Date: Thu, 17 Jul 2025 18:52:41 +0530 Subject: [PATCH 6/6] fix: add validation for account key (cherry picked from commit b6da350c201ff91dfe7dcb887b60d0dba1f0bd95) --- erpnext/accounts/report/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/report/utils.py b/erpnext/accounts/report/utils.py index 35c04b1af8c..2129f553c8c 100644 --- a/erpnext/accounts/report/utils.py +++ b/erpnext/accounts/report/utils.py @@ -101,7 +101,7 @@ def convert_to_presentation_currency(gl_entries, currency_info, filters=None): account_currencies = list(set(entry["account_currency"] for entry in gl_entries)) exchange_gain_or_loss = False - if filters: + if filters and isinstance(filters.get("account"), list): account_filter = filters.get("account") gain_loss_account = frappe.db.get_value("Company", filters.company, "exchange_gain_loss_account")