Skip to content

Commit

Permalink
[IMP] account_liquidity_forecast: Improvements in report formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
JasminSForgeFlow committed May 2, 2024
1 parent f492c24 commit a5c8856
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
2 changes: 1 addition & 1 deletion account_liquidity_forecast/models/account_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def _get_open_items_at_date(self, date, only_posted_moves):
return []
move_states = ["posted"]

Check warning on line 13 in account_liquidity_forecast/models/account_account.py

View check run for this annotation

Codecov / codecov/patch

account_liquidity_forecast/models/account_account.py#L12-L13

Added lines #L12 - L13 were not covered by tests
if not only_posted_moves:
move_states.append(["draft"])
move_states.append("draft")
query = """

Check warning on line 16 in account_liquidity_forecast/models/account_account.py

View check run for this annotation

Codecov / codecov/patch

account_liquidity_forecast/models/account_account.py#L15-L16

Added lines #L15 - L16 were not covered by tests
SELECT
L.ID AS LINE_ID,
Expand Down
39 changes: 25 additions & 14 deletions account_liquidity_forecast/report/liquidity_forecast_xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,22 @@ def _get_report_name(self, report, data=False):
report_name = report_name + suffix
return report_name

Check warning on line 34 in account_liquidity_forecast/report/liquidity_forecast_xlsx.py

View check run for this annotation

Codecov / codecov/patch

account_liquidity_forecast/report/liquidity_forecast_xlsx.py#L31-L34

Added lines #L31 - L34 were not covered by tests

def excel_column_name(self, column_number):
alphabet = ""

Check warning on line 37 in account_liquidity_forecast/report/liquidity_forecast_xlsx.py

View check run for this annotation

Codecov / codecov/patch

account_liquidity_forecast/report/liquidity_forecast_xlsx.py#L37

Added line #L37 was not covered by tests
while column_number > 0:
remainder = (column_number - 1) % 26
alphabet = chr(65 + remainder) + alphabet
column_number = (column_number - 1) // 26
return alphabet

Check warning on line 42 in account_liquidity_forecast/report/liquidity_forecast_xlsx.py

View check run for this annotation

Codecov / codecov/patch

account_liquidity_forecast/report/liquidity_forecast_xlsx.py#L39-L42

Added lines #L39 - L42 were not covered by tests

def _size_columns(self, sheet, total_col_count, data):
for i in range(total_col_count + 1):
sheet.set_column(0, i, 15)
if i == 0:
sheet.set_column("A:A", 30)

Check warning on line 47 in account_liquidity_forecast/report/liquidity_forecast_xlsx.py

View check run for this annotation

Codecov / codecov/patch

account_liquidity_forecast/report/liquidity_forecast_xlsx.py#L47

Added line #L47 was not covered by tests
else:
sheet.set_column(

Check warning on line 49 in account_liquidity_forecast/report/liquidity_forecast_xlsx.py

View check run for this annotation

Codecov / codecov/patch

account_liquidity_forecast/report/liquidity_forecast_xlsx.py#L49

Added line #L49 was not covered by tests
"%(col)s:%(col)s" % ({"col": self.excel_column_name(i + 1)}), 15
)

def generate_xlsx_report(self, workbook, data, objects):
self._define_formats(workbook)
Expand All @@ -59,11 +72,9 @@ def generate_xlsx_report(self, workbook, data, objects):
money_string = "[${}]".format(currency.symbol) + " #,##0.%s" % (

Check warning on line 72 in account_liquidity_forecast/report/liquidity_forecast_xlsx.py

View check run for this annotation

Codecov / codecov/patch

account_liquidity_forecast/report/liquidity_forecast_xlsx.py#L72

Added line #L72 was not covered by tests
"0" * currency.decimal_places
)
FORMATS["money_format"] = workbook.add_format(
{"align": "center", "num_format": money_string}
)
FORMATS["money_format"] = workbook.add_format({"num_format": money_string})
FORMATS["money_format_bold"] = workbook.add_format(

Check warning on line 76 in account_liquidity_forecast/report/liquidity_forecast_xlsx.py

View check run for this annotation

Codecov / codecov/patch

account_liquidity_forecast/report/liquidity_forecast_xlsx.py#L75-L76

Added lines #L75 - L76 were not covered by tests
{"align": "center", "num_format": money_string, "bold": True}
{"num_format": money_string, "bold": True}
)
FORMATS["format_center_bold"].text_wrap = 1
FORMATS["format_center"].text_wrap = 1
Expand All @@ -76,7 +87,7 @@ def generate_xlsx_report(self, workbook, data, objects):
row_pos,
0,
row_pos,
total_col_count,
4,
_("Liquidity Forecast - %(company_name)s - %(currency_name)s")
% (
{
Expand All @@ -91,15 +102,15 @@ def generate_xlsx_report(self, workbook, data, objects):
row_pos,
0,
row_pos,
int(total_col_count / 2) + 1,
2,
_("Date range filter"),
FORMATS["format_theader_yellow_center"],
)
sheet.merge_range(

Check warning on line 109 in account_liquidity_forecast/report/liquidity_forecast_xlsx.py

View check run for this annotation

Codecov / codecov/patch

account_liquidity_forecast/report/liquidity_forecast_xlsx.py#L109

Added line #L109 was not covered by tests
row_pos,
int(total_col_count / 2) + 2,
3,
row_pos,
total_col_count,
4,
_("Target moves filter"),
FORMATS["format_theader_yellow_center"],
)
Expand All @@ -108,15 +119,15 @@ def generate_xlsx_report(self, workbook, data, objects):
row_pos,
0,
row_pos,
int(total_col_count / 2) + 1,
2,
"From %s To %s" % (report_data["date_from"], report_data["date_to"]),
FORMATS["format_center"],
)
sheet.merge_range(

Check warning on line 126 in account_liquidity_forecast/report/liquidity_forecast_xlsx.py

View check run for this annotation

Codecov / codecov/patch

account_liquidity_forecast/report/liquidity_forecast_xlsx.py#L126

Added line #L126 was not covered by tests
row_pos,
int(total_col_count / 2) + 2,
3,
row_pos,
total_col_count,
4,
"All posted entries" if report_data["only_posted_moves"] else "All entries",
FORMATS["format_center"],
)
Expand All @@ -143,9 +154,9 @@ def generate_xlsx_report(self, workbook, data, objects):
0,
line["title"],
(
FORMATS["format_center_bold"]
FORMATS["format_left_bold"]
if line.get("level") == "heading"
else FORMATS["format_center"]
else FORMATS["format_left"]
),
)
col = 1

Check warning on line 162 in account_liquidity_forecast/report/liquidity_forecast_xlsx.py

View check run for this annotation

Codecov / codecov/patch

account_liquidity_forecast/report/liquidity_forecast_xlsx.py#L162

Added line #L162 was not covered by tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@
<!--## Period-->
<t t-foreach="periods" t-as="period">
<t t-if="line['type'] == 'amount'">
<div class="act_as_cell" t-att-style="style">
<div class="act_as_cell left" t-att-style="style">
<t t-if="line['periods'][period['sequence']]['domain']">
<t
<t
t-set="domain"
t-value="line['periods'][period['sequence']]['domain']"
/>
Expand Down
2 changes: 1 addition & 1 deletion account_liquidity_forecast/reports.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<field name="format">custom</field>
<field name="page_height">297</field>
<field name="page_width">210</field>
<field name="orientation">Portrait</field>
<field name="orientation">Landscape</field>
<field name="margin_top">12</field>
<field name="margin_bottom">8</field>
<field name="margin_left">5</field>
Expand Down

0 comments on commit a5c8856

Please sign in to comment.