fix: Label and UX fixes while creating payment entry against customer (#20465)
* fix: Label and UX fixes while creating payment entry against customer
* fix: filter
diff --git a/erpnext/accounts/doctype/bank_account/bank_account.json b/erpnext/accounts/doctype/bank_account/bank_account.json
index 8e30b85..c8ae26d 100644
--- a/erpnext/accounts/doctype/bank_account/bank_account.json
+++ b/erpnext/accounts/doctype/bank_account/bank_account.json
@@ -1,4 +1,5 @@
{
+ "actions": [],
"allow_import": 1,
"allow_rename": 1,
"creation": "2017-05-29 21:35:13.136357",
@@ -82,7 +83,7 @@
"default": "0",
"fieldname": "is_default",
"fieldtype": "Check",
- "label": "Is the Default Account"
+ "label": "Is Default Account"
},
{
"default": "0",
@@ -211,7 +212,8 @@
"read_only": 1
}
],
- "modified": "2019-10-02 01:34:12.417601",
+ "links": [],
+ "modified": "2020-01-29 20:42:26.458316",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Bank Account",
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py
index e36e23a..55d2758 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.py
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py
@@ -102,7 +102,9 @@
self.bank = bank_data.bank
self.bank_account_no = bank_data.bank_account_no
- self.set(field, bank_data.account)
+
+ if not self.get(field):
+ self.set(field, bank_data.account)
def validate_allocated_amount(self):
for d in self.get("references"):
diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js
index ec1b79b..825b170 100644
--- a/erpnext/selling/doctype/customer/customer.js
+++ b/erpnext/selling/doctype/customer/customer.js
@@ -55,6 +55,14 @@
}
}
})
+
+ frm.set_query('default_bank_account', function() {
+ return {
+ filters: {
+ 'is_company_account': 1
+ }
+ }
+ });
},
customer_primary_address: function(frm){
if(frm.doc.customer_primary_address){
diff --git a/erpnext/selling/doctype/customer/customer.json b/erpnext/selling/doctype/customer/customer.json
index dc8febd..89ce325 100644
--- a/erpnext/selling/doctype/customer/customer.json
+++ b/erpnext/selling/doctype/customer/customer.json
@@ -1,4 +1,5 @@
{
+ "actions": [],
"allow_events_in_timeline": 1,
"allow_import": 1,
"allow_rename": 1,
@@ -122,7 +123,7 @@
{
"fieldname": "default_bank_account",
"fieldtype": "Link",
- "label": "Default Bank Account",
+ "label": "Default Company Bank Account",
"options": "Bank Account"
},
{
@@ -470,7 +471,8 @@
"icon": "fa fa-user",
"idx": 363,
"image_field": "image",
- "modified": "2020-01-24 15:07:48.815546",
+ "links": [],
+ "modified": "2020-01-29 20:36:37.879581",
"modified_by": "Administrator",
"module": "Selling",
"name": "Customer",
diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py
index 136236c..7f2fe60 100644
--- a/erpnext/selling/doctype/customer/customer.py
+++ b/erpnext/selling/doctype/customer/customer.py
@@ -54,6 +54,7 @@
self.validate_credit_limit_on_change()
self.set_loyalty_program()
self.check_customer_group_change()
+ self.validate_default_bank_account()
# set loyalty program tier
if frappe.db.exists('Customer', self.name):
@@ -72,6 +73,11 @@
if self.customer_group != frappe.db.get_value('Customer', self.name, 'customer_group'):
frappe.flags.customer_group_changed = True
+ def validate_default_bank_account(self):
+ if self.default_bank_account:
+ is_company_account = frappe.db.get_value('Bank Account', self.default_bank_account, 'is_company_account')
+ frappe.throw(_("{0} is not a company bank account").format(frappe.bold(self.default_bank_account)))
+
def on_update(self):
self.validate_name_with_customer_group()
self.create_primary_contact()