#!/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
margin: auto;
display: block;
}
+
+body.ledgers .transactions {
+ width: 98%;
+ width: calc(100% - 2em);
+ margin: auto;
+}
+body.ledgers .transactions thead {
+ position: sticky;
+ top: 0;
+ z-index: 1;
+}
+body.ledgers .transactions th {
+ text-align: left;
+ background-color: #FFF;
+}
+body.ledgers .transactions td {
+ vertical-align: top;
+ font-family: monospace;
+ font-size: 12pt;
+}
+
+body.ledgers .transactions td:nth-child(2n) {
+ background-color: #DDD;
+}
+body.ledgers .transactions td:nth-child(2n + 1) {
+ background-color: #EEE;
+}
+
+body.ledgers .transactions .date {
+ min-width: 8em;
+}
+body.ledgers .transactions .orig span {
+ display: block;
+}
+body.ledgers .transactions .amount,
+body.ledgers .transactions .balance {
+ vertical-align: bottom;
+ min-width: 6em;
+ text-align: right;
+}
+
+body.ledgers .transactions .reference textarea {
+ width: 100%;
+}
+body.ledgers .transactions .orig input[type=date],
+body.ledgers .transactions .date input[type=date],
+body.ledgers .transactions .amount input[type=number] {
+ display: block;
+ width: 100%;
+}
+
+body.ledgers .transactions .orig input:not(:checked) + label + input[type=date] {
+ background-color: #DDD;
+ border-color: #888;
+ pointer-events: none;
+}