From 1a3ac2facc5fd1304adeeccae4dffa02e0f4ff23 Mon Sep 17 00:00:00 2001 From: mtr Date: Wed, 3 Aug 2011 15:36:33 +0530 Subject: [PATCH] [IMP] account_voucher: improved string/sentence and code in yml bzr revid: mtr@mtr-20110803100633-xsh3olpk5bhc00at --- addons/account_voucher/test/case1_usd_usd.yml | 57 +++++++++++-------- addons/account_voucher/test/case2_usd_eur.yml | 57 ++++++++++--------- addons/account_voucher/test/case3_eur_eur.yml | 38 +++++++------ addons/account_voucher/test/case4_cad_chf.yml | 44 ++++++++------ 4 files changed, 112 insertions(+), 84 deletions(-) diff --git a/addons/account_voucher/test/case1_usd_usd.yml b/addons/account_voucher/test/case1_usd_usd.yml index 7751849120e..a4e59ccc4b3 100755 --- a/addons/account_voucher/test/case1_usd_usd.yml +++ b/addons/account_voucher/test/case1_usd_usd.yml @@ -52,7 +52,7 @@ property_expense_currency_exchange: account.o_expense property_income_currency_exchange: account.o_income - - I'm creating new partner "Mr. strauss". + I create new partner Mark Strauss. - !record {model: res.partner, id: res_partner_strauss0}: address: @@ -97,7 +97,7 @@ 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 == 150.0), "Invoice move is correct for debtors account" + assert (move_line.debit - move_line.credit == 150.0), "Invoice move is not correct for debtors account" - I create the second invoice on 1st February for 100 USD - @@ -132,7 +132,7 @@ 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 == 80), "Invoice move is correct for debtors account" + assert (move_line.debit - move_line.credit == 80), "Invoice move is not correct for debtors account" - I create the first voucher of payment @@ -191,13 +191,15 @@ wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr) - - I check that my voucher is valid + I check that the move of my first voucher is valid - !python {model: account.voucher}: | - voucher = self.search(cr, uid, [('name', '=', 'First payment')]) + voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_strauss0'))]) voucher_id = self.browse(cr, uid, voucher[0]) - assert voucher_id.state == 'posted', "Voucher is not balanced" - + 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 debtor account is correct - @@ -215,11 +217,11 @@ for move_line in move_line_obj.browse(cr, uid, move_lines): if move_line.amount_currency == -180: assert move_line.credit == 135.00, "Debtor account has wrong entry." - if move_line.amount_currency == -70: + elif move_line.amount_currency == -70: assert move_line.credit == 56.00, "Debtor account has wrong entry." - if move_line.credit == 34.00: + elif move_line.credit == 34.00: assert move_line.amount_currency == 0, "Incorrect currency rate difference." - if move_line.amount_currency == 10: + elif move_line.amount_currency == 10: assert move_line.debit == 9.0, "Writeoff amount is wrong." - I check the residual amount of Invoice1, should be 20 in amount_currency and 15 in company currency @@ -231,7 +233,7 @@ move_line = move_line_obj.browse(cr, uid, move_lines[0]) assert (move_line.amount_residual_currency == 20.0 and move_line.amount_residual == 15.0) , "Residual amount is not correct for first Invoice" - - I check the residual amuont of Invoice2, should be 30 in residual currency and 24 in amount_residual + I check the residual amuont of Invoice2, should be 30 in residual currency and 24 in amount_residual - !python {model: account.invoice}: | invoice_id = self.browse(cr, uid, ref("account_invoice_feb")) @@ -240,7 +242,9 @@ move_line = move_line_obj.browse(cr, uid, move_lines[0]) assert (move_line.amount_residual_currency == 30.0 and move_line.amount_residual == 24.0) , "Residual amount is not correct for first Invoice" - - I create the second voucher of payment with Paid Amount as 45 USD, journal USD, and fill amounts 20 for the invoice of 200$ and 30 for the invoice of 100$ + I create the second voucher of payment + + - !python {model: account.voucher}: | import netsvc, time @@ -296,20 +300,23 @@ wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr) - - I check that my voucher state is posted + I check that the move of my second voucher is valid - !python {model: account.voucher}: | voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_strauss0'))]) voucher_id = self.browse(cr, uid, voucher[0]) - assert voucher_id.state == 'posted', "Voucher state is not posted" + 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 debtor account is correct - - I check that the debtor account has 2 new lines with -20 and -30 as amount_currency columns and their credit columns are respectively 15 and 24 and currency is USD($). + I check that the debtor account has 2 new lines with -20 and -30 as amount_currency columns and their credit columns are respectively 15 and 24. - - I check that my Currency Difference entry is created with a credit of 8.5 + I check that my currency rate difference is correct. 8.5 in credit with no amount_currency - - I check that my write-off entry is created with a debit of 4.75 and amount currency as 0.0 + I check that my writeoff is correct. 4.75 debit and 5 amount_currency - !python {model: account.voucher}: | voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_strauss0'))]) @@ -319,27 +326,27 @@ for move_line in move_line_obj.browse(cr, uid, move_lines): if move_line.amount_currency == -20: assert move_line.credit == 15, "Debtor account has wrong entry." - if move_line.amount_currency == -30: + elif move_line.amount_currency == -30: assert move_line.credit == 24, "Debtor account has wrong entry." - if move_line.credit == 8.5: + elif move_line.credit == 8.5: assert move_line.amount_currency == 0.00, "Incorrect Currency Difference." - if move_line.credit == 5: - assert move_line.credit == 4.75, "Writeoff amount is wrong." + elif move_line.amount_currency == 5: + assert move_line.debit == 4.75, "Writeoff amount is wrong." - - I check the residual amount of Invoice1, should be 0 in residual currency and 0 in amount_residual + I check the residual amount of Invoice1, should be 0 in residual currency and 0 in amount_residual and paid - !python {model: account.invoice}: | invoice_id = self.browse(cr, uid, ref("account_invoice_jan")) move_line_obj = self.pool.get('account.move.line') move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)]) move_line = move_line_obj.browse(cr, uid, move_lines[0]) - assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0) , "Residual amount is not correct for first Invoice" + assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice" - - I check the residual amuont of Invoice2, should be 0 in residual currency and 0 in amount_residual + I check the residual amuont of Invoice2, should be 0 in residual currency and 0 in amount_residual and paid - !python {model: account.invoice}: | invoice_id = self.browse(cr, uid, ref("account_invoice_feb")) move_line_obj = self.pool.get('account.move.line') move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)]) move_line = move_line_obj.browse(cr, uid, move_lines[0]) - assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0) , "Residual amount is not correct for second Invoice" \ No newline at end of file + assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice" \ No newline at end of file diff --git a/addons/account_voucher/test/case2_usd_eur.yml b/addons/account_voucher/test/case2_usd_eur.yml index 25d69a95bb1..35e0bf86231 100644 --- a/addons/account_voucher/test/case2_usd_eur.yml +++ b/addons/account_voucher/test/case2_usd_eur.yml @@ -55,7 +55,7 @@ company_id: base.main_company view_id: account.account_journal_bank_view - - I assign accounts for 'Income Curreny Rate' and 'Expense Currency Rate' + I set up some accounts for currency rate expense/income in my company - !record {model: res.company, id: base.main_company}: property_expense_currency_exchange: account.o_expense @@ -98,7 +98,7 @@ - !workflow {model: account.invoice, action: invoice_open, ref: account_first_invoice_jan} - - I check that first invoice move is correct + I check that first invoice move is correct for debtor account(debit - credit == 150) - !python {model: account.invoice}: | invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan")) @@ -143,7 +143,8 @@ move_line = move_line_obj.browse(cr, uid, move_lines[0]) assert (move_line.debit - move_line.credit == 80), "Invoice move is incorrect for debtors account" - - I create the first voucher of payment with values 240 EUR, journal EUR, and fill amount 180 for the invoice of 200$ and 70 for the 100$ invoice. + I create the first voucher of payment + - !python {model: account.voucher}: | import netsvc, time @@ -198,20 +199,23 @@ wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr) - - I check that my voucher state is posted + I check that the move of my voucher is valid - !python {model: account.voucher}: | voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_michael0'))]) voucher_id = self.browse(cr, uid, voucher[0]) - assert voucher_id.state == 'posted', "Voucher state is not posted" + 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 debtor account is correct - - I check that the debtor account has 2 new lines with -180 and -70 as amount_currency columns and their credit columns are respectively 135 and 56 and currency is USD($). + I check that the debtor account has 2 new lines with -180 and -70 in amount_currency columns and their credit columns are respectively 135 and 56 and currency is USD($). - - I check that my Currency Difference entry is created with a credit of 34, amount currency as 0.0 + I check that my currency rate difference is correct. 34 in credit with no amount_currency - - I check that my write-off entry is created with a credit of 15.00 and amount currency as 0.0 + I check that my writeoff is correct. 15 in credit with no amount_currency - !python {model: account.voucher}: | voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_michael0'))]) @@ -221,12 +225,12 @@ for move_line in move_line_obj.browse(cr, uid, move_lines): if move_line.amount_currency == -180: assert move_line.credit == 135, "Debtor account has wrong entry." - if move_line.amount_currency == -70: + elif move_line.amount_currency == -70: assert move_line.credit == 56.00, "Debtor account has wrong entry." - if move_line.credit == 34: + elif move_line.credit == 34: assert move_line.amount_currency == 0.00, "Incorrect Currency Difference." - if move_line.credit == 15.00: - assert move_line.credit == 0.00, "Writeoff amount is wrong." + elif move_line.credit == 15.00: + assert move_line.amount_currency == 0.00, "Writeoff amount is wrong." - I check the residual amount of Invoice1, should be 20 in residual currency and 15 in amount_residual - @@ -246,7 +250,8 @@ move_line = move_line_obj.browse(cr, uid, move_lines[0]) assert (move_line.amount_residual_currency == 30 and move_line.amount_residual == 24) , "Residual amount is not correct for second Invoice" - - I create the second voucher of payment with values, 45 USD, journal USD, and fill amounts 20 for the invoice of 200$ and 30 for the invoice of 100$ + I create the second voucher of payment + - !python {model: account.voucher}: | import netsvc, time @@ -291,8 +296,7 @@ !python {model: account.voucher}: | voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_michael0'))]) voucher_id = self.browse(cr, uid, voucher[0]) - curr_diff = voucher_id.currency_rate_difference - assert (voucher_id.currency_rate_difference == curr_diff), "currency rate difference is not -8.50" + assert (voucher_id.currency_rate_difference == -8.50), "currency rate difference is not -8.50" - I confirm the voucher - @@ -311,11 +315,11 @@ - I check that my debtor account is correct - - I check that the debtor account has 2 new lines with -20 and -30 as amount_currency columns and their credit columns are respectively 15 and 24 and currency is USD($). + I check that the debtor account has 2 new lines with -20 and -30 in amount_currency columns and their credit columns are respectively 15 and 24 and currency is USD($). - - I check that my Currency Difference entry is created with a credit of 8.5 + I check that my currency rate difference is correct. 8.50 in credit with no amount_currency - - I check that my write-off entry is created with a debit of 4.75 and amount currency as 0.0 + I check that my writeoff is correct. 4.75 in debit and 5 in amount_currency - !python {model: account.voucher}: | voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_michael0'))]) @@ -323,30 +327,29 @@ 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): - d if move_line.amount_currency == -20: assert move_line.credit == 15, "Debtor account has wrong entry." - if move_line.amount_currency == -30: + elif move_line.amount_currency == -30: assert move_line.credit == 24, "Debtor account has wrong entry." - if move_line.credit == 8.5: + elif move_line.credit == 8.5: assert move_line.amount_currency == 0.00, "Incorrect Currency Difference." - if move_line.credit == 5: - assert move_line.credit == 4.75, "Writeoff amount is wrong." + elif move_line.amount_currency == 5: + assert move_line.debit == 4.75, "Writeoff amount is wrong." - - I check the residual amount of invoice 1, should be 0 in residual currency and 0 in amount_residual + I check the residual amount of invoice 1, should be 0 in residual currency and 0 in amount_residual and paid - !python {model: account.invoice}: | invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan")) move_line_obj = self.pool.get('account.move.line') move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)]) move_line = move_line_obj.browse(cr, uid, move_lines[0]) - assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0) , "Residual amount is not correct for first Invoice" + assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice" - - I check the residual amuont of invoice 2, should be 0 in residual currency and 0 in amount_residual + I check the residual amuont of invoice 2, should be 0 in residual currency and 0 in amount_residual and paid - !python {model: account.invoice}: | invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb")) move_line_obj = self.pool.get('account.move.line') move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)]) move_line = move_line_obj.browse(cr, uid, move_lines[0]) - assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0) , "Residual amount is not correct for second Invoice" \ No newline at end of file + assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice" \ No newline at end of file diff --git a/addons/account_voucher/test/case3_eur_eur.yml b/addons/account_voucher/test/case3_eur_eur.yml index d1b5de784a9..5779028641e 100644 --- a/addons/account_voucher/test/case3_eur_eur.yml +++ b/addons/account_voucher/test/case3_eur_eur.yml @@ -41,7 +41,7 @@ company_id: base.main_company view_id: account.account_journal_bank_view - - I assign accounts for 'Income Curreny Rate' and 'Expense Currency Rate' + I set up some accounts for currency rate expense/income in my company - !record {model: res.company, id: base.main_company}: property_expense_currency_exchange: account.o_expense @@ -84,7 +84,7 @@ - !workflow {model: account.invoice, action: invoice_open, ref: account_first_invoice_jan_eur} - - I check that first invoice move is correct + I check that first invoice move is correct for debtor account(debit - credit == 150) - !python {model: account.invoice}: | invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_eur")) @@ -94,7 +94,7 @@ move_line = move_line_obj.browse(cr, uid, move_lines[0]) assert (move_line.debit - move_line.credit == 150.00), "Invoice move is incorrect for debtors account" - - I create the first invoice on 1st February for 80 EUR + I create the second invoice on 1st February for 80 EUR - !record {model: account.invoice, id: account_second_invoice_feb_eur}: account_id: account.a_recv @@ -119,7 +119,7 @@ - !workflow {model: account.invoice, action: invoice_open, ref: account_second_invoice_feb_eur} - - I check that second invoice move is correct + I check that second invoice move is correct for debtor account (debit - credit == 80) - !python {model: account.invoice}: | invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_eur")) @@ -129,7 +129,8 @@ move_line = move_line_obj.browse(cr, uid, move_lines[0]) assert (move_line.debit - move_line.credit == 80.00), "Invoice move is incorrect for debtors account" - - I create the first voucher of payment with values 120 EUR, journal EUR, and fill amounts 100 for the invoice of 150 and 20 for the 80 EUR invoice. + I create the first voucher of payment + - !python {model: account.voucher}: | import netsvc, time @@ -162,7 +163,7 @@ voucher_id = self.browse(cr, uid, id) assert (voucher_id.state=='draft'), "Voucher is not in draft state" - - I check that writeoff amount computed is 0 + I check that writeoff amount computed is 0.00 - !python {model: account.voucher}: | voucher = self.search(cr, uid, [('name', '=', 'First payment'),('partner_id', '=', ref('res_partner_peter0'))]) @@ -184,16 +185,19 @@ wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr) - - I check that my voucher state is posted + I check that the move of my first voucher is valid - !python {model: account.voucher}: | voucher = self.search(cr, uid, [('name', '=', 'First payment'),('partner_id', '=', ref('res_partner_peter0'))]) voucher_id = self.browse(cr, uid, voucher[0]) - assert voucher_id.state == 'posted', "Voucher state is not posted" + 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 debtor account is correct - - I check that the debtor account has 2 new lines with 0.00 and 0.00 as amount_currency columns and their credit are 20 and 100 respectively + I check that the debtor account has 2 new lines with 0.00 and 0.00 in amount_currency columns and their credit are 20 and 100 respectively - !python {model: account.voucher}: | voucher = self.search(cr, uid, [('name', '=', 'First payment'),('partner_id', '=', ref('res_partner_peter0'))]) @@ -203,7 +207,7 @@ for move_line in move_line_obj.browse(cr, uid, move_lines): if move_line.credit == 20: assert move_line.amount_currency == 0.00, "Debtor account has wrong entry." - if move_line.credit == 100: + elif move_line.credit == 100: assert move_line.amount_currency == 0.00, "Debtor account has wrong entry." - I check the residual amount of Invoice1 is 50 @@ -225,8 +229,7 @@ assert (move_line.amount_residual_currency == 60.0 and move_line.amount_residual == 60.0) , "Residual amount is not correct for second Invoice" - I create the second voucher of payment and check to let open the debtor overpaid amount. -- - I create the second voucher of payment with Paid Amount as 120, journal EUR, and fill amount 50 for the residual amount 50 for the invoice of 150 and 70 for the residual amount 60 for the invoice of 80 + - !python {model: account.voucher}: | import netsvc, time @@ -282,16 +285,19 @@ wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr) - - I check that my voucher state is posted + I check that the move of my second voucher is valid - !python {model: account.voucher}: | voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_peter0'))]) voucher_id = self.browse(cr, uid, voucher[0]) - assert voucher_id.state == 'posted', "Voucher state is not posted" + 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 debtor account is correct - - I check that the debtor account has 2 new lines with 0.00 and 0.00 as amount_currency columns and their credit are 70 and 50 + I check that the debtor account has 2 new lines with 0.00 and 0.00 in amount_currency columns and their credit are 70 and 50 - !python {model: account.voucher}: | voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_peter0'))]) @@ -301,7 +307,7 @@ for move_line in move_line_obj.browse(cr, uid, move_lines): if move_line.credit == 70.00: assert move_line.amount_currency == 0.00, "Debtor account has wrong entry." - if move_line.credit == 50.00: + elif move_line.credit == 50.00: assert move_line.amount_currency == 0.00, "Debtor account has wrong entry." - I check the residual amount of Invoice1 is 0 diff --git a/addons/account_voucher/test/case4_cad_chf.yml b/addons/account_voucher/test/case4_cad_chf.yml index 6ba92f6c8f3..3d989eaee7a 100644 --- a/addons/account_voucher/test/case4_cad_chf.yml +++ b/addons/account_voucher/test/case4_cad_chf.yml @@ -6,7 +6,7 @@ name: !eval "'%s-01-01' %(datetime.now().year)" rate: 1.338800 - - I create a currency rate for CAD for march of 0.500000 + I create a currency rate for CAD for march of 2.000000 - !record {model: res.currency.rate, id: mar_cad}: currency_id: base.CAD @@ -19,6 +19,13 @@ currency_id: base.CHF name: !eval "'%s-01-01' %(datetime.now().year)" rate: 1.308600 +- + I create a currency rate for CHF for march of 1.250000 +- + !record {model: res.currency.rate, id: jan_chf}: + currency_id: base.CHF + name: !eval "'%s-01-01' %(datetime.now().year)" + rate: 1.250000 - I create a bank journal with CHF as currency - @@ -34,7 +41,7 @@ company_id: base.main_company view_id: account.account_journal_bank_view - - I assign accounts for 'Income Curreny Rate' and 'Expense Currency Rate' + I set up some accounts for currency rate expense/income in my company - !record {model: res.company, id: base.main_company}: property_expense_currency_exchange: account.o_expense @@ -77,7 +84,7 @@ - !workflow {model: account.invoice, action: invoice_open, ref: account_first_invoice_jan_cad} - - I check that accounting move for first invoice is correct + I check that first invoice move is correct for debtor account (debit - credit == 149.39) - !python {model: account.invoice}: | invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_cad")) @@ -87,7 +94,8 @@ move_line = move_line_obj.browse(cr, uid, move_lines[0]) assert (move_line.debit - move_line.credit == 149.39), "Invoice move is incorrect for debtors account" - - I create the first voucher of payment with Paid amount as 300, journal CHF, and fill amounts 200 for the invoice of 200. + I create the first voucher of payment + - !python {model: account.voucher}: | import netsvc, time @@ -95,7 +103,7 @@ res = self.onchange_partner_id(cr, uid, [], ref("res_partner_john0"), ref('bank_journal_CHF'), 300.0, 2, ttype='receipt', date=False) vals = { 'account_id': ref('account.cash'), - 'amount': 120.0, + 'amount': 300.0, 'company_id': ref('base.main_company'), 'currency_id': ref('base.CHF'), 'journal_id': ref('bank_journal_CHF'), @@ -130,7 +138,7 @@ !python {model: account.voucher}: | voucher = self.search(cr, uid, [('name', '=', 'First payment')]) voucher_id = self.browse(cr, uid, voucher[0]) - assert (voucher_id.currency_rate_difference == 49.39), "currency rate difference is not 0.00" + assert (voucher_id.currency_rate_difference == 49.39), "currency rate difference is not 49.39" - I confirm the voucher - @@ -140,40 +148,44 @@ wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr) - - I check that my voucher state is posted + I check that the move of my voucher is valid - !python {model: account.voucher}: | voucher = self.search(cr, uid, [('name', '=', 'First payment')]) 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" assert voucher_id.state == 'posted', "Voucher state is not posted" - I check that my debtor account is correct - - I check that the debtor account has 2 new lines with -20 and -30 as amount_currency columns and their credit columns are respectively 15 and 24 and currency is USD($). + I check that the debtor account has 1 new line with -200 as amount_currency columns and 149.39 of credit and currency is CAD($). - - I check that my Currency Difference entry is created with a credit of 8.5 + I check that my currency rate difference is correct. 49.39 in debit with no amount_currency - - I check that my write-off entry is created with a debit of 4.75 and amount currency as 0.0 + I check that my writeoff is correct. 140 credit and -175 amount_currency - !python {model: account.voucher}: | - voucher = self.search(cr, uid, [('name', '=', 'Second payment')]) + voucher = self.search(cr, uid, [('name', '=', 'First payment')]) 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): if move_line.amount_currency == -200: assert move_line.credit == 149.39, "Debtor account has wrong entry." - if move_line.credit == 49.39: + elif move_line.debit == 49.39: assert move_line.amount_currency == 0.00, "Incorrect Currency Difference." - if move_line.credit == -140.00: - assert move_line.credit == -175, "Writeoff amount is wrong." + elif move_line.credit == 140.00: + assert move_line.amount_currency == -175, "Writeoff amount is wrong." - - I check the residual amount of Invoice1, should be 0 in residual currency and 0 in amount_residual + I check the residual amount of Invoice1, should be 0 in residual currency and 0 in amount_residual and paid - !python {model: account.invoice}: | invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan")) move_line_obj = self.pool.get('account.move.line') move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)]) move_line = move_line_obj.browse(cr, uid, move_lines[0]) - assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0) , "Residual amount is not correct for first Invoice" + assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice" - \ No newline at end of file