s;^([\+-]?[0-9]+)[\.,]([0-9][0-9])$;\1\2;;
s;^([\+-]?[0-9]+)$;&00;;
' | grep -m1 -xE '[\+-]?[0-9]+')"
+ torig="$(POST torig |grep -m1 -xE '\\|[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}')"
# debug "TDATE: $tdate TREF: $tref AMOUNT: $tamount"
if ! [ "$tdate" -a "$tref" -a "$tamount" ]; then
SET_COOKIE 0 message="Transaction info invalid"
REDIRECT "$REQUEST_URI"
fi
tdtstamp="$(date -ud "$tdate" +%s)"
- printf '%s %i %s \ %s %i\n' \
- "${tdate}" "${tdtstamp}" "$(STRING "${cardfile%.vcf}")" \
+ printf '%s %i %s \ %s \ %s %i\n' \
+ "${tdate}" "${tdtstamp}" "${torig}" "$(STRING "${cardfile%.vcf}")" \
"$(STRING "$tref")" "${tamount}" \
>>"${cledger}"
REDIRECT "$REQUEST_URI"
fi
-{ card="$(pdi_load "${_DATA}/vcard/$cardfile")"
- cat <<-EOF
+card="$(pdi_load "${_DATA}/vcard/$cardfile")"
+X_IBAN="$(
+ cnt="$(pdi_count "$card" X-IBAN)"
+ while [ "$cnt" -gt 0 ]; do
+ pdi_value "$card" X-IBAN "$cnt"
+ cnt=$((cnt - 1))
+ done
+)"
+
+{ cat <<-EOF
[h1 $(l10n Payments)]
[div .card #${cardfile}
[div .section .basic . $(
[hidden "tid" "$(transid "${cledger}")"]
[table .transactions
[thead [tr
- [th .date . $(l10n Date)][th .orig . $(l10n Originator)]
+ [th .date . $(l10n Date)][th .amount . $(l10n Amount)]
[th .reference . $(l10n "Reference Text")]
- [th .amount . $(l10n Amount)][th .balance . $(l10n Balance)]
+ [th .orig . $(l10n IBAN)][th .balance . $(l10n Balance)]
+ [th .credit . $(l10n "Credit Account")][th .balance . $(l10n Balance)]
]]
[tbody
EOF
- cnt="$(pdi_count "$card" X-IBAN)"
- { while [ "$cnt" -gt 0 ]; do
- pdi_value "$card" X-IBAN "$cnt" |RXLITERAL
- cnt=$((cnt - 1))
+ { for iban in $X_IBAN; do
+ iban="$(RXLITERAL "$iban")"
+ sed -nE '
+ /^[^\t]+ [^\t]+ '"${iban}"' /{
+ s;^([^\t]+ ){2};&\\ \\ ;;
+ p;
+ }
+ ' "${_DATA}/ledgers/"*.tbl
+ grep -hE "^[^\t]+ [^\t]+ ${iban} " "${_DATA}/ledgers/"vcf.*.account
done
- RXLITERAL "${cardfile%.vcf}"; echo
- } |debug \
- | while read -r iban; do
- grep -hE "^[^\t]+ [^\t]+ ${iban} " "${_DATA}/ledgers/"*
- done \
+ grep -hvE "^[^\t]+ [^\t]+ ${iban} " "${_DATA}/ledgers/vcf.${cardfile%.vcf}.account"
+ } \
| sort -n -k2 \
+ | awk 'BEGIN { FS="\t"; OFS="\t"; }
+ { print $1, $2, $3, $4, $5, $6, $7, $8, acc[$3] -= $8, acc[$5] += $8; }
+ ' \
| { total=0
- while read -r date dtstamp iban accname reftext amount; do
+ while read -r date dtstamp siban saccname tiban taccname reftext amount stotal ttotal; do
total=$((total + amount))
- if [ "$iban" = "${cardfile%.vcf}" ]; then
- printf '[tr [td .date . %s][td .orig [span . %s][span . %s]][td .reference . %s]
- [td .amount . %s][td .balance . %s]]' \
- "$date" "$(l10n "Credit Account")" \
- "$(UNSTRING "$accname" |HTML)" "$(UNSTRING "$reftext" |HTML)" \
- "$(credit "$amount")" "$(credit "$total")"
+ if [ "$siban" = \\ -a "$tiban" = "${cardfile%.vcf}" ]; then
+ printf '[tr
+ [td .date . %s][td .amount . %s][td .reference . %s]
+ [td .orig [span . %s][span . %s]][td .balance . %s]
+ [td .credit [span . %s][span . %s]][td .balance . %s]
+ ]' \
+ "$date" "$(credit "$amount")" "$(UNSTRING "$reftext" |HTML)" \
+ "" "" "" \
+ "$(l10n "Credit Account")" "" "$(credit "$ttotal")"
+ elif [ "$siban" = \\ ]; then
+ printf '[tr
+ [td .date . %s][td .amount . %s][td .reference . %s]
+ [td .orig [span . %s][span . %s]][td .balance . %s]
+ [td .credit [span . %s][span . %s]][td .balance . %s]
+ ]' \
+ "$date" "$(credit "$amount")" "$(UNSTRING "$reftext" |HTML)" \
+ "$(UNSTRING "$tiban" |HTML)" "$(UNSTRING "$taccname" |HTML)" "$(credit "$ttotal")" \
+ "" "" ""
+ elif [ "$tiban" = "${cardfile%.vcf}" ]; then
+ printf '[tr
+ [td .date . %s][td .amount . %s][td .reference . %s]
+ [td .orig [span . %s][span . %s]][td .balance . %s]
+ [td .credit [span . %s][span . %s]][td .balance . %s]
+ ]' \
+ "$date" "$(credit "$amount")" "$(UNSTRING "$reftext" |HTML)" \
+ "$(UNSTRING "$siban" |HTML)" "$(UNSTRING "$saccname" |HTML)" "$(credit "$stotal")" \
+ "$(l10n "Credit Account")" "" "$(credit "$ttotal")"
else
- 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 "$reftext" |HTML)" \
- "$(credit "$amount")" "$(credit "$total")"
+ printf '[tr
+ [td .date . %s][td .amount . %s][td .reference . %s]
+ [td .orig [span . %s][span . %s]][td .balance . %s]
+ [td .credit [span . %s][span . %s]][td .balance . %s]
+ ]' \
+ "$date" "$(credit "$amount")" "$(UNSTRING "$reftext" |HTML)" \
+ "$(UNSTRING "$siban" |HTML)" "$(UNSTRING "$saccname" |HTML)" "$(credit "$stotal")" \
+ "$(UNSTRING "$tiban" |HTML)" "$(UNSTRING "$taccname" |HTML)" ""
fi
done
}
cat <<-EOF
[tr [th colspan=5 . $(l10n 'Manual Record')]]
- [tr [td .date
+ [tr .manual [td .date
[input type=date placeholder="$(l10n Date)" name=tdate value="$(date +%F)"]
[input type=checkbox id=rr_month name=recur value=monthly]
[label for=rr_month $(l10n Recur Monthly)]
- ][td .orig ]
- [td .reference . [textarea placeholder="$(l10n "Reference Text")" name=tref]]
+ ]
[td .amount [input type=number placeholder="$(l10n Amount)" name=tamount value=0.00 step=.01]]
+ [td .reference . [textarea placeholder="$(l10n "Reference Text")" name=tref]]
+ [td .orig [label $(l10n Transfer from)]
+ [input type=radio id=to_cred name=torig value="\\\\" selected][label for=to_cred . $(l10n "Credit Account")]
+ $(for iban in $X_IBAN; do
+ iban="$(HTML "$iban")"
+ printf '[input type=radio id="to_%s" name=torig value="%s"][label for="to_%s" . %s]' \
+ "$iban" "$iban" "$iban" "$iban"
+ done)
+ ]
+ [td .balance ][td .credit ]
[td .balance [button type=submit . $(l10n Submit)]]
]]]]
EOF