Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
extra position on invoice
  • Loading branch information
Andreas Müller committed Sep 28, 2022
commit 307d85ba7bddb2d350187dd1db9c69117315601c
4 changes: 4 additions & 0 deletions src/gtt-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ program
.option('--invoiceDate <number>', 'date string')
.option('--invoiceCurrencyMaxUnit <number>', 'rouning invoice total, e.g. 0.01, 0.05 or 1')
.option('--invoicePositionText <text>', 'invoice position text')
.option('--invoicePositionExtraText <text>', 'extra invoice position: text')
.option('--invoicePositionExtraValue <number>', 'extra invoice position: value')
.parse(process.argv);

// init helpers
Expand Down Expand Up @@ -142,6 +144,8 @@ config
.set('invoiceDate', program.opts().invoiceDate)
.set('invoiceCurrencyMaxUnit', program.opts().invoiceCurrencyMaxUnit)
.set('invoicePositionText', program.opts().invoicePositionText)
.set('invoicePositionExtraText', program.opts().invoicePositionExtraText)
.set('invoicePositionExtraValue', program.opts().invoicePositionExtraValue)
.set('_createDump', program.opts().output === 'dump');

// date shortcuts
Expand Down
21 changes: 17 additions & 4 deletions src/output/invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@ class invoice extends Base {
this.invoiceCurrencyPerHour = this.config.get('invoiceCurrencyPerHour');
this.invoiceVAT = this.config.get('invoiceVAT');
this.invoicePositionText = this.config.get('invoicePositionText');
this.invoicePositionExtraText = this.config.get('invoicePositionExtraText');
this.invoicePositionExtraValue = parseFloat(this.config.get('invoicePositionExtraValue'));
if(!this.invoicePositionExtraValue > 0) {
this.invoicePositionExtraValue = 0.0;
}
this.invoiceCurrencyMaxUnit = this.config.get('invoiceCurrencyMaxUnit');
this.totalhForInvoice = (this.spent-this.spentFree) / 3600.0;
this.totalhForInvoice = (this.spent-this.spentFree-(this.spentHalfPrice*0.5)) / 3600.0;
// round subtotals to 0.01 and total to invoiceCurrencyMaxUnit.
this.totalForInvoiceExkl = Math.round(this.totalhForInvoice * this.invoiceCurrencyPerHour * 100) * 0.01;
this.totalForInvoiceMwst = Math.round(this.totalhForInvoice * this.invoiceCurrencyPerHour * this.invoiceVAT * 100) * 0.01;
let invoiceTotal = this.totalhForInvoice * this.invoiceCurrencyPerHour + this.invoicePositionExtraValue;
this.totalForInvoiceH = Math.round(this.totalhForInvoice * this.invoiceCurrencyPerHour * 100) * 0.01;
this.totalForInvoiceExkl = Math.round(invoiceTotal * 100) * 0.01;
this.totalForInvoiceMwst = Math.round(invoiceTotal * this.invoiceVAT * 100) * 0.01;
this.totalForInvoice = Math.round((this.totalForInvoiceExkl + this.totalForInvoiceMwst)/this.invoiceCurrencyMaxUnit)*this.invoiceCurrencyMaxUnit;
}

Expand Down Expand Up @@ -124,6 +131,11 @@ class invoice extends Base {
svg.instance.viewBox(0,0,740,420)
svg.instance.height("");
svg.instance.width("");
let extra = "";
if(this.invoicePositionExtraValue > 0) {
extra = `<div class="positionDesc">${this.invoicePositionExtraText}</div>
<div class="positionValue">${this.invoiceCurrency} ${this.invoicePositionExtraValue.toFixed(2)}</div>`;
}

this.out +=
`<div class="senderBox">${from}</div>
Expand All @@ -140,7 +152,8 @@ ${opening}

<div class="positionBox">
<div class="positionDesc">${this.invoicePositionText} (${this.totalhForInvoice.toFixed(2)} Stunden zu ${this.invoiceCurrencyPerHour} ${this.invoiceCurrency})</div>
<div class="positionValue">${this.invoiceCurrency} ${this.totalForInvoiceExkl.toFixed(2)}</div>
<div class="positionValue">${this.invoiceCurrency} ${this.totalForInvoiceH.toFixed(2)}</div>
${extra}
<div class="positionDesc">MWST (${this.invoiceVAT*100}%)</div>
<div class="positionValue">${this.invoiceCurrency} ${this.totalForInvoiceMwst.toFixed(2)}</div>
<div class="positionDescTot">Rechnungsbetrag inkl. MWST</div>
Expand Down