manicanldes-backend/src/common/errors/commerce-errors.ts

235 lines
6.1 KiB
TypeScript

export const COMMERCE_ERRORS = {
PRODUCT_NOT_FOUND: [404, 'Product not found', 'Scoped product lookup failed'],
PRODUCT_NOT_PUBLISHABLE: [
409,
'Add an active priced variant before publishing',
'Product publish eligibility failed',
],
PRODUCT_ARCHIVED: [
409,
'Archived products cannot be edited',
'Archived product mutation rejected',
],
VARIANT_NOT_FOUND: [
404,
'Product variant not found',
'Scoped product variant lookup failed',
],
VARIANT_LIMIT: [
409,
'Product variant limit reached',
'Variant resource quota exceeded',
],
VARIANT_REQUIRED: [
409,
'A published product needs an active variant',
'Last sellable variant deactivation rejected',
],
GROUP_NOT_FOUND: [
404,
'Catalogue group not found',
'Scoped catalogue group lookup failed',
],
ADDRESS_NOT_FOUND: [
404,
'Address not found',
'Private address lookup failed',
],
ADDRESS_LIMIT: [
409,
'Address limit reached',
'Account address quota exceeded',
],
WAREHOUSE_NOT_FOUND: [
404,
'Warehouse not found',
'Scoped warehouse lookup failed',
],
STOCK_NOT_FOUND: [404, 'Stock item not found', 'Scoped stock lookup failed'],
STOCK_INSUFFICIENT: [
409,
'Insufficient available stock',
'Inventory availability check rejected operation',
],
STOCK_CAPACITY: [
409,
'Stock balance limit would be exceeded',
'Inventory integer bound rejected operation',
],
IDEMPOTENCY_CONFLICT: [
409,
'Idempotency key was used for a different request',
'Idempotency payload mismatch',
],
RESERVATION_NOT_FOUND: [
404,
'Stock reservation not found',
'Scoped reservation lookup failed',
],
RESERVATION_EXPIRED: [
409,
'Stock reservation has expired',
'Expired reservation commit rejected',
],
RESERVATION_CLOSED: [
409,
'Stock reservation is already closed',
'Invalid reservation state transition',
],
PRODUCT_UNAVAILABLE: [
409,
'Product variant is not available for reservation',
'Non-sellable variant reservation rejected',
],
SUPPLIER_NOT_FOUND: [
404,
'Supplier not found',
'Scoped supplier lookup failed',
],
MATERIAL_NOT_FOUND: [
404,
'Material not found',
'Scoped material lookup failed',
],
SUPPLIER_MATERIAL_NOT_FOUND: [
404,
'Supplier material is unavailable',
'Scoped supplier-material compatibility lookup failed',
],
PURCHASE_ORDER_NOT_FOUND: [
404,
'Purchase order not found',
'Scoped purchase order lookup failed',
],
PURCHASE_ORDER_STATE: [
409,
'Purchase order cannot change in its current state',
'Purchase order lifecycle transition rejected',
],
PURCHASE_ORDER_CURRENCY: [
409,
'Purchase order materials must use one currency',
'Supplier material quote currency mismatch',
],
PURCHASE_ORDER_MINIMUM: [
409,
'Order quantity is below the supplier minimum',
'Supplier material minimum order quantity rejected',
],
RECEIPT_NOT_FOUND: [
404,
'Goods receipt not found',
'Scoped goods receipt lookup failed',
],
RECEIPT_ORDER_STATE: [
409,
'Only issued purchase orders can receive goods',
'Receipt rejected for non-issued order',
],
RECEIPT_LINE_INVALID: [
409,
'Receipt line does not belong to this purchase order',
'Receipt purchase-order line mismatch',
],
RECEIPT_QUANTITY_LIMIT: [
409,
'Received quantity exceeds the outstanding order quantity',
'Receipt outstanding quantity exceeded',
],
RECEIPT_ALREADY_INSPECTED: [
409,
'Goods receipt has already been inspected',
'Duplicate receipt inspection rejected',
],
INSPECTION_LINES_INVALID: [
409,
'Inspect every receipt line exactly once',
'Inspection receipt-line set mismatch',
],
INSPECTION_QUANTITY_INVALID: [
409,
'Accepted and rejected quantities must equal the received quantity',
'Inspection quantity reconciliation failed',
],
INSPECTION_REASON_REQUIRED: [
409,
'Give a reason for rejected goods',
'Rejected receipt quantity lacked a reason',
],
INVOICE_NOT_FOUND: [
404,
'Supplier invoice not found',
'Scoped supplier invoice lookup failed',
],
INVOICE_ORDER_STATE: [
409,
'Only issued purchase orders can be invoiced',
'Supplier invoice rejected for non-issued order',
],
INVOICE_LINE_INVALID: [
409,
'Invoice line does not belong to this purchase order',
'Supplier invoice order-line mismatch',
],
INVOICE_QC_REQUIRED: [
409,
'Goods must pass quality inspection before invoicing',
'Supplier invoice line has no accepted receipt quantity',
],
INVOICE_QUANTITY_LIMIT: [
409,
'Invoice quantity exceeds accepted, uninvoiced goods',
'Supplier invoice accepted quantity exceeded',
],
INVOICE_NUMBER_CONFLICT: [
409,
'Invoice number is already recorded for this supplier',
'Supplier invoice number duplicate',
],
INVOICE_AMOUNT_LIMIT: [
409,
'Invoice amount exceeds the supported limit',
'Supplier invoice money column limit exceeded',
],
INVOICE_ALREADY_VOID: [
409,
'Supplier invoice is already void',
'Duplicate supplier invoice void rejected',
],
INVOICE_PAYMENT_EXISTS: [
409,
'Reverse active payments before voiding this invoice',
'Supplier invoice void blocked by active payment',
],
PAYMENT_NOT_FOUND: [
404,
'Supplier payment not found',
'Scoped supplier payment lookup failed',
],
PAYMENT_INVOICE_VOID: [
409,
'Cannot record payment for a void invoice',
'Supplier payment rejected for void invoice',
],
PAYMENT_AMOUNT_LIMIT: [
409,
'Payment exceeds the remaining invoice balance',
'Supplier payment balance exceeded',
],
PAYMENT_REFERENCE_CONFLICT: [
409,
'Payment reference is already recorded',
'Supplier payment reference duplicate',
],
PAYMENT_REPLAY_CONFLICT: [
409,
'Idempotency key was used for a different payment',
'Supplier payment idempotency payload mismatch',
],
PAYMENT_ALREADY_REVERSED: [
409,
'Supplier payment is already reversed',
'Duplicate supplier payment reversal rejected',
],
} as const;