mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 01:44:30 -04:00
Convert currencies
This commit is contained in:
parent
4683f66fc6
commit
d6590455f1
@ -30,7 +30,7 @@ class ProductDatatable extends EntityDatatable
|
||||
[
|
||||
'cost',
|
||||
function ($model) {
|
||||
return Utils::roundSignificant($model->cost);
|
||||
return Utils::formatMoney($model->cost);
|
||||
},
|
||||
],
|
||||
[
|
||||
|
@ -1037,7 +1037,20 @@ ko.bindingHandlers.productTypeahead = {
|
||||
}
|
||||
if (parseFloat(datum.cost)) {
|
||||
if (! model.cost() || ! model.task_public_id()) {
|
||||
model.cost(roundSignificant(datum.cost, true));
|
||||
// optionally handle curency conversion
|
||||
var cost = datum.cost;
|
||||
var client = window.model.invoice().client();
|
||||
if (client) {
|
||||
var clientCurrencyId = client.currency_id();
|
||||
if (clientCurrencyId) {
|
||||
var accountCurrencyId = {{ $account->getCurrencyId() }};
|
||||
cost = fx.convert(cost, {
|
||||
from: currencyMap[accountCurrencyId].code,
|
||||
to: currencyMap[clientCurrencyId].code,
|
||||
});
|
||||
}
|
||||
}
|
||||
model.cost(roundSignificant(cost, true));
|
||||
}
|
||||
}
|
||||
if (!model.qty() && ! model.task_public_id()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user