Skip to content

Commit f1b8e85

Browse files
author
Andreas Müller
committed
set position text of invoice using program argument
1 parent 0bf6697 commit f1b8e85

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

documentation.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ Defaults to `table`. `csv` and `markdown` can be printed to stdout, `pdf` and `x
282282
There are additional options for the invoice output as given in the following example:
283283

284284
```shell
285-
gtt report --output=invoice --file=invoice.md --from 2021-02-01 --to 2021-02-28 --closed --invoiceCurrencyMaxUnit 1 --invoiceTitle "Rechnung" --invoiceAddress "Firma" "Mr. X" "Strasse" "10000 Ort" "Land" --invoiceCurrency "EUR" --invoiceCurrencyPerHour "50" --invoiceVAT "0.15" --invoiceDate "1.03.2021"
285+
gtt report --output=invoice --file=invoice.md --from 2021-02-01 --to 2021-02-28 --closed --invoiceCurrencyMaxUnit 1 --invoiceTitle "Rechnung" --invoiceAddress "Firma" "Mr. X" "Strasse" "10000 Ort" "Land" --invoiceCurrency "EUR" --invoiceCurrencyPerHour "50" --invoiceVAT "0.15" --invoiceDate "1.03.2021" --invoicePositionText "Position Text"
286286
```
287287

288288
For paper invoice, further process the output with a css, see the folder preview (styles.css, invoice.pdf)
@@ -658,7 +658,6 @@ invoiceSettings:
658658
opening:
659659
- Satz 1.
660660
- Satz 2.
661-
positionText: Positionstext
662661
closing:
663662
- Grussformel
664663
-

src/gtt-report.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ program
7272
.option('--invoiceVAT <number>', 'vat decimal (20% = 0.2)')
7373
.option('--invoiceDate <number>', 'date string')
7474
.option('--invoiceCurrencyMaxUnit <number>', 'rouning invoice total, e.g. 0.01, 0.05 or 1')
75+
.option('--invoicePositionText <text>', 'invoice position text')
7576
.parse(process.argv);
7677

7778
// init helpers
@@ -138,6 +139,7 @@ config
138139
.set('invoiceVAT', program.opts().invoiceVAT)
139140
.set('invoiceDate', program.opts().invoiceDate)
140141
.set('invoiceCurrencyMaxUnit', program.opts().invoiceCurrencyMaxUnit)
142+
.set('invoicePositionText', program.opts().invoicePositionText)
141143
.set('_createDump', program.opts().output === 'dump');
142144

143145
// date shortcuts

src/output/invoice.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class invoice extends Base {
1818
this.invoiceCurrency = this.config.get('invoiceCurrency');
1919
this.invoiceCurrencyPerHour = this.config.get('invoiceCurrencyPerHour');
2020
this.invoiceVAT = this.config.get('invoiceVAT');
21+
this.invoicePositionText = this.config.get('invoicePositionText');
2122
this.invoiceCurrencyMaxUnit = this.config.get('invoiceCurrencyMaxUnit');
2223
this.totalhForInvoice = (this.spent-this.spentFree) / 3600.0;
2324
// round subtotals to 0.01 and total to invoiceCurrencyMaxUnit.
@@ -56,7 +57,7 @@ class invoice extends Base {
5657
let from = this.concat(this.config.get('invoiceSettings').from, '</br>');
5758
let opening = this.concat(this.config.get('invoiceSettings').opening, '</br>');
5859
let closing = this.concat(this.config.get('invoiceSettings').closing, '</br>');
59-
let positionText = this.concat(this.config.get('invoiceSettings').positionText, '</br>');
60+
6061

6162
this.out +=
6263
`<div class="senderBox">${from}</div>
@@ -72,7 +73,7 @@ class invoice extends Base {
7273
${opening}
7374
7475
<div class="positionBox">
75-
<div class="positionDesc">${positionText} (${this.totalhForInvoice.toFixed(2)} Stunden zu ${this.invoiceCurrencyPerHour} ${this.invoiceCurrency})</div>
76+
<div class="positionDesc">${this.invoicePositionText} (${this.totalhForInvoice.toFixed(2)} Stunden zu ${this.invoiceCurrencyPerHour} ${this.invoiceCurrency})</div>
7677
<div class="positionValue">${this.invoiceCurrency} ${this.totalForInvoiceExkl.toFixed(2)}</div>
7778
<div class="positionDesc">MWST (${this.invoiceVAT*100}%)</div>
7879
<div class="positionValue">${this.invoiceCurrency} ${this.totalForInvoiceMwst.toFixed(2)}</div>

0 commit comments

Comments
 (0)