book: hierarchie + test

book: Feld 'start_balance' entfernt
This commit is contained in:
Frederik Jaeckel 2022-09-15 23:49:54 +02:00
parent e10616e847
commit a2e7f192f8
16 changed files with 319 additions and 168 deletions

View file

@ -51,10 +51,37 @@ class BookTestCase(ModuleTestCase):
'number_sequ': self.prep_sequence().id,
}])
self.assertEqual(book.name, 'Book 1')
self.assertEqual(book.rec_name, 'Book 1 | 0.00 usd | Open')
self.assertEqual(book.btype.rec_name, 'CAS - Cash')
self.assertEqual(book.state, 'open')
self.assertEqual(book.state_string, 'Open')
@with_transaction()
def test_book_create_hierarchy(self):
""" create cashbook, hierarchical
"""
pool = Pool()
Book = pool.get('cashbook.book')
types = self.prep_type()
company = self.prep_company()
book, = Book.create([{
'name': 'Level 1',
'btype': None,
'company': company.id,
'childs': [('create', [{
'name': 'Level 2',
'btype': types.id,
'company': company.id,
'currency': company.currency.id,
'number_sequ': self.prep_sequence().id,
}])],
}])
self.assertEqual(book.name, 'Level 1')
self.assertEqual(book.rec_name, 'Level 1')
self.assertEqual(len(book.childs), 1)
self.assertEqual(book.childs[0].rec_name, 'Level 1/Level 2 | 0.00 usd | Open')
@with_transaction()
def test_book_deny_delete_open(self):
""" create cashbook, add lines, try to delete in state 'open'
@ -225,62 +252,6 @@ class BookTestCase(ModuleTestCase):
},
])
@with_transaction()
def test_book_deny_update_start_amount(self):
""" create cashbook, add lines, update start-amount
"""
pool = Pool()
Book = pool.get('cashbook.book')
types = self.prep_type()
company = self.prep_company()
category = self.prep_category(cattype='in')
party = self.prep_party()
book, = Book.create([{
'name': 'Book 1',
'btype': types.id,
'company': company.id,
'currency': company.currency.id,
'number_sequ': self.prep_sequence().id,
}])
self.assertEqual(book.name, 'Book 1')
self.assertEqual(book.start_balance, Decimal('0.0'))
self.assertEqual(book.rec_name, 'Book 1 | 0.00 usd | Open')
Book.write(*[
[book],
{
'start_balance': Decimal('1.0'),
}])
self.assertEqual(book.start_balance, Decimal('1.0'))
self.assertEqual(book.balance, Decimal('1.0'))
Book.write(*[
[book],
{
'lines': [('create', [{
'amount': Decimal('2.0'),
'description': 'Test',
'category': category.id,
'bookingtype': 'in',
'party': party.id,
}])],
}])
self.assertEqual(book.start_balance, Decimal('1.0'))
self.assertEqual(book.balance, Decimal('3.0'))
self.assertEqual(len(book.lines), 1)
self.assertEqual(book.lines[0].balance, Decimal('3.0'))
self.assertRaisesRegex(UserError,
"The initial amount of the cash book 'Fridas book | 3.00 usd | Open' cannot be changed because it already contains bookings.",
Book.write,
*[
[book],
{
'start_balance': Decimal('1.5'),
},
])
@with_transaction()
def test_book_permission_owner(self):
""" create book + 2x users, add users to group, check access

View file

@ -39,7 +39,6 @@ class BookingWizardTestCase(ModuleTestCase):
'currency': company.currency.id,
'number_sequ': self.prep_sequence().id,
'start_date': date(2022, 1, 1),
'start_balance': Decimal('0.0'),
}])
party, = Party.create([{
@ -114,7 +113,6 @@ class BookingWizardTestCase(ModuleTestCase):
'currency': company.currency.id,
'number_sequ': self.prep_sequence().id,
'start_date': date(2022, 1, 1),
'start_balance': Decimal('0.0'),
}, {
'name': 'Bank',
'btype': types.id,
@ -122,7 +120,6 @@ class BookingWizardTestCase(ModuleTestCase):
'currency': company.currency.id,
'number_sequ': self.prep_sequence().id,
'start_date': date(2022, 1, 1),
'start_balance': Decimal('0.0'),
}])
party, = Party.create([{

View file

@ -574,6 +574,36 @@ class LineTestCase(ModuleTestCase):
self.assertEqual(book.lines[2].rec_name, '05/01/2022|Rev/Sp|1.00 usd|Text 3 [-]')
self.assertEqual(book.lines[2].state, 'edit')
@with_transaction()
def test_line_to_non_type_book(self):
""" create cashbook w/o type
"""
pool = Pool()
Book = pool.get('cashbook.book')
Line = pool.get('cashbook.line')
category = self.prep_category(cattype='in')
company = self.prep_company()
party = self.prep_party()
book, = Book.create([{
'name': 'Book 1',
'btype': None,
'company': company.id,
}])
self.assertEqual(book.name, 'Book 1')
self.assertEqual(book.state, 'open')
self.assertRaisesRegex(UserError,
'The value for field "Cashbook" in "Cashbook Line" is not valid according to its domain.',
Line.create,
[{
'cashbook': book.id,
'date': date(2022, 5, 1),
'category': category.id,
'bookingtype': 'in',
'amount': Decimal('0.0'),
}])
@with_transaction()
def test_line_create_check_deny_write(self):
""" create cashbook + line, 'close' book, write to line

View file

@ -221,7 +221,6 @@ class ReconTestCase(ModuleTestCase):
'btype': types.id,
'company': company.id,
'currency': company.currency.id,
'start_balance': Decimal('12.50'),
'start_date': date(2022, 5, 1),
'number_sequ': self.prep_sequence().id,
'reconciliations': [('create', [{
@ -234,7 +233,7 @@ class ReconTestCase(ModuleTestCase):
self.assertEqual(book.reconciliations[0].rec_name, '05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
Reconciliation.wfcheck(list(book.reconciliations))
self.assertEqual(book.reconciliations[0].rec_name, '05/01/2022 - 05/31/2022 | 12.50 usd - 12.50 usd [0]')
self.assertEqual(book.reconciliations[0].rec_name, '05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
@with_transaction()
def test_recon_set_start_amount_by_predecessor(self):
@ -254,7 +253,6 @@ class ReconTestCase(ModuleTestCase):
'btype': types.id,
'company': company.id,
'currency': company.currency.id,
'start_balance': Decimal('12.50'),
'start_date': date(2022, 5, 1),
'number_sequ': self.prep_sequence().id,
'reconciliations': [('create', [{
@ -287,7 +285,7 @@ class ReconTestCase(ModuleTestCase):
Reconciliation.wfcheck(list(book.reconciliations))
self.assertEqual(book.reconciliations[0].state, 'check')
self.assertEqual(book.reconciliations[0].rec_name, '05/01/2022 - 05/31/2022 | 12.50 usd - 24.50 usd [2]')
self.assertEqual(book.reconciliations[0].rec_name, '05/01/2022 - 05/31/2022 | 0.00 usd - 12.00 usd [2]')
Reconciliation.wfdone(list(book.reconciliations))
self.assertEqual(book.reconciliations[0].state, 'done')
@ -298,7 +296,7 @@ class ReconTestCase(ModuleTestCase):
}])
self.assertEqual(recons[0].rec_name, '05/31/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0]')
Reconciliation.wfcheck(recons)
self.assertEqual(recons[0].rec_name, '05/31/2022 - 06/30/2022 | 24.50 usd - 24.50 usd [0]')
self.assertEqual(recons[0].rec_name, '05/31/2022 - 06/30/2022 | 12.00 usd - 12.00 usd [0]')
@with_transaction()
def test_recon_predecessor_done(self):