Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][FIX] account_mass_reconcile : fix write-off with today's date #552

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion account_mass_reconcile/models/base_reconciliation.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def create_write_off(self, lines, amount, amount_curr, same_curr):

move = self.env["account.move"].create(
{
"date": lines.env.context.get("date_p"),
"date": lines.env.context.get("date_p") or fields.Date.today(),
florian-dacosta marked this conversation as resolved.
Show resolved Hide resolved
"journal_id": journal.id,
"currency_id": currency.id,
"line_ids": [(0, 0, write_off_vals), (0, 0, counter_part)],
Expand Down
61 changes: 60 additions & 1 deletion account_mass_reconcile/tests/test_scenario_reconcile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# © 2023 FactorLibre - Aritz Olea <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from datetime import timedelta
from datetime import date, timedelta

import odoo.tests
from odoo import fields
Expand Down Expand Up @@ -362,3 +362,62 @@ def test_reconcile_with_writeoff(self):
writeoff_line.move_id.journal_id.id,
self.company_data["default_journal_misc"].id,
)

def test_reconcile_with_writeoff_today(self):
yesterday = date.today() - timedelta(days=1)
invoice = self._create_invoice(
move_type="out_invoice",
invoice_amount=50,
date_invoice=yesterday,
auto_validate=True,
)

receivable_account_id = invoice.partner_id.property_account_receivable_id.id
# create payment
payment = self.env["account.payment"].create(
{
"partner_type": "customer",
"payment_type": "inbound",
"partner_id": invoice.partner_id.id,
"destination_account_id": receivable_account_id,
"amount": 50.02,
"journal_id": self.bank_journal.id,
"date": yesterday,
}
)
payment.action_post()

# create the mass reconcile record
mass_rec = self.mass_rec_obj.create(
{
"name": "mass_reconcile_1",
"account": invoice.partner_id.property_account_receivable_id.id,
"reconcile_method": [
(
0,
0,
{
"name": "mass.reconcile.simple.partner",
"account_lost_id": self.company_data[
"default_account_expense"
].id,
"account_profit_id": self.company_data[
"default_account_revenue"
].id,
"journal_id": self.company_data["default_journal_misc"].id,
"write_off": 0.05,
"date_base_on": "actual",
},
)
],
}
)
# call the automatic reconciliation method
mass_rec.run_reconcile()
self.assertEqual("paid", invoice.payment_state)
full_reconcile = invoice.line_ids.mapped("full_reconcile_id")
writeoff_line = full_reconcile.reconciled_line_ids.filtered(
lambda l: l.debit == 0.02
)
self.assertEqual(len(writeoff_line), 1)
self.assertEqual(writeoff_line.date, fields.Date.today())
Loading