Stock is scoped to a catalog + cost centers only, per direction that physical GRV/stock-take/recipe transactions belong in an external system (Matrix), not this accounting app. Stock Control/GRN/Variance/ PPV GL accounts are now plain postable accounts rather than locked control accounts. Also fixes session loss on page refresh: auth stores now persist to localStorage, and ProtectedRoute waits for rehydration before deciding to redirect to login. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JWqiUSojMLUoN7mrJqdEbN
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { Router } from 'express';
|
|
import { requireAuth } from '../../middleware/auth';
|
|
import { requirePermission } from '../../middleware/rbac';
|
|
import { validate } from '../../middleware/validate';
|
|
import { asyncHandler } from '../../lib/asyncHandler';
|
|
import {
|
|
createStockItemHandler,
|
|
createStockItemSchema,
|
|
getStockItemHandler,
|
|
listStockItemsHandler,
|
|
listStockLevelsHandler,
|
|
updateStockItemHandler,
|
|
updateStockItemSchema,
|
|
} from './stockItems.controller';
|
|
|
|
export const stockItemsRouter = Router();
|
|
|
|
stockItemsRouter.use(requireAuth);
|
|
|
|
stockItemsRouter.get('/', asyncHandler(listStockItemsHandler));
|
|
stockItemsRouter.get('/levels', asyncHandler(listStockLevelsHandler));
|
|
stockItemsRouter.get('/:id', asyncHandler(getStockItemHandler));
|
|
stockItemsRouter.post(
|
|
'/',
|
|
requirePermission('stock.item.manage'),
|
|
validate(createStockItemSchema),
|
|
asyncHandler(createStockItemHandler),
|
|
);
|
|
stockItemsRouter.put(
|
|
'/:id',
|
|
requirePermission('stock.item.manage'),
|
|
validate(updateStockItemSchema),
|
|
asyncHandler(updateStockItemHandler),
|
|
);
|