/*
 * PAY_RECON.pgc - py 모듈 서비스 PAY_RECON (one service = one file).
 * 지급-파일 대사: 특정 file_id 에 편성된 지급 건수/합계를 확인.
 * 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_RECON.h"

void PAY_RECON(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    EXEC SQL BEGIN DECLARE SECTION;
    long h_file, h_cnt, h_sum;
    EXEC SQL END DECLARE SECTION;
    h_file = getl(b, T_ID2);
    EXEC SQL SELECT count(*), coalesce(sum(net),0) INTO :h_cnt, :h_sum
        FROM py_payout WHERE file_id = :h_file;
    if (sqlca.sqlcode < 0) FAIL(b);
    setl(b, T_COUNT, h_cnt);
    setl(b, T_GROSS, h_sum);
    OK(b);
}
