[perpetual accounting] validate expense account in stock reconciliation
diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.js b/stock/doctype/stock_reconciliation/stock_reconciliation.js
index 4a66c3c..1847864 100644
--- a/stock/doctype/stock_reconciliation/stock_reconciliation.js
+++ b/stock/doctype/stock_reconciliation/stock_reconciliation.js
@@ -30,6 +30,7 @@
var me = this;
if (sys_defaults.perpetual_accounting) {
this.frm.add_fetch("company", "stock_adjustment_account", "expense_account");
+ this.frm.add_fetch("company", "cost_center", "cost_center");
this.frm.fields_dict["expense_account"].get_query = function() {
return {
diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.py b/stock/doctype/stock_reconciliation/stock_reconciliation.py
index c91344f..52542eb 100644
--- a/stock/doctype/stock_reconciliation/stock_reconciliation.py
+++ b/stock/doctype/stock_reconciliation/stock_reconciliation.py
@@ -17,6 +17,7 @@
def validate(self):
self.validate_data()
+ self.validate_expense_account()
def on_submit(self):
self.insert_stock_ledger_entries()
@@ -299,12 +300,7 @@
def make_gl_entries(self):
if not cint(webnotes.defaults.get_global_default("perpetual_accounting")):
return
-
- if not self.doc.expense_account:
- msgprint(_("Please enter Expense Account"), raise_exception=1)
- else:
- self.validate_expense_account()
-
+
if not self.doc.cost_center:
msgprint(_("Please enter Cost Center"), raise_exception=1)
@@ -327,13 +323,19 @@
self.sync_stock_account_balance(warehouse_list, self.doc.cost_center)
def validate_expense_account(self):
- if not webnotes.conn.sql("select * from `tabStock Ledger Entry`"):
+ if not cint(webnotes.defaults.get_global_default("perpetual_accounting")):
+ return
+
+ if not self.doc.expense_account:
+ msgprint(_("Please enter Expense Account"), raise_exception=1)
+ elif not webnotes.conn.sql("""select * from `tabStock Ledger Entry`
+ where ifnull(is_cancelled, 'No') = 'No'"""):
if webnotes.conn.get_value("Account", self.doc.expense_account,
"is_pl_account") == "Yes":
msgprint(_("""Expense Account can not be a PL Account, as this stock \
- reconciliation is an opening entry. Please select 'Temporary Liability' or \
- relevant account"""), raise_exception=1)
-
+ reconciliation is an opening entry. \
+ Please select 'Temporary Account (Liabilities)' or relevant account"""),
+ raise_exception=1)
@webnotes.whitelist()
def upload():
diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.txt b/stock/doctype/stock_reconciliation/stock_reconciliation.txt
index a00547c..2891ad2 100644
--- a/stock/doctype/stock_reconciliation/stock_reconciliation.txt
+++ b/stock/doctype/stock_reconciliation/stock_reconciliation.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-03-28 10:35:31",
"docstatus": 0,
- "modified": "2013-08-07 11:14:17",
+ "modified": "2013-08-07 18:16:18",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -111,6 +111,13 @@
},
{
"doctype": "DocField",
+ "fieldname": "cost_center",
+ "fieldtype": "Link",
+ "label": "Cost Center",
+ "options": "Cost Center"
+ },
+ {
+ "doctype": "DocField",
"fieldname": "col1",
"fieldtype": "Column Break"
},