/*
 * RC_AUTOFIX.pgc - rc 모듈 서비스 RC_AUTOFIX (one service = one file).
 * Moved verbatim from the former inline rc_svr.pgc; runs on the caller's XA
 * branch (no EXEC SQL CONNECT). Advertised by rc_svr at tpsvrinit.
 */
#include "RC_AUTOFIX.h"

/* 14. RC_AUTOFIX - 자동 보정: 예외 해소 + 보정 원장. */
void RC_AUTOFIX(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    char bizdate[16];
    long pid = getl(b, T_PURCHASE_ID), amt = getl(b, T_AMOUNT);
    gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
    if (rcdb_resolve_exception(pid) < 0) FAIL(b);
    if (rcdb_insert_ledger(pid, "AUTOFIX", amt, bizdate) < 0) FAIL(b);
    if (rcdb_update_match_status(pid, "EXCEPTION", "MATCHED") < 0) FAIL(b);
    OK(b);
}

/* vim: set ts=4 sw=4 et smartindent: */
