Merge pull request #14048 from shreyashah115/exchange-rate

[Enhancement] Buying and Selling checkboxes in Currency Exchange
This commit is contained in:
rohitwaghchaure
2018-05-15 17:55:09 +05:30
committed by GitHub
14 changed files with 185 additions and 30 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,22 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
},
get_exchange_rate: function(transaction_date, from_currency, to_currency, callback) {
var args;
if (["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"].includes(this.frm.doctype)) {
args = "for_selling";
}
else if (["Purchase Order", "Purchase Receipt", "Purchase Invoice"].includes(this.frm.doctype)) {
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));