[fix] minor auto-select party type and add has_permission in whitelisted methods
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js
index eac8f44..b05adbd 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.js
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js
@@ -225,11 +225,12 @@
var d = locals[dt][dn];
if(d.account) {
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},
callback: function(r) {
- d.balance = r.message;
+ $.extend(d, r.message);
refresh_field('balance', d.name, 'accounts');
+ refresh_field('party_type', d.name, 'accounts');
}
});
}
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index 00e2e91..d891dd5 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -611,6 +611,8 @@
@frappe.whitelist()
def get_outstanding(args):
+ if not frappe.has_permission("Account"):
+ frappe.msgprint(_("No Permission"), raise_exception=1)
args = eval(args)
if args.get("doctype") == "Journal Entry":
condition = " and party=%(party)s" if args.get("party") else ""
@@ -637,6 +639,9 @@
@frappe.whitelist()
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
account = get_party_account(company, party, party_type)
@@ -648,3 +653,16 @@
"balance": account_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, "")
+ }
+
diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py
index 933570f..b283c8f 100644
--- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py
+++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py
@@ -34,7 +34,7 @@
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.account = %(account)s and {dr_or_cr} > 0
- and ifnull(t2.reference_type, '')=''
+ and ifnull(t2.reference_type, '') in ('', 'Sales Order', 'Purchase Order')
{cond}
and (CASE
WHEN t1.voucher_type in ('Debit Note', 'Credit Note')
diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.js b/erpnext/accounts/page/accounts_browser/accounts_browser.js
index cb36d05..77a87ff 100644
--- a/erpnext/accounts/page/accounts_browser/accounts_browser.js
+++ b/erpnext/accounts/page/accounts_browser/accounts_browser.js
@@ -202,7 +202,7 @@
title:__('New Account'),
fields: [
{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'),
description: __('Further accounts can be made under Groups, but entries can be made against non-Groups')},
{fieldtype:'Select', fieldname:'account_type', label:__('Account Type'),