/*
 * ST_WHT.pgc - st 모듈 서비스 ST_WHT (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_WHT.h"

/* 7. ST_WHT - 원천징수(수수료의 22%) 정산 상세 기록 (dbio). */
void ST_WHT(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    char merch[64], bizdate[16];
    long sid = getl(b, T_SETTLE_ID), pid = getl(b, T_PURCHASE_ID);
    long fee = getl(b, T_FEE), tax, dtl;
    gets_(b, T_MERCHANT, merch, sizeof(merch));
    gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
    tax = acq_wht_amt(fee, 2200);
    dtl = stdb_insert_fee_dtl(sid, pid, merch, "WHT", tax, bizdate);
    if (dtl < 0) FAIL(b);
    setl(b, T_TAX, tax);
    OK(b);
}

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