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:
Mangesh-Khairnar 2019-06-28 12:38:40 +05:30 committed by Nabin Hait
parent 130dcffcc8
commit 4000fb5bb8
3 changed files with 460 additions and 436 deletions

View File

@ -39,8 +39,6 @@ frappe.ui.form.on('Exchange Rate Revaluation', {
});
frm.events.get_total_gain_loss(frm);
refresh_field("accounts");
} else {
frappe.msgprint(__("No records found"));
}
}
});

View File

@ -33,8 +33,9 @@ class ExchangeRateRevaluation(Document):
company_currency = erpnext.get_company_currency(self.company)
precision = get_field_precision(frappe.get_meta("Exchange Rate Revaluation Account")
.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 \
if d.balance_in_account_currency else 0
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_balance_in_base_currency": new_balance_in_base_currency
})
if not accounts:
self.throw_invalid_response_message(account_details)
return accounts
def get_accounts_from_gle(self):
@ -83,6 +88,13 @@ class ExchangeRateRevaluation(Document):
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):
if self.total_gain_loss == 0:
return

View File

@ -20,6 +20,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "account",
"fieldtype": "Link",
"hidden": 0,
@ -53,6 +54,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "party_type",
"fieldtype": "Link",
"hidden": 0,
@ -86,6 +88,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "party",
"fieldtype": "Dynamic Link",
"hidden": 0,
@ -119,6 +122,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_2",
"fieldtype": "Column Break",
"hidden": 0,
@ -150,6 +154,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "account_currency",
"fieldtype": "Link",
"hidden": 0,
@ -183,6 +188,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "balance_in_account_currency",
"fieldtype": "Currency",
"hidden": 0,
@ -195,6 +201,7 @@
"label": "Balance In Account Currency",
"length": 0,
"no_copy": 0,
"options": "account_currency",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@ -215,6 +222,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "balances",
"fieldtype": "Section Break",
"hidden": 0,
@ -247,6 +255,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "current_exchange_rate",
"fieldtype": "Float",
"hidden": 0,
@ -279,6 +288,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "balance_in_base_currency",
"fieldtype": "Currency",
"hidden": 0,
@ -311,6 +321,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_9",
"fieldtype": "Column Break",
"hidden": 0,
@ -342,6 +353,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "new_exchange_rate",
"fieldtype": "Float",
"hidden": 0,
@ -374,6 +386,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "new_balance_in_base_currency",
"fieldtype": "Currency",
"hidden": 0,
@ -406,6 +419,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "gain_loss",
"fieldtype": "Currency",
"hidden": 0,
@ -442,7 +456,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2019-01-07 16:52:07.327930",
"modified": "2019-06-26 18:57:51.762345",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Exchange Rate Revaluation Account",