[FIX] account_voucher: fix amount_currency on writeoff line + fixed/improved yaml tests

bzr revid: qdp-launchpad@openerp.com-20121003155820-7ozaoklt042b7i6i
This commit is contained in:
Quentin (OpenERP) 2012-10-03 17:58:20 +02:00
parent 48a8367968
commit a3d648f319
3 changed files with 18 additions and 4 deletions

View File

@ -667,6 +667,7 @@ class account_voucher(osv.osv):
#voucher line creation
for line in account_move_lines:
if _remove_noise_in_o2m():
continue
@ -1183,6 +1184,7 @@ class account_voucher(osv.osv):
account_id = voucher_brw.partner_id.property_account_receivable.id
else:
account_id = voucher_brw.partner_id.property_account_payable.id
sign = voucher_brw.type == 'payment' and -1 or 1
move_line = {
'name': write_off_name or name,
'account_id': account_id,
@ -1191,7 +1193,7 @@ class account_voucher(osv.osv):
'date': voucher_brw.date,
'credit': diff > 0 and diff or 0.0,
'debit': diff < 0 and -diff or 0.0,
'amount_currency': company_currency <> current_currency and voucher_brw.writeoff_amount or False,
'amount_currency': company_currency <> current_currency and (sign * -1 * voucher_brw.writeoff_amount) or False,
'currency_id': company_currency <> current_currency and current_currency or False,
'analytic_account_id': voucher_brw.analytic_id and voucher_brw.analytic_id.id or False,
}

View File

@ -216,6 +216,10 @@
assert move_line.credit == 63.00, "Debtor account has wrong entry."
elif move_line.amount_currency == 10.00:
assert move_line.debit == 9.00, "Writeoff amount is wrong."
elif move_line.amount_currency == 240.00:
assert move_line.debit == 216.00, "Bank entry is wrong."
else:
assert False, "Unrecognized journal entry"
-
I check the residual amount of Invoice1, should be 20 in amount_currency
-
@ -237,7 +241,7 @@
-
On the first April, I create the second voucher of payment with values 45 USD, journal USD,
-
!record {model: account.voucher, id: account_voucher_2_case1}:
!record {model: account.voucher, id: account_voucher_2_case1, view: view_vendor_receipt_form}:
account_id: account.cash
amount: 45.0
company_id: base.main_company
@ -323,8 +327,16 @@
assert move_line.debit == 4.75, "Writeoff amount is wrong."
elif move_line.debit == 11.5 and move_line.account_id.reconcile:
assert move_line.amount_currency == 0.0 and move_line.reconcile_id.id == reconcile_a, "Exchange difference entry for the invoice of 100$ is wrong"
elif move_line.credit == 11.5:
assert move_line.amount_currency == 0.0
elif move_line.debit == 31.0 and move_line.account_id.reconcile:
assert move_line.amount_currency == 0.0 and move_line.reconcile_id.id == reconcile_b, "Exchange difference entry for the invoice of 200$ is wrong"
elif move_line.credit == 31.0:
assert move_line.amount_currency == 0.0
elif move_line.amount_currency == 45.00:
assert move_line.debit == 42.75, "Bank entry is wrong."
else:
assert False, "Unrecognized journal entry"
-
I check the residual amount of Invoice1, should be 0 in residual currency and 0 in amount_residual and paid
-

View File

@ -164,7 +164,7 @@
-
I check that my currency rate difference is correct. 0 in debit with no amount_currency
-
I check that my writeoff is correct. 11.05 credit and 13.26 amount_currency
I check that my writeoff is correct. 11.05 credit and -13.26 amount_currency
-
!python {model: account.voucher}: |
voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 4'), ('partner_id', '=', ref('base.res_partner_19'))])
@ -179,7 +179,7 @@
elif move_line.debit == 0.00 and move_line.credit == 0.00:
assert move_line.amount_currency == 0.00, "Incorrect Currency Difference."
elif move_line.credit == 10.61:
assert move_line.amount_currency == 13.26, "Writeoff amount is wrong."
assert move_line.amount_currency == -13.26, "Writeoff amount is wrong."
else:
assert False, "Wrong entry"
-