mirror of
https://github.com/s-frick/effigenix.git
synced 2026-03-28 11:59:35 +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
|
|
@ -24,6 +24,7 @@ export { createArticlesResource } from './resources/articles.js';
|
|||
export { createCustomersResource } from './resources/customers.js';
|
||||
export { createStorageLocationsResource } from './resources/storage-locations.js';
|
||||
export { createRecipesResource } from './resources/recipes.js';
|
||||
export { createBatchesResource } from './resources/batches.js';
|
||||
export { createStocksResource } from './resources/stocks.js';
|
||||
export {
|
||||
ApiError,
|
||||
|
|
@ -90,6 +91,20 @@ export type {
|
|||
AddProductionStepRequest,
|
||||
StockBatchDTO,
|
||||
AddStockBatchRequest,
|
||||
BatchDTO,
|
||||
BatchSummaryDTO,
|
||||
ConsumptionDTO,
|
||||
PlanBatchRequest,
|
||||
CompleteBatchRequest,
|
||||
RecordConsumptionRequest,
|
||||
CancelBatchRequest,
|
||||
StockDTO,
|
||||
CreateStockRequest,
|
||||
CreateStockResponse,
|
||||
UpdateStockRequest,
|
||||
RemoveStockBatchRequest,
|
||||
BlockStockBatchRequest,
|
||||
MinimumLevelDTO,
|
||||
} from '@effigenix/types';
|
||||
|
||||
// Resource types (runtime, stay in resource files)
|
||||
|
|
@ -115,8 +130,10 @@ export type {
|
|||
export { STORAGE_TYPE_LABELS } from './resources/storage-locations.js';
|
||||
export type { RecipesResource, RecipeType, RecipeStatus, UoM } from './resources/recipes.js';
|
||||
export { RECIPE_TYPE_LABELS, UOM_VALUES, UOM_LABELS } from './resources/recipes.js';
|
||||
export type { StocksResource, BatchType } from './resources/stocks.js';
|
||||
export { BATCH_TYPE_LABELS } from './resources/stocks.js';
|
||||
export type { BatchesResource, BatchStatus } from './resources/batches.js';
|
||||
export { BATCH_STATUS_LABELS } from './resources/batches.js';
|
||||
export type { StocksResource, BatchType, StockBatchStatus, StockFilter } from './resources/stocks.js';
|
||||
export { BATCH_TYPE_LABELS, STOCK_BATCH_STATUS_LABELS } from './resources/stocks.js';
|
||||
|
||||
import { createApiClient } from './client.js';
|
||||
import { createAuthResource } from './resources/auth.js';
|
||||
|
|
@ -128,6 +145,7 @@ import { createArticlesResource } from './resources/articles.js';
|
|||
import { createCustomersResource } from './resources/customers.js';
|
||||
import { createStorageLocationsResource } from './resources/storage-locations.js';
|
||||
import { createRecipesResource } from './resources/recipes.js';
|
||||
import { createBatchesResource } from './resources/batches.js';
|
||||
import { createStocksResource } from './resources/stocks.js';
|
||||
import type { TokenProvider } from './token-provider.js';
|
||||
import type { ApiConfig } from '@effigenix/config';
|
||||
|
|
@ -152,6 +170,7 @@ export function createEffigenixClient(
|
|||
customers: createCustomersResource(axiosClient),
|
||||
storageLocations: createStorageLocationsResource(axiosClient),
|
||||
recipes: createRecipesResource(axiosClient),
|
||||
batches: createBatchesResource(axiosClient),
|
||||
stocks: createStocksResource(axiosClient),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
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