from django.db import models
from django.utils.translation import gettext_lazy as _

class Item(models.Model):
    class Status(models.TextChoices):
        TODO = 'TODO', _('Todo')
        IN_PROGRESS = 'IN_PROGRESS', _('In Progress')
        DONE = 'DONE', _('Done')

    title = models.CharField(max_length=255)
    description = models.TextField(blank=True)
    status = models.CharField(
        max_length=20,
        choices=Status.choices,
        default=Status.TODO,
    )
    order = models.IntegerField(default=0)
    charge_number = models.ForeignKey('financial.ChargeNumber', on_delete=models.SET_NULL, null=True, blank=True, related_name='tickets')
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        ordering = ['status', 'order', '-created_at']

    def __str__(self):
        return self.title
