Added "ProjectRun" model

This commit is contained in:
Oliver Walters 2017-03-29 22:44:59 +11:00
parent 2b998a1931
commit aafa8781d7
2 changed files with 33 additions and 14 deletions

View File

@ -48,9 +48,9 @@ class ProjectPart(models.Model):
part = models.ForeignKey(Part, on_delete=models.CASCADE)
project = models.ForeignKey(Project, on_delete=models.CASCADE)
quantity = models.IntegerField(default=1)
quantity = models.PositiveIntegerField(default=1)
overage = models.FloatField(default=0)
overage_type = models.IntegerField(
overage_type = models.PositiveIntegerField(
default=1,
choices=[
(OVERAGE_PERCENT, "Percent"),
@ -61,3 +61,17 @@ class ProjectPart(models.Model):
return "{quan} x {name}".format(
name=self.part.name,
quan=self.quantity)
class ProjectRun(models.Model):
""" A single run of a particular project.
Tracks the number of 'units' made in the project.
Provides functionality to update stock,
based on both:
a) Parts used (project inputs)
b) Parts produced (project outputs)
"""
project = models.ForeignKey(Project, on_delete=models.CASCADE)
quantity = models.PositiveIntegerField(default=1)
run_date = models.DateField(auto_now_add=True)

View File

@ -44,6 +44,11 @@ class SupplierPart(models.Model):
URL = models.URLField(blank=True)
description = models.CharField(max_length=250, blank=True)
single_price = models.DecimalField(max_digits=10, decimal_places=3)
# packaging that the part is supplied in, e.g. "Reel"
packaging = models.CharField(max_length=50, blank=True)
def __str__(self):
return "{mpn} - {supplier}".format(
mpn=self.MPN,
@ -58,7 +63,7 @@ class SupplierPriceBreak(models.Model):
part = models.ForeignKey(SupplierPart,
on_delete=models.CASCADE)
quantity = models.IntegerField()
quantity = models.PositiveIntegerField()
cost = models.DecimalField(max_digits=10, decimal_places=3)
currency = models.CharField(max_length=10,
blank=True)