const express = require('express');
const router = express.Router();
const ctrl = require('../controllers/purchaseBatchController');
const { createRequirePage } = require('../../../shared/middleware/pagePermission');
const { getDb } = require('../dbPool');
const requirePage = createRequirePage(getDb);

router.get('/', requirePage('factory_purchases'), ctrl.getAll);
router.get('/:id', requirePage('factory_purchases'), ctrl.getById);
router.post('/', requirePage('factory_purchases'), ctrl.create);
router.put('/:id', requirePage('factory_purchases'), ctrl.update);
router.delete('/:id', requirePage('factory_purchases'), ctrl.delete);
router.post('/:id/purchase', requirePage('factory_purchases'), ctrl.purchase);
router.put('/:id/receive', requirePage('factory_purchases'), ctrl.receive);

module.exports = router;
