From 33a6e5cb02189b7621a279c32c12b5c3d83ba680 Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Thu, 9 Nov 2017 15:57:46 -0500 Subject: Show number of attachments, and color code issues with loads. Prevent invoice generation on zero amounts and no attachments. Add a way for superusers to edit invoices. Add a field to invoices for a payment identifier. E.g. "Check #1234" --- app/dispatch/models.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app/dispatch/models.py') diff --git a/app/dispatch/models.py b/app/dispatch/models.py index fe0cdb3..ef59fe4 100644 --- a/app/dispatch/models.py +++ b/app/dispatch/models.py @@ -40,6 +40,13 @@ class Load(models.Model): def get_absolute_url(self): return "/loads/view/%i" % self.id + def can_invoice(self): + # Prevent 0 and $1 invoices as well as loads w/o attachments + if self.amount >= 2 and len(self.paperwork_set.all()) >= 1: + return True + else: + return False + class Paperwork(models.Model): load = models.ForeignKey(Load, on_delete=models.CASCADE) @@ -96,6 +103,7 @@ class Invoice(models.Model): invoice_date = models.DateField() due_date = models.DateField() paid = models.BooleanField(default=False) + payment_identifer = models.CharField(default="", max_length=256) def __str__(self): return "Invoice for {} by {} for ${}".format( -- cgit v1.2.3