#!/bin/sh
+credit() {
+ printf '%+03i\n' "$1" \
+ | sed -E 's;[0-9]{2}$;d&;; :0 s;([0-9])([0-9]{3}[dm]);\1m\2;; t0; y;dm;,.;'
+}
+
if [ "$REQUEST_METHOD" = POST ]; then
uid="$(POST uid)"
cfile="$(grep -lxF "UID;:${uid}" "${_DATA}/vcard/"*.vcf || grep -lxF "UID:${uid}" "${_DATA}/vcard/"*.vcf)"
REDIRECT "${_BASE}/ledgers/account.sh?card=${cfile##*/}"
fi
+. "${_EXEC}/cgilite/storage.sh"
. "${_EXEC}/pdiread.sh"
. "${_EXEC}/cards/l10n.sh"
. "${_EXEC}/cards/widgets.sh"
REDIRECT "${_BASE}/ledgers/"
fi
+cledger="${cardfile##*/}"
+cledger="${_DATA}/ledgers/vcf.${cledger%.vcf}.account"
+
{ card="$(pdi_load "$cardfile")"
cat <<-EOF
[h1 $(l10n Payments)]
$(card_item "$card" CATEGORIES)
]
]
- [ul .transactions
- $(cnt="$(pdi_count "$card" X-IBAN)"
- while [ "$cnt" -gt 0 ]; do
- pdi_value X-IBAN "$cnt" |RXLITERAL
- cnt=$((cnt - 1))
- done \
- | while read -r iban; do
- printf '[li . '
- grep -E "^[^\t]+ [^\t]+ ${iban} " |HTML
- printf ']'
- done
- )]
EOF
-
+ printf '[table .transactions [thead
+ [tr [th .date . %s][th .orig . %s][th .reference . %s][th .amount . %s][th .balance . %s]]' \
+ "$(l10n Date)" "$(l10n Originator)" "$(l10n "Reference Text")" "$(l10n Amount)" "$(l10n Balance)"
+ printf '][tbody'
+ cnt="$(pdi_count "$card" X-IBAN)"
+ while [ "$cnt" -gt 0 ]; do
+ pdi_value "$card" X-IBAN "$cnt" |RXLITERAL
+ cnt=$((cnt - 1))
+ done \
+ | {
+ while read -r iban; do
+ grep -hE "^[^\t]+ [^\t]+ ${iban} " "${_DATA}/ledgers/"*.tbl
+ done
+ if [ -f "$cledger" ]; then
+ :
+ fi
+ } \
+ | sort -n -k2 \
+ | { total=0
+ while read -r date dtstamp iban accname subject amount; do
+ total=$((total + amount))
+ printf '[tr [td .date . %s][td .orig [span . %s][span . %s]][td .reference . %s][td .amount . %s][td .balance . %s]]' \
+ "$date" "$(HTML "$iban")" \
+ "$(UNSTRING "$accname" |HTML)" "$(UNSTRING "$subject" |HTML)" \
+ "$(credit "$amount")" "$(credit "$total")"
+ done
+ }
+ printf '[tr [th colspan=5 . %s]]' "$(l10n 'Manual Record')"
+ printf '[tr [td .date [input type=date placeholder="%s" name=tdate]]
+ [td .orig [input id=trec_once type=radio name="trec" value="once" selected]
+ [label for=trec_once . %s]<br/>
+ [input id=trec_month type=radio name="trec" value="month"]
+ [label for=trec_month . %s]
+ [input type=date name="trec_until" placeholder="%s"]]
+ [td .reference . [textarea placeholder="%s" name=treference]]
+ [td .amount colspan=2 [input type=number placeholder="%s" name=tamount value=0.00 step=.01]]' \
+ "$(l10n Date)" "$(l10n once)" "$(l10n "monthly until")" "$(l10n until)" "$(l10n "Reference Text")" "$(l10n Amount)"
+ printf ']]]'
} \
| yield_page ledgers