From 97ddfcfc7ca272922203d5423a21e777c62477d1 Mon Sep 17 00:00:00 2001 From: Tunde Akinyanmi Date: Fri, 9 Dec 2022 10:14:18 +0100 Subject: [PATCH 1/8] fix: Maintain Same Rate Throughout Sales Cycle doesn't work Issue #29976 was partly fixed by #32923 but the problem still persists. The reason is because an incorrect fieldname was passed to the `validate_rate_with_reference_doc` method. This commit fixes it --- erpnext/selling/doctype/quotation/test_quotation.py | 13 +++++++++++++ erpnext/selling/doctype/sales_order/sales_order.py | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/erpnext/selling/doctype/quotation/test_quotation.py b/erpnext/selling/doctype/quotation/test_quotation.py index 6f0b381fc1..5cd6545187 100644 --- a/erpnext/selling/doctype/quotation/test_quotation.py +++ b/erpnext/selling/doctype/quotation/test_quotation.py @@ -30,6 +30,19 @@ class TestQuotation(FrappeTestCase): self.assertTrue(sales_order.get("payment_schedule")) + def test_maintain_rate_in_sales_cycle_is_enforced(self): + from erpnext.selling.doctype.quotation.quotation import make_sales_order + + quotation = frappe.copy_doc(test_records[0]) + quotation.transaction_date = nowdate() + quotation.valid_till = add_months(quotation.transaction_date, 1) + quotation.insert() + quotation.submit() + + sales_order = make_sales_order(quotation.name) + sales_order.items[0].rate = 1 + self.assertRaises(frappe.ValidationError, sales_order.save) + def test_make_sales_order_with_different_currency(self): from erpnext.selling.doctype.quotation.quotation import make_sales_order diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 78e2370878..0013c95032 100755 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -194,7 +194,7 @@ class SalesOrder(SellingController): ) if cint(frappe.db.get_single_value("Selling Settings", "maintain_same_sales_rate")): - self.validate_rate_with_reference_doc([["Quotation", "prev_docname", "quotation_item"]]) + self.validate_rate_with_reference_doc([["Quotation", "prevdoc_docname", "quotation_item"]]) def update_enquiry_status(self, prevdoc, flag): enq = frappe.db.sql( From d193a14b8f8e39367bb26e6595283ef5aa545dcc Mon Sep 17 00:00:00 2001 From: Tunde Akinyanmi Date: Fri, 9 Dec 2022 12:39:03 +0100 Subject: [PATCH 2/8] test: ensure test case sets Selling Settings --- erpnext/selling/doctype/quotation/test_quotation.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/erpnext/selling/doctype/quotation/test_quotation.py b/erpnext/selling/doctype/quotation/test_quotation.py index 5cd6545187..b3c21c46ed 100644 --- a/erpnext/selling/doctype/quotation/test_quotation.py +++ b/erpnext/selling/doctype/quotation/test_quotation.py @@ -33,6 +33,11 @@ class TestQuotation(FrappeTestCase): def test_maintain_rate_in_sales_cycle_is_enforced(self): from erpnext.selling.doctype.quotation.quotation import make_sales_order + maintain_rate = frappe.db.get_value( + "Selling Settings", "Selling Settings", "maintain_same_sales_rate" + ) + frappe.db.set_value("Selling Settings", "Selling Settings", "maintain_same_sales_rate", 1) + quotation = frappe.copy_doc(test_records[0]) quotation.transaction_date = nowdate() quotation.valid_till = add_months(quotation.transaction_date, 1) @@ -43,6 +48,10 @@ class TestQuotation(FrappeTestCase): sales_order.items[0].rate = 1 self.assertRaises(frappe.ValidationError, sales_order.save) + frappe.db.set_value( + "Selling Settings", "Selling Settings", "maintain_same_sales_rate", maintain_rate + ) + def test_make_sales_order_with_different_currency(self): from erpnext.selling.doctype.quotation.quotation import make_sales_order From 71aa8c5e1c8f9ac71fc3a5a8246f8a15f896a57d Mon Sep 17 00:00:00 2001 From: Tunde Akinyanmi Date: Fri, 9 Dec 2022 14:33:54 +0100 Subject: [PATCH 3/8] test: refactor test case --- erpnext/selling/doctype/quotation/test_quotation.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/erpnext/selling/doctype/quotation/test_quotation.py b/erpnext/selling/doctype/quotation/test_quotation.py index b3c21c46ed..b151dd5e79 100644 --- a/erpnext/selling/doctype/quotation/test_quotation.py +++ b/erpnext/selling/doctype/quotation/test_quotation.py @@ -33,10 +33,8 @@ class TestQuotation(FrappeTestCase): def test_maintain_rate_in_sales_cycle_is_enforced(self): from erpnext.selling.doctype.quotation.quotation import make_sales_order - maintain_rate = frappe.db.get_value( - "Selling Settings", "Selling Settings", "maintain_same_sales_rate" - ) - frappe.db.set_value("Selling Settings", "Selling Settings", "maintain_same_sales_rate", 1) + maintain_rate = frappe.db.get_single_value("Selling Settings", "maintain_same_sales_rate") + frappe.db.set_single_value("Selling Settings", "maintain_same_sales_rate", 1) quotation = frappe.copy_doc(test_records[0]) quotation.transaction_date = nowdate() @@ -48,9 +46,7 @@ class TestQuotation(FrappeTestCase): sales_order.items[0].rate = 1 self.assertRaises(frappe.ValidationError, sales_order.save) - frappe.db.set_value( - "Selling Settings", "Selling Settings", "maintain_same_sales_rate", maintain_rate - ) + frappe.db.set_single_value("Selling Settings", "maintain_same_sales_rate", maintain_rate) def test_make_sales_order_with_different_currency(self): from erpnext.selling.doctype.quotation.quotation import make_sales_order From 7d64bf78cf7f0f27f991d30ff04e90569dfbba20 Mon Sep 17 00:00:00 2001 From: Sabu Siyad Date: Mon, 12 Dec 2022 19:09:00 +0530 Subject: [PATCH 4/8] fix(pos): variable typo: `s_pos` -> `is_pos` Signed-off-by: Sabu Siyad --- erpnext/public/js/controllers/taxes_and_totals.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 74810005ed..1f8a5e39f2 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -58,7 +58,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { if ( in_list(["Sales Invoice", "POS Invoice"], this.frm.doc.doctype) - && this.frm.doc.s_pos + && this.frm.doc.is_pos && this.frm.doc.is_return ) { this.set_total_amount_to_default_mop(); From 7b3316dc3175bcdd6c2c592d9abdb13ab477f015 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 12 Dec 2022 20:15:59 +0530 Subject: [PATCH 5/8] fix: incorrect balance on parent company due to key mismatch --- .../consolidated_financial_statement.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py index e93fb6138a..d269e1f794 100644 --- a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py +++ b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py @@ -533,12 +533,13 @@ def get_accounts(root_type, companies): ], filters={"company": company, "root_type": root_type}, ): - if account.account_name not in added_accounts: + if account.account_number: + account_key = account.account_number + "-" + account.account_name + else: + account_key = account.account_name + + if account_key not in added_accounts: accounts.append(account) - if account.account_number: - account_key = account.account_number + "-" + account.account_name - else: - account_key = account.account_name added_accounts.append(account_key) return accounts From 78b438f6cf952829cbac907203f0f31584add668 Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Fri, 9 Dec 2022 22:41:43 +0530 Subject: [PATCH 6/8] fix: `Material Request` reference in internal `Sales Order` --- erpnext/selling/doctype/sales_order/sales_order_dashboard.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/erpnext/selling/doctype/sales_order/sales_order_dashboard.py b/erpnext/selling/doctype/sales_order/sales_order_dashboard.py index ace2e29c2b..5c4b57813d 100644 --- a/erpnext/selling/doctype/sales_order/sales_order_dashboard.py +++ b/erpnext/selling/doctype/sales_order/sales_order_dashboard.py @@ -12,7 +12,10 @@ def get_data(): "Auto Repeat": "reference_document", "Maintenance Visit": "prevdoc_docname", }, - "internal_links": {"Quotation": ["items", "prevdoc_docname"]}, + "internal_links": { + "Quotation": ["items", "prevdoc_docname"], + "Material Request": ["items", "material_request"], + }, "transactions": [ { "label": _("Fulfillment"), From aa787e403086c085bc1706d634b243a33be2d91c Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 13 Dec 2022 13:16:24 +0530 Subject: [PATCH 7/8] fix: Permission issue in Tax Detail report --- erpnext/accounts/report/tax_detail/tax_detail.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/report/tax_detail/tax_detail.py b/erpnext/accounts/report/tax_detail/tax_detail.py index ba8d307228..ba733c2d18 100644 --- a/erpnext/accounts/report/tax_detail/tax_detail.py +++ b/erpnext/accounts/report/tax_detail/tax_detail.py @@ -234,8 +234,11 @@ def modify_report_columns(doctype, field, column): if field in ["item_tax_rate", "base_net_amount"]: return None - if doctype == "GL Entry" and field in ["debit", "credit"]: - column.update({"label": _("Amount"), "fieldname": "amount"}) + if doctype == "GL Entry": + if field in ["debit", "credit"]: + column.update({"label": _("Amount"), "fieldname": "amount"}) + elif field == "voucher_type": + column.update({"fieldtype": "Data", "options": ""}) if field == "taxes_and_charges": column.update({"label": _("Taxes and Charges Template")}) From 723c64ba738b027323487500f09dfd7cafe3468d Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Sat, 10 Dec 2022 14:00:29 +0530 Subject: [PATCH 8/8] fix: `Enough Parts to Build` in `BOM Stock Report` --- .../report/bom_stock_report/bom_stock_report.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/erpnext/manufacturing/report/bom_stock_report/bom_stock_report.py b/erpnext/manufacturing/report/bom_stock_report/bom_stock_report.py index 1e1b435600..cdf1541f88 100644 --- a/erpnext/manufacturing/report/bom_stock_report/bom_stock_report.py +++ b/erpnext/manufacturing/report/bom_stock_report/bom_stock_report.py @@ -4,7 +4,7 @@ import frappe from frappe import _ -from frappe.query_builder.functions import Floor, Sum +from frappe.query_builder.functions import Sum from pypika.terms import ExistsCriterion @@ -58,9 +58,9 @@ def get_bom_stock(filters): bom_item.description, bom_item.stock_qty, bom_item.stock_uom, - bom_item.stock_qty * qty_to_produce / bom.quantity, - Sum(bin.actual_qty).as_("actual_qty"), - Sum(Floor(bin.actual_qty / (bom_item.stock_qty * qty_to_produce / bom.quantity))), + (bom_item.stock_qty / bom.quantity) * qty_to_produce, + Sum(bin.actual_qty), + Sum(bin.actual_qty) / (bom_item.stock_qty / bom.quantity), ) .where((bom_item.parent == filters.get("bom")) & (bom_item.parenttype == "BOM")) .groupby(bom_item.item_code)