commit dac7ee3a6880afa4b04ad941c189124ad57686d5
parent 3e70fdc9d79748551efe3624cd807f5a906996cb
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 24 Nov 2024 08:23:46 +0100
more work on AML programs
Diffstat:
4 files changed, 153 insertions(+), 8 deletions(-)
diff --git a/src/kyclogic/Makefile.am b/src/kyclogic/Makefile.am
@@ -22,6 +22,7 @@ bin_SCRIPTS = \
taler-exchange-helper-measure-none \
taler-exchange-helper-measure-preserve-but-investigate \
taler-exchange-helper-measure-preserve-set-expiration \
+ taler-exchange-helper-measure-tops-kyx-check \
taler-exchange-helper-measure-tops-postal-check \
taler-exchange-helper-measure-tops-sms-check \
taler-exchange-helper-measure-test-form \
diff --git a/src/kyclogic/taler-exchange-helper-measure-tops-kyx-check b/src/kyclogic/taler-exchange-helper-measure-tops-kyx-check
@@ -0,0 +1,146 @@
+#!/bin/bash
+#
+# This file is part of TALER
+# Copyright (C) 2024 Taler Systems SA
+#
+# TALER is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 3, or (at your option) any later version.
+#
+# TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/license>
+#
+
+# Hard error reporting on.
+set -eu
+
+
+# Exit, with error message (hard failure)
+function exit_fail() {
+ echo " FAIL: " "$@" >&2
+ EXIT_STATUS=1
+ exit "$EXIT_STATUS"
+}
+
+CONF="$HOME/.config/taler-exchange.conf"
+VERBOSE=0
+
+while getopts 'ac:hirvV' OPTION;
+do
+ case "$OPTION" in
+ a)
+ # Legal entity type is required.
+ echo "SWISS_VQF_LEGAL_ENTITY_TYPE"
+ exit 0
+ ;;
+ c)
+ # shellcheck disable=SC2034
+ CONF="$OPTARG"
+ ;;
+ h)
+ echo "This is a KYC measure program that determines the next VQF form to ask for (if any) based on the type of legal entity the customer claimed to be on the primary form."
+ echo 'Supported options:'
+ echo ' -a -- show required attributes'
+ # shellcheck disable=SC2016
+ echo ' -c $CONF -- set configuration'
+ echo ' -h -- print this help'
+ echo ' -i -- show required inputs'
+ echo ' -r -- show required context'
+ echo ' -v -- show version'
+ echo ' -V -- be verbose'
+ ;;
+ i)
+ # Need context and current_rules.
+ echo "attributes"
+ echo "current_rules"
+ exit 0
+ ;;
+ r)
+ # Nothing needed from context
+ exit 0
+ ;;
+ v)
+ echo "$0 v0.0.0"
+ exit 0
+ ;;
+ V)
+ VERBOSE=1
+ ;;
+ ?)
+ exit_fail "Unrecognized command line option"
+ ;;
+ esac
+done
+
+if [ 1 = "$VERBOSE" ]
+then
+ echo "Running $0" 1>&2
+fi
+
+# See https://docs.taler.net/taler-kyc-manual.html#tsref-type-AmlProgramInput
+# for the full JSON with possible inputs.
+
+# First, extract inputs we need
+INPUTS=$(jq '{"current_rules":.current_rules,"attributes":.attributes}')
+
+# Get entity type
+LEGAL_ENTITY=$(echo "$INPUTS" | jq '.attributes.SWISS_VQF_LEGAL_ENTITY_TYPE // null')
+# Get current rules.
+CURRENT_RULES=$(echo "$INPUTS" | jq '.current_rules // null')
+# Get context values.
+EXPIRATION_TIME=$(echo "$INPUTS" | jq '.context.expiration_time // .current_rules.expiration_time // null')
+
+case "$LEGAL_ENTITY"
+in
+ "NATURAL")
+ FORM="none"
+ ;;
+ "OPERATIONAL")
+ FORM="902.11"
+ ;;
+ "FOUNDATION")
+ FORM="902.12"
+ ;;
+ "TRUST")
+ FORM="902.13"
+ ;;
+ "LIFEINSURANCE")
+ FORM="902.15"
+ ;;
+ "OTHER")
+ FORM="902.9"
+ ;;
+esac
+
+# Check high-level case
+if [ "$FORM" == "none" ]
+then
+ # Proceed to AML stage, preserve rules
+ # FIXME: check if we have to change anything in the rules to prevent
+ # the user from getting the basic KYC form *again*!
+ echo "$INPUTS" | taler-exchange-helper-measure-preserve-but-investigate
+ exit $?
+fi
+
+# Proceed to FORM.
+echo "Selected VQF form ${FORM}." 1&>2
+# FIXME: force user to fill in $FORM
+# NEW_RULES=$(echo "$CURRENT_RULES" | jq 'walk(if (type == "object" and ( ( (.operation_type == "withdraw") and (.threshold == "${EXCHANGE_AML_PROGRAM_TOPS_SMS_WITHDRAW_THRESHOLD") ) or ( (.operation_type == "merge") and (.threshold == "${EXCHANGE_AML_PROGRAM_TOPS_SMS_MERGE_THRESHOLD" ) ) ) ) then del(.) else . end)')
+echo "Not implemented"
+exit 1 # not implemented
+
+# Finally, output the new rules.
+# See https://docs.taler.net/taler-kyc-manual.html#tsref-type-AmlOutcome
+# for the required output format.
+jq \
+ --jsonarg et "$EXPIRATION_TIME" \
+ --jsonarg sm "$SUCCESSOR_MEASURE" \
+ --jsonarg cm "$CUSTOM_MEASURES" \
+ --jsonarg nr "$NEW_RULES" \
+ '{"new_rules":$nr+{"expiration_time":$et,"successor_measure":$sm,"custom_measures":($nr.custom_measures+$cm)}}|del(..|nulls)'
+
+exit 0
diff --git a/src/kyclogic/taler-exchange-helper-measure-tops-postal-check b/src/kyclogic/taler-exchange-helper-measure-tops-postal-check
@@ -57,16 +57,15 @@ do
echo ' -V -- be verbose'
;;
i)
- # Need context and current_rules.
+ # Need attributes, context and current_rules.
+ echo "attributes"
echo "context"
echo "current_rules"
exit 0
;;
r)
- # What to do next?
- echo "custom_measures"
+ # When does the check expire?
echo "expiration_time"
- echo "successor_measure"
exit 0
;;
v)
diff --git a/src/kyclogic/taler-exchange-helper-measure-tops-sms-check b/src/kyclogic/taler-exchange-helper-measure-tops-sms-check
@@ -55,16 +55,15 @@ do
echo ' -V -- be verbose'
;;
i)
- # Need context and current_rules.
+ # Need attributes, context and current_rules.
+ echo "attributes"
echo "context"
echo "current_rules"
exit 0
;;
r)
- # What to do next?
- echo "custom_measures"
+ # When does the check expire?
echo "expiration_time"
- echo "successor_measure"
exit 0
;;
v)