diff --git a/__manifest__.py b/__manifest__.py index 58577351ebb457b4c0f9e466eeb575a4c3325ae8..8f27453fe07c6ba098c771a7a0062e5a418b8f35 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -17,6 +17,7 @@ # datas # views "views/financial_contract_guarantee.xml", + "views/financial_contract_guarantee_commission.xml", "views/financial_contract_guarantee_line.xml", "views/financial_contract_guarantee_partner.xml", "views/financial_product_template_guarantee.xml", diff --git a/models/__init__.py b/models/__init__.py index f1c5687cbfd74b5624480c3ee98dd4d9f5760d08..6f20943b8a5672001a82a3ea0dac3b4eacb7ce84 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -1,5 +1,6 @@ from . import company_share_line from . import financial_contract_guarantee +from . import financial_contract_guarantee_commission from . import financial_contract_guarantee_partner from . import financial_contract_guarantee_line from . import financial_contract_guarantee_suspensive_condition diff --git a/models/financial_contract_guarantee.py b/models/financial_contract_guarantee.py index 73a6f606c2dbb5dd8e8e3caf501738d2bbaaafe6..c3d6491ddc5d36532cfbd386349af647f8d6d258 100644 --- a/models/financial_contract_guarantee.py +++ b/models/financial_contract_guarantee.py @@ -22,7 +22,6 @@ class FinancialContractGuarantee(models.Model): ] _order = "create_date desc" - # chaque contrat de garantie est associée à un identifiant titulaire # plusieurs contrats de garantie peuvent être associés au même identifiant titular_number = fields.Char("Identifiant Titulaire") @@ -75,6 +74,8 @@ class FinancialContractGuarantee(models.Model): store=True, tracking=1, ) + + # --- FMG --- fmg_amount = fields.Monetary( string="FMG calculé", compute="_compute_fmg_amount", @@ -90,6 +91,8 @@ class FinancialContractGuarantee(models.Model): inverse_name="guarantee_id", string="FMG", ) + + # --- Social share --- social_share_number = fields.Integer( string="Nbre parts sociales", compute="_compute_social_share", @@ -110,6 +113,12 @@ class FinancialContractGuarantee(models.Model): compute="_compute_social_share_paid", store=True ) + + # --- Commission --- + commission_ids = fields.One2many( + comodel_name="financial.guarantee.commission.line", + inverse_name="guarantee_id", string="Commissions") + is_old_associate = fields.Boolean( string="Nouveau sociétaire", compute="_compute_is_new_associate", @@ -124,7 +133,7 @@ class FinancialContractGuarantee(models.Model): date_folder_received = fields.Date("Date de réception dossier") date_approval_president = fields.Date("Date Validation Président") - # Loan Data + # --- Loan Data --- payment_date = fields.Date("Date de versement") amount_initial = fields.Monetary( string="Montant initial", @@ -142,7 +151,7 @@ class FinancialContractGuarantee(models.Model): readonly=False, ) - # Company Data + # --- Company Data --- segment_code = fields.Char("Code Segment") bdf_scoring = fields.Char( string="Cotation BDF", @@ -188,7 +197,7 @@ class FinancialContractGuarantee(models.Model): ) def _compute_guarantee_data(self): for guarantee in self: - last_line = guarantee.line_ids.sorted("line_date") # desc ?? + last_line = guarantee.line_ids.sorted("line_date") # desc ?? guarantee.update({"bdf_scoring": last_line.bdf_scoring}) @api.depends( @@ -201,13 +210,15 @@ class FinancialContractGuarantee(models.Model): guarantee.line_ids.mapped("commission_amount") ) - @api.depends("guarantee_amount", "is_counter_guarantee", "counter_guarantee_rate") + @api.depends("guarantee_amount", "is_counter_guarantee", + "counter_guarantee_rate") def _compute_final_risk_guarantee(self): for guarantee in self: if not guarantee.is_counter_guarantee: guarantee.final_risk_guarantee = guarantee.guarantee_amount else: - guarantee.final_risk_guarantee = (1 - guarantee.counter_guarantee_rate) * guarantee.guarantee_amount + guarantee.final_risk_guarantee = ( + 1 - guarantee.counter_guarantee_rate) * guarantee.guarantee_amount @api.depends("remaining_capital", "guarantee_rate") def _compute_guarantee_amount(self): @@ -255,7 +266,8 @@ class FinancialContractGuarantee(models.Model): @api.depends("social_share_ids", "social_share_ids.share_total_amount") def _compute_social_share_paid(self): for guarantee in self: - guarantee.social_share_paid = sum(guarantee.social_share_ids.mapped("share_total_amount")) + guarantee.social_share_paid = sum( + guarantee.social_share_ids.mapped("share_total_amount")) @api.depends("product_id") def _compute_suspensive_condition_ids(self): diff --git a/models/financial_contract_guarantee_commission.py b/models/financial_contract_guarantee_commission.py new file mode 100644 index 0000000000000000000000000000000000000000..a1963fd26951be8b8196599d3d569c96a9f74cb4 --- /dev/null +++ b/models/financial_contract_guarantee_commission.py @@ -0,0 +1,42 @@ +# © 2024 Le Filament (<http://www.le-filament.com>) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class FinancialContractGuaranteeCommission(models.Model): + """ + """ + _name = "financial.guarantee.commission.line" + _description = "Ligne de commission sur contrat de garantie" + + # commission line + prime_reversee = fields.Monetary("Prime reversée") + taux_commission = fields.Float() + + guarantee_id = fields.Many2one( + comodel_name="financial.contract.guarantee", + string="Contrat de garantie", + required=True, + store=True, + index=True, + ) + # related to guarantee + partner_id = fields.Many2one( + comodel_name="res.partner", + related="guarantee_id.partner_id", + string="Contact", + store=True, + index=True, + ) + company_id = fields.Many2one( + comodel_name="res.company", + related="guarantee_id.company_id", + string="Société", + store=True, + index=True, + ) + currency_id = fields.Many2one( + comodel_name="res.currency", + related="guarantee_id.currency_id", + ) diff --git a/views/financial_contract_guarantee_commission.xml b/views/financial_contract_guarantee_commission.xml new file mode 100644 index 0000000000000000000000000000000000000000..7b9e370fa55bcd940be265bb38c63f68fd16e5c3 --- /dev/null +++ b/views/financial_contract_guarantee_commission.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8" ?> +<odoo> + <!-- action --> + <record model="ir.actions.act_window" id="commission_line_action"> + <field name="name">Commission</field> + <field name="res_model">financial.guarantee.commission.line</field> + <field name="path">commission_act</field> + <field name="view_mode">list,form</field> + </record> + + <!-- tree view --> + <record model="ir.ui.view" id="commission_line_tree_view"> + <field name="name">commission.line.tree.view</field> + <field name="model">financial.guarantee.commission.line</field> + <field name="arch" type="xml"> + <list> + <field name="guarantee_id" optional="hide"/> + <field name="partner_id" optional="hide"/> + <field name="company_id" optional="show"/> + <field name="currency_id" optional="hide"/> + <field name="prime_reversee" optional="show"/> + <field name="taux_commission" optional="show"/> + </list> + </field> + </record> + +</odoo>