[15.0][FIX] account_financial_report: Fix intervals calculations

pull/1146/head
Carolina Fernandez 2024-04-15 11:07:29 +02:00
parent ed6afe5f3c
commit 28ee17994a
4 changed files with 23 additions and 33 deletions

View File

@ -1841,7 +1841,6 @@ msgid "future"
msgstr ""
#. module: account_financial_report
#: model_terms:ir.ui.view,arch_db:account_financial_report.aged_partner_balance_wizard
#: model_terms:ir.ui.view,arch_db:account_financial_report.general_ledger_wizard
#: model_terms:ir.ui.view,arch_db:account_financial_report.journal_ledger_wizard
#: model_terms:ir.ui.view,arch_db:account_financial_report.open_items_wizard

View File

@ -1869,7 +1869,6 @@ msgid "future"
msgstr "futuro"
#. module: account_financial_report
#: model_terms:ir.ui.view,arch_db:account_financial_report.aged_partner_balance_wizard
#: model_terms:ir.ui.view,arch_db:account_financial_report.general_ledger_wizard
#: model_terms:ir.ui.view,arch_db:account_financial_report.journal_ledger_wizard
#: model_terms:ir.ui.view,arch_db:account_financial_report.open_items_wizard

View File

@ -71,26 +71,29 @@ class AgedPartnerBalanceReport(models.AbstractModel):
else:
ag_pb_data[acc_id]["older"] += residual
ag_pb_data[acc_id][prt_id]["older"] += residual
days_difference = abs((today - due_date).days)
for index, line in enumerate(interval_lines):
next_line = (
interval_lines[index + 1] if index + 1 < len(interval_lines) else None
lower_limit = 0 if not index else interval_lines[index - 1].inferior_limit
next_line = interval_lines[index] if index < len(interval_lines) else None
interval_range = self._get_values_for_range_intervals(
lower_limit, next_line.inferior_limit
)
lower_limit = 0 if not index else line.inferior_limit
if (
due_date
and next_line
and today > due_date
and today >= due_date + timedelta(days=lower_limit)
and today < due_date + timedelta(days=next_line.inferior_limit)
days_difference in interval_range
or days_difference == line.inferior_limit
):
ag_pb_data[acc_id][line] += residual
ag_pb_data[acc_id][prt_id][line] += residual
if not next_line and due_date:
if today >= due_date + timedelta(days=line.inferior_limit):
ag_pb_data[acc_id][line] += residual
ag_pb_data[acc_id][prt_id][line] += residual
break
return ag_pb_data
def _get_values_for_range_intervals(self, num1, num2):
min_num = min(num1, num2)
max_num = max(num1, num2)
if abs(num2 - num1) == 1:
return [max_num]
return list(range(min_num + 1, max_num))
def _get_account_partial_reconciled(self, company_id, date_at_object):
domain = [("max_date", ">", date_at_object), ("company_id", "=", company_id)]
fields = [
@ -276,27 +279,19 @@ class AgedPartnerBalanceReport(models.AbstractModel):
ml["120_days"] += amount
else:
ml["older"] += amount
days_difference = abs((today - due_date).days)
for index, interval_line in enumerate(interval_lines):
next_line = (
interval_lines[index + 1] if index + 1 < len(interval_lines) else None
lower_limit = 0 if not index else interval_lines[index - 1].inferior_limit
next_line = interval_lines[index] if index < len(interval_lines) else None
interval_range = self._get_values_for_range_intervals(
lower_limit, next_line.inferior_limit
)
upper_limit = next_line.inferior_limit if next_line else None
if (
due_date
and (
next_line
and today > due_date
and today >= due_date + timedelta(days=interval_line.inferior_limit)
and today < due_date + timedelta(days=upper_limit)
)
or (
not next_line
and today >= due_date + timedelta(days=interval_line.inferior_limit)
)
days_difference in interval_range
or days_difference == interval_line.inferior_limit
):
ml[interval_line] += amount
break
def _create_account_list(
self,

View File

@ -70,19 +70,16 @@
default_focus="1"
class="oe_highlight"
/>
or
<button
name="button_export_pdf"
string="Export PDF"
type="object"
/>
or
<button
name="button_export_xlsx"
string="Export XLSX"
type="object"
/>
or
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>