1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 12:42:36 +01:00

Support higher precision for unit cost and quantity

This commit is contained in:
Hillel Coren 2017-08-14 14:24:41 +03:00
parent 7a4a5d51f3
commit db714a17ac
4 changed files with 36 additions and 29 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -495,7 +495,7 @@ NINJA.invoiceLines = function(invoice, isSecondTable) {
var row = [];
var item = invoice.invoice_items[i];
var cost = formatMoneyInvoice(item.cost, invoice, 'none', getPrecision(item.cost));
var qty = NINJA.parseFloat(item.qty) ? roundToTwo(NINJA.parseFloat(item.qty)) + '' : '';
var qty = NINJA.parseFloat(item.qty) ? roundSignificant(NINJA.parseFloat(item.qty)) + '' : '';
var notes = item.notes;
var productKey = item.product_key;
var tax1 = '';
@ -565,7 +565,7 @@ NINJA.invoiceLines = function(invoice, isSecondTable) {
}
if (!hideQuantity) {
row.push({style:["cost", rowStyle], text:cost});
row.push({style:["quantity", rowStyle], text:formatAmount(qty, invoice.client.currency_id) || ' '});
row.push({style:["quantity", rowStyle], text:formatAmount(qty, invoice.client.currency_id, getPrecision(qty)) || ' '});
}
if (showItemTaxes) {
var str = ' ';

View File

@ -63,16 +63,23 @@
return formatMoney(value, currencyId, countryId, decorator, precision)
}
function formatAmount(value, currencyId) {
function formatAmount(value, currencyId, precision) {
if (!value) {
return '';
}
if (!currencyId) {
currencyId = {{ Session::get(SESSION_CURRENCY, DEFAULT_CURRENCY) }};
}
if (!precision) {
precision = 2;
}
var currency = currencyMap[currencyId];
var decimal = currency.decimal_separator;
value = NINJA.parseFloat(value) + '';
value = roundToPrecision(NINJA.parseFloat(value), precision) + '';
if (decimal == '.') {
return value;