OwlCyberSecurity - MANAGER
Edit File: models.py
from django.db import models import datetime # Create your models here. class produit(models.Model): class p_categorie(models.TextChoices): VENOISERIE = 'Vénoiserie' PATISSERIE = "Patisserie" BS = 'Boisson chaude' BF = 'Boisson fraiche' SP = 'Suplément' SALE = 'Salé' DIVERS = 'Divers' nom = models.CharField(max_length=30,null=True) prix = models.FloatField(max_length=10,null=True) categorie = models.CharField(max_length=30, choices=p_categorie.choices, default=p_categorie.PATISSERIE, ) quantite = models.FloatField(max_length=100,null=True) vendu = models.FloatField(max_length=10,null=True,default=0) date_dernier_ajout = models.DateField(default=datetime.date.today) minimum = models.FloatField(max_length=100,null=True) class ligne_commande(models.Model): produit = models.ForeignKey(produit,on_delete=models.CASCADE) quantite = models.IntegerField(default=1) def price(self): return self.produit.prix*self.quantite class vente(models.Model): commandes = models.ManyToManyField(ligne_commande) date_commande=models.DateField(default=datetime.date.today,) tt_prix = models.FloatField(default=0) def total_price(self): tt_price=0.0 for lc in self.commandes.all(): tt_price += lc.price() return tt_price """ def __str__(self) -> str: return self.client.client_firstname +" "+ self.client.client_familyname + " "+ "Cmd({})".format(self.id) """ class element(models.Model): class e_categorie(models.TextChoices): VENOISERIE = 'Vénoiserie' PATISSERIE = "Patisserie" SALE = 'Salé' DIVERS = 'Divers' nom = models.CharField(max_length=30,null=True) prix_u = models.FloatField(max_length=10,null=True) prix_tt= models.FloatField(max_length=10,null=True) categorie = models.CharField(max_length=30, choices=e_categorie.choices, default=e_categorie.DIVERS, ) quantite = models.FloatField(max_length=10,null=True) utilise = models.FloatField(max_length=10,null=True,default=0) date_dernier_ajout = models.DateField(default=datetime.date.today) minimum = models.FloatField(max_length=100,null=True) class dépence_gain(models.Model): class types(models.TextChoices): DEPENCE = 'Dépence' GAIN = 'Gain' type = models.CharField(max_length=30,choices=types.choices,default=types.DEPENCE) date = models.DateField(default=datetime.date.today) montant = models.FloatField() motif = models.CharField(max_length=300) class product_stat(models.Model): product=models.ForeignKey(produit,on_delete=models.CASCADE) date = models.DateField(default=datetime.date.today) quantity = models.IntegerField(default=0) def set_quantity(self): self.quantity=self.product.product_quantity class notif(models.Model): class etats(models.TextChoices): LU = 'Lu' NONLU = 'Non lu' content = models.CharField(max_length=300) date = models.DateField(default=datetime.date.today) etat = models.CharField(max_length=300,choices=etats.choices,default=etats.NONLU)