fix: add a more descriptive message when no records are found (#18082)
* fix: add a more descriptive message when no records are found * fix: translation by passing string to translation function
This commit is contained in:
parent
130dcffcc8
commit
4000fb5bb8
@ -39,8 +39,6 @@ frappe.ui.form.on('Exchange Rate Revaluation', {
|
|||||||
});
|
});
|
||||||
frm.events.get_total_gain_loss(frm);
|
frm.events.get_total_gain_loss(frm);
|
||||||
refresh_field("accounts");
|
refresh_field("accounts");
|
||||||
} else {
|
|
||||||
frappe.msgprint(__("No records found"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -33,8 +33,9 @@ class ExchangeRateRevaluation(Document):
|
|||||||
company_currency = erpnext.get_company_currency(self.company)
|
company_currency = erpnext.get_company_currency(self.company)
|
||||||
precision = get_field_precision(frappe.get_meta("Exchange Rate Revaluation Account")
|
precision = get_field_precision(frappe.get_meta("Exchange Rate Revaluation Account")
|
||||||
.get_field("new_balance_in_base_currency"), company_currency)
|
.get_field("new_balance_in_base_currency"), company_currency)
|
||||||
for d in self.get_accounts_from_gle():
|
|
||||||
|
|
||||||
|
account_details = self.get_accounts_from_gle()
|
||||||
|
for d in account_details:
|
||||||
current_exchange_rate = d.balance / d.balance_in_account_currency \
|
current_exchange_rate = d.balance / d.balance_in_account_currency \
|
||||||
if d.balance_in_account_currency else 0
|
if d.balance_in_account_currency else 0
|
||||||
new_exchange_rate = get_exchange_rate(d.account_currency, company_currency, self.posting_date)
|
new_exchange_rate = get_exchange_rate(d.account_currency, company_currency, self.posting_date)
|
||||||
@ -52,6 +53,10 @@ class ExchangeRateRevaluation(Document):
|
|||||||
"new_exchange_rate": new_exchange_rate,
|
"new_exchange_rate": new_exchange_rate,
|
||||||
"new_balance_in_base_currency": new_balance_in_base_currency
|
"new_balance_in_base_currency": new_balance_in_base_currency
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if not accounts:
|
||||||
|
self.throw_invalid_response_message(account_details)
|
||||||
|
|
||||||
return accounts
|
return accounts
|
||||||
|
|
||||||
def get_accounts_from_gle(self):
|
def get_accounts_from_gle(self):
|
||||||
@ -83,6 +88,13 @@ class ExchangeRateRevaluation(Document):
|
|||||||
|
|
||||||
return account_details
|
return account_details
|
||||||
|
|
||||||
|
def throw_invalid_response_message(self, account_details):
|
||||||
|
if account_details:
|
||||||
|
message = _("No outstanding invoices require exchange rate revaluation")
|
||||||
|
else:
|
||||||
|
message = _("No outstanding invoices found")
|
||||||
|
frappe.msgprint(message)
|
||||||
|
|
||||||
def make_jv_entry(self):
|
def make_jv_entry(self):
|
||||||
if self.total_gain_loss == 0:
|
if self.total_gain_loss == 0:
|
||||||
return
|
return
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "account",
|
"fieldname": "account",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -53,6 +54,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "party_type",
|
"fieldname": "party_type",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -86,6 +88,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "party",
|
"fieldname": "party",
|
||||||
"fieldtype": "Dynamic Link",
|
"fieldtype": "Dynamic Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -119,6 +122,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "column_break_2",
|
"fieldname": "column_break_2",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -150,6 +154,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "account_currency",
|
"fieldname": "account_currency",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -183,6 +188,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "balance_in_account_currency",
|
"fieldname": "balance_in_account_currency",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -195,6 +201,7 @@
|
|||||||
"label": "Balance In Account Currency",
|
"label": "Balance In Account Currency",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
|
"options": "account_currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
@ -215,6 +222,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "balances",
|
"fieldname": "balances",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -247,6 +255,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "current_exchange_rate",
|
"fieldname": "current_exchange_rate",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -279,6 +288,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "balance_in_base_currency",
|
"fieldname": "balance_in_base_currency",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -311,6 +321,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "column_break_9",
|
"fieldname": "column_break_9",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -342,6 +353,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "new_exchange_rate",
|
"fieldname": "new_exchange_rate",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -374,6 +386,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "new_balance_in_base_currency",
|
"fieldname": "new_balance_in_base_currency",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -406,6 +419,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "gain_loss",
|
"fieldname": "gain_loss",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -442,7 +456,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2019-01-07 16:52:07.327930",
|
"modified": "2019-06-26 18:57:51.762345",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Exchange Rate Revaluation Account",
|
"name": "Exchange Rate Revaluation Account",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user