ref: 00e5cf965166c614977ac549d9361d63d5edba02
parent: debb5dccc7b87c897de9d6167e8af3e7e4b8fbb8
author: sirjofri <sirjofri@sirjofri.de>
date: Wed Aug 6 15:57:40 EDT 2025
adds sed replacement
--- a/bin/formatdata.awk
+++ b/bin/formatdata.awk
@@ -7,7 +7,7 @@
print "l n n n n"
print "."
print "_"
- printf "Name\tCount\tPrice\tTax\tTotal\n"
+ printf "##ROW_NAME##\t##ROW_COUNT##\t##ROW_PRICE##\t##ROW_TAX##\t##ROW_TOTAL##\n"
print "="
}
@@ -31,20 +31,32 @@
END {print "_"
+ print ".T&"
+ print "l s s s n"
+ print "."
+
# net sum
- printf "Sum\t\t\t\t%.2f EUR\n", final
- print "_"
+ printf "##SUBTOTAL##\t%.2f EUR\n", final
+ hasvat = 0
for (i in vats) {if (i == 0)
continue;
+ hasvat++
+ }
+ if (hasvat)
+ print "_"
+
+ for (i in vats) {+ if (i == 0)
+ continue;
v = vats[i] * i / 100.
- printf "VAT / MwSt. %.2f %%\t\t\t\t%.2f EUR\n", i, v
+ printf "##VAT_TOTAL## %.2f %%\t%.2f EUR\n", i, v
final += v
}
- print "_"
+ print "="
print ".B"
- printf "Total\t\t\t\t%.2f EUR\n", final
+ printf "##TOTAL##\t%.2f EUR\n", final
print "_"
print ".TE"
}
--- a/mkfile
+++ b/mkfile
@@ -10,8 +10,13 @@
rfork en
ramfs
+ # template
+ t=`{cat invoice/$stem1/template}+ cp template/$t /tmp/template.tmp
+ cp template/$t.msg /tmp/msg.tmp
+
# data
- bin/formatdata.awk <invoice/$stem1/data.tsv | tbl >/tmp/positions.tmp
+ bin/formatdata.awk <invoice/$stem1/data.tsv | sed -f template/$t.sed | tbl >/tmp/positions.tmp
cat <<EOF > /tmp/pre.tmp
.ds iv "$stem1
.de IV
@@ -20,11 +25,6 @@
..
EOF
- # template
- t=`{cat invoice/$stem1/template}- cp template/$t /tmp/template.tmp
- cp template/$t.msg /tmp/msg.tmp
-
# date
date -f 'DD.MM.YYYY' `{cat invoice/$stem1/date} >/tmp/date.tmp@@ -45,7 +45,7 @@
bin/genpdfmark $stem1 > /tmp/info.pdfmark
# build
- cat /tmp/pre.tmp /tmp/template.tmp | troff -ms | lp -dstdout > /tmp/invoice.ps
+ cat /tmp/pre.tmp /tmp/template.tmp | sed -f template/$t.sed | troff -ms | lp -dstdout > /tmp/invoice.ps
cat /tmp/invoice.ps /tmp/info.pdfmark | ps2pdf '-sPAPERSIZE=a4' > /tmp/invoice.pdf
bin/pdfid /tmp/invoice.pdf $sum > $target
--- /dev/null
+++ b/template/default.sed
@@ -1,0 +1,8 @@
+s:##ROW_NAME##:Name:g
+s:##ROW_COUNT##:Amount:g
+s:##ROW_PRICE##:Price:g
+s:##ROW_TAX##:VAT:g
+s:##ROW_TOTAL##:Sum:g
+s:##SUBTOTAL##:Subtotal (without VAT):g
+s:##VAT_TOTAL##:Vat:g
+s:##TOTAL##:Total (with VAT):g
--
⑨