1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Corrected rounding issue if qty or cost had greater than 2 precision

This commit is contained in:
Hillel Coren 2015-03-10 13:15:01 +02:00
parent e91c832cc2
commit 0ebf08c53d
5 changed files with 11 additions and 10 deletions

View File

@ -264,8 +264,8 @@ class InvoiceRepository
continue;
}
$invoiceItemCost = Utils::parseFloat($item['cost']);
$invoiceItemQty = Utils::parseFloat($item['qty']);
$invoiceItemCost = round(Utils::parseFloat($item['cost']), 2);
$invoiceItemQty = round(Utils::parseFloat($item['qty']), 2);
$invoiceItemTaxRate = 0;
if (isset($item['tax_rate']) && Utils::parseFloat($item['tax_rate']) > 0) {

View File

@ -1517,8 +1517,8 @@
this.totals = ko.observable();
this.totals.rawTotal = ko.computed(function() {
var cost = NINJA.parseFloat(self.cost());
var qty = NINJA.parseFloat(self.qty());
var cost = roundToTwo(NINJA.parseFloat(self.cost()));
var qty = roundToTwo(NINJA.parseFloat(self.qty()));
var taxRate = NINJA.parseFloat(self.tax_rate());
var value = cost * qty;
if (taxRate > 0) {

View File

@ -71,6 +71,7 @@
</p>
<p>{{ Button::success_submit(trans('texts.lets_go'), array('class' => 'btn-lg'))->block() }}</p>
<p class="link">
{{ link_to('forgot_password', trans('texts.forgot_password')) }}
</p>

View File

@ -32436,7 +32436,7 @@ function calculateAmounts(invoice) {
tax = parseFloat(item.tax_rate);
}
var lineTotal = NINJA.parseFloat(item.cost) * NINJA.parseFloat(item.qty);
var lineTotal = roundToTwo(NINJA.parseFloat(item.cost)) * roundToTwo(NINJA.parseFloat(item.qty));
if (tax) {
lineTotal += roundToTwo(lineTotal * tax / 100);
}
@ -32552,7 +32552,7 @@ function displayInvoiceItems(doc, invoice, layout) {
for (var i=0; i<invoice.invoice_items.length; i++) {
var item = invoice.invoice_items[i];
var cost = formatMoney(item.cost, currencyId, true);
var qty = NINJA.parseFloat(item.qty) ? NINJA.parseFloat(item.qty) + '' : '';
var qty = NINJA.parseFloat(item.qty) ? roundToTwo(NINJA.parseFloat(item.qty)) + '' : '';
var notes = item.notes;
var productKey = item.product_key;
var tax = 0;
@ -32593,7 +32593,7 @@ function displayInvoiceItems(doc, invoice, layout) {
productKey = processVariables(productKey);
}
var lineTotal = NINJA.parseFloat(item.cost) * NINJA.parseFloat(item.qty);
var lineTotal = roundToTwo(NINJA.parseFloat(item.cost)) * roundToTwo(NINJA.parseFloat(item.qty));
if (tax) {
lineTotal += lineTotal * tax / 100;
}

View File

@ -913,7 +913,7 @@ function calculateAmounts(invoice) {
tax = parseFloat(item.tax_rate);
}
var lineTotal = NINJA.parseFloat(item.cost) * NINJA.parseFloat(item.qty);
var lineTotal = roundToTwo(NINJA.parseFloat(item.cost)) * roundToTwo(NINJA.parseFloat(item.qty));
if (tax) {
lineTotal += roundToTwo(lineTotal * tax / 100);
}
@ -1029,7 +1029,7 @@ function displayInvoiceItems(doc, invoice, layout) {
for (var i=0; i<invoice.invoice_items.length; i++) {
var item = invoice.invoice_items[i];
var cost = formatMoney(item.cost, currencyId, true);
var qty = NINJA.parseFloat(item.qty) ? NINJA.parseFloat(item.qty) + '' : '';
var qty = NINJA.parseFloat(item.qty) ? roundToTwo(NINJA.parseFloat(item.qty)) + '' : '';
var notes = item.notes;
var productKey = item.product_key;
var tax = 0;
@ -1070,7 +1070,7 @@ function displayInvoiceItems(doc, invoice, layout) {
productKey = processVariables(productKey);
}
var lineTotal = NINJA.parseFloat(item.cost) * NINJA.parseFloat(item.qty);
var lineTotal = roundToTwo(NINJA.parseFloat(item.cost)) * roundToTwo(NINJA.parseFloat(item.qty));
if (tax) {
lineTotal += lineTotal * tax / 100;
}