houtmarkt-jeremy/markt/models.py
2020-05-24 12:00:10 -03:00

103 lines
3.7 KiB
Python

from django.db import models
# Used to generate URLs by reversing the URL patterns
from django.urls import reverse
# Create your models here.
class Houtsoort(models.Model):
Hout_ID = models.AutoField(primary_key=True)
Houtsoort_naam = models.CharField(max_length=255, help_text='Houtsoort')
def get_absolute_url(self):
"""Returns the url to access a particular instance of the model."""
return reverse('model-detail-view', args=[str(self.Hout_ID)])
def __str__(self):
"""String for representing the Model object."""
return self.Houtsoort_naam
class Formaat(models.Model):
Format_ID = models.AutoField(primary_key=True)
Formaat = models.CharField(max_length=255, help_text='Formaat (vb 2x4)')
Lengte = models.FloatField()
def get_absolute_url(self):
"""Returns the url to access a particular instance of the model."""
return reverse('model-detail-view', args=[str(self.Format_ID)])
def __str__(self):
"""String for representing the Model object."""
return self.Formaat
class Houtmarkt(models.Model):
Houtmarkt_ID = models.AutoField(primary_key=True)
Houtmarkt_naam = models.CharField(
max_length=255, help_text='Houtmarkt naam')
Houtmarkt_tel = models.IntegerField()
Houtmarkt_addr = models.CharField(max_length=255)
Houtmarkt_type = models.BooleanField()
def get_absolute_url(self):
"""Returns the url to access a particular instance of the model."""
return reverse('model-detail-view', args=[str(self.Houtmarkt_ID)])
def __str__(self):
"""String for representing the Model object."""
return self.Houtmarkt_naam
class Voorraad(models.Model):
Voorraad_ID = models.AutoField(primary_key=True)
Houtmarkt_ID = models.ForeignKey("Houtmarkt", on_delete=models.CASCADE)
Hout_ID = models.ForeignKey("Houtsoort", on_delete=models.CASCADE)
Format_ID = models.ForeignKey("Formaat", on_delete=models.CASCADE)
prijs = models.FloatField()
Voorraad_Amount = models.IntegerField()
def get_absolute_url(self):
"""Returns the url to access a particular instance of the model."""
return reverse('model-detail-view', args=[str(self.Voorraad_ID)])
def __str__(self):
"""String for representing the Model object."""
return self.Voorraad_ID
class Klant(models.Model):
Klant_ID = models.AutoField(primary_key=True)
Klant_naam = models.CharField(max_length=255, help_text='Klant naam')
Klant_tel = models.CharField(
max_length=255, help_text='Klant telefoon nummer')
Klant_Addr = models.CharField(max_length=255, help_text='Klant Adres')
Is_Houtmarkt = models.BooleanField()
def get_absolute_url(self):
"""Returns the url to access a particular instance of the model."""
return reverse('model-detail-view', args=[str(self.Klant_ID)])
def __str__(self):
"""String for representing the Model object."""
return self.Klant_naam
class Factuur(models.Model):
Factuur_ID = models.AutoField(primary_key=True)
Voorraad_ID = models.ForeignKey("Voorraad", on_delete=models.CASCADE)
Klant_ID = models.ForeignKey("Klant", on_delete=models.CASCADE)
Houtmarkt_ID = models.ForeignKey("Houtmarkt", on_delete=models.CASCADE)
Korting_percent = models.FloatField()
AMT_Sold = models.IntegerField()
Subtotal = models.FloatField()
total = models.FloatField()
def get_absolute_url(self):
"""Returns the url to access a particular instance of the model."""
return reverse('model-detail-view', args=[str(self.Factuur_ID)])
def __str__(self):
"""String for representing the Model object."""
return self.Factuur_ID