Browse Source

Merge pull request #390 from SimoRubi/10.0-account_financial_report_qweb-foreign_currency

General ledger, foreign currency in initial and final balance
pull/402/head
Jordi Ballester Alomar 7 years ago
committed by GitHub
parent
commit
eff45100c3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      account_financial_report_qweb/__manifest__.py
  2. 12
      account_financial_report_qweb/i18n/it.po
  3. 2
      account_financial_report_qweb/report/aged_partner_balance.py
  4. 68
      account_financial_report_qweb/report/general_ledger.py
  5. 2
      account_financial_report_qweb/report/open_items.py
  6. 24
      account_financial_report_qweb/report/templates/general_ledger.xml
  7. 24
      account_financial_report_qweb/report/templates/trial_balance.xml
  8. 15
      account_financial_report_qweb/report/trial_balance.py

2
account_financial_report_qweb/__manifest__.py

@ -5,7 +5,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'QWeb Financial Reports',
'version': '10.0.1.3.0',
'version': '10.0.1.4.0',
'category': 'Reporting',
'summary': 'OCA Financial Reports',
'author': 'Camptocamp SA,'

12
account_financial_report_qweb/i18n/it.po

@ -669,6 +669,12 @@ msgstr "Bilancio finale residuo"
msgid "Final balance"
msgstr "Bilancio finale"
#. module: account_financial_report_qweb
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_general_ledger_qweb_account_final_balance_currency
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_general_ledger_qweb_partner_final_balance_currency
msgid "Final balance foreign currency"
msgstr "Bilancio finale in valuta estera"
#. module: account_financial_report_qweb
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_general_ledger_qweb_account_final_credit
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_general_ledger_qweb_partner_final_credit
@ -815,6 +821,12 @@ msgstr ""
msgid "Initial balance"
msgstr "Bilancio iniziale"
#. module: account_financial_report_qweb
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_general_ledger_qweb_account_initial_balance_currency
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_general_ledger_qweb_partner_initial_balance_currency
msgid "Initial balance foreign currency"
msgstr "Bilancio iniziale valuta estera"
#. module: account_financial_report_qweb
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_general_ledger_qweb_account_initial_credit
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_general_ledger_qweb_partner_initial_credit

2
account_financial_report_qweb/report/aged_partner_balance.py

@ -227,7 +227,7 @@ class AgedPartnerBalanceReportCompute(models.TransientModel):
self._inject_move_line_values(only_empty_partner_line=True)
self._compute_accounts_cumul()
# Refresh cache because all data are computed with SQL requests
self.refresh()
self.invalidate_cache()
def _inject_account_values(self):
"""Inject report values for report_aged_partner_balance_qweb_account"""

68
account_financial_report_qweb/report/general_ledger.py

@ -91,9 +91,12 @@ class GeneralLedgerReportAccount(models.TransientModel):
initial_debit = fields.Float(digits=(16, 2))
initial_credit = fields.Float(digits=(16, 2))
initial_balance = fields.Float(digits=(16, 2))
currency_name = fields.Char()
initial_balance_foreign_currency = fields.Float(digits=(16, 2))
final_debit = fields.Float(digits=(16, 2))
final_credit = fields.Float(digits=(16, 2))
final_balance = fields.Float(digits=(16, 2))
final_balance_foreign_currency = fields.Float(digits=(16, 2))
# Flag fields, used for report display and for data computation
is_partner_account = fields.Boolean()
@ -130,9 +133,12 @@ class GeneralLedgerReportPartner(models.TransientModel):
initial_debit = fields.Float(digits=(16, 2))
initial_credit = fields.Float(digits=(16, 2))
initial_balance = fields.Float(digits=(16, 2))
currency_name = fields.Char()
initial_balance_foreign_currency = fields.Float(digits=(16, 2))
final_debit = fields.Float(digits=(16, 2))
final_credit = fields.Float(digits=(16, 2))
final_balance = fields.Float(digits=(16, 2))
final_balance_foreign_currency = fields.Float(digits=(16, 2))
# Data fields, used to browse report data
move_line_ids = fields.One2many(
@ -261,7 +267,7 @@ class GeneralLedgerReportCompute(models.TransientModel):
self._compute_has_second_currency()
# Refresh cache because all data are computed with SQL requests
self.refresh()
self.invalidate_cache()
def _get_account_sub_subquery_sum_amounts(
self, include_initial_balance, date_included):
@ -271,7 +277,9 @@ class GeneralLedgerReportCompute(models.TransientModel):
a.id AS account_id,
SUM(ml.debit) AS debit,
SUM(ml.credit) AS credit,
SUM(ml.balance) AS balance
SUM(ml.balance) AS balance,
c.name AS currency_name,
SUM(ml.amount_currency) AS balance_currency
FROM
accounts a
INNER JOIN
@ -313,8 +321,12 @@ class GeneralLedgerReportCompute(models.TransientModel):
AND aa.id IN %s
"""
sub_subquery_sum_amounts += """
LEFT JOIN
res_currency c ON a.currency_id = c.id
"""
sub_subquery_sum_amounts += """
GROUP BY
a.id
a.id, c.name
"""
return sub_subquery_sum_amounts
@ -325,7 +337,9 @@ class GeneralLedgerReportCompute(models.TransientModel):
sub.account_id AS account_id,
SUM(COALESCE(sub.debit, 0.0)) AS debit,
SUM(COALESCE(sub.credit, 0.0)) AS credit,
SUM(COALESCE(sub.balance, 0.0)) AS balance
SUM(COALESCE(sub.balance, 0.0)) AS balance,
MAX(sub.currency_name) AS currency_name,
SUM(COALESCE(sub.balance_currency, 0.0)) AS balance_currency
FROM
(
"""
@ -357,7 +371,8 @@ WITH
a.name,
a.internal_type IN ('payable', 'receivable')
AS is_partner_account,
a.user_type_id
a.user_type_id,
a.currency_id
FROM
account_account a
"""
@ -423,9 +438,12 @@ INSERT INTO
initial_debit,
initial_credit,
initial_balance,
currency_name,
initial_balance_foreign_currency,
final_debit,
final_credit,
final_balance,
final_balance_foreign_currency,
is_partner_account
)
SELECT
@ -438,9 +456,12 @@ SELECT
COALESCE(i.debit, 0.0) AS initial_debit,
COALESCE(i.credit, 0.0) AS initial_credit,
COALESCE(i.balance, 0.0) AS initial_balance,
c.name AS currency_name,
COALESCE(i.balance_currency, 0.0) AS initial_balance_foreign_currency,
COALESCE(f.debit, 0.0) AS final_debit,
COALESCE(f.credit, 0.0) AS final_credit,
COALESCE(f.balance, 0.0) AS final_balance,
COALESCE(f.balance_currency, 0.0) AS final_balance_foreign_currency,
a.is_partner_account
FROM
accounts a
@ -448,6 +469,8 @@ LEFT JOIN
initial_sum_amounts i ON a.id = i.account_id
LEFT JOIN
final_sum_amounts f ON a.id = f.account_id
LEFT JOIN
res_currency c ON c.id = a.currency_id
WHERE
(
i.debit IS NOT NULL AND i.debit != 0
@ -526,9 +549,15 @@ AND
ap.partner_id AS partner_id,
SUM(ml.debit) AS debit,
SUM(ml.credit) AS credit,
SUM(ml.balance) AS balance
SUM(ml.balance) AS balance,
c.name as currency_name,
SUM(ml.amount_currency) AS balance_currency
FROM
accounts_partners ap
INNER JOIN account_account ac
ON ac.id = ap.account_id
LEFT JOIN
res_currency c ON ap.account_id = c.id
INNER JOIN
account_move_line ml
ON ap.account_id = ml.account_id
@ -572,7 +601,7 @@ AND
"""
sub_subquery_sum_amounts += """
GROUP BY
ap.account_id, ap.partner_id
ap.account_id, ap.partner_id, c.name
"""
return sub_subquery_sum_amounts
@ -587,7 +616,9 @@ AND
sub.partner_id AS partner_id,
SUM(COALESCE(sub.debit, 0.0)) AS debit,
SUM(COALESCE(sub.credit, 0.0)) AS credit,
SUM(COALESCE(sub.balance, 0.0)) AS balance
SUM(COALESCE(sub.balance, 0.0)) AS balance,
MAX(sub.currency_name) AS currency_name,
SUM(COALESCE(sub.balance_currency, 0.0)) AS balance_currency
FROM
(
"""
@ -712,9 +743,12 @@ INSERT INTO
initial_debit,
initial_credit,
initial_balance,
currency_name,
initial_balance_foreign_currency,
final_debit,
final_credit,
final_balance
final_balance,
final_balance_foreign_currency
)
SELECT
ap.report_account_id,
@ -725,9 +759,12 @@ SELECT
COALESCE(i.debit, 0.0) AS initial_debit,
COALESCE(i.credit, 0.0) AS initial_credit,
COALESCE(i.balance, 0.0) AS initial_balance,
i.currency_name AS currency_name,
COALESCE(i.balance_currency, 0.0) AS initial_balance_foreign_currency,
COALESCE(f.debit, 0.0) AS final_debit,
COALESCE(f.credit, 0.0) AS final_credit,
COALESCE(f.balance, 0.0) AS final_balance
COALESCE(f.balance, 0.0) AS final_balance,
COALESCE(f.balance_currency, 0.0) AS final_balance_foreign_currency
FROM
accounts_partners ap
LEFT JOIN
@ -1313,7 +1350,8 @@ WHERE id = %s
code,
name,
is_partner_account,
initial_balance
initial_balance,
currency_name
)
SELECT
%s AS report_id,
@ -1323,7 +1361,8 @@ WHERE id = %s
a.code,
a.name,
False AS is_partner_account,
COALESCE(i.balance, 0.0) AS initial_balance
COALESCE(i.balance, 0.0) AS initial_balance,
''
FROM
account_account a,
initial_sum_amounts i
@ -1360,6 +1399,7 @@ WHERE id = %s
self.company_id.id,
self.unaffected_earnings_account.id,
)
self.env.cr.execute(query_inject_account,
query_inject_account_params)
@ -1395,7 +1435,9 @@ WHERE id = %s
initial_credit = 0.0,
final_debit = sum_amounts.debit,
final_credit = sum_amounts.credit,
final_balance = sum_amounts.balance
final_balance = sum_amounts.balance,
initial_balance_foreign_currency = 0.0,
final_balance_foreign_currency = 0.0
FROM
sum_amounts
WHERE

2
account_financial_report_qweb/report/open_items.py

@ -170,7 +170,7 @@ class OpenItemsReportCompute(models.TransientModel):
# Compute display flag
self._compute_has_second_currency()
# Refresh cache because all data are computed with SQL requests
self.refresh()
self.invalidate_cache()
def _inject_account_values(self):
"""Inject report values for report_open_items_qweb_account."""

24
account_financial_report_qweb/report/templates/general_ledger.xml

@ -160,9 +160,15 @@
<!--## balance cumulated-->
<div class="act_as_cell amount"><span t-field="account_or_partner_object.initial_balance"/></div>
<!--## currency_name-->
<div class="act_as_cell"></div>
<!--## amount_currency-->
<div class="act_as_cell"></div>
<div class="act_as_cell"><span t-field="account_or_partner_object.currency_name"/></div>
<t t-if="account_or_partner_object.currency_name">
<!--## balance_currency-->
<div class="act_as_cell amount"><span t-field="account_or_partner_object.initial_balance_foreign_currency"/></div>
</t>
<t t-if="not account_or_partner_object.currency_name">
<!--## balance_currency-->
<div class="act_as_cell"></div>
</t>
</div>
<!-- Display each lines -->
@ -233,8 +239,16 @@
<div class="act_as_cell amount" style="width: 75px;"><span t-field="account_or_partner_object.final_credit"/></div>
<!--## balance cumulated-->
<div class="act_as_cell amount" style="width: 75px; padding-right: 1px;"><span t-field="account_or_partner_object.final_balance"/></div>
<!--## currency_name + amount_currency-->
<div class="act_as_cell" style="width: 110px;"></div>
<!--## currency_name-->
<div class="act_as_cell" style="width: 35px;"><span t-field="account_or_partner_object.currency_name"/></div>
<t t-if="account_or_partner_object.currency_name">
<!--## balance_currency-->
<div class="act_as_cell amount" style="width: 75px;"><span t-field="account_or_partner_object.final_balance_foreign_currency"/></div>
</t>
<t t-if="not account_or_partner_object.currency_name">
<!--## balance_currency-->
<div class="act_as_cell" style="width: 75px;"/>
</t>
</div>
</div>
</template>

24
account_financial_report_qweb/report/templates/trial_balance.xml

@ -19,7 +19,7 @@
<!-- Display account lines -->
<t t-if="not show_partner_details">
<div class="act_as_table data_table" style="width: 1140px !important;">
<div class="act_as_table data_table" style="width: 1325px !important;">
<!-- Display account header -->
<t t-call="account_financial_report_qweb.report_trial_balance_qweb_lines_header"/>
@ -41,7 +41,7 @@
<span t-field="account.code"/> - <span t-field="account.name"/>
</div>
<div class="act_as_table data_table" style="width: 1140px !important;">
<div class="act_as_table data_table" style="width: 1325px !important;">
<!-- Display account/partner header -->
<t t-call="account_financial_report_qweb.report_trial_balance_qweb_lines_header"/>
@ -65,7 +65,7 @@
</template>
<template id="account_financial_report_qweb.report_trial_balance_qweb_filters">
<div class="act_as_table data_table" style="width: 1140px !important;">
<div class="act_as_table data_table" style="width: 1325px !important;">
<div class="act_as_row labels">
<div class="act_as_cell">Date range filter</div>
<div class="act_as_cell">Target moves filter</div>
@ -109,6 +109,11 @@
<div class="act_as_cell" style="width: 110px;">Credit</div>
<!--## Ending balance-->
<div class="act_as_cell" style="width: 110px;">Ending balance</div>
<!--## currency_name-->
<div class="act_as_cell" style="width: 35px;">Cur.</div>
<!--## amount_currency-->
<div class="act_as_cell" style="width: 75px;">Initial blance cur.</div>
<div class="act_as_cell" style="width: 75px;">Ending blance cur.</div>
</div>
</div>
</template>
@ -130,6 +135,19 @@
<div class="act_as_cell amount"><span t-field="line.credit"/></div>
<!--## Ending balance-->
<div class="act_as_cell amount"><span t-field="line.final_balance"/></div>
<!--## currency_name-->
<div class="act_as_cell"><span t-field="line.currency_name"/></div>
<t t-if="line.currency_name">
<!--## balance_currency-->
<div class="act_as_cell amount"><span t-field="line.initial_balance_foreign_currency"/></div>
<div class="act_as_cell amount"><span
t-field="line.final_balance_foreign_currency"/></div>
</t>
<t t-if="not line.currency_name">
<!--## balance_currency-->
<div class="act_as_cell"/>
<div class="act_as_cell"/>
</t>
</div>
</template>

15
account_financial_report_qweb/report/trial_balance.py

@ -64,9 +64,12 @@ class TrialBalanceReportAccount(models.TransientModel):
name = fields.Char()
initial_balance = fields.Float(digits=(16, 2))
initial_balance_foreign_currency = fields.Float(digits=(16, 2))
debit = fields.Float(digits=(16, 2))
credit = fields.Float(digits=(16, 2))
currency_name = fields.Char()
final_balance = fields.Float(digits=(16, 2))
final_balance_foreign_currency = fields.Float(digits=(16, 2))
# Data fields, used to browse report data
partner_ids = fields.One2many(
@ -165,7 +168,7 @@ class TrialBalanceReportCompute(models.TransientModel):
if self.show_partner_details:
self._inject_partner_values()
# Refresh cache because all data are computed with SQL requests
self.refresh()
self.invalidate_cache()
def _inject_account_values(self):
"""Inject report values for report_trial_balance_qweb_account"""
@ -182,7 +185,10 @@ INSERT INTO
initial_balance,
debit,
credit,
final_balance
final_balance,
currency_name,
initial_balance_foreign_currency,
final_balance_foreign_currency
)
SELECT
%s AS report_id,
@ -194,7 +200,10 @@ SELECT
rag.initial_balance AS initial_balance,
rag.final_debit - rag.initial_debit AS debit,
rag.final_credit - rag.initial_credit AS credit,
rag.final_balance AS final_balance
rag.final_balance AS final_balance,
rag.currency_name AS currency_name,
rag.initial_balance_foreign_currency AS initial_balance_foreign_currency,
rag.final_balance_foreign_currency AS final_balance_foreign_currency
FROM
report_general_ledger_qweb_account rag
WHERE

Loading…
Cancel
Save