[REF] account_voucher: yaml test case 5 refactoring

bzr revid: qdp-launchpad@openerp.com-20121031104439-yksfyq68ggw1i2fw
This commit is contained in:
Quentin (OpenERP) 2012-10-31 11:44:39 +01:00
parent c5c8d87eab
commit 483503a761
1 changed files with 20 additions and 34 deletions

View File

@ -12,14 +12,14 @@
user_type: "account.data_account_type_cash"
-
I create currency USD in OpenERP for November of 1.5 Rate
I create currency USD in OpenERP for November of 1.8 Rate
-
!record {model: res.currency.rate, id: nov_usd}:
currency_id: base.USD
name: !eval "'%s-11-01' %(datetime.now().year)"
rate: 1.8
-
I create currency USD in OpenERP for December of 1.8 Rate
I create currency USD in OpenERP for December of 1.5 Rate
-
!record {model: res.currency.rate, id: dec_usd}:
currency_id: base.USD
@ -99,7 +99,8 @@
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
assert (move_line.debit - move_line.credit == -555.56), "Invoice move is incorrect for debtors account"
assert (move_line.debit - move_line.credit == -555.56), "Invoice move is incorrect for creditor account"
assert (move_line.amount_currency == -1000), "Amount currency is incorrect for creditor account"
-
I set the context that will be used for the encoding of all the vouchers of this file
-
@ -108,7 +109,7 @@
-
I create the voucher of payment with values $950, journal USD
-
!record {model: account.voucher, id: account_voucher_1_case_basic_supplier_flows, view: view_vendor_payment_form}:
!record {model: account.voucher, id: account_voucher_case_5_supplier_flow, view: view_vendor_payment_form}:
account_id: account.cash
amount: 950.0
company_id: base.main_company
@ -128,56 +129,41 @@
import netsvc, time
vals = {}
voucher_id = self.browse(cr, uid, ref('account_voucher_1_case_basic_supplier_flows'))
data = []
for item in voucher_id.line_dr_ids:
if item.amount_unreconciled == 1000.00:
data += [(item.id, 1000)]
for line_id, amount in data:
self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount})
self.pool.get('account.voucher.line').write(cr, uid, [item.id], {'amount': 1000})
assert (voucher_id.state=='draft'), "Voucher is not in draft state"
-
I check that writeoff amount computed is -50.0
-
!python {model: account.voucher}: |
voucher = self.search(cr, uid, [('name', '=', 'Payment: Case Basic SUPPLIER USD/USD'), ('partner_id', '=', ref('base.res_partner_19'))])
voucher_id = self.browse(cr, uid, voucher[0])
assert (voucher_id.writeoff_amount == -50.0), "Writeoff amount is not -50.0"
!assert {model: account.voucher, id: account_voucher_case_5_supplier_flow}:
- writeoff_amount == -50.0
-
I confirm the voucher
-
!workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_1_case_basic_supplier_flows}
-
I check that the move of my voucher is valid
I check that the move of my voucher is valid and that it is posted
-
!python {model: account.voucher}: |
voucher = self.search(cr, uid, [('name', '=', 'Payment: Case Basic SUPPLIER USD/USD'), ('partner_id', '=', ref('base.res_partner_19'))])
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.state == 'valid', "Voucher move is not valid"
-
I check that my voucher state is posted
-
!python {model: account.voucher}: |
voucher = self.search(cr, uid, [('name', '=', 'Payment: Case Basic SUPPLIER USD/USD'), ('partner_id', '=', ref('base.res_partner_19'))])
voucher_id = self.browse(cr, uid, voucher[0])
voucher_id = self.browse(cr, uid, ref('account_voucher_case_5_supplier_flow,'))
assert voucher_id.state == 'posted', "Voucher state is not posted"
for move_line in voucher_id.move_id.line_id:
assert move_line.state == 'valid', "Voucher move is not valid"
-
I check that my creditor account is correct
-
I check that the creditor account has 1 new line with -$950 and 633.33€ as amount_currency and credit, respectively.
I check that the bank entry is -$950 and 633.33€ as amount_currency and credit, respectively.
-
I check that my currency rate difference is correct (105.56€ in debit with no amount_currency)
I check that the creditor account has 1 new line with $1000 and 666.67€ as amount_currency and debit, respectively.
-
I check that my writeoff is correct. 33.33€ in debit with $50 as amount currency
I check that my currency rate difference is correct (111.11€ in debit/credit with no amount_currency)
-
I check that my writeoff is correct. 33.34€ in credit with -$50 as amount currency
-
!python {model: account.voucher}: |
voucher = self.search(cr, uid, [('name', '=', 'Payment: Case Basic SUPPLIER USD/USD'), ('partner_id', '=', ref('base.res_partner_19'))])
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):
voucher_id = self.browse(cr, uid, ref('account_voucher_case_5_supplier_flow,'))
for move_line in voucher_id.move_id.line_id:
if move_line.amount_currency == -950.00:
assert move_line.credit == 633.33, "Wrong bank entry."
elif move_line.credit == 111.11 or move_line.debit == 111.11:
@ -187,7 +173,7 @@
elif move_line.debit == 666.67:
assert move_line.amount_currency == 1000.0, "Wrong supplier entry."
else:
assert False == True, "Wrong entry. Unrecognized account move line"
assert False, "Wrong entry. Unrecognized account move line"
-
I check the residual amount of invoice, it should be 0 in residual currency and 0 in amount_residual and paid
-