]> git.plutz.net Git - invoices/blobdiff - odtgen.sh
bugfix: include issuance number and work items
[invoices] / odtgen.sh
index f9b7d62cf920e7c0371eea17609203b5f59379dc..9ed1e22bbc7c57e3ecf9f9793da49f9cc88120c9 100755 (executable)
--- a/odtgen.sh
+++ b/odtgen.sh
@@ -12,7 +12,7 @@ odt_manifest(){
 }
 
 odt_stylesheet(){
-  local iban="$2" bic="$3"
+  local iban="$1" bic="$2"
 
   cat <<-EOF
        <?xml version="1.0" encoding="UTF-8"?>
@@ -46,8 +46,8 @@ odt_stylesheet(){
              <style:footer>
                <text:p text:style-name="MP1">
                  <text:span text:style-name="MT1">Bankverbindung - IBAN:</text:span>
-                 <text:span>${iban} |</text:span>
-                 <text:span text:style-name="MT1">BIC:</text:span>
+                 <text:span>${iban}</text:span>
+                 <text:span text:style-name="MT1">BIC:</text:span>
                  <text:span>${bic}</text:span>
                </text:p>
              </style:footer>
@@ -58,7 +58,11 @@ odt_stylesheet(){
 }
 
 odt_content(){
-  local id="$1" sender="$2" client="$3" date="$4" number="$5" vat="$6" vatrate="$7" hourly="$8"
+  local id="$1" sender="$2" client="$3" date="$4" number="$5" vat="$6" vatrate="$7" hourly="$8" \
+        taxtype nett tax gross
+  read -r taxtype nett tax gross <<-EOF
+       $(invoice_total "$id")
+       EOF
 
   cat <<-EOF
        <?xml version="1.0" encoding="UTF-8"?>
@@ -132,7 +136,7 @@ odt_content(){
                    -->$(HTML "$client" |sed -r 's;(&#13\;)?&#10\;;<text:line-break/>;g')<!--
                   --></text:p>
                  </draw:text-box>
-               </draw:frame><text:span text:style-name="T3">Rechnung ${issuance}</text:span>
+               </draw:frame><text:span text:style-name="T3">Rechnung ${number}</text:span>
              </text:p>
              <text:p text:style-name="P3"/>
              <text:p text:style-name="P3"/>
@@ -140,8 +144,8 @@ odt_content(){
              -->$(case $vat in
                   (smallbusiness)
                     printf '<text:line-break/>Gemäß Kleinunternehmerregelung (§19 Umsatzsteuergesetz) wird keine Umsatzsteuer berechnet.';;
-                  (nett)  printf 'zuzüglich %i%% MWSt.' "$vatrate";;
-                  (gross) printf '(einschließlich %i\% MWSt.)' "$vatrate";;
+                  (nett)  printf 'zuzüglich %i%% MwSt.' "$vatrate";;
+                  (gross) printf '(einschließlich %i%% MwSt.)' "$vatrate";;
                  esac)<!--
            --></text:p>
              <text:p text:style-name="P3"/>
@@ -176,7 +180,7 @@ odt_content(){
                            <text:p text:style-name="P3">${time}</text:p>
                          </table:table-cell>
                          <table:table-cell table:style-name="Table1.2" office:value-type="string">
-                           <text:p text:style-name="P3">${item}</text:p>
+                           <text:p text:style-name="P3">${work}</text:p>
                          </table:table-cell>
                          <table:table-cell table:style-name="Table1.2" office:value-type="string">
                            <text:p text:style-name="P5">${hours}</text:p>
@@ -191,15 +195,53 @@ odt_content(){
                  <table:table-cell table:style-name="Table1.6" office:value-type="string">
                    <text:p text:style-name="P6"/>
                  </table:table-cell>
-                 <table:table-cell table:style-name="Table1.6" office:value-type="string">
-                   <text:p text:style-name="P6"/>
-                 </table:table-cell>
-                 <table:table-cell table:style-name="Table1.6" office:value-type="string">
-                   <text:p text:style-name="P7">Summe:</text:p>
-                 </table:table-cell>
-                 <table:table-cell table:style-name="Table1.6" office:value-type="string">
-                   <text:p text:style-name="P7">$(invoice_total "$id") €</text:p>
-                 </table:table-cell>
+                  $(case $taxtype in
+                    (nett) cat <<-TCELL
+                       <table:table-cell table:style-name="Table1.6" table:number-columns-spanned="2" office:value-type="string">
+                         <text:p text:style-name="P5">
+                         Zwischensumme:<text:line-break/>
+                         zzgl. ${vatrate}% MwSt.:<text:line-break/>
+                         </text:p>
+                         <text:p text:style-name="P7">zu zahlender Betrag:</text:p>
+                       </table:table-cell>
+                       <table:table-cell table:style-name="Table1.6" office:value-type="string">
+                         <text:p text:style-name="P5">
+                         ${nett} €<text:line-break/>
+                         ${tax} €<text:line-break/>
+                         </text:p>
+                         <text:p text:style-name="P7">${gross} €</text:p>
+                       </table:table-cell>
+                       TCELL
+                        ;;
+                    (gross) cat <<-TCELL
+                       <table:table-cell table:style-name="Table1.6" table:number-columns-spanned="2" office:value-type="string">
+                         <text:p text:style-name="P7">zu zahlender Betrag:</text:p>
+                         <text:p text:style-name="P5">
+                         <text:line-break/>
+                         enthaltene MwSt (${vatrate}%):<text:line-break/>
+                         enthaltener Netto-Betrag:<!--
+                       --></text:p>
+                       </table:table-cell>
+                       <table:table-cell table:style-name="Table1.6" office:value-type="string">
+                         <text:p text:style-name="P7">${gross} €</text:p>
+                         <text:p text:style-name="P5">
+                         <text:line-break/>
+                         ${tax} €<text:line-break/>
+                         ${nett} €<!--
+                       --></text:p>
+                       </table:table-cell>
+                       TCELL
+                        ;;
+                    (*) cat <<-TCELL
+                       <table:table-cell table:style-name="Table1.6" table:number-columns-spanned="2" office:value-type="string">
+                         <text:p text:style-name="P7">zu zahlender Betrag:</text:p>
+                       </table:table-cell>
+                       <table:table-cell table:style-name="Table1.6" office:value-type="string">
+                         <text:p text:style-name="P7">${gross} €</text:p>
+                       </table:table-cell>
+                       TCELL
+                        ;;
+                  esac)
                </table:table-row>
              </table:table>
            </office:text>
@@ -215,11 +257,11 @@ genodt(){
     rmdir "$exdir/META-INF/" "$exdir/"
   }
 
-  read -r sender client date number vat vatrate <<-EOF
+  read -r sender client date number vat vatrate hourly x<<-EOF
        $(sed q "invoices/$id")
        EOF
-  read -r sender iban bic <"senders/${sender#sender=}"
-  read -r client hourly <"clients/${client#client=}"
+  read -r sender iban bic x<"senders/${sender#sender=}"
+  read -r client chourly x<"clients/${client#client=}"
 
   mkdir -p "$exdir/META-INF"
   odt_manifest >"$exdir/META-INF/manifest.xml"
@@ -240,3 +282,11 @@ genodt(){
   rm "$exdir/content.xml" "$exdir/styles.xml" "$exdir/META-INF/manifest.xml"
   rmdir "$exdir/META-INF/" "$exdir/"
 }
+
+genpdf(){
+  local id="$1"
+  genodt "$id"
+  lowriter --convert-to pdf --outdir "export/" "export/${id}.odt" >/dev/null
+  rm "export/${id}.odt"
+}
+