]> git.plutz.net Git - confetti/commitdiff
display transaction amount in ledger
authorPaul Hänsch <paul@plutz.net>
Thu, 18 Apr 2024 13:04:46 +0000 (15:04 +0200)
committerPaul Hänsch <paul@plutz.net>
Thu, 18 Apr 2024 13:04:46 +0000 (15:04 +0200)
ledgers/index.cgi
style.css

index e8852941f20f72615c33e2b4c0f0d4d40878ad24..e9dea1f20d76a2da4c82da357e3c868349b74c99 100755 (executable)
@@ -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:]
       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
index 3da85f104835c32a3b39626d154055e8f43f13e7..b56956f4e2fded145c03e092861770eb56c98777 100644 (file)
--- 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;
+}