Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands - CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround - CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check - NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere - MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates - LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference Co-authored-by: Cursor <cursoragent@cursor.com>
53 lines
1.9 KiB
Bash
Executable File
53 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Post a single deposit to an existing savings account in OMNL Fineract.
|
|
# Usage: ACCOUNT_ID=<id> AMOUNT=<number> [DATE=yyyy-MM-dd] bash scripts/omnl/omnl-deposit-one.sh
|
|
# Get ACCOUNT_ID from: bash scripts/omnl/omnl-discovery.sh (savingsaccounts) or OUT_DIR output.
|
|
|
|
set -euo pipefail
|
|
REPO_ROOT="${REPO_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}"
|
|
DATE="${DATE:-$(date +%Y-%m-%d)}"
|
|
|
|
if [ -f "${REPO_ROOT}/omnl-fineract/.env" ]; then
|
|
set +u
|
|
source "${REPO_ROOT}/omnl-fineract/.env" 2>/dev/null || true
|
|
set -u
|
|
elif [ -f "${REPO_ROOT}/.env" ]; then
|
|
set +u
|
|
source "${REPO_ROOT}/.env" 2>/dev/null || true
|
|
set -u
|
|
fi
|
|
|
|
BASE_URL="${OMNL_FINERACT_BASE_URL:-}"
|
|
TENANT="${OMNL_FINERACT_TENANT:-omnl}"
|
|
USER="${OMNL_FINERACT_USER:-app.omnl}"
|
|
PASS="${OMNL_FINERACT_PASSWORD:-}"
|
|
ACCOUNT_ID="${ACCOUNT_ID:-}"
|
|
AMOUNT="${AMOUNT:-}"
|
|
|
|
if [ -z "$BASE_URL" ] || [ -z "$PASS" ]; then
|
|
echo "Set OMNL_FINERACT_BASE_URL and OMNL_FINERACT_PASSWORD (e.g. omnl-fineract/.env)" >&2
|
|
exit 1
|
|
fi
|
|
if [ -z "$ACCOUNT_ID" ] || [ -z "$AMOUNT" ]; then
|
|
echo "Usage: ACCOUNT_ID=<savingsAccountId> AMOUNT=<number> [DATE=yyyy-MM-dd] $0" >&2
|
|
echo "Get ACCOUNT_ID from: bash scripts/omnl/omnl-discovery.sh (see savingsaccounts)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
AUTH="${USER}:${PASS}"
|
|
BODY=$(jq -n \
|
|
--arg date "$DATE" \
|
|
--argjson amount "$AMOUNT" \
|
|
'{ transactionDate: $date, transactionAmount: $amount, dateFormat: "yyyy-MM-dd", locale: "en", paymentTypeId: 1, note: "Deposit via omnl-deposit-one.sh" }')
|
|
out=$(curl -s -S -w "\n%{http_code}" -X POST \
|
|
-H "Fineract-Platform-TenantId: ${TENANT}" -H "Content-Type: application/json" -u "$AUTH" \
|
|
-d "$BODY" "${BASE_URL}/savingsaccounts/${ACCOUNT_ID}/transactions?command=deposit")
|
|
code=$(echo "$out" | tail -n1)
|
|
resp=$(echo "$out" | sed '$d')
|
|
if [ "$code" = "200" ] || [ "${code:0:1}" = "2" ]; then
|
|
echo "OK Deposit $AMOUNT to account $ACCOUNT_ID (HTTP $code)"
|
|
else
|
|
echo "FAIL HTTP $code: $resp" >&2
|
|
exit 1
|
|
fi
|