Add For Buying and For Selling checkboxes in Currency Exchange

This commit is contained in:
Shreya
2018-05-15 11:25:46 +05:30
parent 12f708d155
commit 0db85067b2
5 changed files with 155 additions and 19 deletions

View File

@@ -599,14 +599,13 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
/* manqala 19/09/2016: let the translation date be whichever of the transaction_date or posting_date is available */
var transaction_date = this.frm.doc.transaction_date || this.frm.doc.posting_date;
/* end manqala */
var me = this;
this.set_dynamic_labels();
var company_currency = this.get_company_currency();
// Added `ignore_pricing_rule` to determine if document is loading after mapping from another doc
if(this.frm.doc.currency && this.frm.doc.currency !== company_currency
&& !this.frm.doc.ignore_pricing_rule) {
this.get_exchange_rate(transaction_date, this.frm.doc.currency, company_currency,
function(exchange_rate) {
me.frm.set_value("conversion_rate", exchange_rate);
@@ -668,13 +667,17 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
},
get_exchange_rate: function(transaction_date, from_currency, to_currency, callback) {
if (this.frm.doctype == "Purchase Order") {
var args = "for_buying";
}
if (!transaction_date || !from_currency || !to_currency) return;
return frappe.call({
method: "erpnext.setup.utils.get_exchange_rate",
args: {
transaction_date: transaction_date,
from_currency: from_currency,
to_currency: to_currency
to_currency: to_currency,
args: args
},
callback: function(r) {
callback(flt(r.message));