[12.0] account_financial_report: refactor

This commit is contained in:
Joan Sisquella
2020-01-23 17:27:52 +01:00
committed by chaule97
parent b26ee9ff05
commit 1227d53d4f
45 changed files with 5446 additions and 7930 deletions

View File

@@ -2,10 +2,6 @@
# ?? 2016 Julien Coux (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).-
from . import abstract_test
from . import abstract_test_tax_report
from . import abstract_test_foreign_currency
from . import test_aged_partner_balance
from . import test_general_ledger
from . import test_journal_ledger
from . import test_open_items

View File

@@ -1,399 +0,0 @@
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
from odoo.tests import common
from odoo.tools import test_reports
_logger = logging.getLogger(__name__)
class AbstractTest(common.TransactionCase):
"""Common technical tests for all reports."""
at_install = False
post_install = True
accounts = {}
def with_context(self, *args, **kwargs):
context = dict(args[0] if args else self.env.context, **kwargs)
self.env = self.env(context=context)
return self
def _chart_template_create(self):
transfer_account_id = self.env['account.account.template'].create({
'code': '000',
'name': 'Liquidity Transfers',
'reconcile': True,
'user_type_id': self.ref(
"account.data_account_type_current_assets"),
})
self.chart = self.env['account.chart.template'].create({
'name': 'Test COA',
'code_digits': 4,
'bank_account_code_prefix': 1014,
'cash_account_code_prefix': 1014,
'currency_id': self.ref('base.USD'),
'transfer_account_code_prefix': '000',
})
transfer_account_id.update({
'chart_template_id': self.chart.id,
})
self.env['ir.model.data'].create({
'res_id': transfer_account_id.id,
'model': transfer_account_id._name,
'name': 'Liquidity Transfers',
})
act = self.env['account.account.template'].create({
'code': '001',
'name': 'Expenses',
'user_type_id': self.ref("account.data_account_type_expenses"),
'chart_template_id': self.chart.id,
'reconcile': True,
})
self.env['ir.model.data'].create({
'res_id': act.id,
'model': act._name,
'name': 'expenses',
})
act = self.env['account.account.template'].create({
'code': '002',
'name': 'Product Sales',
'user_type_id': self.ref("account.data_account_type_revenue"),
'chart_template_id': self.chart.id,
'reconcile': True,
})
self.env['ir.model.data'].create({
'res_id': act.id,
'model': act._name,
'name': 'sales',
})
act = self.env['account.account.template'].create({
'code': '003',
'name': 'Account Receivable',
'user_type_id': self.ref("account.data_account_type_receivable"),
'chart_template_id': self.chart.id,
'reconcile': True,
})
self.env['ir.model.data'].create({
'res_id': act.id,
'model': act._name,
'name': 'receivable',
})
act = self.env['account.account.template'].create({
'code': '004',
'name': 'Account Payable',
'user_type_id': self.ref("account.data_account_type_payable"),
'chart_template_id': self.chart.id,
'reconcile': True,
})
self.env['ir.model.data'].create({
'res_id': act.id,
'model': act._name,
'name': 'payable',
})
def _add_chart_of_accounts(self):
self.company = self.env['res.company'].create({
'name': 'Spanish test company',
})
self.env.ref('base.group_multi_company').write({
'users': [(4, self.env.uid)],
})
self.env.user.write({
'company_ids': [(4, self.company.id)],
'company_id': self.company.id,
})
self.with_context(
company_id=self.company.id, force_company=self.company.id)
self.chart.try_loading_for_current_company()
self.revenue = self.env['account.account'].search(
[('user_type_id', '=', self.ref(
"account.data_account_type_revenue"))], limit=1)
self.expense = self.env['account.account'].search(
[('user_type_id', '=', self.ref(
"account.data_account_type_expenses"))], limit=1)
self.receivable = self.env['account.account'].search(
[('user_type_id', '=', self.ref(
"account.data_account_type_receivable"))], limit=1)
self.payable = self.env['account.account'].search(
[('user_type_id', '=', self.ref(
"account.data_account_type_payable"))], limit=1)
return True
def _journals_create(self):
self.journal_sale = self.env['account.journal'].create({
'company_id': self.company.id,
'name': 'Test journal for sale',
'type': 'sale',
'code': 'TSALE',
'default_debit_account_id': self.revenue.id,
'default_credit_account_id': self.revenue.id,
})
self.journal_purchase = self.env['account.journal'].create({
'company_id': self.company.id,
'name': 'Test journal for purchase',
'type': 'purchase',
'code': 'TPUR',
'default_debit_account_id': self.expense.id,
'default_credit_account_id': self.expense.id,
})
return True
def _invoice_create(self):
self.partner = self.env['res.partner'].create({
'name': 'Test partner',
'company_id': self.company.id,
'property_account_receivable_id': self.receivable.id,
'property_account_payable_id': self.payable.id,
})
# customer invoice
customer_invoice_lines = [(0, False, {
'name': 'Test description #1',
'account_id': self.revenue.id,
'quantity': 1.0,
'price_unit': 100.0,
}), (0, False, {
'name': 'Test description #2',
'account_id': self.revenue.id,
'quantity': 2.0,
'price_unit': 25.0,
})]
self.invoice_out = self.env['account.invoice'].create({
'partner_id': self.partner.id,
'type': 'out_invoice',
'invoice_line_ids': customer_invoice_lines,
'account_id': self.partner.property_account_receivable_id.id,
'journal_id': self.journal_sale.id,
})
self.invoice_out.action_invoice_open()
# vendor bill
vendor_invoice_lines = [(0, False, {
'name': 'Test description #1',
'account_id': self.revenue.id,
'quantity': 1.0,
'price_unit': 100.0,
}), (0, False, {
'name': 'Test description #2',
'account_id': self.revenue.id,
'quantity': 2.0,
'price_unit': 25.0,
})]
self.invoice_in = self.env['account.invoice'].create({
'partner_id': self.partner.id,
'type': 'in_invoice',
'invoice_line_ids': vendor_invoice_lines,
'account_id': self.partner.property_account_payable_id.id,
'journal_id': self.journal_purchase.id,
})
self.invoice_in.action_invoice_open()
def setUp(self):
super(AbstractTest, self).setUp()
self.with_context()
self._chart_template_create()
self._add_chart_of_accounts()
self._journals_create()
self._invoice_create()
self.model = self._getReportModel()
self.qweb_report_name = self._getQwebReportName()
self.xlsx_report_name = self._getXlsxReportName()
self.xlsx_action_name = self._getXlsxReportActionName()
self.report_title = self._getReportTitle()
self.base_filters = self._getBaseFilters()
self.additional_filters = self._getAdditionalFiltersToBeTested()
self.report = self.model.create(self.base_filters)
self.report.compute_data_for_report()
def test_html(self):
test_reports.try_report(self.env.cr, self.env.uid,
self.qweb_report_name,
[self.report.id],
report_type='qweb-html')
def test_qweb(self):
test_reports.try_report(self.env.cr, self.env.uid,
self.qweb_report_name,
[self.report.id],
report_type='qweb-pdf')
def test_xlsx(self):
test_reports.try_report(self.env.cr, self.env.uid,
self.xlsx_report_name,
[self.report.id],
report_type='xlsx')
def test_print(self):
self.report.print_report('qweb')
self.report.print_report('xlsx')
def test_02_generation_report_html(self):
"""Check if report HTML is correctly generated"""
# Check if returned report action is correct
report_type = 'qweb-html'
report_action = self.report.print_report(report_type)
self.assertDictContainsSubset(
{
'type': 'ir.actions.report',
'report_name': self.qweb_report_name,
'report_type': 'qweb-html',
},
report_action
)
# Check if report template is correct
report = self.env['ir.actions.report'].search(
[('report_name', '=', self.qweb_report_name),
('report_type', '=', report_type)], limit=1)
self.assertEqual(report.report_type, 'qweb-html')
rep = report.render(self.report.ids, {})
self.assertTrue(self.report_title.encode('utf8') in rep[0])
self.assertTrue(
self.report.account_ids[0].name.encode('utf8') in rep[0]
)
def test_04_compute_data(self):
"""Check that the SQL queries work with all filters options"""
for filters in [{}] + self.additional_filters:
current_filter = self.base_filters.copy()
current_filter.update(filters)
report = self.model.create(current_filter)
report.compute_data_for_report()
self.assertGreaterEqual(len(report.account_ids), 1)
# Same filters with only one account
current_filter = self.base_filters.copy()
current_filter.update(filters)
report_accounts = report.account_ids.filtered('account_id')
current_filter.update({
'filter_account_ids':
[(6, 0, report_accounts[0].account_id.ids)],
})
report2 = self.model.create(current_filter)
report2.compute_data_for_report()
self.assertEqual(len(report2.account_ids), 1)
self.assertEqual(report2.account_ids.name,
report_accounts[0].name)
if self._partner_test_is_possible(filters):
# Same filters with only one partner
report_partner_ids = report.account_ids.mapped('partner_ids')
partner_ids = report_partner_ids.mapped('partner_id')
current_filter = self.base_filters.copy()
current_filter.update(filters)
current_filter.update({
'filter_partner_ids': [(6, 0, partner_ids[0].ids)],
})
report3 = self.model.create(current_filter)
report3.compute_data_for_report()
self.assertGreaterEqual(len(report3.account_ids), 1)
report_partner_ids3 = report3.account_ids.mapped('partner_ids')
partner_ids3 = report_partner_ids3.mapped('partner_id')
self.assertEqual(len(partner_ids3), 1)
self.assertEqual(
partner_ids3.name,
partner_ids[0].name
)
# Same filters with only one partner and one account
report_partner_ids = report3.account_ids.mapped('partner_ids')
report_account_id = report_partner_ids.filtered(
lambda p: p.partner_id
)[0].report_account_id
current_filter = self.base_filters.copy()
current_filter.update(filters)
current_filter.update({
'filter_account_ids':
[(6, 0, report_account_id.account_id.ids)],
'filter_partner_ids': [(6, 0, partner_ids[0].ids)],
})
report4 = self.model.create(current_filter)
report4.compute_data_for_report()
self.assertEqual(len(report4.account_ids), 1)
self.assertEqual(report4.account_ids.name,
report_account_id.account_id.name)
report_partner_ids4 = report4.account_ids.mapped('partner_ids')
partner_ids4 = report_partner_ids4.mapped('partner_id')
self.assertEqual(len(partner_ids4), 1)
self.assertEqual(
partner_ids4.name,
partner_ids[0].name
)
def _partner_test_is_possible(self, filters):
"""
:return:
a boolean to indicate if partner test is possible
with current filters
"""
return True
def _getReportModel(self):
"""
:return: the report model name
"""
raise NotImplementedError()
def _getQwebReportName(self):
"""
:return: the qweb report name
"""
raise NotImplementedError()
def _getXlsxReportName(self):
"""
:return: the xlsx report name
"""
raise NotImplementedError()
def _getXlsxReportActionName(self):
"""
:return: the xlsx report action name
"""
raise NotImplementedError()
def _getReportTitle(self):
"""
:return: the report title displayed into the report
"""
raise NotImplementedError()
def _getBaseFilters(self):
"""
:return: the minimum required filters to generate report
"""
raise NotImplementedError()
def _getAdditionalFiltersToBeTested(self):
"""
:return: the additional filters to generate report variants
"""
raise NotImplementedError()

View File

@@ -1,78 +0,0 @@
# Copyright 2018 Forest and Biomass Romania
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
from . import abstract_test
_logger = logging.getLogger(__name__)
class AbstractTestForeignCurrency(abstract_test.AbstractTest):
"""Common technical tests for all reports."""
def _chart_template_create(self):
super(AbstractTestForeignCurrency, self)._chart_template_create()
# Account for foreign payments
self.account_type_other = self.env['account.account.type'].create(
{'name': 'foreign expenses',
'type': 'other',
})
act = self.env['account.account.template'].create({
'code': '0012',
'name': 'Foreign Expenses',
'user_type_id': self.account_type_other.id,
'chart_template_id': self.chart.id,
'currency_id': self.env.ref('base.EUR').id,
})
self.env['ir.model.data'].create({
'res_id': act.id,
'model': act._name,
'name': 'foreign expenses',
})
return True
def _add_chart_of_accounts(self):
super(AbstractTestForeignCurrency, self)._add_chart_of_accounts()
self.foreign_expense = self.env['account.account'].search(
[('currency_id', '=', self.env.ref('base.EUR').id)], limit=1)
self.foreign_currency_id = self.foreign_expense.currency_id
return True
def _journals_create(self):
super(AbstractTestForeignCurrency, self)._journals_create()
self.journal_foreign_purchases = self.env['account.journal'].create({
'company_id': self.company.id,
'name': 'Test journal for purchase',
'type': 'purchase',
'code': 'TFORPUR',
'default_debit_account_id': self.foreign_expense.id,
'default_credit_account_id': self.foreign_expense.id,
'currency_id': self.foreign_currency_id.id,
})
return True
def _invoice_create(self):
super(AbstractTestForeignCurrency, self)._invoice_create()
# vendor bill foreign currency
foreign_vendor_invoice_lines = [(0, False, {
'name': 'Test description #1',
'account_id': self.revenue.id,
'quantity': 1.0,
'price_unit': 100.0,
'currency_id': self.foreign_currency_id.id,
}), (0, False, {
'name': 'Test description #2',
'account_id': self.revenue.id,
'quantity': 2.0,
'price_unit': 25.0,
'currency_id': self.foreign_currency_id.id,
})]
self.foreign_invoice_in = self.env['account.invoice'].create({
'partner_id': self.partner.id,
'type': 'in_invoice',
'invoice_line_ids': foreign_vendor_invoice_lines,
'account_id': self.partner.property_account_payable_id.id,
'journal_id': self.journal_foreign_purchases.id,
})
self.foreign_invoice_in.action_invoice_open()
return True

View File

@@ -1,75 +0,0 @@
# Copyright 2018 Forest and Biomass Romania
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
from odoo.tests.common import TransactionCase
from odoo.tools import test_reports
_logger = logging.getLogger(__name__)
class AbstractTest(TransactionCase):
"""Common technical tests for all reports."""
def setUp(cls):
super(AbstractTest, cls).setUp()
cls.model = cls._getReportModel()
cls.qweb_report_name = cls._getQwebReportName()
cls.xlsx_report_name = cls._getXlsxReportName()
cls.xlsx_action_name = cls._getXlsxReportActionName()
cls.report_title = cls._getReportTitle()
cls.base_filters = cls._getBaseFilters()
cls.report = cls.model.create(cls.base_filters)
cls.report.compute_data_for_report()
def test_html(self):
test_reports.try_report(self.env.cr, self.env.uid,
self.qweb_report_name,
[self.report.id],
report_type='qweb-html')
def test_qweb(self):
test_reports.try_report(self.env.cr, self.env.uid,
self.qweb_report_name,
[self.report.id],
report_type='qweb-pdf')
def test_xlsx(self):
test_reports.try_report(self.env.cr, self.env.uid,
self.xlsx_report_name,
[self.report.id],
report_type='xlsx')
def test_print(self):
self.report.print_report('qweb')
self.report.print_report('xlsx')
def test_generation_report_html(self):
"""Check if report HTML is correctly generated"""
# Check if returned report action is correct
report_type = 'qweb-html'
report_action = self.report.print_report(report_type)
self.assertDictContainsSubset(
{
'type': 'ir.actions.report',
'report_name': self.qweb_report_name,
'report_type': 'qweb-html',
},
report_action
)
# Check if report template is correct
report = self.env['ir.actions.report'].search(
[('report_name', '=', self.qweb_report_name),
('report_type', '=', report_type)], limit=1)
self.assertEqual(report.report_type, 'qweb-html')
rep = report.render(self.report.ids, {})
self.assertTrue(self.report_title.encode('utf8') in rep[0])

View File

@@ -1,41 +0,0 @@
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from datetime import date
from . import abstract_test
class TestAgedPartnerBalance(abstract_test.AbstractTest):
"""
Technical tests for Aged Partner Balance Report.
"""
def _getReportModel(self):
return self.env['report_aged_partner_balance']
def _getQwebReportName(self):
return 'account_financial_report.report_aged_partner_balance_qweb'
def _getXlsxReportName(self):
return 'a_f_r.report_aged_partner_balance_xlsx'
def _getXlsxReportActionName(self):
return 'account_financial_report.' \
'action_report_aged_partner_balance_xlsx'
def _getReportTitle(self):
return 'Odoo'
def _getBaseFilters(self):
return {
'date_at': date(date.today().year, 12, 31),
'company_id': self.company.id,
}
def _getAdditionalFiltersToBeTested(self):
return [
{'only_posted_moves': True},
{'show_move_line_details': True},
{'only_posted_moves': True, 'show_move_line_details': True},
]

View File

@@ -1,88 +1,13 @@
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import time
from odoo.tests import common
from odoo import fields
from odoo import fields, api
from datetime import date
from . import abstract_test_foreign_currency as a_t_f_c
class TestGeneralLedger(a_t_f_c.AbstractTestForeignCurrency):
"""
Technical tests for General Ledger Report.
"""
def _getReportModel(self):
return self.env['report_general_ledger']
def _getQwebReportName(self):
return 'account_financial_report.report_general_ledger_qweb'
def _getXlsxReportName(self):
return 'a_f_r.report_general_ledger_xlsx'
def _getXlsxReportActionName(self):
return 'account_financial_report.' \
'action_report_general_ledger_xlsx'
def _getReportTitle(self):
return 'Odoo'
def _getBaseFilters(self):
return {
'date_from': date(date.today().year, 1, 1),
'date_to': date(date.today().year, 12, 31),
'company_id': self.company.id,
'fy_start_date': date(date.today().year, 1, 1),
'foreign_currency': True,
}
def _getAdditionalFiltersToBeTested(self):
additional_filters = [
{'only_posted_moves': True},
{'hide_account_at_0': True},
{'centralize': True},
{'only_posted_moves': True, 'hide_account_at_0': True},
{'only_posted_moves': True, 'centralize': True},
{'hide_account_at_0': True, 'centralize': True},
{
'only_posted_moves': True,
'hide_account_at_0': True,
'centralize': True
},
]
# Add `show_analytic_tags` filter on each cases
additional_filters_with_show_tags = []
for additional_filter in additional_filters:
additional_filter['show_analytic_tags'] = True
additional_filters_with_show_tags.append(
additional_filter
)
additional_filters += additional_filters_with_show_tags
# Add `filter_analytic_tag_ids` filter on each cases
analytic_tag = self.env['account.analytic.tag'].create({
'name': 'TEST tag'
})
# Define all move lines on this tag
# (this test just check with the all filters, all works technically)
move_lines = self.env['account.move.line'].search([])
move_lines.write({
'analytic_tag_ids': [(6, False, analytic_tag.ids)],
})
additional_filters_with_filter_tags = []
for additional_filter in additional_filters:
additional_filter['filter_analytic_tag_ids'] = [
(6, False, analytic_tag.ids)
]
additional_filters_with_filter_tags.append(
additional_filter
)
additional_filters += additional_filters_with_filter_tags
return additional_filters
class TestGeneralLedgerReport(common.TransactionCase):
@@ -106,6 +31,7 @@ class TestGeneralLedgerReport(common.TransactionCase):
'=',
self.env.ref('account.data_unaffected_earnings').id
)], limit=1)
self.partner = self.env.ref('base.res_partner_12')
def _add_move(
self,
@@ -148,47 +74,92 @@ class TestGeneralLedgerReport(common.TransactionCase):
move.post()
def _get_report_lines(self, with_partners=False):
centralize = True
if with_partners:
centralize = False
company = self.env.ref('base.main_company')
general_ledger = self.env['report_general_ledger'].create({
general_ledger = self.env['general.ledger.report.wizard'].create({
'date_from': self.fy_date_start,
'date_to': self.fy_date_end,
'only_posted_moves': True,
'target_move': 'posted',
'hide_account_at_0': False,
'company_id': company.id,
'fy_start_date': self.fy_date_start,
'centralize': centralize,
})
general_ledger.compute_data_for_report(
with_line_details=True, with_partners=with_partners
)
lines = {}
report_account_model = self.env['report_general_ledger_account']
lines['receivable'] = report_account_model.search([
('report_id', '=', general_ledger.id),
('account_id', '=', self.receivable_account.id),
])
lines['income'] = report_account_model.search([
('report_id', '=', general_ledger.id),
('account_id', '=', self.income_account.id),
])
lines['unaffected'] = report_account_model.search([
('report_id', '=', general_ledger.id),
('account_id', '=', self.unaffected_account.id),
])
if with_partners:
report_partner_model = self.env[
'report_general_ledger_partner'
]
lines['partner_receivable'] = report_partner_model.search([
('report_account_id', '=', lines['receivable'].id),
('partner_id', '=', self.env.ref('base.res_partner_12').id),
])
return lines
data = general_ledger._prepare_report_general_ledger()
res_data = self.env[
'report.account_financial_report.general_ledger'
]._get_report_values(general_ledger, data)
return res_data
@api.model
def check_account_in_report(self, account_id, general_ledger):
account_in_report = False
for account in general_ledger:
if account['id'] == account_id:
account_in_report = True
break
return account_in_report
@api.model
def check_partner_in_report(self, account_id, partner_id, general_ledger):
partner_in_report = False
for account in general_ledger:
if account['id'] == account_id and account['partners']:
for partner in account['list_partner']:
if partner['id'] == partner_id:
partner_in_report = True
return partner_in_report
@api.model
def _get_initial_balance(self, account_id, general_ledger):
initial_balance = False
for account in general_ledger:
if account['id'] == account_id:
initial_balance = account['init_bal']
return initial_balance
@api.model
def _get_partner_initial_balance(self, account_id, partner_id,
general_ledger):
initial_balance = False
for account in general_ledger:
if account['id'] == account_id and account['partners']:
for partner in account['list_partner']:
if partner['id'] == partner_id:
initial_balance = partner['init_bal']
return initial_balance
@api.model
def _get_final_balance(self, account_id, general_ledger):
final_balance = False
for account in general_ledger:
if account['id'] == account_id:
final_balance = account['fin_bal']
return final_balance
@api.model
def _get_partner_final_balance(
self, account_id, partner_id, general_ledger):
final_balance = False
for account in general_ledger:
if account['id'] == account_id and account['partners']:
for partner in account['list_partner']:
if partner['id'] == partner_id:
final_balance = partner['fin_bal']
return final_balance
def test_01_account_balance(self):
# Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['receivable']), 0)
self.assertEqual(len(lines['income']), 0)
res_data = self._get_report_lines()
general_ledger = res_data['general_ledger']
check_receivable_account = self.check_account_in_report(
self.receivable_account.id, general_ledger)
self.assertFalse(check_receivable_account)
check_income_account = self.check_account_in_report(
self.income_account.id, general_ledger)
self.assertFalse(check_income_account)
# Add a move at the previous day of the first day of fiscal year
# to check the initial balance
@@ -201,17 +172,27 @@ class TestGeneralLedgerReport(common.TransactionCase):
)
# Re Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['receivable']), 1)
self.assertEqual(len(lines['income']), 0)
res_data = self._get_report_lines()
general_ledger = res_data['general_ledger']
check_receivable_account = self.check_account_in_report(
self.receivable_account.id, general_ledger)
self.assertTrue(check_receivable_account)
check_income_account = self.check_account_in_report(
self.income_account.id, general_ledger)
self.assertFalse(check_income_account)
# Check the initial and final balance
self.assertEqual(lines['receivable'].initial_debit, 1000)
self.assertEqual(lines['receivable'].initial_credit, 0)
self.assertEqual(lines['receivable'].initial_balance, 1000)
self.assertEqual(lines['receivable'].final_debit, 1000)
self.assertEqual(lines['receivable'].final_credit, 0)
self.assertEqual(lines['receivable'].final_balance, 1000)
receivable_init_balance = self._get_initial_balance(
self.receivable_account.id, general_ledger)
receivable_fin_balance = self._get_final_balance(
self.receivable_account.id, general_ledger)
self.assertEqual(receivable_init_balance['debit'], 1000)
self.assertEqual(receivable_init_balance['credit'], 0)
self.assertEqual(receivable_init_balance['balance'], 1000)
self.assertEqual(receivable_fin_balance['debit'], 1000)
self.assertEqual(receivable_fin_balance['credit'], 0)
self.assertEqual(receivable_fin_balance['balance'], 1000)
# Add reversale move of the initial move the first day of fiscal year
# to check the first day of fiscal year is not used
@@ -225,24 +206,38 @@ class TestGeneralLedgerReport(common.TransactionCase):
)
# Re Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['receivable']), 1)
self.assertEqual(len(lines['income']), 1)
res_data = self._get_report_lines()
general_ledger = res_data['general_ledger']
check_receivable_account = self.check_account_in_report(
self.receivable_account.id, general_ledger)
self.assertTrue(check_receivable_account)
check_income_account = self.check_account_in_report(
self.income_account.id, general_ledger)
self.assertTrue(check_income_account)
# Check the initial and final balance
self.assertEqual(lines['receivable'].initial_debit, 1000)
self.assertEqual(lines['receivable'].initial_credit, 0)
self.assertEqual(lines['receivable'].initial_balance, 1000)
self.assertEqual(lines['receivable'].final_debit, 1000)
self.assertEqual(lines['receivable'].final_credit, 1000)
self.assertEqual(lines['receivable'].final_balance, 0)
receivable_init_balance = self._get_initial_balance(
self.receivable_account.id, general_ledger)
receivable_fin_balance = self._get_final_balance(
self.receivable_account.id, general_ledger)
income_init_balance = self._get_initial_balance(
self.income_account.id, general_ledger)
income_fin_balance = self._get_final_balance(
self.income_account.id, general_ledger)
self.assertEqual(lines['income'].initial_debit, 0)
self.assertEqual(lines['income'].initial_credit, 0)
self.assertEqual(lines['income'].initial_balance, 0)
self.assertEqual(lines['income'].final_debit, 1000)
self.assertEqual(lines['income'].final_credit, 0)
self.assertEqual(lines['income'].final_balance, 1000)
self.assertEqual(receivable_init_balance['debit'], 1000)
self.assertEqual(receivable_init_balance['credit'], 0)
self.assertEqual(receivable_init_balance['balance'], 1000)
self.assertEqual(receivable_fin_balance['debit'], 1000)
self.assertEqual(receivable_fin_balance['credit'], 1000)
self.assertEqual(receivable_fin_balance['balance'], 0)
self.assertEqual(income_init_balance['debit'], 0)
self.assertEqual(income_init_balance['credit'], 0)
self.assertEqual(income_init_balance['balance'], 0)
self.assertEqual(income_fin_balance['debit'], 1000)
self.assertEqual(income_fin_balance['credit'], 0)
self.assertEqual(income_fin_balance['balance'], 1000)
# Add another move at the end day of fiscal year
# to check that it correctly used on report
@@ -255,29 +250,46 @@ class TestGeneralLedgerReport(common.TransactionCase):
)
# Re Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['receivable']), 1)
self.assertEqual(len(lines['income']), 1)
res_data = self._get_report_lines()
general_ledger = res_data['general_ledger']
check_receivable_account = self.check_account_in_report(
self.receivable_account.id, general_ledger)
self.assertTrue(check_receivable_account)
check_income_account = self.check_account_in_report(
self.income_account.id, general_ledger)
self.assertTrue(check_income_account)
# Check the initial and final balance
self.assertEqual(lines['receivable'].initial_debit, 1000)
self.assertEqual(lines['receivable'].initial_credit, 0)
self.assertEqual(lines['receivable'].initial_balance, 1000)
self.assertEqual(lines['receivable'].final_debit, 1000)
self.assertEqual(lines['receivable'].final_credit, 2000)
self.assertEqual(lines['receivable'].final_balance, -1000)
receivable_init_balance = self._get_initial_balance(
self.receivable_account.id, general_ledger)
receivable_fin_balance = self._get_final_balance(
self.receivable_account.id, general_ledger)
income_init_balance = self._get_initial_balance(
self.income_account.id, general_ledger)
income_fin_balance = self._get_final_balance(
self.income_account.id, general_ledger)
self.assertEqual(lines['income'].initial_debit, 0)
self.assertEqual(lines['income'].initial_credit, 0)
self.assertEqual(lines['income'].initial_balance, 0)
self.assertEqual(lines['income'].final_debit, 2000)
self.assertEqual(lines['income'].final_credit, 0)
self.assertEqual(lines['income'].final_balance, 2000)
self.assertEqual(receivable_init_balance['debit'], 1000)
self.assertEqual(receivable_init_balance['credit'], 0)
self.assertEqual(receivable_init_balance['balance'], 1000)
self.assertEqual(receivable_fin_balance['debit'], 1000)
self.assertEqual(receivable_fin_balance['credit'], 2000)
self.assertEqual(receivable_fin_balance['balance'], -1000)
self.assertEqual(income_init_balance['debit'], 0)
self.assertEqual(income_init_balance['credit'], 0)
self.assertEqual(income_init_balance['balance'], 0)
self.assertEqual(income_fin_balance['debit'], 2000)
self.assertEqual(income_fin_balance['credit'], 0)
self.assertEqual(income_fin_balance['balance'], 2000)
def test_02_partner_balance(self):
# Generate the general ledger line
lines = self._get_report_lines(with_partners=True)
self.assertEqual(len(lines['partner_receivable']), 0)
res_data = self._get_report_lines(with_partners=True)
general_ledger = res_data['general_ledger']
check_partner = self.check_partner_in_report(
self.receivable_account.id, self.partner.id, general_ledger)
self.assertFalse(check_partner)
# Add a move at the previous day of the first day of fiscal year
# to check the initial balance
@@ -290,16 +302,26 @@ class TestGeneralLedgerReport(common.TransactionCase):
)
# Re Generate the general ledger line
lines = self._get_report_lines(with_partners=True)
self.assertEqual(len(lines['partner_receivable']), 1)
res_data = self._get_report_lines(with_partners=True)
general_ledger = res_data['general_ledger']
check_partner = self.check_partner_in_report(
self.receivable_account.id, self.partner.id, general_ledger)
self.assertTrue(check_partner)
# Check the initial and final balance
self.assertEqual(lines['partner_receivable'].initial_debit, 1000)
self.assertEqual(lines['partner_receivable'].initial_credit, 0)
self.assertEqual(lines['partner_receivable'].initial_balance, 1000)
self.assertEqual(lines['partner_receivable'].final_debit, 1000)
self.assertEqual(lines['partner_receivable'].final_credit, 0)
self.assertEqual(lines['partner_receivable'].final_balance, 1000)
partner_initial_balance = self._get_partner_initial_balance(
self.receivable_account.id, self.partner.id, general_ledger
)
partner_final_balance = self._get_partner_final_balance(
self.receivable_account.id, self.partner.id, general_ledger
)
self.assertEqual(partner_initial_balance['debit'], 1000)
self.assertEqual(partner_initial_balance['credit'], 0)
self.assertEqual(partner_initial_balance['balance'], 1000)
self.assertEqual(partner_final_balance['debit'], 1000)
self.assertEqual(partner_final_balance['credit'], 0)
self.assertEqual(partner_final_balance['balance'], 1000)
# Add reversale move of the initial move the first day of fiscal year
# to check the first day of fiscal year is not used
@@ -313,16 +335,26 @@ class TestGeneralLedgerReport(common.TransactionCase):
)
# Re Generate the general ledger line
lines = self._get_report_lines(with_partners=True)
self.assertEqual(len(lines['partner_receivable']), 1)
res_data = self._get_report_lines(with_partners=True)
general_ledger = res_data['general_ledger']
check_partner = self.check_partner_in_report(
self.receivable_account.id, self.partner.id, general_ledger)
self.assertTrue(check_partner)
# Check the initial and final balance
self.assertEqual(lines['partner_receivable'].initial_debit, 1000)
self.assertEqual(lines['partner_receivable'].initial_credit, 0)
self.assertEqual(lines['partner_receivable'].initial_balance, 1000)
self.assertEqual(lines['partner_receivable'].final_debit, 1000)
self.assertEqual(lines['partner_receivable'].final_credit, 1000)
self.assertEqual(lines['partner_receivable'].final_balance, 0)
partner_initial_balance = self._get_partner_initial_balance(
self.receivable_account.id, self.partner.id, general_ledger
)
partner_final_balance = self._get_partner_final_balance(
self.receivable_account.id, self.partner.id, general_ledger
)
self.assertEqual(partner_initial_balance['debit'], 1000)
self.assertEqual(partner_initial_balance['credit'], 0)
self.assertEqual(partner_initial_balance['balance'], 1000)
self.assertEqual(partner_final_balance['debit'], 1000)
self.assertEqual(partner_final_balance['credit'], 1000)
self.assertEqual(partner_final_balance['balance'], 0)
# Add another move at the end day of fiscal year
# to check that it correctly used on report
@@ -335,29 +367,47 @@ class TestGeneralLedgerReport(common.TransactionCase):
)
# Re Generate the general ledger line
lines = self._get_report_lines(with_partners=True)
self.assertEqual(len(lines['partner_receivable']), 1)
res_data = self._get_report_lines(with_partners=True)
general_ledger = res_data['general_ledger']
check_partner = self.check_partner_in_report(
self.receivable_account.id, self.partner.id, general_ledger)
self.assertTrue(check_partner)
# Check the initial and final balance
self.assertEqual(lines['partner_receivable'].initial_debit, 1000)
self.assertEqual(lines['partner_receivable'].initial_credit, 0)
self.assertEqual(lines['partner_receivable'].initial_balance, 1000)
self.assertEqual(lines['partner_receivable'].final_debit, 1000)
self.assertEqual(lines['partner_receivable'].final_credit, 2000)
self.assertEqual(lines['partner_receivable'].final_balance, -1000)
partner_initial_balance = self._get_partner_initial_balance(
self.receivable_account.id, self.partner.id, general_ledger
)
partner_final_balance = self._get_partner_final_balance(
self.receivable_account.id, self.partner.id, general_ledger
)
self.assertEqual(partner_initial_balance['debit'], 1000)
self.assertEqual(partner_initial_balance['credit'], 0)
self.assertEqual(partner_initial_balance['balance'], 1000)
self.assertEqual(partner_final_balance['debit'], 1000)
self.assertEqual(partner_final_balance['credit'], 2000)
self.assertEqual(partner_final_balance['balance'], -1000)
def test_03_unaffected_account_balance(self):
# Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['unaffected']), 1)
res_data = self._get_report_lines()
general_ledger = res_data['general_ledger']
check_unaffected_account = self.check_account_in_report(
self.unaffected_account.id, general_ledger)
self.assertTrue(check_unaffected_account)
# Check the initial and final balance
self.assertEqual(lines['unaffected'].initial_debit, 0)
self.assertEqual(lines['unaffected'].initial_credit, 0)
self.assertEqual(lines['unaffected'].initial_balance, 0)
self.assertEqual(lines['unaffected'].final_debit, 0)
self.assertEqual(lines['unaffected'].final_credit, 0)
self.assertEqual(lines['unaffected'].final_balance, 0)
unaffected_init_balance = self._get_initial_balance(
self.unaffected_account.id, general_ledger)
unaffected_fin_balance = self._get_final_balance(
self.unaffected_account.id, general_ledger)
self.assertEqual(unaffected_init_balance['debit'], 0)
self.assertEqual(unaffected_init_balance['credit'], 0)
self.assertEqual(unaffected_init_balance['balance'], 0)
self.assertEqual(unaffected_fin_balance['debit'], 0)
self.assertEqual(unaffected_fin_balance['credit'], 0)
self.assertEqual(unaffected_fin_balance['balance'], 0)
# Add a move at the previous day of the first day of fiscal year
# to check the initial balance
@@ -370,16 +420,24 @@ class TestGeneralLedgerReport(common.TransactionCase):
)
# Re Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['unaffected']), 1)
res_data = self._get_report_lines()
general_ledger = res_data['general_ledger']
check_unaffected_account = self.check_account_in_report(
self.unaffected_account.id, general_ledger)
self.assertTrue(check_unaffected_account)
# Check the initial and final balance
self.assertEqual(lines['unaffected'].initial_debit, 0)
self.assertEqual(lines['unaffected'].initial_credit, 1000)
self.assertEqual(lines['unaffected'].initial_balance, -1000)
self.assertEqual(lines['unaffected'].final_debit, 0)
self.assertEqual(lines['unaffected'].final_credit, 1000)
self.assertEqual(lines['unaffected'].final_balance, -1000)
unaffected_init_balance = self._get_initial_balance(
self.unaffected_account.id, general_ledger)
unaffected_fin_balance = self._get_final_balance(
self.unaffected_account.id, general_ledger)
self.assertEqual(unaffected_init_balance['debit'], 0)
self.assertEqual(unaffected_init_balance['credit'], 1000)
self.assertEqual(unaffected_init_balance['balance'], -1000)
self.assertEqual(unaffected_fin_balance['debit'], 0)
self.assertEqual(unaffected_fin_balance['credit'], 1000)
self.assertEqual(unaffected_fin_balance['balance'], -1000)
# Add reversale move of the initial move the first day of fiscal year
# to check the first day of fiscal year is not used
@@ -395,16 +453,24 @@ class TestGeneralLedgerReport(common.TransactionCase):
)
# Re Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['unaffected']), 1)
res_data = self._get_report_lines()
general_ledger = res_data['general_ledger']
check_unaffected_account = self.check_account_in_report(
self.unaffected_account.id, general_ledger)
self.assertTrue(check_unaffected_account)
# Check the initial and final balance
self.assertEqual(lines['unaffected'].initial_debit, 0)
self.assertEqual(lines['unaffected'].initial_credit, 1000)
self.assertEqual(lines['unaffected'].initial_balance, -1000)
self.assertEqual(lines['unaffected'].final_debit, 1000)
self.assertEqual(lines['unaffected'].final_credit, 1000)
self.assertEqual(lines['unaffected'].final_balance, 0)
unaffected_init_balance = self._get_initial_balance(
self.unaffected_account.id, general_ledger)
unaffected_fin_balance = self._get_final_balance(
self.unaffected_account.id, general_ledger)
self.assertEqual(unaffected_init_balance['debit'], 0)
self.assertEqual(unaffected_init_balance['credit'], 1000)
self.assertEqual(unaffected_init_balance['balance'], -1000)
self.assertEqual(unaffected_fin_balance['debit'], 1000)
self.assertEqual(unaffected_fin_balance['credit'], 1000)
self.assertEqual(unaffected_fin_balance['balance'], 0)
# Add another move at the end day of fiscal year
# to check that it correctly used on report
@@ -419,29 +485,45 @@ class TestGeneralLedgerReport(common.TransactionCase):
)
# Re Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['unaffected']), 1)
res_data = self._get_report_lines()
general_ledger = res_data['general_ledger']
check_unaffected_account = self.check_account_in_report(
self.unaffected_account.id, general_ledger)
self.assertTrue(check_unaffected_account)
# Check the initial and final balance
self.assertEqual(lines['unaffected'].initial_debit, 0)
self.assertEqual(lines['unaffected'].initial_credit, 1000)
self.assertEqual(lines['unaffected'].initial_balance, -1000)
self.assertEqual(lines['unaffected'].final_debit, 1000)
self.assertEqual(lines['unaffected'].final_credit, 4000)
self.assertEqual(lines['unaffected'].final_balance, -3000)
unaffected_init_balance = self._get_initial_balance(
self.unaffected_account.id, general_ledger)
unaffected_fin_balance = self._get_final_balance(
self.unaffected_account.id, general_ledger)
self.assertEqual(unaffected_init_balance['debit'], 0)
self.assertEqual(unaffected_init_balance['credit'], 1000)
self.assertEqual(unaffected_init_balance['balance'], -1000)
self.assertEqual(unaffected_fin_balance['debit'], 1000)
self.assertEqual(unaffected_fin_balance['credit'], 4000)
self.assertEqual(unaffected_fin_balance['balance'], -3000)
def test_04_unaffected_account_balance_2_years(self):
# Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['unaffected']), 1)
res_data = self._get_report_lines()
general_ledger = res_data['general_ledger']
check_unaffected_account = self.check_account_in_report(
self.unaffected_account.id, general_ledger)
self.assertTrue(check_unaffected_account)
# Check the initial and final balance
self.assertEqual(lines['unaffected'].initial_debit, 0)
self.assertEqual(lines['unaffected'].initial_credit, 0)
self.assertEqual(lines['unaffected'].initial_balance, 0)
self.assertEqual(lines['unaffected'].final_debit, 0)
self.assertEqual(lines['unaffected'].final_credit, 0)
self.assertEqual(lines['unaffected'].final_balance, 0)
unaffected_init_balance = self._get_initial_balance(
self.unaffected_account.id, general_ledger)
unaffected_fin_balance = self._get_final_balance(
self.unaffected_account.id, general_ledger)
self.assertEqual(unaffected_init_balance['debit'], 0)
self.assertEqual(unaffected_init_balance['credit'], 0)
self.assertEqual(unaffected_init_balance['balance'], 0)
self.assertEqual(unaffected_fin_balance['debit'], 0)
self.assertEqual(unaffected_fin_balance['credit'], 0)
self.assertEqual(unaffected_fin_balance['balance'], 0)
# Add a move at any date 2 years before the balance
# (to create an historic)
@@ -454,16 +536,24 @@ class TestGeneralLedgerReport(common.TransactionCase):
)
# Re Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['unaffected']), 1)
res_data = self._get_report_lines()
general_ledger = res_data['general_ledger']
check_unaffected_account = self.check_account_in_report(
self.unaffected_account.id, general_ledger)
self.assertTrue(check_unaffected_account)
# Check the initial and final balance
self.assertEqual(lines['unaffected'].initial_debit, 1000)
self.assertEqual(lines['unaffected'].initial_credit, 0)
self.assertEqual(lines['unaffected'].initial_balance, 1000)
self.assertEqual(lines['unaffected'].final_debit, 1000)
self.assertEqual(lines['unaffected'].final_credit, 0)
self.assertEqual(lines['unaffected'].final_balance, 1000)
unaffected_init_balance = self._get_initial_balance(
self.unaffected_account.id, general_ledger)
unaffected_fin_balance = self._get_final_balance(
self.unaffected_account.id, general_ledger)
self.assertEqual(unaffected_init_balance['debit'], 1000)
self.assertEqual(unaffected_init_balance['credit'], 0)
self.assertEqual(unaffected_init_balance['balance'], 1000)
self.assertEqual(unaffected_fin_balance['debit'], 1000)
self.assertEqual(unaffected_fin_balance['credit'], 0)
self.assertEqual(unaffected_fin_balance['balance'], 1000)
# Affect the company's result last year
self._add_move(
@@ -486,17 +576,26 @@ class TestGeneralLedgerReport(common.TransactionCase):
unaffected_debit=0,
unaffected_credit=0
)
# Re Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['unaffected']), 1)
res_data = self._get_report_lines()
general_ledger = res_data['general_ledger']
check_unaffected_account = self.check_account_in_report(
self.unaffected_account.id, general_ledger)
self.assertTrue(check_unaffected_account)
# Check the initial and final balance
self.assertEqual(lines['unaffected'].initial_debit, 500)
self.assertEqual(lines['unaffected'].initial_credit, 0)
self.assertEqual(lines['unaffected'].initial_balance, 500)
self.assertEqual(lines['unaffected'].final_debit, 500)
self.assertEqual(lines['unaffected'].final_credit, 0)
self.assertEqual(lines['unaffected'].final_balance, 500)
unaffected_init_balance = self._get_initial_balance(
self.unaffected_account.id, general_ledger)
unaffected_fin_balance = self._get_final_balance(
self.unaffected_account.id, general_ledger)
self.assertEqual(unaffected_init_balance['debit'], 1500)
self.assertEqual(unaffected_init_balance['credit'], 1000)
self.assertEqual(unaffected_init_balance['balance'], 500)
self.assertEqual(unaffected_fin_balance['debit'], 1500)
self.assertEqual(unaffected_fin_balance['credit'], 1000)
self.assertEqual(unaffected_fin_balance['balance'], 500)
def test_partner_filter(self):
partner_1 = self.env.ref('base.res_partner_1')

View File

@@ -1,83 +1,13 @@
# Copyright 2017 ACSONE SA/NV
# Copyright 2019-20 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from datetime import datetime, date
from datetime import datetime
from dateutil.relativedelta import relativedelta
from odoo.fields import Date
from odoo.tests.common import TransactionCase
from . import abstract_test_foreign_currency as a_t_f_c
class TestJournalLedger(a_t_f_c.AbstractTestForeignCurrency):
"""
Technical tests for General Ledger Report.
"""
def _getReportModel(self):
return self.env['report_journal_ledger']
def _getQwebReportName(self):
return 'account_financial_report.report_journal_ledger_qweb'
def _getXlsxReportName(self):
return 'a_f_r.report_journal_ledger_xlsx'
def _getXlsxReportActionName(self):
return 'account_financial_report.' \
'action_report_journal_ledger_xlsx'
def _getReportTitle(self):
return 'Odoo'
def _getBaseFilters(self):
return {
'date_from': date(date.today().year, 1, 1),
'date_to': date(date.today().year, 12, 31),
'company_id': self.company.id,
'journal_ids': [(6, 0, self.journal_sale.ids)]
}
def _getAdditionalFiltersToBeTested(self):
return [
{'move_target': "All",
'sort_option': "Date",
'group_option': "Journal",
'with_account_name': True,
'foreign_currency': True},
]
def test_02_generation_report_html(self):
"""Check if report HTML is correctly generated"""
# Check if returned report action is correct
report_type = 'qweb-html'
report_action = self.report.print_report(report_type)
self.assertDictContainsSubset(
{
'type': 'ir.actions.report',
'report_name': self.qweb_report_name,
'report_type': 'qweb-html',
},
report_action
)
# Check if report template is correct
report = self.env['ir.actions.report'].search(
[('report_name', '=', self.qweb_report_name),
('report_type', '=', report_type)], limit=1)
self.assertEqual(report.report_type, 'qweb-html')
rep = report.render(self.report.ids, {})
self.assertTrue(self.report_title.encode('utf8') in rep[0])
self.assertTrue(
self.report.journal_ids[0].name.encode('utf8') in rep[0]
)
def test_04_compute_data(self):
return True
class TestJournalReport(TransactionCase):
@@ -86,11 +16,13 @@ class TestJournalReport(TransactionCase):
self.AccountObj = self.env['account.account']
self.InvoiceObj = self.env['account.invoice']
self.JournalObj = self.env['account.journal']
self.JournalReportObj = self.env['journal.ledger.report.wizard']
self.MoveObj = self.env['account.move']
self.ReportJournalLedger = self.env['report_journal_ledger']
self.TaxObj = self.env['account.tax']
self.JournalLedgerReportWizard = self.env[
'journal.ledger.report.wizard']
self.JournalLedgerReport = \
self.env['report.account_financial_report.journal_ledger']
self.company = self.env.ref('base.main_company')
today = datetime.today()
@@ -191,52 +123,50 @@ class TestJournalReport(TransactionCase):
return self.MoveObj.create(move_vals)
def check_report_journal_debit_credit(
self, report, expected_debit, expected_credit):
self, res_data, expected_debit, expected_credit):
self.assertEqual(
expected_debit,
sum([journal.debit for journal in
report.report_journal_ledger_ids])
sum([rec['debit'] for rec in res_data['Journal_Ledgers']])
)
self.assertEqual(
expected_credit,
sum([journal.credit for journal in
report.report_journal_ledger_ids])
sum([rec['credit'] for rec in res_data['Journal_Ledgers']])
)
def check_report_journal_debit_credit_taxes(
self, report,
self, res_data,
expected_base_debit, expected_base_credit,
expected_tax_debit, expected_tax_credit):
self.assertEqual(
expected_base_debit,
sum([
journal.base_debit
for journal in report.report_journal_ledger_tax_line_ids
])
)
self.assertEqual(
expected_base_credit,
sum([
journal.base_credit
for journal in report.report_journal_ledger_tax_line_ids
])
)
self.assertEqual(
expected_tax_debit,
sum([
journal.tax_debit
for journal in report.report_journal_ledger_tax_line_ids
])
)
self.assertEqual(
expected_tax_credit,
sum([
journal.tax_credit
for journal in report.report_journal_ledger_tax_line_ids
])
)
for rec in res_data['Journal_Ledgers']:
self.assertEqual(
expected_base_debit,
sum([
tax_line['base_debit']
for tax_line in rec['tax_lines']
])
)
self.assertEqual(
expected_base_credit,
sum([
tax_line['base_credit']
for tax_line in rec['tax_lines']
])
)
self.assertEqual(
expected_tax_debit,
sum([
tax_line['tax_debit']
for tax_line in rec['tax_lines']
])
)
self.assertEqual(
expected_tax_credit,
sum([
tax_line['tax_credit']
for tax_line in rec['tax_lines']
])
)
def test_01_test_total(self):
today_date = Date.today()
@@ -250,42 +180,43 @@ class TestJournalReport(TransactionCase):
last_year_date, self.journal_sale,
0, 100, 100, 0)
report = self.ReportJournalLedger.create({
wiz = self.JournalLedgerReportWizard.create({
'date_from': self.fy_date_start,
'date_to': self.fy_date_end,
'company_id': self.company.id,
'journal_ids': [(6, 0, self.journal_sale.ids)]
})
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 100, 100)
data = wiz._prepare_report_journal_ledger()
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(res_data, 100, 100)
move3 = self._add_move(
today_date, self.journal_sale,
0, 100, 100, 0)
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 200, 200)
report.move_target = 'posted'
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 0, 0)
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(res_data, 200, 200)
wiz.move_target = 'posted'
data = wiz._prepare_report_journal_ledger()
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(res_data, 0, 0)
move1.post()
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 100, 100)
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(res_data, 100, 100)
move2.post()
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 100, 100)
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(res_data, 100, 100)
move3.post()
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 200, 200)
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(res_data, 200, 200)
report.date_from = self.previous_fy_date_start
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 300, 300)
wiz.date_from = self.previous_fy_date_start
data = wiz._prepare_report_journal_ledger()
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(res_data, 300, 300)
def test_02_test_taxes_out_invoice(self):
invoice_values = {
@@ -314,16 +245,16 @@ class TestJournalReport(TransactionCase):
invoice = self.InvoiceObj.create(invoice_values)
invoice.action_invoice_open()
report = self.ReportJournalLedger.create({
wiz = self.JournalLedgerReportWizard.create({
'date_from': self.fy_date_start,
'date_to': self.fy_date_end,
'company_id': self.company.id,
'journal_ids': [(6, 0, self.journal_sale.ids)]
})
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 250, 250)
self.check_report_journal_debit_credit_taxes(report, 0, 300, 0, 50)
data = wiz._prepare_report_journal_ledger()
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(res_data, 250, 250)
self.check_report_journal_debit_credit_taxes(res_data, 0, 300, 0, 50)
def test_03_test_taxes_in_invoice(self):
invoice_values = {
@@ -352,13 +283,14 @@ class TestJournalReport(TransactionCase):
invoice = self.InvoiceObj.create(invoice_values)
invoice.action_invoice_open()
report = self.ReportJournalLedger.create({
wiz = self.JournalLedgerReportWizard.create({
'date_from': self.fy_date_start,
'date_to': self.fy_date_end,
'company_id': self.company.id,
'journal_ids': [(6, 0, self.journal_sale.ids)]
})
report.compute_data_for_report()
data = wiz._prepare_report_journal_ledger()
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(report, 250, 250)
self.check_report_journal_debit_credit_taxes(report, 300, 0, 50, 0)
self.check_report_journal_debit_credit(res_data, 250, 250)
self.check_report_journal_debit_credit_taxes(res_data, 300, 0, 50, 0)

View File

@@ -2,43 +2,10 @@
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from datetime import date
from . import abstract_test_foreign_currency as a_t_f_c
from odoo.tests.common import TransactionCase
class TestOpenItems(a_t_f_c.AbstractTestForeignCurrency):
"""
Technical tests for Open Items Report.
"""
def _getReportModel(self):
return self.env['report_open_items']
def _getQwebReportName(self):
return 'account_financial_report.report_open_items_qweb'
def _getXlsxReportName(self):
return 'a_f_r.report_open_items_xlsx'
def _getXlsxReportActionName(self):
return 'account_financial_report.action_report_open_items_xlsx'
def _getReportTitle(self):
return 'Odoo'
def _getBaseFilters(self):
return {
'date_at': date(date.today().year, 12, 31),
'company_id': self.company.id,
'foreign_currency': True,
}
def _getAdditionalFiltersToBeTested(self):
return [
{'only_posted_moves': True},
{'hide_account_at_0': True},
{'only_posted_moves': True, 'hide_account_at_0': True},
]
class TestOpenItems(TransactionCase):
def test_partner_filter(self):
partner_1 = self.env.ref('base.res_partner_1')

View File

@@ -1,65 +1,9 @@
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from datetime import date
from odoo.tests import common
from . import abstract_test_foreign_currency as a_t_f_c
class TestTrialBalance(a_t_f_c.AbstractTestForeignCurrency):
"""
Technical tests for Trial Balance Report.
"""
def _getReportModel(self):
return self.env['report_trial_balance']
def _getQwebReportName(self):
return 'account_financial_report.report_trial_balance_qweb'
def _getXlsxReportName(self):
return 'a_f_r.report_trial_balance_xlsx'
def _getXlsxReportActionName(self):
return 'account_financial_report.action_report_trial_balance_xlsx'
def _getReportTitle(self):
return 'Odoo'
def _getBaseFilters(self):
return {
'date_from': date(date.today().year, 1, 1),
'date_to': date(date.today().year, 12, 31),
'company_id': self.company.id,
'fy_start_date': date(date.today().year, 1, 1),
'foreign_currency': True,
'show_partner_details': True,
}
def _getAdditionalFiltersToBeTested(self):
return [
{'only_posted_moves': True},
{'hide_account_at_0': True},
{'show_partner_details': True},
{'hierarchy_on': 'computed'},
{'hierarchy_on': 'relation'},
{'only_posted_moves': True, 'hide_account_at_0': True,
'hierarchy_on': 'computed'},
{'only_posted_moves': True, 'hide_account_at_0': True,
'hierarchy_on': 'relation'},
{'only_posted_moves': True, 'hide_account_at_0': True},
{'only_posted_moves': True, 'show_partner_details': True},
{'hide_account_at_0': True, 'show_partner_details': True},
{
'only_posted_moves': True,
'hide_account_at_0': True,
'show_partner_details': True
},
]
def _partner_test_is_possible(self, filters):
return 'show_partner_details' in filters
class TestTrialBalanceReport(common.TransactionCase):
@@ -114,6 +58,13 @@ class TestTrialBalanceReport(common.TransactionCase):
self.fy_date_end = '2016-12-31'
self.date_start = '2016-01-01'
self.date_end = '2016-12-31'
self.partner = self.env.ref('base.res_partner_12')
self.unaffected_account = self.env['account.account'].search([
(
'user_type_id',
'=',
self.env.ref('account.data_unaffected_earnings').id
)], limit=1)
def _add_move(
self,
@@ -169,49 +120,81 @@ class TestTrialBalanceReport(common.TransactionCase):
def _get_report_lines(self, with_partners=False, hierarchy_on='computed'):
company = self.env.ref('base.main_company')
trial_balance = self.env['report_trial_balance'].create({
trial_balance = self.env['trial.balance.report.wizard'].create({
'date_from': self.date_start,
'date_to': self.date_end,
'only_posted_moves': True,
'hide_account_at_0': False,
'target_move': 'posted',
'hide_account_at_0': True,
'hierarchy_on': hierarchy_on,
'company_id': company.id,
'fy_start_date': self.fy_date_start,
'show_partner_details': with_partners,
})
trial_balance.compute_data_for_report()
lines = {}
report_account_model = self.env['report_trial_balance_account']
lines['receivable'] = report_account_model.search([
('report_id', '=', trial_balance.id),
('account_id', '=', self.account100.id),
])
lines['income'] = report_account_model.search([
('report_id', '=', trial_balance.id),
('account_id', '=', self.account200.id),
])
lines['unaffected'] = report_account_model.search([
('report_id', '=', trial_balance.id),
('account_id', '=', self.account110.id),
])
lines['group1'] = report_account_model.search([
('report_id', '=', trial_balance.id),
('account_group_id', '=', self.group1.id),
])
lines['group2'] = report_account_model.search([
('report_id', '=', trial_balance.id),
('account_group_id', '=', self.group2.id),
])
if with_partners:
report_partner_model = self.env[
'report_trial_balance_partner'
]
lines['partner_receivable'] = report_partner_model.search([
('report_account_id', '=', lines['receivable'].id),
('partner_id', '=', self.env.ref('base.res_partner_12').id),
])
data = trial_balance._prepare_report_trial_balance()
res_data = self.env[
'report.account_financial_report.trial_balance']._get_report_values(
trial_balance, data)
return res_data
def check_account_in_report(self, account_id, trial_balance):
account_in_report = False
for account in trial_balance:
if account['id'] == account_id and account['type'] == 'account_type':
account_in_report = True
break
return account_in_report
def _get_account_lines(self, account_id, trial_balance):
lines = False
for account in trial_balance:
if account['id'] == account_id and account['type'] == 'account_type':
lines = {
'initial_balance': account['initial_balance'],
'debit': account['debit'],
'credit': account['credit'],
'final_balance': account['ending_balance']
}
return lines
def _get_group_lines(self, group_id, trial_balance):
lines = False
for group in trial_balance:
if group['id'] == group_id and group['type'] == 'group_type':
lines = {
'initial_balance': group['initial_balance'],
'debit': group['debit'],
'credit': group['credit'],
'final_balance': group['ending_balance']
}
return lines
def check_partner_in_report(self, account_id, partner_id, total_amount):
partner_in_report = False
if account_id in total_amount.keys():
if partner_id in total_amount[account_id]:
partner_in_report = True
return partner_in_report
def _get_partner_lines(self, account_id, partner_id, total_amount):
acc_id = account_id
prt_id = partner_id
lines = {
'initial_balance': total_amount[acc_id][prt_id]['initial_balance'],
'debit': total_amount[acc_id][prt_id]['debit'],
'credit': total_amount[acc_id][prt_id]['credit'],
'final_balance': total_amount[acc_id][prt_id]['ending_balance'],
}
return lines
def _sum_all_accounts(self, trial_balance, feature):
total = 0.0
for account in trial_balance:
if account['type'] == 'account_type':
for key in account.keys():
if key == feature:
total += account[key]
return total
def test_00_account_group(self):
self.assertGreaterEqual(len(self.group1.compute_account_ids), 19)
self.assertGreaterEqual(len(self.group2.compute_account_ids), 9)
@@ -227,9 +210,15 @@ class TestTrialBalanceReport(common.TransactionCase):
if acc.code.startswith('1') or acc.code.startswith('2'):
acc.code = '999' + acc.code
# Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['receivable']), 1)
self.assertEqual(len(lines['income']), 1)
res_data = self._get_report_lines()
trial_balance = res_data['trial_balance']
check_receivable_account = self.check_account_in_report(
self.account100.id, trial_balance)
self.assertFalse(check_receivable_account)
check_income_account = self.check_account_in_report(
self.account200.id, trial_balance)
self.assertFalse(check_income_account)
# Add a move at the previous day of the first day of fiscal year
# to check the initial balance
@@ -242,20 +231,29 @@ class TestTrialBalanceReport(common.TransactionCase):
)
# Re Generate the trial balance line
lines = self._get_report_lines()
self.assertEqual(len(lines['receivable']), 1)
self.assertEqual(len(lines['income']), 1)
res_data = self._get_report_lines()
trial_balance = res_data['trial_balance']
check_receivable_account = self.check_account_in_report(
self.account100.id, trial_balance)
self.assertTrue(check_receivable_account)
check_income_account = self.check_account_in_report(
self.account200.id, trial_balance)
self.assertFalse(check_income_account)
# Check the initial and final balance
self.assertEqual(lines['receivable'].initial_balance, 1000)
self.assertEqual(lines['receivable'].debit, 0)
self.assertEqual(lines['receivable'].credit, 0)
self.assertEqual(lines['receivable'].final_balance, 1000)
account_receivable_lines = self._get_account_lines(
self.account100.id, trial_balance)
group1_lines = self._get_group_lines(self.group1.id, trial_balance)
self.assertEqual(lines['group1'].initial_balance, 1000)
self.assertEqual(lines['group1'].debit, 0)
self.assertEqual(lines['group1'].credit, 0)
self.assertEqual(lines['group1'].final_balance, 1000)
self.assertEqual(account_receivable_lines['initial_balance'], 1000)
self.assertEqual(account_receivable_lines['debit'], 0)
self.assertEqual(account_receivable_lines['credit'], 0)
self.assertEqual(account_receivable_lines['final_balance'], 1000)
self.assertEqual(group1_lines['initial_balance'], 1000)
self.assertEqual(group1_lines['debit'], 0)
self.assertEqual(group1_lines['credit'], 0)
self.assertEqual(group1_lines['final_balance'], 1000)
# Add reversed move of the initial move the first day of fiscal year
# to check the first day of fiscal year is not used
@@ -269,30 +267,42 @@ class TestTrialBalanceReport(common.TransactionCase):
)
# Re Generate the trial balance line
lines = self._get_report_lines()
self.assertEqual(len(lines['receivable']), 1)
self.assertEqual(len(lines['income']), 1)
res_data = self._get_report_lines()
trial_balance = res_data['trial_balance']
check_receivable_account = self.check_account_in_report(
self.account100.id, trial_balance)
self.assertTrue(check_receivable_account)
check_income_account = self.check_account_in_report(
self.account200.id, trial_balance)
self.assertTrue(check_income_account)
# Check the initial and final balance
self.assertEqual(lines['receivable'].initial_balance, 1000)
self.assertEqual(lines['receivable'].debit, 0)
self.assertEqual(lines['receivable'].credit, 1000)
self.assertEqual(lines['receivable'].final_balance, 0)
account_receivable_lines = self._get_account_lines(
self.account100.id, trial_balance)
account_income_lines = self._get_account_lines(
self.account200.id, trial_balance)
group1_lines = self._get_group_lines(self.group1.id, trial_balance)
group2_lines = self._get_group_lines(self.group2.id, trial_balance)
self.assertEqual(lines['income'].initial_balance, 0)
self.assertEqual(lines['income'].debit, 1000)
self.assertEqual(lines['income'].credit, 0)
self.assertEqual(lines['income'].final_balance, 1000)
self.assertEqual(account_receivable_lines['initial_balance'], 1000)
self.assertEqual(account_receivable_lines['debit'], 0)
self.assertEqual(account_receivable_lines['credit'], 1000)
self.assertEqual(account_receivable_lines['final_balance'], 0)
self.assertEqual(lines['group1'].initial_balance, 1000)
self.assertEqual(lines['group1'].debit, 0)
self.assertEqual(lines['group1'].credit, 1000)
self.assertEqual(lines['group1'].final_balance, 0)
self.assertEqual(account_income_lines['initial_balance'], 0)
self.assertEqual(account_income_lines['debit'], 1000)
self.assertEqual(account_income_lines['credit'], 0)
self.assertEqual(account_income_lines['final_balance'], 1000)
self.assertEqual(lines['group2'].initial_balance, 0)
self.assertEqual(lines['group2'].debit, 1000)
self.assertEqual(lines['group2'].credit, 0)
self.assertEqual(lines['group2'].final_balance, 1000)
self.assertEqual(group1_lines['initial_balance'], 1000)
self.assertEqual(group1_lines['debit'], 0)
self.assertEqual(group1_lines['credit'], 1000)
self.assertEqual(group1_lines['final_balance'], 0)
self.assertEqual(group2_lines['initial_balance'], 0)
self.assertEqual(group2_lines['debit'], 1000)
self.assertEqual(group2_lines['credit'], 0)
self.assertEqual(group2_lines['final_balance'], 1000)
# Add another move at the end day of fiscal year
# to check that it correctly used on report
@@ -305,37 +315,53 @@ class TestTrialBalanceReport(common.TransactionCase):
)
# Re Generate the trial balance line
lines = self._get_report_lines()
self.assertEqual(len(lines['receivable']), 1)
self.assertEqual(len(lines['income']), 1)
res_data = self._get_report_lines()
trial_balance = res_data['trial_balance']
check_receivable_account = self.check_account_in_report(
self.account100.id, trial_balance)
self.assertTrue(check_receivable_account)
check_income_account = self.check_account_in_report(
self.account200.id, trial_balance)
self.assertTrue(check_income_account)
# Check the initial and final balance
self.assertEqual(lines['receivable'].initial_balance, 1000)
self.assertEqual(lines['receivable'].debit, 0)
self.assertEqual(lines['receivable'].credit, 2000)
self.assertEqual(lines['receivable'].final_balance, -1000)
account_receivable_lines = self._get_account_lines(
self.account100.id, trial_balance)
account_income_lines = self._get_account_lines(
self.account200.id, trial_balance)
group1_lines = self._get_group_lines(self.group1.id, trial_balance)
group2_lines = self._get_group_lines(self.group2.id, trial_balance)
self.assertEqual(lines['income'].initial_balance, 0)
self.assertEqual(lines['income'].debit, 2000)
self.assertEqual(lines['income'].credit, 0)
self.assertEqual(lines['income'].final_balance, 2000)
self.assertEqual(account_receivable_lines['initial_balance'], 1000)
self.assertEqual(account_receivable_lines['debit'], 0)
self.assertEqual(account_receivable_lines['credit'], 2000)
self.assertEqual(account_receivable_lines['final_balance'], -1000)
self.assertEqual(lines['group1'].initial_balance, 1000)
self.assertEqual(lines['group1'].debit, 0)
self.assertEqual(lines['group1'].credit, 2000)
self.assertEqual(lines['group1'].final_balance, -1000)
self.assertEqual(account_income_lines['initial_balance'], 0)
self.assertEqual(account_income_lines['debit'], 2000)
self.assertEqual(account_income_lines['credit'], 0)
self.assertEqual(account_income_lines['final_balance'], 2000)
self.assertEqual(lines['group2'].initial_balance, 0)
self.assertEqual(lines['group2'].debit, 2000)
self.assertEqual(lines['group2'].credit, 0)
self.assertEqual(lines['group2'].final_balance, 2000)
self.assertGreaterEqual(len(lines['group2'].compute_account_ids), 9)
self.assertEqual(group1_lines['initial_balance'], 1000)
self.assertEqual(group1_lines['debit'], 0)
self.assertEqual(group1_lines['credit'], 2000)
self.assertEqual(group1_lines['final_balance'], -1000)
self.assertEqual(group2_lines['initial_balance'], 0)
self.assertEqual(group2_lines['debit'], 2000)
self.assertEqual(group2_lines['credit'], 0)
self.assertEqual(group2_lines['final_balance'], 2000)
def test_02_account_balance_hierarchy(self):
# Generate the general ledger line
lines = self._get_report_lines(hierarchy_on='relation')
self.assertEqual(len(lines['receivable']), 1)
self.assertEqual(len(lines['income']), 1)
res_data = self._get_report_lines(hierarchy_on='relation')
trial_balance = res_data['trial_balance']
check_receivable_account = self.check_account_in_report(
self.account100.id, trial_balance)
self.assertFalse(check_receivable_account)
check_income_account = self.check_account_in_report(
self.account200.id, trial_balance)
self.assertFalse(check_income_account)
# Add a move at the previous day of the first day of fiscal year
# to check the initial balance
@@ -348,20 +374,29 @@ class TestTrialBalanceReport(common.TransactionCase):
)
# Re Generate the trial balance line
lines = self._get_report_lines(hierarchy_on='relation')
self.assertEqual(len(lines['receivable']), 1)
self.assertEqual(len(lines['income']), 1)
res_data = self._get_report_lines(hierarchy_on='relation')
trial_balance = res_data['trial_balance']
check_receivable_account = self.check_account_in_report(
self.account100.id, trial_balance)
self.assertTrue(check_receivable_account)
check_income_account = self.check_account_in_report(
self.account200.id, trial_balance)
self.assertFalse(check_income_account)
# Check the initial and final balance
self.assertEqual(lines['receivable'].initial_balance, 1000)
self.assertEqual(lines['receivable'].debit, 0)
self.assertEqual(lines['receivable'].credit, 0)
self.assertEqual(lines['receivable'].final_balance, 1000)
account_receivable_lines = self._get_account_lines(
self.account100.id, trial_balance)
group1_lines = self._get_group_lines(self.group1.id, trial_balance)
self.assertEqual(lines['group1'].initial_balance, 1000)
self.assertEqual(lines['group1'].debit, 0)
self.assertEqual(lines['group1'].credit, 0)
self.assertEqual(lines['group1'].final_balance, 1000)
self.assertEqual(account_receivable_lines['initial_balance'], 1000)
self.assertEqual(account_receivable_lines['debit'], 0)
self.assertEqual(account_receivable_lines['credit'], 0)
self.assertEqual(account_receivable_lines['final_balance'], 1000)
self.assertEqual(group1_lines['initial_balance'], 1000)
self.assertEqual(group1_lines['debit'], 0)
self.assertEqual(group1_lines['credit'], 0)
self.assertEqual(group1_lines['final_balance'], 1000)
# Add reversale move of the initial move the first day of fiscal year
# to check the first day of fiscal year is not used
@@ -375,31 +410,43 @@ class TestTrialBalanceReport(common.TransactionCase):
)
# Re Generate the trial balance line
lines = self._get_report_lines(hierarchy_on='relation')
self.assertEqual(len(lines['receivable']), 1)
self.assertEqual(len(lines['income']), 1)
res_data = self._get_report_lines(hierarchy_on='relation')
trial_balance = res_data['trial_balance']
check_receivable_account = self.check_account_in_report(
self.account100.id, trial_balance)
self.assertTrue(check_receivable_account)
check_income_account = self.check_account_in_report(
self.account200.id, trial_balance)
self.assertTrue(check_income_account)
# Check the initial and final balance
self.assertEqual(lines['receivable'].initial_balance, 1000)
self.assertEqual(lines['receivable'].debit, 0)
self.assertEqual(lines['receivable'].credit, 1000)
self.assertEqual(lines['receivable'].final_balance, 0)
account_receivable_lines = self._get_account_lines(
self.account100.id, trial_balance)
account_income_lines = self._get_account_lines(
self.account200.id, trial_balance)
group1_lines = self._get_group_lines(self.group1.id, trial_balance)
group2_lines = self._get_group_lines(self.group2.id, trial_balance)
self.assertEqual(lines['income'].initial_balance, 0)
self.assertEqual(lines['income'].debit, 1000)
self.assertEqual(lines['income'].credit, 0)
self.assertEqual(lines['income'].final_balance, 1000)
self.assertEqual(account_receivable_lines['initial_balance'], 1000)
self.assertEqual(account_receivable_lines['debit'], 0)
self.assertEqual(account_receivable_lines['credit'], 1000)
self.assertEqual(account_receivable_lines['final_balance'], 0)
self.assertEqual(lines['group1'].initial_balance, 1000)
self.assertEqual(lines['group1'].debit, 0)
self.assertEqual(lines['group1'].credit, 1000)
self.assertEqual(lines['group1'].final_balance, 0)
self.assertEqual(account_income_lines['initial_balance'], 0)
self.assertEqual(account_income_lines['debit'], 1000)
self.assertEqual(account_income_lines['credit'], 0)
self.assertEqual(account_income_lines['final_balance'], 1000)
self.assertEqual(group1_lines['initial_balance'], 1000)
self.assertEqual(group1_lines['debit'], 0)
self.assertEqual(group1_lines['credit'], 1000)
self.assertEqual(group1_lines['final_balance'], 0)
self.assertEqual(group2_lines['initial_balance'], 0)
self.assertEqual(group2_lines['debit'], 2000)
self.assertEqual(group2_lines['credit'], 0)
self.assertEqual(group2_lines['final_balance'], 2000)
self.assertEqual(lines['group2'].initial_balance, 0)
self.assertEqual(lines['group2'].debit, 2000)
self.assertEqual(lines['group2'].credit, 0)
self.assertEqual(lines['group2'].final_balance, 2000)
self.assertEqual(len(lines['group2'].compute_account_ids), 2)
# Add another move at the end day of fiscal year
# to check that it correctly used on report
self._add_move(
@@ -411,35 +458,50 @@ class TestTrialBalanceReport(common.TransactionCase):
)
# Re Generate the trial balance line
lines = self._get_report_lines(hierarchy_on='relation')
self.assertEqual(len(lines['receivable']), 1)
self.assertEqual(len(lines['income']), 1)
res_data = self._get_report_lines(hierarchy_on='relation')
trial_balance = res_data['trial_balance']
check_receivable_account = self.check_account_in_report(
self.account100.id, trial_balance)
self.assertTrue(check_receivable_account)
check_income_account = self.check_account_in_report(
self.account200.id, trial_balance)
self.assertTrue(check_income_account)
# Check the initial and final balance
self.assertEqual(lines['receivable'].initial_balance, 1000)
self.assertEqual(lines['receivable'].debit, 0)
self.assertEqual(lines['receivable'].credit, 2000)
self.assertEqual(lines['receivable'].final_balance, -1000)
account_receivable_lines = self._get_account_lines(
self.account100.id, trial_balance)
account_income_lines = self._get_account_lines(
self.account200.id, trial_balance)
group1_lines = self._get_group_lines(self.group1.id, trial_balance)
group2_lines = self._get_group_lines(self.group2.id, trial_balance)
self.assertEqual(lines['income'].initial_balance, 0)
self.assertEqual(lines['income'].debit, 2000)
self.assertEqual(lines['income'].credit, 0)
self.assertEqual(lines['income'].final_balance, 2000)
self.assertEqual(account_receivable_lines['initial_balance'], 1000)
self.assertEqual(account_receivable_lines['debit'], 0)
self.assertEqual(account_receivable_lines['credit'], 2000)
self.assertEqual(account_receivable_lines['final_balance'], -1000)
self.assertEqual(lines['group1'].initial_balance, 1000)
self.assertEqual(lines['group1'].debit, 0)
self.assertEqual(lines['group1'].credit, 2000)
self.assertEqual(lines['group1'].final_balance, -1000)
self.assertEqual(account_income_lines['initial_balance'], 0)
self.assertEqual(account_income_lines['debit'], 2000)
self.assertEqual(account_income_lines['credit'], 0)
self.assertEqual(account_income_lines['final_balance'], 2000)
self.assertEqual(lines['group2'].initial_balance, 0)
self.assertEqual(lines['group2'].debit, 4000)
self.assertEqual(lines['group2'].credit, 0)
self.assertEqual(lines['group2'].final_balance, 4000)
self.assertEqual(group1_lines['initial_balance'], 1000)
self.assertEqual(group1_lines['debit'], 0)
self.assertEqual(group1_lines['credit'], 2000)
self.assertEqual(group1_lines['final_balance'], -1000)
self.assertEqual(group2_lines['initial_balance'], 0)
self.assertEqual(group2_lines['debit'], 4000)
self.assertEqual(group2_lines['credit'], 0)
self.assertEqual(group2_lines['final_balance'], 4000)
def test_03_partner_balance(self):
# Generate the trial balance line
lines = self._get_report_lines(with_partners=True)
self.assertEqual(len(lines['partner_receivable']), 0)
res_data = self._get_report_lines(with_partners=True)
total_amount = res_data['total_amount']
check_partner_receivable = self.check_partner_in_report(
self.account100.id, self.partner.id, total_amount)
self.assertFalse(check_partner_receivable)
# Add a move at the previous day of the first day of fiscal year
# to check the initial balance
@@ -452,14 +514,20 @@ class TestTrialBalanceReport(common.TransactionCase):
)
# Re Generate the trial balance line
lines = self._get_report_lines(with_partners=True)
self.assertEqual(len(lines['partner_receivable']), 1)
res_data = self._get_report_lines(with_partners=True)
total_amount = res_data['total_amount']
check_partner_receivable = self.check_partner_in_report(
self.account100.id, self.partner.id, total_amount)
self.assertTrue(check_partner_receivable)
# Check the initial and final balance
self.assertEqual(lines['partner_receivable'].initial_balance, 1000)
self.assertEqual(lines['partner_receivable'].debit, 0)
self.assertEqual(lines['partner_receivable'].credit, 0)
self.assertEqual(lines['partner_receivable'].final_balance, 1000)
partner_lines = self._get_partner_lines(
self.account100.id, self.partner.id, total_amount)
self.assertEqual(partner_lines['initial_balance'], 1000)
self.assertEqual(partner_lines['debit'], 0)
self.assertEqual(partner_lines['credit'], 0)
self.assertEqual(partner_lines['final_balance'], 1000)
# Add reversale move of the initial move the first day of fiscal year
# to check the first day of fiscal year is not used
@@ -473,14 +541,20 @@ class TestTrialBalanceReport(common.TransactionCase):
)
# Re Generate the trial balance line
lines = self._get_report_lines(with_partners=True)
self.assertEqual(len(lines['partner_receivable']), 1)
res_data = self._get_report_lines(with_partners=True)
total_amount = res_data['total_amount']
check_partner_receivable = self.check_partner_in_report(
self.account100.id, self.partner.id, total_amount)
self.assertTrue(check_partner_receivable)
# Check the initial and final balance
self.assertEqual(lines['partner_receivable'].initial_balance, 1000)
self.assertEqual(lines['partner_receivable'].debit, 0)
self.assertEqual(lines['partner_receivable'].credit, 1000)
self.assertEqual(lines['partner_receivable'].final_balance, 0)
partner_lines = self._get_partner_lines(
self.account100.id, self.partner.id, total_amount)
self.assertEqual(partner_lines['initial_balance'], 1000)
self.assertEqual(partner_lines['debit'], 0)
self.assertEqual(partner_lines['credit'], 1000)
self.assertEqual(partner_lines['final_balance'], 0)
# Add another move at the end day of fiscal year
# to check that it correctly used on report
@@ -493,14 +567,20 @@ class TestTrialBalanceReport(common.TransactionCase):
)
# Re Generate the trial balance line
lines = self._get_report_lines(with_partners=True)
self.assertEqual(len(lines['partner_receivable']), 1)
res_data = self._get_report_lines(with_partners=True)
total_amount = res_data['total_amount']
check_partner_receivable = self.check_partner_in_report(
self.account100.id, self.partner.id, total_amount)
self.assertTrue(check_partner_receivable)
# Check the initial and final balance
self.assertEqual(lines['partner_receivable'].initial_balance, 1000)
self.assertEqual(lines['partner_receivable'].debit, 0)
self.assertEqual(lines['partner_receivable'].credit, 2000)
self.assertEqual(lines['partner_receivable'].final_balance, -1000)
partner_lines = self._get_partner_lines(
self.account100.id, self.partner.id, total_amount)
self.assertEqual(partner_lines['initial_balance'], 1000)
self.assertEqual(partner_lines['debit'], 0)
self.assertEqual(partner_lines['credit'], 2000)
self.assertEqual(partner_lines['final_balance'], -1000)
def test_04_undistributed_pl(self):
# Add a P&L Move in the previous FY
@@ -525,28 +605,33 @@ class TestTrialBalanceReport(common.TransactionCase):
move = self.env['account.move'].create(move_vals)
move.post()
# Generate the trial balance line
report_account_model = self.env['report_trial_balance_account']
company = self.env.ref('base.main_company')
trial_balance = self.env['report_trial_balance'].create({
trial_balance = self.env['trial.balance.report.wizard'].create({
'date_from': self.date_start,
'date_to': self.date_end,
'only_posted_moves': True,
'target_move': 'posted',
'hide_account_at_0': False,
'hierarchy_on': 'none',
'company_id': company.id,
'fy_start_date': self.fy_date_start,
})
trial_balance.compute_data_for_report()
data = trial_balance._prepare_report_trial_balance()
res_data = self.env[
'report.account_financial_report.trial_balance']._get_report_values(
trial_balance, data)
trial_balance = res_data['trial_balance']
unaffected_balance_lines = report_account_model.search([
('report_id', '=', trial_balance.id),
('account_id', '=', self.account110.id),
])
self.assertEqual(len(unaffected_balance_lines), 1)
self.assertEqual(unaffected_balance_lines[0].initial_balance, -1000)
self.assertEqual(unaffected_balance_lines[0].debit, 0)
self.assertEqual(unaffected_balance_lines[0].credit, 0)
self.assertEqual(unaffected_balance_lines[0].final_balance, -1000)
check_unaffected_account = self.check_account_in_report(
self.unaffected_account.id, trial_balance)
self.assertTrue(check_unaffected_account)
unaffected_lines = self._get_account_lines(
self.unaffected_account.id, trial_balance)
self.assertEqual(unaffected_lines['initial_balance'], -1000)
self.assertEqual(unaffected_lines['debit'], 0)
self.assertEqual(unaffected_lines['credit'], 0)
self.assertEqual(unaffected_lines['final_balance'], -1000)
# Add a P&L Move to the current FY
move_name = 'current year pl move'
journal = self.env['account.journal'].search([], limit=1)
@@ -569,27 +654,33 @@ class TestTrialBalanceReport(common.TransactionCase):
move = self.env['account.move'].create(move_vals)
move.post()
# Re Generate the trial balance line
trial_balance = self.env['report_trial_balance'].create({
trial_balance = self.env['trial.balance.report.wizard'].create({
'date_from': self.date_start,
'date_to': self.date_end,
'only_posted_moves': True,
'target_move': 'posted',
'hide_account_at_0': False,
'hierarchy_on': 'none',
'company_id': company.id,
'fy_start_date': self.fy_date_start,
})
trial_balance.compute_data_for_report()
unaffected_balance_lines = report_account_model.search([
('report_id', '=', trial_balance.id),
('account_id', '=', self.account110.id),
])
data = trial_balance._prepare_report_trial_balance()
res_data = self.env[
'report.account_financial_report.trial_balance']._get_report_values(
trial_balance, data)
trial_balance = res_data['trial_balance']
# The unaffected earnings account is not affected by a journal entry
# made to the P&L in the current fiscal year.
self.assertEqual(len(unaffected_balance_lines), 1)
self.assertEqual(unaffected_balance_lines[0].initial_balance, -1000)
self.assertEqual(unaffected_balance_lines[0].debit, 0)
self.assertEqual(unaffected_balance_lines[0].credit, 0)
self.assertEqual(unaffected_balance_lines[0].final_balance, -1000)
check_unaffected_account = self.check_account_in_report(
self.unaffected_account.id, trial_balance)
self.assertTrue(check_unaffected_account)
unaffected_lines = self._get_account_lines(
self.unaffected_account.id, trial_balance)
self.assertEqual(unaffected_lines['initial_balance'], -1000)
self.assertEqual(unaffected_lines['debit'], 0)
self.assertEqual(unaffected_lines['credit'], 0)
self.assertEqual(unaffected_lines['final_balance'], -1000)
# Add a Move including Unaffected Earnings to the current FY
move_name = 'current year unaffected earnings move'
journal = self.env['account.journal'].search([], limit=1)
@@ -612,32 +703,42 @@ class TestTrialBalanceReport(common.TransactionCase):
move = self.env['account.move'].create(move_vals)
move.post()
# Re Generate the trial balance line
trial_balance = self.env['report_trial_balance'].create({
trial_balance = self.env['trial.balance.report.wizard'].create({
'date_from': self.date_start,
'date_to': self.date_end,
'only_posted_moves': True,
'target_move': 'posted',
'hide_account_at_0': False,
'hierarchy_on': 'none',
'company_id': company.id,
'fy_start_date': self.fy_date_start,
})
trial_balance.compute_data_for_report()
data = trial_balance._prepare_report_trial_balance()
res_data = self.env[
'report.account_financial_report.trial_balance']._get_report_values(
trial_balance, data)
trial_balance = res_data['trial_balance']
# The unaffected earnings account affected by a journal entry
# made to the unaffected earnings in the current fiscal year.
unaffected_balance_lines = report_account_model.search([
('report_id', '=', trial_balance.id),
('account_id', '=', self.account110.id),
])
self.assertEqual(len(unaffected_balance_lines), 1)
self.assertEqual(unaffected_balance_lines[0].initial_balance, -1000)
self.assertEqual(unaffected_balance_lines[0].debit, 0)
self.assertEqual(unaffected_balance_lines[0].credit, 1000)
self.assertEqual(unaffected_balance_lines[0].final_balance, -2000)
check_unaffected_account = self.check_account_in_report(
self.unaffected_account.id, trial_balance)
self.assertTrue(check_unaffected_account)
unaffected_lines = self._get_account_lines(
self.unaffected_account.id, trial_balance)
self.assertEqual(unaffected_lines['initial_balance'], -1000)
self.assertEqual(unaffected_lines['debit'], 0)
self.assertEqual(unaffected_lines['credit'], 1000)
self.assertEqual(unaffected_lines['final_balance'], -2000)
# The totals for the Trial Balance are zero
all_lines = report_account_model.search([
('report_id', '=', trial_balance.id),
])
self.assertEqual(sum(all_lines.mapped('initial_balance')), 0)
self.assertEqual(sum(all_lines.mapped('final_balance')), 0)
self.assertEqual(sum(all_lines.mapped('debit')),
sum(all_lines.mapped('credit')))
total_initial_balance = self._sum_all_accounts(trial_balance,
'initial_balance')
total_final_balance = self._sum_all_accounts(trial_balance,
'ending_balance')
total_debit = self._sum_all_accounts(trial_balance, 'debit')
total_credit = self._sum_all_accounts(trial_balance, 'credit')
self.assertEqual(total_initial_balance, 0)
self.assertEqual(total_final_balance, 0)
self.assertEqual(total_debit, total_credit)

View File

@@ -1,47 +1,10 @@
# Copyright 2018 Forest and Biomass Romania
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import time
from datetime import date
from odoo.tests import common
from . import abstract_test_tax_report
class TestVAT(abstract_test_tax_report.AbstractTest):
"""
Technical tests for VAT Report.
"""
def _getReportModel(self):
return self.env['report_vat_report']
def _getQwebReportName(self):
return 'account_financial_report.report_vat_report_qweb'
def _getXlsxReportName(self):
return 'a_f_r.report_vat_report_xlsx'
def _getXlsxReportActionName(self):
return 'account_financial_report.action_report_vat_report_xlsx'
def _getReportTitle(self):
return 'Odoo'
def _getBaseFilters(self):
return {
'date_from': date(date.today().year, 1, 1),
'date_to': date(date.today().year, 12, 31),
'company_id': self.env.user.company_id.id,
}
def _getAdditionalFiltersToBeTested(self):
return [
{'based_on': 'taxtags'},
{'based_on': 'taxgroups'},
{'tax_details': True},
{'based_on': 'taxtags', 'tax_details': True},
{'based_on': 'taxgroups', 'tax_details': True},
]
class TestVATReport(common.TransactionCase):
@@ -155,106 +118,142 @@ class TestVATReport(common.TransactionCase):
self.cbinvoice.compute_taxes()
self.cbinvoice.action_invoice_open()
def _get_report_lines(self):
self.cbinvoice.pay_and_reconcile(
self.bank_journal.id, 300, date(
date.today().year, date.today().month, 10))
vat_report = self.env['report_vat_report'].create({
def _get_report_lines(self, taxgroups=False):
based_on = 'taxtags'
if taxgroups:
based_on = 'taxgroups'
vat_report = self.env['vat.report.wizard'].create({
'date_from': self.date_from,
'date_to': self.date_to,
'company_id': self.company.id,
'based_on': 'taxtags',
'based_on': based_on,
'tax_detail': True,
})
vat_report.compute_data_for_report()
lines = {}
vat_taxtag_model = self.env['report_vat_report_taxtag']
lines['tag_01'] = vat_taxtag_model.search([
('report_id', '=', vat_report.id),
('taxtag_id', '=', self.tax_tag_01.id),
])
lines['tag_02'] = vat_taxtag_model.search([
('report_id', '=', vat_report.id),
('taxtag_id', '=', self.tax_tag_02.id),
])
lines['tag_03'] = vat_taxtag_model.search([
('report_id', '=', vat_report.id),
('taxtag_id', '=', self.tax_tag_03.id),
])
vat_tax_model = self.env['report_vat_report_tax']
lines['tax_10'] = vat_tax_model.search([
('report_tax_id', '=', lines['tag_02'].id),
('tax_id', '=', self.tax_10.id),
])
lines['tax_20'] = vat_tax_model.search([
('report_tax_id', '=', lines['tag_02'].id),
('tax_id', '=', self.tax_20.id),
])
vat_report['based_on'] = 'taxgroups'
vat_report.compute_data_for_report()
lines['group_10'] = vat_taxtag_model.search([
('report_id', '=', vat_report.id),
('taxgroup_id', '=', self.tax_group_10.id),
])
lines['group_20'] = vat_taxtag_model.search([
('report_id', '=', vat_report.id),
('taxgroup_id', '=', self.tax_group_20.id),
])
vat_tax_model = self.env['report_vat_report_tax']
lines['tax_group_10'] = vat_tax_model.search([
('report_tax_id', '=', lines['group_10'].id),
('tax_id', '=', self.tax_10.id),
])
lines['tax_group_20'] = vat_tax_model.search([
('report_tax_id', '=', lines['group_20'].id),
('tax_id', '=', self.tax_20.id),
])
return lines
data = vat_report._prepare_vat_report()
res_data = self.env[
'report.account_financial_report.vat_report'
]._get_report_values(vat_report, data)
return res_data
def check_tag_or_group_in_report(self, tag_or_group_name, vat_report):
tag_or_group_in_report = False
for tag_or_group in vat_report:
if tag_or_group['name'] == tag_or_group_name:
tag_or_group_in_report = True
break
return tag_or_group_in_report
def check_tax_in_report(self, tax_name, vat_report):
tax_in_report = False
for tag_or_group in vat_report:
if tag_or_group['taxes']:
for tax in tag_or_group['taxes']:
if tax['name'] == tax_name:
tax_in_report = True
return tax_in_report
def _get_tag_or_group_line(self, tag_or_group_name, vat_report):
tag_or_group_net = False
tag_or_group_tax = False
for tag_or_group in vat_report:
if tag_or_group['name'] == tag_or_group_name:
tag_or_group_net = tag_or_group['net']
tag_or_group_tax = tag_or_group['tax']
return tag_or_group_net, tag_or_group_tax
def _get_tax_line(self, tax_name, vat_report):
tax_net = False
tax_tax = False
for tag_or_group in vat_report:
if tag_or_group['taxes']:
for tax in tag_or_group['taxes']:
if tax['name'] == tax_name:
tax_net = tax['net']
tax_tax = tax['tax']
return tax_net, tax_tax
def test_01_compute(self):
# Generate the vat lines
lines = self._get_report_lines()
res_data = self._get_report_lines()
vat_report = res_data['vat_report']
# Check report based on taxtags
self.assertEqual(len(lines['tag_01']), 1)
self.assertEqual(len(lines['tag_02']), 1)
self.assertEqual(len(lines['tag_03']), 1)
self.assertEqual(len(lines['tax_10']), 1)
self.assertEqual(len(lines['tax_20']), 1)
self.assertEqual(lines['tag_01'].net, 100)
self.assertEqual(lines['tag_01'].tax, 10)
self.assertEqual(lines['tag_02'].net, 350)
self.assertEqual(lines['tag_02'].tax, 60)
self.assertEqual(lines['tag_03'].net, 250)
self.assertEqual(lines['tag_03'].tax, 50)
self.assertEqual(lines['tax_10'].net, 100)
self.assertEqual(lines['tax_10'].tax, 10)
self.assertEqual(lines['tax_20'].net, 250)
self.assertEqual(lines['tax_20'].tax, 50)
check_tax_tag_01 = self.check_tag_or_group_in_report(
self.tax_tag_01.name, vat_report)
self.assertTrue(check_tax_tag_01)
check_tax_tag_02 = self.check_tag_or_group_in_report(
self.tax_tag_02.name, vat_report)
self.assertTrue(check_tax_tag_02)
check_tax_tag_03 = self.check_tag_or_group_in_report(
self.tax_tag_03.name, vat_report)
self.assertTrue(check_tax_tag_03)
check_tax_10 = self.check_tax_in_report(
self.tax_10.name, vat_report)
self.assertTrue(check_tax_10)
check_tax_20 = self.check_tax_in_report(
self.tax_20.name, vat_report)
self.assertTrue(check_tax_20)
tag_01_net, tag_01_tax = self._get_tag_or_group_line(
self.tax_tag_01.name, vat_report)
tag_02_net, tag_02_tax = self._get_tag_or_group_line(
self.tax_tag_02.name, vat_report)
tag_03_net, tag_03_tax = self._get_tag_or_group_line(
self.tax_tag_03.name, vat_report)
tax_10_net, tax_10_tax = self._get_tax_line(
self.tax_10.name, vat_report)
tax_20_net, tax_20_tax = self._get_tax_line(
self.tax_20.name, vat_report)
self.assertEqual(tag_01_net, 100)
self.assertEqual(tag_01_tax, 10)
self.assertEqual(tag_02_net, 350)
self.assertEqual(tag_02_tax, 60)
self.assertEqual(tag_03_net, 250)
self.assertEqual(tag_03_tax, 50)
self.assertEqual(tax_10_net, 100)
self.assertEqual(tax_10_tax, 10)
self.assertEqual(tax_20_net, 250)
self.assertEqual(tax_20_tax, 50)
# Check report based on taxgroups
self.assertEqual(len(lines['group_10']), 1)
self.assertEqual(len(lines['group_20']), 1)
self.assertEqual(len(lines['tax_group_10']), 1)
self.assertEqual(len(lines['tax_group_20']), 1)
self.assertEqual(lines['group_10'].net, 100)
self.assertEqual(lines['group_10'].tax, 10)
self.assertEqual(lines['group_20'].net, 250)
self.assertEqual(lines['group_20'].tax, 50)
self.assertEqual(lines['tax_group_10'].net, 100)
self.assertEqual(lines['tax_group_10'].tax, 10)
self.assertEqual(lines['tax_group_20'].net, 250)
self.assertEqual(lines['tax_group_20'].tax, 50)
res_data = self._get_report_lines(taxgroups=True)
vat_report = res_data['vat_report']
def test_get_report_html(self):
vat_report = self.env['report_vat_report'].create({
'date_from': self.date_from,
'date_to': self.date_to,
'company_id': self.company.id,
'tax_detail': True,
})
vat_report.compute_data_for_report()
vat_report.get_html(given_context={})
check_group_10 = self.check_tag_or_group_in_report(
self.tax_group_10.name, vat_report)
self.assertTrue(check_group_10)
check_group_20 = self.check_tag_or_group_in_report(
self.tax_group_20.name, vat_report)
self.assertTrue(check_group_20)
check_tax_10 = self.check_tax_in_report(
self.tax_10.name, vat_report)
self.assertTrue(check_tax_10)
check_tax_20 = self.check_tax_in_report(
self.tax_20.name, vat_report)
self.assertTrue(check_tax_20)
group_10_net, group_10_tax = self._get_tag_or_group_line(
self.tax_group_10.name, vat_report)
group_20_net, group_20_tax = self._get_tag_or_group_line(
self.tax_group_20.name, vat_report)
tax_10_net, tax_10_tax = self._get_tax_line(
self.tax_10.name, vat_report)
tax_20_net, tax_20_tax = self._get_tax_line(
self.tax_20.name, vat_report)
self.assertEqual(group_10_net, 100)
self.assertEqual(group_10_tax, 10)
self.assertEqual(group_20_net, 250)
self.assertEqual(group_20_tax, 50)
self.assertEqual(tax_10_net, 100)
self.assertEqual(tax_10_tax, 10)
self.assertEqual(tax_20_net, 250)
self.assertEqual(tax_20_tax, 50)
def test_wizard_date_range(self):
vat_wizard = self.env['vat.report.wizard']