Skip to content

Commit

Permalink
[IMP] l10n_it_riba: add exposition amount field
Browse files Browse the repository at this point in the history
  • Loading branch information
odooNextev committed Feb 22, 2024
1 parent f966a79 commit adc75b1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
19 changes: 19 additions & 0 deletions l10n_it_riba/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# (<http://www.odoo-italia.org>).
# Copyright (C) 2012-2018 Lorenzo Battistini - Agile Business Group
# Copyright 2023 Simone Rubino - Aion Tech
# Copyright 2024 Nextev Srl
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
Expand Down Expand Up @@ -58,9 +59,27 @@ def _compute_is_past_due(self):
if len(invoice.past_due_move_line_ids) != reconciled_past_due:
invoice.is_past_due = True

def _compute_exposition(self):
for invoice in self:
if invoice.is_riba_payment:
today = fields.Date.today()

Check warning on line 65 in l10n_it_riba/models/account.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_riba/models/account.py#L65

Added line #L65 was not covered by tests
exposition_line_ids = invoice.line_ids.filtered(
lambda l: l.riba
and l.display_type == "payment_term"
and l.date_maturity > today
)
invoice.exposition = sum(exposition_line_ids.mapped("balance"))

Check warning on line 71 in l10n_it_riba/models/account.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_riba/models/account.py#L71

Added line #L71 was not covered by tests
else:
invoice.exposition = 0.0

Check warning on line 73 in l10n_it_riba/models/account.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_riba/models/account.py#L73

Added line #L73 was not covered by tests

riba_credited_ids = fields.One2many(
"riba.slip", "credit_move_id", "Credited RiBa Slips", readonly=True
)

exposition = fields.Float(
digits="Account", compute="_compute_exposition", default=0.0
)

riba_past_due_ids = fields.One2many(
"riba.slip.line", "past_due_move_id", "Past Due RiBa Slips", readonly=True
)
Expand Down
3 changes: 2 additions & 1 deletion l10n_it_riba/models/riba.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# (<http://www.odoo-italia.org>).
# Copyright (C) 2012-2017 Lorenzo Battistini - Agile Business Group
# Copyright 2023 Simone Rubino - Aion Tech
# Copyright 2024 Nextev Srl
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from datetime import date
Expand Down Expand Up @@ -371,7 +372,7 @@ def confirm(self):
line.invoice_number, line.slip_id.name, line.sequence
),
"journal_id": journal.id,
"date": line.slip_id.registration_date,
"date": line.due_date,
}
)
to_be_reconciled = self.env["account.move.line"]
Expand Down
1 change: 1 addition & 0 deletions l10n_it_riba/views/account_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
<field name="inherit_id" ref="account.view_invoice_tree" />
<field name="arch" type="xml">
<field name="move_type" position="after">
<field name="exposition" widget="monetary" />
<field name="is_past_due" string="Past Due" />
</field>
</field>
Expand Down

0 comments on commit adc75b1

Please sign in to comment.