diff --git a/models/res_company.py b/models/res_company.py index 3bdf8eb16fb739441fefccd2710e3e2cc1d85f2b..900d2b074063bf6d4769a8139be1af022c45f203 100644 --- a/models/res_company.py +++ b/models/res_company.py @@ -63,3 +63,13 @@ class ScopCotisationCGCompany(models.Model): string="Journal UR Med", domain="[('type', '=', 'sale')]", ) + contribution_idf_id = fields.Many2one( + comodel_name="product.product", + string="Article de cotisation UR IDF", + domain="[('sale_ok', '=', True), ('company_id', '=', company_id)]", + ) + journal_ur_idf_id = fields.Many2one( + comodel_name="account.journal", + string="Journal UR IDF", + domain="[('type', '=', 'sale')]", + ) diff --git a/models/res_config_settings.py b/models/res_config_settings.py index 75f2bd80ca1e1e79725d00e3f7a61b91dbdb0c4f..895b3dbf3e629e62719929c0690dfa74feb63ec1 100644 --- a/models/res_config_settings.py +++ b/models/res_config_settings.py @@ -89,6 +89,20 @@ class CotisationsConfigSettings(models.TransientModel): string="Journal UR Med", domain="[('type', '=', 'sale')]", ) + contribution_idf_id = fields.Many2one( + comodel_name="product.product", + related="company_id.contribution_idf_id", + readonly=False, + string="Article de cotisation UR IDF", + domain="[('sale_ok', '=', True), ('company_id', '=', company_id)]", + ) + journal_ur_idf_id = fields.Many2one( + comodel_name="account.journal", + related="company_id.journal_ur_idf_id", + readonly=False, + string="Journal UR IDF", + domain="[('type', '=', 'sale')]", + ) @api.onchange("is_contribution") def _onchange_is_contribution_cg(self): diff --git a/models/scop_bordereau_cg.py b/models/scop_bordereau_cg.py index 5944e68b1585da0e1d05efa7329c93eaabb064e0..f4297fa61ff5f355baba70d858aeb58fd7bda06c 100644 --- a/models/scop_bordereau_cg.py +++ b/models/scop_bordereau_cg.py @@ -892,6 +892,24 @@ class Bordereau(models.Model): journal_id=journal_ur_med_id, ) + # Invoice cotiz UR Ile De France + # + ur_idf = self.env.ref("cgscop_partner.riga_14231").id + if partner.ur_id.id == ur_idf: + product_idf_id = self.company_id.contribution_idf_id + journal_idf_id = self.company_id.journal_ur_idf_id + + if liasse: + amount_idf = liasse.contribution_idf + else: + amount_idf = 840 + self.create_contribution( + product=product_idf_id, + type_contribution=type_cotisation_ur, + amount=amount_idf, + journal_id=journal_idf_id, + ) + def create_contribution( self, product, @@ -1046,10 +1064,12 @@ class Bordereau(models.Model): # CREATE REGUL ur_hdf = self.env.ref("cgscop_partner.riga_14232").id ur_med = self.env.ref("cgscop_partner.riga_14243").id + ur_idf = self.env.ref("cgscop_partner.riga_14231").id type_cotisation_cg = self.env.ref("cgscop_partner.riga_14397").id type_cotisation_ur = self.env.ref("cgscop_partner.riga_14399").id type_cotisation_fede_com = self.env.ref("cgscop_partner.riga_14398").id type_cotisation_fede_cae = self.env.ref("cgscop_partner.cotiz_fede_cae").id + type_cotisation_fede_indus = self.env.ref("cgscop_partner.cotiz_fede_indus").id # Cotisations présentes sur le bordereau contribs = bordereau_id.invoice_ids.read_group( @@ -1088,6 +1108,17 @@ class Bordereau(models.Model): } ) + if ( + partner_id.is_federation_indus + and type_cotisation_fede_indus not in contrib_type + ): + contribs.append( + { + "type_contribution_id": (type_cotisation_fede_indus,), + "amount_total_signed": 0, + } + ) + if partner_id.cae and type_cotisation_fede_cae not in contrib_type: contribs.append( { @@ -1103,6 +1134,12 @@ class Bordereau(models.Model): ) product_ur = self.env.company.contribution_hdf_id journal_ur = self.env.user.company_id.journal_ur_hdf_id + elif partner_id.ur_id.id == ur_idf: + amount_ur = ( + liasse_fiscale_new_id.contribution_idf if liasse_fiscale_new_id else 840 + ) + product_ur = self.env.company.contribution_idf_id + journal_ur = self.env.user.company_id.journal_ur_idf_id else: # ur = ur_med amount_ur = liasse_fiscale_new_id.contribution_med product_ur = self.env.company.contribution_med_id diff --git a/models/scop_cotisation_cg.py b/models/scop_cotisation_cg.py index d485fd0bde213f94ef7ac61acbd830ba98883a7c..1ec5959ac3114442dfe348d12b7a247799bd458f 100644 --- a/models/scop_cotisation_cg.py +++ b/models/scop_cotisation_cg.py @@ -536,6 +536,7 @@ class ScopCotisation(models.Model): product_indus_id = self.company_id.contribution_fede_indus_id product_hdf_id = self.company_id.contribution_hdf_id product_med_id = self.company_id.contribution_med_id + product_idf_id = self.company_id.contribution_idf_id # List of members members = self.get_members() @@ -566,7 +567,9 @@ class ScopCotisation(models.Model): # Init variables datas = [] - total_cg = total_hdf = total_com = total_med = total_cae = total_indus = 0 + total_cg = ( + total_hdf + ) = total_idf = total_com = total_med = total_cae = total_indus = 0 count_member = 0 for m in members: @@ -683,6 +686,30 @@ class ScopCotisation(models.Model): datas.append(datas_contrib_med) total_med += contrib_med + # Ajout ligne UR IDF + ur_idf = self.env.ref("cgscop_partner.riga_14231") + if m.ur_id == ur_idf: + datas_contrib_idf = datas_contrib.copy() + # Calcul cotisation + contrib_idf = ( + self.round_to_closest_multiple(liasse.contribution_idf, 4) + if liasse + else 40 + ) + # Calcul cotisation N-1 + contribution_last_year = sum( + line_ids.filtered( + lambda l: l.product_id == product_idf_id + ).mapped( + lambda c: c.price_total if c.balance > 0 else -c.price_total + ) + ) + datas_contrib_idf[4] = "Cotisation UR IDF Centre Val de Loire" + datas_contrib_idf[5] = contrib_idf + datas_contrib_idf[6] = contribution_last_year + datas.append(datas_contrib_idf) + total_idf += contrib_idf + # Ajout ligne Fédération Com if m.is_federation_com: datas_contrib_com = datas_contrib.copy() diff --git a/models/scop_cotisation_simulation.py b/models/scop_cotisation_simulation.py index afd4bdee7513cc0b9e372e7bd88fc3de990a6dc2..003bdb63d625b8bfbfab35cb5f8e029084c4a912 100644 --- a/models/scop_cotisation_simulation.py +++ b/models/scop_cotisation_simulation.py @@ -29,6 +29,7 @@ class ScopCotisation(models.Model): total_cg = fields.Float("Total CG Scop") total_hdf = fields.Float("Total UR HDF") total_med = fields.Float("Total UR Med") + total_idf = fields.Float("Total UR IDF") total_com = fields.Float("Total Fédération Com") total_cae = fields.Float("Total Fédération CAE") total_indus = fields.Float("Total Fédération Industrie") diff --git a/models/scop_liasse_fiscale.py b/models/scop_liasse_fiscale.py index 53b5881089d082e0525b4eb423b8ff626282b576..18663823e22e70b4b078cb3c867d45f30d70588e 100644 --- a/models/scop_liasse_fiscale.py +++ b/models/scop_liasse_fiscale.py @@ -36,6 +36,11 @@ class ScopLiasseFiscale(models.Model): compute="_compute_contribution_med", store=True, ) + contribution_idf = fields.Float( + string="Cotisation UR IdF, Val de Loire, Dom Tom", + compute="_compute_contribution_idf", + store=True, + ) contribution_com = fields.Float( string="Cotisation Fédération Com", compute="_compute_contribution_com", @@ -320,6 +325,27 @@ class ScopLiasseFiscale(models.Model): if liasse.is_federation_indus: liasse.contribution_indus = 100 + @api.depends("contribution_cg") + def _compute_contribution_idf(self): + """ + Calcule la cotisation de l'UR IDF pour 1 liasse : + - Taux d’appel : 1/3 de la cotisation CG + - Plancher : 840 + - Plafond : 12000 + + @return float : cotisation + """ + ur_idf = self.env.ref("cgscop_partner.riga_14231") + for liasse in self: + if liasse.partner_id.ur_id == ur_idf: + contribution_idf = round(liasse.contribution_cg / 3, 2) + if contribution_idf < 840: + liasse.contribution_idf = 840 + elif contribution_idf > 12000: + liasse.contribution_idf = 12000 + else: + liasse.contribution_idf = contribution_idf + # ------------------------------------------------------ # Business Function # ------------------------------------------------------ diff --git a/views/res_config_settings.xml b/views/res_config_settings.xml index 36d451860e8195752b056fe1f7542548030ed3fb..a40d549c66b84233f2bf7daa9139ea624b05118a 100644 --- a/views/res_config_settings.xml +++ b/views/res_config_settings.xml @@ -171,6 +171,29 @@ attrs="{'required': [('is_contribution_cg', '=', True)]}" /> </div> + <!-- Cotisation UR IDF --> + <div + class="o_setting_right_pane" + attrs="{'invisible': [('is_contribution_cg', '=', False)]}" + > + <div><label for="contribution_idf_id" /></div> + <field + name="contribution_idf_id" + options="{'no_open': True, 'no_create': True}" + attrs="{'required': [('is_contribution_cg', '=', True)]}" + /> + </div> + <div + class="o_setting_right_pane" + attrs="{'invisible': [('is_contribution_cg', '=', False)]}" + > + <div><label for="journal_ur_idf_id" /></div> + <field + name="journal_ur_idf_id" + options="{'no_open': True, 'no_create': True}" + attrs="{'required': [('is_contribution_cg', '=', True)]}" + /> + </div> </div> </xpath> </field> diff --git a/views/scop_cotisation_simulation.xml b/views/scop_cotisation_simulation.xml index 34c3ee41a18e42bc018698504e200662f1d93d92..92e5417ed28108251a9c4fb82e43c74c286f1185 100644 --- a/views/scop_cotisation_simulation.xml +++ b/views/scop_cotisation_simulation.xml @@ -17,6 +17,7 @@ <field name="total_cg" /> <field name="total_hdf" /> <field name="total_med" /> + <field name="total_idf" /> <field name="total_com" /> <field name="total_cae" /> <field name="total_indus" /> @@ -54,6 +55,7 @@ <field name="total_cg" readonly="1" /> <field name="total_hdf" readonly="1" /> <field name="total_med" readonly="1" /> + <field name="total_idf" readonly="1" /> <field name="total_com" readonly="1" /> <field name="total_cae" readonly="1" /> <field name="total_indus" readonly="1" /> diff --git a/views/scop_liasse_fiscale.xml b/views/scop_liasse_fiscale.xml index cd033f2eb91f7554dd5db728402eecfecfe407c3..46959c221eff02b8393c786bcd1be877c6231543 100644 --- a/views/scop_liasse_fiscale.xml +++ b/views/scop_liasse_fiscale.xml @@ -32,22 +32,35 @@ <field name="contribution_cg" string="Cotisation CG Scop" /> </group> <group> - <field name="contribution_hdf" string="Cotisation HDF" /> + <field + name="contribution_hdf" + string="Cotisation HDF" + attrs="{'invisible': [('contribution_hdf', '=', 0)]}" + /> <field name="contribution_med" string="Cotisation Méditerranée" + attrs="{'invisible': [('contribution_med', '=', 0)]}" + /> + <field + name="contribution_idf" + string="Cotisation Ile de France, Centre Val de Loire" + attrs="{'invisible': [('contribution_idf', '=', 0)]}" /> <field name="contribution_com" string="Cotisation Fédération Com" + attrs="{'invisible': [('contribution_com', '=', 0)]}" /> <field name="contribution_cae" string="Cotisation Fédération CAE" + attrs="{'invisible': [('contribution_cae', '=', 0)]}" /> <field name="contribution_indus" string="Cotisation Fédération Industrie" + attrs="{'invisible': [('contribution_indus', '=', 0)]}" /> </group> </group> diff --git a/wizard/scop_bordereau_refund_wizard.py b/wizard/scop_bordereau_refund_wizard.py index 5945af5d6c3e9915eb6db9abe9d603e208b5999e..a1bb5dc18b1ec326f93a69f95f649a1bc127b1cf 100644 --- a/wizard/scop_bordereau_refund_wizard.py +++ b/wizard/scop_bordereau_refund_wizard.py @@ -125,6 +125,7 @@ class ScopBordereauRefundWizard(models.TransientModel): bordereau_id = self.bordereau_id partner_id = bordereau_id.partner_id ur_hdf = self.env.ref("cgscop_partner.riga_14232").id + ur_idf = self.env.ref("cgscop_partner.riga_14231").id # CREATE VERSION bordereau_id.read(["amount_total_cotiz"]) @@ -149,6 +150,9 @@ class ScopBordereauRefundWizard(models.TransientModel): if partner_id.ur_id.id == ur_hdf: product_ur = self.env.company.contribution_hdf_id journal_ur = self.env.user.company_id.journal_ur_hdf_id + elif partner_id.ur_id.id == ur_idf: + product_ur = self.env.company.contribution_idf_id + journal_ur = self.env.user.company_id.journal_ur_idf_id else: # ur = ur_med product_ur = self.env.company.contribution_med_id journal_ur = self.env.user.company_id.journal_ur_med_id diff --git a/wizard/scop_bordereau_update_liasse_wizard.py b/wizard/scop_bordereau_update_liasse_wizard.py index 76ff065b14c932cc7877f9b68a7ea85686701b4e..6932df5cf5b77650f5863c5280b1cddd610112f1 100644 --- a/wizard/scop_bordereau_update_liasse_wizard.py +++ b/wizard/scop_bordereau_update_liasse_wizard.py @@ -32,12 +32,18 @@ class ScopBordereauChangeLiasse(models.TransientModel): amount_ur_hdf = fields.Float( "Cotisation UR HDF actuelle", compute="_compute_amount_cotiz" ) + amount_ur_idf = fields.Float( + "Cotisation UR IDF actuelle", compute="_compute_amount_cotiz" + ) amount_fede_com = fields.Float( "Cotisation Fede Com actuelle", compute="_compute_amount_cotiz" ) amount_fede_cae = fields.Float( "Cotisation Fede CAE actuelle", compute="_compute_amount_cotiz" ) + amount_fede_indus = fields.Float( + "Cotisation Fede Industrie actuelle", compute="_compute_amount_cotiz" + ) type_assiette = fields.Selection( string="Type d'assiette", related="bordereau_id.type_assiette", @@ -76,6 +82,9 @@ class ScopBordereauChangeLiasse(models.TransientModel): amount_ur_hdf_new = fields.Float( "Cotisation UR HDF", related="liasse_fiscale_new_id.contribution_hdf" ) + amount_ur_idf_new = fields.Float( + "Cotisation UR IDF", related="liasse_fiscale_new_id.contribution_idf" + ) amount_fede_com_new = fields.Float( "Cotisation Fédé Communication", related="liasse_fiscale_new_id.contribution_com", @@ -83,6 +92,9 @@ class ScopBordereauChangeLiasse(models.TransientModel): amount_fede_cae_new = fields.Float( "Cotisation Fédé CAE", related="liasse_fiscale_new_id.contribution_cae" ) + amount_fede_indus_new = fields.Float( + "Cotisation Fédé Industrie", related="liasse_fiscale_new_id.contribution_indus" + ) type_assiette_new = fields.Selection( related="liasse_fiscale_new_id.contribution_base_type" ) @@ -97,6 +109,7 @@ class ScopBordereauChangeLiasse(models.TransientModel): type_cotisation_cg = self.env.ref("cgscop_partner.riga_14397").id type_cotisation_fede_com = self.env.ref("cgscop_partner.riga_14398").id type_cotisation_fede_cae = self.env.ref("cgscop_partner.cotiz_fede_cae").id + type_cotisation_fede_indus = self.env.ref("cgscop_partner.cotiz_fede_indus").id type_cotisation_ur = self.env.ref("cgscop_partner.riga_14399").id for r in self: partner = r.bordereau_id.partner_id @@ -116,6 +129,11 @@ class ScopBordereauChangeLiasse(models.TransientModel): lambda i: i.type_contribution_id.id == type_cotisation_fede_cae ) r.amount_fede_cae = sum(cotiz_fede_cae.mapped("amount_total")) + # Fede Industrie + cotiz_fede_indus = cotiz.filtered( + lambda i: i.type_contribution_id.id == type_cotisation_fede_indus + ) + r.amount_fede_indus = sum(cotiz_fede_indus.mapped("amount_total")) # UR HDF ur_hdf = self.env.ref("cgscop_partner.riga_14232").id if partner.ur_id.id == ur_hdf: @@ -125,7 +143,8 @@ class ScopBordereauChangeLiasse(models.TransientModel): r.amount_ur_hdf = sum(cotiz_ur_hdf.mapped("amount_total")) else: r.amount_ur_hdf = 0 - # UR Med + + # UR Med ur_med = self.env.ref("cgscop_partner.riga_14243").id if partner.ur_id.id == ur_med: cotiz_ur_med = cotiz.filtered( @@ -135,6 +154,16 @@ class ScopBordereauChangeLiasse(models.TransientModel): else: r.amount_ur_med = 0 + # UR IDF + ur_idf = self.env.ref("cgscop_partner.riga_14231").id + if partner.ur_id.id == ur_idf: + cotiz_ur_idf = cotiz.filtered( + lambda i: i.type_contribution_id.id == type_cotisation_ur + ) + r.amount_ur_med = sum(cotiz_ur_idf.mapped("amount_total")) + else: + r.amount_ur_med = 0 + # ------------------------------------------------------ # Onchange # ------------------------------------------------------ @@ -146,7 +175,10 @@ class ScopBordereauChangeLiasse(models.TransientModel): r.amount_cg_new + r.amount_ur_hdf_new + r.amount_ur_med_new - + r.amount_fede_com + + r.amount_ur_idf_new + + r.amount_fede_com_new + + r.amount_fede_cae_new + + r.amount_fede_indus_new ) # ------------------------------------------------------ diff --git a/wizard/scop_bordereau_update_liasse_wizard.xml b/wizard/scop_bordereau_update_liasse_wizard.xml index 125e66c599121ff38c782db6b517c09a24d5a9a7..c9999d97fdd064b0a21027fd3ff20d14b64573e6 100644 --- a/wizard/scop_bordereau_update_liasse_wizard.xml +++ b/wizard/scop_bordereau_update_liasse_wizard.xml @@ -28,6 +28,10 @@ name="amount_ur_hdf" attrs="{'invisible':[('amount_ur_hdf','=',0)]}" /> + <field + name="amount_ur_idf" + attrs="{'invisible':[('amount_ur_idf','=',0)]}" + /> <field name="amount_fede_com" attrs="{'invisible':[('amount_fede_com','=',0)]}" @@ -36,6 +40,10 @@ name="amount_fede_cae" attrs="{'invisible':[('amount_fede_cae','=',0)]}" /> + <field + name="amount_fede_indus" + attrs="{'invisible':[('amount_fede_indus','=',0)]}" + /> <hr /> <field name="type_assiette" /> <field name="montant_assiette" /> @@ -79,6 +87,10 @@ name="amount_ur_hdf_new" attrs="{'invisible':[('amount_ur_hdf_new','=',0)]}" /> + <field + name="amount_ur_idf_new" + attrs="{'invisible':[('amount_ur_idf_new','=',0)]}" + /> <field name="amount_fede_com_new" attrs="{'invisible':[('amount_fede_com_new','=',0)]}" @@ -87,6 +99,10 @@ name="amount_fede_cae_new" attrs="{'invisible':[('amount_fede_cae_new','=',0)]}" /> + <field + name="amount_fede_indus_new" + attrs="{'invisible':[('amount_fede_indus_new','=',0)]}" + /> <hr /> <field name="type_assiette_new" /> <field name="montant_assiette_new" /> diff --git a/wizard/scop_cotisation_cg_regul.py b/wizard/scop_cotisation_cg_regul.py index bdc7b08d61d64a0bf4ec8140852a5a2fe4842664..3b008201c0ae2879daf6f207dcf0252a1df9b506 100644 --- a/wizard/scop_cotisation_cg_regul.py +++ b/wizard/scop_cotisation_cg_regul.py @@ -64,8 +64,10 @@ class ScopCotisationRegul(models.TransientModel): amount_cg = fields.Float(related="liasse_fiscale_new_id.contribution_cg") amount_ur_med = fields.Float(related="liasse_fiscale_new_id.contribution_med") amount_ur_hdf = fields.Float(related="liasse_fiscale_new_id.contribution_hdf") + amount_ur_idf = fields.Float(related="liasse_fiscale_new_id.contribution_idf") amount_fede_com = fields.Float(related="liasse_fiscale_new_id.contribution_com") amount_fede_cae = fields.Float(related="liasse_fiscale_new_id.contribution_cae") + amount_fede_indus = fields.Float(related="liasse_fiscale_new_id.contribution_indus") is_payment = fields.Boolean("Paiements liés") diff --git a/wizard/scop_cotisation_cg_regul_wizard.xml b/wizard/scop_cotisation_cg_regul_wizard.xml index dda2ebc48bc078fde1cfe4fb63ad486b70d086f4..66ad93cfdf085b86dc0244b3027728e8189ffe06 100644 --- a/wizard/scop_cotisation_cg_regul_wizard.xml +++ b/wizard/scop_cotisation_cg_regul_wizard.xml @@ -104,6 +104,11 @@ attrs="{'invisible': [('amount_fede_cae', '=', 0.0)]}" readonly="1" /> + <field + name="amount_fede_indus" + attrs="{'invisible': [('amount_fede_cae', '=', 0.0)]}" + readonly="1" + /> <field name="amount_ur_hdf" attrs="{'invisible': [('amount_ur_hdf', '=', 0.0)]}" @@ -114,6 +119,11 @@ attrs="{'invisible': [('amount_ur_med', '=', 0.0)]}" readonly="1" /> + <field + name="amount_ur_idf" + attrs="{'invisible': [('amount_ur_med', '=', 0.0)]}" + readonly="1" + /> </group> <label for="comment"