/*
 * ACQ_CORRECT.pgc - ac 모듈 서비스 ACQ_CORRECT (one service = one file).
 * Moved verbatim from the former inline ac_svr.pgc; runs on the caller's XA
 * branch (no EXEC SQL CONNECT). Advertised by ac_svr at tpsvrinit.
 */
#include "ACQ_CORRECT.h"

void ACQ_CORRECT(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    char merch[64];
    long pid, amount, bps = 25, fee, net;
    pid = getl(b, T_PURCHASE_ID); amount = getl(b, T_AMOUNT);
    gets_(b, T_MERCHANT, merch, sizeof(merch));
    if (merch[0] && acdb_merchant_mdr(merch, &bps) < 0) bps = 25;
    fee = acq_fee(amount, bps); net = amount - fee;
    if (acdb_update_amount(pid, amount, fee, net) < 0) FAIL(b);
    setl(b, T_FEE, fee); setl(b, T_NET, net);
    OK(b);
}
