Skip to content

Commit 0bf6697

Browse files
author
Andreas Müller
committed
round subtotals to 0.01
1 parent 8058e70 commit 0bf6697

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/output/invoice.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ class invoice extends Base {
2020
this.invoiceVAT = this.config.get('invoiceVAT');
2121
this.invoiceCurrencyMaxUnit = this.config.get('invoiceCurrencyMaxUnit');
2222
this.totalhForInvoice = (this.spent-this.spentFree) / 3600.0;
23-
this.totalForInvoiceExkl = this.totalhForInvoice * this.invoiceCurrencyPerHour;
24-
this.totalForInvoiceMwst = this.totalForInvoiceExkl * this.invoiceVAT;
25-
this.totalForInvoice = this.totalForInvoiceExkl + this.totalForInvoiceMwst;
26-
// round
27-
this.totalForInvoice = Math.round(this.totalForInvoice/this.invoiceCurrencyMaxUnit)*this.invoiceCurrencyMaxUnit;
23+
// round subtotals to 0.01 and total to invoiceCurrencyMaxUnit.
24+
this.totalForInvoiceExkl = Math.round(this.totalhForInvoice * this.invoiceCurrencyPerHour * 100) * 0.01;
25+
this.totalForInvoiceMwst = Math.round(this.totalhForInvoice * this.invoiceCurrencyPerHour * this.invoiceVAT * 100) * 0.01;
26+
this.totalForInvoice = Math.round((this.totalForInvoiceExkl + this.totalForInvoiceMwst)/this.invoiceCurrencyMaxUnit)*this.invoiceCurrencyMaxUnit;
2827
}
2928

3029

0 commit comments

Comments
 (0)