@@ -66,21 +66,27 @@ class invoice extends Base {
6666 let city = this . config . get ( 'invoiceSettings' ) . from [ 3 ] . substring ( endOfZipPos + 1 ) ;
6767
6868 // debitor
69- let nDebitorAddressFields = this . config . get ( 'invoiceAddress' ) . length ;
69+ let nDebitorAddressFields = Array . isArray ( this . config . get ( 'invoiceAddress' ) ) ? this . config . get ( 'invoiceAddress' ) . length : - 1 ;
7070 let nameDebitor = "" ;
7171 let zipDebitor = "" ;
7272 let cityDebitor = "" ;
7373 let addressDebitor = "" ;
7474 let countryDebitor = "CH" ;
7575
7676 if ( nDebitorAddressFields > 0 ) {
77- nameDebitor = this . config . get ( 'invoiceAddress' ) [ 0 ] . replaceAll ( "_ ", " " ) ;
77+ nameDebitor = this . config . get ( 'invoiceAddress' ) [ 0 ] . replace ( "/_/g ", " " ) ;
7878 }
79+ else {
80+ nameDebitor = this . config . get ( 'invoiceAddress' ) . toString ( ) ;
81+ }
82+
7983 if ( nDebitorAddressFields > 2 ) {
8084 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 ( "_" , " " ) ;
85+ if ( endOfZipPosDebitor > 0 ) {
86+ zipDebitor = this . config . get ( 'invoiceAddress' ) [ nDebitorAddressFields - 1 ] . substring ( 0 , endOfZipPosDebitor ) . replace ( "/_/g" , " " ) ;
87+ cityDebitor = this . config . get ( 'invoiceAddress' ) [ nDebitorAddressFields - 1 ] . substring ( endOfZipPosDebitor + 1 ) . replace ( "/_/g" , " " ) ;
88+ }
89+ addressDebitor = this . config . get ( 'invoiceAddress' ) [ nDebitorAddressFields - 2 ] . replace ( "/_/g" , " " ) ;
8490 if ( zipDebitor . search ( "-" ) > 0 )
8591 {
8692 let countryZip = zipDebitor . split ( "-" ) ;
0 commit comments