/*
 * ACQ_TAXINV.pgc - ac 모듈 서비스 ACQ_TAXINV (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_TAXINV.h"

void ACQ_TAXINV(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    char merch[64], bizdate[16];
    long pid, supply, vat, inv;
    pid = getl(b, T_PURCHASE_ID);
    supply = getl(b, T_AMOUNT);
    gets_(b, T_MERCHANT, merch, sizeof(merch));
    gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
    vat = acq_vat(supply);
    inv = acdb_insert_tax_invoice(pid, merch, supply, vat, bizdate);
    if (inv < 0) FAIL(b);
    setl(b, T_TAX, vat);
    OK(b);
}
