import { Router } from "express";
import {
  addCashMovement,
  closeCashRegister,
  closeCashShift,
  deleteCashMovement,
  getTodayCashRegister,
  openCashRegister,
  openCashShift,
  updateCashMovement
} from "../controllers/cashRegisterController.js";
import { requirePermission } from "../middleware/auth.js";

const router = Router();

router.get("/today", getTodayCashRegister);
router.post("/open", requirePermission("cash", "create"), openCashRegister);
router.post("/movements", requirePermission("cash", "create"), addCashMovement);
router.put("/movements/:id", requirePermission("cash", "edit"), updateCashMovement);
router.delete("/movements/:id", requirePermission("cash", "delete"), deleteCashMovement);
router.post("/shifts/open", requirePermission("cash", "create"), openCashShift);
router.post("/shifts/close", requirePermission("cash", "edit"), closeCashShift);
router.post("/close", requirePermission("cash", "edit"), closeCashRegister);

export default router;
