diff --git a/wizard/scop_cotisation_cg_regul.py b/wizard/scop_cotisation_cg_regul.py index 614aff59592bbf34c0490b929912757b5ade7ff2..5f0d6d7a1dc2e469d852148e0399481887e93daa 100644 --- a/wizard/scop_cotisation_cg_regul.py +++ b/wizard/scop_cotisation_cg_regul.py @@ -207,6 +207,12 @@ class ScopCotisationRegul(models.TransientModel): if type_invoice: for i in range(0, bordereau_id.nb_quarter): + + if self.date_regul < quarters[i]: + date_due = quarters[i] + else: + date_due = self.date_regul + refund = self.env['account.invoice'].create({ 'partner_id': partner_id.id, 'journal_id': cotiz_type.get(type_cotiz)[2].id, @@ -224,7 +230,7 @@ class ScopCotisationRegul(models.TransientModel): 'liasse_fiscale_id': bordereau_id.liasse_fiscale_id.id, 'type_contribution_id': type_cotiz, 'payment_mode_id': bordereau_id.payment_mode_id.id, - 'date_due': quarters[bordereau_id.nb_quarter-1], + 'date_due': date_due, 'cotiz_quarter': i+1, }) self.env['account.invoice.line'].create({