Skip to content
Extraits de code Groupes Projets
Valider aa234065 rédigé par jordan's avatar jordan
Parcourir les fichiers

[fix] compute state with inner function

parent 938a7fdd
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -87,30 +87,29 @@ class ScopCotisationsIDF(models.Model):
@api.multi
def _compute_state(self):
"""
A line can be in different state :
A line can be in different states :
- No invoice related to a payment / refund
- Too many payments related to one invoice
- Some payments are missing
- The invoice has been paid
"""
def which_state(amount_residual):
if amount_residual > 0:
return 'awaiting_payments'
elif amount_residual < 0:
return 'overpaid'
else:
return 'paid'
for r in self:
if r.type != 'inv':
if not r.invoice_id:
r.state = 'no_invoice'
else:
if r.invoice_id.amount_residual > 0:
r.state = 'awaiting_payments'
elif r.invoice_id.amount_residual < 0:
r.state = 'overpaid'
else:
r.state = 'paid'
else:
if r.amount_residual > 0:
r.state = 'awaiting_payments'
elif r.amount_residual < 0:
r.state = 'overpaid'
r.state = which_state(r.invoice_id.amount_residual)
else:
r.state = 'paid'
r.state = which_state(r.amount_residual)
@api.multi
def _search_state(self, operator, value):
......
......@@ -83,30 +83,28 @@ class ScopInvoiceIDF(models.Model):
@api.multi
def _compute_state(self):
"""
A line can be in different state :
A line can be in different states :
- No invoice related to a payment / refund
- Too many payments related to one invoice
- Some payments are missing
- The invoice has been paid
"""
def which_state(amount_residual):
if amount_residual > 0:
return 'awaiting_payments'
elif amount_residual < 0:
return 'overpaid'
else:
return 'paid'
for r in self:
if r.type != 'inv':
if not r.invoice_id:
r.state = 'no_invoice'
else:
if r.invoice_id.amount_residual > 0:
r.state = 'awaiting_payments'
elif r.invoice_id.amount_residual < 0:
r.state = 'overpaid'
else:
r.state = 'paid'
else:
if r.amount_residual > 0:
r.state = 'awaiting_payments'
elif r.amount_residual < 0:
r.state = 'overpaid'
r.state = which_state(r.invoice_id.amount_residual)
else:
r.state = 'paid'
r.state = which_state(r.amount_residual)
@api.multi
def _search_state(self, operator, value):
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter