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

/* 10. ST_DELAYINT - 지연이자(net * bps/10000 * 일수) 정산 상세 기록 (dbio). */
void ST_DELAYINT(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 net = getl(b, T_NET), days = getl(b, T_ARG1), bps = getl(b, T_ARG2), intr, dtl;
    gets_(b, T_MERCHANT, merch, sizeof(merch));
    gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
    if (days <= 0) days = 1;
    if (bps <= 0) bps = 15;                    /* 일 0.15% 기본 */
    intr = acq_fee(net, bps) * days;
    dtl = stdb_insert_fee_dtl(sid, pid, merch, "DELAYINT", intr, bizdate);
    if (dtl < 0) FAIL(b);
    setl(b, T_AMOUNT, intr);
    OK(b);
}

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