mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Enable setting exchange rate when converting product prices
This commit is contained in:
parent
464e0b95e0
commit
c3b12ed9e6
@ -1059,23 +1059,33 @@ ko.bindingHandlers.productTypeahead = {
|
|||||||
|
|
||||||
// optionally handle curency conversion
|
// optionally handle curency conversion
|
||||||
@if ($account->convert_products)
|
@if ($account->convert_products)
|
||||||
var client = window.model.invoice().client();
|
var rate = false;
|
||||||
if (client) {
|
if ((account.custom_fields.invoice_text1 || '').toLowerCase() == "{{ strtolower(trans('texts.exchange_rate')) }}") {
|
||||||
var clientCurrencyId = client.currency_id();
|
rate = window.model.invoice().custom_text_value1();
|
||||||
var accountCurrencyId = {{ $account->getCurrencyId() }};
|
} else if ((account.custom_fields.invoice_text1 || '').toLowerCase() == "{{ strtolower(trans('texts.exchange_rate')) }}") {
|
||||||
if (clientCurrencyId && clientCurrencyId != accountCurrencyId) {
|
rate = window.model.invoice().custom_text_value1();
|
||||||
cost = fx.convert(cost, {
|
}
|
||||||
from: currencyMap[accountCurrencyId].code,
|
if (rate) {
|
||||||
to: currencyMap[clientCurrencyId].code,
|
cost = cost * rate;
|
||||||
});
|
} else {
|
||||||
var rate = fx.convert(1, {
|
var client = window.model.invoice().client();
|
||||||
from: currencyMap[accountCurrencyId].code,
|
if (client) {
|
||||||
to: currencyMap[clientCurrencyId].code,
|
var clientCurrencyId = client.currency_id();
|
||||||
});
|
var accountCurrencyId = {{ $account->getCurrencyId() }};
|
||||||
if ((account.custom_fields.invoice_text1 || '').toLowerCase() == "{{ strtolower(trans('texts.exchange_rate')) }}") {
|
if (clientCurrencyId && clientCurrencyId != accountCurrencyId) {
|
||||||
window.model.invoice().custom_text_value1(roundToFour(rate, true));
|
cost = fx.convert(cost, {
|
||||||
} else if ((account.custom_fields.invoice_text1 || '').toLowerCase() == "{{ strtolower(trans('texts.exchange_rate')) }}") {
|
from: currencyMap[accountCurrencyId].code,
|
||||||
window.model.invoice().custom_text_value2(roundToFour(rate, true));
|
to: currencyMap[clientCurrencyId].code,
|
||||||
|
});
|
||||||
|
var rate = fx.convert(1, {
|
||||||
|
from: currencyMap[accountCurrencyId].code,
|
||||||
|
to: currencyMap[clientCurrencyId].code,
|
||||||
|
});
|
||||||
|
if ((account.custom_fields.invoice_text1 || '').toLowerCase() == "{{ strtolower(trans('texts.exchange_rate')) }}") {
|
||||||
|
window.model.invoice().custom_text_value1(roundToFour(rate, true));
|
||||||
|
} else if ((account.custom_fields.invoice_text1 || '').toLowerCase() == "{{ strtolower(trans('texts.exchange_rate')) }}") {
|
||||||
|
window.model.invoice().custom_text_value2(roundToFour(rate, true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user