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
diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json
index 9ef011b..231c8ab 100644
--- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json
+++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json
@@ -5,6 +5,13 @@
"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.",
"fieldname": "auto_accounting_for_stock",
@@ -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 c0ebf68..2516ded 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -39,6 +39,7 @@
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 @@
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):