[fix] filter and validation of Debit To and Credit To accounts
This commit is contained in:
parent
f326c63588
commit
2b6bdc1edb
@ -148,12 +148,22 @@ cur_frm.fields_dict['items'].grid.get_field("item_code").get_query = function(do
|
|||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.fields_dict['credit_to'].get_query = function(doc) {
|
cur_frm.fields_dict['credit_to'].get_query = function(doc) {
|
||||||
return{
|
// filter on Account
|
||||||
filters:{
|
if (doc.supplier) {
|
||||||
'account_type': 'Payable',
|
return {
|
||||||
'root_type': 'Liability',
|
filters: {
|
||||||
'is_group': 0,
|
'account_type': 'Payable',
|
||||||
'company': doc.company
|
'is_group': 0,
|
||||||
|
'company': doc.company
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
'report_type': 'Balance Sheet',
|
||||||
|
'is_group': 0,
|
||||||
|
'company': doc.company
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,8 +91,12 @@ class PurchaseInvoice(BuyingController):
|
|||||||
throw(_("Conversion rate cannot be 0 or 1"))
|
throw(_("Conversion rate cannot be 0 or 1"))
|
||||||
|
|
||||||
def validate_credit_to_acc(self):
|
def validate_credit_to_acc(self):
|
||||||
account_type = frappe.db.get_value("Account", self.credit_to, "account_type")
|
account = frappe.db.get_value("Account", self.credit_to, ["account_type", "report_type"], as_dict=True)
|
||||||
if account_type != "Payable":
|
|
||||||
|
if account.report_type != "Balance Sheet":
|
||||||
|
frappe.throw(_("Credit To account must be a Balance Sheet account"))
|
||||||
|
|
||||||
|
if self.supplier and account.account_type != "Payable":
|
||||||
frappe.throw(_("Credit To account must be a Payable account"))
|
frappe.throw(_("Credit To account must be a Payable account"))
|
||||||
|
|
||||||
def check_for_stopped_status(self):
|
def check_for_stopped_status(self):
|
||||||
|
|||||||
@ -405,10 +405,22 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.set_query("debit_to", function(doc) {
|
cur_frm.set_query("debit_to", function(doc) {
|
||||||
return{
|
// filter on Account
|
||||||
filters: [
|
if (doc.customer) {
|
||||||
['Account', 'root_type', '=', 'Asset'],
|
return {
|
||||||
['Account', 'account_type', '=', 'Receivable']
|
filters: {
|
||||||
]
|
'account_type': 'Receivable',
|
||||||
|
'is_group': 0,
|
||||||
|
'company': doc.company
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
'report_type': 'Balance Sheet',
|
||||||
|
'is_group': 0,
|
||||||
|
'company': doc.company
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -271,8 +271,12 @@ class SalesInvoice(SellingController):
|
|||||||
reconcile_against_document(lst)
|
reconcile_against_document(lst)
|
||||||
|
|
||||||
def validate_debit_to_acc(self):
|
def validate_debit_to_acc(self):
|
||||||
account_type = frappe.db.get_value("Account", self.debit_to, "account_type")
|
account = frappe.db.get_value("Account", self.debit_to, ["account_type", "report_type"], as_dict=True)
|
||||||
if account_type != "Receivable":
|
|
||||||
|
if account.report_type != "Balance Sheet":
|
||||||
|
frappe.throw(_("Debit To account must be a Balance Sheet account"))
|
||||||
|
|
||||||
|
if self.customer and account.account_type != "Receivable":
|
||||||
frappe.throw(_("Debit To account must be a Receivable account"))
|
frappe.throw(_("Debit To account must be a Receivable account"))
|
||||||
|
|
||||||
def validate_fixed_asset_account(self):
|
def validate_fixed_asset_account(self):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user