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
set position text of invoice using program argument
  • Loading branch information
Andreas Müller committed Dec 28, 2021
commit f1b8e8562d2e5ce86b681305577ca95d7a458685
3 changes: 1 addition & 2 deletions documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ Defaults to `table`. `csv` and `markdown` can be printed to stdout, `pdf` and `x
There are additional options for the invoice output as given in the following example:

```shell
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"
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"
```

For paper invoice, further process the output with a css, see the folder preview (styles.css, invoice.pdf)
Expand Down Expand Up @@ -658,7 +658,6 @@ invoiceSettings:
opening:
- Satz 1.
- Satz 2.
positionText: Positionstext
closing:
- Grussformel
-
Expand Down
2 changes: 2 additions & 0 deletions src/gtt-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ program
.option('--invoiceVAT <number>', 'vat decimal (20% = 0.2)')
.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')
.parse(process.argv);

// init helpers
Expand Down Expand Up @@ -138,6 +139,7 @@ config
.set('invoiceVAT', program.opts().invoiceVAT)
.set('invoiceDate', program.opts().invoiceDate)
.set('invoiceCurrencyMaxUnit', program.opts().invoiceCurrencyMaxUnit)
.set('invoicePositionText', program.opts().invoicePositionText)
.set('_createDump', program.opts().output === 'dump');

// date shortcuts
Expand Down
5 changes: 3 additions & 2 deletions src/output/invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class invoice extends Base {
this.invoiceCurrency = this.config.get('invoiceCurrency');
this.invoiceCurrencyPerHour = this.config.get('invoiceCurrencyPerHour');
this.invoiceVAT = this.config.get('invoiceVAT');
this.invoicePositionText = this.config.get('invoicePositionText');
this.invoiceCurrencyMaxUnit = this.config.get('invoiceCurrencyMaxUnit');
this.totalhForInvoice = (this.spent-this.spentFree) / 3600.0;
// round subtotals to 0.01 and total to invoiceCurrencyMaxUnit.
Expand Down Expand Up @@ -56,7 +57,7 @@ class invoice extends Base {
let from = this.concat(this.config.get('invoiceSettings').from, '</br>');
let opening = this.concat(this.config.get('invoiceSettings').opening, '</br>');
let closing = this.concat(this.config.get('invoiceSettings').closing, '</br>');
let positionText = this.concat(this.config.get('invoiceSettings').positionText, '</br>');


this.out +=
`<div class="senderBox">${from}</div>
Expand All @@ -72,7 +73,7 @@ class invoice extends Base {
${opening}

<div class="positionBox">
<div class="positionDesc">${positionText} (${this.totalhForInvoice.toFixed(2)} Stunden zu ${this.invoiceCurrencyPerHour} ${this.invoiceCurrency})</div>
<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="positionDesc">MWST (${this.invoiceVAT*100}%)</div>
<div class="positionValue">${this.invoiceCurrency} ${this.totalForInvoiceMwst.toFixed(2)}</div>
Expand Down