[fix] minor auto-select party type and add has_permission in whitelisted methods
This commit is contained in:
parent
207b3efed7
commit
ed40542658
@ -225,11 +225,12 @@ cur_frm.cscript.account = function(doc,dt,dn) {
|
|||||||
var d = locals[dt][dn];
|
var d = locals[dt][dn];
|
||||||
if(d.account) {
|
if(d.account) {
|
||||||
return frappe.call({
|
return frappe.call({
|
||||||
method: "erpnext.accounts.utils.get_balance_on",
|
method: "erpnext.accounts.doctype.journal_entry.journal_entry.get_account_balance_and_party_type",
|
||||||
args: {account: d.account, date: doc.posting_date},
|
args: {account: d.account, date: doc.posting_date},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
d.balance = r.message;
|
$.extend(d, r.message);
|
||||||
refresh_field('balance', d.name, 'accounts');
|
refresh_field('balance', d.name, 'accounts');
|
||||||
|
refresh_field('party_type', d.name, 'accounts');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -611,6 +611,8 @@ def get_against_jv(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_outstanding(args):
|
def get_outstanding(args):
|
||||||
|
if not frappe.has_permission("Account"):
|
||||||
|
frappe.msgprint(_("No Permission"), raise_exception=1)
|
||||||
args = eval(args)
|
args = eval(args)
|
||||||
if args.get("doctype") == "Journal Entry":
|
if args.get("doctype") == "Journal Entry":
|
||||||
condition = " and party=%(party)s" if args.get("party") else ""
|
condition = " and party=%(party)s" if args.get("party") else ""
|
||||||
@ -637,6 +639,9 @@ def get_outstanding(args):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_party_account_and_balance(company, party_type, party):
|
def get_party_account_and_balance(company, party_type, party):
|
||||||
|
if not frappe.has_permission("Account"):
|
||||||
|
frappe.msgprint(_("No Permission"), raise_exception=1)
|
||||||
|
|
||||||
from erpnext.accounts.party import get_party_account
|
from erpnext.accounts.party import get_party_account
|
||||||
account = get_party_account(company, party, party_type)
|
account = get_party_account(company, party, party_type)
|
||||||
|
|
||||||
@ -648,3 +653,16 @@ def get_party_account_and_balance(company, party_type, party):
|
|||||||
"balance": account_balance,
|
"balance": account_balance,
|
||||||
"party_balance": party_balance
|
"party_balance": party_balance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def get_account_balance_and_party_type(account, date):
|
||||||
|
"""Returns dict of account balance and party type to be set in Journal Entry on selection of account."""
|
||||||
|
if not frappe.has_permission("Account"):
|
||||||
|
frappe.msgprint(_("No Permission"), raise_exception=1)
|
||||||
|
|
||||||
|
account_type = frappe.db.get_value("Account", account, "account_type")
|
||||||
|
return {
|
||||||
|
"balance": get_balance_on(account, date),
|
||||||
|
"party_type": {"Receivable":"Customer", "Payable":"Supplier"}.get(account_type, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ class PaymentReconciliation(Document):
|
|||||||
t1.name = t2.parent and t1.docstatus = 1 and t2.docstatus = 1
|
t1.name = t2.parent and t1.docstatus = 1 and t2.docstatus = 1
|
||||||
and t2.party_type = %(party_type)s and t2.party = %(party)s
|
and t2.party_type = %(party_type)s and t2.party = %(party)s
|
||||||
and t2.account = %(account)s and {dr_or_cr} > 0
|
and t2.account = %(account)s and {dr_or_cr} > 0
|
||||||
and ifnull(t2.reference_type, '')=''
|
and ifnull(t2.reference_type, '') in ('', 'Sales Order', 'Purchase Order')
|
||||||
{cond}
|
{cond}
|
||||||
and (CASE
|
and (CASE
|
||||||
WHEN t1.voucher_type in ('Debit Note', 'Credit Note')
|
WHEN t1.voucher_type in ('Debit Note', 'Credit Note')
|
||||||
|
@ -202,7 +202,7 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
title:__('New Account'),
|
title:__('New Account'),
|
||||||
fields: [
|
fields: [
|
||||||
{fieldtype:'Data', fieldname:'account_name', label:__('New Account Name'), reqd:true,
|
{fieldtype:'Data', fieldname:'account_name', label:__('New Account Name'), reqd:true,
|
||||||
description: __("Name of new Account. Note: Please don't create accounts for Customers and Suppliers, they are created automatically from the Customer and Supplier master")},
|
description: __("Name of new Account. Note: Please don't create accounts for Customers and Suppliers")},
|
||||||
{fieldtype:'Check', fieldname:'is_group', label:__('Is Group'),
|
{fieldtype:'Check', fieldname:'is_group', label:__('Is Group'),
|
||||||
description: __('Further accounts can be made under Groups, but entries can be made against non-Groups')},
|
description: __('Further accounts can be made under Groups, but entries can be made against non-Groups')},
|
||||||
{fieldtype:'Select', fieldname:'account_type', label:__('Account Type'),
|
{fieldtype:'Select', fieldname:'account_type', label:__('Account Type'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user