From 1792ff3be72f654719279815633cc550b1b608c4 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Thu, 11 Jun 2015 15:47:48 +0530 Subject: [PATCH] Validation added in Purchase Invoice to check if Supplier Invoice Date is greater than Posting Date Check Supplier Invoice Number Uniqueness setting added to Accounts Settings Validation added in Purchase Invoice to check Supplier Invoice Number Uniqueness if Check Supplier Invoice Number Uniqueness is enabled in Accounts Settings --- .../doctype/accounts_settings/accounts_settings.json | 9 ++++++++- .../doctype/purchase_invoice/purchase_invoice.py | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index 9ef011b943..231c8ab874 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 c0ebf686cb..2516ded589 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):