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/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 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): 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 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 diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index ceb922c0e53..d1530395d8a 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -116,7 +116,7 @@ class Quotation(SellingController): @frappe.whitelist() def declare_enquiry_lost(self, lost_reasons_list, detailed_reason=None): - if not self.has_sales_order(): + if not (self.is_fully_ordered() or self.is_partially_ordered()): 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")