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

/* 9. ST_ADVANCE - 선지급 예약: 지급 레코드(SCHEDULED) 생성 (dbio). */
void ST_ADVANCE(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    char merch[64], bizdate[16], paydate[16];
    long net = getl(b, T_NET), pay;
    gets_(b, T_MERCHANT, merch, sizeof(merch));
    gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
    gets_(b, T_KEY1, paydate, sizeof(paydate));
    if (paydate[0] == 0) { strncpy(paydate, bizdate, sizeof(paydate)-1); paydate[sizeof(paydate)-1] = 0; }
    pay = stdb_insert_payment(merch, net, paydate, "SCHEDULED", bizdate);
    if (pay < 0) FAIL(b);
    setl(b, T_ID1, pay);
    OK(b);
}

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