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