From 375a3c003dd26053d34b1775587035cdd0a33c62 Mon Sep 17 00:00:00 2001 From: Chude Osiegbu Date: Mon, 19 Sep 2016 02:35:32 +0100 Subject: [PATCH] Update to erpnext/public/js/controllers/transaction.js in order to enable it detect when the doctype for which exchange rate is to be determined is a Sales Order or Purchase order. If it is either, then use transaction_date instead of posting_date as the argument to get_exchange_rate method --- erpnext/public/js/controllers/transaction.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 78776a3833..274e295bbb 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -417,6 +417,16 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ }, currency: function() { + /* cksgb 19/09/2016: We need to detect if this transaction is a PO/SO. + If so, use transaction_date. + If not, use posting_date as we assume that any other document type is an accounting document. */ + + if (this.frm.doc.doctype == "Purchase Order" || this.frm.doc.doctype == "Sales Order"){ + lookup_date = this.frm.doc.transaction_date; + }else{ + lookup_date = this.frm.doc.posting_date; + } + var me = this; this.set_dynamic_labels(); @@ -424,7 +434,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ // 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(this.frm.doc.posting_date, this.frm.doc.currency, company_currency, + this.get_exchange_rate(lookup_date, this.frm.doc.currency, company_currency, function(exchange_rate) { me.frm.set_value("conversion_rate", exchange_rate); });