From 7696ae4de1a015d2d14271fb9a05092076abd245 Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Wed, 8 Jun 2022 09:36:33 +0530 Subject: [PATCH 1/7] fix(india): e-invoice eligibility if company gstin is not configured (#31247) (cherry picked from commit fb4f8d870be85037df1fd416be8fb93c1a85231f) --- erpnext/regional/india/e_invoice/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erpnext/regional/india/e_invoice/utils.py b/erpnext/regional/india/e_invoice/utils.py index 871bf9027c1..0d53e702d8e 100644 --- a/erpnext/regional/india/e_invoice/utils.py +++ b/erpnext/regional/india/e_invoice/utils.py @@ -56,6 +56,9 @@ def validate_eligibility(doc): return False invalid_company = not frappe.db.get_value("E Invoice User", {"company": doc.get("company")}) + invalid_company_gstin = not frappe.db.get_value( + "E Invoice User", {"gstin": doc.get("company_gstin")} + ) invalid_supply_type = doc.get("gst_category") not in [ "Registered Regular", "Registered Composition", @@ -72,6 +75,7 @@ def validate_eligibility(doc): if ( invalid_company + or invalid_company_gstin or invalid_supply_type or company_transaction or no_taxes_applied From 3b9f943335f2b6badbdb681c5dd6149bdbd8165f Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 17 Jun 2022 18:54:42 +0530 Subject: [PATCH 2/7] fix: Quotation lost update (cherry picked from commit 02f9441e1ab74a83c355cd546d1c0669dc21ef7e) # Conflicts: # erpnext/selling/doctype/quotation/quotation.py --- erpnext/selling/doctype/quotation/quotation.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index ceb922c0e53..f967b187f80 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -115,8 +115,13 @@ class Quotation(SellingController): opp.set_status(status=status, update=True) @frappe.whitelist() +<<<<<<< HEAD def declare_enquiry_lost(self, lost_reasons_list, detailed_reason=None): if not self.has_sales_order(): +======= + def declare_enquiry_lost(self, lost_reasons_list, competitors, detailed_reason=None): + if not self.is_fully_ordered() or self.is_partially_ordered(): +>>>>>>> 02f9441e1a (fix: Quotation lost update) get_lost_reasons = frappe.get_list("Quotation Lost Reason", fields=["name"]) lost_reasons_lst = [reason.get("name") for reason in get_lost_reasons] frappe.db.set(self, "status", "Lost") From 8d63abb442d98121002230d330219791091b3bd5 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 17 Jun 2022 18:56:53 +0530 Subject: [PATCH 3/7] chore: fix condition (cherry picked from commit e457288dbaceda121fb35eeeacc4189a15d0f9f6) # Conflicts: # erpnext/selling/doctype/quotation/quotation.py --- erpnext/selling/doctype/quotation/quotation.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index f967b187f80..e1aa03e41de 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -120,8 +120,12 @@ class Quotation(SellingController): if not self.has_sales_order(): ======= def declare_enquiry_lost(self, lost_reasons_list, competitors, detailed_reason=None): +<<<<<<< HEAD if not self.is_fully_ordered() or self.is_partially_ordered(): >>>>>>> 02f9441e1a (fix: Quotation lost update) +======= + if not (self.is_fully_ordered() or self.is_partially_ordered()): +>>>>>>> e457288dba (chore: fix condition) get_lost_reasons = frappe.get_list("Quotation Lost Reason", fields=["name"]) lost_reasons_lst = [reason.get("name") for reason in get_lost_reasons] frappe.db.set(self, "status", "Lost") From 8e2e61ef84561391b57fb74c9c4ff50e2a97a4bb Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sat, 18 Jun 2022 20:23:58 +0530 Subject: [PATCH 4/7] chore: resolve conflicts --- erpnext/selling/doctype/quotation/quotation.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index e1aa03e41de..d1530395d8a 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -115,17 +115,8 @@ class Quotation(SellingController): opp.set_status(status=status, update=True) @frappe.whitelist() -<<<<<<< HEAD def declare_enquiry_lost(self, lost_reasons_list, detailed_reason=None): - if not self.has_sales_order(): -======= - def declare_enquiry_lost(self, lost_reasons_list, competitors, detailed_reason=None): -<<<<<<< HEAD - if not self.is_fully_ordered() or self.is_partially_ordered(): ->>>>>>> 02f9441e1a (fix: Quotation lost update) -======= if not (self.is_fully_ordered() or self.is_partially_ordered()): ->>>>>>> e457288dba (chore: fix condition) get_lost_reasons = frappe.get_list("Quotation Lost Reason", fields=["name"]) lost_reasons_lst = [reason.get("name") for reason in get_lost_reasons] frappe.db.set(self, "status", "Lost") From e982abbe4d4a7a896663c9932cbecaea0022cfc2 Mon Sep 17 00:00:00 2001 From: Marica Date: Mon, 20 Jun 2022 17:09:52 +0530 Subject: [PATCH 5/7] chore: Change autoname to v13 compatible value (#31407) - 'autoincrement' is present only in v14 - 'hash' is automatically still used in tables but change value for safety --- .../doctype/bom_update_batch/bom_update_batch.json | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom_update_batch/bom_update_batch.json b/erpnext/manufacturing/doctype/bom_update_batch/bom_update_batch.json index 83b54d326cb..d204e8e6de9 100644 --- a/erpnext/manufacturing/doctype/bom_update_batch/bom_update_batch.json +++ b/erpnext/manufacturing/doctype/bom_update_batch/bom_update_batch.json @@ -1,6 +1,6 @@ { "actions": [], - "autoname": "autoincrement", + "autoname": "hash", "creation": "2022-05-31 17:34:39.825537", "doctype": "DocType", "engine": "InnoDB", @@ -42,7 +42,7 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2022-06-06 14:50:35.161062", + "modified": "2022-06-20 15:10:15.826571", "modified_by": "Administrator", "module": "Manufacturing", "name": "BOM Update Batch", @@ -50,6 +50,5 @@ "owner": "Administrator", "permissions": [], "sort_field": "modified", - "sort_order": "DESC", - "states": [] + "sort_order": "DESC" } \ No newline at end of file From 4186aafd07a495b5b8ef02fda8a6ac4c07578203 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Tue, 14 Jun 2022 12:50:49 +0530 Subject: [PATCH 6/7] fix: Conversion rate validation for multi-currency invoices (cherry picked from commit d05d15346a22de311cf16f437e80804207b4fe60) --- .../doctype/purchase_invoice/purchase_invoice.py | 11 ----------- .../accounts/doctype/sales_invoice/sales_invoice.py | 1 + erpnext/controllers/accounts_controller.py | 11 +++++++++++ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 3c1dc80970e..a3558ab8b40 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -161,17 +161,6 @@ class PurchaseInvoice(BuyingController): super(PurchaseInvoice, self).set_missing_values(for_validate) - def check_conversion_rate(self): - default_currency = erpnext.get_company_currency(self.company) - if not default_currency: - throw(_("Please enter default currency in Company Master")) - if ( - (self.currency == default_currency and flt(self.conversion_rate) != 1.00) - or not self.conversion_rate - or (self.currency != default_currency and flt(self.conversion_rate) == 1.00) - ): - throw(_("Conversion rate cannot be 0 or 1")) - def validate_credit_to_acc(self): if not self.credit_to: self.credit_to = get_party_account("Supplier", self.supplier, self.company) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 954a8207780..069148c1199 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -116,6 +116,7 @@ class SalesInvoice(SellingController): self.set_income_account_for_fixed_assets() self.validate_item_cost_centers() self.validate_income_account() + self.check_conversion_rate() validate_inter_company_party( self.doctype, self.customer, self.company, self.inter_company_invoice_reference diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index cd985e43bec..71901c52bf6 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -1846,6 +1846,17 @@ class AccountsController(TransactionBase): jv.save() jv.submit() + def check_conversion_rate(self): + default_currency = erpnext.get_company_currency(self.company) + if not default_currency: + throw(_("Please enter default currency in Company Master")) + if ( + (self.currency == default_currency and flt(self.conversion_rate) != 1.00) + or not self.conversion_rate + or (self.currency != default_currency and flt(self.conversion_rate) == 1.00) + ): + throw(_("Conversion rate cannot be 0 or 1")) + @frappe.whitelist() def get_tax_rate(account_head): From da70b69d68ccff4cc2b4d5e863971d46af5e1598 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 20 Jun 2022 22:00:32 +0530 Subject: [PATCH 7/7] test: Add test case (cherry picked from commit 8f373930448af79e7222eb78eb7d8c364a4b7fd0) --- .../doctype/sales_invoice/test_sales_invoice.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 068d1ffd89d..16210e78bdd 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -1612,6 +1612,17 @@ class TestSalesInvoice(unittest.TestCase): self.assertTrue(gle) + def test_invoice_exchange_rate(self): + si = create_sales_invoice( + customer="_Test Customer USD", + debit_to="_Test Receivable USD - _TC", + currency="USD", + conversion_rate=1, + do_not_save=1, + ) + + self.assertRaises(frappe.ValidationError, si.save) + def test_invalid_currency(self): # Customer currency = USD