Skip to content
Extraits de code Groupes Projets
Valider ca26d497 rédigé par Benjamin - Le Filament's avatar Benjamin - Le Filament
Parcourir les fichiers

[update] refactor contribution

parent 2730e5b4
Branches 13.0
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -129,6 +129,7 @@ class Bordereau(models.Model):
string='Cotisation CG Scop',
currency_field='company_currency_id',
compute='_compute_amount_cg',
store=True,
)
amount_residual = fields.Monetary(
string="Montant dû",
......@@ -235,11 +236,13 @@ class Bordereau(models.Model):
for r in self:
if r.liasse_fiscale_id:
liasse = r.liasse_fiscale_id
r.ca = liasse.revenue_cgsubv
r.ca = liasse.L2052_FL
r.va = r.base_cotisation_cg.get_va(liasse)
r.net_results = (
liasse.L2053_HN if liasse.L2053_HN > 0 else liasse.L2051_DI
)
r.net_results = 0
if liasse.L2053_HN > 0:
r.net_results = liasse.L2053_HN
elif liasse.L2051_DI > 0:
r.net_results = liasse.L2051_DI
r.wage_cg = liasse.wage_cg
else:
r.ca = r.va = r.net_results = r.wage_cg = 0
......@@ -289,8 +292,9 @@ class Bordereau(models.Model):
for r in self:
r.amount_total_cotiz = sum(r.invoice_ids.mapped("amount_total_signed"))
@api.depends("invoice_ids", "invoice_ids.amount_total_signed")
def _compute_amount_cg(self):
type_cotisation_cg = self.env.ref('cgscop_partner.riga_14397')
type_cotisation_cg = self.env.ref("cgscop_partner.riga_14397")
for r in self:
contrib_cg_ids = r.invoice_ids.filtered(
lambda i: i.type_contribution_id == type_cotisation_cg
......@@ -300,7 +304,7 @@ class Bordereau(models.Model):
@api.depends("invoice_ids", "invoice_ids.amount_residual_signed")
def _compute_amount_residual(self):
for r in self:
r.amount_total_cotiz = sum(r.invoice_ids.mapped("amount_residual_signed"))
r.amount_residual = sum(r.invoice_ids.mapped("amount_residual_signed"))
def _compute_recipient(self):
tag_cotiz_id = self.env.company.tag_cotiz_id
......
......@@ -516,7 +516,11 @@ class ScopCotisation(models.Model):
)
# Calcul Cotisation CG Scop
net_results = liasse.L2053_HN if liasse.L2053_HN > 0 else liasse.L2051_DI
net_results = 0
if liasse.L2053_HN > 0:
net_results = liasse.L2053_HN
elif liasse.L2051_DI > 0:
net_results = liasse.L2051_DI
contrib_cg = (
self.round_to_closest_multiple(liasse.contribution_cg, 4)
if liasse
......
......@@ -50,7 +50,7 @@ class ScopLiasseFiscale(models.Model):
# ------------------------------------------------------
# Compute fields
# ------------------------------------------------------
@api.depends("av_lf", "av_cg", "revenue_cg", "dureeExercice")
@api.depends("av_lf", "av_cg", "L2052_FL", "dureeExercice")
def _compute_contribution_cg(self):
"""
Calcule la cotisation de la CG Scop :
......@@ -64,9 +64,9 @@ class ScopLiasseFiscale(models.Model):
"""
for liasse in self:
# Calcul VA
liasse.read(["av_lf", "av_cg", "revenue_cg"])
liasse.read(["av_lf", "av_cg", "L2052_FL"])
va = liasse.av_lf if liasse.av_lf > 0 else liasse.av_cg
ca = liasse.revenue_cg
ca = liasse.L2052_FL
if liasse.dureeExercice and liasse.dureeExercice not in (0, 12):
va = va * (12 / liasse.dureeExercice)
ca = ca * (12 / liasse.dureeExercice)
......@@ -303,30 +303,11 @@ class ScopLiasseFiscale(models.Model):
# Business Function
# ------------------------------------------------------
def get_plancher_cotiz(self):
# Calculation plancher med
staff_id = self.get_last_staff_id(self.partner_id)
if staff_id:
staff_shareholder_count = staff_id.staff_shareholder_count
staff_count = staff_id.staff_count
else:
staff_shareholder_count = staff_count = 0
if staff_count > 0:
societariat_rate = staff_shareholder_count / staff_count
else:
societariat_rate = 0
if 0.5 <= societariat_rate < 0.8:
abatt_rate_med = 1 - 0.2
elif societariat_rate >= 0.8:
abatt_rate_med = 1 - 0.3
else:
abatt_rate_med = 1 - 0
assiette_rate_med = 1 / 3
plancher_cg = self.get_values_for_cotiz_cg(self.partner_id)["plancher1"]
return {
"fede_com": 108,
"fede_cae": 300,
"ur_med": plancher_cg * assiette_rate_med * abatt_rate_med,
"ur_med": 0,
"ur_hdf": 40,
}
......@@ -340,10 +321,10 @@ class ScopLiasseFiscale(models.Model):
self.env.ref("cgscop_partner.form_coop47"),
self.env.ref("cgscop_partner.form_lamaneur"),
):
plancher1 = 1 / 3 * plancher1
plancher2 = 1 / 3 * plancher2
plancher3 = 1 / 3 * plancher3
plafond = 1 / 3 * plafond
plancher1 = 2 / 3 * plancher1
plancher2 = 2 / 3 * plancher2
plancher3 = 2 / 3 * plancher3
plafond = 2 / 3 * plafond
return {
"plancher1": plancher1,
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter