/** * 품목 테이블 금액 계산 유틸리티 */ const DEFAULT_TAX_RATE = 0.1; /** * 공급가액 계산 */ export function calcSupplyAmount(quantity: number, unitPrice: number): number { return quantity * unitPrice; } /** * 부가세 계산 (공급가액의 10%, 소수점 내림) */ export function calcVat(supplyAmount: number, taxRate: number = DEFAULT_TAX_RATE): number { return Math.floor(supplyAmount * taxRate); } /** * 수량 또는 단가 변경 시 공급가액 + 부가세 자동 재계산 * @returns { supplyAmount, vat } 계산된 값 */ export function recalculate( quantity: number, unitPrice: number, taxRate: number = DEFAULT_TAX_RATE, ): { supplyAmount: number; vat: number } { const supplyAmount = calcSupplyAmount(quantity, unitPrice); const vat = calcVat(supplyAmount, taxRate); return { supplyAmount, vat }; }