feat: Add and test the finance and task api routes

This commit is contained in:
2025-02-22 22:47:37 +05:30
parent 4897c53259
commit 0a43591739
8 changed files with 2724 additions and 41 deletions
+15 -15
View File
@@ -1,24 +1,24 @@
import express from "express";
import {
createFinanceRecord,
getFinanceRecords,
getFinanceById,
updateFinance,
deleteFinance,
const express = require("express");
const {
addTransaction,
} from "../controllers/financeController.js";
import { checkAuthenticated } from "../Middlewares/authentication.js";
createFinance,
getFinanceByFarm,
deleteTransaction,
getTransactions,
getFinancialSummary,
} = require("../Controllers/finance.controller.js");
const { checkAuthenticated } = require("../Middlewares/authentication.js");
const router = express.Router();
// Routes for finance management
router.post("/", checkAuthenticated, createFinanceRecord); // Create a new finance record
router.get("/", checkAuthenticated, getFinanceRecords); // Get all finance records
router.get("/:financeId", checkAuthenticated, getFinanceById); // Get a finance record by ID
router.put("/:financeId", checkAuthenticated, updateFinance); // Update finance record
router.delete("/:financeId", checkAuthenticated, deleteFinance); // Delete a finance record
router.post("/", checkAuthenticated, createFinance); // Create a new finance record
router.get("/:farmId", checkAuthenticated, getFinanceByFarm); // Get all finance records
router.get("/transactions/:financeId", checkAuthenticated, getTransactions); // Get a finance record by ID
router.get("/summary/:financeId", checkAuthenticated, getFinancialSummary); //
router.delete("/:financeId", checkAuthenticated, deleteTransaction); // Delete a finance record
// Add transactions (Expense/Revenue) to a finance record
router.post("/:financeId/transaction", checkAuthenticated, addTransaction);
export default router;
module.exports = router;
+7 -6
View File
@@ -1,13 +1,14 @@
import express from "express";
import {
const { checkAuthenticated } = require("../Middlewares/authentication.js");
const express = require("express");
const {
createTask,
getTasksByFarm,
getTaskById,
updateTask,
deleteTask,
updateTaskStatus,
} from "../controllers/taskController.js";
const { checkAuthenticated } = require("../Middlewares/authentication.js");
} = require("../Controllers/task.controller.js");
const router = express.Router();
@@ -19,6 +20,6 @@ router.put("/:taskId", checkAuthenticated, updateTask); // Update task details
router.delete("/:taskId", checkAuthenticated, deleteTask); // Delete a task
// Update task status (Pending → Completed)
router.patch("/:taskId/status", protect, updateTaskStatus);
router.patch("/:taskId/status", checkAuthenticated, updateTaskStatus);
export default router;
module.exports = router;