list_invoices(){
[ -d invoices/ ] && for i in invoices/*; do
- read -r sender client date number vat<<-EOF
+ read -r sender client date number vat vatrate<<-EOF
$(sed q "$i")
EOF
[ -f "senders/${sender#sender=}" ] \
edit_invoice(){
id="$1"
if [ -f "invoices/$id" ]; then
- read -r sender client date number vat<<-EOF
+ read -r sender client date number vat vatrate<<-EOF
$(sed q "invoices/$id")
EOF
fi
&& date="$(date -d "@${date#date=}" +%F)" \
|| date="$(date +%F)"
[ "${number#number=}" ] || number="number=$(date +%s)"
- [ "${vat%=*}" = vat -a "${vat#vat=}" -ge 0 ] 2>&- \
- && vatrate="${vat#vat=}" \
- || vatrate=19
+ [ "${vatrate#vatrate=}" -ge 0 ] 2>&- || vatrate="vatrate=19"
cat <<-EOF
[form method="POST" action="/update_invoice"
[label for=date Date:]
[input #date name=date value="${date}" placeholder="YYYY-MM-TT"]
- [radio "vat" "smallbusiness" #vatsb $([ "$vat" = smallbusiness ] && printf checked) ]
+ [radio "vat" "smallbusiness" #vatsb $([ "${vat#vat=}" = smallbusiness ] && printf checked) ]
[label for=vatsb Small business exemption from VAT]
- [radio "vat" "allgross" #vatgross $([ "$vat" = allgross ] && printf checked)]
- [label for=vatgross All amounts are gross]
- [radio "vat" "rate" #vatrate $([ "${vat%=*}" = vat ] && printf checked) ]
- [label for=vatrate VAT Rate: [input type=number name="vatrate" value="${vatrate}"]% ]
+ [radio "vat" "nett" #vatnett $([ "${vat#vat=}" = nett ] && printf checked)]
+ [label for=vatnett Nett]<!--
+ -->[radio "vat" "gross" #vatgross $([ "${vat#vat=}" = gross ] && printf checked)]<!--
+ -->[label for=vatgross Gross]
+ [label for=vatrate VAT Rate: [input type=number name="vatrate" value="${vatrate#vatrate=}"]% ]
[submit "update" "update" Update]
]
id="$(POST id |checkid)"
if [ "$(POST update)" = update -a "$id" ]; then
mkdir -p invoices
- vat="$(POST vat |grep -m1 -xE 'smallbusiness|allgross|rate' )"
- printf 'sender=%s client=%s date=%s number=%s %s\n' \
+ printf 'sender=%s client=%s date=%s number=%s vat=%s vatrate=%s\n' \
"$(POST sender)" "$(POST client)" \
"$(date -d "$(POST date)" +%s)" \
"$(POST number |STRING)" \
- "$([ "$vat" = rate ] && printf 'vat=%i' "$(POST vatrate)" || printf %s "$vat" )" \
+ "$(POST vat |grep -m1 -xE 'smallbusiness|gross|nett')" \
+ "$(POST vatrate |grep -m1 -xE '[0-9]+')" \
>"invoices/$id"
fi
REDIRECT "/invoice/$id"
content: '';
}
-.invoice form input[type=radio] {display: none;}
-.invoice form label[for^=vat] {
+.invoice form label[for=vatsb],
+.invoice form label[for=vatrate] {
display: block;
text-align: left;
- line-height: 1.5em;
}
-.invoice form label[for^=vat]::before {
- content: '[ ] ';
+.invoice form label[for=vatnett],
+.invoice form label[for=vatgross] {
+ display: inline-block;
+ float: left; margin-right: 1em;
+ line-height: 1em;
}
-.invoice form input:checked + label[for^=vat]::before {
- content: '[x] ';
+.invoice form input[type=radio] { display: none; }
+.invoice form input[type=radio] + label::before {
+ content: '( ) ';
}
-.invoice form label[for=vatrate] {
- float: left;
- display: inline-block;
+.invoice form input:checked + label[for^=vat]::before {
+ content: '(x) ';
}