mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
Add test: check if rounding rules are well skipped on multi-currency lines
This commit is contained in:
committed by
Cyril Gaudin
parent
585416d7f8
commit
fd2430747e
@@ -19,4 +19,4 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from . import test_rule
|
||||
from . import test_rule_rounding
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
##############################################################################
|
||||
|
||||
|
||||
def prepare_statement(test, difference):
|
||||
def prepare_statement(test, difference,
|
||||
statement_line_currency=None,
|
||||
move_line_currency=None):
|
||||
""" Prepare a bank statement line and a move line
|
||||
|
||||
The difference is applied on the bank statement line relatively to
|
||||
@@ -35,24 +37,33 @@ def prepare_statement(test, difference):
|
||||
'name': '/',
|
||||
'journal_id': test.ref('account.cash_journal')
|
||||
})
|
||||
statement_line = statement_line_obj.create({
|
||||
line_vals = {
|
||||
'name': '001',
|
||||
'amount': amount + difference,
|
||||
'statement_id': statement.id,
|
||||
})
|
||||
}
|
||||
if statement_line_currency:
|
||||
line_vals['currency_id'] = statement_line_currency.id
|
||||
statement_line = statement_line_obj.create(line_vals)
|
||||
move = move_obj.create({
|
||||
'journal_id': test.ref('account.sales_journal')
|
||||
})
|
||||
move_line = move_line_obj.create({
|
||||
line_vals = {
|
||||
'move_id': move.id,
|
||||
'name': '001',
|
||||
'account_id': test.ref('account.a_recv'),
|
||||
'debit': amount,
|
||||
})
|
||||
move_line_obj.create({
|
||||
}
|
||||
if move_line_currency:
|
||||
line_vals['currency_id'] = move_line_currency.id
|
||||
move_line = move_line_obj.create(line_vals)
|
||||
line_vals = {
|
||||
'move_id': move.id,
|
||||
'name': '001',
|
||||
'account_id': test.ref('account.a_sale'),
|
||||
'credit': amount,
|
||||
})
|
||||
}
|
||||
if move_line_currency:
|
||||
line_vals['currency_id'] = move_line_currency.id
|
||||
move_line_obj.create(line_vals)
|
||||
return statement_line, move_line
|
||||
|
||||
@@ -19,15 +19,16 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import unittest2
|
||||
from openerp.tests import common
|
||||
|
||||
from .common import prepare_statement
|
||||
|
||||
|
||||
class TestRule(common.TransactionCase):
|
||||
class TestRuleRounding(common.TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestRule, self).setUp()
|
||||
super(TestRuleRounding, self).setUp()
|
||||
self.operation_obj = self.env['account.statement.operation.template']
|
||||
self.rule_obj = self.env['account.statement.operation.rule']
|
||||
self.operation_round_1 = self.operation_obj.create({
|
||||
@@ -151,3 +152,16 @@ class TestRule(common.TransactionCase):
|
||||
ops = self.rule_obj.operations_for_reconciliation(statement_line.id,
|
||||
move_line.ids)
|
||||
self.assertEquals(ops, self.operation_round_1)
|
||||
|
||||
def test_multicurrency_lines(self):
|
||||
"""No rounding rules on multi-currency lines"""
|
||||
currency = self.browse_ref('base.AED')
|
||||
statement_line, move_line = prepare_statement(
|
||||
self,
|
||||
-0.5,
|
||||
statement_line_currency=currency,
|
||||
move_line_currency=currency
|
||||
)
|
||||
ops = self.rule_obj.operations_for_reconciliation(statement_line.id,
|
||||
move_line.ids)
|
||||
self.assertFalse(ops)
|
||||
Reference in New Issue
Block a user