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

/* 17. ST_OFFSET - 상계: 음수 조정으로 채권 상계 기록 (dbio). */
void ST_OFFSET(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    char bizdate[16];
    long sid = getl(b, T_SETTLE_ID), pid = getl(b, T_PURCHASE_ID);
    long amt = getl(b, T_AMOUNT), adj;
    gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
    adj = stdb_insert_adjust(sid, pid, -amt, "OFFSET", bizdate);
    if (adj < 0) FAIL(b);
    setl(b, T_ADJ, adj);
    OK(b);
}

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