35611-vm/core/models.py
Flatlogic Bot cc56417940 v1
2025-11-10 06:29:01 +00:00

29 lines
1.0 KiB
Python

from django.db import models
class Vendor(models.Model):
name = models.CharField(max_length=255)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):
return self.name
class Invoice(models.Model):
STATUS_CHOICES = [
('processed', 'Processed'),
('pending', 'Pending'),
('paid', 'Paid'),
('overdue', 'Overdue'),
]
vendor = models.ForeignKey(Vendor, on_delete=models.CASCADE, related_name='invoices')
invoice_number = models.CharField(max_length=255, unique=True)
amount = models.DecimalField(max_digits=10, decimal_places=2)
status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='pending')
file_path = models.CharField(max_length=1024)
due_date = models.DateField()
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):
return f"Invoice {self.invoice_number} from {self.vendor.name}"