From c9ef6f69aaad5632b439a96b895abd466bac09b7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Tue, 21 Jan 2025 03:42:46 +0100 Subject: [PATCH] minor fixes --- import.sh | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/import.sh b/import.sh index da4f78a..0f06b8a 100755 --- 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 -- 2.39.5