Ordonnancements par défaut
[auf_django_coda.git] / auf / django / coda / models.py
CommitLineData
bcf7b99e
EMS
1# encoding: utf-8
2
3from django.conf import settings
4from django.db import models
5
d17f2253
EMS
6class ElementManager(models.Manager):
7
8 def __init__(self, niveau):
9 super(ElementManager, self).__init__()
10 self.niveau = niveau
11
12 def get_query_set(self):
13 qs = super(ElementManager, self).get_query_set()
14 return qs.filter(niveau=self.niveau)
15
bcf7b99e
EMS
16
17class Element(models.Model):
18 id = models.CharField(max_length=74, primary_key=True)
19 niveau = models.IntegerField()
d7957f8d 20 code = models.CharField(max_length=72, db_index=True)
bcf7b99e
EMS
21 date_modification = models.DateField()
22 nom = models.CharField(max_length=36)
23
d17f2253
EMS
24 # Managers
25 objects = models.Manager()
26 comptes_comptables = ElementManager(1)
27 tiers_operations = ElementManager(2)
28 projets_postes = ElementManager(3)
29
bcf7b99e
EMS
30 class Meta:
31 managed = False
32 db_table = 'coda_element'
e840f3f8 33 ordering = ['id']
bcf7b99e 34
d17f2253
EMS
35 def __unicode__(self):
36 return self.code
bcf7b99e
EMS
37
38class Ecriture(models.Model):
39 id = models.CharField(max_length=25, primary_key=True)
40 code = models.CharField(max_length=12)
41 numero = models.CharField(max_length=12)
42 date_modification = models.DateField()
43 periode = models.IntegerField()
44 annee = models.IntegerField()
45 date = models.DateField()
46
47 class Meta:
48 managed = False
49 db_table = 'coda_ecriture'
e840f3f8 50 ordering = ['id']
bcf7b99e
EMS
51
52
53class LigneEcriture(models.Model):
54 DEBIT_CREDIT_CHOICES = (
55 ('D', 'Débit'),
56 ('C', 'Crédit'),
57 )
58 ETAT_PAIEMENT_CHOICES = (
59 ('D', 'D-Disponible'),
60 ('A', 'A-Attente'),
61 ('X', 'X-Fermé (non-lettrable)'),
62 ('P', 'P-Payé'),
63 ('O', 'O-Proposé'),
64 )
65
66 id = models.CharField(max_length=36, primary_key=True)
67 ecriture = models.ForeignKey(Ecriture, related_name='doclines')
68 numero = models.IntegerField()
69 date_modification = models.DateField()
d7957f8d
EMS
70 compte_comptable = models.ForeignKey(Element, related_name='+')
71 tiers_operation = models.ForeignKey(Element, related_name='+')
72 projet_poste = models.ForeignKey(Element, related_name='+')
bcf7b99e
EMS
73 description = models.CharField(max_length=36)
74 montant_eur = models.DecimalField(max_digits=17, decimal_places=2)
75 debit_credit = models.CharField(max_length=1, choices=DEBIT_CREDIT_CHOICES)
76 numero_facture = models.CharField(max_length=32)
77 numero_avoir = models.CharField(max_length=32)
78 implantation = models.CharField(max_length=32)
79 salarie = models.CharField(max_length=32)
80 numero_cheque = models.CharField(max_length=32)
81 etat_paiement = models.CharField(max_length=1, choices=ETAT_PAIEMENT_CHOICES)
82
83 class Meta:
84 managed = False
85 db_table = 'coda_ligne_ecriture'
e840f3f8 86 ordering = ['id']