Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion 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" --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)
Expand Down
2 changes: 2 additions & 0 deletions src/gtt-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ program
.option('--show_without_times', 'show issues/merge requests without time records')
.option('--from_dump <file>', 'instead of querying gitlab, use data from the given dump file')
.option('--invoiceTitle <title>', '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')
Expand Down Expand Up @@ -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)
Expand Down
37 changes: 29 additions & 8 deletions src/output/invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,28 +64,49 @@ 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 = "";
let countryDebitor = "CH";

if(nDebitorAddressFields > 0) {
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).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('invoiceTitle'),
additionalInformation: 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,
account: this.config.get('invoiceSettings').IBAN,
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"
country: countryDebitor
}
};
const options = {
Expand Down