From 0843e0e054a1dddcefcf12014bf9dfaaded88d5d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Wed, 8 Nov 2023 15:25:25 +0100 Subject: [PATCH] switch to html template --- odtgen.sh | 464 ++++++++++++++++++++++-------------------------------- 1 file changed, 190 insertions(+), 274 deletions(-) diff --git a/odtgen.sh b/odtgen.sh index abed2db..8dedaef 100755 --- a/odtgen.sh +++ b/odtgen.sh @@ -1,274 +1,200 @@ #!/bin/zsh -odt_manifest(){ - cat <<-EOF - - - - - - - EOF -} - -odt_stylesheet(){ - local iban="$1" bic="$2" - - cat <<-EOF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Bankverbindung - IBAN: - ${iban} - | BIC: - ${bic} - - - - - - EOF -} - -odt_content(){ +html_content(){ local id="$1" sender="$2" client="$3" date="$4" number="$5" vat="$6" vatrate="$7" hourly="$8" \ - taxtype nett tax gross + taxtype nett tax gross date_due read -r taxtype nett tax gross <<-EOF $(invoice_total "$id") EOF + date_due="$((date + 86400 * 28))" + cat <<-EOF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(date -d @${date} +%d.%m.%Y) - - - - $(HTML "$sender" |sed -r 's;( \;)? \;|(�?[Dd]\;)?�?[aA]\;|\r?$;;g') - - - - $(HTML "$client" |sed -r 's;( \;)? \;|(�?[Dd]\;)?�?[aA]\;|\r?$;;g') - - Rechnung ${number} - - - - Vergütung: ${hourly} € / Std.$(case $vat in - (smallbusiness) - printf 'Gemäß Kleinunternehmerregelung (§19 Umsatzsteuergesetz) wird keine Umsatzsteuer berechnet.';; - (nett) printf 'zuzüglich %i%% MwSt.' "$vatrate";; - (gross) printf '(einschließlich %i%% MwSt.)' "$vatrate";; - esac) - - - - - - - - - - Datum - - - Art der Leistung - - - Stundenzahl - - - Betrag - - - - $(sed 1d "invoices/$id" |while read -r time work hours; do - time="$(UNSTRING "${time#time=}" |sed -r 's;( \;)? \;|(�?[Dd]\;)?�?[aA]\;|\r?$;;g')" - work="$(UNSTRING "${work#work=}" |sed -r 's;( \;)? \;|(�?[Dd]\;)?�?[aA]\;|\r?$;;g')" - hours="$(UNSTRING "${hours#hours=}")" - cat <<-TROW - - - ${time} - - - ${work} - - - $( awk "BEGIN { - if ( int(${hours}) == ${hours} ) - printf \"%i\", ${hours}; - else - printf \"%i:%i\", int(${hours}), int((${hours} - int(${hours})) * 60); - }" - ) - - - $(awk "BEGIN { printf \"%.2f\", ${hourly} * ${hours}; }" ) € - - - TROW + + + + + + + + + + +

+ ${sender}

+

+ ${client}

+

+ Rechnung + SI $(date -d @${date} +%y) ${number}

+

+ Sehr + geehrte Damen und Herren,

+

+ $(date -d @${date} +%d.%m.%Y)

+


+
+ +

+ + + + + + + + + + + + + + + + + + + + + + $(sed 1d "invoices/$id" |while read -r time work hours pcs ppp; do + work="$(UNSTRING "${work#work=}" |HTML)" + pcs="$(UNSTRING "${pcs#pcs=}" \ + |grep -m1 -xE '[0-9]+' || printf 1)" + ppp="$(UNSTRING "${ppp#ppp=}" \ + |grep -m1 -xE '-?(\.[0-9]+|[0-9]+\.?[0-9]*)' || printf 0)" + total=$(awk "BEGIN { printf \"%.2f\", ${total} + ${pcs} * ${ppp}; }") + cat <<-ROW + + + + + + + + ROW done) - - - - - $(case $taxtype in - (nett) cat <<-TCELL - - - Zwischensumme: - zzgl. ${vatrate}% MwSt.: - - zu zahlender Betrag: - - - - ${nett} € - ${tax} € - - ${gross} € - - TCELL - ;; - (gross) cat <<-TCELL - - zu zahlender Betrag: - - - enthaltene MwSt (${vatrate}%): - enthaltener Netto-Betrag: - - - ${gross} € - - - ${tax} € - ${nett} € - - TCELL - ;; - (*) cat <<-TCELL - - zu zahlender Betrag: - - - ${gross} € - - TCELL - ;; - esac) - - - - - + + + + + + + + + + + + + + + +

+ Anz.

+

+
+ +

+

+ Leistung

+

+ Einzelpreis

+

+ Summe

+

+ ${pcs}

+

+
+ +

+

+ ${work}

+

+ ${ppp} + €

+

+ ${total} + €

+

+
+ +

+

+
+ +

+

+ ${vatrate}% + MwSt.

+

+ ${tax} + €

+

+ ${nett} + €

+

+
+ +

+

+
+ +

+

+ Gesamtsumme

+

+
+ +

+

+ $gross + €

+
+

+
+
+ +

+

+ Ich + bitte um Überweisung des Rechnungsbetrags bis zum $(date -d @${date_due} +%d.%m.%Y)

+


+
+ +

+

Vielen + Dank für den Auftrag, die gute Zusammenarbeit und freundliche Grüße,

+


+
+ +

+

Olaf + Schenckenberg

+


+
+ +

+


+
+ +

+

+ Der + Rechnungsbetrag ist nach § 4 Abs. 25 UStG umsatzsteuerfrei

+ + EOF } -genodt(){ - local id="$1" exdir="export/$1" - [ -d "$exdir" ] && { - rm "$exdir/content.xml" "$exdir/styles.xml" "$exdir/META-INF/manifest.xml" - rmdir "$exdir/META-INF/" "$exdir/" - } +genhtml(){ + local id="$1" read -r sender client date number vat vatrate hourly x<<-EOF $(sed q "invoices/$id") @@ -276,30 +202,20 @@ genodt(){ 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" - odt_stylesheet "$(UNSTRING "${iban#iban=}")" "$(UNSTRING "${bic#bic=}")" >"$exdir/styles.xml" - odt_content "$id" \ + html_content "$id" \ "$(UNSTRING "${sender#address=}")" \ "$(UNSTRING "${client#address=}")" \ "${date#date=}" \ "$(UNSTRING "${number#number=}")" \ "${vat#vat=}" "${vatrate#vatrate=}" \ "${hourly#hourly=}" \ - >"$exdir/content.xml" - - [ -f "export/${id}.odt" ] && rm "export/${id}.odt" - ( cd "$exdir" - zip -q "../${id}.odt" content.xml styles.xml META-INF/manifest.xml - ) - rm "$exdir/content.xml" "$exdir/styles.xml" "$exdir/META-INF/manifest.xml" - rmdir "$exdir/META-INF/" "$exdir/" + >"export/$id.html" } genpdf(){ local id="$1" - genodt "$id" - lowriter --convert-to pdf --outdir "export/" "export/${id}.odt" >/dev/null - rm "export/${id}.odt" + genhtml "$id" + lowriter --convert-to pdf --outdir "export/" "export/${id}.html" >/dev/null + rm "export/${id}.html" } -- 2.39.5