]> git.plutz.net Git - invoices/commitdiff
smaller fixes
authorPaul Hänsch <paul@plutz.net>
Wed, 8 Nov 2023 15:26:57 +0000 (16:26 +0100)
committerPaul Hänsch <paul@plutz.net>
Wed, 8 Nov 2023 15:26:57 +0000 (16:26 +0100)
invoices.sh
odtgen.sh

index 6bbe5b553bc33d77be54957ceafba43ae56079c5..0fc3a7ec8be702d076f863621b602df206b24b23 100755 (executable)
@@ -172,7 +172,7 @@ $({ sed 1d "invoices/$id"; printf 'time= work= hours=\n'; } \
     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
@@ -224,7 +224,7 @@ invoice_total(){
         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
@@ -272,11 +272,11 @@ update_invoice(){
         "$(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"
 
index 8dedaefc3e0ec446a4991c324aa9a514046e8c10..d72faa4826cfc66cd1a162441cb67c035430b41d 100755 (executable)
--- a/odtgen.sh
+++ b/odtgen.sh
@@ -3,10 +3,15 @@
 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/&#x0D;&#x0A;/ • /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
@@ -77,12 +82,13 @@ html_content(){
                </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">
@@ -127,7 +133,7 @@ html_content(){
                                        €</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>
@@ -195,6 +201,7 @@ html_content(){
 
 genhtml(){
   local id="$1"
+  mkdir -p "export/"
 
   read -r sender client date number vat vatrate hourly x<<-EOF
        $(sed q "invoices/$id")