From 83129c4d53320ec1ef894b1d1f1cc853e5276def Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Thu, 18 Apr 2024 15:04:46 +0200 Subject: [PATCH] display transaction amount in ledger --- ledgers/index.cgi | 15 +++++++++++---- style.css | 11 +++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ledgers/index.cgi b/ledgers/index.cgi index e885294..e9dea1f 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 diff --git a/style.css b/style.css index 3da85f1..b56956f 100644 --- a/style.css +++ b/style.css @@ -384,7 +384,14 @@ form.ledgers { .ledgers fieldset.iban legend { top: .75em; } -.ledgers fieldset.iban p.principal, -.ledgers fieldset.iban p.amount { +.ledgers fieldset.iban p.principal { font-size: .875em; } +.ledgers fieldset.iban p.amount, +.ledgers fieldset.iban p.subject { + display: inline-block; + vertical-align: top; +} +.ledgers fieldset.iban p.amount { + font-weight: bold; +} -- 2.39.2