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)"
+ |grep -m1 -xEe '-?(\.[0-9]+|[0-9]+\.?[0-9]*)' || printf 0)"
printf '[tr
[td [input type=number name=pieces value="%i" step=1] ]
[td [textarea name=work
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)"
+ |grep -m1 -xEe '-?(\.[0-9]+|[0-9]+\.?[0-9]*)' || printf 0)"
total=$(awk "BEGIN { printf \"%.2f\", ${total} + ${pcs} * ${ppp}; }")
done
case $vat in
"$(POST hourly |grep -m1 -xE '[0-9]+')" \
"$(POST status |grep -m1 -xE 'open|sent|resent|paid|cancelled')"
for n in $(seq 1 $extra); do
- printf 'time=%s work=%s hours=%s pcs=%s ppp=%s\n' \
+ printf 'time=%s work=%s hours=%s pcs=%s ppp=%s\n' \
"$(POST time $n |STRING)" "$(POST work $n |STRING)" \
"$(POST hours $n |STRING)" \
"$(POST pieces $n |STRING)" "$(POST price $n |STRING)" \
- | grep -xvF 'time=\ work=\ hours=0 pcs=1 ppp=0'
+ | grep -xvF 'time=\ work=\ hours=\ pcs=1 ppp=0'
done
} >"invoices/$id"
html_content(){
local id="$1" sender="$2" client="$3" date="$4" number="$5" vat="$6" vatrate="$7" hourly="$8" \
taxtype nett tax gross date_due
+
+ sender="$(HTML "$sender" |sed -E 's/
/ • /g;')"
+ client="$(HTML "$client")"
+
read -r taxtype nett tax gross <<-EOF
$(invoice_total "$id")
EOF
+ [ "$vatrate" ] || vatrate=0
date_due="$((date + 86400 * 28))"
cat <<-EOF
</thead>
<tbody>
$(sed 1d "invoices/$id" |while read -r time work hours pcs ppp; do
- work="$(UNSTRING "${work#work=}" |HTML)"
+ work="$(UNSTRING "${work#work=}" |HTML |sed -E '$!s;$;<br />;;')"
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}; }")
+ |grep -m1 -xEe '-?(\.[0-9]+|[0-9]+\.?[0-9]*)' || printf 0)"
+ ppp="$(printf "%.2f" "$ppp")"
+ total=$(awk "BEGIN { printf \"%.2f\", ${pcs} * ${ppp}; }")
cat <<-ROW
<tr valign="top">
<td width="9%" style="border: none; padding: 0cm"><p align="right">
€</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">${nett}
+ <font face="Cabin"><font size="2" style="font-size: 11pt">${tax}
€</font></font></p>
</td>
</tr>
genhtml(){
local id="$1"
+ mkdir -p "export/"
read -r sender client date number vat vatrate hourly x<<-EOF
$(sed q "invoices/$id")