From: Paul Hänsch Date: Mon, 20 Jan 2025 11:42:37 +0000 (+0100) Subject: importer for v1 invoice data X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=1b0cdb26904ce561acdb6efc21637f4ef4a1bd76;p=invoices importer for v1 invoice data --- diff --git a/import.sh b/import.sh new file mode 100755 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