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

sync with master

parents 86b21f76 d94cb792
Branches
Aucune étiquette associée trouvée
1 requête de fusion!1[add] merge 14.0 new process adh
...@@ -10,6 +10,5 @@ class ResPartner(models.Model): ...@@ -10,6 +10,5 @@ class ResPartner(models.Model):
exo_ids = fields.One2many( exo_ids = fields.One2many(
comodel_name="scop.cotisation.cg.exo", comodel_name="scop.cotisation.cg.exo",
inverse_name="partner_id", inverse_name="partner_id",
domain=[("state", "=", "done")],
string="Exonérations", string="Exonérations",
) )
...@@ -109,7 +109,7 @@ class ScopCotisationExo(models.Model): ...@@ -109,7 +109,7 @@ class ScopCotisationExo(models.Model):
amount_quarter = fields.Float("Montant souhaité pour les échéances") amount_quarter = fields.Float("Montant souhaité pour les échéances")
percent_quarter = fields.Integer("Réduction appliquée aux échéances") percent_quarter = fields.Integer("Réduction appliquée aux échéances")
date_exo_ok = fields.Date("Date Acceptation Exo") date_exo_ok = fields.Date("Date Acceptation Exo")
head_office_comment = fields.Text("Commentaire du bureau") head_office_comment = fields.Text("Commentaire")
note = fields.Text("Notes internes") note = fields.Text("Notes internes")
instance_id = fields.Many2one(comodel_name="scop.instance", string="Instance") instance_id = fields.Many2one(comodel_name="scop.instance", string="Instance")
bordereau_ids = fields.Many2many( bordereau_ids = fields.Many2many(
...@@ -265,6 +265,18 @@ class ScopCotisationExo(models.Model): ...@@ -265,6 +265,18 @@ class ScopCotisationExo(models.Model):
def create_lines(self): def create_lines(self):
self.exo_line_ids.unlink() 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 exo is percent => affects percent to each line
...@@ -282,15 +294,6 @@ class ScopCotisationExo(models.Model): ...@@ -282,15 +294,6 @@ class ScopCotisationExo(models.Model):
if self.type_exo == "amount": if self.type_exo == "amount":
# if various contribution type => affects prorate amount to each line # if various contribution type => affects prorate amount to each line
if len(contrib_type) > 1: if len(contrib_type) > 1:
# 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: if last_bdx:
last_amount = last_bdx.amount_total_cotiz last_amount = last_bdx.amount_total_cotiz
amount_by_type = last_bdx.get_contribution_type() amount_by_type = last_bdx.get_contribution_type()
...@@ -489,17 +492,21 @@ class ScopCotisationExo(models.Model): ...@@ -489,17 +492,21 @@ class ScopCotisationExo(models.Model):
) )
if exo_amount != 0: if exo_amount != 0:
date_refund = ( if self.date_exo_ok > bordereau_id.date_cotisation:
bordereau_id.date_cotisation date_refund = self.date_exo_ok
if bordereau_id.state == "draft" else:
else self.date_exo_ok date_refund = bordereau_id.date_cotisation
)
date_due = bordereau_id.invoice_ids.filtered( quarter_date_due = bordereau_id.invoice_ids.filtered(
lambda i: i.cotiz_quarter == str(quarter) lambda i: i.cotiz_quarter == str(quarter)
and i.move_type == "out_invoice" and i.move_type == "out_invoice"
)[0].invoice_date_due )[0].invoice_date_due
if quarter_date_due < self.date_exo_ok:
date_due = self.date_exo_ok
else:
date_due = quarter_date_due
# Create refund # Create refund
refund = bordereau_id.invoice_ids.create( bordereau_id.invoice_ids.create(
{ {
"partner_id": bordereau_id.partner_id.id, "partner_id": bordereau_id.partner_id.id,
"liasse_fiscale_id": bordereau_id.liasse_fiscale_id.id, "liasse_fiscale_id": bordereau_id.liasse_fiscale_id.id,
......
...@@ -18,17 +18,20 @@ ...@@ -18,17 +18,20 @@
<field name="exo_ids" mode="tree,form" readonly="1"> <field name="exo_ids" mode="tree,form" readonly="1">
<tree create="false" edit="false" delete="false"> <tree create="false" edit="false" delete="false">
<field name="date_request" /> <field name="date_request" />
<field name="number" />
<field name="source" /> <field name="source" />
<field name="date_exo_start" /> <field name="date_exo_start" />
<field name="date_exo_end" /> <field name="date_exo_end" />
<field name="ur_notice" /> <field name="ur_notice" />
<field name="final_notice" /> <field name="final_notice" />
<field name="date_exo_ok" /> <field name="date_exo_ok" />
<field name="head_office_comment" optional="show" />
</tree> </tree>
<form> <form>
<group string="Demande initiale"> <group string="Demande initiale">
<group name="request"> <group name="request">
<field name="date_request" /> <field name="date_request" />
<field name="number" />
<field name="source" /> <field name="source" />
<field <field
name="ur_notice" name="ur_notice"
...@@ -53,7 +56,7 @@ ...@@ -53,7 +56,7 @@
<strong><label for="head_office_comment" /></strong> <strong><label for="head_office_comment" /></strong>
<field <field
name="head_office_comment" name="head_office_comment"
placeholder="Commentaire du bureau" placeholder="Commentaire"
/> />
</form> </form>
</field> </field>
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
<search string="Exonerations"> <search string="Exonerations">
<field name="partner_id" options="{'no_create': 1}" /> <field name="partner_id" options="{'no_create': 1}" />
<field name="name" /> <field name="name" />
<field name="number" />
<field name="date_request" /> <field name="date_request" />
<separator /> <separator />
<filter <filter
...@@ -64,6 +65,7 @@ ...@@ -64,6 +65,7 @@
<tree string="Exonerations"> <tree string="Exonerations">
<field name="date_request" /> <field name="date_request" />
<field name="partner_id" /> <field name="partner_id" />
<field name="number" optional="show" />
<field name="state" /> <field name="state" />
<field name="date_exo_start" /> <field name="date_exo_start" />
<field name="date_exo_end" /> <field name="date_exo_end" />
......
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