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 Apr 12, 2024
1 parent f966a79 commit 243518f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
23 changes: 23 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,31 @@ def _compute_is_past_due(self):
if len(invoice.past_due_move_line_ids) != reconciled_past_due:
invoice.is_past_due = True

def _compute_open_amount(self):
for invoice in self:
if invoice.is_riba_payment:
today = fields.Date.today()
open_amount_line_ids = invoice.line_ids.filtered(
lambda l: l.riba
and l.display_type == "payment_term"
and l.date_maturity > today
)
invoice.open_amount = sum(open_amount_line_ids.mapped("balance"))
else:
invoice.open_amount = 0.0

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

open_amount = fields.Float(
digits="Account",
compute="_compute_open_amount",
store=True,
default=0.0,
help="Amount currently only supposed to be paid, but has actually not happened",
)

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
5 changes: 0 additions & 5 deletions l10n_it_riba/tests/test_riba.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,6 @@ def test_past_due_riba(self):
# self.assertTrue(
# bank_past_due_line.id in [l.id for l in move_lines_for_rec])

riba_list.line_ids[0].past_due_move_id.line_ids.remove_move_reconcile()
self.assertEqual(riba_list.state, "credited")
self.assertEqual(len(riba_list.line_ids), 1)
self.assertEqual(riba_list.line_ids[0].state, "credited")

def test_riba_fatturapa(self):
self.partner.property_account_receivable_id = self.account_rec1_id.id
recent_date = (
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="open_amount" widget="monetary" />
<field name="is_past_due" string="Past Due" />
</field>
</field>
Expand Down
22 changes: 1 addition & 21 deletions l10n_it_riba/wizard/wizard_past_due.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,27 +130,6 @@ def create_move(self):
"journal_id": wizard.past_due_journal_id.id,
"date": slip_line.due_date,
"line_ids": [
(
0,
0,
{
"name": _("Bills"),
"account_id": wizard.effects_account_id.id,
"partner_id": slip_line.partner_id.id,
"credit": wizard.effects_amount,
"debit": 0.0,
},
),
(
0,
0,
{
"name": _("RiBa"),
"account_id": wizard.riba_bank_account_id.id,
"debit": wizard.riba_bank_amount,
"credit": 0.0,
},
),
(
0,
0,
Expand Down Expand Up @@ -205,6 +184,7 @@ def create_move(self):
i.id
for i in riba_move_line.move_line_id.past_due_invoice_ids
]
riba_move_line.move_line_id.remove_move_reconcile()
move_model.browse(invoice_ids).write(
{
"past_due_move_line_ids": [(4, move_line.id)],
Expand Down

0 comments on commit 243518f

Please sign in to comment.