diff --git a/models/scop_cotisation_cg_exo.py b/models/scop_cotisation_cg_exo.py index da3e60f4567f25b7b6fdf0cc94eee4c0de8458a7..dfd9fb06f8ad62f2d88f2917ea67056e64c37cb2 100644 --- a/models/scop_cotisation_cg_exo.py +++ b/models/scop_cotisation_cg_exo.py @@ -493,14 +493,16 @@ class ScopCotisationExo(models.Model): if exo_amount != 0: date_refund = ( - bordereau_id.date_cotisation - if bordereau_id.state == "draft" - else self.date_exo_ok + self.date_exo_ok ) - date_due = bordereau_id.invoice_ids.filtered( + quarter_date_due = bordereau_id.invoice_ids.filtered( lambda i: i.cotiz_quarter == str(quarter) and i.move_type == "out_invoice" )[0].invoice_date_due + if quarter_date_due < self.date_exo_ok: + date_due = self.date_exo_ok + else: + date_due = quarter_date_due # Create refund bordereau_id.invoice_ids.create( {