taxation modes, background stamping
authorPaul Hänsch <paul@plutz.net>
Fri, 10 Nov 2023 00:16:40 +0000 (01:16 +0100)
committerPaul Hänsch <paul@plutz.net>
Fri, 10 Nov 2023 00:16:40 +0000 (01:16 +0100)
odtgen.sh

index d72faa4826cfc66cd1a162441cb67c035430b41d..8a8e7969fa12e4d45e6557e26036ebc720473161 100755 (executable)
--- a/odtgen.sh
+++ b/odtgen.sh
@@ -5,7 +5,7 @@ html_content(){
         taxtype nett tax gross date_due
 
   sender="$(HTML "$sender" |sed -E 's/&#x0D;&#x0A;/ • /g;')"
-  client="$(HTML "$client")"
+  client="$(HTML "$client" |sed -E ':A; /(.*&#x0D;&#x0A;){6}/!{ s/$/\&#x0D;\&#x0A;/; bA; }')"
 
   read -r taxtype nett tax gross <<-EOF
        $(invoice_total "$id")
@@ -32,18 +32,18 @@ html_content(){
                        a:visited { color: #800000; text-decoration: underline }
                </style>
        </head>
-       <body lang="de-DE" link="#000080" vlink="#800000" dir="ltr"><p align="left" style="line-height: 100%; margin-top: 1.5cm; background: transparent">
+       <body lang="de-DE" link="#000080" vlink="#800000" dir="ltr"><p align="left" style="line-height: 100%; margin-top: 2cm; background: transparent">
        <font color="#000000"><font face="Cabin"><font size="1" style="font-size: 8pt"><b>${sender}</b></font></font></font></p>
        <p align="left" style="font-weight: normal; line-height: 100%; margin-top: 0.2cm; background: transparent">
        <font color="#000000"><font face="Cabin"><font size="2" style="font-size: 11pt">${client}</font></font></font></p>
-       <p align="left" style="line-height: 100%; margin-top: 3.3cm; background: transparent; page-break-before: auto; page-break-after: auto">
+       <p align="left" style="line-height: 100%; margin-top: 1.1cm; background: transparent; page-break-before: auto; page-break-after: auto">
        <font color="#000000"><font face="Cabin"><font size="3" style="font-size: 12pt"><b>Rechnung
        SI $(date -d @${date} +%y) ${number}</b></font></font></font></p>
-       <p align="left" style="font-weight: normal; line-height: 100%; margin-top: 0.9cm; background: transparent; page-break-before: auto; page-break-after: auto">
+       <p align="left" style="font-weight: normal; line-height: 100%; margin-left: 12.375cm; background: transparent; page-break-before: auto; page-break-after: auto">
+       <font color="#000000"><font face="Cabin"><font size="2" style="font-size: 10pt">$(date -d @${date} +%d.%m.%Y)</font></font></font></p>
+       <p align="left" style="font-weight: normal; line-height: 100%; margin-top: 2.5cm; background: transparent; page-break-before: auto; page-break-after: auto">
        <font color="#000000"><font face="Cabin"><font size="2" style="font-size: 11pt">Sehr
        geehrte Damen und Herren,</font></font></font></p>
-       <p align="right" style="font-weight: normal; line-height: 100%; margin-right: 2cm; background: transparent; page-break-before: auto; page-break-after: auto">
-       <font color="#000000"><font face="Cabin"><font size="2" style="font-size: 10pt">$(date -d @${date} +%d.%m.%Y)</font></font></font></p>
        <p><br/>
        <br/>
        
@@ -113,6 +113,7 @@ html_content(){
                        </tr>
                        ROW
                done)
+               $([ $taxtype != notax ] && cat <<-ROW
                        <tr valign="top">
                                <td width="9%" style="border: none; padding: 0cm"><p align="right">
                                        <br/>
@@ -124,19 +125,24 @@ html_content(){
        
                                        </p>
                                </td>
-                               <td width="60%" style="border: none; padding: 0cm"><p align="left" style="font-weight: normal">
-                                       <font face="Cabin"><font size="2" style="font-size: 11pt">${vatrate}%
-                                       MwSt.</font></font></p>
+                               <td width="60%" style="border: none; padding: 0cm"><p align="right" style="font-weight: normal">
+                                       <font face="Cabin"><font size="2" style="font-size: 11pt">
+                                       $([ $taxtype = gross ] && printf "incl."; [ $taxtype = nett ] && printf "zzgl."; )
+                                       ${vatrate}% MwSt.:</font></font></p>
                                </td>
                                <td width="15%" style="border: none; padding: 0cm"><p align="right">
-                                       <font face="Cabin"><font size="2" style="font-size: 11pt">${tax}
-                                       €</font></font></p>
+                                       <font face="Cabin"><font size="2" style="font-size: 11pt">
+                                       $([ $taxtype = gross ] && printf "$tax €";)
+                                       </font></font></p>
                                </td>
                                <td width="15%" style="border: none; padding: 0cm"><p align="right">
-                                       <font face="Cabin"><font size="2" style="font-size: 11pt">${tax}
-                                       €</font></font></p>
+                                       <font face="Cabin"><font size="2" style="font-size: 11pt">
+                                       $([ $taxtype = nett ] && printf "$tax €";)
+                                       </font></font></p>
                                </td>
                        </tr>
+                       ROW
+               )
                        <tr valign="top">
                                <td width="9%" style="border: none; padding: 0cm"><p align="right">
                                        <br/>
@@ -148,8 +154,8 @@ html_content(){
        
                                        </p>
                                </td>
-                               <td width="60%" style="border: none; padding: 0cm"><p align="left">
-                                       <font face="Cabin"><font size="2" style="font-size: 11pt"><b>Gesamtsumme</b></font></font></p>
+                               <td width="60%" style="border: none; padding: 0cm"><p align="right">
+                                       <font face="Cabin"><font size="2" style="font-size: 11pt"><b>Gesamtsumme:</b></font></font></p>
                                </td>
                                <td width="15%" style="border: none; padding: 0cm"><p align="right">
                                        <br/>
@@ -191,9 +197,12 @@ html_content(){
        <br/>
        
        </p>
+       $([ $taxtype = notax ] && cat <<-EOF
        <p style="font-weight: normal; line-height: 100%"><a name="__DdeLink__15_3552620450"></a>
        <font face="Cabin"><font size="2" style="font-size: 9pt"><i>Der
        Rechnungsbetrag ist nach § 4 Abs. 25 UStG umsatzsteuerfrei</i></font></font></p>
+       EOF
+       )
        </body>
        </html>
        EOF
@@ -220,9 +229,11 @@ genhtml(){
 }
 
 genpdf(){
-  local id="$1"
+  local id="$1" tmp="tmp$(randomid)"
   genhtml "$id"
   lowriter --convert-to pdf --outdir "export/" "export/${id}.html" >/dev/null
-  rm "export/${id}.html"
+  pdftk "export/${id}.pdf" background $_DATA/Background.pdf output "export/${tmp}.pdf"
+  mv -- "export/${tmp}.pdf" "export/${id}.pdf"
+  rm -- "export/${id}.html"
 }