Files
proxmox/scripts/omnl/omnl-transaction-package-snapshot.sh
defiQUG 95522d3bca
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
feat(omnl): HYBX-BATCH-001 package, rail scripts, regulatory docs, CI
- Add OMNL/CBK Indonesia submission and audit binder docs, manifests, attestations
- Add scripts/omnl transaction-package pipeline, LEI/PvP helpers, jq/lib fixtures
- Update entity master data, MASTER_INDEX, TODOS, dbis-rail docs and rulebook
- Add proof_package/regulatory skeleton and transaction package zip + snapshot JSON
- validate-omnl-rail workflow, forge-verification-proxy tweak, .gitignore hygiene
- Bump smom-dbis-138 (cronos verify docs/scripts) and explorer-monorepo (SPA + env report)

Made-with: Cursor
2026-03-24 18:11:36 -07:00

79 lines
3.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# OMNL — Build omnl_transaction_package_snapshot.json for Volume A Section 2 (GET offices + glaccounts).
# Enriches each office with registry LEI / entity name from OMNL_ENTITY_MASTER_DATA.json (offices model;
# Fineract does not store LEI on the office resource).
# Usage: OUT_DIR=. bash scripts/omnl/omnl-transaction-package-snapshot.sh
# Writes: $OUT_DIR/omnl_transaction_package_snapshot.json (default REPO_ROOT)
# ENTITY_DATA=path/to/OMNL_ENTITY_MASTER_DATA.json (optional; default under docs/.../mifos-omnl-central-bank/)
set -euo pipefail
REPO_ROOT="${REPO_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}"
OUT_DIR="${OUT_DIR:-$REPO_ROOT}"
OUT_FILE="${OUT_FILE:-$OUT_DIR/omnl_transaction_package_snapshot.json}"
ENTITY_DATA="${ENTITY_DATA:-${REPO_ROOT}/docs/04-configuration/mifos-omnl-central-bank/OMNL_ENTITY_MASTER_DATA.json}"
ENRICH_JQ="${REPO_ROOT}/scripts/omnl/jq/enrich-snapshot-entity-master.jq"
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 for live snapshot." >&2
exit 1
fi
command -v curl >/dev/null && command -v jq >/dev/null || { echo "Need curl and jq" >&2; exit 1; }
AUTH="${USER}:${PASS}"
CURL_OPTS=(-s -S -H "Fineract-Platform-TenantId: ${TENANT}" -H "Content-Type: application/json" -u "$AUTH")
api_get() { curl "${CURL_OPTS[@]}" "${BASE_URL}/${1}"; }
OFFICES=$(api_get "offices")
GL=$(api_get "glaccounts")
OFFICES_N=$(echo "$OFFICES" | jq -c 'if type == "array" then . elif .pageItems != null then .pageItems else [] end')
GL_N=$(echo "$GL" | jq -c 'if type == "array" then . elif .pageItems != null then .pageItems else [] end')
NOW=$(date -u +%Y-%m-%dT%H:%M:%SZ)
TMP_OUT="${OUT_FILE}.tmp.$$"
jq -n \
--argjson offices "$OFFICES_N" \
--argjson glaccounts "$GL_N" \
--arg gen "$NOW" \
--arg base "$BASE_URL" \
'{
snapshotMeta: {
documentId: "OMNL-TRANSACTION-PACKAGE-SNAPSHOT",
omnlLegalName: "ORGANISATION MONDIALE DU NUMERIQUE L.P.B.C.",
omnlLei: "98450070C57395F6B906",
omnlLeiReferenceUrl: "https://lei.info/98450070C57395F6B906",
omnlDirectorsAndOfficersDoc: "Appendix/OMNL_BANKING_DIRECTORS_AND_LEI.md",
generatedAtUtc: $gen,
settlementRef: "HYBX-BATCH-001",
valueDate: "2026-03-17",
beneficiary: "Bank Kanaya (Indonesia)",
beneficiaryOfficeId: 22,
beneficiaryExternalId: "BANK-KANAYA-ID",
amountUsd: "1000000000.00",
currency: "USD",
source: "live-api",
apiBaseUrl: $base
},
offices: $offices,
glAccounts: $glaccounts
}' > "$TMP_OUT"
if [ -f "$ENTITY_DATA" ] && [ -f "$ENRICH_JQ" ]; then
jq --argjson master "$(jq -c . "$ENTITY_DATA")" -f "$ENRICH_JQ" "$TMP_OUT" > "$OUT_FILE"
rm -f "$TMP_OUT"
else
mv "$TMP_OUT" "$OUT_FILE"
fi
echo "Wrote $OUT_FILE" >&2