from rest_framework import serializers
from retailers.models import Notification, Retailer, Recharge, Transaction, Wallet


class NotificationSerializer(serializers.ModelSerializer):
    class Meta:
        model = Notification
        fields = ["id", "title", "message", "is_sean","created_on"]


class RetailerSerializer(serializers.ModelSerializer):
    class Meta:
        model = Retailer
        fields = ["id", "name", "mobile", "email", "address", "password", "mpin", "is_active", "created_on"]


class RechargeSerializer(serializers.ModelSerializer):
    # business = BusinessSerializer(read_only=True)
    operator_name = serializers.ReadOnlyField(source="operator.name")
    retailer_name = serializers.ReadOnlyField(source="retailer.name")

    class Meta:
        model = Recharge
        fields = [
            "id",
            "order_id",
            "recharge_id",
            "mrobotics",
            "source",
            "source_name",
            "retailer",
            "retailer_name",
            "operator",
            "operator_name",
            "operator_no",
            "amount",
            "deduction_amount",
            "commission_amount",
            "date",
            "is_active",
                        
        ]


class SaveTransactionSerializer(serializers.ModelSerializer):
    # business = BusinessSerializer(read_only=True)
    class Meta:
        model = Transaction
        fields = [
            "id",
            "order_id",
            "tnx_id",
            "status",
            "source",
            "source_name",
            "retailer",
            "operator",
            "transaction_type",
            "amount",
            "is_active",
        ]


class TransactionSerializer(serializers.ModelSerializer):
    # business = BusinessSerializer(read_only=True)
    class Meta:
        model = Transaction
        fields = [
            "id",
            "order_id",
            "tnx_id",
            "source",
            "source_name",
            "retailer",
            "operator",
            "transaction_type",
            "amount",
            "deduction_amount",
            "commission_amount",
            "cumulative_amount",
            "date",
            "status",
            "is_active",
        ]


class WalletSerializer(serializers.ModelSerializer):
    retailer_name = serializers.ReadOnlyField(source="retailer.name")

    class Meta:
        model = Wallet
        fields = ["id", "retailer", "retailer_name", "amount", "is_active"]
