Update links in report, add account group file, update trial balance with hierarchy.
Update indentation, remove empty lines from header. Update test. Update pylint. Remove company_id on computing accounts, since account.group is not a company based model, filtering accounts is done on trial balance report. Update account variables. Improve condition in padding on accounts. Add option to print hierarchy based on defined accounts/computed accounts. Add VAT report, hierarchy from tax tags ans taxes. Fix pylint, xlsx report generation header. Update code to select code_prefix or name. Update code to select code_prefix or name. Update code to select code_prefix or name. Fix domain in base amounts in vat report. Change trial balance code_prefix or name. Update trail balance, add tests for vat report. Update pylint, amounts as monetary, many2one option on generation excels. Update pulint. Add VAT Report in readme. Add VAT Report in readme. Update array_agg. Update array_agg. Update array_agg. Add option in VAT Report to be printed on Tax Tags - Tax Groups. Add widget to hierarchy_on on trial balance.
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
# 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 test_aged_partner_balance
|
||||
from . import test_general_ledger
|
||||
from . import test_open_items
|
||||
from . import test_trial_balance
|
||||
from . import test_vat_report
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
|
||||
# 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
|
||||
|
||||
import logging
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
75
account_financial_report/tests/abstract_test_tax_report.py
Normal file
75
account_financial_report/tests/abstract_test_tax_report.py
Normal file
@@ -0,0 +1,75 @@
|
||||
# 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])
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
# Author: Julien Coux
|
||||
# Copyright 2016 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
|
||||
# Author: Julien Coux
|
||||
# Copyright 2016 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
import time
|
||||
from . import abstract_test
|
||||
|
||||
from odoo.tests import common
|
||||
from . import abstract_test
|
||||
|
||||
|
||||
class TestGeneralLedger(abstract_test.AbstractTest):
|
||||
@@ -78,14 +78,14 @@ class TestGeneralLedgerReport(common.TransactionCase):
|
||||
)], limit=1)
|
||||
|
||||
def _add_move(
|
||||
self,
|
||||
date,
|
||||
receivable_debit,
|
||||
receivable_credit,
|
||||
income_debit,
|
||||
income_credit,
|
||||
unaffected_debit=0,
|
||||
unaffected_credit=0
|
||||
self,
|
||||
date,
|
||||
receivable_debit,
|
||||
receivable_credit,
|
||||
income_debit,
|
||||
income_credit,
|
||||
unaffected_debit=0,
|
||||
unaffected_credit=0
|
||||
):
|
||||
move_name = 'expense accrual'
|
||||
journal = self.env['account.journal'].search([
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
# Author: Julien Coux
|
||||
# Copyright 2016 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
|
||||
# Author: Julien Coux
|
||||
# Copyright 2016 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
import time
|
||||
|
||||
from odoo.tests import common
|
||||
from . import abstract_test
|
||||
|
||||
|
||||
@@ -40,6 +41,12 @@ class TestTrialBalance(abstract_test.AbstractTest):
|
||||
{'only_posted_moves': True},
|
||||
{'hide_account_balance_at_0': True},
|
||||
{'show_partner_details': True},
|
||||
{'hierarchy_on': 'computed'},
|
||||
{'hierarchy_on': 'relation'},
|
||||
{'only_posted_moves': True, 'hide_account_balance_at_0': True,
|
||||
'hierarchy_on': 'computed'},
|
||||
{'only_posted_moves': True, 'hide_account_balance_at_0': True,
|
||||
'hierarchy_on': 'relation'},
|
||||
{'only_posted_moves': True, 'hide_account_balance_at_0': True},
|
||||
{'only_posted_moves': True, 'show_partner_details': True},
|
||||
{'hide_account_balance_at_0': True, 'show_partner_details': True},
|
||||
@@ -52,3 +59,434 @@ class TestTrialBalance(abstract_test.AbstractTest):
|
||||
|
||||
def _partner_test_is_possible(self, filters):
|
||||
return 'show_partner_details' in filters
|
||||
|
||||
|
||||
@common.at_install(False)
|
||||
@common.post_install(True)
|
||||
class TestTrialBalanceReport(common.TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestTrialBalanceReport, self).setUp()
|
||||
group_obj = self.env['account.group']
|
||||
acc_obj = self.env['account.account']
|
||||
self.group1 = group_obj.create(
|
||||
{'code_prefix': '1',
|
||||
'name': 'Group 1'})
|
||||
self.group11 = group_obj.create(
|
||||
{'code_prefix': '11',
|
||||
'name': 'Group 11',
|
||||
'parent_id': self.group1.id})
|
||||
self.group2 = group_obj.create(
|
||||
{'code_prefix': '2',
|
||||
'name': 'Group 2'})
|
||||
self.account100 = acc_obj.create(
|
||||
{'code': '100',
|
||||
'name': 'Account 100',
|
||||
'group_id': self.group1.id,
|
||||
'user_type_id': self.env.ref(
|
||||
'account.data_account_type_receivable').id,
|
||||
'reconcile': True})
|
||||
self.account110 = self.env['account.account'].search([
|
||||
(
|
||||
'user_type_id',
|
||||
'=',
|
||||
self.env.ref('account.data_unaffected_earnings').id
|
||||
)], limit=1)
|
||||
self.account200 = acc_obj.create(
|
||||
{'code': '200',
|
||||
'name': 'Account 200',
|
||||
'group_id': self.group2.id,
|
||||
'user_type_id': self.env.ref(
|
||||
'account.data_account_type_other_income').id})
|
||||
self.account300 = acc_obj.create(
|
||||
{'code': '300',
|
||||
'name': 'Account 300',
|
||||
'user_type_id': self.env.ref(
|
||||
'account.data_account_type_other_income').id})
|
||||
self.account301 = acc_obj.create(
|
||||
{'code': '301',
|
||||
'name': 'Account 301',
|
||||
'group_id': self.group2.id,
|
||||
'user_type_id': self.env.ref(
|
||||
'account.data_account_type_other_income').id})
|
||||
self.previous_fy_date_start = '2015-01-01'
|
||||
self.previous_fy_date_end = '2015-12-31'
|
||||
self.fy_date_start = '2016-01-01'
|
||||
self.fy_date_end = '2016-12-31'
|
||||
self.date_start = '2016-01-01'
|
||||
self.date_end = '2016-12-31'
|
||||
|
||||
def _add_move(
|
||||
self,
|
||||
date,
|
||||
receivable_debit,
|
||||
receivable_credit,
|
||||
income_debit,
|
||||
income_credit,
|
||||
unaffected_debit=0,
|
||||
unaffected_credit=0
|
||||
):
|
||||
move_name = 'expense accrual'
|
||||
journal = self.env['account.journal'].search([
|
||||
('code', '=', 'MISC')])
|
||||
partner = self.env.ref('base.res_partner_12')
|
||||
move_vals = {
|
||||
'journal_id': journal.id,
|
||||
'partner_id': partner.id,
|
||||
'name': move_name,
|
||||
'date': date,
|
||||
'line_ids': [
|
||||
(0, 0, {
|
||||
'name': move_name,
|
||||
'debit': receivable_debit,
|
||||
'credit': receivable_credit,
|
||||
'account_id': self.account100.id}),
|
||||
(0, 0, {
|
||||
'name': move_name,
|
||||
'debit': income_debit,
|
||||
'credit': income_credit,
|
||||
'account_id': self.account200.id}),
|
||||
(0, 0, {
|
||||
'name': move_name,
|
||||
'debit': unaffected_debit,
|
||||
'credit': unaffected_credit,
|
||||
'account_id': self.account110.id}),
|
||||
(0, 0, {
|
||||
'name': move_name,
|
||||
'debit': receivable_debit,
|
||||
'credit': receivable_credit,
|
||||
'account_id': self.account300.id}),
|
||||
(0, 0, {
|
||||
'name': move_name,
|
||||
'debit': receivable_credit,
|
||||
'credit': receivable_debit,
|
||||
'account_id': self.account301.id})
|
||||
]}
|
||||
move = self.env['account.move'].create(move_vals)
|
||||
move.post()
|
||||
|
||||
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({
|
||||
'date_from': self.date_start,
|
||||
'date_to': self.date_end,
|
||||
'only_posted_moves': True,
|
||||
'hide_account_balance_at_0': False,
|
||||
'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),
|
||||
])
|
||||
return lines
|
||||
|
||||
def test_00_account_group(self):
|
||||
self.assertEqual(len(self.group1.compute_account_ids.ids), 19)
|
||||
self.assertEqual(len(self.group2.compute_account_ids.ids), 9)
|
||||
|
||||
def test_01_account_balance_computed(self):
|
||||
# Generate the general ledger line
|
||||
lines = self._get_report_lines()
|
||||
self.assertEqual(len(lines['receivable']), 1)
|
||||
self.assertEqual(len(lines['income']), 1)
|
||||
|
||||
# Add a move at the previous day of the first day of fiscal year
|
||||
# to check the initial balance
|
||||
self._add_move(
|
||||
date=self.previous_fy_date_end,
|
||||
receivable_debit=1000,
|
||||
receivable_credit=0,
|
||||
income_debit=0,
|
||||
income_credit=1000
|
||||
)
|
||||
|
||||
# Re Generate the trial balance line
|
||||
lines = self._get_report_lines()
|
||||
self.assertEqual(len(lines['receivable']), 1)
|
||||
self.assertEqual(len(lines['income']), 1)
|
||||
|
||||
# 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)
|
||||
|
||||
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)
|
||||
|
||||
# Add reversale move of the initial move the first day of fiscal year
|
||||
# to check the first day of fiscal year is not used
|
||||
# to compute the initial balance
|
||||
self._add_move(
|
||||
date=self.fy_date_start,
|
||||
receivable_debit=0,
|
||||
receivable_credit=1000,
|
||||
income_debit=1000,
|
||||
income_credit=0
|
||||
)
|
||||
|
||||
# Re Generate the trial balance line
|
||||
lines = self._get_report_lines()
|
||||
self.assertEqual(len(lines['receivable']), 1)
|
||||
self.assertEqual(len(lines['income']), 1)
|
||||
|
||||
# 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)
|
||||
|
||||
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(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(lines['group2'].initial_balance, 0)
|
||||
self.assertEqual(lines['group2'].debit, 1000)
|
||||
self.assertEqual(lines['group2'].credit, 0)
|
||||
self.assertEqual(lines['group2'].final_balance, 1000)
|
||||
|
||||
# Add another move at the end day of fiscal year
|
||||
# to check that it correctly used on report
|
||||
self._add_move(
|
||||
date=self.fy_date_end,
|
||||
receivable_debit=0,
|
||||
receivable_credit=1000,
|
||||
income_debit=1000,
|
||||
income_credit=0
|
||||
)
|
||||
|
||||
# Re Generate the trial balance line
|
||||
lines = self._get_report_lines()
|
||||
self.assertEqual(len(lines['receivable']), 1)
|
||||
self.assertEqual(len(lines['income']), 1)
|
||||
|
||||
# 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)
|
||||
|
||||
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(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(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)
|
||||
|
||||
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)
|
||||
|
||||
# Add a move at the previous day of the first day of fiscal year
|
||||
# to check the initial balance
|
||||
self._add_move(
|
||||
date=self.previous_fy_date_end,
|
||||
receivable_debit=1000,
|
||||
receivable_credit=0,
|
||||
income_debit=0,
|
||||
income_credit=1000
|
||||
)
|
||||
|
||||
# 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)
|
||||
|
||||
# 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)
|
||||
|
||||
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)
|
||||
|
||||
# Add reversale move of the initial move the first day of fiscal year
|
||||
# to check the first day of fiscal year is not used
|
||||
# to compute the initial balance
|
||||
self._add_move(
|
||||
date=self.fy_date_start,
|
||||
receivable_debit=0,
|
||||
receivable_credit=1000,
|
||||
income_debit=1000,
|
||||
income_credit=0
|
||||
)
|
||||
|
||||
# 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)
|
||||
|
||||
# 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)
|
||||
|
||||
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(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(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(
|
||||
date=self.fy_date_end,
|
||||
receivable_debit=0,
|
||||
receivable_credit=1000,
|
||||
income_debit=1000,
|
||||
income_credit=0
|
||||
)
|
||||
|
||||
# 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)
|
||||
|
||||
# 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)
|
||||
|
||||
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(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(lines['group2'].initial_balance, 0)
|
||||
self.assertEqual(lines['group2'].debit, 4000)
|
||||
self.assertEqual(lines['group2'].credit, 0)
|
||||
self.assertEqual(lines['group2'].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)
|
||||
|
||||
# Add a move at the previous day of the first day of fiscal year
|
||||
# to check the initial balance
|
||||
self._add_move(
|
||||
date=self.previous_fy_date_end,
|
||||
receivable_debit=1000,
|
||||
receivable_credit=0,
|
||||
income_debit=0,
|
||||
income_credit=1000
|
||||
)
|
||||
|
||||
# Re Generate the trial balance line
|
||||
lines = self._get_report_lines(with_partners=True)
|
||||
self.assertEqual(len(lines['partner_receivable']), 1)
|
||||
|
||||
# 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)
|
||||
|
||||
# Add reversale move of the initial move the first day of fiscal year
|
||||
# to check the first day of fiscal year is not used
|
||||
# to compute the initial balance
|
||||
self._add_move(
|
||||
date=self.fy_date_start,
|
||||
receivable_debit=0,
|
||||
receivable_credit=1000,
|
||||
income_debit=1000,
|
||||
income_credit=0
|
||||
)
|
||||
|
||||
# Re Generate the trial balance line
|
||||
lines = self._get_report_lines(with_partners=True)
|
||||
self.assertEqual(len(lines['partner_receivable']), 1)
|
||||
|
||||
# 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)
|
||||
|
||||
# Add another move at the end day of fiscal year
|
||||
# to check that it correctly used on report
|
||||
self._add_move(
|
||||
date=self.fy_date_end,
|
||||
receivable_debit=0,
|
||||
receivable_credit=1000,
|
||||
income_debit=1000,
|
||||
income_credit=0
|
||||
)
|
||||
|
||||
# Re Generate the trial balance line
|
||||
lines = self._get_report_lines(with_partners=True)
|
||||
self.assertEqual(len(lines['partner_receivable']), 1)
|
||||
|
||||
# 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)
|
||||
|
||||
288
account_financial_report/tests/test_vat_report.py
Normal file
288
account_financial_report/tests/test_vat_report.py
Normal file
@@ -0,0 +1,288 @@
|
||||
# Copyright 2018 Forest and Biomass Romania
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
import time
|
||||
|
||||
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': time.strftime('%Y-01-01'),
|
||||
'date_to': time.strftime('%Y-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):
|
||||
|
||||
def setUp(self):
|
||||
super(TestVATReport, self).setUp()
|
||||
self.date_from = time.strftime('%Y-%m-01'),
|
||||
self.date_to = time.strftime('%Y-%m-28'),
|
||||
self.receivable_account = self.env['account.account'].search([
|
||||
('user_type_id.name', '=', 'Receivable')
|
||||
], limit=1)
|
||||
self.income_account = self.env['account.account'].search([
|
||||
('user_type_id.name', '=', 'Income')
|
||||
], limit=1)
|
||||
self.tax_account = self.env['account.account'].search([
|
||||
('user_type_id',
|
||||
'=',
|
||||
self.env.ref(
|
||||
'account.data_account_type_non_current_liabilities').id
|
||||
)], limit=1)
|
||||
self.bank_journal = self.env['account.journal'].search(
|
||||
[('type', '=', 'bank')], limit=1)
|
||||
self.tax_tag_01 = self.env['account.account.tag'].create({
|
||||
'name': 'Tag 01',
|
||||
'applicability': 'taxes'
|
||||
})
|
||||
self.tax_tag_02 = self.env['account.account.tag'].create({
|
||||
'name': 'Tag 02',
|
||||
'applicability': 'taxes'
|
||||
})
|
||||
self.tax_tag_03 = self.env['account.account.tag'].create({
|
||||
'name': 'Tag 03',
|
||||
'applicability': 'taxes'
|
||||
})
|
||||
self.tax_group_10 = self.env['account.tax.group'].create({
|
||||
'name': 'Tax 10%',
|
||||
'sequence': 1
|
||||
})
|
||||
self.tax_group_20 = self.env['account.tax.group'].create({
|
||||
'name': 'Tax 20%',
|
||||
'sequence': 2
|
||||
})
|
||||
self.tax_10 = self.env['account.tax'].create({
|
||||
'name': 'Tax 10.0%',
|
||||
'amount': 10.0,
|
||||
'amount_type': 'percent',
|
||||
'type_tax_use': 'sale',
|
||||
'account_id': self.tax_account.id,
|
||||
'refund_account_id': self.tax_account.id,
|
||||
'tax_group_id': self.tax_group_10.id,
|
||||
'tag_ids': [(6, 0, [self.tax_tag_01.id, self.tax_tag_02.id])]
|
||||
})
|
||||
self.tax_20 = self.env['account.tax'].create({
|
||||
'sequence': 30,
|
||||
'name': 'Tax 20.0%',
|
||||
'amount': 20.0,
|
||||
'amount_type': 'percent',
|
||||
'type_tax_use': 'sale',
|
||||
'tax_exigibility': 'on_payment',
|
||||
'account_id': self.tax_account.id,
|
||||
'refund_account_id': self.tax_account.id,
|
||||
'cash_basis_account': self.tax_account.id,
|
||||
'tax_group_id': self.tax_group_20.id,
|
||||
'tag_ids': [(6, 0, [self.tax_tag_02.id, self.tax_tag_03.id])]
|
||||
})
|
||||
|
||||
invoice = self.env['account.invoice'].create({
|
||||
'partner_id': self.env.ref('base.res_partner_2').id,
|
||||
'account_id': self.receivable_account.id,
|
||||
'date_invoice': time.strftime('%Y-%m-03'),
|
||||
'type': 'out_invoice',
|
||||
})
|
||||
|
||||
self.env['account.invoice.line'].create({
|
||||
'product_id': self.env.ref('product.product_product_4').id,
|
||||
'quantity': 1.0,
|
||||
'price_unit': 100.0,
|
||||
'invoice_id': invoice.id,
|
||||
'name': 'product',
|
||||
'account_id': self.income_account.id,
|
||||
'invoice_line_tax_ids': [(6, 0, [self.tax_10.id])],
|
||||
})
|
||||
invoice.compute_taxes()
|
||||
invoice.action_invoice_open()
|
||||
|
||||
self.cbinvoice = self.env['account.invoice'].create({
|
||||
'partner_id': self.env.ref('base.res_partner_2').id,
|
||||
'account_id': self.receivable_account.id,
|
||||
'date_invoice': time.strftime('%Y-%m-05'),
|
||||
'type': 'out_invoice',
|
||||
})
|
||||
|
||||
self.env['account.invoice.line'].create({
|
||||
'product_id': self.env.ref('product.product_product_4').id,
|
||||
'quantity': 1.0,
|
||||
'price_unit': 500.0,
|
||||
'invoice_id': self.cbinvoice.id,
|
||||
'name': 'product',
|
||||
'account_id': self.income_account.id,
|
||||
'invoice_line_tax_ids': [(6, 0, [self.tax_20.id])],
|
||||
})
|
||||
self.cbinvoice.compute_taxes()
|
||||
self.cbinvoice.action_invoice_open()
|
||||
|
||||
def _get_report_lines(self):
|
||||
company = self.env.ref('base.main_company')
|
||||
self.cbinvoice.pay_and_reconcile(
|
||||
self.bank_journal.id, 300, time.strftime('%Y-%m-10'))
|
||||
vat_report = self.env['report_vat_report'].create({
|
||||
'date_from': self.date_from,
|
||||
'date_to': self.date_to,
|
||||
'company_id': company.id,
|
||||
'based_on': 'taxtags',
|
||||
'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
|
||||
|
||||
def test_01_compute(self):
|
||||
# Generate the vat lines
|
||||
lines = self._get_report_lines()
|
||||
|
||||
# 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 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)
|
||||
|
||||
def test_get_report_html(self):
|
||||
company = self.env.ref('base.main_company')
|
||||
vat_report = self.env['report_vat_report'].create({
|
||||
'date_from': self.date_from,
|
||||
'date_to': self.date_to,
|
||||
'company_id': company.id,
|
||||
'tax_detail': True,
|
||||
})
|
||||
vat_report.compute_data_for_report()
|
||||
vat_report.get_html(given_context={})
|
||||
|
||||
def test_wizard_date_range(self):
|
||||
vat_wizard = self.env['vat.report.wizard']
|
||||
date_range = self.env['date.range']
|
||||
self.type = self.env['date.range.type'].create(
|
||||
{'name': 'Month',
|
||||
'company_id': False,
|
||||
'allow_overlap': False})
|
||||
dt = date_range.create({
|
||||
'name': 'FS2016',
|
||||
'date_start': time.strftime('%Y-%m-01'),
|
||||
'date_end': time.strftime('%Y-%m-28'),
|
||||
'type_id': self.type.id,
|
||||
})
|
||||
wizard = vat_wizard.create(
|
||||
{'date_range_id': dt.id,
|
||||
'date_from': time.strftime('%Y-%m-28'),
|
||||
'date_to': time.strftime('%Y-%m-01'),
|
||||
'tax_detail': True})
|
||||
wizard.onchange_date_range_id()
|
||||
self.assertEqual(wizard.date_from, time.strftime('%Y-%m-01'))
|
||||
self.assertEqual(wizard.date_to, time.strftime('%Y-%m-28'))
|
||||
wizard._export('qweb-pdf')
|
||||
wizard.button_export_html()
|
||||
wizard.button_export_pdf()
|
||||
wizard.button_export_xlsx()
|
||||
wizard = vat_wizard.create(
|
||||
{'date_range_id': dt.id,
|
||||
'date_from': time.strftime('%Y-%m-28'),
|
||||
'date_to': time.strftime('%Y-%m-01'),
|
||||
'based_on': 'taxgroups',
|
||||
'tax_detail': True})
|
||||
wizard.onchange_date_range_id()
|
||||
self.assertEqual(wizard.date_from, time.strftime('%Y-%m-01'))
|
||||
self.assertEqual(wizard.date_to, time.strftime('%Y-%m-28'))
|
||||
wizard._export('qweb-pdf')
|
||||
wizard.button_export_html()
|
||||
wizard.button_export_pdf()
|
||||
wizard.button_export_xlsx()
|
||||
Reference in New Issue
Block a user