From b0166cca8322da8335f075f5315786b07e00be0a Mon Sep 17 00:00:00 2001 From: benjamin <benjamin@le-filament.com> Date: Tue, 14 Feb 2023 18:48:24 +0100 Subject: [PATCH] [update] refund date & date due --- models/scop_cotisation_cg_exo.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/models/scop_cotisation_cg_exo.py b/models/scop_cotisation_cg_exo.py index da3e60f..dfd9fb0 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( { -- GitLab