Some checks failed
CI/CD Pipeline / Solidity Contracts (push) Failing after 1m22s
CI/CD Pipeline / Security Scanning (push) Successful in 2m30s
CI/CD Pipeline / Lint and Format (push) Failing after 44s
CI/CD Pipeline / Terraform Validation (push) Failing after 27s
CI/CD Pipeline / Kubernetes Validation (push) Successful in 31s
Deploy ChainID 138 / Deploy ChainID 138 (push) Failing after 56s
HYBX OMNL TypeScript & anchor / token-aggregation build + reconcile artifact (push) Failing after 29s
Validation / validate-genesis (push) Successful in 34s
Validation / validate-terraform (push) Failing after 39s
Validation / validate-kubernetes (push) Failing after 14s
Validation / validate-smart-contracts (push) Failing after 20s
Validation / validate-security (push) Failing after 1m19s
Validation / validate-documentation (push) Failing after 27s
Verify Deployment / Verify Deployment (push) Failing after 1m13s
Co-authored-by: Cursor <cursoragent@cursor.com>
53 lines
2.0 KiB
JavaScript
53 lines
2.0 KiB
JavaScript
"use strict";
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.postJournalEntry = postJournalEntry;
|
|
exports.fetchGlBalances = fetchGlBalances;
|
|
const axios_1 = __importDefault(require("axios"));
|
|
function authHeaders() {
|
|
const base = (process.env.OMNL_FINERACT_BASE_URL || '').replace(/\/$/, '');
|
|
const tenant = process.env.OMNL_FINERACT_TENANT || 'omnl';
|
|
const user = process.env.OMNL_FINERACT_USER?.trim() ||
|
|
process.env.OMNL_FINERACT_USERNAME?.trim() ||
|
|
'ali_hospitallers_tenant';
|
|
const pass = process.env.OMNL_FINERACT_PASSWORD || '';
|
|
if (!base || !pass)
|
|
throw new Error('Fineract credentials required');
|
|
const auth = Buffer.from(`${user}:${pass}`).toString('base64');
|
|
return {
|
|
Authorization: `Basic ${auth}`,
|
|
'Fineract-Platform-TenantId': tenant,
|
|
'Content-Type': 'application/json',
|
|
};
|
|
}
|
|
async function postJournalEntry(entry) {
|
|
const base = (process.env.OMNL_FINERACT_BASE_URL || '').replace(/\/$/, '');
|
|
const { data } = await axios_1.default.post(`${base}/journalentries`, entry, {
|
|
headers: authHeaders(),
|
|
timeout: 60000,
|
|
});
|
|
return { resourceId: data.resourceId ?? data.entityId ?? 0 };
|
|
}
|
|
async function fetchGlBalances(officeId) {
|
|
const base = (process.env.OMNL_FINERACT_BASE_URL || '').replace(/\/$/, '');
|
|
try {
|
|
const { data } = await axios_1.default.get(`${base}/runreports/General Ledger Report`, {
|
|
headers: authHeaders(),
|
|
params: { R_officeId: officeId, genericResultSet: false },
|
|
timeout: 60000,
|
|
});
|
|
const out = {};
|
|
const rows = Array.isArray(data) ? data : data?.data ?? [];
|
|
for (const row of rows) {
|
|
if (row.glCode)
|
|
out[row.glCode] = String(row.balance ?? 0);
|
|
}
|
|
return out;
|
|
}
|
|
catch {
|
|
return {};
|
|
}
|
|
}
|