]> git.plutz.net Git - invoices/commitdiff
importer for v1 invoice data
authorPaul Hänsch <paul@plutz.net>
Mon, 20 Jan 2025 11:42:37 +0000 (12:42 +0100)
committerPaul Hänsch <paul@plutz.net>
Mon, 20 Jan 2025 11:42:37 +0000 (12:42 +0100)
import.sh [new file with mode: 0755]

diff --git a/import.sh b/import.sh
new file mode 100755 (executable)
index 0000000..da4f78a
--- /dev/null
+++ b/import.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# import directory
+import="$1"
+
+for invoice in "$import/invoices/"????????????????; do
+  status= date= invnum= rcpt= sender= taxrate= taxtype= tb_desc= tb_pcs= tb_ppp= tb_time=
+  sender= client= date= number= vat= vatrate= hourly= status= time= work= hours=
+
+  { read 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
+      time="${time#*=}" work="${work#*=}" hours="${hours#*=}"
+      tb_time="${tb_time}${tb_time:+   }${time}"
+      tb_desc="${tb_desc}${tb_desc:+   }${work}"
+       tb_pcs="${tb_pcs}${tb_pcs:+     }${hours}"
+       tb_ppp="${tb_ppp}${tb_ppp:+     }${hourly}"
+    done
+  } <"$invoice"
+
+  read sender junk <"$import/senders/${sender}"; sender="${sender#*=}"
+  read client junk <"$import/clients/${client}"; client="${client#*=}"
+
+  cat >"${invoice##*/}.kvd" <<-EOF
+       type    tmpl_paul_byhour
+       status  ${status}
+       date    $(date -d %${date} +%F)
+       invnum  ${number}
+       rcpt    ${client}
+       sender  ${sender}
+       tax     ${vat}
+       taxrate ${vatrate}
+       tb_desc ${tb_desc}
+       tb_pcs  ${tb_pcs}
+       tb_ppp  ${tb_ppp}
+       tb_time ${tb_time}
+       EOF
+done