from django.db import models

class Domain(models.Model):
    name = models.CharField(max_length=255)
    cycle = models.IntegerField(choices=[(1, 'Cycle 1'), (2, 'Cycle 2'), (3, 'Cycle 3'), (4, 'Cycle 4')])

    def __str__(self):
        return f"{self.name} (Cycle {self.cycle})"

class Category(models.Model):
    name = models.CharField(max_length=255)
    domain = models.ForeignKey(Domain, on_delete=models.CASCADE, related_name='categories')

    def __str__(self):
        return self.name

class PaymentPlanType(models.Model):
    code = models.CharField(max_length=50, unique=True)
    label = models.CharField(max_length=255)

    def __str__(self):
        return self.label

class PaymentModeType(models.Model):
    code = models.CharField(max_length=50, unique=True)
    label = models.CharField(max_length=255)

    def __str__(self):
        return self.label

class Cycle(models.Model):
    number = models.IntegerField(unique=True)
    label = models.CharField(max_length=50)

    def __str__(self):
        return f"Cycle {self.number} - {self.label}"

class Level(models.Model):
    name = models.CharField(max_length=50)
    cycle = models.ForeignKey(Cycle, on_delete=models.CASCADE, related_name='levels')

    def __str__(self):
        return self.name