# api/serializers.py
from rest_framework import serializers
from students.models import Student, ParentGuardian
from academics.models import SchoolClass, Subject, Attendance
from finance.models import FeeStructure, Invoice, Payment
from staff.models import Staff

class StudentSerializer(serializers.ModelSerializer):
    class Meta:
        model = Student
        fields = '__all__'

class StaffSerializer(serializers.ModelSerializer):
    full_name = serializers.SerializerMethodField()
    
    class Meta:
        model = Staff
        fields = ['id', 'employee_id', 'full_name', 'role', 'department', 'phone_number', 'email']
    
    def get_full_name(self, obj):
        return obj.user.get_full_name()

class SchoolClassSerializer(serializers.ModelSerializer):
    class Meta:
        model = SchoolClass
        fields = '__all__'

class InvoiceSerializer(serializers.ModelSerializer):
    student_name = serializers.SerializerMethodField()
    
    class Meta:
        model = Invoice
        fields = '__all__'
    
    def get_student_name(self, obj):
        return str(obj.student)