[FIX] partner_statement: don't consider reconciled lines outside date range

This commit is contained in:
Miquel Raïch
2024-05-07 17:36:13 +02:00
parent 3397031434
commit e1b5b9729e
15 changed files with 171 additions and 40 deletions

View File

@@ -7,7 +7,7 @@ Partner Statement
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:95be111a13141377a3160fe32ac75f3648d8345060d59fdf7f45a60d3ada1e50
!! source digest: sha256:77de87887c4a3ada88f9db6a00b25d47dd445dc8bb5c0da54a72841d3c2816a3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png

View File

@@ -3,7 +3,7 @@
{
"name": "Partner Statement",
"version": "16.0.1.0.2",
"version": "16.0.1.0.3",
"category": "Accounting & Finance",
"summary": "OCA Financial Reports",
"author": "ForgeFlow, Odoo Community Association (OCA)",

View File

@@ -9,7 +9,7 @@ msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-12-22 23:13+0000\n"
"PO-Revision-Date: 2024-04-04 16:37+0000\n"
"PO-Revision-Date: 2024-06-15 19:37+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n"
"Language: it\n"
@@ -467,7 +467,7 @@ msgstr "Abilita Scaduto OCA"
#: model_terms:ir.ui.view,arch_db:partner_statement.outstanding_balance
#, python-format
msgid "Ending Balance"
msgstr "Saldo Finale"
msgstr "Saldo finale"
#. module: partner_statement
#: model:ir.model.fields,field_description:partner_statement.field_activity_statement_wizard__filter_negative_balances

View File

@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-02-23 10:33+0000\n"
"PO-Revision-Date: 2024-06-18 15:36+0000\n"
"Last-Translator: jakobkrabbe <jakob@syscare.se>\n"
"Language-Team: none\n"
"Language: sv\n"
@@ -112,7 +112,7 @@ msgstr ""
"uttryckt i\n"
" så att partnern kan granska hur mycket som är öppet, förfallet eller "
"försenat.\n"
" </span>."
" </span>"
#. module: partner_statement
#: model_terms:ir.ui.view,arch_db:partner_statement.activity_statement_wizard_view
@@ -136,7 +136,9 @@ msgstr ""
"kontoutdraget. Listan visas i\n"
" visas i kronologisk ordning och är uppdelad efter "
"valutor.\n"
" </span> </span"
" </span>\n"
" <br/>\n"
" <br/>"
#. module: partner_statement
#: model_terms:ir.ui.view,arch_db:partner_statement.detailed_activity_statement_wizard_view
@@ -152,8 +154,9 @@ msgstr ""
"transaktioner\n"
"som har skett under perioden, och innehåller även en sektion för tidigare "
"balans och en sektion för utgående balans.\n"
" </span>.\n"
" <br/> </span"
" </span>\n"
" <br/>\n"
" <br/>"
#. module: partner_statement
#: model_terms:ir.ui.view,arch_db:partner_statement.outstanding_statement_wizard_view
@@ -172,8 +175,10 @@ msgstr ""
"alla obetalda fakturor, ej utkrävda\n"
" återbetalningar och utestående betalningar. Listan visas i "
"kronologisk ordning och är uppdelad\n"
" uppdelad efter valutor.\n"
" </span> </span"
" efter valutor.\n"
" </span>\n"
" <br/>\n"
" <br/>"
#. module: partner_statement
#: model_terms:ir.ui.view,arch_db:partner_statement.activity_statement_document
@@ -634,7 +639,7 @@ msgstr ""
#: model:ir.actions.act_window,name:partner_statement.activity_statement_wizard_action
#: model:ir.model,name:partner_statement.model_report_partner_statement_activity_statement
msgid "Partner Activity Statement"
msgstr "Verksamhetsberättelse för partner"
msgstr "Verksamhetsberättelse för kontakter"
#. module: partner_statement
#: model:ir.actions.act_window,name:partner_statement.detailed_activity_statement_wizard_action

View File

@@ -310,7 +310,7 @@ class ActivityStatementXslx(models.AbstractModel):
FORMATS["current_money_format"] = workbook.add_format(
{"align": "right", "num_format": money_string}
)
bg_grey = "#CCCCCC"
bg_grey = "#ADB5BD"
FORMATS["format_tcell_left_blocked"] = copy_format(
workbook, FORMATS["format_tcell_left"]
)

View File

@@ -100,12 +100,20 @@ class DetailedActivityStatementXslx(models.AbstractModel):
format_tcell_date_left = FORMATS["format_tcell_date_left_blocked"]
format_distributed = FORMATS["format_distributed_blocked"]
current_money_format = FORMATS["current_money_format_blocked"]
elif line.get("reconciled_line") and not line.get("blocked"):
elif (
line.get("reconciled_line")
and not line.get("blocked")
and not line.get("outside-date-rank")
):
format_tcell_left = FORMATS["format_tcell_left_reconciled"]
format_tcell_date_left = FORMATS["format_tcell_date_left_reconciled"]
format_distributed = FORMATS["format_distributed_reconciled"]
current_money_format = FORMATS["current_money_format_reconciled"]
elif line.get("blocked") and line.get("reconciled_line"):
elif (
line.get("blocked")
and line.get("reconciled_line")
and not line.get("outside-date-rank")
):
format_tcell_left = FORMATS["format_tcell_left_blocked_reconciled"]
format_tcell_date_left = FORMATS[
"format_tcell_date_left_blocked_reconciled"
@@ -114,6 +122,40 @@ class DetailedActivityStatementXslx(models.AbstractModel):
current_money_format = FORMATS[
"current_money_format_blocked_reconciled"
]
elif (
line.get("reconciled_line")
and not line.get("blocked")
and line.get("outside-date-rank")
):
format_tcell_left = FORMATS[
"format_tcell_left_reconciled_outside-date-rank"
]
format_tcell_date_left = FORMATS[
"format_tcell_date_left_reconciled_outside-date-rank"
]
format_distributed = FORMATS[
"format_distributed_reconciled_outside-date-rank"
]
current_money_format = FORMATS[
"current_money_format_reconciled_outside-date-rank"
]
elif (
line.get("blocked")
and line.get("reconciled_line")
and line.get("outside-date-rank")
):
format_tcell_left = FORMATS[
"format_tcell_left_blocked_reconciled_outside-date-rank"
]
format_tcell_date_left = FORMATS[
"format_tcell_date_left_blocked_reconciled_outside-date-rank"
]
format_distributed = FORMATS[
"format_distributed_blocked_reconciled_outside-date-rank"
]
current_money_format = FORMATS[
"current_money_format_blocked_reconciled_outside-date-rank"
]
else:
format_tcell_left = FORMATS["format_tcell_left"]
format_tcell_date_left = FORMATS["format_tcell_date_left"]
@@ -491,7 +533,8 @@ class DetailedActivityStatementXslx(models.AbstractModel):
FORMATS["current_money_format"] = workbook.add_format(
{"align": "right", "num_format": money_string}
)
bg_grey = "#CCCCCC"
bg_grey = "#ADB5BD"
fc_red = "#DC3545"
FORMATS["format_tcell_left_blocked"] = copy_format(
workbook, FORMATS["format_tcell_left"]
)
@@ -530,32 +573,79 @@ class DetailedActivityStatementXslx(models.AbstractModel):
FORMATS["current_money_format_reconciled"].set_italic(True)
FORMATS["current_money_format_reconciled"].set_font_size(10)
FORMATS["format_tcell_left_blocked_reconciled"] = copy_format(
workbook, FORMATS["format_tcell_left"]
workbook, FORMATS["format_tcell_left_reconciled"]
)
FORMATS["format_tcell_left_blocked_reconciled"].set_bg_color(bg_grey)
FORMATS["format_tcell_left_blocked_reconciled"].set_italic(True)
FORMATS["format_tcell_left_blocked_reconciled"].set_font_size(10)
FORMATS["format_tcell_left_blocked_reconciled"].set_indent(1)
FORMATS["format_tcell_date_left_blocked_reconciled"] = copy_format(
workbook, FORMATS["format_tcell_date_left"]
workbook, FORMATS["format_tcell_date_left_reconciled"]
)
FORMATS["format_tcell_date_left_blocked_reconciled"].set_bg_color(
bg_grey
)
FORMATS["format_tcell_date_left_blocked_reconciled"].set_italic(True)
FORMATS["format_tcell_date_left_blocked_reconciled"].set_font_size(10)
FORMATS["format_distributed_blocked_reconciled"] = copy_format(
workbook, FORMATS["format_distributed"]
workbook, FORMATS["format_distributed_reconciled"]
)
FORMATS["format_distributed_blocked_reconciled"].set_bg_color(bg_grey)
FORMATS["format_distributed_blocked_reconciled"].set_italic(True)
FORMATS["format_distributed_blocked_reconciled"].set_font_size(10)
FORMATS["current_money_format_blocked_reconciled"] = copy_format(
workbook, FORMATS["current_money_format"]
workbook, FORMATS["current_money_format_reconciled"]
)
FORMATS["current_money_format_blocked_reconciled"].set_bg_color(bg_grey)
FORMATS["current_money_format_blocked_reconciled"].set_italic(True)
FORMATS["current_money_format_blocked_reconciled"].set_font_size(10)
FORMATS["format_tcell_left_reconciled_outside-date-rank"] = copy_format(
workbook, FORMATS["format_tcell_left_reconciled"]
)
FORMATS[
"format_tcell_left_reconciled_outside-date-rank"
].set_font_color(fc_red)
FORMATS[
"format_tcell_date_left_reconciled_outside-date-rank"
] = copy_format(workbook, FORMATS["format_tcell_date_left_reconciled"])
FORMATS[
"format_tcell_date_left_reconciled_outside-date-rank"
].set_font_color(fc_red)
FORMATS[
"format_distributed_reconciled_outside-date-rank"
] = copy_format(workbook, FORMATS["format_distributed_reconciled"])
FORMATS[
"format_distributed_reconciled_outside-date-rank"
].set_font_color(fc_red)
FORMATS[
"current_money_format_reconciled_outside-date-rank"
] = copy_format(workbook, FORMATS["current_money_format_reconciled"])
FORMATS[
"current_money_format_reconciled_outside-date-rank"
].set_font_color(fc_red)
FORMATS[
"format_tcell_left_blocked_reconciled_outside-date-rank"
] = copy_format(
workbook, FORMATS["format_tcell_left_blocked_reconciled"]
)
FORMATS[
"format_tcell_left_blocked_reconciled_outside-date-rank"
].set_font_color(fc_red)
FORMATS[
"format_tcell_date_left_blocked_reconciled_outside-date-rank"
] = copy_format(
workbook, FORMATS["format_tcell_date_left_blocked_reconciled"]
)
FORMATS[
"format_tcell_date_left_blocked_reconciled_outside-date-rank"
].set_font_color(fc_red)
FORMATS[
"format_distributed_blocked_reconciled_outside-date-rank"
] = copy_format(
workbook, FORMATS["format_distributed_blocked_reconciled"]
)
FORMATS[
"format_distributed_blocked_reconciled_outside-date-rank"
].set_font_color(fc_red)
FORMATS[
"current_money_format_blocked_reconciled_outside-date-rank"
] = copy_format(
workbook, FORMATS["current_money_format_blocked_reconciled"]
)
FORMATS[
"current_money_format_blocked_reconciled_outside-date-rank"
].set_font_color(fc_red)
row_pos = self._write_currency_prior_lines(
row_pos, sheet, partner, currency, data
)

View File

@@ -288,7 +288,7 @@ class OutstandingStatementXslx(models.AbstractModel):
FORMATS["current_money_format"] = workbook.add_format(
{"align": "right", "num_format": money_string}
)
bg_grey = "#CCCCCC"
bg_grey = "#ADB5BD"
FORMATS["format_tcell_left_blocked"] = copy_format(
workbook, FORMATS["format_tcell_left"]
)

View File

@@ -476,6 +476,7 @@ class ReportStatementCommon(models.AbstractModel):
if not line["blocked"]:
line_currency["ending_balance"] += line[amount_field]
line["balance"] = line_currency["ending_balance"]
line["outside-date-rank"] = False
line["date"] = format_date(
line["date"], date_formats.get(partner_id, default_fmt)
)
@@ -491,6 +492,14 @@ class ReportStatementCommon(models.AbstractModel):
)
for line2 in reconciled_lines:
if line2["id"] in line["ids"]:
line2["reconciled_line"] = True
line2["applied_amount"] = line2["open_amount"]
if line2["date"] >= date_start and line2["date"] <= date_end:
line2["outside-date-rank"] = False
if not line2["blocked"]:
line["applied_amount"] += line2["open_amount"]
else:
line2["outside-date-rank"] = True
line2["date"] = format_date(
line2["date"], date_formats.get(partner_id, default_fmt)
)
@@ -498,9 +507,6 @@ class ReportStatementCommon(models.AbstractModel):
line2["date_maturity"],
date_formats.get(partner_id, default_fmt),
)
line2["reconciled_line"] = True
line2["applied_amount"] = line2["open_amount"]
line["applied_amount"] += line2["open_amount"]
if is_detailed:
line_currency["lines"].extend(
self._add_currency_line(
@@ -509,7 +515,8 @@ class ReportStatementCommon(models.AbstractModel):
)
if is_activity:
line["open_amount"] = line["amount"] + line["applied_amount"]
line_currency["amount_due"] += line["open_amount"]
if not line["blocked"]:
line_currency["amount_due"] += line["open_amount"]
if is_detailed:
for line_currency in currency_dict.values():

View File

@@ -366,7 +366,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:95be111a13141377a3160fe32ac75f3648d8345060d59fdf7f45a60d3ada1e50
!! source digest: sha256:77de87887c4a3ada88f9db6a00b25d47dd445dc8bb5c0da54a72841d3c2816a3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-financial-reporting/tree/16.0/partner_statement"><img alt="OCA/account-financial-reporting" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--reporting-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-financial-reporting-16-0/account-financial-reporting-16-0-partner_statement"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-financial-reporting&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module extends the functionality of Invoicing to support the printing of customer and vendor statements.

View File

@@ -28,3 +28,10 @@
font-style: italic !important;
}
}
.statement-outside-date-rank {
color: $red !important;
td:last-child {
color: $red !important;
}
}

View File

@@ -3,6 +3,8 @@
from datetime import date
from freezegun import freeze_time
from odoo import fields
from odoo.tests import new_test_user
from odoo.tests.common import TransactionCase
@@ -112,8 +114,10 @@ class TestActivityStatement(TransactionCase):
)
self.assertEqual(res, "30/09/2018")
@freeze_time("2024-05-01")
def test_onchange_aging_type(self):
"""Test that partner data is filled accordingly"""
self.today = fields.Date.context_today(self.wiz)
wiz_id = self.wiz.with_context(
active_ids=[self.partner1.id, self.partner2.id]
).new()
@@ -127,3 +131,21 @@ class TestActivityStatement(TransactionCase):
wiz_id.onchange_aging_type()
self.assertEqual((wiz_id.date_end - wiz_id.date_start).days, 30)
self.assertTrue(wiz_id.date_end == self.today)
@freeze_time("2024-05-31")
def test_onchange_aging_type2(self):
"""Test that partner data is filled accordingly"""
self.today = fields.Date.context_today(self.wiz)
wiz_id = self.wiz.with_context(
active_ids=[self.partner1.id, self.partner2.id]
).new()
wiz_id.aging_type = "months"
wiz_id.onchange_aging_type()
self.assertEqual(wiz_id.date_end.month, wiz_id.date_start.month)
self.assertTrue(wiz_id.date_end.day > wiz_id.date_start.day)
self.assertTrue(wiz_id.date_end < self.today)
wiz_id.aging_type = "days"
wiz_id.onchange_aging_type()
self.assertEqual((wiz_id.date_end - wiz_id.date_start).days, 31)
self.assertTrue(wiz_id.date_end == self.today)

View File

@@ -42,7 +42,7 @@
<tr
t-foreach="currency['lines']"
t-as="line"
t-att-class="('statement-blocked ' if line['blocked'] else '') + ('statement-reconciled' if line['reconciled_line'] else '')"
t-att-class="('statement-blocked ' if line['blocked'] else '') + ('statement-reconciled ' if line['reconciled_line'] else '') + ('statement-outside-date-rank' if line['outside-date-rank'] else '')"
>
<td>
<span

View File

@@ -27,7 +27,7 @@ class ActivityStatementWizard(models.TransientModel):
if self.aging_type == "months":
self.date_start = self.date_end.replace(day=1)
else:
self.date_start = self.date_end - relativedelta(days=30)
self.date_start = self.date_end - relativedelta(months=1)
return res
def _prepare_statement(self):
@@ -47,7 +47,7 @@ class ActivityStatementWizard(models.TransientModel):
report_name = "p_s.report_activity_statement_xlsx"
else:
report_name = "partner_statement.activity_statement"
partners = self.env["res.partner"].browse(self._context["active_ids"])
partners = self.env["res.partner"].browse(data["partner_ids"])
return (
self.env["ir.actions.report"]
.search(

View File

@@ -30,7 +30,7 @@ class DetailedActivityStatementWizard(models.TransientModel):
report_name = "p_s.report_detailed_activity_statement_xlsx"
else:
report_name = "partner_statement.detailed_activity_statement"
partners = self.env["res.partner"].browse(self._context["active_ids"])
partners = self.env["res.partner"].browse(data["partner_ids"])
return (
self.env["ir.actions.report"]
.search(

View File

@@ -27,7 +27,7 @@ class OutstandingStatementWizard(models.TransientModel):
report_name = "p_s.report_outstanding_statement_xlsx"
else:
report_name = "partner_statement.outstanding_statement"
partners = self.env["res.partner"].browse(self._context["active_ids"])
partners = self.env["res.partner"].browse(data["partner_ids"])
return (
self.env["ir.actions.report"]
.search(