From 0e02b7e13187d84a502b164d8488e31957fd040a Mon Sep 17 00:00:00 2001 From: Matt Choplin Date: Fri, 6 Mar 2015 12:01:02 +0000 Subject: [PATCH] [test_for_account_banking_payment_transfer] add test for the partial payment without refund --- .../__openerp__.py | 2 + .../test/test_partial_payment_transfer.yml | 276 ++++++++++++++++++ 2 files changed, 278 insertions(+) create mode 100644 account_banking_payment_transfer/test/test_partial_payment_transfer.yml diff --git a/account_banking_payment_transfer/__openerp__.py b/account_banking_payment_transfer/__openerp__.py index d197f8e5f..e9d37c1d6 100644 --- a/account_banking_payment_transfer/__openerp__.py +++ b/account_banking_payment_transfer/__openerp__.py @@ -43,6 +43,8 @@ 'test/data.yml', 'test/test_payment_method.yml', 'test/test_partial_payment_refunded.yml', + 'test/test_partial_payment_transfer.yml', + ], 'description': '''Payment order reconciliation infrastructure diff --git a/account_banking_payment_transfer/test/test_partial_payment_transfer.yml b/account_banking_payment_transfer/test/test_partial_payment_transfer.yml new file mode 100644 index 000000000..f32b9a84d --- /dev/null +++ b/account_banking_payment_transfer/test/test_partial_payment_transfer.yml @@ -0,0 +1,276 @@ +- + I create a supplier invoice +- + !record {model: account.invoice, id: account_invoice_supplier_partial, view: account.invoice_supplier_form}: + check_total: 1000.00 + partner_id: base.res_partner_12 + reference_type: none + type: in_invoice + account_id: account.a_pay + company_id: base.main_company + currency_id: base.EUR + invoice_line: + - account_id: account.a_expense + name: 'Some glasses' + price_unit: 1000.00 + quantity: 1.0 + journal_id: account.expenses_journal +- + Make sure that the type is in_invoice +- + !python {model: account.invoice}: | + self.write(cr, uid, ref("account_invoice_supplier_partial"), {'type': 'in_invoice'}) +- + I change the state of invoice to open by clicking Validate button +- + !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier_partial} +- + I create a payment order on which I will select the invoice I created +- + !record {model: payment.order, id: partial_payment_order_2}: + mode: account_banking_payment_transfer.payment_mode0 + date_prefered: 'due' +- + !record {model: payment.order.create, id: payment_order_create_2}: + duedate: !eval time.strftime('%Y-%m-%d') +- + I search for the invoice entries to make the payment. +- + !python {model: payment.order.create}: | + self.search_entries(cr, uid, [ref("payment_order_create_2")], { + "active_model": "payment.order", "active_ids": [ref("partial_payment_order_2")], + "active_id": ref("partial_payment_order_2"), }) +- + I create payment lines entries. +- + !python {model: payment.order.create}: | + invoice = self.pool.get('account.invoice').browse(cr, uid, ref("account_invoice_supplier_partial")) + move_line = invoice.move_id.line_id[0] + self.write(cr, uid, [ref("payment_order_create_2")], {'entries': [(6,0,[move_line.id])]}) + self.create_payment(cr, uid, [ref("payment_order_create_2")], { + "active_model": "payment.order", "active_ids": [ref("partial_payment_order_2")], + "active_id": ref("partial_payment_order_2")}) + pay_obj = self.pool.get('payment.order') + pay = pay_obj.browse(cr, uid, ref('partial_payment_order_2')) + assert pay.line_ids + assert pay.line_ids[0].amount_currency == 1000.0 +- + I change the amount paid to test the partial payment +- + !python {model: payment.order}: | + line_ids = self.browse(cr, uid, ref('partial_payment_order_2')).line_ids + line_to_change = line_ids[0] + assert line_to_change.amount_currency == 1000.00 + self.pool.get('payment.line').write(cr, uid, line_to_change.id, {'amount_currency':100}) +- + I confirm the payment order. +- + !workflow {model: payment.order, action: open, ref: partial_payment_order_2} +- + I check that payment order is now "Confirmed". +- + !assert {model: payment.order, id: partial_payment_order_2, severity: error, string: Payment Order should be 'Confirmed'.}: + - state == 'open' +- + I assume that the document is sent to the bank and validate. +- + !record {model: payment.manual, id: payment_manual_1}: + create_date: !eval time.strftime('%Y-%m-%d') +- + I click OK +- + !python {model: payment.manual}: | + if context is None: + context = {} + context.update({'active_ids': [ref("partial_payment_order_2")]}) + self.button_ok(cr, uid, ref("payment_manual_1"), context) +- + I check that the payment order is now "Sent". +- + !assert {model: payment.order, id: partial_payment_order_2, severity: error, string: Payment Order should be 'Sent'.}: + - state == 'sent' +- + I check that the invoice has payments associated +- + !assert {model: account.invoice, id: account_invoice_supplier_partial, severity: error, string: payment_ids should be populated}: + - payment_ids +- + I check the content of the payment of the invoice +- + !python {model: account.invoice}: | + inv = self.browse(cr, uid, ref("account_invoice_supplier_partial")) + assert round(inv.payment_ids[0].debit, 2) == 100 + assert inv.payment_ids[0].credit == 0 + assert not inv.payment_ids[0].reconcile_id.id + assert inv.payment_ids[0].reconcile_partial_id + sum_debit = 0.0 + sum_credit = 0.0 + for line in inv.payment_ids[0].reconcile_partial_id.line_partial_ids: + sum_debit += line.debit + sum_credit += line.credit + assert sum_debit == 100 + sum_credit == 1000 + assert inv.residual == 900 + assert inv.state == 'open' +- + I create a 2nd partial payment +- + !record {model: payment.order, id: partial_partial_payment_order_2}: + mode: account_banking_payment_transfer.payment_mode0 + date_prefered: 'due' +- + !record {model: payment.order.create, id: partial_payment_order_create_2}: + duedate: !eval time.strftime('%Y-%m-%d') +- + I search for the invoice entries to make the payment. +- + !python {model: payment.order.create}: | + self.search_entries(cr, uid, [ref("partial_payment_order_create_2")], { + "active_model": "payment.order", "active_ids": [ref("partial_partial_payment_order_2")], + "active_id": ref("partial_partial_payment_order_2"), }) +- + I create payment lines entries. +- + !python {model: payment.order.create}: | + invoice = self.pool.get('account.invoice').browse(cr, uid, ref("account_invoice_supplier_partial")) + for l in invoice.move_id.line_id: + if not l.debit and l.credit: + move_line = l + break + self.write(cr, uid, [ref("partial_payment_order_create_2")], {'entries': [(6,0,[move_line.id])]}) + self.create_payment(cr, uid, [ref("partial_payment_order_create_2")], { + "active_model": "payment.order", "active_ids": [ref("partial_partial_payment_order_2")], + "active_id": ref("partial_partial_payment_order_2")}) + pay_obj = self.pool.get('payment.order') + pay = pay_obj.browse(cr, uid, ref('partial_partial_payment_order_2')) + assert len(pay.line_ids) == 1 + assert pay.line_ids[0].amount_currency == 900 +- + I change the amount paid to test the partial payment +- + !python {model: payment.order}: | + line_ids = self.browse(cr, uid, ref('partial_partial_payment_order_2')).line_ids + line_to_change = line_ids[0] + self.pool.get('payment.line').write(cr, uid, line_to_change.id, {'amount_currency':200}) +- + I confirm the payment order. +- + !workflow {model: payment.order, action: open, ref: partial_partial_payment_order_2} +- + I assume that the document is sent to the bank and validate. +- + !record {model: payment.manual, id: payment_manual_1}: + create_date: !eval time.strftime('%Y-%m-%d') +- + I click OK +- + !python {model: payment.manual}: | + if context is None: + context = {} + context.update({'active_ids': [ref("partial_partial_payment_order_2")]}) + self.button_ok(cr, uid, ref("payment_manual_1"), context) +- + I check that the payment order is now "Sent". +- + !assert {model: payment.order, id: partial_partial_payment_order_2, severity: error, string: Payment Order should be 'Sent'.}: + - state == 'sent' +- + I check the content of the payment of the invoice +- + !python {model: account.invoice}: | + inv = self.browse(cr, uid, ref("account_invoice_supplier_partial")) + assert len(inv.payment_ids) == 2 + assert inv.payment_ids[0].credit == 0 + assert not inv.payment_ids[0].reconcile_id.id + assert inv.payment_ids[0].reconcile_partial_id + sum_debit = 0.0 + sum_credit = 0.0 + for line in inv.payment_ids[0].reconcile_partial_id.line_partial_ids: + sum_debit += line.debit + sum_credit += line.credit + assert sum_debit == 300 + assert sum_credit == 1000 + assert inv.residual == 700 + assert inv.state == 'open' +- + I create the last partial payment for completing the payment +- + !record {model: payment.order, id: partial_partial_payment_order_3}: + mode: account_banking_payment_transfer.payment_mode0 + date_prefered: 'due' +- + !record {model: payment.order.create, id: partial_payment_order_create_3}: + duedate: !eval time.strftime('%Y-%m-%d') +- + I search for the invoice entries to make the payment. +- + !python {model: payment.order.create}: | + self.search_entries(cr, uid, [ref("partial_payment_order_create_3")], { + "active_model": "payment.order", "active_ids": [ref("partial_partial_payment_order_3")], + "active_id": ref("partial_partial_payment_order_3"), }) +- + I create payment lines entries. +- + !python {model: payment.order.create}: | + invoice = self.pool.get('account.invoice').browse(cr, uid, ref("account_invoice_supplier_partial")) + for l in invoice.move_id.line_id: + if not l.debit and l.credit: + move_line = l + break + self.write(cr, uid, [ref("partial_payment_order_create_3")], {'entries': [(6,0,[move_line.id])]}) + self.create_payment(cr, uid, [ref("partial_payment_order_create_3")], { + "active_model": "payment.order", "active_ids": [ref("partial_partial_payment_order_3")], + "active_id": ref("partial_partial_payment_order_3")}) + pay_obj = self.pool.get('payment.order') + pay = pay_obj.browse(cr, uid, ref('partial_partial_payment_order_3')) + assert len(pay.line_ids) == 1 + assert pay.line_ids[0].amount_currency == 700 +- + I confirm the payment order. +- + !workflow {model: payment.order, action: open, ref: partial_partial_payment_order_3} +- + I assume that the document is sent to the bank and validate. +- + !record {model: payment.manual, id: payment_manual_3}: + create_date: !eval time.strftime('%Y-%m-%d') +- + I click OK +- + !python {model: payment.manual}: | + if context is None: + context = {} + context.update({'active_ids': [ref("partial_partial_payment_order_3")]}) + self.button_ok(cr, uid, ref("payment_manual_3"), context) +- + I check that the payment order is now "Sent". +- + !assert {model: payment.order, id: partial_partial_payment_order_3, severity: error, string: Payment Order should be 'Sent'.}: + - state == 'sent' +- + I check the content of the payment of the invoice +- + !python {model: account.invoice}: | + inv = self.browse(cr, uid, ref("account_invoice_supplier_partial")) + assert len(inv.payment_ids) == 3 + assert inv.payment_ids[0].credit == 0 + assert inv.payment_ids[0].reconcile_id.id + #assert not inv.payment_ids[0].reconcile_partial_id ?? should we remove it? + sum_debit = 0.0 + sum_credit = 0.0 + for line in inv.payment_ids: + sum_debit += line.debit + sum_credit += line.credit + assert sum_debit == 1000 + assert sum_credit == 0 + assert inv.residual == 0 + assert inv.state == 'paid' + + + + + + + + +