40 lines
1.7 KiB
Python
40 lines
1.7 KiB
Python
import uuid
|
|
from django.conf import settings
|
|
from django.db import models
|
|
|
|
|
|
class ProcessingBatch(models.Model):
|
|
class Grade(models.TextChoices):
|
|
A = "A", "Grade A"
|
|
B = "B", "Grade B"
|
|
C = "C", "Grade C"
|
|
|
|
class Status(models.TextChoices):
|
|
HARVESTED = "harvested", "Harvested"
|
|
PROCESSING = "processing", "Processing"
|
|
QC_PASS = "qc_pass", "QC Pass"
|
|
QC_FAIL = "qc_fail", "QC Fail"
|
|
READY_TO_SHIP = "ready_to_ship", "Ready to Ship"
|
|
IN_TRANSIT = "in_transit", "In Transit"
|
|
AT_UK_PORT = "at_uk_port", "At UK Port"
|
|
CUSTOMS = "customs", "Customs"
|
|
DELIVERED = "delivered", "Delivered"
|
|
|
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
|
batch_reference = models.CharField(max_length=50, unique=True)
|
|
harvest_date = models.DateField(null=True, blank=True)
|
|
weight_kg = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True)
|
|
grade = models.CharField(max_length=5, choices=Grade.choices, null=True, blank=True)
|
|
status = models.CharField(max_length=20, choices=Status.choices, default=Status.HARVESTED)
|
|
origin_facility = models.CharField(max_length=255, default="ASI - Katsina State, Nigeria")
|
|
notes = models.TextField(blank=True)
|
|
created_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, null=True, related_name="batches_created")
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
class Meta:
|
|
db_table = "processing_batches"
|
|
ordering = ["-created_at"]
|
|
|
|
def __str__(self):
|
|
return self.batch_reference
|