@@ -71,22 +71,28 @@ class invoice extends Base {
7171 let zipDebitor = "" ;
7272 let cityDebitor = "" ;
7373 let addressDebitor = "" ;
74-
74+ let countryDebitor = "CH" ;
7575
7676 if ( nDebitorAddressFields > 0 ) {
77- nameDebitor = this . config . get ( 'invoiceAddress' ) [ 0 ] . replace ( "_" , " " ) ;
77+ nameDebitor = this . config . get ( 'invoiceAddress' ) [ 0 ] . replaceAll ( "_" , " " ) ;
7878 }
7979 if ( nDebitorAddressFields > 2 ) {
8080 let endOfZipPosDebitor = this . config . get ( 'invoiceAddress' ) [ nDebitorAddressFields - 1 ] . search ( "[ _]" ) ;
81- zipDebitor = this . config . get ( 'invoiceAddress' ) [ nDebitorAddressFields - 1 ] . substring ( 0 , endOfZipPosDebitor ) . replace ( "_" , " " ) ;
82- cityDebitor = this . config . get ( 'invoiceAddress' ) [ nDebitorAddressFields - 1 ] . substring ( endOfZipPosDebitor + 1 ) . replace ( "_" , " " ) ;
83- addressDebitor = this . config . get ( 'invoiceAddress' ) [ nDebitorAddressFields - 2 ] . replace ( "_" , " " ) ;
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 ( "_" , " " ) ;
84+ if ( zipDebitor . search ( "-" ) > 0 )
85+ {
86+ let countryZip = zipDebitor . split ( "-" ) ;
87+ countryDebitor = countryZip [ 0 ] ;
88+ zipDebitor = countryZip [ 1 ] ;
89+ }
8490 }
8591
8692 const data = {
8793 currency : "CHF" ,
8894 amount : this . totalForInvoice ,
89- reference : this . config . get ( 'invoiceReference' ) ,
95+ additionalInformation : this . config . get ( 'invoiceReference' ) ,
9096 creditor : {
9197 name : this . config . get ( 'invoiceSettings' ) . from [ 0 ] ,
9298 address : this . config . get ( 'invoiceSettings' ) . from [ 2 ] ,
@@ -100,7 +106,7 @@ class invoice extends Base {
100106 address : addressDebitor ,
101107 zip : zipDebitor ,
102108 city : cityDebitor ,
103- country : "CH"
109+ country : countryDebitor
104110 }
105111 } ;
106112 const options = {
0 commit comments