← All packages

@lacspace/refund

v1.0.0Commerce & Ledger0 deps

Returns / RMA workflow and refund-calculation engine — partial refunds with correct tax apportionment, restocking fees, restock lists and a return state machine. Integer minor units, zero-dependency, isomorphic.

npm i @lacspace/refund

Usage

refund.ts
import { createReturn, refundAmount, restockItems, transition } from "@lacspace/refund";

let rma = createReturn({ orderId: "ORD-1042", items: [
  { lineId: "l1", sku: "NP-1", qty: 1, unitPrice: 120000, taxRate: 0.13, reason: "size", restock: true },
] });
rma = transition(rma, "approved");

const money = refundAmount(rma.items, { restockingPct: 0.10 });
// { subtotal: 120000, tax: 15600, restockingFee: 12000, shipping: 0, total: 123600 }
const restock = restockItems(rma.items); // [{ sku: "NP-1", qty: 1 }] -> feed @lacspace/inventory

Exports 9

createReturntransitionrefundAmountrestockItemsvalidateReturncanTransitionisTerminalRETURN_TRANSITIONSRefundError

Keywords

refundreturnsrmaecommercepartial-refundrestock

More in Commerce & Ledger