line: spalte 'empfänger', Feld 'reference' + tests
This commit is contained in:
parent
30b91cf518
commit
5fdbb0ce89
10 changed files with 510 additions and 42 deletions
|
@ -45,6 +45,7 @@ class BookTestCase(ModuleTestCase):
|
|||
types = self.prep_type()
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
'btype': types.id,
|
||||
|
@ -56,6 +57,7 @@ class BookTestCase(ModuleTestCase):
|
|||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Book 1')
|
||||
|
@ -76,6 +78,7 @@ class BookTestCase(ModuleTestCase):
|
|||
types = self.prep_type()
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
'btype': types.id,
|
||||
|
@ -87,6 +90,7 @@ class BookTestCase(ModuleTestCase):
|
|||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Book 1')
|
||||
|
@ -109,6 +113,7 @@ class BookTestCase(ModuleTestCase):
|
|||
types = self.prep_type()
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
'btype': types.id,
|
||||
|
@ -120,6 +125,7 @@ class BookTestCase(ModuleTestCase):
|
|||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Book 1')
|
||||
|
@ -202,6 +208,7 @@ class BookTestCase(ModuleTestCase):
|
|||
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,
|
||||
|
@ -228,6 +235,7 @@ class BookTestCase(ModuleTestCase):
|
|||
'description': 'Test',
|
||||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'party': party.id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.start_balance, Decimal('1.0'))
|
||||
|
|
|
@ -43,6 +43,16 @@ class ConfigTestCase(ModuleTestCase):
|
|||
self.assertEqual(cfg2.catnamelong, True)
|
||||
return cfg2
|
||||
|
||||
def prep_party(self, name='Party'):
|
||||
""" new party
|
||||
"""
|
||||
Party = Pool().get('party.party')
|
||||
party, = Party.create([{
|
||||
'name': name,
|
||||
'addresses': [('create', [{}])],
|
||||
}])
|
||||
return party
|
||||
|
||||
@with_transaction()
|
||||
def test_config_create(self):
|
||||
""" create config
|
||||
|
|
|
@ -27,6 +27,7 @@ class LineTestCase(ModuleTestCase):
|
|||
types = self.prep_type()
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
'btype': types.id,
|
||||
|
@ -38,12 +39,14 @@ class LineTestCase(ModuleTestCase):
|
|||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}, {
|
||||
'date': date(2022, 5, 2),
|
||||
'description': 'Text 2',
|
||||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Book 1')
|
||||
|
@ -51,10 +54,10 @@ class LineTestCase(ModuleTestCase):
|
|||
self.assertEqual(book.state, 'open')
|
||||
self.assertEqual(len(book.lines), 2)
|
||||
self.assertEqual(book.lines[0].date, date(2022, 5, 1))
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].state_cashbook, 'open')
|
||||
self.assertEqual(book.lines[1].date, date(2022, 5, 2))
|
||||
self.assertEqual(book.lines[1].rec_name, '05/02/2022|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '05/02/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
|
||||
self.assertEqual(Lines.search_count([('rec_name', '=', 'Text 1')]), 1)
|
||||
self.assertEqual(Lines.search_count([('rec_name', '=', 'Text 1a')]), 0)
|
||||
|
@ -67,9 +70,9 @@ class LineTestCase(ModuleTestCase):
|
|||
|
||||
# sorting: date -> state -> id
|
||||
self.assertEqual(len(book.lines), 2)
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].state, 'edit')
|
||||
self.assertEqual(book.lines[1].rec_name, '05/02/2022|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '05/02/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[1].state, 'edit')
|
||||
|
||||
# set to same date
|
||||
|
@ -80,17 +83,17 @@ class LineTestCase(ModuleTestCase):
|
|||
}])
|
||||
# check again
|
||||
book, = Book.search([])
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].state, 'edit')
|
||||
self.assertEqual(book.lines[1].rec_name, '05/01/2022|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '05/01/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[1].state, 'edit')
|
||||
|
||||
# set to 'check', will sort first
|
||||
Lines.wfcheck([book.lines[1]])
|
||||
book, = Book.search([])
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[0].state, 'check')
|
||||
self.assertEqual(book.lines[1].rec_name, '05/01/2022|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[1].state, 'edit')
|
||||
|
||||
@with_transaction()
|
||||
|
@ -104,6 +107,7 @@ class LineTestCase(ModuleTestCase):
|
|||
types = self.prep_type()
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
'btype': types.id,
|
||||
|
@ -115,12 +119,14 @@ class LineTestCase(ModuleTestCase):
|
|||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}, {
|
||||
'date': date(2022, 6, 1),
|
||||
'description': 'Text 2',
|
||||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Book 1')
|
||||
|
@ -170,6 +176,7 @@ class LineTestCase(ModuleTestCase):
|
|||
types = self.prep_type()
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
IrDate.today = MagicMock(return_value=date(2022, 6, 1))
|
||||
|
||||
book, = Book.create([{
|
||||
|
@ -183,12 +190,14 @@ class LineTestCase(ModuleTestCase):
|
|||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}, {
|
||||
'date': date(2022, 6, 1),
|
||||
'description': 'Text 2',
|
||||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Book 1')
|
||||
|
@ -221,6 +230,135 @@ class LineTestCase(ModuleTestCase):
|
|||
|
||||
IrDate.today = MagicMock(return_value=date.today())
|
||||
|
||||
@with_transaction()
|
||||
def test_line_check_bookingtype_mvout(self):
|
||||
""" create cashbook + line, bookingtype 'mvout'
|
||||
"""
|
||||
pool = Pool()
|
||||
Book = pool.get('cashbook.book')
|
||||
Line = pool.get('cashbook.line')
|
||||
Category = pool.get('cashbook.category')
|
||||
|
||||
types = self.prep_type()
|
||||
category_in = self.prep_category(cattype='in')
|
||||
category_out = self.prep_category(name='Out Category', cattype='out')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
|
||||
book2, = Book.create([{
|
||||
'name': 'Book 2',
|
||||
'btype': types.id,
|
||||
'company': company.id,
|
||||
'currency': company.currency.id,
|
||||
}])
|
||||
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
'btype': types.id,
|
||||
'company': company.id,
|
||||
'currency': company.currency.id,
|
||||
'lines': [('create', [{
|
||||
'date': date(2022, 5, 1),
|
||||
'description': 'Transfer Out',
|
||||
'category': category_out.id,
|
||||
'bookingtype': 'mvout',
|
||||
'amount': Decimal('1.0'),
|
||||
'booktransf': book2.id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.rec_name, 'Book 1 | -1.00 usd | Open')
|
||||
self.assertEqual(len(book.lines), 1)
|
||||
self.assertEqual(len(book2.lines), 0)
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|to|-1.00 usd|Transfer Out [Book 2 | 0.00 usd | Open]')
|
||||
self.assertEqual(len(book.lines[0].references), 0)
|
||||
|
||||
# check payee
|
||||
self.assertEqual(book.lines[0].payee.rec_name, 'Book 2 | 0.00 usd | Open')
|
||||
self.assertEqual(Line.search_count([('payee', 'ilike', 'book 2%')]), 1)
|
||||
|
||||
# set line to 'checked', this creates the counterpart
|
||||
Line.wfcheck(list(book.lines))
|
||||
|
||||
self.assertEqual(len(book.lines), 1)
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|to|-1.00 usd|Transfer Out [Book 2 | 1.00 usd | Open]')
|
||||
self.assertEqual(book.lines[0].state, 'check')
|
||||
self.assertEqual(len(book.lines[0].references), 1)
|
||||
self.assertEqual(book.lines[0].reference, None)
|
||||
self.assertEqual(book.lines[0].references[0].id, book2.lines[0].id)
|
||||
|
||||
self.assertEqual(len(book2.lines), 1)
|
||||
self.assertEqual(book2.lines[0].rec_name, '05/01/2022|from|1.00 usd|Transfer Out [Book 1 | -1.00 usd | Open]')
|
||||
self.assertEqual(book2.lines[0].state, 'check')
|
||||
self.assertEqual(book2.lines[0].reference.rec_name, '05/01/2022|to|-1.00 usd|Transfer Out [Book 2 | 1.00 usd | Open]')
|
||||
self.assertEqual(len(book2.lines[0].references), 0)
|
||||
|
||||
@with_transaction()
|
||||
def test_line_check_bookingtype_mvin(self):
|
||||
""" create cashbook + line, bookingtype 'mvin'
|
||||
"""
|
||||
pool = Pool()
|
||||
Book = pool.get('cashbook.book')
|
||||
Line = pool.get('cashbook.line')
|
||||
Category = pool.get('cashbook.category')
|
||||
|
||||
types = self.prep_type()
|
||||
category_in = self.prep_category(cattype='in')
|
||||
category_out = self.prep_category(name='Out Category', cattype='out')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
|
||||
book2, = Book.create([{
|
||||
'name': 'Book 2',
|
||||
'btype': types.id,
|
||||
'company': company.id,
|
||||
'currency': company.currency.id,
|
||||
}])
|
||||
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
'btype': types.id,
|
||||
'company': company.id,
|
||||
'currency': company.currency.id,
|
||||
'lines': [('create', [{
|
||||
'date': date(2022, 5, 1),
|
||||
'description': 'Transfer In',
|
||||
'category': category_in.id,
|
||||
'bookingtype': 'mvin',
|
||||
'amount': Decimal('1.0'),
|
||||
'booktransf': book2.id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.rec_name, 'Book 1 | 1.00 usd | Open')
|
||||
self.assertEqual(len(book.lines), 1)
|
||||
self.assertEqual(len(book2.lines), 0)
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|from|1.00 usd|Transfer In [Book 2 | 0.00 usd | Open]')
|
||||
self.assertEqual(len(book.lines[0].references), 0)
|
||||
|
||||
# set line to 'checked', this creates the counterpart
|
||||
Line.wfcheck(list(book.lines))
|
||||
|
||||
self.assertEqual(len(book.lines), 1)
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|from|1.00 usd|Transfer In [Book 2 | -1.00 usd | Open]')
|
||||
self.assertEqual(book.lines[0].state, 'check')
|
||||
self.assertEqual(len(book.lines[0].references), 1)
|
||||
self.assertEqual(book.lines[0].reference, None)
|
||||
self.assertEqual(book.lines[0].references[0].id, book2.lines[0].id)
|
||||
|
||||
self.assertEqual(len(book2.lines), 1)
|
||||
self.assertEqual(book2.lines[0].rec_name, '05/01/2022|to|-1.00 usd|Transfer In [Book 1 | 1.00 usd | Open]')
|
||||
self.assertEqual(book2.lines[0].state, 'check')
|
||||
self.assertEqual(book2.lines[0].reference.rec_name, '05/01/2022|from|1.00 usd|Transfer In [Book 2 | -1.00 usd | Open]')
|
||||
self.assertEqual(len(book2.lines[0].references), 0)
|
||||
|
||||
# tryt wfedit to 'book2.lines[0]'
|
||||
self.assertRaisesRegex(UserError,
|
||||
"The current line is managed by the cashbook line '05/01/2022|from|1.00 usd|Transfer In [Book 2 | -1.00 usd | Open]', cashbook: 'Book 1 | 1.00 usd | Open'.",
|
||||
Line.wfedit,
|
||||
[book2.lines[0]])
|
||||
|
||||
Line.wfedit([book.lines[0]])
|
||||
self.assertEqual(len(book2.lines), 0)
|
||||
|
||||
@with_transaction()
|
||||
def test_line_create_check_debit_credit(self):
|
||||
""" create cashbook + line, check calculation of debit/credit
|
||||
|
@ -235,6 +373,14 @@ class LineTestCase(ModuleTestCase):
|
|||
category_in = self.prep_category(cattype='in')
|
||||
category_out = self.prep_category(name='Out Category', cattype='out')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
|
||||
book2, = Book.create([{
|
||||
'name': 'Book 2',
|
||||
'btype': types.id,
|
||||
'company': company.id,
|
||||
'currency': company.currency.id,
|
||||
}])
|
||||
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
|
@ -247,24 +393,28 @@ class LineTestCase(ModuleTestCase):
|
|||
'category': category_in.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}, {
|
||||
'date': date(2022, 6, 1),
|
||||
'description': 'Expense',
|
||||
'category': category_out.id,
|
||||
'bookingtype': 'out',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}, {
|
||||
'date': date(2022, 6, 1),
|
||||
'description': 'Transfer from',
|
||||
'category': category_in.id,
|
||||
'bookingtype': 'mvin',
|
||||
'amount': Decimal('1.0'),
|
||||
'booktransf': book2.id,
|
||||
}, {
|
||||
'date': date(2022, 6, 1),
|
||||
'description': 'Transfer to',
|
||||
'category': category_out.id,
|
||||
'bookingtype': 'mvout',
|
||||
'amount': Decimal('1.0'),
|
||||
'booktransf': book2.id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Book 1')
|
||||
|
@ -276,6 +426,11 @@ class LineTestCase(ModuleTestCase):
|
|||
self.assertEqual(book.lines[0].credit, Decimal('1.0'))
|
||||
self.assertEqual(book.lines[0].debit, Decimal('0.0'))
|
||||
|
||||
# check payee
|
||||
self.assertEqual(book.lines[0].payee.rec_name, 'Party')
|
||||
self.assertEqual(Line.search_count([('payee', 'ilike', 'party%')]), 2)
|
||||
self.assertEqual(Line.search_count([('payee', 'ilike', 'book%')]), 2)
|
||||
|
||||
self.assertEqual(book.lines[1].amount, Decimal('1.0'))
|
||||
self.assertEqual(book.lines[1].bookingtype, 'out')
|
||||
self.assertEqual(book.lines[1].credit, Decimal('0.0'))
|
||||
|
@ -318,6 +473,7 @@ class LineTestCase(ModuleTestCase):
|
|||
'category': category_in.id,
|
||||
'bookingtype': 'mvin',
|
||||
'amount': Decimal('3.0'),
|
||||
'booktransf': book2.id,
|
||||
}])
|
||||
self.assertEqual(book.lines[0].amount, Decimal('3.0'))
|
||||
self.assertEqual(book.lines[0].bookingtype, 'mvin')
|
||||
|
@ -337,6 +493,7 @@ class LineTestCase(ModuleTestCase):
|
|||
types = self.prep_type()
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
|
||||
with Transaction().set_context({
|
||||
'company': company.id,
|
||||
|
@ -370,12 +527,14 @@ class LineTestCase(ModuleTestCase):
|
|||
'category': category2.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}, {
|
||||
'date': date(2022, 6, 1),
|
||||
'description': 'Text 2',
|
||||
'category': category2.childs[0].id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Book 1')
|
||||
|
@ -407,6 +566,7 @@ class LineTestCase(ModuleTestCase):
|
|||
types = self.prep_type()
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
'btype': types.id,
|
||||
|
@ -418,12 +578,14 @@ class LineTestCase(ModuleTestCase):
|
|||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}, {
|
||||
'date': date(2022, 5, 2),
|
||||
'description': 'Text 2',
|
||||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Book 1')
|
||||
|
@ -443,6 +605,7 @@ class LineTestCase(ModuleTestCase):
|
|||
types = self.prep_type()
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
'btype': types.id,
|
||||
|
@ -454,12 +617,14 @@ class LineTestCase(ModuleTestCase):
|
|||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}, {
|
||||
'date': date(2022, 5, 2),
|
||||
'description': 'Text 2',
|
||||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Book 1')
|
||||
|
@ -484,6 +649,7 @@ class LineTestCase(ModuleTestCase):
|
|||
types = self.prep_type()
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
'btype': types.id,
|
||||
|
@ -495,12 +661,14 @@ class LineTestCase(ModuleTestCase):
|
|||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}, {
|
||||
'date': date(2022, 5, 2),
|
||||
'description': 'Text 2',
|
||||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Book 1')
|
||||
|
@ -529,6 +697,7 @@ class LineTestCase(ModuleTestCase):
|
|||
types = self.prep_type()
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
grp_cashbook, = ResGroup.search([('name', '=', 'Cashbook')])
|
||||
usr_lst = ResUser.create([{
|
||||
'login': 'frida',
|
||||
|
@ -559,6 +728,7 @@ class LineTestCase(ModuleTestCase):
|
|||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.rec_name, 'Fridas book | 1.00 usd | Open'),
|
||||
|
@ -577,14 +747,15 @@ class LineTestCase(ModuleTestCase):
|
|||
lines = Line.search([])
|
||||
self.assertEqual(len(lines), 1)
|
||||
self.assertEqual(lines[0].cashbook.rec_name, 'Fridas book | 1.00 usd | Open')
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|1.00 usd|Test 1 [Cat1]')
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Test 1 [Cat1]')
|
||||
|
||||
Line.write(*[
|
||||
lines,
|
||||
{
|
||||
'description': 'Test 2',
|
||||
}])
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|1.00 usd|Test 2 [Cat1]')
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Test 2 [Cat1]')
|
||||
self.assertEqual(lines[0].owner_cashbook.rec_name, 'Frida')
|
||||
|
||||
@with_transaction()
|
||||
def test_line_permission_reviewer(self):
|
||||
|
@ -599,6 +770,7 @@ class LineTestCase(ModuleTestCase):
|
|||
types = self.prep_type()
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
grp_cashbook, = ResGroup.search([('name', '=', 'Cashbook')])
|
||||
grp_reviewer, = ResGroup.create([{
|
||||
'name': 'Cashbook Reviewer',
|
||||
|
@ -636,6 +808,7 @@ class LineTestCase(ModuleTestCase):
|
|||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.rec_name, 'Fridas book | 1.00 usd | Open'),
|
||||
|
@ -650,25 +823,25 @@ class LineTestCase(ModuleTestCase):
|
|||
self.assertEqual(len(lines), 1)
|
||||
self.assertEqual(len(lines[0].cashbook.reviewer.users), 1)
|
||||
self.assertEqual(lines[0].cashbook.reviewer.users[0].rec_name, 'Diego')
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|1.00 usd|Test 1 [Cat1]')
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Test 1 [Cat1]')
|
||||
Line.write(*[
|
||||
lines,
|
||||
{
|
||||
'description': 'Test 2',
|
||||
}])
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|1.00 usd|Test 2 [Cat1]')
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Test 2 [Cat1]')
|
||||
|
||||
# change to user 'frida' read/write line
|
||||
with Transaction().set_user(usr_lst[0].id):
|
||||
lines = Line.search([])
|
||||
self.assertEqual(len(lines), 1)
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|1.00 usd|Test 2 [Cat1]')
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Test 2 [Cat1]')
|
||||
Line.write(*[
|
||||
lines,
|
||||
{
|
||||
'description': 'Test 3',
|
||||
}])
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|1.00 usd|Test 3 [Cat1]')
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Test 3 [Cat1]')
|
||||
|
||||
@with_transaction()
|
||||
def test_line_permission_observer(self):
|
||||
|
@ -683,6 +856,7 @@ class LineTestCase(ModuleTestCase):
|
|||
types = self.prep_type()
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
grp_cashbook, = ResGroup.search([('name', '=', 'Cashbook')])
|
||||
grp_observer, = ResGroup.create([{
|
||||
'name': 'Cashbook Observer',
|
||||
|
@ -720,6 +894,7 @@ class LineTestCase(ModuleTestCase):
|
|||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.rec_name, 'Fridas book | 1.00 usd | Open'),
|
||||
|
@ -734,7 +909,7 @@ class LineTestCase(ModuleTestCase):
|
|||
self.assertEqual(len(lines), 1)
|
||||
self.assertEqual(len(lines[0].cashbook.observer.users), 1)
|
||||
self.assertEqual(lines[0].cashbook.observer.users[0].rec_name, 'Diego')
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|1.00 usd|Test 1 [Cat1]')
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Test 1 [Cat1]')
|
||||
|
||||
self.assertRaisesRegex(UserError,
|
||||
'You are not allowed to write to records "[0-9]{1,}" of "Cashbook Line" because of at least one of these rules:\nOwners and reviewers: Cashbook line write - ',
|
||||
|
@ -750,12 +925,12 @@ class LineTestCase(ModuleTestCase):
|
|||
with Transaction().set_user(usr_lst[0].id):
|
||||
lines = Line.search([])
|
||||
self.assertEqual(len(lines), 1)
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|1.00 usd|Test 1 [Cat1]')
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Test 1 [Cat1]')
|
||||
Line.write(*[
|
||||
lines,
|
||||
{
|
||||
'description': 'Test 2',
|
||||
}])
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|1.00 usd|Test 2 [Cat1]')
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Test 2 [Cat1]')
|
||||
|
||||
# end LineTestCase
|
||||
|
|
|
@ -202,6 +202,7 @@ class ReconTestCase(ModuleTestCase):
|
|||
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,
|
||||
|
@ -219,12 +220,14 @@ class ReconTestCase(ModuleTestCase):
|
|||
'category': category.id,
|
||||
'description': 'Line 1',
|
||||
'amount': Decimal('5.0'),
|
||||
'party': party.id,
|
||||
}, {
|
||||
'date': date(2022, 5, 5),
|
||||
'bookingtype': 'in',
|
||||
'category': category.id,
|
||||
'description': 'Line 2',
|
||||
'amount': Decimal('7.0'),
|
||||
'party': party.id,
|
||||
'amount': Decimal('7.0'),
|
||||
},])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Book 1')
|
||||
|
@ -344,6 +347,7 @@ class ReconTestCase(ModuleTestCase):
|
|||
types = self.prep_type()
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
'btype': types.id,
|
||||
|
@ -355,12 +359,14 @@ class ReconTestCase(ModuleTestCase):
|
|||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}, {
|
||||
'date': date(2022, 5, 5),
|
||||
'description': 'Text 2',
|
||||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}])],
|
||||
'reconciliations': [('create', [{
|
||||
'date': date(2022, 5, 28),
|
||||
|
@ -371,14 +377,14 @@ class ReconTestCase(ModuleTestCase):
|
|||
self.assertEqual(book.name, 'Book 1')
|
||||
self.assertEqual(book.state, 'open')
|
||||
self.assertEqual(len(book.lines), 2)
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '05/05/2022|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '05/05/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(len(book.reconciliations), 1)
|
||||
self.assertEqual(book.reconciliations[0].rec_name, '05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(len(book.reconciliations[0].lines), 0)
|
||||
|
||||
self.assertRaisesRegex(UserError,
|
||||
"For reconciliation, the line '05/01/2022|1.00 usd|Text 1 [Cat1]' must be in the status 'Check' or 'Done'.",
|
||||
"For reconciliation, the line '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]' must be in the status 'Check' or 'Done'.",
|
||||
Lines.write,
|
||||
*[
|
||||
[book.lines[0]],
|
||||
|
@ -420,9 +426,9 @@ class ReconTestCase(ModuleTestCase):
|
|||
Reconciliation.wfcheck(list(book.reconciliations))
|
||||
self.assertEqual(book.reconciliations[0].state, 'check')
|
||||
self.assertEqual(len(book.reconciliations[0].lines), 1)
|
||||
self.assertEqual(book.reconciliations[0].lines[0].rec_name, '05/01/2022|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '06/01/2022|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.reconciliations[0].lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '06/01/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
|
||||
# move 2nd line into date-range of checked-reconciliation, wf-check
|
||||
Lines.write(*[
|
||||
|
@ -481,6 +487,7 @@ class ReconTestCase(ModuleTestCase):
|
|||
types = self.prep_type()
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
'btype': types.id,
|
||||
|
@ -492,12 +499,14 @@ class ReconTestCase(ModuleTestCase):
|
|||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}, {
|
||||
'date': date(2022, 6, 5),
|
||||
'description': 'Text 2',
|
||||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}])],
|
||||
'reconciliations': [('create', [{
|
||||
'date': date(2022, 5, 28),
|
||||
|
@ -508,13 +517,13 @@ class ReconTestCase(ModuleTestCase):
|
|||
self.assertEqual(book.name, 'Book 1')
|
||||
self.assertEqual(book.state, 'open')
|
||||
self.assertEqual(len(book.lines), 2)
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '06/05/2022|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '06/05/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
|
||||
Lines.wfcheck([book.lines[0]])
|
||||
Reconciliation.wfcheck([book.reconciliations[0]])
|
||||
self.assertEqual(len(book.reconciliations[0].lines), 1)
|
||||
self.assertEqual(book.reconciliations[0].lines[0].rec_name, '05/01/2022|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.reconciliations[0].lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
|
||||
Lines.write(*[
|
||||
[book.lines[1]],
|
||||
|
@ -539,6 +548,7 @@ class ReconTestCase(ModuleTestCase):
|
|||
types = self.prep_type()
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
'btype': types.id,
|
||||
|
@ -550,6 +560,7 @@ class ReconTestCase(ModuleTestCase):
|
|||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}])],
|
||||
'reconciliations': [('create', [{
|
||||
'date': date(2022, 5, 28),
|
||||
|
@ -599,6 +610,7 @@ class ReconTestCase(ModuleTestCase):
|
|||
types = self.prep_type()
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
'btype': types.id,
|
||||
|
@ -610,12 +622,14 @@ class ReconTestCase(ModuleTestCase):
|
|||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}, {
|
||||
'date': date(2022, 5, 5),
|
||||
'description': 'Text 2',
|
||||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}])],
|
||||
'reconciliations': [('create', [{
|
||||
'date': date(2022, 5, 28),
|
||||
|
@ -626,8 +640,8 @@ class ReconTestCase(ModuleTestCase):
|
|||
self.assertEqual(book.name, 'Book 1')
|
||||
self.assertEqual(book.state, 'open')
|
||||
self.assertEqual(len(book.lines), 2)
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '05/05/2022|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '05/05/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[0].reconciliation, None)
|
||||
self.assertEqual(book.lines[1].reconciliation, None)
|
||||
self.assertEqual(len(book.reconciliations), 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue