Move line manual

This commit is contained in:
2026-04-28 11:09:37 +02:00
parent 384c1285b1
commit 2e276e2b1f
4 changed files with 115 additions and 37 deletions

View File

@@ -12,7 +12,7 @@ from trytond.modules.account.exceptions import (
from trytond.modules.account.tax import TaxableMixin
from trytond.modules.company.tests import (
CompanyTestMixin, PartyCompanyCheckEraseMixin, create_company, set_company)
from trytond.modules.currency.tests import create_currency
from trytond.modules.currency.tests import add_currency_rate, create_currency
from trytond.pool import Pool
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
from trytond.transaction import Transaction, inactive_records
@@ -576,6 +576,54 @@ class AccountTestCase(
self.assertEqual(
cash_cur.amount_second_currency, Decimal(50))
@with_transaction()
def test_move_line_second_currency_amount_on_change(self):
'Test account move line computes amount from second currency'
pool = Pool()
Account = pool.get('account.account')
Line = pool.get('account.move.line')
company = create_company()
with set_company(company):
create_chart(company)
second_currency = create_currency('sec')
add_currency_rate(second_currency, Decimal('0.939506'))
expense, = Account.search([
('type.expense', '=', True),
])
line = Line(
account=expense,
second_currency=second_currency,
amount_second_currency=Decimal('100.00'))
line.on_change_amount_second_currency()
self.assertEqual(line.debit, Decimal('93.95'))
self.assertEqual(line.credit, Decimal(0))
self.assertEqual(line.rate, Decimal('0.939506'))
self.assertEqual(line.get_rate(), Decimal('0.939500'))
line = Line(
account=expense,
credit=Decimal('7.61'),
second_currency=second_currency,
amount_second_currency=Decimal('-108.10'))
line.on_change_amount_second_currency()
self.assertEqual(line.debit, Decimal(0))
self.assertEqual(line.credit, Decimal('101.56'))
self.assertEqual(line.rate, Decimal('0.939506'))
self.assertEqual(line.get_rate(), Decimal('0.939500'))
line.debit = line.credit = Decimal(0)
line.rate = Decimal('1.100000')
line.on_change_rate()
self.assertEqual(line.debit, Decimal(0))
self.assertEqual(line.credit, Decimal('118.91'))
self.assertEqual(line.rate, Decimal('1.100000'))
@with_transaction()
def test_account_type_amount(self):
"Test account type amount"