/*
 * PAY_INT.pgc - py 모듈 서비스 PAY_INT (one service = one file).
 * 선지급 이자 계산: 일할(days) * bps 로 이자와 차감 후 순액을 산출(순수 계산).
 * 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_INT.h"

void PAY_INT(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    long principal, days, bps, interest;
    principal = getl(b, T_AMOUNT);
    days = getl(b, T_ARG1); if (days < 1) days = 1;
    bps = getl(b, T_ARG2); if (bps <= 0) bps = 15;   /* 0.15%/일 */
    interest = principal * bps * days / 10000;
    setl(b, T_AMT1, interest);
    setl(b, T_NET, principal - interest);
    OK(b);
}
