Skip to content

Commit 7246104

Browse files
author
Andreas Müller
committed
Merge branch 'qrinvoice'
2 parents 8aed0e8 + 85956db commit 7246104

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

documentation.md

Lines changed: 1 addition & 1 deletion
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" --invoicePositionText "Position Text"
285+
gtt report --output=invoice --file=invoice.md --from 2021-02-01 --to 2021-02-28 --closed --invoiceCurrencyMaxUnit 1 --invoiceTitle "Rechnung" --invoiceReference "Reference" --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)

src/gtt-report.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ program
6666
.option('--show_without_times', 'show issues/merge requests without time records')
6767
.option('--from_dump <file>', 'instead of querying gitlab, use data from the given dump file')
6868
.option('--invoiceTitle <title>', 'title on invoice')
69+
.option('--invoiceReference <reference>', 'payment reference on invoice')
6970
.option('--invoiceAddress [address...]', 'address')
7071
.option('--invoiceCurrency <currency>', 'currecnty on invoice')
7172
.option('--invoiceCurrencyPerHour <number>', 'hourly wage rate on invoice')
@@ -133,6 +134,7 @@ config
133134
.set('subgroups', program.opts().subgroups)
134135
.set('_verbose', program.opts().verbose)
135136
.set('invoiceTitle', program.opts().invoiceTitle)
137+
.set('invoiceReference', program.opts().invoiceReference)
136138
.set('invoiceAddress', program.opts().invoiceAddress)
137139
.set('invoiceCurrency', program.opts().invoiceCurrency)
138140
.set('invoiceCurrencyPerHour', program.opts().invoiceCurrencyPerHour)

src/output/invoice.js

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,40 @@ class invoice extends Base {
6464
let endOfZipPos = this.config.get('invoiceSettings').from[3].search("[ _]");
6565
let zip = this.config.get('invoiceSettings').from[3].substring(0, endOfZipPos);
6666
let city = this.config.get('invoiceSettings').from[3].substring(endOfZipPos + 1);
67-
let endOfZipPosDebitor = this.config.get('invoiceAddress')[3].search("[ _]");
68-
let zipDebitor = this.config.get('invoiceAddress')[3].substring(0, endOfZipPosDebitor);
69-
let cityDebitor = this.config.get('invoiceAddress')[3].substring(endOfZipPosDebitor + 1);
67+
68+
// debitor
69+
let nDebitorAddressFields = this.config.get('invoiceAddress').length;
70+
let nameDebitor = "";
71+
let zipDebitor = "";
72+
let cityDebitor = "";
73+
let addressDebitor = "";
74+
75+
76+
if(nDebitorAddressFields > 0) {
77+
nameDebitor = this.config.get('invoiceAddress') [0].replace("_", " ");
78+
}
79+
if(nDebitorAddressFields > 2) {
80+
let endOfZipPosDebitor = this.config.get('invoiceAddress')[nDebitorAddressFields-1].search("[ _]");
81+
zipDebitor = this.config.get('invoiceAddress')[nDebitorAddressFields-1].substring(0, endOfZipPosDebitor).replace("_", " ");
82+
cityDebitor = this.config.get('invoiceAddress')[nDebitorAddressFields-1].substring(endOfZipPosDebitor + 1).replace("_", " ");
83+
addressDebitor = this.config.get('invoiceAddress') [nDebitorAddressFields-2].replace("_", " ");
84+
}
7085

7186
const data = {
7287
currency: "CHF",
7388
amount: this.totalForInvoice,
74-
reference: this.config.get('invoiceTitle'),
89+
reference: this.config.get('invoiceReference'),
7590
creditor: {
76-
name: this.config.get('invoiceSettings').from [0],
91+
name: this.config.get('invoiceSettings').from[0],
7792
address: this.config.get('invoiceSettings').from [2],
7893
zip: zip,
7994
city: city,
8095
account: this.config.get('invoiceSettings').IBAN,
8196
country: this.config.get('invoiceSettings').Country
8297
},
8398
debtor: {
84-
name: this.config.get('invoiceAddress') [0],
85-
address: this.config.get('invoiceAddress') [2],
99+
name: nameDebitor,
100+
address: addressDebitor,
86101
zip: zipDebitor,
87102
city: cityDebitor,
88103
country: "CH"

0 commit comments

Comments
 (0)