[15.0][FIX] account_financial_report: Fix intervals calculations
parent
ed6afe5f3c
commit
28ee17994a
|
@ -1841,7 +1841,6 @@ msgid "future"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: account_financial_report
|
#. 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.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.journal_ledger_wizard
|
||||||
#: model_terms:ir.ui.view,arch_db:account_financial_report.open_items_wizard
|
#: model_terms:ir.ui.view,arch_db:account_financial_report.open_items_wizard
|
||||||
|
|
|
@ -1869,7 +1869,6 @@ msgid "future"
|
||||||
msgstr "futuro"
|
msgstr "futuro"
|
||||||
|
|
||||||
#. module: account_financial_report
|
#. 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.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.journal_ledger_wizard
|
||||||
#: model_terms:ir.ui.view,arch_db:account_financial_report.open_items_wizard
|
#: model_terms:ir.ui.view,arch_db:account_financial_report.open_items_wizard
|
||||||
|
|
|
@ -71,26 +71,29 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
||||||
else:
|
else:
|
||||||
ag_pb_data[acc_id]["older"] += residual
|
ag_pb_data[acc_id]["older"] += residual
|
||||||
ag_pb_data[acc_id][prt_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):
|
for index, line in enumerate(interval_lines):
|
||||||
next_line = (
|
lower_limit = 0 if not index else interval_lines[index - 1].inferior_limit
|
||||||
interval_lines[index + 1] if index + 1 < len(interval_lines) else None
|
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 (
|
if (
|
||||||
due_date
|
days_difference in interval_range
|
||||||
and next_line
|
or days_difference == line.inferior_limit
|
||||||
and today > due_date
|
|
||||||
and today >= due_date + timedelta(days=lower_limit)
|
|
||||||
and today < due_date + timedelta(days=next_line.inferior_limit)
|
|
||||||
):
|
):
|
||||||
ag_pb_data[acc_id][line] += residual
|
ag_pb_data[acc_id][line] += residual
|
||||||
ag_pb_data[acc_id][prt_id][line] += residual
|
ag_pb_data[acc_id][prt_id][line] += residual
|
||||||
if not next_line and due_date:
|
break
|
||||||
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
|
|
||||||
return ag_pb_data
|
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):
|
def _get_account_partial_reconciled(self, company_id, date_at_object):
|
||||||
domain = [("max_date", ">", date_at_object), ("company_id", "=", company_id)]
|
domain = [("max_date", ">", date_at_object), ("company_id", "=", company_id)]
|
||||||
fields = [
|
fields = [
|
||||||
|
@ -276,27 +279,19 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
||||||
ml["120_days"] += amount
|
ml["120_days"] += amount
|
||||||
else:
|
else:
|
||||||
ml["older"] += amount
|
ml["older"] += amount
|
||||||
|
days_difference = abs((today - due_date).days)
|
||||||
for index, interval_line in enumerate(interval_lines):
|
for index, interval_line in enumerate(interval_lines):
|
||||||
next_line = (
|
lower_limit = 0 if not index else interval_lines[index - 1].inferior_limit
|
||||||
interval_lines[index + 1] if index + 1 < len(interval_lines) else None
|
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 (
|
if (
|
||||||
due_date
|
days_difference in interval_range
|
||||||
and (
|
or days_difference == interval_line.inferior_limit
|
||||||
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)
|
|
||||||
)
|
|
||||||
):
|
):
|
||||||
ml[interval_line] += amount
|
ml[interval_line] += amount
|
||||||
|
break
|
||||||
|
|
||||||
def _create_account_list(
|
def _create_account_list(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -70,19 +70,16 @@
|
||||||
default_focus="1"
|
default_focus="1"
|
||||||
class="oe_highlight"
|
class="oe_highlight"
|
||||||
/>
|
/>
|
||||||
or
|
|
||||||
<button
|
<button
|
||||||
name="button_export_pdf"
|
name="button_export_pdf"
|
||||||
string="Export PDF"
|
string="Export PDF"
|
||||||
type="object"
|
type="object"
|
||||||
/>
|
/>
|
||||||
or
|
|
||||||
<button
|
<button
|
||||||
name="button_export_xlsx"
|
name="button_export_xlsx"
|
||||||
string="Export XLSX"
|
string="Export XLSX"
|
||||||
type="object"
|
type="object"
|
||||||
/>
|
/>
|
||||||
or
|
|
||||||
<button string="Cancel" class="oe_link" special="cancel" />
|
<button string="Cancel" class="oe_link" special="cancel" />
|
||||||
</footer>
|
</footer>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in New Issue