line/splitline: fremdwährung ok+test+migration
This commit is contained in:
parent
0f6180ebdb
commit
25dcdde09b
10 changed files with 485 additions and 217 deletions
|
@ -156,6 +156,71 @@ class LineTestCase(ModuleTestCase):
|
|||
self.assertEqual(books[0].lines[0].amount_2nd_currency, Decimal('10.5'))
|
||||
self.assertEqual(books[0].lines[0].amount, Decimal('12.0'))
|
||||
|
||||
@with_transaction()
|
||||
def test_line_check_migrate_amount_2nd_currency(self):
|
||||
""" create cashbook, lines, transfer
|
||||
check migration
|
||||
"""
|
||||
pool = Pool()
|
||||
Book = pool.get('cashbook.book')
|
||||
Lines = pool.get('cashbook.line')
|
||||
tab_line = Lines.__table__()
|
||||
cursor = Transaction().connection.cursor()
|
||||
|
||||
types = self.prep_type()
|
||||
company = self.prep_company()
|
||||
|
||||
# add EURO, set company-currency to EURO
|
||||
(usd, euro) = self.prep_2nd_currency(company)
|
||||
|
||||
books = Book.create([{
|
||||
'name': 'Book USD',
|
||||
'btype': types.id,
|
||||
'company': company.id,
|
||||
'currency': usd.id,
|
||||
'number_sequ': self.prep_sequence().id,
|
||||
'start_date': date(2022, 5, 1),
|
||||
}, {
|
||||
'name': 'Book EURO',
|
||||
'btype': types.id,
|
||||
'company': company.id,
|
||||
'currency': euro.id,
|
||||
'number_sequ': self.prep_sequence().id,
|
||||
'start_date': date(2022, 5, 1),
|
||||
}])
|
||||
self.assertEqual(len(books), 2)
|
||||
self.assertEqual(books[0].rec_name, 'Book USD | 0.00 usd | Open')
|
||||
self.assertEqual(books[1].rec_name, 'Book EURO | 0.00 € | Open')
|
||||
|
||||
Book.write(*[
|
||||
[books[0]],
|
||||
{
|
||||
'lines': [('create', [{
|
||||
'date': date(2022, 5, 5),
|
||||
'description': 'Transfer USD --> EUR',
|
||||
'bookingtype': 'mvout',
|
||||
'amount': Decimal('10.0'),
|
||||
'booktransf': books[1].id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(len(books[0].lines), 1)
|
||||
self.assertEqual(len(books[1].lines), 0)
|
||||
self.assertEqual(books[0].lines[0].rec_name,
|
||||
'05/05/2022|to|-10.00 usd|Transfer USD --> EUR [Book EURO | 0.00 € | Open]')
|
||||
self.assertEqual(books[0].lines[0].amount_2nd_currency, Decimal('9.52'))
|
||||
|
||||
# clear field 'amount_2nd_currency' to prepare for migration
|
||||
clear_field = tab_line.update(
|
||||
columns = [tab_line.amount_2nd_currency],
|
||||
values = [None],
|
||||
where = (tab_line.id == books[0].lines[0].id),
|
||||
)
|
||||
cursor.execute(*clear_field)
|
||||
|
||||
# migrate
|
||||
Lines.migrate_amount_2nd_currency()
|
||||
self.assertEqual(books[0].lines[0].amount_2nd_currency, Decimal('9.52'))
|
||||
|
||||
@with_transaction()
|
||||
def test_line_check_transfer_2nd_currency_out(self):
|
||||
""" create cashbook, lines, transfer amount between
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue