line: funktion für 'balance' + test
reconciliation: rec_name + test
This commit is contained in:
parent
f86db6dea3
commit
fd36a3f4ce
6 changed files with 206 additions and 3 deletions
|
@ -5,6 +5,7 @@ import trytond.tests.test_tryton
|
|||
import unittest
|
||||
|
||||
from trytond.modules.cashbook_investment.tests.test_book import CbInvTestCase
|
||||
from trytond.modules.cashbook_investment.tests.test_reconciliation import ReconTestCase
|
||||
|
||||
|
||||
__all__ = ['suite']
|
||||
|
@ -12,6 +13,7 @@ __all__ = ['suite']
|
|||
|
||||
class CashbookInvestmentTestCase(\
|
||||
CbInvTestCase,\
|
||||
ReconTestCase,\
|
||||
):
|
||||
'Test cashbook-investment module'
|
||||
module = 'cashbook_investment'
|
||||
|
|
152
tests/test_reconciliation.py
Normal file
152
tests/test_reconciliation.py
Normal file
|
@ -0,0 +1,152 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# This file is part of the cashbook-module from m-ds for Tryton.
|
||||
# The COPYRIGHT file at the top level of this repository contains the
|
||||
# full copyright notices and license terms.
|
||||
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
from trytond.pool import Pool
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.exceptions import UserError
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
|
||||
|
||||
class ReconTestCase(ModuleTestCase):
|
||||
'Test quantity reconciliation module'
|
||||
module = 'cashbook_investment'
|
||||
|
||||
@with_transaction()
|
||||
def test_recon_set_start_quantity_by_cashbook(self):
|
||||
""" set stat-quantity from cashbook-setting
|
||||
"""
|
||||
pool = Pool()
|
||||
Book = pool.get('cashbook.book')
|
||||
Reconciliation = pool.get('cashbook.recon')
|
||||
BType = pool.get('cashbook.type')
|
||||
|
||||
company = self.prep_company()
|
||||
type_depot = self.prep_type('Depot', 'D')
|
||||
BType.write(*[
|
||||
[type_depot],
|
||||
{
|
||||
'feature': 'asset',
|
||||
}])
|
||||
asset = self.prep_asset_item(
|
||||
company=company,
|
||||
product = self.prep_asset_product(name='Product 1'))
|
||||
self.assertEqual(asset.symbol, 'usd/u')
|
||||
|
||||
book, = Book.create([{
|
||||
'name': 'Asset-Book',
|
||||
'btype': type_depot.id,
|
||||
'company': company.id,
|
||||
'currency': company.currency.id,
|
||||
'asset': asset.id,
|
||||
'quantity_uom': asset.uom.id,
|
||||
'start_date': date(2022, 5, 1),
|
||||
'number_sequ': self.prep_sequence().id,
|
||||
'reconciliations': [('create', [{
|
||||
'date': date(2022, 5, 28),
|
||||
'date_from': date(2022, 5, 1),
|
||||
'date_to': date(2022, 5, 31),
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Asset-Book')
|
||||
self.assertEqual(book.reconciliations[0].feature, 'asset')
|
||||
self.assertEqual(book.reconciliations[0].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0] | 0.00 u - 0.00 u')
|
||||
|
||||
Reconciliation.wfcheck(list(book.reconciliations))
|
||||
self.assertEqual(book.reconciliations[0].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0] | 0.00 u - 0.00 u')
|
||||
|
||||
@with_transaction()
|
||||
def test_recon_set_start_quantity_by_predecessor(self):
|
||||
""" set stat-quantity from end_amount of predecessor
|
||||
"""
|
||||
pool = Pool()
|
||||
Book = pool.get('cashbook.book')
|
||||
Lines = pool.get('cashbook.line')
|
||||
Reconciliation = pool.get('cashbook.recon')
|
||||
BType = pool.get('cashbook.type')
|
||||
|
||||
company = self.prep_company()
|
||||
type_depot = self.prep_type('Depot', 'D')
|
||||
BType.write(*[
|
||||
[type_depot],
|
||||
{
|
||||
'feature': 'asset',
|
||||
}])
|
||||
asset = self.prep_asset_item(
|
||||
company=company,
|
||||
product = self.prep_asset_product(name='Product 1'))
|
||||
self.assertEqual(asset.symbol, 'usd/u')
|
||||
|
||||
category = self.prep_category(cattype='in')
|
||||
party = self.prep_party()
|
||||
book, = Book.create([{
|
||||
'name': 'Asset-Book',
|
||||
'btype': type_depot.id,
|
||||
'company': company.id,
|
||||
'currency': company.currency.id,
|
||||
'asset': asset.id,
|
||||
'quantity_uom': asset.uom.id,
|
||||
'start_date': date(2022, 5, 1),
|
||||
'number_sequ': self.prep_sequence().id,
|
||||
'reconciliations': [('create', [{
|
||||
'date': date(2022, 5, 28),
|
||||
'date_from': date(2022, 5, 1),
|
||||
'date_to': date(2022, 5, 31),
|
||||
}])],
|
||||
'lines': [('create', [{
|
||||
'date': date(2022, 5, 5),
|
||||
'bookingtype': 'in',
|
||||
'category': category.id,
|
||||
'description': 'Line 1',
|
||||
'amount': Decimal('5.0'),
|
||||
'quantity': Decimal('1.5'),
|
||||
'party': party.id,
|
||||
}, {
|
||||
'date': date(2022, 5, 6),
|
||||
'bookingtype': 'in',
|
||||
'category': category.id,
|
||||
'description': 'Line 2',
|
||||
'party': party.id,
|
||||
'amount': Decimal('7.0'),
|
||||
'quantity': Decimal('2.5'),
|
||||
},])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Asset-Book')
|
||||
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] | 0.00 u - 0.00 u')
|
||||
self.assertEqual(len(book.reconciliations[0].lines), 0)
|
||||
|
||||
Lines.wfcheck(list(book.lines))
|
||||
|
||||
self.assertEqual(book.lines[0].quantity_balance, Decimal('1.5'))
|
||||
self.assertEqual(book.lines[1].quantity_balance, Decimal('4.0'))
|
||||
|
||||
Reconciliation.wfcheck(list(book.reconciliations))
|
||||
|
||||
self.assertEqual(book.lines[0].quantity_balance, Decimal('1.5'))
|
||||
self.assertEqual(book.lines[1].quantity_balance, Decimal('4.0'))
|
||||
|
||||
self.assertEqual(book.reconciliations[0].state, 'check')
|
||||
self.assertEqual(book.reconciliations[0].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 12.00 usd [2] | 0.00 u - 4.00 u')
|
||||
Reconciliation.wfdone(list(book.reconciliations))
|
||||
self.assertEqual(book.reconciliations[0].state, 'done')
|
||||
|
||||
recons = Reconciliation.create([{
|
||||
'cashbook': book.id,
|
||||
'date_from': date(2022, 5, 31),
|
||||
'date_to': date(2022, 6, 30),
|
||||
}])
|
||||
self.assertEqual(recons[0].rec_name,
|
||||
'05/31/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0] | 0.00 u - 0.00 u')
|
||||
Reconciliation.wfcheck(recons)
|
||||
self.assertEqual(recons[0].rec_name,
|
||||
'05/31/2022 - 06/30/2022 | 12.00 usd - 12.00 usd [0] | 4.00 u - 4.00 u')
|
||||
|
||||
# end ReconTestCase
|
Loading…
Add table
Add a link
Reference in a new issue