[perpetual accounting] validate expense account in stock reconciliation
This commit is contained in:
parent
815a49e027
commit
95c748eb67
@ -30,6 +30,7 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
|||||||
var me = this;
|
var me = this;
|
||||||
if (sys_defaults.perpetual_accounting) {
|
if (sys_defaults.perpetual_accounting) {
|
||||||
this.frm.add_fetch("company", "stock_adjustment_account", "expense_account");
|
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() {
|
this.frm.fields_dict["expense_account"].get_query = function() {
|
||||||
return {
|
return {
|
||||||
|
@ -17,6 +17,7 @@ class DocType(StockController):
|
|||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_data()
|
self.validate_data()
|
||||||
|
self.validate_expense_account()
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
self.insert_stock_ledger_entries()
|
self.insert_stock_ledger_entries()
|
||||||
@ -299,12 +300,7 @@ class DocType(StockController):
|
|||||||
def make_gl_entries(self):
|
def make_gl_entries(self):
|
||||||
if not cint(webnotes.defaults.get_global_default("perpetual_accounting")):
|
if not cint(webnotes.defaults.get_global_default("perpetual_accounting")):
|
||||||
return
|
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:
|
if not self.doc.cost_center:
|
||||||
msgprint(_("Please enter Cost Center"), raise_exception=1)
|
msgprint(_("Please enter Cost Center"), raise_exception=1)
|
||||||
|
|
||||||
@ -327,13 +323,19 @@ class DocType(StockController):
|
|||||||
self.sync_stock_account_balance(warehouse_list, self.doc.cost_center)
|
self.sync_stock_account_balance(warehouse_list, self.doc.cost_center)
|
||||||
|
|
||||||
def validate_expense_account(self):
|
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,
|
if webnotes.conn.get_value("Account", self.doc.expense_account,
|
||||||
"is_pl_account") == "Yes":
|
"is_pl_account") == "Yes":
|
||||||
msgprint(_("""Expense Account can not be a PL Account, as this stock \
|
msgprint(_("""Expense Account can not be a PL Account, as this stock \
|
||||||
reconciliation is an opening entry. Please select 'Temporary Liability' or \
|
reconciliation is an opening entry. \
|
||||||
relevant account"""), raise_exception=1)
|
Please select 'Temporary Account (Liabilities)' or relevant account"""),
|
||||||
|
raise_exception=1)
|
||||||
|
|
||||||
@webnotes.whitelist()
|
@webnotes.whitelist()
|
||||||
def upload():
|
def upload():
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-03-28 10:35:31",
|
"creation": "2013-03-28 10:35:31",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-08-07 11:14:17",
|
"modified": "2013-08-07 18:16:18",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@ -109,6 +109,13 @@
|
|||||||
"label": "Expense Account",
|
"label": "Expense Account",
|
||||||
"options": "Account"
|
"options": "Account"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "cost_center",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Cost Center",
|
||||||
|
"options": "Cost Center"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "col1",
|
"fieldname": "col1",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user