from rest_framework import serializers
from retailers.models import Recharge, Transaction


class RechargeSerializer(serializers.ModelSerializer):
    operator__name = serializers.CharField(source="operator.name", read_only=True)
    operator__icon = serializers.CharField(source="operator.icon", read_only=True)

    class Meta:
        model = Recharge
        fields = [
            "id",
            "order_id",
            "recharge_id",
            "user_id",
            "mobile",
            "amount",
            "deduction_amount",
            "commission_amount",
            "status",
            "date",
            "source_name",
            "operator",
            "operator__name",
            "operator__icon",
        ]


class TransactionSerializer(serializers.ModelSerializer):
    class Meta:
        model = Transaction
        fields = [
            "id",
            "order_id",
            "tnx_id",
            "operator",
            "source_name",
            "amount",
            "deduction_amount",
            "commission_amount",
        ]
