tools: Insert thousands-separators
authorWerner Koch <wk@gnupg.org>
Fri, 12 May 2017 10:34:07 +0000 (12:34 +0200)
committerWerner Koch <wk@gnupg.org>
Fri, 12 May 2017 10:34:07 +0000 (12:34 +0200)
Note that this requires gawk.

tools/append-to-donors.sh
tools/mkkudos.sh

index 1c5667d..0145c5c 100755 (executable)
@@ -143,10 +143,15 @@ send_thanks () {
     else
       xqpmail=$(mu-tool 2047 -c utf-8 "$xmail")
     fi
+    if [ $testmode = yes ]; then
+      xisatest="[TEST DONATION] "
+    else
+      xisatest=""
+    fi
     ( cat <<EOF
 From: donations@gnupg.org
 To: $xqpmail
-Subject: Thank you for supporting GnuPG
+Subject: ${xisatest}Thank you for supporting GnuPG
 Date: $RFCDATE
 Mime-Version: 1.0
 Content-Type: text/plain
@@ -159,7 +164,7 @@ Your donation helps us to develop and maintain GnuPG and related software.
 
 Thank you.
 
-  Werner
+  The GnuPG Team
 
 
 $SIGDELIM
@@ -212,6 +217,7 @@ find $journal_dir/ -type f -name 'journal-????????.log' -print \
     jyear=$(echo $jdate |sed 's/\(....\).*/\1/')
     if [ "$jdate" -ge "$lastdate" ]; then
         [ "$jdate" -gt "$lastdate" ] && lastline=0
+        # First for charge records
         payproc-jrnl -F_lnr -Fdate -F'[name]' -F'[message]' \
                      -Fmail -Famount -Fcurrency -Feuro\
            -S "_lnr > $lastline" -Stype=C -Saccount==1 \
@@ -226,6 +232,21 @@ find $journal_dir/ -type f -name 'journal-????????.log' -print \
             touch "$donors".stamp
             send_thanks
          done
+        # Second for new subscriptions
+        payproc-jrnl -F_lnr -Fdate -F'[name]' -F'[message]' \
+                     -Fmail -Famount -Fcurrency -Feuro -Frecur\
+           -S "_lnr > $lastline" -Stype=S -Saccount==1 \
+           --html --print "$journal_dir/journal-$jdate.log" \
+         | while IFS=: read lnr datestr name message \
+                            xmail amount currency euro recur rest; do
+            name=$(echo "$name" | tr \`\$: ...)
+            message=$(echo "$message" | tr \`\$ ..)
+            xmail=$(echo "$xmail" | tr \`\$ .. | sed 's/\.$//')
+            # Note that we removed colons from $name
+            echo "$jyear:$datestr:$name:S:$lnr:" >> "$donors.tmp"
+            touch "$donors".stamp
+            send_thanks
+         done
     fi
 done
 
index 9858816..613caf3 100755 (executable)
@@ -145,7 +145,7 @@ thisyear=$(echo "$tmp" | awk -F: '{print $1}')
 nyr=$(echo "$tmp" | awk -F: '{printf "%d", $9}')
 euroyr=$(echo "$tmp" | awk -F: '{printf "%d", int($10 + 0.5)}')
 recur_nyr=$(echo "$tmp" | awk -F: '{printf "%d", $13}')
-recur_euroyr=$(echo "$tmp" | awk -F: '{printf "%d", int($14 + 0.5)}')
+recur_euroyr=$(echo "$tmp" | awk -F: '{printf "%d", int($14 + 0.5)/12}')
 
 dontable=$(awk -F: <"$donations" -v thisyear="$thisyear" '
   BEGIN { m[1] = "January";
@@ -215,7 +215,8 @@ for file in "$htdocs/donate/"kudos-????.html "$htdocs/donate/"kudos.html \
    fi
    [ $verbose = yes ] && echo "processing $file" >&2
    [ -f "$file.tmp" ] && rm "$file.tmp"
-   awk -F: -v year=$year -v donors="$donors" -v dontable="$dontable" \
+   # We need gawk to use "%'d" in inprint
+   gawk -F: -v year=$year -v donors="$donors" -v dontable="$dontable" \
            -v monyear="$monyear" -v thisyear="$thisyear" \
            -v euro="$euro" -v euroyr="$euroyr" \
            -v nyr="$nyr" -v goal="$goal" -v percent="$percent" \
@@ -285,20 +286,20 @@ for file in "$htdocs/donate/"kudos-????.html "$htdocs/donate/"kudos.html \
      }
      /<!--CMPGN-RECUR-EURO-->/ {
            n = index($0,"<!--CMPGN");
-           printf "%s!--CMPGN-RECUR-EURO-->%s&thinsp;&euro;\n",
-                  substr($0,1,n), recur_euroyr;
+           printf "%s!--CMPGN-RECUR-EURO-->%'"'"'d&thinsp;&euro;\n",
+                  substr($0,1,n), int(recur_euroyr);
            next
      }
      /<!--CMPGN-RECUR-EURO-GOAL-->/ {
            n = index($0,"<!--CMPGN");
-           printf "%s!--CMPGN-RECUR-EURO-GOAL-->%s&thinsp;&euro;\n",
-                  substr($0,1,n), recur_goal;
+           printf "%s!--CMPGN-RECUR-EURO-GOAL-->%'"'"'d&thinsp;&euro;\n",
+                  substr($0,1,n), int(recur_goal);
            next
      }
      /<!--CMPGN-ONCE-EURO-->/ {
            n = index($0,"<!--CMPGN");
-           printf "%s!--CMPGN-ONCE-EURO-->%s&thinsp;&euro;\n",
-                  substr($0,1,n), euroyr;
+           printf "%s!--CMPGN-ONCE-EURO-->%'"'"'d&thinsp;&euro;\n",
+                  substr($0,1,n), int(euroyr);
            next
      }
      /<!--CMPGN-RECUR-COUNT-->/ {