You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

640 lines
26 KiB

  1. # Author: Julien Coux
  2. # Copyright 2016 Camptocamp SA
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. import time
  5. from odoo.tests import common
  6. from . import abstract_test_foreign_currency as a_t_f_c
  7. class TestTrialBalance(a_t_f_c.AbstractTestForeignCurrency):
  8. """
  9. Technical tests for Trial Balance Report.
  10. """
  11. def _getReportModel(self):
  12. return self.env['report_trial_balance']
  13. def _getQwebReportName(self):
  14. return 'account_financial_report.report_trial_balance_qweb'
  15. def _getXlsxReportName(self):
  16. return 'a_f_r.report_trial_balance_xlsx'
  17. def _getXlsxReportActionName(self):
  18. return 'account_financial_report.action_report_trial_balance_xlsx'
  19. def _getReportTitle(self):
  20. return 'Odoo'
  21. def _getBaseFilters(self):
  22. return {
  23. 'date_from': time.strftime('%Y-01-01'),
  24. 'date_to': time.strftime('%Y-12-31'),
  25. 'company_id': self.company.id,
  26. 'fy_start_date': time.strftime('%Y-01-01'),
  27. 'foreign_currency': True,
  28. 'show_partner_details': True,
  29. }
  30. def _getAdditionalFiltersToBeTested(self):
  31. return [
  32. {'only_posted_moves': True},
  33. {'hide_account_balance_at_0': True},
  34. {'show_partner_details': True},
  35. {'hierarchy_on': 'computed'},
  36. {'hierarchy_on': 'relation'},
  37. {'only_posted_moves': True, 'hide_account_balance_at_0': True,
  38. 'hierarchy_on': 'computed'},
  39. {'only_posted_moves': True, 'hide_account_balance_at_0': True,
  40. 'hierarchy_on': 'relation'},
  41. {'only_posted_moves': True, 'hide_account_balance_at_0': True},
  42. {'only_posted_moves': True, 'show_partner_details': True},
  43. {'hide_account_balance_at_0': True, 'show_partner_details': True},
  44. {
  45. 'only_posted_moves': True,
  46. 'hide_account_balance_at_0': True,
  47. 'show_partner_details': True
  48. },
  49. ]
  50. def _partner_test_is_possible(self, filters):
  51. return 'show_partner_details' in filters
  52. class TestTrialBalanceReport(common.TransactionCase):
  53. def setUp(self):
  54. super(TestTrialBalanceReport, self).setUp()
  55. group_obj = self.env['account.group']
  56. acc_obj = self.env['account.account']
  57. self.group1 = group_obj.create(
  58. {'code_prefix': '1',
  59. 'name': 'Group 1'})
  60. self.group11 = group_obj.create(
  61. {'code_prefix': '11',
  62. 'name': 'Group 11',
  63. 'parent_id': self.group1.id})
  64. self.group2 = group_obj.create(
  65. {'code_prefix': '2',
  66. 'name': 'Group 2'})
  67. self.account100 = acc_obj.create(
  68. {'code': '100',
  69. 'name': 'Account 100',
  70. 'group_id': self.group1.id,
  71. 'user_type_id': self.env.ref(
  72. 'account.data_account_type_receivable').id,
  73. 'reconcile': True})
  74. self.account110 = self.env['account.account'].search([
  75. (
  76. 'user_type_id',
  77. '=',
  78. self.env.ref('account.data_unaffected_earnings').id
  79. )], limit=1)
  80. self.account200 = acc_obj.create(
  81. {'code': '200',
  82. 'name': 'Account 200',
  83. 'group_id': self.group2.id,
  84. 'user_type_id': self.env.ref(
  85. 'account.data_account_type_other_income').id})
  86. self.account300 = acc_obj.create(
  87. {'code': '300',
  88. 'name': 'Account 300',
  89. 'user_type_id': self.env.ref(
  90. 'account.data_account_type_other_income').id})
  91. self.account301 = acc_obj.create(
  92. {'code': '301',
  93. 'name': 'Account 301',
  94. 'group_id': self.group2.id,
  95. 'user_type_id': self.env.ref(
  96. 'account.data_account_type_other_income').id})
  97. self.previous_fy_date_start = '2015-01-01'
  98. self.previous_fy_date_end = '2015-12-31'
  99. self.fy_date_start = '2016-01-01'
  100. self.fy_date_end = '2016-12-31'
  101. self.date_start = '2016-01-01'
  102. self.date_end = '2016-12-31'
  103. def _add_move(
  104. self,
  105. date,
  106. receivable_debit,
  107. receivable_credit,
  108. income_debit,
  109. income_credit,
  110. unaffected_debit=0,
  111. unaffected_credit=0
  112. ):
  113. move_name = 'expense accrual'
  114. journal = self.env['account.journal'].search([], limit=1)
  115. partner = self.env.ref('base.res_partner_12')
  116. move_vals = {
  117. 'journal_id': journal.id,
  118. 'partner_id': partner.id,
  119. 'name': move_name,
  120. 'date': date,
  121. 'line_ids': [
  122. (0, 0, {
  123. 'name': move_name,
  124. 'debit': receivable_debit,
  125. 'credit': receivable_credit,
  126. 'account_id': self.account100.id}),
  127. (0, 0, {
  128. 'name': move_name,
  129. 'debit': income_debit,
  130. 'credit': income_credit,
  131. 'account_id': self.account200.id}),
  132. (0, 0, {
  133. 'name': move_name,
  134. 'debit': unaffected_debit,
  135. 'credit': unaffected_credit,
  136. 'account_id': self.account110.id}),
  137. (0, 0, {
  138. 'name': move_name,
  139. 'debit': receivable_debit,
  140. 'credit': receivable_credit,
  141. 'account_id': self.account300.id}),
  142. (0, 0, {
  143. 'name': move_name,
  144. 'debit': receivable_credit,
  145. 'credit': receivable_debit,
  146. 'account_id': self.account301.id})
  147. ]}
  148. move = self.env['account.move'].create(move_vals)
  149. move.post()
  150. def _get_report_lines(self, with_partners=False, hierarchy_on='computed'):
  151. company = self.env.ref('base.main_company')
  152. trial_balance = self.env['report_trial_balance'].create({
  153. 'date_from': self.date_start,
  154. 'date_to': self.date_end,
  155. 'only_posted_moves': True,
  156. 'hide_account_balance_at_0': False,
  157. 'hierarchy_on': hierarchy_on,
  158. 'company_id': company.id,
  159. 'fy_start_date': self.fy_date_start,
  160. 'show_partner_details': with_partners,
  161. })
  162. trial_balance.compute_data_for_report()
  163. lines = {}
  164. report_account_model = self.env['report_trial_balance_account']
  165. lines['receivable'] = report_account_model.search([
  166. ('report_id', '=', trial_balance.id),
  167. ('account_id', '=', self.account100.id),
  168. ])
  169. lines['income'] = report_account_model.search([
  170. ('report_id', '=', trial_balance.id),
  171. ('account_id', '=', self.account200.id),
  172. ])
  173. lines['unaffected'] = report_account_model.search([
  174. ('report_id', '=', trial_balance.id),
  175. ('account_id', '=', self.account110.id),
  176. ])
  177. lines['group1'] = report_account_model.search([
  178. ('report_id', '=', trial_balance.id),
  179. ('account_group_id', '=', self.group1.id),
  180. ])
  181. lines['group2'] = report_account_model.search([
  182. ('report_id', '=', trial_balance.id),
  183. ('account_group_id', '=', self.group2.id),
  184. ])
  185. if with_partners:
  186. report_partner_model = self.env[
  187. 'report_trial_balance_partner'
  188. ]
  189. lines['partner_receivable'] = report_partner_model.search([
  190. ('report_account_id', '=', lines['receivable'].id),
  191. ('partner_id', '=', self.env.ref('base.res_partner_12').id),
  192. ])
  193. return lines
  194. def test_00_account_group(self):
  195. self.assertGreaterEqual(len(self.group1.compute_account_ids), 19)
  196. self.assertGreaterEqual(len(self.group2.compute_account_ids), 9)
  197. def test_01_account_balance_computed(self):
  198. # Make sure there's no account of type "Current Year Earnings" in the
  199. # groups - We change the code
  200. earning_accs = self.env['account.account'].search([
  201. ('user_type_id', '=',
  202. self.env.ref('account.data_unaffected_earnings').id)
  203. ])
  204. for acc in earning_accs:
  205. if acc.code.startswith('1') or acc.code.startswith('2'):
  206. acc.code = '999' + acc.code
  207. # Generate the general ledger line
  208. lines = self._get_report_lines()
  209. self.assertEqual(len(lines['receivable']), 1)
  210. self.assertEqual(len(lines['income']), 1)
  211. # Add a move at the previous day of the first day of fiscal year
  212. # to check the initial balance
  213. self._add_move(
  214. date=self.previous_fy_date_end,
  215. receivable_debit=1000,
  216. receivable_credit=0,
  217. income_debit=0,
  218. income_credit=1000
  219. )
  220. # Re Generate the trial balance line
  221. lines = self._get_report_lines()
  222. self.assertEqual(len(lines['receivable']), 1)
  223. self.assertEqual(len(lines['income']), 1)
  224. # Check the initial and final balance
  225. self.assertEqual(lines['receivable'].initial_balance, 1000)
  226. self.assertEqual(lines['receivable'].debit, 0)
  227. self.assertEqual(lines['receivable'].credit, 0)
  228. self.assertEqual(lines['receivable'].final_balance, 1000)
  229. self.assertEqual(lines['group1'].initial_balance, 1000)
  230. self.assertEqual(lines['group1'].debit, 0)
  231. self.assertEqual(lines['group1'].credit, 0)
  232. self.assertEqual(lines['group1'].final_balance, 1000)
  233. # Add reversed move of the initial move the first day of fiscal year
  234. # to check the first day of fiscal year is not used
  235. # to compute the initial balance
  236. self._add_move(
  237. date=self.fy_date_start,
  238. receivable_debit=0,
  239. receivable_credit=1000,
  240. income_debit=1000,
  241. income_credit=0
  242. )
  243. # Re Generate the trial balance line
  244. lines = self._get_report_lines()
  245. self.assertEqual(len(lines['receivable']), 1)
  246. self.assertEqual(len(lines['income']), 1)
  247. # Check the initial and final balance
  248. self.assertEqual(lines['receivable'].initial_balance, 1000)
  249. self.assertEqual(lines['receivable'].debit, 0)
  250. self.assertEqual(lines['receivable'].credit, 1000)
  251. self.assertEqual(lines['receivable'].final_balance, 0)
  252. self.assertEqual(lines['income'].initial_balance, 0)
  253. self.assertEqual(lines['income'].debit, 1000)
  254. self.assertEqual(lines['income'].credit, 0)
  255. self.assertEqual(lines['income'].final_balance, 1000)
  256. self.assertEqual(lines['group1'].initial_balance, 1000)
  257. self.assertEqual(lines['group1'].debit, 0)
  258. self.assertEqual(lines['group1'].credit, 1000)
  259. self.assertEqual(lines['group1'].final_balance, 0)
  260. self.assertEqual(lines['group2'].initial_balance, 0)
  261. self.assertEqual(lines['group2'].debit, 1000)
  262. self.assertEqual(lines['group2'].credit, 0)
  263. self.assertEqual(lines['group2'].final_balance, 1000)
  264. # Add another move at the end day of fiscal year
  265. # to check that it correctly used on report
  266. self._add_move(
  267. date=self.fy_date_end,
  268. receivable_debit=0,
  269. receivable_credit=1000,
  270. income_debit=1000,
  271. income_credit=0
  272. )
  273. # Re Generate the trial balance line
  274. lines = self._get_report_lines()
  275. self.assertEqual(len(lines['receivable']), 1)
  276. self.assertEqual(len(lines['income']), 1)
  277. # Check the initial and final balance
  278. self.assertEqual(lines['receivable'].initial_balance, 1000)
  279. self.assertEqual(lines['receivable'].debit, 0)
  280. self.assertEqual(lines['receivable'].credit, 2000)
  281. self.assertEqual(lines['receivable'].final_balance, -1000)
  282. self.assertEqual(lines['income'].initial_balance, 0)
  283. self.assertEqual(lines['income'].debit, 2000)
  284. self.assertEqual(lines['income'].credit, 0)
  285. self.assertEqual(lines['income'].final_balance, 2000)
  286. self.assertEqual(lines['group1'].initial_balance, 1000)
  287. self.assertEqual(lines['group1'].debit, 0)
  288. self.assertEqual(lines['group1'].credit, 2000)
  289. self.assertEqual(lines['group1'].final_balance, -1000)
  290. self.assertEqual(lines['group2'].initial_balance, 0)
  291. self.assertEqual(lines['group2'].debit, 2000)
  292. self.assertEqual(lines['group2'].credit, 0)
  293. self.assertEqual(lines['group2'].final_balance, 2000)
  294. self.assertEqual(len(lines['group2'].compute_account_ids), 2)
  295. def test_02_account_balance_hierarchy(self):
  296. # Generate the general ledger line
  297. lines = self._get_report_lines(hierarchy_on='relation')
  298. self.assertEqual(len(lines['receivable']), 1)
  299. self.assertEqual(len(lines['income']), 1)
  300. # Add a move at the previous day of the first day of fiscal year
  301. # to check the initial balance
  302. self._add_move(
  303. date=self.previous_fy_date_end,
  304. receivable_debit=1000,
  305. receivable_credit=0,
  306. income_debit=0,
  307. income_credit=1000
  308. )
  309. # Re Generate the trial balance line
  310. lines = self._get_report_lines(hierarchy_on='relation')
  311. self.assertEqual(len(lines['receivable']), 1)
  312. self.assertEqual(len(lines['income']), 1)
  313. # Check the initial and final balance
  314. self.assertEqual(lines['receivable'].initial_balance, 1000)
  315. self.assertEqual(lines['receivable'].debit, 0)
  316. self.assertEqual(lines['receivable'].credit, 0)
  317. self.assertEqual(lines['receivable'].final_balance, 1000)
  318. self.assertEqual(lines['group1'].initial_balance, 1000)
  319. self.assertEqual(lines['group1'].debit, 0)
  320. self.assertEqual(lines['group1'].credit, 0)
  321. self.assertEqual(lines['group1'].final_balance, 1000)
  322. # Add reversale move of the initial move the first day of fiscal year
  323. # to check the first day of fiscal year is not used
  324. # to compute the initial balance
  325. self._add_move(
  326. date=self.fy_date_start,
  327. receivable_debit=0,
  328. receivable_credit=1000,
  329. income_debit=1000,
  330. income_credit=0
  331. )
  332. # Re Generate the trial balance line
  333. lines = self._get_report_lines(hierarchy_on='relation')
  334. self.assertEqual(len(lines['receivable']), 1)
  335. self.assertEqual(len(lines['income']), 1)
  336. # Check the initial and final balance
  337. self.assertEqual(lines['receivable'].initial_balance, 1000)
  338. self.assertEqual(lines['receivable'].debit, 0)
  339. self.assertEqual(lines['receivable'].credit, 1000)
  340. self.assertEqual(lines['receivable'].final_balance, 0)
  341. self.assertEqual(lines['income'].initial_balance, 0)
  342. self.assertEqual(lines['income'].debit, 1000)
  343. self.assertEqual(lines['income'].credit, 0)
  344. self.assertEqual(lines['income'].final_balance, 1000)
  345. self.assertEqual(lines['group1'].initial_balance, 1000)
  346. self.assertEqual(lines['group1'].debit, 0)
  347. self.assertEqual(lines['group1'].credit, 1000)
  348. self.assertEqual(lines['group1'].final_balance, 0)
  349. self.assertEqual(lines['group2'].initial_balance, 0)
  350. self.assertEqual(lines['group2'].debit, 2000)
  351. self.assertEqual(lines['group2'].credit, 0)
  352. self.assertEqual(lines['group2'].final_balance, 2000)
  353. self.assertEqual(len(lines['group2'].compute_account_ids), 2)
  354. # Add another move at the end day of fiscal year
  355. # to check that it correctly used on report
  356. self._add_move(
  357. date=self.fy_date_end,
  358. receivable_debit=0,
  359. receivable_credit=1000,
  360. income_debit=1000,
  361. income_credit=0
  362. )
  363. # Re Generate the trial balance line
  364. lines = self._get_report_lines(hierarchy_on='relation')
  365. self.assertEqual(len(lines['receivable']), 1)
  366. self.assertEqual(len(lines['income']), 1)
  367. # Check the initial and final balance
  368. self.assertEqual(lines['receivable'].initial_balance, 1000)
  369. self.assertEqual(lines['receivable'].debit, 0)
  370. self.assertEqual(lines['receivable'].credit, 2000)
  371. self.assertEqual(lines['receivable'].final_balance, -1000)
  372. self.assertEqual(lines['income'].initial_balance, 0)
  373. self.assertEqual(lines['income'].debit, 2000)
  374. self.assertEqual(lines['income'].credit, 0)
  375. self.assertEqual(lines['income'].final_balance, 2000)
  376. self.assertEqual(lines['group1'].initial_balance, 1000)
  377. self.assertEqual(lines['group1'].debit, 0)
  378. self.assertEqual(lines['group1'].credit, 2000)
  379. self.assertEqual(lines['group1'].final_balance, -1000)
  380. self.assertEqual(lines['group2'].initial_balance, 0)
  381. self.assertEqual(lines['group2'].debit, 4000)
  382. self.assertEqual(lines['group2'].credit, 0)
  383. self.assertEqual(lines['group2'].final_balance, 4000)
  384. def test_03_partner_balance(self):
  385. # Generate the trial balance line
  386. lines = self._get_report_lines(with_partners=True)
  387. self.assertEqual(len(lines['partner_receivable']), 0)
  388. # Add a move at the previous day of the first day of fiscal year
  389. # to check the initial balance
  390. self._add_move(
  391. date=self.previous_fy_date_end,
  392. receivable_debit=1000,
  393. receivable_credit=0,
  394. income_debit=0,
  395. income_credit=1000
  396. )
  397. # Re Generate the trial balance line
  398. lines = self._get_report_lines(with_partners=True)
  399. self.assertEqual(len(lines['partner_receivable']), 1)
  400. # Check the initial and final balance
  401. self.assertEqual(lines['partner_receivable'].initial_balance, 1000)
  402. self.assertEqual(lines['partner_receivable'].debit, 0)
  403. self.assertEqual(lines['partner_receivable'].credit, 0)
  404. self.assertEqual(lines['partner_receivable'].final_balance, 1000)
  405. # Add reversale move of the initial move the first day of fiscal year
  406. # to check the first day of fiscal year is not used
  407. # to compute the initial balance
  408. self._add_move(
  409. date=self.fy_date_start,
  410. receivable_debit=0,
  411. receivable_credit=1000,
  412. income_debit=1000,
  413. income_credit=0
  414. )
  415. # Re Generate the trial balance line
  416. lines = self._get_report_lines(with_partners=True)
  417. self.assertEqual(len(lines['partner_receivable']), 1)
  418. # Check the initial and final balance
  419. self.assertEqual(lines['partner_receivable'].initial_balance, 1000)
  420. self.assertEqual(lines['partner_receivable'].debit, 0)
  421. self.assertEqual(lines['partner_receivable'].credit, 1000)
  422. self.assertEqual(lines['partner_receivable'].final_balance, 0)
  423. # Add another move at the end day of fiscal year
  424. # to check that it correctly used on report
  425. self._add_move(
  426. date=self.fy_date_end,
  427. receivable_debit=0,
  428. receivable_credit=1000,
  429. income_debit=1000,
  430. income_credit=0
  431. )
  432. # Re Generate the trial balance line
  433. lines = self._get_report_lines(with_partners=True)
  434. self.assertEqual(len(lines['partner_receivable']), 1)
  435. # Check the initial and final balance
  436. self.assertEqual(lines['partner_receivable'].initial_balance, 1000)
  437. self.assertEqual(lines['partner_receivable'].debit, 0)
  438. self.assertEqual(lines['partner_receivable'].credit, 2000)
  439. self.assertEqual(lines['partner_receivable'].final_balance, -1000)
  440. def test_04_undistributed_pl(self):
  441. # Add a P&L Move in the previous FY
  442. move_name = 'current year pl move'
  443. journal = self.env['account.journal'].search([], limit=1)
  444. move_vals = {
  445. 'journal_id': journal.id,
  446. 'name': move_name,
  447. 'date': self.previous_fy_date_end,
  448. 'line_ids': [
  449. (0, 0, {
  450. 'name': move_name,
  451. 'debit': 0.0,
  452. 'credit': 1000.0,
  453. 'account_id': self.account300.id}),
  454. (0, 0, {
  455. 'name': move_name,
  456. 'debit': 1000.0,
  457. 'credit': 0.0,
  458. 'account_id': self.account100.id})
  459. ]}
  460. move = self.env['account.move'].create(move_vals)
  461. move.post()
  462. # Generate the trial balance line
  463. report_account_model = self.env['report_trial_balance_account']
  464. company = self.env.ref('base.main_company')
  465. trial_balance = self.env['report_trial_balance'].create({
  466. 'date_from': self.date_start,
  467. 'date_to': self.date_end,
  468. 'only_posted_moves': True,
  469. 'hide_account_balance_at_0': False,
  470. 'hierarchy_on': 'none',
  471. 'company_id': company.id,
  472. 'fy_start_date': self.fy_date_start,
  473. })
  474. trial_balance.compute_data_for_report()
  475. unaffected_balance_lines = report_account_model.search([
  476. ('report_id', '=', trial_balance.id),
  477. ('account_id', '=', self.account110.id),
  478. ])
  479. self.assertEqual(len(unaffected_balance_lines), 1)
  480. self.assertEqual(unaffected_balance_lines[0].initial_balance, -1000)
  481. self.assertEqual(unaffected_balance_lines[0].debit, 0)
  482. self.assertEqual(unaffected_balance_lines[0].credit, 0)
  483. self.assertEqual(unaffected_balance_lines[0].final_balance, -1000)
  484. # Add a P&L Move to the current FY
  485. move_name = 'current year pl move'
  486. journal = self.env['account.journal'].search([], limit=1)
  487. move_vals = {
  488. 'journal_id': journal.id,
  489. 'name': move_name,
  490. 'date': self.date_start,
  491. 'line_ids': [
  492. (0, 0, {
  493. 'name': move_name,
  494. 'debit': 0.0,
  495. 'credit': 1000.0,
  496. 'account_id': self.account300.id}),
  497. (0, 0, {
  498. 'name': move_name,
  499. 'debit': 1000.0,
  500. 'credit': 0.0,
  501. 'account_id': self.account100.id})
  502. ]}
  503. move = self.env['account.move'].create(move_vals)
  504. move.post()
  505. # Re Generate the trial balance line
  506. trial_balance = self.env['report_trial_balance'].create({
  507. 'date_from': self.date_start,
  508. 'date_to': self.date_end,
  509. 'only_posted_moves': True,
  510. 'hide_account_balance_at_0': False,
  511. 'hierarchy_on': 'none',
  512. 'company_id': company.id,
  513. 'fy_start_date': self.fy_date_start,
  514. })
  515. trial_balance.compute_data_for_report()
  516. unaffected_balance_lines = report_account_model.search([
  517. ('report_id', '=', trial_balance.id),
  518. ('account_id', '=', self.account110.id),
  519. ])
  520. # The unaffected earnings account is not affected by a journal entry
  521. # made to the P&L in the current fiscal year.
  522. self.assertEqual(len(unaffected_balance_lines), 1)
  523. self.assertEqual(unaffected_balance_lines[0].initial_balance, -1000)
  524. self.assertEqual(unaffected_balance_lines[0].debit, 0)
  525. self.assertEqual(unaffected_balance_lines[0].credit, 0)
  526. self.assertEqual(unaffected_balance_lines[0].final_balance, -1000)
  527. # Add a Move including Unaffected Earnings to the current FY
  528. move_name = 'current year unaffected earnings move'
  529. journal = self.env['account.journal'].search([], limit=1)
  530. move_vals = {
  531. 'journal_id': journal.id,
  532. 'name': move_name,
  533. 'date': self.date_start,
  534. 'line_ids': [
  535. (0, 0, {
  536. 'name': move_name,
  537. 'debit': 0.0,
  538. 'credit': 1000.0,
  539. 'account_id': self.account110.id}),
  540. (0, 0, {
  541. 'name': move_name,
  542. 'debit': 1000.0,
  543. 'credit': 0.0,
  544. 'account_id': self.account100.id})
  545. ]}
  546. move = self.env['account.move'].create(move_vals)
  547. move.post()
  548. # Re Generate the trial balance line
  549. trial_balance = self.env['report_trial_balance'].create({
  550. 'date_from': self.date_start,
  551. 'date_to': self.date_end,
  552. 'only_posted_moves': True,
  553. 'hide_account_balance_at_0': False,
  554. 'hierarchy_on': 'none',
  555. 'company_id': company.id,
  556. 'fy_start_date': self.fy_date_start,
  557. })
  558. trial_balance.compute_data_for_report()
  559. # The unaffected earnings account affected by a journal entry
  560. # made to the unaffected earnings in the current fiscal year.
  561. unaffected_balance_lines = report_account_model.search([
  562. ('report_id', '=', trial_balance.id),
  563. ('account_id', '=', self.account110.id),
  564. ])
  565. self.assertEqual(len(unaffected_balance_lines), 1)
  566. self.assertEqual(unaffected_balance_lines[0].initial_balance, -1000)
  567. self.assertEqual(unaffected_balance_lines[0].debit, 0)
  568. self.assertEqual(unaffected_balance_lines[0].credit, 1000)
  569. self.assertEqual(unaffected_balance_lines[0].final_balance, -2000)
  570. # The totals for the Trial Balance are zero
  571. all_lines = report_account_model.search([
  572. ('report_id', '=', trial_balance.id),
  573. ])
  574. self.assertEqual(sum(all_lines.mapped('initial_balance')), 0)
  575. self.assertEqual(sum(all_lines.mapped('final_balance')), 0)
  576. self.assertEqual(sum(all_lines.mapped('debit')),
  577. sum(all_lines.mapped('credit')))