import Student from "../models/Student.js"
import Payment from "../models/Payment.js";

export const createPayment = async(req,res) => {
    try{
   const payment = await Payment.create(req.body);
   res.status(201).json(payment);
    }catch(error){
   res.status(500).json({message:error.message});
    }
};

export const getPayment = async(req,res) => {
    try{
   const payment = await Payment.find()
   .populate('student')
   .populate('fees')
   res.status(200).json(payment);
    }catch(error){
        
   res.status(500).json({message:error.message});
    }
};

export const updatePayment = async(req,res) => {
    try{
   const payment = await Payment.findByIdAndUpdate(req.body);
   res.status(201).json(payment);
    }catch(error){
   res.status(500).json({message:error.message});
    }
};

export const deletePayment = async(req,res) => {
    try{
        const payment = await Payment.findByIdAndDelete(req.body);
        res.status(200).json({message:"payment deleted succussfully"});
    }catch(error){

        res.status(500).json({message:error.message});
    }
};