Files
proxmox/scripts/omnl/omnl-gl-accounts-create.sh
defiQUG fbda1b4beb
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
docs: Ledger Live integration, contract deploy learnings, NEXT_STEPS updates
- 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>
2026-02-12 15:46:57 -08:00

91 lines
2.9 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Create the five migration GL accounts (1000, 1050, 2000, 2100, 3000) in OMNL Fineract via API.
# Idempotent: skips if glCode already exists. Run from repo root. Requires: curl, jq.
set -euo pipefail
REPO_ROOT="${REPO_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}"
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:-}"
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
AUTH="${USER}:${PASS}"
CURL_OPTS=(-s -S -w "\n%{http_code}" -H "Fineract-Platform-TenantId: ${TENANT}" -H "Content-Type: application/json" -u "$AUTH")
api_get() {
curl "${CURL_OPTS[@]}" "${BASE_URL}/${1}"
}
api_post() {
local path="$1"
local body="$2"
local out
out=$(curl "${CURL_OPTS[@]}" -X POST -d "$body" "${BASE_URL}/${path}")
HTTP_CODE=$(echo "$out" | tail -n1)
echo "$out" | sed '$d'
}
# type: 1=ASSET, 2=LIABILITY, 3=EQUITY. usage: 1=DETAIL
create_gl() {
local gl_code="$1"
local name="$2"
local type_id="$3"
local description="$4"
local list
list=$(api_get "glaccounts" 2>/dev/null | sed '$d')
if echo "$list" | jq -e --arg c "$gl_code" '.[] | select(.glCode == $c) | .id' >/dev/null 2>&1; then
echo " [skip] $gl_code$name (exists)"
return 0
fi
# Handle both array and object response
if echo "$list" | grep -q "\"glCode\":\"${gl_code}\""; then
echo " [skip] $gl_code$name (exists)"
return 0
fi
local body
body=$(jq -n \
--arg code "$gl_code" \
--arg name "$name" \
--argjson type "$type_id" \
--arg desc "$description" \
'{glCode: $code, name: $name, type: $type, usage: 1, manualEntriesAllowed: true, description: $desc}')
api_post "glaccounts" "$body" >/dev/null
if [ "${HTTP_CODE:-0}" = "200" ] || [ "${HTTP_CODE:0:1}" = "2" ]; then
echo " [created] $gl_code$name"
else
echo " [fail] $gl_code HTTP ${HTTP_CODE}" >&2
return 1
fi
}
echo "=== OMNL Fineract — Create migration GL accounts ==="
echo "Base URL: $BASE_URL"
echo ""
create_gl "1000" "USD Settlement Reserves" 1 "USD Settlement & Reserve Assets"
create_gl "1050" "USD Treasury Conversion Reserve (M0)" 1 "Treasury Conversion Reserve (M0); backs M1 capacity at 1:5"
create_gl "2000" "USD Central Deposits" 2 "Central bank customer deposits; M1-denominated claims backed by 1050 where applicable"
create_gl "2100" "USD Restricted Liabilities" 2 "Restricted / held deposits"
create_gl "3000" "Opening Balance Control" 3 "Migration control account"
echo ""
echo "Done. Run scripts/omnl/omnl-ledger-post.sh to post T-001T-008."