/*
 * CM_INTEREST.pgc - cm 모듈 서비스 CM_INTEREST (one service = one file).
 * Split out of the former inline cm_svr.pgc; runs on the caller's XA
 * branch (no EXEC SQL CONNECT). Advertised by cm_svr at tpsvrinit.
 */
#include "CM_INTEREST.h"

/* 26. CM_INTEREST - 단리 이자 계산 (순수 계산): 원금*연이율(bps)*일수/(10000*365). */
void CM_INTEREST(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    long principal = getl(b, T_AMOUNT), rate_bps = getl(b, T_ARG1), days = getl(b, T_ARG2), interest;
    if (principal < 0 || rate_bps < 0 || days < 0) FAIL(b);
    interest = principal * rate_bps / 10000 * days / 365;
    setl(b, T_AMT1, interest);
    OK(b);
}
