first commit
This commit is contained in:
2
modules/account_deposit/tests/__init__.py
Normal file
2
modules/account_deposit/tests/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
modules/account_deposit/tests/__pycache__/tools.cpython-311.pyc
Normal file
BIN
modules/account_deposit/tests/__pycache__/tools.cpython-311.pyc
Normal file
Binary file not shown.
101
modules/account_deposit/tests/scenario_deposit.rst
Normal file
101
modules/account_deposit/tests/scenario_deposit.rst
Normal file
@@ -0,0 +1,101 @@
|
||||
================
|
||||
Deposit Scenario
|
||||
================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.account.tests.tools import (
|
||||
... create_chart, create_fiscalyear, get_accounts)
|
||||
>>> from trytond.modules.account_deposit.tests.tools import add_deposit_accounts
|
||||
>>> from trytond.modules.account_invoice.tests.tools import (
|
||||
... create_payment_term, set_fiscalyear_invoice_sequences)
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('account_deposit', create_company, create_chart)
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = set_fiscalyear_invoice_sequences(
|
||||
... create_fiscalyear())
|
||||
>>> fiscalyear.click('create_period')
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = add_deposit_accounts(get_accounts())
|
||||
|
||||
Create party::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> party = Party(name='Party')
|
||||
>>> party.save()
|
||||
|
||||
Create payment_term::
|
||||
|
||||
>>> payment_term = create_payment_term()
|
||||
>>> payment_term.save()
|
||||
|
||||
Create deposit invoice::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice(party=party, payment_term=payment_term)
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.account = accounts['deposit']
|
||||
>>> line.description = 'Deposit'
|
||||
>>> line.quantity = 1
|
||||
>>> line.unit_price = Decimal(100)
|
||||
>>> invoice.click('post')
|
||||
>>> invoice.untaxed_amount
|
||||
Decimal('100.00')
|
||||
|
||||
Check party deposit::
|
||||
|
||||
>>> party.reload()
|
||||
>>> party.deposit
|
||||
Decimal('100.00')
|
||||
|
||||
Create final invoice::
|
||||
|
||||
>>> invoice = Invoice(party=party, payment_term=payment_term)
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.account = accounts['revenue']
|
||||
>>> line.description = 'Revenue'
|
||||
>>> line.quantity = 1
|
||||
>>> line.unit_price = Decimal(500)
|
||||
>>> invoice.save()
|
||||
>>> invoice.untaxed_amount
|
||||
Decimal('500.00')
|
||||
|
||||
Recall deposit::
|
||||
|
||||
>>> recall_deposit = invoice.click('recall_deposit')
|
||||
>>> recall_deposit.form.account = accounts['deposit']
|
||||
>>> recall_deposit.form.description = 'Recall Deposit'
|
||||
>>> recall_deposit.execute('recall')
|
||||
>>> invoice.reload()
|
||||
>>> deposit_line, = [l for l in invoice.lines
|
||||
... if l.account == accounts['deposit']]
|
||||
>>> deposit_line.amount
|
||||
Decimal('-100.00')
|
||||
>>> invoice.untaxed_amount
|
||||
Decimal('400.00')
|
||||
|
||||
Recall too much::
|
||||
|
||||
>>> deposit_line.unit_price = Decimal('-200.00')
|
||||
>>> deposit_line.save()
|
||||
>>> invoice.click('post')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
DepositError: ...
|
||||
|
||||
Recall available::
|
||||
|
||||
>>> deposit_line.unit_price = Decimal('-100.00')
|
||||
>>> deposit_line.save()
|
||||
>>> invoice.click('post')
|
||||
@@ -0,0 +1,115 @@
|
||||
=====================================
|
||||
Deposit with Second Currency Scenario
|
||||
=====================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime as dt
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.account.tests.tools import (
|
||||
... create_chart, create_fiscalyear, get_accounts)
|
||||
>>> from trytond.modules.account_deposit.tests.tools import add_deposit_accounts
|
||||
>>> from trytond.modules.account_invoice.tests.tools import (
|
||||
... set_fiscalyear_invoice_sequences)
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.modules.currency.tests.tools import get_currency
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
|
||||
>>> today = dt.date.today()
|
||||
>>> yesterday = today - dt.timedelta(days=1)
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('account_deposit', create_company, create_chart)
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
|
||||
Get currencies::
|
||||
|
||||
>>> currency = get_currency('USD')
|
||||
>>> eur = get_currency('EUR')
|
||||
|
||||
Set alternate currency rates::
|
||||
|
||||
>>> rate = eur.rates.new()
|
||||
>>> rate.date = yesterday
|
||||
>>> rate.rate = Decimal('1.20')
|
||||
>>> rate = eur.rates.new()
|
||||
>>> rate.date = today
|
||||
>>> rate.rate = Decimal('1.10')
|
||||
>>> eur.save()
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = set_fiscalyear_invoice_sequences(create_fiscalyear())
|
||||
>>> fiscalyear.click('create_period')
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = add_deposit_accounts(get_accounts())
|
||||
>>> accounts['deposit'].second_currency = eur
|
||||
>>> accounts['deposit'].save()
|
||||
|
||||
Create party::
|
||||
|
||||
>>> party = Party(name='Party')
|
||||
>>> party.save()
|
||||
|
||||
Create deposit invoice::
|
||||
|
||||
>>> invoice = Invoice(party=party, currency=eur, invoice_date=yesterday)
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.account = accounts['deposit']
|
||||
>>> line.description = "Deposit"
|
||||
>>> line.quantity = 1
|
||||
>>> line.unit_price = Decimal(100)
|
||||
>>> invoice.click('post')
|
||||
>>> invoice.untaxed_amount
|
||||
Decimal('100.00')
|
||||
|
||||
Check party deposit::
|
||||
|
||||
>>> party.reload()
|
||||
>>> party.deposit
|
||||
Decimal('83.33')
|
||||
|
||||
Create final invoice::
|
||||
|
||||
>>> invoice = Invoice(party=party, currency=eur, invoice_date=today)
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.account = accounts['revenue']
|
||||
>>> line.description = "Revenue"
|
||||
>>> line.quantity = 1
|
||||
>>> line.unit_price = Decimal(500)
|
||||
>>> invoice.save()
|
||||
>>> invoice.untaxed_amount
|
||||
Decimal('500.00')
|
||||
|
||||
Recall deposit::
|
||||
|
||||
>>> recall_deposit = invoice.click('recall_deposit')
|
||||
>>> recall_deposit.form.account = accounts['deposit']
|
||||
>>> recall_deposit.form.description = "Recall Deposit"
|
||||
>>> recall_deposit.execute('recall')
|
||||
>>> invoice.reload()
|
||||
>>> deposit_line, = [l for l in invoice.lines
|
||||
... if l.account == accounts['deposit']]
|
||||
>>> deposit_line.amount
|
||||
Decimal('-100.00')
|
||||
>>> invoice.untaxed_amount
|
||||
Decimal('400.00')
|
||||
>>> invoice.click('post')
|
||||
|
||||
Check party deposit::
|
||||
|
||||
>>> party.reload()
|
||||
>>> party.deposit
|
||||
Decimal('-7.58')
|
||||
>>> accounts['deposit'].reload()
|
||||
>>> accounts['deposit'].balance
|
||||
Decimal('7.58')
|
||||
>>> accounts['deposit'].amount_second_currency
|
||||
Decimal('0.00')
|
||||
16
modules/account_deposit/tests/test_module.py
Normal file
16
modules/account_deposit/tests/test_module.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.modules.company.tests import (
|
||||
CompanyTestMixin, PartyCompanyCheckEraseMixin)
|
||||
from trytond.tests.test_tryton import ModuleTestCase
|
||||
|
||||
|
||||
class AccountDepositTestCase(
|
||||
PartyCompanyCheckEraseMixin, CompanyTestMixin, ModuleTestCase):
|
||||
'Test Account Deposit module'
|
||||
module = 'account_deposit'
|
||||
extras = ['account_payment_clearing']
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
modules/account_deposit/tests/test_scenario.py
Normal file
8
modules/account_deposit/tests/test_scenario.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# This file is part of 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 load_doc_tests
|
||||
|
||||
|
||||
def load_tests(*args, **kwargs):
|
||||
return load_doc_tests(__name__, __file__, *args, **kwargs)
|
||||
19
modules/account_deposit/tests/tools.py
Normal file
19
modules/account_deposit/tests/tools.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from proteus import Model
|
||||
from trytond.modules.company.tests.tools import get_company
|
||||
|
||||
|
||||
def add_deposit_accounts(accounts, company=None, config=None):
|
||||
'Add deposit to accounts'
|
||||
Account = Model.get('account.account', config=config)
|
||||
|
||||
if not company:
|
||||
company = get_company(config=config)
|
||||
|
||||
accounts['deposit'], = Account.find([
|
||||
('type.deposit', '=', True),
|
||||
('company', '=', company.id),
|
||||
('name', '=', 'Deposit'),
|
||||
])
|
||||
return accounts
|
||||
Reference in New Issue
Block a user