get exchange rate on change of date
This commit is contained in:
parent
1cc55fbbcb
commit
87d70279c6
@ -413,6 +413,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
transaction_date: function() {
|
||||
if (this.frm.doc.transaction_date) {
|
||||
this.frm.transaction_date = this.frm.doc.transaction_date;
|
||||
frappe.ui.form.trigger(me.frm.doc.doctype, "currency");
|
||||
}
|
||||
},
|
||||
|
||||
@ -434,9 +435,12 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
callback: function(r, rt) {
|
||||
if(r.message) {
|
||||
me.frm.set_value("due_date", r.message);
|
||||
frappe.ui.form.trigger(me.frm.doc.doctype, "currency");
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
frappe.ui.form.trigger(me.frm.doc.doctype, "currency");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -74,7 +74,13 @@ def get_exchange_rate(translation_date, from_currency, to_currency):
|
||||
return 1
|
||||
|
||||
# cksgb 19/09/2016: get all entries in Currency Exchange with from_currency and to_currency. Order by date desc. Top one is the required exchange rate
|
||||
entries = frappe.get_all("Currency Exchange", fields = ["*"], filters=[["date", "<=", get_datetime_str(translation_date)], ["from_currency", "=", from_currency], ["to_currency", "=", to_currency]], order_by="date desc")
|
||||
entries = frappe.get_all("Currency Exchange", fields = ["exchange_rate"],
|
||||
filters=[
|
||||
["date", "<=", get_datetime_str(translation_date)],
|
||||
["from_currency", "=", from_currency],
|
||||
["to_currency", "=", to_currency]
|
||||
], order_by="date desc", limit=1)
|
||||
|
||||
if entries:
|
||||
return flt(entries[0].exchange_rate)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user