/*
 * PAY_REVERSE.pgc - py 모듈 서비스 PAY_REVERSE (one service = one file).
 * 지급 역분개(reverse): 상태 V(역분개)로 전이하고 계좌 잔액을 원복.
 * 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_REVERSE.h"

void PAY_REVERSE(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    char acct[32];
    long payout_id = getl(b, T_ID1), amount = getl(b, T_AMOUNT);
    gets_(b, T_KEY1, acct, sizeof(acct));
    if (pydb_update_status(payout_id, "V") < 0) FAIL(b);
    if (acct[0] && pydb_account_add(acct, amount) < 0) FAIL(b);
    Bchg(b, T_STATUS, 0, "V", 0L);
    OK(b);
}
