from rest_framework import serializers
from .models import Bill,Chargeitem


class BillSerializer(serializers.ModelSerializer):
    class Meta:
        model = Bill
        fields = '__all__'
class ChargeitemSerializer(serializers.ModelSerializer):
    class Meta:
        model = Chargeitem
        fields = '__all__'
class BillsSerializer(serializers.ModelSerializer):
    number_=ChargeitemSerializer(source='chargeitem_number')
    class Meta:
        model = Bill
        fields = '__all__'
    def setup_eager_loading(queryset):
        """ Perform necessary eager loading of data. """
        # queryset = queryset.select_related('type','economy_class')
        queryset = queryset.prefetch_related('chargeitem_bill',)
        return queryset
    
   