"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bindOffice24 = bindOffice24;
const config_1 = require("../config");
/** Bind every settlement request to Office 24 (same profile as OMNL terminal). */
function bindOffice24(req) {
    const cfg = (0, config_1.loadConfig)();
    const profile = (0, config_1.loadOfficeProfile)();
    const officeId = (0, config_1.settlementOfficeId)(req.officeId);
    if (!req.idempotencyKey || !req.creditorIban || !req.amount) {
        throw new Error('idempotencyKey, creditorIban, amount required');
    }
    return {
        officeId,
        valueDate: req.valueDate ?? new Date().toISOString().slice(0, 10),
        currency: req.currency ?? profile.settlement.defaultCurrency ?? cfg.defaultCurrency,
        moneyLayers: (req.moneyLayers ?? profile.settlement.moneyLayers),
        rail: req.rail ?? 'SWIFT',
        remittanceInfo: req.remittanceInfo ?? `OMNL Office 24 settlement — ${profile.externalId}`,
        beneficiaryName: req.beneficiaryName ?? 'Beneficiary',
        idempotencyKey: req.idempotencyKey,
        creditorIban: req.creditorIban,
        amount: req.amount,
        debtorIban: req.debtorIban,
        creditorBic: req.creditorBic,
        orderingName: req.orderingName ?? profile.omnlLegalName,
        swiftMessageKind: req.swiftMessageKind,
        tradeFinance: req.tradeFinance,
        rwaVerbiage: req.rwaVerbiage,
        convertToCrypto: req.convertToCrypto,
    };
}
