Enable setting exchange rate when converting product prices

This commit is contained in:
Hillel Coren 2018-04-12 20:36:25 +03:00
parent 464e0b95e0
commit c3b12ed9e6

View File

@ -1059,6 +1059,15 @@ ko.bindingHandlers.productTypeahead = {
// optionally handle curency conversion // optionally handle curency conversion
@if ($account->convert_products) @if ($account->convert_products)
var rate = false;
if ((account.custom_fields.invoice_text1 || '').toLowerCase() == "{{ strtolower(trans('texts.exchange_rate')) }}") {
rate = window.model.invoice().custom_text_value1();
} else if ((account.custom_fields.invoice_text1 || '').toLowerCase() == "{{ strtolower(trans('texts.exchange_rate')) }}") {
rate = window.model.invoice().custom_text_value1();
}
if (rate) {
cost = cost * rate;
} else {
var client = window.model.invoice().client(); var client = window.model.invoice().client();
if (client) { if (client) {
var clientCurrencyId = client.currency_id(); var clientCurrencyId = client.currency_id();
@ -1079,6 +1088,7 @@ ko.bindingHandlers.productTypeahead = {
} }
} }
} }
}
@endif @endif
model.cost(roundToTwo(cost, true)); model.cost(roundToTwo(cost, true));