Skip to content

Commit 8869657

Browse files
authored
Merge pull request #16 from ndu2/qrinvoice
Qrinvoice
2 parents 3241100 + dca61ab commit 8869657

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
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: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,28 +64,49 @@ 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+
let countryDebitor = "CH";
75+
76+
if(nDebitorAddressFields > 0) {
77+
nameDebitor = this.config.get('invoiceAddress') [0].replaceAll("_", " ");
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).replaceAll("_", " ");
82+
cityDebitor = this.config.get('invoiceAddress')[nDebitorAddressFields-1].substring(endOfZipPosDebitor + 1).replaceAll("_", " ");
83+
addressDebitor = this.config.get('invoiceAddress') [nDebitorAddressFields-2].replaceAll("_", " ");
84+
if(zipDebitor.search("-") > 0)
85+
{
86+
let countryZip = zipDebitor.split("-");
87+
countryDebitor = countryZip[0];
88+
zipDebitor = countryZip[1];
89+
}
90+
}
7091

7192
const data = {
7293
currency: "CHF",
7394
amount: this.totalForInvoice,
74-
reference: this.config.get('invoiceTitle'),
95+
additionalInformation: this.config.get('invoiceReference'),
7596
creditor: {
76-
name: this.config.get('invoiceSettings').from [0],
97+
name: this.config.get('invoiceSettings').from[0],
7798
address: this.config.get('invoiceSettings').from [2],
7899
zip: zip,
79100
city: city,
80101
account: this.config.get('invoiceSettings').IBAN,
81102
country: this.config.get('invoiceSettings').Country
82103
},
83104
debtor: {
84-
name: this.config.get('invoiceAddress') [0],
85-
address: this.config.get('invoiceAddress') [2],
105+
name: nameDebitor,
106+
address: addressDebitor,
86107
zip: zipDebitor,
87108
city: cityDebitor,
88-
country: "CH"
109+
country: countryDebitor
89110
}
90111
};
91112
const options = {

0 commit comments

Comments
 (0)