/*
 * CM_FX.pgc - cm 모듈 서비스 CM_FX (one service = one file).
 * Split out of the former inline cm_svr.pgc; runs on the caller's XA
 * branch (no EXEC SQL CONNECT). Advertised by cm_svr at tpsvrinit.
 */
#include "CM_FX.h"

/* 11. CM_FX - 환율 조회 (cm_fx_rate). */
void CM_FX(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    char ccy[8], bizdate[16];
    long rate;
    gets_(b, T_CCY, ccy, sizeof(ccy)); if (ccy[0] == 0) strcpy(ccy, "USD");
    gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
    if (bizdate[0] == 0) { if (cmdb_get_param("BIZ_DATE", bizdate) < 0) strcpy(bizdate, "2026-07-19"); }
    if (cmdb_get_fx_rate(ccy, bizdate, &rate) < 0) { userlog("CM_FX 환율 없음 ccy=%s", ccy); FAIL(b); }
    setl(b, T_ARG1, rate);
    OK(b);
}
