Rate Matrix Rules user story

This commit is contained in:
hagiye
2026-06-02 10:47:36 +03:00
parent 3682bda85c
commit d52a5715e0
12 changed files with 769 additions and 3 deletions

View File

@@ -16,5 +16,21 @@ export const QUERY_KEYS = {
ROOT: "customers",
LIST: "list",
BY_ID: "by-id"
}
}
},
// constants/queryKeys.ts - Add these keys
rateMatrix: {
all: ['rate-matrices'] as const,
lists: () => [...QUERY_KEYS.rateMatrix.all, 'list'] as const,
list: (filters: Record<string, unknown>) => [...QUERY_KEYS.rateMatrix.lists(), filters] as const,
details: () => [...QUERY_KEYS.rateMatrix.all, 'detail'] as const,
detail: (id: string) => [...QUERY_KEYS.rateMatrix.details(), id] as const,
},
referenceData: {
all: ['reference-data'] as const,
ports: () => [...QUERY_KEYS.referenceData.all, 'ports'] as const,
cities: () => [...QUERY_KEYS.referenceData.all, 'cities'] as const,
containerTypes: () => [...QUERY_KEYS.referenceData.all, 'container-types'] as const,
currencies: () => [...QUERY_KEYS.referenceData.all, 'currencies'] as const,
},
};

View File

@@ -121,4 +121,18 @@ export const URL_CONSTANTS = {
WEIGHT_LIMIT_RULE_BY_ID: (id: string | number) =>
`/weight-limit-rules/${id}`,
},
RATE_MATRIX: {
BASE: '/api/rate-matrices',
DRAFT: '/api/rate-matrices/draft',
SUBMIT: (id: string) => `/api/rate-matrices/${id}/submit`,
AUTHORIZE: (id: string) => `/api/rate-matrices/${id}/authorize`,
LIST: '/api/rate-matrices',
DETAIL: (id: string) => `/api/rate-matrices/${id}`,
},
REFERENCE: {
PORTS: '/api/reference/ports',
CITIES: '/api/reference/cities',
CONTAINER_TYPES: '/api/reference/container-types',
CURRENCIES: '/api/reference/currencies',
},
};

View File

@@ -0,0 +1,60 @@
// constants/rateMatrixConstants.ts
export const RATE_TYPES = {
CONTAINER_IMPORT: 'container_import',
CONTAINER_EXPORT: 'container_export',
BULK_IMPORT: 'bulk_import',
BULK_EXPORT: 'bulk_export',
INTER_CITY_BULK: 'inter_city_bulk',
INTER_CITY_CONTAINER: 'inter_city_container',
FIRST_MILE: 'first_mile',
LAST_MILE: 'last_mile',
DEMURRAGE: 'demurrage',
LASHING: 'lashing',
DOUBLE_HANDLING: 'double_handling',
CONTAINER_WITH_RETURN: 'container_with_return',
CANCELLATION_FEE: 'cancellation_fee',
} as const;
export const RATE_TYPE_LABELS = {
[RATE_TYPES.CONTAINER_IMPORT]: 'Container Import Rates',
[RATE_TYPES.CONTAINER_EXPORT]: 'Container Export Rates',
[RATE_TYPES.BULK_IMPORT]: 'Bulk Import Rates',
[RATE_TYPES.BULK_EXPORT]: 'Bulk Export Rates',
[RATE_TYPES.INTER_CITY_BULK]: 'Inter City Bulk Rates',
[RATE_TYPES.INTER_CITY_CONTAINER]: 'Inter City Container Rates',
[RATE_TYPES.FIRST_MILE]: 'First Mile Cost Rates',
[RATE_TYPES.LAST_MILE]: 'Last Mile Cost Rates',
[RATE_TYPES.DEMURRAGE]: 'Demurrage Cost Rates',
[RATE_TYPES.LASHING]: 'Lashing Cost Rates',
[RATE_TYPES.DOUBLE_HANDLING]: 'Double Handling Cost Rates',
[RATE_TYPES.CONTAINER_WITH_RETURN]: 'Container With Return Cost Rates',
[RATE_TYPES.CANCELLATION_FEE]: 'Cancellation Fee Cost Rates',
} as const;
export const REQUIRED_RATE_TYPES = Object.values(RATE_TYPES);
export const RATE_FIELDS_CONFIG = {
[RATE_TYPES.CONTAINER_IMPORT]: [
{ name: 'portOfLoading', label: 'Port of Loading', type: 'text', required: true },
{ name: 'portOfDischarge', label: 'Port of Discharge', type: 'text', required: true },
{ name: 'containerType', label: 'Container Type', type: 'select', required: true },
{ name: 'baseRate', label: 'Base Rate', type: 'number', required: true, min: 0, step: '0.01' },
{ name: 'baf', label: 'Bunker Adjustment Factor', type: 'number', required: false, min: 0 },
{ name: 'caf', label: 'Currency Adjustment Factor', type: 'number', required: false, min: 0 },
],
[RATE_TYPES.DEMURRAGE]: [
{ name: 'containerType', label: 'Container Type', type: 'select', required: true },
{ name: 'freeDays', label: 'Free Days', type: 'number', required: true, min: 0 },
{ name: 'ratePerDay', label: 'Rate per Day', type: 'number', required: true, min: 0 },
{ name: 'maximumDays', label: 'Maximum Days', type: 'number', required: false, min: 1 },
],
// ... define for all 13 rate types
} as const;
export const MATRIX_STATUS = {
DRAFT: 'draft',
PENDING_APPROVAL: 'pending_approval',
ACTIVE: 'active',
REJECTED: 'rejected',
EXPIRED: 'expired',
} as const;