From 95396325676ba07b51b751fd7d6046b00be9bceb Mon Sep 17 00:00:00 2001 From: benjamin <benjamin@le-filament.com> Date: Wed, 13 Mar 2024 19:45:47 +0100 Subject: [PATCH] [UPD] create exo lines and add FD Indus and UR IDF --- models/scop_cotisation_cg_exo.py | 51 +++++++------------------------- 1 file changed, 11 insertions(+), 40 deletions(-) diff --git a/models/scop_cotisation_cg_exo.py b/models/scop_cotisation_cg_exo.py index 3958a22..cae7c87 100644 --- a/models/scop_cotisation_cg_exo.py +++ b/models/scop_cotisation_cg_exo.py @@ -255,19 +255,7 @@ class ScopCotisationExo(models.Model): def create_lines(self): self.exo_line_ids.unlink() - # Get last bdx for prorate calculation - last_bdx = self.env["scop.bordereau"].search( - [ - ("state", "in", ["validated", "paid"]), - ("partner_id", "=", self.partner_id.id), - ], - order="date_cotisation desc", - limit=1, - ) - if last_bdx: - contrib_type = last_bdx.mapped("invoice_ids.type_contribution_id") - else: - contrib_type = self.partner_id.get_partner_contribution_type() + contrib_type = self.partner_id.get_partner_contribution_type() # if exo is percent => affects percent to each line if self.type_exo == "percent": @@ -284,33 +272,16 @@ class ScopCotisationExo(models.Model): if self.type_exo == "amount": # if various contribution type => affects prorate amount to each line if len(contrib_type) > 1: - if last_bdx: - last_amount = last_bdx.amount_total_cotiz - amount_by_type = last_bdx.get_contribution_type() - - for contrib in contrib_type: - for amount in amount_by_type: - if contrib.id == amount.get("type_contribution_id")[0]: - self.exo_line_ids.create( - { - "exo_id": self.id, - "contribution_id": contrib.id, - "amount": self.amount_quarter - * amount.get("amount_total_signed") - / last_amount, - } - ) - else: - for contrib in contrib_type: - self.exo_line_ids.create( - { - "exo_id": self.id, - "contribution_id": contrib.id, - "amount": round( - self.amount_quarter / len(contrib_type), 2 - ), - } - ) + for contrib in contrib_type: + self.exo_line_ids.create( + { + "exo_id": self.id, + "contribution_id": contrib.id, + "amount": round( + self.amount_quarter / len(contrib_type), 2 + ), + } + ) else: self.exo_line_ids.create( { -- GitLab