Skip to content

Commit 307d85b

Browse files
author
Andreas Müller
committed
extra position on invoice
1 parent 715569a commit 307d85b

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/gtt-report.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ program
7474
.option('--invoiceDate <number>', 'date string')
7575
.option('--invoiceCurrencyMaxUnit <number>', 'rouning invoice total, e.g. 0.01, 0.05 or 1')
7676
.option('--invoicePositionText <text>', 'invoice position text')
77+
.option('--invoicePositionExtraText <text>', 'extra invoice position: text')
78+
.option('--invoicePositionExtraValue <number>', 'extra invoice position: value')
7779
.parse(process.argv);
7880

7981
// init helpers
@@ -142,6 +144,8 @@ config
142144
.set('invoiceDate', program.opts().invoiceDate)
143145
.set('invoiceCurrencyMaxUnit', program.opts().invoiceCurrencyMaxUnit)
144146
.set('invoicePositionText', program.opts().invoicePositionText)
147+
.set('invoicePositionExtraText', program.opts().invoicePositionExtraText)
148+
.set('invoicePositionExtraValue', program.opts().invoicePositionExtraValue)
145149
.set('_createDump', program.opts().output === 'dump');
146150

147151
// date shortcuts

src/output/invoice.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,18 @@ class invoice extends Base {
2121
this.invoiceCurrencyPerHour = this.config.get('invoiceCurrencyPerHour');
2222
this.invoiceVAT = this.config.get('invoiceVAT');
2323
this.invoicePositionText = this.config.get('invoicePositionText');
24+
this.invoicePositionExtraText = this.config.get('invoicePositionExtraText');
25+
this.invoicePositionExtraValue = parseFloat(this.config.get('invoicePositionExtraValue'));
26+
if(!this.invoicePositionExtraValue > 0) {
27+
this.invoicePositionExtraValue = 0.0;
28+
}
2429
this.invoiceCurrencyMaxUnit = this.config.get('invoiceCurrencyMaxUnit');
25-
this.totalhForInvoice = (this.spent-this.spentFree) / 3600.0;
30+
this.totalhForInvoice = (this.spent-this.spentFree-(this.spentHalfPrice*0.5)) / 3600.0;
2631
// round subtotals to 0.01 and total to invoiceCurrencyMaxUnit.
27-
this.totalForInvoiceExkl = Math.round(this.totalhForInvoice * this.invoiceCurrencyPerHour * 100) * 0.01;
28-
this.totalForInvoiceMwst = Math.round(this.totalhForInvoice * this.invoiceCurrencyPerHour * this.invoiceVAT * 100) * 0.01;
32+
let invoiceTotal = this.totalhForInvoice * this.invoiceCurrencyPerHour + this.invoicePositionExtraValue;
33+
this.totalForInvoiceH = Math.round(this.totalhForInvoice * this.invoiceCurrencyPerHour * 100) * 0.01;
34+
this.totalForInvoiceExkl = Math.round(invoiceTotal * 100) * 0.01;
35+
this.totalForInvoiceMwst = Math.round(invoiceTotal * this.invoiceVAT * 100) * 0.01;
2936
this.totalForInvoice = Math.round((this.totalForInvoiceExkl + this.totalForInvoiceMwst)/this.invoiceCurrencyMaxUnit)*this.invoiceCurrencyMaxUnit;
3037
}
3138

@@ -124,6 +131,11 @@ class invoice extends Base {
124131
svg.instance.viewBox(0,0,740,420)
125132
svg.instance.height("");
126133
svg.instance.width("");
134+
let extra = "";
135+
if(this.invoicePositionExtraValue > 0) {
136+
extra = `<div class="positionDesc">${this.invoicePositionExtraText}</div>
137+
<div class="positionValue">${this.invoiceCurrency} ${this.invoicePositionExtraValue.toFixed(2)}</div>`;
138+
}
127139

128140
this.out +=
129141
`<div class="senderBox">${from}</div>
@@ -140,7 +152,8 @@ ${opening}
140152
141153
<div class="positionBox">
142154
<div class="positionDesc">${this.invoicePositionText} (${this.totalhForInvoice.toFixed(2)} Stunden zu ${this.invoiceCurrencyPerHour} ${this.invoiceCurrency})</div>
143-
<div class="positionValue">${this.invoiceCurrency} ${this.totalForInvoiceExkl.toFixed(2)}</div>
155+
<div class="positionValue">${this.invoiceCurrency} ${this.totalForInvoiceH.toFixed(2)}</div>
156+
${extra}
144157
<div class="positionDesc">MWST (${this.invoiceVAT*100}%)</div>
145158
<div class="positionValue">${this.invoiceCurrency} ${this.totalForInvoiceMwst.toFixed(2)}</div>
146159
<div class="positionDescTot">Rechnungsbetrag inkl. MWST</div>

0 commit comments

Comments
 (0)