From 4ae5f6ef3f868b314be3ad26de333cbb15b0a1c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Tue, 26 Jul 2022 15:46:26 +0200 Subject: [PATCH 1/3] added reference to qr code --- documentation.md | 2 +- src/gtt-report.js | 2 ++ src/output/invoice.js | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/documentation.md b/documentation.md index 0691e0f..32b8a5e 100644 --- a/documentation.md +++ b/documentation.md @@ -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" --invoicePositionText "Position Text" +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" ``` For paper invoice, further process the output with a css, see the folder preview (styles.css, invoice.pdf) diff --git a/src/gtt-report.js b/src/gtt-report.js index 13ea2c5..2a16905 100755 --- a/src/gtt-report.js +++ b/src/gtt-report.js @@ -66,6 +66,7 @@ program .option('--show_without_times', 'show issues/merge requests without time records') .option('--from_dump ', 'instead of querying gitlab, use data from the given dump file') .option('--invoiceTitle ', 'title on invoice') + .option('--invoiceReference <reference>', 'payment reference on invoice') .option('--invoiceAddress [address...]', 'address') .option('--invoiceCurrency <currency>', 'currecnty on invoice') .option('--invoiceCurrencyPerHour <number>', 'hourly wage rate on invoice') @@ -133,6 +134,7 @@ config .set('subgroups', program.opts().subgroups) .set('_verbose', program.opts().verbose) .set('invoiceTitle', program.opts().invoiceTitle) + .set('invoiceReference', program.opts().invoiceReference) .set('invoiceAddress', program.opts().invoiceAddress) .set('invoiceCurrency', program.opts().invoiceCurrency) .set('invoiceCurrencyPerHour', program.opts().invoiceCurrencyPerHour) diff --git a/src/output/invoice.js b/src/output/invoice.js index 6774b18..15bf72c 100644 --- a/src/output/invoice.js +++ b/src/output/invoice.js @@ -71,7 +71,7 @@ class invoice extends Base { const data = { currency: "CHF", amount: this.totalForInvoice, - reference: this.config.get('invoiceTitle'), + reference: this.config.get('invoiceReference'), creditor: { name: this.config.get('invoiceSettings').from [0], address: this.config.get('invoiceSettings').from [2], From 85956db49b81e5fc4f1c2ac126af64181e665adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= <blueapu2@gmail.com> Date: Tue, 26 Jul 2022 15:51:51 +0200 Subject: [PATCH 2/3] cleanup invoice address fields --- src/output/invoice.js | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/output/invoice.js b/src/output/invoice.js index 15bf72c..3b49e07 100644 --- a/src/output/invoice.js +++ b/src/output/invoice.js @@ -64,16 +64,31 @@ class invoice extends Base { let endOfZipPos = this.config.get('invoiceSettings').from[3].search("[ _]"); let zip = this.config.get('invoiceSettings').from[3].substring(0, endOfZipPos); let city = this.config.get('invoiceSettings').from[3].substring(endOfZipPos + 1); - let endOfZipPosDebitor = this.config.get('invoiceAddress')[3].search("[ _]"); - let zipDebitor = this.config.get('invoiceAddress')[3].substring(0, endOfZipPosDebitor); - let cityDebitor = this.config.get('invoiceAddress')[3].substring(endOfZipPosDebitor + 1); + + // debitor + let nDebitorAddressFields = this.config.get('invoiceAddress').length; + let nameDebitor = ""; + let zipDebitor = ""; + let cityDebitor = ""; + let addressDebitor = ""; + + + if(nDebitorAddressFields > 0) { + nameDebitor = this.config.get('invoiceAddress') [0].replace("_", " "); + } + if(nDebitorAddressFields > 2) { + let endOfZipPosDebitor = this.config.get('invoiceAddress')[nDebitorAddressFields-1].search("[ _]"); + zipDebitor = this.config.get('invoiceAddress')[nDebitorAddressFields-1].substring(0, endOfZipPosDebitor).replace("_", " "); + cityDebitor = this.config.get('invoiceAddress')[nDebitorAddressFields-1].substring(endOfZipPosDebitor + 1).replace("_", " "); + addressDebitor = this.config.get('invoiceAddress') [nDebitorAddressFields-2].replace("_", " "); + } const data = { currency: "CHF", amount: this.totalForInvoice, reference: this.config.get('invoiceReference'), creditor: { - name: this.config.get('invoiceSettings').from [0], + name: this.config.get('invoiceSettings').from[0], address: this.config.get('invoiceSettings').from [2], zip: zip, city: city, @@ -81,8 +96,8 @@ class invoice extends Base { country: this.config.get('invoiceSettings').Country }, debtor: { - name: this.config.get('invoiceAddress') [0], - address: this.config.get('invoiceAddress') [2], + name: nameDebitor, + address: addressDebitor, zip: zipDebitor, city: cityDebitor, country: "CH" From dca61aba69ba3f4f8c77f64e1d266f29e2138505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= <blueapu2@gmail.com> Date: Tue, 26 Jul 2022 16:14:18 +0200 Subject: [PATCH 3/3] fixed address fields and reference --- src/output/invoice.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/output/invoice.js b/src/output/invoice.js index 3b49e07..b8c82fe 100644 --- a/src/output/invoice.js +++ b/src/output/invoice.js @@ -71,22 +71,28 @@ class invoice extends Base { let zipDebitor = ""; let cityDebitor = ""; let addressDebitor = ""; - + let countryDebitor = "CH"; if(nDebitorAddressFields > 0) { - nameDebitor = this.config.get('invoiceAddress') [0].replace("_", " "); + nameDebitor = this.config.get('invoiceAddress') [0].replaceAll("_", " "); } if(nDebitorAddressFields > 2) { let endOfZipPosDebitor = this.config.get('invoiceAddress')[nDebitorAddressFields-1].search("[ _]"); - zipDebitor = this.config.get('invoiceAddress')[nDebitorAddressFields-1].substring(0, endOfZipPosDebitor).replace("_", " "); - cityDebitor = this.config.get('invoiceAddress')[nDebitorAddressFields-1].substring(endOfZipPosDebitor + 1).replace("_", " "); - addressDebitor = this.config.get('invoiceAddress') [nDebitorAddressFields-2].replace("_", " "); + zipDebitor = this.config.get('invoiceAddress')[nDebitorAddressFields-1].substring(0, endOfZipPosDebitor).replaceAll("_", " "); + cityDebitor = this.config.get('invoiceAddress')[nDebitorAddressFields-1].substring(endOfZipPosDebitor + 1).replaceAll("_", " "); + addressDebitor = this.config.get('invoiceAddress') [nDebitorAddressFields-2].replaceAll("_", " "); + if(zipDebitor.search("-") > 0) + { + let countryZip = zipDebitor.split("-"); + countryDebitor = countryZip[0]; + zipDebitor = countryZip[1]; + } } const data = { currency: "CHF", amount: this.totalForInvoice, - reference: this.config.get('invoiceReference'), + additionalInformation: this.config.get('invoiceReference'), creditor: { name: this.config.get('invoiceSettings').from[0], address: this.config.get('invoiceSettings').from [2], @@ -100,7 +106,7 @@ class invoice extends Base { address: addressDebitor, zip: zipDebitor, city: cityDebitor, - country: "CH" + country: countryDebitor } }; const options = {