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