mirror of
https://github.com/s-frick/effigenix.git
synced 2026-03-28 23:13:42 +01:00
feat(tui): Produktionschargen und Bestandsverwaltung in TUI einbauen
Chargen: Liste mit Statusfilter, Planen, Starten, Verbrauch erfassen, Abschließen und Stornieren. Bestände: Liste, Anlegen, Detailansicht mit Chargen sperren/entsperren/entfernen. Types, API-Client, Hooks, Navigation und Screens für beide Bounded Contexts vollständig ergänzt.
This commit is contained in:
parent
b2b3b59ce9
commit
5fe0dfc139
21 changed files with 2385 additions and 31 deletions
81
frontend/packages/api-client/src/resources/batches.ts
Normal file
81
frontend/packages/api-client/src/resources/batches.ts
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/** Batches resource – Production BC. */
|
||||
|
||||
import type { AxiosInstance } from 'axios';
|
||||
import type {
|
||||
BatchDTO,
|
||||
BatchSummaryDTO,
|
||||
ConsumptionDTO,
|
||||
PlanBatchRequest,
|
||||
CompleteBatchRequest,
|
||||
RecordConsumptionRequest,
|
||||
CancelBatchRequest,
|
||||
} from '@effigenix/types';
|
||||
|
||||
export type BatchStatus = 'PLANNED' | 'IN_PRODUCTION' | 'COMPLETED' | 'CANCELLED';
|
||||
|
||||
export const BATCH_STATUS_LABELS: Record<BatchStatus, string> = {
|
||||
PLANNED: 'Geplant',
|
||||
IN_PRODUCTION: 'In Produktion',
|
||||
COMPLETED: 'Abgeschlossen',
|
||||
CANCELLED: 'Storniert',
|
||||
};
|
||||
|
||||
export type {
|
||||
BatchDTO,
|
||||
BatchSummaryDTO,
|
||||
ConsumptionDTO,
|
||||
PlanBatchRequest,
|
||||
CompleteBatchRequest,
|
||||
RecordConsumptionRequest,
|
||||
CancelBatchRequest,
|
||||
};
|
||||
|
||||
const BASE = '/api/production/batches';
|
||||
|
||||
export function createBatchesResource(client: AxiosInstance) {
|
||||
return {
|
||||
async list(status?: BatchStatus): Promise<BatchSummaryDTO[]> {
|
||||
const params: Record<string, string> = {};
|
||||
if (status) params.status = status;
|
||||
const res = await client.get<BatchSummaryDTO[]>(BASE, { params });
|
||||
return res.data;
|
||||
},
|
||||
|
||||
async getById(id: string): Promise<BatchDTO> {
|
||||
const res = await client.get<BatchDTO>(`${BASE}/${id}`);
|
||||
return res.data;
|
||||
},
|
||||
|
||||
async getByNumber(batchNumber: string): Promise<BatchDTO> {
|
||||
const res = await client.get<BatchDTO>(`${BASE}/by-number/${batchNumber}`);
|
||||
return res.data;
|
||||
},
|
||||
|
||||
async plan(request: PlanBatchRequest): Promise<BatchDTO> {
|
||||
const res = await client.post<BatchDTO>(BASE, request);
|
||||
return res.data;
|
||||
},
|
||||
|
||||
async start(id: string): Promise<BatchDTO> {
|
||||
const res = await client.post<BatchDTO>(`${BASE}/${id}/start`);
|
||||
return res.data;
|
||||
},
|
||||
|
||||
async recordConsumption(id: string, request: RecordConsumptionRequest): Promise<ConsumptionDTO> {
|
||||
const res = await client.post<ConsumptionDTO>(`${BASE}/${id}/consumptions`, request);
|
||||
return res.data;
|
||||
},
|
||||
|
||||
async complete(id: string, request: CompleteBatchRequest): Promise<BatchDTO> {
|
||||
const res = await client.post<BatchDTO>(`${BASE}/${id}/complete`, request);
|
||||
return res.data;
|
||||
},
|
||||
|
||||
async cancel(id: string, request: CancelBatchRequest): Promise<BatchDTO> {
|
||||
const res = await client.post<BatchDTO>(`${BASE}/${id}/cancel`, request);
|
||||
return res.data;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export type BatchesResource = ReturnType<typeof createBatchesResource>;
|
||||
|
|
@ -1,7 +1,16 @@
|
|||
/** Stocks resource – Inventory BC. */
|
||||
|
||||
import type { AxiosInstance } from 'axios';
|
||||
import type { StockBatchDTO, AddStockBatchRequest } from '@effigenix/types';
|
||||
import type {
|
||||
StockDTO,
|
||||
StockBatchDTO,
|
||||
AddStockBatchRequest,
|
||||
CreateStockRequest,
|
||||
CreateStockResponse,
|
||||
UpdateStockRequest,
|
||||
RemoveStockBatchRequest,
|
||||
BlockStockBatchRequest,
|
||||
} from '@effigenix/types';
|
||||
|
||||
export type BatchType = 'PURCHASED' | 'PRODUCED';
|
||||
|
||||
|
|
@ -10,7 +19,30 @@ export const BATCH_TYPE_LABELS: Record<BatchType, string> = {
|
|||
PRODUCED: 'Produziert',
|
||||
};
|
||||
|
||||
export type { StockBatchDTO, AddStockBatchRequest };
|
||||
export type StockBatchStatus = 'AVAILABLE' | 'EXPIRING_SOON' | 'EXPIRED' | 'BLOCKED';
|
||||
|
||||
export const STOCK_BATCH_STATUS_LABELS: Record<StockBatchStatus, string> = {
|
||||
AVAILABLE: 'Verfügbar',
|
||||
EXPIRING_SOON: 'Bald ablaufend',
|
||||
EXPIRED: 'Abgelaufen',
|
||||
BLOCKED: 'Gesperrt',
|
||||
};
|
||||
|
||||
export type {
|
||||
StockDTO,
|
||||
StockBatchDTO,
|
||||
AddStockBatchRequest,
|
||||
CreateStockRequest,
|
||||
CreateStockResponse,
|
||||
UpdateStockRequest,
|
||||
RemoveStockBatchRequest,
|
||||
BlockStockBatchRequest,
|
||||
};
|
||||
|
||||
export interface StockFilter {
|
||||
storageLocationId?: string;
|
||||
articleId?: string;
|
||||
}
|
||||
|
||||
// ── Resource factory ─────────────────────────────────────────────────────────
|
||||
|
||||
|
|
@ -18,10 +50,45 @@ const BASE = '/api/inventory/stocks';
|
|||
|
||||
export function createStocksResource(client: AxiosInstance) {
|
||||
return {
|
||||
async list(filter?: StockFilter): Promise<StockDTO[]> {
|
||||
const params: Record<string, string> = {};
|
||||
if (filter?.storageLocationId) params.storageLocationId = filter.storageLocationId;
|
||||
if (filter?.articleId) params.articleId = filter.articleId;
|
||||
const res = await client.get<StockDTO[]>(BASE, { params });
|
||||
return res.data;
|
||||
},
|
||||
|
||||
async getById(id: string): Promise<StockDTO> {
|
||||
const res = await client.get<StockDTO>(`${BASE}/${id}`);
|
||||
return res.data;
|
||||
},
|
||||
|
||||
async create(request: CreateStockRequest): Promise<CreateStockResponse> {
|
||||
const res = await client.post<CreateStockResponse>(BASE, request);
|
||||
return res.data;
|
||||
},
|
||||
|
||||
async update(id: string, request: UpdateStockRequest): Promise<StockDTO> {
|
||||
const res = await client.put<StockDTO>(`${BASE}/${id}`, request);
|
||||
return res.data;
|
||||
},
|
||||
|
||||
async addBatch(stockId: string, request: AddStockBatchRequest): Promise<StockBatchDTO> {
|
||||
const res = await client.post<StockBatchDTO>(`${BASE}/${stockId}/batches`, request);
|
||||
return res.data;
|
||||
},
|
||||
|
||||
async removeBatch(stockId: string, batchId: string, request: RemoveStockBatchRequest): Promise<void> {
|
||||
await client.post(`${BASE}/${stockId}/batches/${batchId}/remove`, request);
|
||||
},
|
||||
|
||||
async blockBatch(stockId: string, batchId: string, request: BlockStockBatchRequest): Promise<void> {
|
||||
await client.post(`${BASE}/${stockId}/batches/${batchId}/block`, request);
|
||||
},
|
||||
|
||||
async unblockBatch(stockId: string, batchId: string): Promise<void> {
|
||||
await client.post(`${BASE}/${stockId}/batches/${batchId}/unblock`);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue