models.py 1.3 KB

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