/*
 * PAY_ACCTCHK.pgc - py 모듈 서비스 PAY_ACCTCHK (one service = one file).
 * 지급계좌 유효성 점검: dbio 로 계좌 상태/잔액을 읽어 ACTIVE 여부를 회신.
 * Moved verbatim from the former inline py_svr.pgc; runs on the caller's XA
 * branch (no EXEC SQL CONNECT). Advertised by py_svr at tpsvrinit.
 */
#include "PAY_ACCTCHK.h"

void PAY_ACCTCHK(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    char acct[32], st[8];
    long bal = 0;
    gets_(b, T_KEY1, acct, sizeof(acct));
    if (pydb_account_check(acct, st, &bal) < 0) { setl(b, T_RC, 1); FAIL(b); }
    setl(b, T_AMT1, bal);
    Bchg(b, T_STR1, 0, st, 0L);
    setl(b, T_RC, (strcmp(st, "ACTIVE") == 0) ? 0 : 1);
    OK(b);
}
