[IMP] account_financial_report: Trial balance changes:
- Show Initial balance and Ending balance only when it is necessary with currency + hide currency column - Show currency in the correct column - Create a dict with all keys when it does not exist - Prevent wrong values TT41158pull/992/head
parent
a62b723ea0
commit
1621edbacb
|
@ -191,17 +191,11 @@
|
||||||
<!--## Ending balance-->
|
<!--## Ending balance-->
|
||||||
<div class="act_as_cell" style="width: 9%;">Ending balance</div>
|
<div class="act_as_cell" style="width: 9%;">Ending balance</div>
|
||||||
<t t-if="foreign_currency">
|
<t t-if="foreign_currency">
|
||||||
<!--## currency_name-->
|
|
||||||
<div class="act_as_cell" style="width: 4%;">Cur.</div>
|
|
||||||
<!--## amount_currency-->
|
<!--## amount_currency-->
|
||||||
<div class="act_as_cell" style="width: 9%;">
|
<div class="act_as_cell" style="width: 11%;">Initial
|
||||||
Initial
|
balance cur.</div>
|
||||||
balance cur.
|
<div class="act_as_cell" style="width: 11%;">Ending balance
|
||||||
</div>
|
cur.</div>
|
||||||
<div class="act_as_cell" style="width: 9%;">
|
|
||||||
Ending balance
|
|
||||||
cur.
|
|
||||||
</div>
|
|
||||||
</t>
|
</t>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -737,10 +731,6 @@
|
||||||
<t t-if="not show_partner_details">
|
<t t-if="not show_partner_details">
|
||||||
<t t-if="balance['type'] == 'account_type'">
|
<t t-if="balance['type'] == 'account_type'">
|
||||||
<t t-if="balance['currency_id']">
|
<t t-if="balance['currency_id']">
|
||||||
<!--## currency_name-->
|
|
||||||
<div class="act_as_cell" style="width: 4.43%;">
|
|
||||||
<span t-esc="balance['currency_name']" />
|
|
||||||
</div>
|
|
||||||
<!--## Initial balance cur.-->
|
<!--## Initial balance cur.-->
|
||||||
<div class="act_as_cell amount" t-att-style="style">
|
<div class="act_as_cell amount" t-att-style="style">
|
||||||
<t t-if="only_posted_moves">
|
<t t-if="only_posted_moves">
|
||||||
|
@ -759,7 +749,10 @@
|
||||||
t-att-domain="domain+aml_domain_common"
|
t-att-domain="domain+aml_domain_common"
|
||||||
res-model="account.move.line"
|
res-model="account.move.line"
|
||||||
>
|
>
|
||||||
<t t-esc="balance['initial_currency_balance']" />
|
<t
|
||||||
|
t-esc="balance['initial_currency_balance']"
|
||||||
|
t-options="{'widget': 'monetary', 'display_currency': balance['currency_id']}"
|
||||||
|
/>
|
||||||
</span>
|
</span>
|
||||||
<!-- <t t-if="line.account_group_id">-->
|
<!-- <t t-if="line.account_group_id">-->
|
||||||
<!-- <t t-set="domain"-->
|
<!-- <t t-set="domain"-->
|
||||||
|
@ -779,12 +772,6 @@
|
||||||
<t t-if="show_partner_details">
|
<t t-if="show_partner_details">
|
||||||
<t t-if="total_amount[account_id]['currency_id']">
|
<t t-if="total_amount[account_id]['currency_id']">
|
||||||
<t t-if="type == 'partner_type'">
|
<t t-if="type == 'partner_type'">
|
||||||
<!--## currency_name-->
|
|
||||||
<div class="act_as_cell" style="width: 4.43%;">
|
|
||||||
<span
|
|
||||||
t-esc="total_amount[account_id]['currency_name']"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="act_as_cell amount" t-att-style="style">
|
<div class="act_as_cell amount" t-att-style="style">
|
||||||
<t t-if="only_posted_moves">
|
<t t-if="only_posted_moves">
|
||||||
<t
|
<t
|
||||||
|
@ -807,6 +794,7 @@
|
||||||
>
|
>
|
||||||
<t
|
<t
|
||||||
t-raw="total_amount[account_id][partner_id]['initial_currency_balance']"
|
t-raw="total_amount[account_id][partner_id]['initial_currency_balance']"
|
||||||
|
t-options="{'widget': 'monetary', 'display_currency': total_amount[account_id]['currency_id']}"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -834,7 +822,10 @@
|
||||||
t-att-domain="domain+aml_domain_common"
|
t-att-domain="domain+aml_domain_common"
|
||||||
res-model="account.move.line"
|
res-model="account.move.line"
|
||||||
>
|
>
|
||||||
<t t-raw="balance['ending_currency_balance']" />
|
<t
|
||||||
|
t-raw="balance['ending_currency_balance']"
|
||||||
|
t-options="{'widget': 'monetary', 'display_currency': balance['currency_id']}"
|
||||||
|
/>
|
||||||
</span>
|
</span>
|
||||||
<!-- <t t-if="line.account_group_id">-->
|
<!-- <t t-if="line.account_group_id">-->
|
||||||
<!-- <t t-set="domain"-->
|
<!-- <t t-set="domain"-->
|
||||||
|
@ -876,6 +867,7 @@
|
||||||
>
|
>
|
||||||
<t
|
<t
|
||||||
t-raw="total_amount[account_id][partner_id]['ending_currency_balance']"
|
t-raw="total_amount[account_id][partner_id]['ending_currency_balance']"
|
||||||
|
t-options="{'widget': 'monetary', 'display_currency': total_amount[account_id]['currency_id']}"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
</t>
|
</t>
|
||||||
|
@ -887,7 +879,6 @@
|
||||||
<!--## balance_currency-->
|
<!--## balance_currency-->
|
||||||
<div class="act_as_cell" />
|
<div class="act_as_cell" />
|
||||||
<div class="act_as_cell" />
|
<div class="act_as_cell" />
|
||||||
<div class="act_as_cell" />
|
|
||||||
</t>
|
</t>
|
||||||
</t>
|
</t>
|
||||||
<t t-if="not show_partner_details">
|
<t t-if="not show_partner_details">
|
||||||
|
@ -896,14 +887,12 @@
|
||||||
<!--## balance_currency-->
|
<!--## balance_currency-->
|
||||||
<div class="act_as_cell" />
|
<div class="act_as_cell" />
|
||||||
<div class="act_as_cell" />
|
<div class="act_as_cell" />
|
||||||
<div class="act_as_cell" />
|
|
||||||
</t>
|
</t>
|
||||||
</t>
|
</t>
|
||||||
<t t-if="balance['type'] == 'group_type'">
|
<t t-if="balance['type'] == 'group_type'">
|
||||||
<!--## balance_currency-->
|
<!--## balance_currency-->
|
||||||
<div class="act_as_cell" />
|
<div class="act_as_cell" />
|
||||||
<div class="act_as_cell" />
|
<div class="act_as_cell" />
|
||||||
<div class="act_as_cell" />
|
|
||||||
</t>
|
</t>
|
||||||
</t>
|
</t>
|
||||||
</t>
|
</t>
|
||||||
|
@ -1082,12 +1071,10 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<t t-if="foreign_currency">
|
<t t-if="foreign_currency">
|
||||||
<!--## currency_name-->
|
|
||||||
<div class="act_as_cell" style="width: 4%;" />
|
|
||||||
<!--## amount_total_due_currency-->
|
<!--## amount_total_due_currency-->
|
||||||
<div class="act_as_cell" style="width: 9%;" />
|
<div class="act_as_cell" style="width: 11%;" />
|
||||||
<!--## amount_residual_currency-->
|
<!--## amount_residual_currency-->
|
||||||
<div class="act_as_cell" style="width: 9%;" />
|
<div class="act_as_cell" style="width: 11%;" />
|
||||||
</t>
|
</t>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -187,33 +187,15 @@ class TrialBalanceReport(models.AbstractModel):
|
||||||
):
|
):
|
||||||
for tb in tb_period_acc:
|
for tb in tb_period_acc:
|
||||||
acc_id = tb["account_id"][0]
|
acc_id = tb["account_id"][0]
|
||||||
total_amount[acc_id] = {}
|
total_amount[acc_id] = self._prepare_total_amount(tb, foreign_currency)
|
||||||
total_amount[acc_id]["credit"] = tb["credit"]
|
total_amount[acc_id]["credit"] = tb["credit"]
|
||||||
total_amount[acc_id]["debit"] = tb["debit"]
|
total_amount[acc_id]["debit"] = tb["debit"]
|
||||||
total_amount[acc_id]["balance"] = tb["balance"]
|
total_amount[acc_id]["balance"] = tb["balance"]
|
||||||
total_amount[acc_id]["initial_balance"] = 0.0
|
total_amount[acc_id]["initial_balance"] = 0.0
|
||||||
total_amount[acc_id]["ending_balance"] = tb["balance"]
|
|
||||||
if foreign_currency:
|
|
||||||
total_amount[acc_id]["initial_currency_balance"] = 0.0
|
|
||||||
total_amount[acc_id]["ending_currency_balance"] = round(
|
|
||||||
tb["amount_currency"], 2
|
|
||||||
)
|
|
||||||
for tb in tb_initial_acc:
|
for tb in tb_initial_acc:
|
||||||
acc_id = tb["account_id"]
|
acc_id = tb["account_id"]
|
||||||
if acc_id not in total_amount.keys():
|
if acc_id not in total_amount.keys():
|
||||||
total_amount[acc_id] = {}
|
total_amount[acc_id] = self._prepare_total_amount(tb, foreign_currency)
|
||||||
total_amount[acc_id]["credit"] = 0.0
|
|
||||||
total_amount[acc_id]["debit"] = 0.0
|
|
||||||
total_amount[acc_id]["balance"] = 0.0
|
|
||||||
total_amount[acc_id]["initial_balance"] = tb["balance"]
|
|
||||||
total_amount[acc_id]["ending_balance"] = tb["balance"]
|
|
||||||
if foreign_currency:
|
|
||||||
total_amount[acc_id]["initial_currency_balance"] = round(
|
|
||||||
tb["amount_currency"], 2
|
|
||||||
)
|
|
||||||
total_amount[acc_id]["ending_currency_balance"] = round(
|
|
||||||
tb["amount_currency"], 2
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
total_amount[acc_id]["initial_balance"] = tb["balance"]
|
total_amount[acc_id]["initial_balance"] = tb["balance"]
|
||||||
total_amount[acc_id]["ending_balance"] += tb["balance"]
|
total_amount[acc_id]["ending_balance"] += tb["balance"]
|
||||||
|
@ -226,23 +208,42 @@ class TrialBalanceReport(models.AbstractModel):
|
||||||
)
|
)
|
||||||
return total_amount
|
return total_amount
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _prepare_total_amount(self, tb, foreign_currency):
|
||||||
|
res = {
|
||||||
|
"credit": 0.0,
|
||||||
|
"debit": 0.0,
|
||||||
|
"balance": 0.0,
|
||||||
|
"initial_balance": tb["balance"],
|
||||||
|
"ending_balance": tb["balance"],
|
||||||
|
}
|
||||||
|
if foreign_currency:
|
||||||
|
res["initial_currency_balance"] = round(tb["amount_currency"], 2)
|
||||||
|
res["ending_currency_balance"] = round(tb["amount_currency"], 2)
|
||||||
|
return res
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _compute_acc_prt_amount(
|
def _compute_acc_prt_amount(
|
||||||
self, total_amount, tb, acc_id, prt_id, foreign_currency
|
self, total_amount, tb, acc_id, prt_id, foreign_currency
|
||||||
):
|
):
|
||||||
total_amount[acc_id][prt_id] = {}
|
# Add keys to dict if not exists
|
||||||
total_amount[acc_id][prt_id]["credit"] = 0.0
|
if acc_id not in total_amount:
|
||||||
total_amount[acc_id][prt_id]["debit"] = 0.0
|
total_amount[acc_id] = self._prepare_total_amount(tb, foreign_currency)
|
||||||
total_amount[acc_id][prt_id]["balance"] = 0.0
|
if prt_id not in total_amount[acc_id]:
|
||||||
total_amount[acc_id][prt_id]["initial_balance"] = tb["balance"]
|
total_amount[acc_id][prt_id] = self._prepare_total_amount(
|
||||||
total_amount[acc_id][prt_id]["ending_balance"] = tb["balance"]
|
tb, foreign_currency
|
||||||
if foreign_currency:
|
|
||||||
total_amount[acc_id][prt_id]["initial_currency_balance"] = round(
|
|
||||||
tb["amount_currency"], 2
|
|
||||||
)
|
|
||||||
total_amount[acc_id][prt_id]["ending_currency_balance"] = round(
|
|
||||||
tb["amount_currency"], 2
|
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
# Increase balance field values
|
||||||
|
total_amount[acc_id][prt_id]["initial_balance"] = tb["balance"]
|
||||||
|
total_amount[acc_id][prt_id]["ending_balance"] += tb["balance"]
|
||||||
|
if foreign_currency:
|
||||||
|
total_amount[acc_id][prt_id]["initial_currency_balance"] = round(
|
||||||
|
tb["amount_currency"], 2
|
||||||
|
)
|
||||||
|
total_amount[acc_id][prt_id]["ending_currency_balance"] += round(
|
||||||
|
tb["amount_currency"], 2
|
||||||
|
)
|
||||||
return total_amount
|
return total_amount
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
|
@ -259,18 +260,14 @@ class TrialBalanceReport(models.AbstractModel):
|
||||||
partners_data.update(
|
partners_data.update(
|
||||||
{prt_id: {"id": prt_id, "name": tb["partner_id"][1]}}
|
{prt_id: {"id": prt_id, "name": tb["partner_id"][1]}}
|
||||||
)
|
)
|
||||||
total_amount[acc_id][prt_id] = {}
|
total_amount[acc_id][prt_id] = self._prepare_total_amount(
|
||||||
|
tb, foreign_currency
|
||||||
|
)
|
||||||
total_amount[acc_id][prt_id]["credit"] = tb["credit"]
|
total_amount[acc_id][prt_id]["credit"] = tb["credit"]
|
||||||
total_amount[acc_id][prt_id]["debit"] = tb["debit"]
|
total_amount[acc_id][prt_id]["debit"] = tb["debit"]
|
||||||
total_amount[acc_id][prt_id]["balance"] = tb["balance"]
|
total_amount[acc_id][prt_id]["balance"] = tb["balance"]
|
||||||
total_amount[acc_id][prt_id]["initial_balance"] = 0.0
|
total_amount[acc_id][prt_id]["initial_balance"] = 0.0
|
||||||
total_amount[acc_id][prt_id]["ending_balance"] = tb["balance"]
|
partners_ids.add(tb["partner_id"])
|
||||||
if foreign_currency:
|
|
||||||
total_amount[acc_id][prt_id]["initial_currency_balance"] = 0.0
|
|
||||||
total_amount[acc_id][prt_id]["ending_currency_balance"] = round(
|
|
||||||
tb["amount_currency"], 2
|
|
||||||
)
|
|
||||||
partners_ids.add(tb["partner_id"])
|
|
||||||
for tb in tb_initial_prt:
|
for tb in tb_initial_prt:
|
||||||
acc_id = tb["account_id"][0]
|
acc_id = tb["account_id"][0]
|
||||||
if tb["partner_id"]:
|
if tb["partner_id"]:
|
||||||
|
@ -279,27 +276,9 @@ class TrialBalanceReport(models.AbstractModel):
|
||||||
partners_data.update(
|
partners_data.update(
|
||||||
{prt_id: {"id": prt_id, "name": tb["partner_id"][1]}}
|
{prt_id: {"id": prt_id, "name": tb["partner_id"][1]}}
|
||||||
)
|
)
|
||||||
if acc_id not in total_amount.keys():
|
total_amount = self._compute_acc_prt_amount(
|
||||||
total_amount[acc_id] = {}
|
total_amount, tb, acc_id, prt_id, foreign_currency
|
||||||
total_amount = self._compute_acc_prt_amount(
|
)
|
||||||
total_amount, tb, acc_id, prt_id, foreign_currency
|
|
||||||
)
|
|
||||||
partners_ids.add(tb["partner_id"])
|
|
||||||
elif prt_id not in total_amount[acc_id].keys():
|
|
||||||
total_amount = self._compute_acc_prt_amount(
|
|
||||||
total_amount, tb, acc_id, prt_id, foreign_currency
|
|
||||||
)
|
|
||||||
partners_ids.add(tb["partner_id"])
|
|
||||||
else:
|
|
||||||
total_amount[acc_id][prt_id]["initial_balance"] += tb["balance"]
|
|
||||||
total_amount[acc_id][prt_id]["ending_balance"] += tb["balance"]
|
|
||||||
if foreign_currency:
|
|
||||||
total_amount[acc_id][prt_id][
|
|
||||||
"initial_currency_balance"
|
|
||||||
] += round(tb["amount_currency"], 2)
|
|
||||||
total_amount[acc_id][prt_id][
|
|
||||||
"ending_currency_balance"
|
|
||||||
] += round(tb["amount_currency"], 2)
|
|
||||||
return total_amount, partners_data
|
return total_amount, partners_data
|
||||||
|
|
||||||
def _remove_accounts_at_cero(self, total_amount, show_partner_details, company):
|
def _remove_accounts_at_cero(self, total_amount, show_partner_details, company):
|
||||||
|
|
|
@ -60,19 +60,12 @@ class TrialBalanceXslx(models.AbstractModel):
|
||||||
if report.foreign_currency:
|
if report.foreign_currency:
|
||||||
foreign_currency = {
|
foreign_currency = {
|
||||||
7: {
|
7: {
|
||||||
"header": _("Cur."),
|
|
||||||
"field": "currency_id",
|
|
||||||
"field_currency_balance": "currency_id",
|
|
||||||
"type": "many2one",
|
|
||||||
"width": 7,
|
|
||||||
},
|
|
||||||
8: {
|
|
||||||
"header": _("Initial balance"),
|
"header": _("Initial balance"),
|
||||||
"field": "initial_currency_balance",
|
"field": "initial_currency_balance",
|
||||||
"type": "amount_currency",
|
"type": "amount_currency",
|
||||||
"width": 14,
|
"width": 14,
|
||||||
},
|
},
|
||||||
9: {
|
8: {
|
||||||
"header": _("Ending balance"),
|
"header": _("Ending balance"),
|
||||||
"field": "ending_currency_balance",
|
"field": "ending_currency_balance",
|
||||||
"type": "amount_currency",
|
"type": "amount_currency",
|
||||||
|
@ -118,19 +111,12 @@ class TrialBalanceXslx(models.AbstractModel):
|
||||||
if report.foreign_currency:
|
if report.foreign_currency:
|
||||||
foreign_currency = {
|
foreign_currency = {
|
||||||
6: {
|
6: {
|
||||||
"header": _("Cur."),
|
|
||||||
"field": "currency_id",
|
|
||||||
"field_currency_balance": "currency_id",
|
|
||||||
"type": "many2one",
|
|
||||||
"width": 7,
|
|
||||||
},
|
|
||||||
7: {
|
|
||||||
"header": _("Initial balance"),
|
"header": _("Initial balance"),
|
||||||
"field": "initial_currency_balance",
|
"field": "initial_currency_balance",
|
||||||
"type": "amount_currency",
|
"type": "amount_currency",
|
||||||
"width": 14,
|
"width": 14,
|
||||||
},
|
},
|
||||||
8: {
|
7: {
|
||||||
"header": _("Ending balance"),
|
"header": _("Ending balance"),
|
||||||
"field": "ending_currency_balance",
|
"field": "ending_currency_balance",
|
||||||
"type": "amount_currency",
|
"type": "amount_currency",
|
||||||
|
|
Loading…
Reference in New Issue