Skip to content

Commit

Permalink
[IMP] account_financial_report: black, isort, prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
tupaq committed Oct 11, 2020
1 parent 42a1c2e commit c18e0db
Show file tree
Hide file tree
Showing 22 changed files with 352 additions and 290 deletions.
65 changes: 32 additions & 33 deletions account_financial_report/report/abstract_report_xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def generate_xlsx_report(self, workbook, data, objects):
self._write_report_footer(report_footer)

def _define_formats(self, workbook):
""" Add cell formats to current workbook.
"""Add cell formats to current workbook.
Those formats can be used on all cell.
Available formats are :
* format_bold
Expand Down Expand Up @@ -237,8 +237,7 @@ def write_line(self, line_object):
self.row_pos += 1

def write_line_from_dict(self, line_dict):
"""Write a line on current line
"""
"""Write a line on current line"""
for col_pos, column in self.columns.items():
value = line_dict.get(column["field"], False)
cell_type = column.get("type", "string")
Expand Down Expand Up @@ -528,7 +527,7 @@ def _get_currency_amt_header_format_dict(self, line_object):

def _generate_report_content(self, workbook, report, data):
"""
Allow to fetch report content to be displayed.
Allow to fetch report content to be displayed.
"""
raise NotImplementedError()

Expand All @@ -542,74 +541,74 @@ def _get_report_complete_name(self, report, prefix, data=None):

def _get_report_name(self, report, data=False):
"""
Allow to define the report name.
Report name will be used as sheet name and as report title.
:return: the report name
Allow to define the report name.
Report name will be used as sheet name and as report title.
:return: the report name
"""
raise NotImplementedError()

def _get_report_footer(self):
"""
Allow to define the report footer.
:return: the report footer
Allow to define the report footer.
:return: the report footer
"""
return False

def _get_report_columns(self, report):
"""
Allow to define the report columns
which will be used to generate report.
:return: the report columns as dict
:Example:
{
0: {'header': 'Simple column',
'field': 'field_name_on_my_object',
'width': 11},
1: {'header': 'Amount column',
'field': 'field_name_on_my_object',
'type': 'amount',
'width': 14},
}
Allow to define the report columns
which will be used to generate report.
:return: the report columns as dict
:Example:
{
0: {'header': 'Simple column',
'field': 'field_name_on_my_object',
'width': 11},
1: {'header': 'Amount column',
'field': 'field_name_on_my_object',
'type': 'amount',
'width': 14},
}
"""
raise NotImplementedError()

def _get_report_filters(self, report):
"""
:return: the report filters as list
:Example:
[
['first_filter_name', 'first_filter_value'],
['second_filter_name', 'second_filter_value']
]
:return: the report filters as list
:Example:
[
['first_filter_name', 'first_filter_value'],
['second_filter_name', 'second_filter_value']
]
"""
raise NotImplementedError()

def _get_col_count_filter_name(self):
"""
:return: the columns number used for filter names.
:return: the columns number used for filter names.
"""
raise NotImplementedError()

def _get_col_count_filter_value(self):
"""
:return: the columns number used for filter values.
:return: the columns number used for filter values.
"""
raise NotImplementedError()

def _get_col_pos_initial_balance_label(self):
"""
:return: the columns position used for initial balance label.
:return: the columns position used for initial balance label.
"""
raise NotImplementedError()

def _get_col_count_final_balance_name(self):
"""
:return: the columns number used for final balance name.
:return: the columns number used for final balance name.
"""
raise NotImplementedError()

def _get_col_pos_final_balance_label(self):
"""
:return: the columns position used for final balance label.
:return: the columns position used for final balance label.
"""
raise NotImplementedError()
6 changes: 3 additions & 3 deletions account_financial_report/report/aged_partner_balance_xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ def _generate_report_content(self, workbook, report, data):

def write_ending_balance_from_dict(self, my_object):
"""
Specific function to write ending partner balance
for Aged Partner Balance
Specific function to write ending partner balance
for Aged Partner Balance
"""
name = None
label = _("Partner cumul aged balance")
Expand All @@ -288,7 +288,7 @@ def write_account_footer_from_dict(
amount_is_percent,
):
"""
Specific function to write account footer for Aged Partner Balance
Specific function to write account footer for Aged Partner Balance
"""
col_pos_footer_label = self._get_col_pos_footer_label(report)
for col_pos, column in self.columns.items():
Expand Down
8 changes: 6 additions & 2 deletions account_financial_report/report/general_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,12 +748,16 @@ def _get_centralized_ml(self, account, date_to):
for partner in account["list_partner"]:
for move_line in partner["move_lines"]:
centralized_ml = self._calculate_centralization(
centralized_ml, move_line, date_to,
centralized_ml,
move_line,
date_to,
)
else:
for move_line in account["move_lines"]:
centralized_ml = self._calculate_centralization(
centralized_ml, move_line, date_to,
centralized_ml,
move_line,
date_to,
)
list_centralized_ml = []
for jnl_id in centralized_ml.keys():
Expand Down
18 changes: 14 additions & 4 deletions account_financial_report/report/general_ledger_xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ def _generate_report_content(self, workbook, report, data):
for tag_id in line["tag_ids"]:
tags += tags_data[tag_id]["name"] + " "
line.update(
{"taxes_description": taxes_description, "tags": tags,}
{
"taxes_description": taxes_description,
"tags": tags,
}
)
self.write_line_from_dict(line)
# Display ending balance line for account
Expand All @@ -208,7 +211,9 @@ def _generate_report_content(self, workbook, report, data):
)
if foreign_currency:
account.update(
{"final_bal_curr": account["fin_bal"]["bal_curr"],}
{
"final_bal_curr": account["fin_bal"]["bal_curr"],
}
)
self.write_ending_balance_from_dict(account)

Expand All @@ -234,7 +239,9 @@ def _generate_report_content(self, workbook, report, data):
)
if foreign_currency:
partner.update(
{"initial_bal_curr": partner["init_bal"]["bal_curr"],}
{
"initial_bal_curr": partner["init_bal"]["bal_curr"],
}
)
self.write_initial_balance_from_dict(partner)

Expand Down Expand Up @@ -263,7 +270,10 @@ def _generate_report_content(self, workbook, report, data):
for tag_id in line["tag_ids"]:
tags += tags_data[tag_id]["name"] + " "
line.update(
{"taxes_description": taxes_description, "tags": tags,}
{
"taxes_description": taxes_description,
"tags": tags,
}
)
self.write_line_from_dict(line)

Expand Down
Loading

0 comments on commit c18e0db

Please sign in to comment.