models.py 2.09 KB
Newer Older
Claire Zuliani's avatar
Claire Zuliani committed
1 2 3 4
from django.conf import settings
from django.db import models
import datetime

5
class ClientInvoice(models.Model):
Claire Zuliani's avatar
Claire Zuliani committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
    # customer = models.ForeignKey(User, on_delete=models.CASCADE)
    # provider = models.ForeignKey(User, on_delete=models.CASCADE)
    STATES = (
      ('pending', 'en attente'),
      ('paid', 'réglée')
    )
    identifier = models.CharField(max_length=255)
    title = models.CharField(max_length=255)
    # state = models.CharField(max_length=1, choices=STATES, default = 'pending')
    htAmount = models.DecimalField(max_digits=11, decimal_places=2)
    tvaRate = models.DecimalField(max_digits=4, decimal_places=2)
    creationDate = models.DateField(default = datetime.date.today)
    modificationDate = models.DateField(default = datetime.date.today)

    class Meta:
        permissions = (
            ('view_invoice', 'Read'),
            ('control_invoice', 'Control'),
        )

    def __str__(self):
        return '{} ({})'.format(self.identifier, self.title)
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54

class FreelanceInvoice(models.Model):
    # customer = models.ForeignKey(User, on_delete=models.CASCADE)
    # provider = models.ForeignKey(User, on_delete=models.CASCADE)
    STATES = (
      ('pending', 'en attente'),
      ('paid', 'réglée')
    )
    freelanceFullname = models.CharField(max_length=255)
    identifier = models.CharField(max_length=255)
    title = models.CharField(max_length=255)
    # state = models.CharField(max_length=1, choices=STATES, default = 'pending')
    htAmount = models.DecimalField(max_digits=11, decimal_places=2)
    tvaRate = models.DecimalField(max_digits=4, decimal_places=2)
    creationDate = models.DateField(default = datetime.date.today)
    modificationDate = models.DateField(default = datetime.date.today)
    invoicingDate = models.DateField(default = datetime.date.today)
    uploadUrl = models.CharField(max_length=255)

    class Meta:
        permissions = (
            ('view_freelance_invoice', 'Read'),
            ('control_freelance_invoice', 'Control'),
        )

    def __str__(self):
        return '{} ({} / {})'.format(self.freelanceFullname, self.identifier, self.title)