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
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 78776a3..274e295 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -417,6 +417,16 @@
},
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 @@
// 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);
});