From f27591d078868ba825058e9f63863f6458063bfd Mon Sep 17 00:00:00 2001 From: "Jeong, Sejun" Date: Sat, 25 Jul 2026 10:01:17 +0900 Subject: [PATCH] fix: read Business Area (GSBER) / Business Place (BUPLA) from user config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GSBER and BUPLA were hardcoded to K200/K100, which only matches the default shipped user (박영걸, Business Area K200). A user in another Business Area (e.g. K300) hits "Please input only the same 'Business Area'" (SAP.ZFI1,213) on `voucher create`, because SAP derives the line Business Area from the cost center and it conflicts with the hardcoded K200 header value. - Add optional gsber/bupla fields to UserProfile - Read user.gsber / user.bupla (fallback K200/K100) in computeDefaults, createTempDoc, and the corpcard create flow Co-Authored-By: Claude Opus 4.8 (1M context) --- src/lib/ops.ts | 6 +++--- src/types/index.ts | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/ops.ts b/src/lib/ops.ts index a76d381..4e6ad76 100644 --- a/src/lib/ops.ts +++ b/src/lib/ops.ts @@ -486,7 +486,7 @@ export async function computeDefaults( const r = await callNS(ctx, "ZUNIEFI_4003", PROG_LEGACY, { BUDAT: budat, BLDAT: bldat, BLART: "KE", LIFNR: user.pernr, LIFNR_TXT: user.pernrName, - BUPLA: "K100", GSBER: "K200", MWSKZ: "T0", + BUPLA: user.bupla ?? "K100", GSBER: user.gsber ?? "K200", MWSKZ: "T0", AKONT: "21020103", ZTERM: "V123", WRBTR: String(amountWon), WRBTR_SLASH: "", WMWST: "0", BVTYP: "0001", ZFBDT: "", ZFBDT_SLASH: "", @@ -529,7 +529,7 @@ export async function createTempDoc( const commonFi = { BUDAT: budat, BLDAT: bldat, BLART: "KE", LIFNR: user.pernr, LIFNR_TXT: user.pernrName, - BUPLA: "K100", GSBER: "K200", MWSKZ: "T0", + BUPLA: user.bupla ?? "K100", GSBER: user.gsber ?? "K200", MWSKZ: "T0", AKONT: "21020103", ZTERM: "V123", WRBTR: String(amountWon), WRBTR_SLASH: "", WMWST: "0", BVTYP: "0001", ZFBDT: zfbdt, ZFBDT_SLASH: "", @@ -929,7 +929,7 @@ export async function createCorpCardVoucher( CHARGETOTAL: card.AMOUNT, CHARGETOTAL_Slash: "", WMWST_READ_ONLY: card.TAX, BUDAT: p.budat, BLDAT: bldat, BLART: "KE", - BUPLA: "K100", GSBER: "K200", + BUPLA: user.bupla ?? "K100", GSBER: user.gsber ?? "K200", WRBTR_SLASH: "", WMWST: card.TAX, ZFBDT_SLASH: "", EMPTY: "", SGTXT: p.sgtxt, diff --git a/src/types/index.ts b/src/types/index.ts index bcc305b..c3d292f 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -14,6 +14,8 @@ export interface UserProfile { kostlText: string; // "Device Engineering" wfDept: string; // Department code wfDeptText: string; // "Service Engineering" + gsber?: string; // Business Area, e.g. "K300" (SAP requires cost-center-consistent value) + bupla?: string; // Business Place, e.g. "K100" } export interface ReimbursementItem {