Add supply purchase order workflow

This commit is contained in:
Cauê Faleiros
2026-08-25 11:10:36 -03:00
parent 91f3e5e00c
commit 21d9960145
6 changed files with 223 additions and 4 deletions

View File

@@ -5,13 +5,16 @@ const {
approveReceipt,
consumeLotForProduction,
createFabricPlan,
createPurchaseOrder,
createReceipt,
deleteFabricPlan,
deleteReceipt,
getSupplySummary,
listFabricPlans,
listKnownSuppliers,
listPurchaseOrders,
saveMaterialDetails,
updatePurchaseOrderStatus,
listLots,
listMovements,
listPurchaseNeeds,
@@ -36,6 +39,30 @@ router.get('/supply/suppliers', verifyToken, async (req, res, next) => {
}
});
router.get('/supply/purchase-orders', verifyToken, async (req, res, next) => {
try {
res.json(await listPurchaseOrders());
} catch (error) {
next(error);
}
});
router.post('/supply/purchase-orders', verifyToken, async (req, res, next) => {
try {
res.status(201).json(await createPurchaseOrder(req.body || {}));
} catch (error) {
next(error);
}
});
router.patch('/supply/purchase-orders/:id/status', verifyToken, async (req, res, next) => {
try {
res.json(await updatePurchaseOrderStatus(req.params.id, req.body?.status));
} catch (error) {
next(error);
}
});
router.get('/supply/receipts', verifyToken, async (req, res, next) => {
try {
res.json(await listReceipts());