diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index 9ef011b9432..231c8ab8740 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -4,6 +4,13 @@ "docstatus": 0, "doctype": "DocType", "fields": [ + { + "fieldname": "check_supplier_invoice_uniqueness", + "fieldtype": "Check", + "label": "Check Supplier Invoice Number Uniqueness", + "permlevel": 0, + "precision": "" + }, { "default": "1", "description": "If enabled, the system will post accounting entries for inventory automatically.", @@ -43,7 +50,7 @@ "icon": "icon-cog", "idx": 1, "issingle": 1, - "modified": "2015-02-05 05:11:34.163902", + "modified": "2015-06-11 06:06:34.047890", "modified_by": "Administrator", "module": "Accounts", "name": "Accounts Settings", diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index c0ebf686cbc..2516ded589e 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -39,6 +39,7 @@ class PurchaseInvoice(BuyingController): self.po_required() self.pr_required() + self.validate_supplier_invoice() self.check_active_purchase_items() self.check_conversion_rate() self.validate_credit_to_acc() @@ -385,6 +386,16 @@ class PurchaseInvoice(BuyingController): project.update_purchase_costing() project.save() project_list.append(d.project_name) + + def validate_supplier_invoice(self): + if self.bill_date: + if self.bill_date > self.posting_date: + frappe.throw("Supplier Invoice Date cannot be greater than Posting Date") + if self.bill_no: + if cint(frappe.db.get_single_value("Accounts Settings", "check_supplier_invoice_uniqueness")): + pi = frappe.db.exists("Purchase Invoice", {"bill_no": self.bill_no, "fiscal_year": self.fiscal_year}) + if pi: + frappe.throw("Supplier Invoice No exists in Purchase Invoice {0}".format(pi)) @frappe.whitelist() def get_expense_account(doctype, txt, searchfield, start, page_len, filters):