[IMP] account_voucher: changed logic when paying an invoice in a secondary currency => now we always write the amount_currency (and in the same currency)
bzr revid: qdp-launchpad@openerp.com-20111123162234-nr685qp729btv19c
This commit is contained in:
@@ -882,7 +882,7 @@ class account_voucher(osv.osv):
|
||||
|
||||
def _convert_amount(self, cr, uid, amount, voucher_id, context=None):
|
||||
#TODO: doccument me
|
||||
#TODO: rounding errors
|
||||
#TODO: check: rounding errors ?
|
||||
currency_obj = self.pool.get('res.currency')
|
||||
voucher = self.browse(cr, uid, voucher_id, context=context)
|
||||
res = amount
|
||||
@@ -944,7 +944,7 @@ class account_voucher(osv.osv):
|
||||
'account_id': line.account_id.id,
|
||||
'move_id': move_id,
|
||||
'partner_id': voucher_brw.partner_id.id,
|
||||
'currency_id': company_currency <> current_currency and current_currency or False,
|
||||
'currency_id': line.move_line_id and (company_currency <> line.move_line_id.currency_id.id and line.move_line_id.currency_id.id) or False,
|
||||
'analytic_account_id': line.account_analytic_id and line.account_analytic_id.id or False,
|
||||
'quantity': 1,
|
||||
'credit': 0.0,
|
||||
@@ -976,7 +976,18 @@ class account_voucher(osv.osv):
|
||||
raise osv.except_osv(_('No Account Base Code and Account Tax Code!'),_("You have to configure account base code and account tax code on the '%s' tax!") % (tax_data.name))
|
||||
|
||||
sign = (move_line['debit'] - move_line['credit']) < 0 and -1 or 1
|
||||
move_line['amount_currency'] = company_currency <> current_currency and sign * line.amount or False
|
||||
#TODO: comment me
|
||||
amount_currency = False
|
||||
if line.move_line_id:
|
||||
if line.move_line_id.currency_id and line.move_line_id.currency_id.id != company_currency:
|
||||
if line.move_line_id.currency_id.id == current_currency:
|
||||
amount_currency = sign * (line.amount)
|
||||
elif line.move_line_id.currency_id.id == voucher_brw.payment_rate_currency_id.id:
|
||||
amount_currency = (move_line['debit'] - move_line['credit']) * voucher_brw.payment_rate
|
||||
else:
|
||||
amount_currency = currency_obj.compute(cr, uid, company_currency, line.move_line_id.currency_id.id, move_line['debit']-move_line['credit'], context=ctx)
|
||||
|
||||
move_line['amount_currency'] = amount_currency
|
||||
voucher_line = move_line_obj.create(cr, uid, move_line)
|
||||
rec_ids = [voucher_line, line.move_line_id.id]
|
||||
|
||||
|
||||
@@ -190,18 +190,6 @@
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
|
||||
for move_line in move_line_obj.browse(cr, uid, move_lines):
|
||||
assert move_line.state == 'valid', "Voucher move is not valid"
|
||||
-
|
||||
I check that my debtor account is correct
|
||||
-
|
||||
I check that the debtor account has 2 new lines with 0 in amount_currency columns and their credit columns are 130 and 70
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 2 USD/EUR DR EUR'), ('partner_id', '=', ref('base.res_partner_seagate'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
|
||||
for move_line in move_line_obj.browse(cr, uid, move_lines):
|
||||
assert move_line.amount_currency == 0.00, "A line has the 'amount_currency' column filled"
|
||||
-
|
||||
I check the residual amount of Invoice1, should be 55.56 in residual currency and 20 in amount_residual
|
||||
-
|
||||
|
||||
@@ -152,7 +152,7 @@
|
||||
-
|
||||
I check that my debtor account is correct
|
||||
-
|
||||
I check that the debtor account has 1 new line with -186.74 as amount_currency columns and 149.39 of credit and currency is CHF.
|
||||
I check that the debtor account has 1 new line with -298.78 as amount_currency columns and 149.39 of credit and currency is CAD.
|
||||
-
|
||||
I check that my currency rate difference is correct. 0 in debit with no amount_currency
|
||||
-
|
||||
@@ -166,7 +166,7 @@
|
||||
for move_line in move_line_obj.browse(cr, uid, move_lines):
|
||||
if move_line.amount_currency == 200:
|
||||
assert move_line.debit == 160.00, "Bank account has wrong entry."
|
||||
elif move_line.amount_currency == -186.74:
|
||||
elif move_line.amount_currency == -298.78:
|
||||
assert move_line.credit == 149.39, "Debtor account has wrong entry."
|
||||
elif move_line.debit == 0.00 and move_line.credit == 0.00:
|
||||
assert move_line.amount_currency == 0.00, "Incorrect Currency Difference."
|
||||
|
||||
Reference in New Issue
Block a user