]> git.plutz.net Git - invoices/commitdiff
minor fixes
authorPaul Hänsch <paul@plutz.net>
Tue, 21 Jan 2025 02:42:46 +0000 (03:42 +0100)
committerPaul Hänsch <paul@plutz.net>
Tue, 21 Jan 2025 02:42:46 +0000 (03:42 +0100)
import.sh

index da4f78adf1f5cedb6493805275461e444abaab02..0f06b8a0e306d8385919414c9820a28a4f7e7a15 100755 (executable)
--- a/import.sh
+++ b/import.sh
@@ -4,36 +4,43 @@
 import="$1"
 
 for invoice in "$import/invoices/"????????????????; do
-  status= date= invnum= rcpt= sender= taxrate= taxtype= tb_desc= tb_pcs= tb_ppp= tb_time=
+  status= date= invnum= rcpt= sender= taxrate= taxtype= tb_date= tb_desc= tb_time=
   sender= client= date= number= vat= vatrate= hourly= status= time= work= hours=
 
-  { read sender client date number vat vatrate hourly status junk
+  { read -r sender client date number vat vatrate hourly status junk
     sender="${sender#*=}" client="${client#*=}" date="${date#*=}" number="${number#*=}"
     vat="${vat#*=}" vatrate="${vatrate#*=}" hourly="${hourly#*=}" status="${status#*=}"
-    while read time work hours junk; do
+    while read -r time work hours junk; do
       time="${time#*=}" work="${work#*=}" hours="${hours#*=}"
-      tb_time="${tb_time}${tb_time:+   }${time}"
+      tb_date="${tb_date}${tb_date:+   }${time}"
       tb_desc="${tb_desc}${tb_desc:+   }${work}"
-       tb_pcs="${tb_pcs}${tb_pcs:+     }${hours}"
-       tb_ppp="${tb_ppp}${tb_ppp:+     }${hourly}"
+      tb_time="${tb_time}${tb_time:+   }${hours}"
     done
   } <"$invoice"
 
-  read sender junk <"$import/senders/${sender}"; sender="${sender#*=}"
-  read client junk <"$import/clients/${client}"; client="${client#*=}"
+  read -r sender junk <"$import/senders/${sender}"
+  sender="$(printf %s "${sender#*=}" |sed -E 's/\\r?\\n/;+/g')"
+  read -r client junk <"$import/clients/${client}"
+  client="$(printf %s "${client#*=}" |sed -E 's/\\r?\\n/;+/g')"
+
+  if [ "$vat" = smallbusiness ]; then
+    vat=free
+    taxfreetext="Gemäß+Kleinunternehmerregelung+(§19+UStG.)+wird+keine+Umsatzsteuer+berechnet."
+  fi
 
   cat >"${invoice##*/}.kvd" <<-EOF
-       type    tmpl_paul_byhour
+       type    tmpl_byhour
        status  ${status}
-       date    $(date -d %${date} +%F)
+       date    $(date -d @${date} +%F)
        invnum  ${number}
        rcpt    ${client}
        sender  ${sender}
-       tax     ${vat}
+       rate    ${hourly}
+       taxtype ${vat}
        taxrate ${vatrate}
+       taxfreetext     $taxfreetext
+       tb_date ${tb_date}
        tb_desc ${tb_desc}
-       tb_pcs  ${tb_pcs}
-       tb_ppp  ${tb_ppp}
        tb_time ${tb_time}
        EOF
 done