X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=ledgers%2Findex.cgi;h=621ef827661d4f12c447a8de4720ffd8cb7786a2;hb=598ae8a2f12203b0e7c3aec28eeaabd6e8ae4a23;hp=e8852941f20f72615c33e2b4c0f0d4d40878ad24;hpb=cbfa134047e26cde3814fc0a3036be78dcb5d2c7;p=confetti diff --git a/ledgers/index.cgi b/ledgers/index.cgi index e885294..621ef82 100755 --- a/ledgers/index.cgi +++ b/ledgers/index.cgi @@ -3,6 +3,11 @@ . "$_EXEC/cgilite/storage.sh" . "$_EXEC/pdiread.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;,.;' +} + { printf ' [form .upload action="%s/ledgers/csv_upload.sh" method="POST" enctype="multipart/form-data" [label for=ledger_upload . %s:] @@ -40,13 +45,15 @@ record="$(UNSTRING "${data%% *}")" principal="${record#* * * }" principal="${principal%% *}" subject="${record#* * * * }" subject="${subject%% *}" - printf '[p .principal . %s][p .subject . %s]' \ - "$(UNSTRING "$principal" |HTML)" "$(UNSTRING "$subject" |HTML)" + amount="${record#* * * * * }" amount="${amount%% *}" + printf '[p .principal . %s][p .amount %s][p .subject . %s]' \ + "$(UNSTRING "$principal" |HTML)" "$(credit "$amount")" "$(UNSTRING "$subject" |HTML)" elif [ $state = unknown ]; then principal="${data#* * * }" principal="${principal%% *}" subject="${data#* * * * }" subject="${subject%% *}" - printf '[p .principal . %s][p .subject . %s]' \ - "$(UNSTRING "$principal" |HTML)" "$(UNSTRING "$subject" |HTML)" + amount="${data#* * * * * }" amount="${amount%% *}" + printf '[p .principal . %s][p .amount %s][p .subject . %s]' \ + "$(UNSTRING "$principal" |HTML)" "$(credit "$amount")" "$(UNSTRING "$subject" |HTML)" fi printf ']' done