Skip to content
View Mouctar112's full-sized avatar

Block or report Mouctar112

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Maximum 250 characters. Please don't include any personal information such as legal names or email addresses. Markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
Mouctar112/README.md

from django.db import models from django.contrib.auth.models import User

class Client(models.Model): nom = models.CharField(max_length=255) email = models.EmailField(unique=True) telephone = models.CharField(max_length=20, blank=True, null=True) adresse = models.TextField(blank=True, null=True) created_at = models.DateTimeField(auto_now_add=True)

def __str__(self):
    return self.nom

class Produit(models.Model): nom = models.CharField(max_length=255) description = models.TextField(blank=True, null=True) prix = models.DecimalField(max_digits=10, decimal_places=2) stock = models.IntegerField(default=0) created_at = models.DateTimeField(auto_now_add=True)

def __str__(self):
    return self.nom

class Facture(models.Model): client = models.ForeignKey(Client, on_delete=models.CASCADE) date = models.DateField(auto_now_add=True) total = models.DecimalField(max_digits=10, decimal_places=2) paye = models.BooleanField(default=False) created_at = models.DateTimeField(auto_now_add=True)

def __str__(self):
    return f"Facture {self.id} - {self.client.nom}"

class LigneFacture(models.Model): facture = models.ForeignKey(Facture, on_delete=models.CASCADE, related_name='lignes') produit = models.ForeignKey(Produit, on_delete=models.CASCADE) quantite = models.IntegerField() sous_total = models.DecimalField(max_digits=10, decimal_places=2)

def save(self, *args, **kwargs):
    self.sous_total = self.produit.prix * self.quantite
    super().save(*args, **kwargs)

def __str__(self):
    return f"{self.quantite} x {self.produit.nom} ({self.sous_total}€)"

Popular repositories Loading

  1. Comptabilit- Comptabilit- Public

  2. Mouctar112 Mouctar112 Public

    Config files for my GitHub profile.

  3. webcontainer-core webcontainer-core Public

    Forked from stackblitz/webcontainer-core

    Dev environments. In your web app.

  4. sb1-awccqcu6 sb1-awccqcu6 Public

    Created with StackBlitz ⚡️

    TypeScript

  5. sb1-vcafzxs7 sb1-vcafzxs7 Public

    Created with StackBlitz ⚡️

  6. sb1-qz7mtngk-MOUTEST sb1-qz7mtngk-MOUTEST Public

    Created with StackBlitz ⚡️

    TypeScript