@@ -88,14 +88,14 @@ class invoice extends Base {
8888 // REMOVE
8989 // _.each(this.users, (time, name) => stats += `\n* **${name}**: ${time}`);
9090 let to = this . concat ( this . config . get ( 'invoiceAddress' ) , '<br />' ) ;
91- let from = this . concat ( this . config . get ( 'invoiceSettings' ) . from , '<br />' ) ;
92- let opening = this . concat ( this . config . get ( 'invoiceSettings' ) . opening , '<br />' ) ;
93- let closing = this . concat ( this . config . get ( 'invoiceSettings' ) . closing , '<br />' ) ;
91+ let from = this . concat ( this . config . get ( 'invoiceSettings' ) ? .from , '<br />' ) ;
92+ let opening = this . concat ( this . config . get ( 'invoiceSettings' ) ? .opening , '<br />' ) ;
93+ let closing = this . concat ( this . config . get ( 'invoiceSettings' ) ? .closing , '<br />' ) ;
9494
9595 // QR bill
96- let endOfZipPos = this . config . get ( 'invoiceSettings' ) . from [ 3 ] . search ( "[ _]" ) ;
97- let zip = this . config . get ( 'invoiceSettings' ) . from [ 3 ] . substring ( 0 , endOfZipPos ) ;
98- let city = this . config . get ( 'invoiceSettings' ) . from [ 3 ] . substring ( endOfZipPos + 1 ) ;
96+ let endOfZipPos = this . config . get ( 'invoiceSettings' ) ? .from [ 3 ] ? .search ( "[ _]" ) ;
97+ let zip = this . config . get ( 'invoiceSettings' ) ? .from [ 3 ] ? .substring ( 0 , endOfZipPos ) ;
98+ let city = this . config . get ( 'invoiceSettings' ) ? .from [ 3 ] ? .substring ( endOfZipPos + 1 ) ;
9999
100100 // debitor
101101 let nDebitorAddressFields = Array . isArray ( this . config . get ( 'invoiceAddress' ) ) ? this . config . get ( 'invoiceAddress' ) . length : - 1 ;
@@ -109,7 +109,7 @@ class invoice extends Base {
109109 if ( nDebitorAddressFields > 0 ) {
110110 nameDebitor = this . config . get ( 'invoiceAddress' ) [ 0 ] . replace ( regexAllUnderscores , " " ) ;
111111 }
112- else {
112+ else if ( this . config . get ( 'invoiceAddress' ) ) {
113113 nameDebitor = this . config . get ( 'invoiceAddress' ) . toString ( ) ;
114114 }
115115
@@ -131,16 +131,16 @@ class invoice extends Base {
131131 let qrDivContent = "" ;
132132
133133 const data = {
134- currency : "CHF" ,
134+ currency : this . invoiceCurrency ,
135135 amount : this . totalForInvoice ,
136136 additionalInformation : this . config . get ( 'invoiceReference' ) ,
137137 creditor : {
138- name : this . config . get ( 'invoiceSettings' ) . from [ 0 ] ,
139- address : this . config . get ( 'invoiceSettings' ) . from [ 2 ] ,
138+ name : this . config . get ( 'invoiceSettings' ) ? .from [ 0 ] ,
139+ address : this . config . get ( 'invoiceSettings' ) ? .from [ 2 ] ,
140140 zip : zip ,
141141 city : city ,
142- account : this . config . get ( 'invoiceSettings' ) . IBAN ,
143- country : this . config . get ( 'invoiceSettings' ) . Country
142+ account : this . config . get ( 'invoiceSettings' ) ? .IBAN ,
143+ country : this . config . get ( 'invoiceSettings' ) ? .Country
144144 } ,
145145 debtor : {
146146 name : nameDebitor ,
@@ -151,10 +151,10 @@ class invoice extends Base {
151151 }
152152 } ;
153153 const options = {
154- language : "DE"
154+ language : this . config . get ( 'invoiceSettings' ) ?. Language ?? "DE"
155155 } ;
156156
157- if ( this . config . get ( 'invoiceSettings' ) . SwissQRBill ) {
157+ if ( this . config . get ( 'invoiceSettings' ) ? .SwissQRBill ) {
158158 const svg = new SwissQRBill ( data , options ) ;
159159 // make svg scalable, by adding viewBox and removing height/width attributes
160160 svg . instance . viewBox ( 0 , 0 , 740 , 420 )
@@ -195,7 +195,7 @@ class invoice extends Base {
195195`<div class="senderBox">${ from } </div>
196196
197197<div class="addressBox">
198- <div class="addressFrom">${ this . config . get ( 'invoiceSettings' ) . fromShort } </div>
198+ <div class="addressFrom">${ this . config . get ( 'invoiceSettings' ) ? .fromShort } </div>
199199<div class="addressTo">${ to } </div>
200200</div>
201201<div class="dateBox">${ this . config . get ( 'invoiceDate' ) } </div>
@@ -216,7 +216,7 @@ ${extra}
216216<div class="positionValueTot">${ this . invoiceCurrency } ${ this . totalForInvoice . toFixed ( 2 ) } </div>
217217</div>
218218
219- ${ this . config . get ( 'invoiceSettings' ) . bankAccount }
219+ ${ this . config . get ( 'invoiceSettings' ) ? .bankAccount }
220220
221221${ closing }
222222
0 commit comments