Skip to content
Merged
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
cleanup invoice address fields
  • Loading branch information
Andreas Müller committed Jul 26, 2022
commit 85956db49b81e5fc4f1c2ac126af64181e665adc
27 changes: 21 additions & 6 deletions src/output/invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,40 @@ 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,
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"
Expand Down