]> git.plutz.net Git - confetti/commitdiff
display IBAN and credit account side by side
authorPaul Hänsch <paul@plutz.net>
Tue, 4 Jun 2024 22:47:32 +0000 (00:47 +0200)
committerPaul Hänsch <paul@plutz.net>
Tue, 4 Jun 2024 22:47:32 +0000 (00:47 +0200)
l10n.sh
ledgers/account.sh
style.css

diff --git a/l10n.sh b/l10n.sh
index 039cb6f1f634f18f16f738bd676715ca554c989e..187f151113f5c376f9485aaa73f778464a9e8a35 100755 (executable)
--- a/l10n.sh
+++ b/l10n.sh
@@ -135,7 +135,7 @@ l10n_global() {
     'Balance') printf %s "Kto.Stand";;
     'Manual Record') printf %s "Manueller Eintrag";;
     'Recur Monthly') printf %s "[strike monat&shy;lich wie&shy;der&shy;holen]";;
-    'Credit Account') printf %s "Guthaben&shy;konto";;
+    'Credit Account') printf %s "Sonder&shy;konto";;
     'Submit') printf %s "Eintragen";;
 
     # UI Labels Special
index 9d3329936e08d25ee74c3248b7bff216bd913fb1..6a8fce1ca6f50dda1c502bb81406796fceb6b47f 100755 (executable)
@@ -36,21 +36,30 @@ if tid="$(POST tid)"; then
              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 . $(
@@ -75,50 +84,89 @@ fi
          [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
index 9e6bc02a04d5ef272978024eabb7d858bf97f5ea..9755417a21a086bddc4013b9de58f23c959be112 100644 (file)
--- a/style.css
+++ b/style.css
@@ -509,12 +509,30 @@ body.ledgers .transactions .date {
 body.ledgers .transactions .orig span {
   display: block;
 }
+body.ledgers .transactions .orig,
+body.ledgers .transactions .credit {
+  min-width: 12em;
+}
 body.ledgers .transactions .amount,
 body.ledgers .transactions .balance {
   vertical-align: bottom;
   width: 8em;
   text-align: right;
 }
+body.ledgers .transactions tr.manual .amount {
+  vertical-align: top;
+}
+
+body.ledgers .transactions tr.manual .orig label:first-child {
+  display: block;
+  font-weight: bold;
+}
+body.ledgers .transactions tr.manual .orig label {
+  display: inline-block;
+  width: calc(100% - 2em);
+  line-break: anywhere;
+  vertical-align: middle;
+}
 
 body.ledgers .transactions .reference textarea {
   width: 100%;