models.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # -*- coding: utf-8 -*-
  2. from django.db import models
  3. class Invoice(models.Model):
  4. INVOICES_STATUS_CHOICES = (
  5. ('open', 'A payer'),
  6. ('closed', 'Reglée'),
  7. ('trouble', 'Litige')
  8. )
  9. status = models.CharField(max_length=50, choices=INVOICES_STATUS_CHOICES,
  10. default='open')
  11. amount = models.DecimalField(max_digits=5, decimal_places=2)
  12. date = models.DateField(auto_now_add=True, null=True)
  13. period_from = models.DateField(auto_now_add=False, null=True)
  14. period_to = models.DateField(auto_now_add=False, null=True)
  15. date_due = models.DateField(auto_now_add=False, null=True)
  16. class InvoiceDetail(models.Model):
  17. label = models.CharField(max_length=100)
  18. amount = models.DecimalField(max_digits=5, decimal_places=2)
  19. quantity = models.IntegerField(null=True)
  20. tax = models.IntegerField(null=True)
  21. invoice = models.ForeignKey(Invoice)
  22. def __unicode__(self):
  23. return self.label
  24. class Payment(models.Model):
  25. payment_means = models.CharField(max_length=100, null=True)
  26. amount = models.DecimalField(max_digits=7, decimal_places=2, null=True)
  27. date = models.DateField(auto_now_add=True)
  28. invoce = models.ForeignKey(Invoice)