[REF] partner_statement: Allow to override XLSX structure (2nd part)
This commit is contained in:
@@ -33,6 +33,197 @@ class ActivityStatementXslx(models.AbstractModel):
|
|||||||
report_name = report_name + suffix
|
report_name = report_name + suffix
|
||||||
return report_name
|
return report_name
|
||||||
|
|
||||||
|
def _get_currency_header_row_data(self, partner, currency, data):
|
||||||
|
return (
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"col_pos": col_pos,
|
||||||
|
"sheet_func": "write",
|
||||||
|
"args": args,
|
||||||
|
}
|
||||||
|
for col_pos, args in enumerate(
|
||||||
|
[
|
||||||
|
(
|
||||||
|
_("Reference Number"),
|
||||||
|
FORMATS["format_theader_yellow_center"],
|
||||||
|
),
|
||||||
|
(_("Date"), FORMATS["format_theader_yellow_center"]),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
+ [
|
||||||
|
{
|
||||||
|
"col_pos": 2,
|
||||||
|
"sheet_func": "merge_range",
|
||||||
|
"span": 1,
|
||||||
|
"args": (_("Description"), FORMATS["format_theader_yellow_center"]),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
+ [
|
||||||
|
{
|
||||||
|
"col_pos": col_pos,
|
||||||
|
"sheet_func": "write",
|
||||||
|
"args": args,
|
||||||
|
}
|
||||||
|
for col_pos, args in enumerate(
|
||||||
|
[
|
||||||
|
(_("Original Amount"), FORMATS["format_theader_yellow_center"]),
|
||||||
|
(_("Applied Amount"), FORMATS["format_theader_yellow_center"]),
|
||||||
|
(_("Open Amount"), FORMATS["format_theader_yellow_center"]),
|
||||||
|
],
|
||||||
|
4,
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
def _get_currency_subheader_row_data(self, partner, currency, data):
|
||||||
|
partner_data = data.get("data", {}).get(partner.id, {})
|
||||||
|
currency_data = partner_data.get("currencies", {}).get(currency.id)
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"col_pos": 1,
|
||||||
|
"sheet_func": "write",
|
||||||
|
"args": (
|
||||||
|
partner_data.get("prior_day"),
|
||||||
|
FORMATS["format_tcell_date_left"],
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"col_pos": 2,
|
||||||
|
"sheet_func": "merge_range",
|
||||||
|
"span": 3,
|
||||||
|
"args": (_("Balance Forward"), FORMATS["format_tcell_left"]),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"col_pos": 6,
|
||||||
|
"sheet_func": "write",
|
||||||
|
"args": (
|
||||||
|
currency_data.get("balance_forward"),
|
||||||
|
FORMATS["current_money_format"],
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
def _get_currency_line_row_data(self, partner, currency, data, line):
|
||||||
|
if line.get("blocked"):
|
||||||
|
format_tcell_left = FORMATS["format_tcell_left_blocked"]
|
||||||
|
format_tcell_date_left = FORMATS["format_tcell_date_left_blocked"]
|
||||||
|
format_distributed = FORMATS["format_distributed_blocked"]
|
||||||
|
current_money_format = FORMATS["current_money_format_blocked"]
|
||||||
|
else:
|
||||||
|
format_tcell_left = FORMATS["format_tcell_left"]
|
||||||
|
format_tcell_date_left = FORMATS["format_tcell_date_left"]
|
||||||
|
format_distributed = FORMATS["format_distributed"]
|
||||||
|
current_money_format = FORMATS["current_money_format"]
|
||||||
|
name_to_show = (
|
||||||
|
line.get("name", "") == "/" or not line.get("name", "")
|
||||||
|
) and line.get("ref", "")
|
||||||
|
if line.get("name", "") and line.get("name", "") != "/":
|
||||||
|
if not line.get("ref", ""):
|
||||||
|
name_to_show = line.get("name", "")
|
||||||
|
else:
|
||||||
|
if (line.get("name", "") in line.get("ref", "")) or (
|
||||||
|
line.get("name", "") == line.get("ref", "")
|
||||||
|
):
|
||||||
|
name_to_show = line.get("name", "")
|
||||||
|
elif line.get("ref", "") not in line.get("name", ""):
|
||||||
|
name_to_show = line.get("ref", "")
|
||||||
|
return (
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"col_pos": col_pos,
|
||||||
|
"sheet_func": "write",
|
||||||
|
"args": args,
|
||||||
|
}
|
||||||
|
for col_pos, args in enumerate(
|
||||||
|
[
|
||||||
|
(line.get("move_id", ""), format_tcell_left),
|
||||||
|
(line.get("date", ""), format_tcell_date_left),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
+ [
|
||||||
|
{
|
||||||
|
"col_pos": 2,
|
||||||
|
"sheet_func": "merge_range",
|
||||||
|
"span": 1,
|
||||||
|
"args": (name_to_show, format_distributed),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
+ [
|
||||||
|
{
|
||||||
|
"col_pos": col_pos,
|
||||||
|
"sheet_func": "write",
|
||||||
|
"args": args,
|
||||||
|
}
|
||||||
|
for col_pos, args in enumerate(
|
||||||
|
[
|
||||||
|
(line.get("amount", ""), current_money_format),
|
||||||
|
(line.get("applied_amount", ""), current_money_format),
|
||||||
|
(line.get("open_amount", ""), current_money_format),
|
||||||
|
],
|
||||||
|
4,
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
def _get_currency_footer_row_data(self, partner, currency, data):
|
||||||
|
partner_data = data.get("data", {}).get(partner.id, {})
|
||||||
|
currency_data = partner_data.get("currencies", {}).get(currency.id)
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"col_pos": 1,
|
||||||
|
"sheet_func": "write",
|
||||||
|
"args": (partner_data.get("end"), FORMATS["format_tcell_date_left"]),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"col_pos": 2,
|
||||||
|
"sheet_func": "merge_range",
|
||||||
|
"span": 3,
|
||||||
|
"args": (_("Ending Balance"), FORMATS["format_tcell_left"]),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"col_pos": 6,
|
||||||
|
"sheet_func": "write",
|
||||||
|
"args": (
|
||||||
|
currency_data.get("amount_due"),
|
||||||
|
FORMATS["current_money_format"],
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
def _write_row_data(self, sheet, row_pos, row_data):
|
||||||
|
for cell_data in row_data:
|
||||||
|
sheet_func_name = cell_data.get("sheet_func", "")
|
||||||
|
sheet_func = getattr(sheet, sheet_func_name, None)
|
||||||
|
if callable(sheet_func):
|
||||||
|
col_pos = cell_data["col_pos"]
|
||||||
|
args = cell_data["args"]
|
||||||
|
span = cell_data.get("span")
|
||||||
|
if span:
|
||||||
|
args = row_pos, col_pos + span, *args
|
||||||
|
sheet_func(row_pos, col_pos, *args)
|
||||||
|
|
||||||
|
def _write_currency_header(self, row_pos, sheet, partner, currency, data):
|
||||||
|
row_data = self._get_currency_header_row_data(partner, currency, data)
|
||||||
|
self._write_row_data(sheet, row_pos, row_data)
|
||||||
|
return row_pos
|
||||||
|
|
||||||
|
def _write_currency_subheader(self, row_pos, sheet, partner, currency, data):
|
||||||
|
row_data = self._get_currency_subheader_row_data(partner, currency, data)
|
||||||
|
self._write_row_data(sheet, row_pos, row_data)
|
||||||
|
return row_pos
|
||||||
|
|
||||||
|
def _write_currency_line(self, row_pos, sheet, partner, currency, data, line):
|
||||||
|
row_data = self._get_currency_line_row_data(partner, currency, data, line)
|
||||||
|
self._write_row_data(sheet, row_pos, row_data)
|
||||||
|
return row_pos
|
||||||
|
|
||||||
|
def _write_currency_footer(self, row_pos, sheet, partner, currency, data):
|
||||||
|
row_data = self._get_currency_footer_row_data(partner, currency, data)
|
||||||
|
self._write_row_data(sheet, row_pos, row_data)
|
||||||
|
return row_pos
|
||||||
|
|
||||||
def _write_currency_lines(self, row_pos, sheet, partner, currency, data):
|
def _write_currency_lines(self, row_pos, sheet, partner, currency, data):
|
||||||
partner_data = data.get("data", {}).get(partner.id, {})
|
partner_data = data.get("data", {}).get(partner.id, {})
|
||||||
currency_data = partner_data.get("currencies", {}).get(currency.id)
|
currency_data = partner_data.get("currencies", {}).get(currency.id)
|
||||||
@@ -50,85 +241,18 @@ class ActivityStatementXslx(models.AbstractModel):
|
|||||||
row_pos, 0, row_pos, 6, statement_header, FORMATS["format_left_bold"]
|
row_pos, 0, row_pos, 6, statement_header, FORMATS["format_left_bold"]
|
||||||
)
|
)
|
||||||
row_pos += 1
|
row_pos += 1
|
||||||
sheet.write(
|
row_pos = self._write_currency_header(row_pos, sheet, partner, currency, data)
|
||||||
row_pos, 0, _("Reference Number"), FORMATS["format_theader_yellow_center"]
|
|
||||||
)
|
|
||||||
sheet.write(row_pos, 1, _("Date"), FORMATS["format_theader_yellow_center"])
|
|
||||||
sheet.merge_range(
|
|
||||||
row_pos,
|
|
||||||
2,
|
|
||||||
row_pos,
|
|
||||||
3,
|
|
||||||
_("Description"),
|
|
||||||
FORMATS["format_theader_yellow_center"],
|
|
||||||
)
|
|
||||||
sheet.write(
|
|
||||||
row_pos, 4, _("Original Amount"), FORMATS["format_theader_yellow_center"]
|
|
||||||
)
|
|
||||||
sheet.write(
|
|
||||||
row_pos, 5, _("Applied Amount"), FORMATS["format_theader_yellow_center"]
|
|
||||||
)
|
|
||||||
sheet.write(
|
|
||||||
row_pos, 6, _("Open Amount"), FORMATS["format_theader_yellow_center"]
|
|
||||||
)
|
|
||||||
row_pos += 1
|
row_pos += 1
|
||||||
sheet.write(
|
row_pos = self._write_currency_subheader(
|
||||||
row_pos, 1, partner_data.get("prior_day"), FORMATS["format_tcell_date_left"]
|
row_pos, sheet, partner, currency, data
|
||||||
)
|
)
|
||||||
sheet.merge_range(
|
|
||||||
row_pos, 2, row_pos, 5, _("Balance Forward"), FORMATS["format_tcell_left"]
|
|
||||||
)
|
|
||||||
sheet.write(
|
|
||||||
row_pos,
|
|
||||||
6,
|
|
||||||
currency_data.get("balance_forward"),
|
|
||||||
FORMATS["current_money_format"],
|
|
||||||
)
|
|
||||||
format_tcell_left = FORMATS["format_tcell_left"]
|
|
||||||
format_tcell_date_left = FORMATS["format_tcell_date_left"]
|
|
||||||
format_distributed = FORMATS["format_distributed"]
|
|
||||||
current_money_format = FORMATS["current_money_format"]
|
|
||||||
for line in currency_data.get("lines"):
|
for line in currency_data.get("lines"):
|
||||||
if line.get("blocked"):
|
|
||||||
format_tcell_left = FORMATS["format_tcell_left_blocked"]
|
|
||||||
format_tcell_date_left = FORMATS["format_tcell_date_left_blocked"]
|
|
||||||
format_distributed = FORMATS["format_distributed_blocked"]
|
|
||||||
current_money_format = FORMATS["current_money_format_blocked"]
|
|
||||||
row_pos += 1
|
row_pos += 1
|
||||||
name_to_show = (
|
row_pos = self._write_currency_line(
|
||||||
line.get("name", "") == "/" or not line.get("name", "")
|
row_pos, sheet, partner, currency, data, line
|
||||||
) and line.get("ref", "")
|
|
||||||
if line.get("name", "") and line.get("name", "") != "/":
|
|
||||||
if not line.get("ref", ""):
|
|
||||||
name_to_show = line.get("name", "")
|
|
||||||
else:
|
|
||||||
if (line.get("name", "") in line.get("ref", "")) or (
|
|
||||||
line.get("name", "") == line.get("ref", "")
|
|
||||||
):
|
|
||||||
name_to_show = line.get("name", "")
|
|
||||||
elif line.get("ref", "") not in line.get("name", ""):
|
|
||||||
name_to_show = line.get("ref", "")
|
|
||||||
sheet.write(row_pos, 0, line.get("move_id", ""), format_tcell_left)
|
|
||||||
sheet.write(row_pos, 1, line.get("date", ""), format_tcell_date_left)
|
|
||||||
sheet.merge_range(row_pos, 2, row_pos, 3, name_to_show, format_distributed)
|
|
||||||
sheet.write(row_pos, 4, line.get("amount", ""), current_money_format)
|
|
||||||
sheet.write(
|
|
||||||
row_pos, 5, line.get("applied_amount", ""), current_money_format
|
|
||||||
)
|
)
|
||||||
sheet.write(row_pos, 6, line.get("open_amount", ""), current_money_format)
|
|
||||||
row_pos += 1
|
row_pos += 1
|
||||||
sheet.write(
|
row_pos = self._write_currency_footer(row_pos, sheet, partner, currency, data)
|
||||||
row_pos, 1, partner_data.get("end"), FORMATS["format_tcell_date_left"]
|
|
||||||
)
|
|
||||||
sheet.merge_range(
|
|
||||||
row_pos, 2, row_pos, 5, _("Ending Balance"), FORMATS["format_tcell_left"]
|
|
||||||
)
|
|
||||||
sheet.write(
|
|
||||||
row_pos,
|
|
||||||
6,
|
|
||||||
currency_data.get("amount_due"),
|
|
||||||
FORMATS["current_money_format"],
|
|
||||||
)
|
|
||||||
return row_pos
|
return row_pos
|
||||||
|
|
||||||
def _write_currency_buckets(self, row_pos, sheet, partner, currency, data):
|
def _write_currency_buckets(self, row_pos, sheet, partner, currency, data):
|
||||||
|
|||||||
@@ -35,6 +35,161 @@ class DetailedActivityStatementXslx(models.AbstractModel):
|
|||||||
report_name = report_name + suffix
|
report_name = report_name + suffix
|
||||||
return report_name
|
return report_name
|
||||||
|
|
||||||
|
def _get_currency_subheader_row_data(self, partner, currency, data):
|
||||||
|
partner_data = data.get("data", {}).get(partner.id, {})
|
||||||
|
currency_data = partner_data.get("currencies", {}).get(currency.id)
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"col_pos": 1,
|
||||||
|
"sheet_func": "write",
|
||||||
|
"args": (
|
||||||
|
partner_data.get("prior_day"),
|
||||||
|
FORMATS["format_tcell_date_left"],
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"col_pos": 2,
|
||||||
|
"sheet_func": "merge_range",
|
||||||
|
"span": 3,
|
||||||
|
"args": (_("Initial Balance"), FORMATS["format_tcell_left"]),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"col_pos": 6,
|
||||||
|
"sheet_func": "write",
|
||||||
|
"args": (
|
||||||
|
currency_data.get("balance_forward"),
|
||||||
|
FORMATS["current_money_format"],
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
def _get_currency_line_row_data(self, partner, currency, data, line):
|
||||||
|
if line.get("blocked") and not line.get("reconciled_line"):
|
||||||
|
format_tcell_left = FORMATS["format_tcell_left_blocked"]
|
||||||
|
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")
|
||||||
|
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")
|
||||||
|
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"
|
||||||
|
]
|
||||||
|
format_distributed = FORMATS["format_distributed_blocked_reconciled"]
|
||||||
|
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"]
|
||||||
|
format_distributed = FORMATS["format_distributed"]
|
||||||
|
current_money_format = FORMATS["current_money_format"]
|
||||||
|
name_to_show = (
|
||||||
|
line.get("name", "") == "/" or not line.get("name", "")
|
||||||
|
) and line.get("ref", "")
|
||||||
|
if line.get("name", "") and line.get("name", "") != "/":
|
||||||
|
if not line.get("ref", ""):
|
||||||
|
name_to_show = line.get("name", "")
|
||||||
|
else:
|
||||||
|
if (line.get("name", "") in line.get("ref", "")) or (
|
||||||
|
line.get("name", "") == line.get("ref", "")
|
||||||
|
):
|
||||||
|
name_to_show = line.get("name", "")
|
||||||
|
elif line.get("ref", "") not in line.get("name", ""):
|
||||||
|
name_to_show = line.get("ref", "")
|
||||||
|
return (
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"col_pos": col_pos,
|
||||||
|
"sheet_func": "write",
|
||||||
|
"args": args,
|
||||||
|
}
|
||||||
|
for col_pos, args in enumerate(
|
||||||
|
[
|
||||||
|
(line.get("move_id", ""), format_tcell_left),
|
||||||
|
(line.get("date", ""), format_tcell_date_left),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
+ [
|
||||||
|
{
|
||||||
|
"col_pos": 2,
|
||||||
|
"sheet_func": "merge_range",
|
||||||
|
"span": 1,
|
||||||
|
"args": (name_to_show, format_distributed),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
+ [
|
||||||
|
{
|
||||||
|
"col_pos": col_pos,
|
||||||
|
"sheet_func": "write",
|
||||||
|
"args": args,
|
||||||
|
}
|
||||||
|
for col_pos, args in enumerate(
|
||||||
|
[
|
||||||
|
(
|
||||||
|
line.get("amount", "")
|
||||||
|
if not line.get("reconciled_line")
|
||||||
|
else "",
|
||||||
|
current_money_format,
|
||||||
|
),
|
||||||
|
(line.get("applied_amount", ""), current_money_format),
|
||||||
|
(
|
||||||
|
line.get("open_amount", "")
|
||||||
|
if not line.get("reconciled_line")
|
||||||
|
else "",
|
||||||
|
current_money_format,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
4,
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
def _write_currency_lines(self, row_pos, sheet, partner, currency, data):
|
def _write_currency_lines(self, row_pos, sheet, partner, currency, data):
|
||||||
partner_data = data.get("data", {}).get(partner.id, {})
|
partner_data = data.get("data", {}).get(partner.id, {})
|
||||||
currency_data = partner_data.get("currencies", {}).get(currency.id)
|
currency_data = partner_data.get("currencies", {}).get(currency.id)
|
||||||
@@ -49,170 +204,139 @@ class DetailedActivityStatementXslx(models.AbstractModel):
|
|||||||
currency=currency.display_name,
|
currency=currency.display_name,
|
||||||
)
|
)
|
||||||
sheet.merge_range(
|
sheet.merge_range(
|
||||||
row_pos,
|
row_pos, 0, row_pos, 6, statement_header, FORMATS["format_left_bold"]
|
||||||
0,
|
|
||||||
row_pos,
|
|
||||||
6,
|
|
||||||
statement_header,
|
|
||||||
FORMATS["format_left_bold"],
|
|
||||||
)
|
)
|
||||||
row_pos += 1
|
row_pos += 1
|
||||||
sheet.write(
|
row_pos = self._write_currency_header(row_pos, sheet, partner, currency, data)
|
||||||
row_pos, 0, _("Reference Number"), FORMATS["format_theader_yellow_center"]
|
|
||||||
)
|
|
||||||
sheet.write(row_pos, 1, _("Date"), FORMATS["format_theader_yellow_center"])
|
|
||||||
sheet.merge_range(
|
|
||||||
row_pos,
|
|
||||||
2,
|
|
||||||
row_pos,
|
|
||||||
3,
|
|
||||||
_("Description"),
|
|
||||||
FORMATS["format_theader_yellow_center"],
|
|
||||||
)
|
|
||||||
sheet.write(
|
|
||||||
row_pos, 4, _("Original Amount"), FORMATS["format_theader_yellow_center"]
|
|
||||||
)
|
|
||||||
sheet.write(
|
|
||||||
row_pos, 5, _("Applied Amount"), FORMATS["format_theader_yellow_center"]
|
|
||||||
)
|
|
||||||
sheet.write(
|
|
||||||
row_pos, 6, _("Open Amount"), FORMATS["format_theader_yellow_center"]
|
|
||||||
)
|
|
||||||
row_pos += 1
|
row_pos += 1
|
||||||
sheet.write(
|
row_pos = self._write_currency_subheader(
|
||||||
row_pos, 1, partner_data.get("prior_day"), FORMATS["format_tcell_date_left"]
|
row_pos, sheet, partner, currency, data
|
||||||
)
|
|
||||||
sheet.merge_range(
|
|
||||||
row_pos,
|
|
||||||
2,
|
|
||||||
row_pos,
|
|
||||||
5,
|
|
||||||
_("Initial Balance"),
|
|
||||||
FORMATS["format_tcell_left"],
|
|
||||||
)
|
|
||||||
sheet.write(
|
|
||||||
row_pos,
|
|
||||||
6,
|
|
||||||
currency_data.get("balance_forward"),
|
|
||||||
FORMATS["current_money_format"],
|
|
||||||
)
|
)
|
||||||
for line in currency_data.get("lines"):
|
for line in currency_data.get("lines"):
|
||||||
if line.get("blocked") and not line.get("reconciled_line"):
|
|
||||||
format_tcell_left = FORMATS["format_tcell_left_blocked"]
|
|
||||||
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")
|
|
||||||
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")
|
|
||||||
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"
|
|
||||||
]
|
|
||||||
format_distributed = FORMATS["format_distributed_blocked_reconciled"]
|
|
||||||
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"]
|
|
||||||
format_distributed = FORMATS["format_distributed"]
|
|
||||||
current_money_format = FORMATS["current_money_format"]
|
|
||||||
row_pos += 1
|
row_pos += 1
|
||||||
name_to_show = (
|
row_pos = self._write_currency_line(
|
||||||
line.get("name", "") == "/" or not line.get("name", "")
|
row_pos, sheet, partner, currency, data, line
|
||||||
) and line.get("ref", "")
|
|
||||||
if line.get("name", "") and line.get("name", "") != "/":
|
|
||||||
if not line.get("ref", ""):
|
|
||||||
name_to_show = line.get("name", "")
|
|
||||||
else:
|
|
||||||
if (line.get("name", "") in line.get("ref", "")) or (
|
|
||||||
line.get("name", "") == line.get("ref", "")
|
|
||||||
):
|
|
||||||
name_to_show = line.get("name", "")
|
|
||||||
elif line.get("ref", "") not in line.get("name", ""):
|
|
||||||
name_to_show = line.get("ref", "")
|
|
||||||
sheet.write(row_pos, 0, line.get("move_id", ""), format_tcell_left)
|
|
||||||
sheet.write(row_pos, 1, line.get("date", ""), format_tcell_date_left)
|
|
||||||
sheet.merge_range(row_pos, 2, row_pos, 3, name_to_show, format_distributed)
|
|
||||||
sheet.write(
|
|
||||||
row_pos,
|
|
||||||
4,
|
|
||||||
line.get("amount", "") if not line.get("reconciled_line") else "",
|
|
||||||
current_money_format,
|
|
||||||
)
|
|
||||||
sheet.write(
|
|
||||||
row_pos, 5, line.get("applied_amount", ""), current_money_format
|
|
||||||
)
|
|
||||||
sheet.write(
|
|
||||||
row_pos,
|
|
||||||
6,
|
|
||||||
line.get("open_amount", "") if not line.get("reconciled_line") else "",
|
|
||||||
current_money_format,
|
|
||||||
)
|
)
|
||||||
row_pos += 1
|
row_pos += 1
|
||||||
sheet.write(
|
row_pos = self._write_currency_footer(row_pos, sheet, partner, currency, data)
|
||||||
row_pos, 1, partner_data.get("end"), FORMATS["format_tcell_date_left"]
|
return row_pos
|
||||||
)
|
|
||||||
sheet.merge_range(
|
def _get_currency_prior_header_row_data(self, partner, currency, data):
|
||||||
row_pos,
|
return [
|
||||||
2,
|
{
|
||||||
row_pos,
|
"col_pos": col_pos,
|
||||||
5,
|
"sheet_func": "write",
|
||||||
_("Ending Balance"),
|
"args": args,
|
||||||
FORMATS["format_tcell_left"],
|
}
|
||||||
)
|
for col_pos, args in enumerate(
|
||||||
sheet.write(
|
[
|
||||||
row_pos,
|
(_("Reference Number"), FORMATS["format_theader_yellow_center"]),
|
||||||
6,
|
(_("Date"), FORMATS["format_theader_yellow_center"]),
|
||||||
currency_data.get("amount_due"),
|
(_("Due Date"), FORMATS["format_theader_yellow_center"]),
|
||||||
FORMATS["current_money_format"],
|
(_("Description"), FORMATS["format_theader_yellow_center"]),
|
||||||
)
|
(_("Original"), FORMATS["format_theader_yellow_center"]),
|
||||||
|
(_("Open Amount"), FORMATS["format_theader_yellow_center"]),
|
||||||
|
(_("Balance"), FORMATS["format_theader_yellow_center"]),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
def _get_currency_prior_line_row_data(self, partner, currency, data, line):
|
||||||
|
if line.get("blocked") and not line.get("reconciled_line"):
|
||||||
|
format_tcell_left = FORMATS["format_tcell_left_blocked"]
|
||||||
|
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"):
|
||||||
|
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"):
|
||||||
|
format_tcell_left = FORMATS["format_tcell_left_blocked_reconciled"]
|
||||||
|
format_tcell_date_left = FORMATS[
|
||||||
|
"format_tcell_date_left_blocked_reconciled"
|
||||||
|
]
|
||||||
|
format_distributed = FORMATS["format_distributed_blocked_reconciled"]
|
||||||
|
current_money_format = FORMATS["current_money_format_blocked_reconciled"]
|
||||||
|
else:
|
||||||
|
format_tcell_left = FORMATS["format_tcell_left"]
|
||||||
|
format_tcell_date_left = FORMATS["format_tcell_date_left"]
|
||||||
|
format_distributed = FORMATS["format_distributed"]
|
||||||
|
current_money_format = FORMATS["current_money_format"]
|
||||||
|
name_to_show = (
|
||||||
|
line.get("name", "") == "/" or not line.get("name", "")
|
||||||
|
) and line.get("ref", "")
|
||||||
|
if line.get("name", "") and line.get("name", "") != "/":
|
||||||
|
if not line.get("ref", ""):
|
||||||
|
name_to_show = line.get("name", "")
|
||||||
|
else:
|
||||||
|
if (line.get("ref", "") in line.get("name", "")) or (
|
||||||
|
line.get("name", "") == line.get("ref", "")
|
||||||
|
):
|
||||||
|
name_to_show = line.get("name", "")
|
||||||
|
else:
|
||||||
|
name_to_show = line.get("ref", "")
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"col_pos": col_pos,
|
||||||
|
"sheet_func": "write",
|
||||||
|
"args": args,
|
||||||
|
}
|
||||||
|
for col_pos, args in enumerate(
|
||||||
|
[
|
||||||
|
(line.get("move_id", ""), format_tcell_left),
|
||||||
|
(line.get("date", ""), format_tcell_date_left),
|
||||||
|
(line.get("date_maturity", ""), format_tcell_date_left),
|
||||||
|
(name_to_show, format_distributed),
|
||||||
|
(line.get("amount", ""), current_money_format),
|
||||||
|
(line.get("open_amount", ""), current_money_format),
|
||||||
|
(line.get("balance", ""), current_money_format),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
def _get_currency_footer_prior_row_data(self, partner, currency, data):
|
||||||
|
partner_data = data.get("data", {}).get(partner.id, {})
|
||||||
|
currency_data = partner_data.get("currencies", {}).get(currency.id)
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"col_pos": 1,
|
||||||
|
"sheet_func": "write",
|
||||||
|
"args": (
|
||||||
|
partner_data.get("prior_day"),
|
||||||
|
FORMATS["format_tcell_date_left"],
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"col_pos": 2,
|
||||||
|
"sheet_func": "merge_range",
|
||||||
|
"span": 3,
|
||||||
|
"args": (_("Ending Balance"), FORMATS["format_tcell_left"]),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"col_pos": 6,
|
||||||
|
"sheet_func": "write",
|
||||||
|
"args": (
|
||||||
|
currency_data.get("balance_forward"),
|
||||||
|
FORMATS["current_money_format"],
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
def _write_currency_prior_header(self, row_pos, sheet, partner, currency, data):
|
||||||
|
row_data = self._get_currency_prior_header_row_data(partner, currency, data)
|
||||||
|
self._write_row_data(sheet, row_pos, row_data)
|
||||||
|
return row_pos
|
||||||
|
|
||||||
|
def _write_currency_prior_line(self, row_pos, sheet, partner, currency, data, line):
|
||||||
|
row_data = self._get_currency_prior_line_row_data(partner, currency, data, line)
|
||||||
|
self._write_row_data(sheet, row_pos, row_data)
|
||||||
|
return row_pos
|
||||||
|
|
||||||
|
def _write_currency_prior_footer(self, row_pos, sheet, partner, currency, data):
|
||||||
|
row_data = self._get_currency_footer_prior_row_data(partner, currency, data)
|
||||||
|
self._write_row_data(sheet, row_pos, row_data)
|
||||||
return row_pos
|
return row_pos
|
||||||
|
|
||||||
def _write_currency_prior_lines(self, row_pos, sheet, partner, currency, data):
|
def _write_currency_prior_lines(self, row_pos, sheet, partner, currency, data):
|
||||||
@@ -237,90 +361,137 @@ class DetailedActivityStatementXslx(models.AbstractModel):
|
|||||||
FORMATS["format_left_bold"],
|
FORMATS["format_left_bold"],
|
||||||
)
|
)
|
||||||
row_pos += 1
|
row_pos += 1
|
||||||
sheet.write(
|
row_pos = self._write_currency_prior_header(
|
||||||
row_pos, 0, _("Reference Number"), FORMATS["format_theader_yellow_center"]
|
row_pos, sheet, partner, currency, data
|
||||||
)
|
)
|
||||||
sheet.write(row_pos, 1, _("Date"), FORMATS["format_theader_yellow_center"])
|
|
||||||
sheet.write(row_pos, 2, _("Due Date"), FORMATS["format_theader_yellow_center"])
|
|
||||||
sheet.write(
|
|
||||||
row_pos,
|
|
||||||
3,
|
|
||||||
_("Description"),
|
|
||||||
FORMATS["format_theader_yellow_center"],
|
|
||||||
)
|
|
||||||
sheet.write(row_pos, 4, _("Original"), FORMATS["format_theader_yellow_center"])
|
|
||||||
sheet.write(
|
|
||||||
row_pos, 5, _("Open Amount"), FORMATS["format_theader_yellow_center"]
|
|
||||||
)
|
|
||||||
sheet.write(row_pos, 6, _("Balance"), FORMATS["format_theader_yellow_center"])
|
|
||||||
format_tcell_left = FORMATS["format_tcell_left"]
|
|
||||||
format_tcell_date_left = FORMATS["format_tcell_date_left"]
|
|
||||||
format_distributed = FORMATS["format_distributed"]
|
|
||||||
current_money_format = FORMATS["current_money_format"]
|
|
||||||
for line in currency_data.get("prior_lines"):
|
for line in currency_data.get("prior_lines"):
|
||||||
if line.get("blocked") and not line.get("reconciled_line"):
|
|
||||||
format_tcell_left = FORMATS["format_tcell_left_blocked"]
|
|
||||||
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"):
|
|
||||||
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"):
|
|
||||||
format_tcell_left = FORMATS["format_tcell_left_blocked_reconciled"]
|
|
||||||
format_tcell_date_left = FORMATS[
|
|
||||||
"format_tcell_date_left_blocked_reconciled"
|
|
||||||
]
|
|
||||||
format_distributed = FORMATS["format_distributed_blocked_reconciled"]
|
|
||||||
current_money_format = FORMATS[
|
|
||||||
"current_money_format_blocked_reconciled"
|
|
||||||
]
|
|
||||||
row_pos += 1
|
row_pos += 1
|
||||||
name_to_show = (
|
row_pos = self._write_currency_prior_line(
|
||||||
line.get("name", "") == "/" or not line.get("name", "")
|
row_pos, sheet, partner, currency, data, line
|
||||||
) and line.get("ref", "")
|
)
|
||||||
if line.get("name", "") and line.get("name", "") != "/":
|
row_pos += 1
|
||||||
if not line.get("ref", ""):
|
row_pos = self._write_currency_prior_footer(
|
||||||
|
row_pos, sheet, partner, currency, data
|
||||||
|
)
|
||||||
|
return row_pos
|
||||||
|
|
||||||
|
def _get_currency_ending_header_row_data(self, partner, currency, data):
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"col_pos": col_pos,
|
||||||
|
"sheet_func": "write",
|
||||||
|
"args": args,
|
||||||
|
}
|
||||||
|
for col_pos, args in enumerate(
|
||||||
|
[
|
||||||
|
(_("Reference Number"), FORMATS["format_theader_yellow_center"]),
|
||||||
|
(_("Date"), FORMATS["format_theader_yellow_center"]),
|
||||||
|
(_("Due Date"), FORMATS["format_theader_yellow_center"]),
|
||||||
|
(_("Description"), FORMATS["format_theader_yellow_center"]),
|
||||||
|
(_("Original"), FORMATS["format_theader_yellow_center"]),
|
||||||
|
(_("Open Amount"), FORMATS["format_theader_yellow_center"]),
|
||||||
|
(_("Balance"), FORMATS["format_theader_yellow_center"]),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
def _get_currency_ending_line_row_data(self, partner, currency, data, line):
|
||||||
|
if line.get("blocked") and not line.get("reconciled_line"):
|
||||||
|
format_tcell_left = FORMATS["format_tcell_left_blocked"]
|
||||||
|
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"):
|
||||||
|
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"):
|
||||||
|
format_tcell_left = FORMATS["format_tcell_left_blocked_reconciled"]
|
||||||
|
format_tcell_date_left = FORMATS[
|
||||||
|
"format_tcell_date_left_blocked_reconciled"
|
||||||
|
]
|
||||||
|
format_distributed = FORMATS["format_distributed_blocked_reconciled"]
|
||||||
|
current_money_format = FORMATS["current_money_format_blocked_reconciled"]
|
||||||
|
else:
|
||||||
|
format_tcell_left = FORMATS["format_tcell_left"]
|
||||||
|
format_tcell_date_left = FORMATS["format_tcell_date_left"]
|
||||||
|
format_distributed = FORMATS["format_distributed"]
|
||||||
|
current_money_format = FORMATS["current_money_format"]
|
||||||
|
name_to_show = (
|
||||||
|
line.get("name", "") == "/" or not line.get("name", "")
|
||||||
|
) and line.get("ref", "")
|
||||||
|
if line.get("name", "") and line.get("name", "") != "/":
|
||||||
|
if not line.get("ref", ""):
|
||||||
|
name_to_show = line.get("name", "")
|
||||||
|
else:
|
||||||
|
if (line.get("ref", "") in line.get("name", "")) or (
|
||||||
|
line.get("name", "") == line.get("ref", "")
|
||||||
|
):
|
||||||
name_to_show = line.get("name", "")
|
name_to_show = line.get("name", "")
|
||||||
else:
|
else:
|
||||||
if (line.get("ref", "") in line.get("name", "")) or (
|
name_to_show = line.get("ref", "")
|
||||||
line.get("name", "") == line.get("ref", "")
|
return [
|
||||||
):
|
{
|
||||||
name_to_show = line.get("name", "")
|
"col_pos": col_pos,
|
||||||
else:
|
"sheet_func": "write",
|
||||||
name_to_show = line.get("ref", "")
|
"args": args,
|
||||||
sheet.write(row_pos, 0, line.get("move_id", ""), format_tcell_left)
|
}
|
||||||
sheet.write(row_pos, 1, line.get("date", ""), format_tcell_date_left)
|
for col_pos, args in enumerate(
|
||||||
sheet.write(
|
[
|
||||||
row_pos,
|
(line.get("move_id", ""), format_tcell_left),
|
||||||
2,
|
(line.get("date", ""), format_tcell_date_left),
|
||||||
line.get("date_maturity", ""),
|
(line.get("date_maturity", ""), format_tcell_date_left),
|
||||||
format_tcell_date_left,
|
(name_to_show, format_distributed),
|
||||||
|
(line.get("amount", ""), current_money_format),
|
||||||
|
(line.get("open_amount", ""), current_money_format),
|
||||||
|
(line.get("balance", ""), current_money_format),
|
||||||
|
]
|
||||||
)
|
)
|
||||||
sheet.write(row_pos, 3, name_to_show, format_distributed)
|
]
|
||||||
sheet.write(row_pos, 4, line.get("amount", ""), current_money_format)
|
|
||||||
sheet.write(row_pos, 5, line.get("open_amount", ""), current_money_format)
|
def _get_currency_footer_ending_row_data(self, partner, currency, data):
|
||||||
sheet.write(row_pos, 6, line.get("balance", ""), current_money_format)
|
partner_data = data.get("data", {}).get(partner.id, {})
|
||||||
row_pos += 1
|
currency_data = partner_data.get("currencies", {}).get(currency.id)
|
||||||
sheet.write(
|
return [
|
||||||
row_pos, 1, partner_data.get("prior_day"), FORMATS["format_tcell_date_left"]
|
{
|
||||||
)
|
"col_pos": 1,
|
||||||
sheet.merge_range(
|
"sheet_func": "write",
|
||||||
row_pos,
|
"args": (partner_data.get("end"), FORMATS["format_tcell_date_left"]),
|
||||||
2,
|
},
|
||||||
row_pos,
|
{
|
||||||
5,
|
"col_pos": 2,
|
||||||
_("Ending Balance"),
|
"sheet_func": "merge_range",
|
||||||
FORMATS["format_tcell_left"],
|
"span": 3,
|
||||||
)
|
"args": (_("Ending Balance"), FORMATS["format_tcell_left"]),
|
||||||
sheet.write(
|
},
|
||||||
row_pos,
|
{
|
||||||
6,
|
"col_pos": 6,
|
||||||
currency_data.get("balance_forward"),
|
"sheet_func": "write",
|
||||||
FORMATS["current_money_format"],
|
"args": (
|
||||||
|
currency_data.get("amount_due"),
|
||||||
|
FORMATS["current_money_format"],
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
def _write_currency_ending_header(self, row_pos, sheet, partner, currency, data):
|
||||||
|
row_data = self._get_currency_ending_header_row_data(partner, currency, data)
|
||||||
|
self._write_row_data(sheet, row_pos, row_data)
|
||||||
|
return row_pos
|
||||||
|
|
||||||
|
def _write_currency_ending_line(
|
||||||
|
self, row_pos, sheet, partner, currency, data, line
|
||||||
|
):
|
||||||
|
row_data = self._get_currency_ending_line_row_data(
|
||||||
|
partner, currency, data, line
|
||||||
)
|
)
|
||||||
|
self._write_row_data(sheet, row_pos, row_data)
|
||||||
|
return row_pos
|
||||||
|
|
||||||
|
def _write_currency_ending_footer(self, row_pos, sheet, partner, currency, data):
|
||||||
|
row_data = self._get_currency_footer_ending_row_data(partner, currency, data)
|
||||||
|
self._write_row_data(sheet, row_pos, row_data)
|
||||||
return row_pos
|
return row_pos
|
||||||
|
|
||||||
def _write_currency_ending_lines(self, row_pos, sheet, partner, currency, data):
|
def _write_currency_ending_lines(self, row_pos, sheet, partner, currency, data):
|
||||||
@@ -345,89 +516,17 @@ class DetailedActivityStatementXslx(models.AbstractModel):
|
|||||||
FORMATS["format_left_bold"],
|
FORMATS["format_left_bold"],
|
||||||
)
|
)
|
||||||
row_pos += 1
|
row_pos += 1
|
||||||
sheet.write(
|
row_pos = self._write_currency_ending_header(
|
||||||
row_pos, 0, _("Reference Number"), FORMATS["format_theader_yellow_center"]
|
row_pos, sheet, partner, currency, data
|
||||||
)
|
)
|
||||||
sheet.write(row_pos, 1, _("Date"), FORMATS["format_theader_yellow_center"])
|
|
||||||
sheet.write(row_pos, 2, _("Due Date"), FORMATS["format_theader_yellow_center"])
|
|
||||||
sheet.write(
|
|
||||||
row_pos,
|
|
||||||
3,
|
|
||||||
_("Description"),
|
|
||||||
FORMATS["format_theader_yellow_center"],
|
|
||||||
)
|
|
||||||
sheet.write(row_pos, 4, _("Original"), FORMATS["format_theader_yellow_center"])
|
|
||||||
sheet.write(
|
|
||||||
row_pos, 5, _("Open Amount"), FORMATS["format_theader_yellow_center"]
|
|
||||||
)
|
|
||||||
sheet.write(row_pos, 6, _("Balance"), FORMATS["format_theader_yellow_center"])
|
|
||||||
format_tcell_left = FORMATS["format_tcell_left"]
|
|
||||||
format_tcell_date_left = FORMATS["format_tcell_date_left"]
|
|
||||||
format_distributed = FORMATS["format_distributed"]
|
|
||||||
current_money_format = FORMATS["current_money_format"]
|
|
||||||
for line in currency_data.get("ending_lines"):
|
for line in currency_data.get("ending_lines"):
|
||||||
if line.get("blocked") and not line.get("reconciled_line"):
|
|
||||||
format_tcell_left = FORMATS["format_tcell_left_blocked"]
|
|
||||||
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"):
|
|
||||||
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"):
|
|
||||||
format_tcell_left = FORMATS["format_tcell_left_blocked_reconciled"]
|
|
||||||
format_tcell_date_left = FORMATS[
|
|
||||||
"format_tcell_date_left_blocked_reconciled"
|
|
||||||
]
|
|
||||||
format_distributed = FORMATS["format_distributed_blocked_reconciled"]
|
|
||||||
current_money_format = FORMATS[
|
|
||||||
"current_money_format_blocked_reconciled"
|
|
||||||
]
|
|
||||||
row_pos += 1
|
row_pos += 1
|
||||||
name_to_show = (
|
row_pos = self._write_currency_ending_line(
|
||||||
line.get("name", "") == "/" or not line.get("name", "")
|
row_pos, sheet, partner, currency, data, line
|
||||||
) and line.get("ref", "")
|
|
||||||
if line.get("name", "") and line.get("name", "") != "/":
|
|
||||||
if not line.get("ref", ""):
|
|
||||||
name_to_show = line.get("name", "")
|
|
||||||
else:
|
|
||||||
if (line.get("ref", "") in line.get("name", "")) or (
|
|
||||||
line.get("name", "") == line.get("ref", "")
|
|
||||||
):
|
|
||||||
name_to_show = line.get("name", "")
|
|
||||||
else:
|
|
||||||
name_to_show = line.get("ref", "")
|
|
||||||
sheet.write(row_pos, 0, line.get("move_id", ""), format_tcell_left)
|
|
||||||
sheet.write(row_pos, 1, line.get("date", ""), format_tcell_date_left)
|
|
||||||
sheet.write(
|
|
||||||
row_pos,
|
|
||||||
2,
|
|
||||||
line.get("date_maturity", ""),
|
|
||||||
format_tcell_date_left,
|
|
||||||
)
|
)
|
||||||
sheet.write(row_pos, 3, name_to_show, format_distributed)
|
|
||||||
sheet.write(row_pos, 4, line.get("amount", ""), current_money_format)
|
|
||||||
sheet.write(row_pos, 5, line.get("open_amount", ""), current_money_format)
|
|
||||||
sheet.write(row_pos, 6, line.get("balance", ""), current_money_format)
|
|
||||||
row_pos += 1
|
row_pos += 1
|
||||||
sheet.write(
|
row_pos = self._write_currency_ending_footer(
|
||||||
row_pos, 1, partner_data.get("end"), FORMATS["format_tcell_date_left"]
|
row_pos, sheet, partner, currency, data
|
||||||
)
|
|
||||||
sheet.merge_range(
|
|
||||||
row_pos,
|
|
||||||
2,
|
|
||||||
row_pos,
|
|
||||||
5,
|
|
||||||
_("Ending Balance"),
|
|
||||||
FORMATS["format_tcell_left"],
|
|
||||||
)
|
|
||||||
sheet.write(
|
|
||||||
row_pos,
|
|
||||||
6,
|
|
||||||
currency_data.get("amount_due"),
|
|
||||||
FORMATS["current_money_format"],
|
|
||||||
)
|
)
|
||||||
return row_pos
|
return row_pos
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ class OutstandingStatementXslx(models.AbstractModel):
|
|||||||
format_tcell_date_left = FORMATS["format_tcell_date_left"]
|
format_tcell_date_left = FORMATS["format_tcell_date_left"]
|
||||||
format_distributed = FORMATS["format_distributed"]
|
format_distributed = FORMATS["format_distributed"]
|
||||||
current_money_format = FORMATS["current_money_format"]
|
current_money_format = FORMATS["current_money_format"]
|
||||||
|
|
||||||
name_to_show = (
|
name_to_show = (
|
||||||
line.get("name", "") == "/" or not line.get("name", "")
|
line.get("name", "") == "/" or not line.get("name", "")
|
||||||
) and line.get("ref", "")
|
) and line.get("ref", "")
|
||||||
@@ -78,7 +77,6 @@ class OutstandingStatementXslx(models.AbstractModel):
|
|||||||
name_to_show = line.get("name", "")
|
name_to_show = line.get("name", "")
|
||||||
else:
|
else:
|
||||||
name_to_show = line.get("ref", "")
|
name_to_show = line.get("ref", "")
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"col_pos": col_pos,
|
"col_pos": col_pos,
|
||||||
@@ -133,7 +131,6 @@ class OutstandingStatementXslx(models.AbstractModel):
|
|||||||
span = cell_data.get("span")
|
span = cell_data.get("span")
|
||||||
if span:
|
if span:
|
||||||
args = row_pos, col_pos + span, *args
|
args = row_pos, col_pos + span, *args
|
||||||
|
|
||||||
sheet_func(row_pos, col_pos, *args)
|
sheet_func(row_pos, col_pos, *args)
|
||||||
|
|
||||||
def _write_currency_header(self, row_pos, sheet, partner, currency, data):
|
def _write_currency_header(self, row_pos, sheet, partner, currency, data):
|
||||||
@@ -172,7 +169,6 @@ class OutstandingStatementXslx(models.AbstractModel):
|
|||||||
row_pos = self._write_currency_line(
|
row_pos = self._write_currency_line(
|
||||||
row_pos, sheet, partner, currency, data, line
|
row_pos, sheet, partner, currency, data, line
|
||||||
)
|
)
|
||||||
|
|
||||||
row_pos += 1
|
row_pos += 1
|
||||||
row_pos = self._write_currency_footer(row_pos, sheet, partner, currency, data)
|
row_pos = self._write_currency_footer(row_pos, sheet, partner, currency, data)
|
||||||
return row_pos
|
return row_pos
|
||||||
@@ -187,7 +183,6 @@ class OutstandingStatementXslx(models.AbstractModel):
|
|||||||
"end": partner_data.get("end"),
|
"end": partner_data.get("end"),
|
||||||
"currency": currency.display_name,
|
"currency": currency.display_name,
|
||||||
}
|
}
|
||||||
|
|
||||||
sheet.merge_range(
|
sheet.merge_range(
|
||||||
row_pos, 0, row_pos, 6, buckets_header, FORMATS["format_right_bold"]
|
row_pos, 0, row_pos, 6, buckets_header, FORMATS["format_right_bold"]
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user