46 lines
1.7 KiB
Python
46 lines
1.7 KiB
Python
from django.db import models
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
class Department(models.Model):
|
|
name = models.CharField(max_length=100)
|
|
code = models.CharField(max_length=10, unique=True)
|
|
description = models.TextField(blank=True)
|
|
|
|
def __cl__(self):
|
|
return self.name
|
|
|
|
class ProcurementProposal(models.Model):
|
|
STATUS_CHOICES = [
|
|
('draft', 'Draft'),
|
|
('submitted', 'Submitted'),
|
|
('under_review', 'Under Review'),
|
|
('approved', 'Approved'),
|
|
('rejected', 'Rejected'),
|
|
]
|
|
|
|
proposal_number = models.CharField(max_length=50, unique=True)
|
|
title = models.CharField(max_length=255)
|
|
description = models.TextField()
|
|
estimated_cost = models.DecimalField(max_digits=15, decimal_places=2)
|
|
department = models.ForeignKey(Department, on_delete=models.CASCADE)
|
|
status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='draft')
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
def __str__(self):
|
|
return f"{self.proposal_number} - {self.title}"
|
|
|
|
class Document(models.Model):
|
|
TYPE_CHOICES = [
|
|
('M7', 'Form M-7 (Proposal)'),
|
|
('M16', 'Form M-16 (Payment)'),
|
|
('S16', 'Form S-16 (Invoice)'),
|
|
]
|
|
doc_type = models.CharField(max_length=10, choices=TYPE_CHOICES)
|
|
proposal = models.ForeignKey(ProcurementProposal, on_delete=models.CASCADE, related_name='documents')
|
|
file_path = models.CharField(max_length=255, blank=True) # Cloud path simulation
|
|
metadata = models.JSONField(default=dict)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
|
|
def __str__(self):
|
|
return f"{self.doc_type} for {self.proposal.proposal_number}" |