Merge pull request #9769 from manassolanki/payment-entry
frappe call if posting date is defined
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js
index 5bfd4d9..63832fa 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.js
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js
@@ -291,37 +291,39 @@
set_account_currency_and_balance: function(frm, account, currency_field,
balance_field, callback_function) {
- frappe.call({
- method: "erpnext.accounts.doctype.payment_entry.payment_entry.get_account_details",
- args: {
- "account": account,
- "date": frm.doc.posting_date
- },
- callback: function(r, rt) {
- if(r.message) {
- frm.set_value(currency_field, r.message['account_currency']);
- frm.set_value(balance_field, r.message['account_balance']);
+ if (frm.doc.posting_date) {
+ frappe.call({
+ method: "erpnext.accounts.doctype.payment_entry.payment_entry.get_account_details",
+ args: {
+ "account": account,
+ "date": frm.doc.posting_date
+ },
+ callback: function(r, rt) {
+ if(r.message) {
+ frm.set_value(currency_field, r.message['account_currency']);
+ frm.set_value(balance_field, r.message['account_balance']);
- if(frm.doc.payment_type=="Receive" && currency_field=="paid_to_account_currency") {
- frm.toggle_reqd(["reference_no", "reference_date"],
- (r.message['account_type'] == "Bank" ? 1 : 0));
- if(!frm.doc.received_amount && frm.doc.paid_amount)
- frm.events.paid_amount(frm);
- } else if(frm.doc.payment_type=="Pay" && currency_field=="paid_from_account_currency") {
- frm.toggle_reqd(["reference_no", "reference_date"],
- (r.message['account_type'] == "Bank" ? 1 : 0));
+ if(frm.doc.payment_type=="Receive" && currency_field=="paid_to_account_currency") {
+ frm.toggle_reqd(["reference_no", "reference_date"],
+ (r.message['account_type'] == "Bank" ? 1 : 0));
+ if(!frm.doc.received_amount && frm.doc.paid_amount)
+ frm.events.paid_amount(frm);
+ } else if(frm.doc.payment_type=="Pay" && currency_field=="paid_from_account_currency") {
+ frm.toggle_reqd(["reference_no", "reference_date"],
+ (r.message['account_type'] == "Bank" ? 1 : 0));
- if(!frm.doc.paid_amount && frm.doc.received_amount)
- frm.events.received_amount(frm);
+ if(!frm.doc.paid_amount && frm.doc.received_amount)
+ frm.events.received_amount(frm);
+ }
+
+ if(callback_function) callback_function(frm);
+
+ frm.events.hide_unhide_fields(frm);
+ frm.events.set_dynamic_labels(frm);
}
-
- if(callback_function) callback_function(frm);
-
- frm.events.hide_unhide_fields(frm);
- frm.events.set_dynamic_labels(frm);
}
- }
- });
+ });
+ }
},
paid_from_account_currency: function(frm) {