mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[test_for_account_banking_payment_transfer] add tests according to the use case given in https://github.com/OCA/bank-payment/issues/93
This commit is contained in:
@@ -38,6 +38,12 @@
|
||||
'view/payment_mode.xml',
|
||||
'workflow/account_payment.xml',
|
||||
],
|
||||
'test': [
|
||||
'test/data.yml',
|
||||
'test/test_payment_method.yml',
|
||||
'test/test_partial_payment_refunded.yml',
|
||||
|
||||
],
|
||||
'description': '''Payment order reconciliation infrastructure
|
||||
|
||||
This module reconciles invoices as soon as the payment order
|
||||
|
||||
28
account_banking_payment_transfer/test/data.yml
Normal file
28
account_banking_payment_transfer/test/data.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
-
|
||||
I create a transfer account
|
||||
-
|
||||
!record {model: account.account, id: account_account_transfer0}:
|
||||
code: TRANSF
|
||||
name: Transfer
|
||||
user_type: account.data_account_type_liability
|
||||
type: other
|
||||
reconcile: True
|
||||
-
|
||||
I create a transfer journal
|
||||
-
|
||||
!record {model: account.journal, id: transfer_journal0}:
|
||||
name: Transfer journal
|
||||
code: TR
|
||||
type: general
|
||||
company_id: base.main_company
|
||||
-
|
||||
I create a payment mode
|
||||
-
|
||||
!record {model: payment.mode, id: payment_mode0}:
|
||||
name: Payment Mode Test
|
||||
journal: account.bank_journal
|
||||
bank_id: account_payment.partner_bank_1
|
||||
company_id: base.main_company
|
||||
transfer_account_id: account_account_transfer0
|
||||
transfer_journal_id: transfer_journal0
|
||||
type: account_banking_payment_export.manual_bank_tranfer
|
||||
@@ -0,0 +1,162 @@
|
||||
-
|
||||
I create a supplier invoice
|
||||
-
|
||||
!record {model: account.invoice, id: account_invoice_supplier_refunded, view: account.invoice_supplier_form}:
|
||||
check_total: 600.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 contact lenses'
|
||||
price_unit: 600.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_refunded"), {'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_refunded}
|
||||
-
|
||||
I create a supplier refund for this invoice
|
||||
-
|
||||
!record {model: account.invoice, id: account_refund_supplier_refunded, view: account.invoice_supplier_form}:
|
||||
check_total: 200.00
|
||||
partner_id: base.res_partner_12
|
||||
reference_type: none
|
||||
type: in_refund
|
||||
account_id: account.a_pay
|
||||
company_id: base.main_company
|
||||
currency_id: base.EUR
|
||||
invoice_line:
|
||||
- account_id: account.a_expense
|
||||
name: 'Some contact lenses'
|
||||
price_unit: 200.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_refund_supplier_refunded"), {'type': 'in_refund'})
|
||||
-
|
||||
I change the state of invoice to open by clicking Validate button
|
||||
-
|
||||
!workflow {model: account.invoice, action: invoice_open, ref: account_refund_supplier_refunded}
|
||||
-
|
||||
I reconcile the invoice and the refund
|
||||
-
|
||||
!record {model: account.move.line.reconcile, id: account_move_line_reconcile0}:
|
||||
trans_nbr: 2
|
||||
credit: 600.0
|
||||
debit: 200.0
|
||||
writeoff: -400.0
|
||||
-
|
||||
Then I click on the 'Partial Reconcile' button
|
||||
-
|
||||
!python {model: account.move.line.reconcile}: |
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
inv_obj = self.pool.get('account.invoice')
|
||||
invoice_move_id = inv_obj.browse(cr, uid, ref("account_invoice_supplier_refunded")).move_id.id
|
||||
refund_move_id = inv_obj.browse(cr, uid, ref("account_refund_supplier_refunded")).move_id.id
|
||||
debit_line_id = move_line_obj.search(cr, uid, [('move_id', '=', refund_move_id),('debit', '=', 200)])[0]
|
||||
credit_line_id = move_line_obj.search(cr, uid, [('move_id', '=', invoice_move_id),('credit', '=', 600)])[0]
|
||||
ids = [debit_line_id, credit_line_id]
|
||||
partial_reconcile = self.trans_rec_reconcile_partial_reconcile(cr, uid, [ref('account_move_line_reconcile0')], {
|
||||
'active_model': 'account.move.line', 'active_ids': ids, 'tz': False, 'active_id': ids[1]})
|
||||
move_line = move_line_obj.browse(cr, uid, ids)
|
||||
assert move_line[0].reconcile_partial_id, "Partial reconcilation is not done"
|
||||
-
|
||||
I check that the invoice balance (residual) is now 400
|
||||
-
|
||||
!assert {model: account.invoice, id: account_invoice_supplier_refunded, severity: error, string: Invoice residual should be 400.}:
|
||||
- residual == 400
|
||||
- amount_total == 600
|
||||
-
|
||||
I create a payment order on which I will select the invoice I created
|
||||
-
|
||||
!record {model: payment.order, id: partial_payment_order_1}:
|
||||
mode: account_banking_payment_transfer.payment_mode0
|
||||
date_prefered: 'due'
|
||||
-
|
||||
!record {model: payment.order.create, id: payment_order_create_1}:
|
||||
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_1")], {
|
||||
"active_model": "payment.order", "active_ids": [ref("partial_payment_order_1")],
|
||||
"active_id": ref("partial_payment_order_1"), })
|
||||
-
|
||||
I create payment lines entries.
|
||||
-
|
||||
!python {model: payment.order.create}: |
|
||||
invoice = self.pool.get('account.invoice').browse(cr, uid, ref("account_invoice_supplier_refunded"))
|
||||
for l in invoice.move_id.line_id:
|
||||
if not l.debit and l.credit:
|
||||
move_line = l
|
||||
break
|
||||
self.write(cr, uid, [ref("payment_order_create_1")], {'entries': [(6,0,[move_line.id])]})
|
||||
self.create_payment(cr, uid, [ref("payment_order_create_1")], {
|
||||
"active_model": "payment.order", "active_ids": [ref("partial_payment_order_1")],
|
||||
"active_id": ref("partial_payment_order_1")})
|
||||
pay_obj = self.pool.get('payment.order')
|
||||
pay = pay_obj.browse(cr, uid, ref('partial_payment_order_1'))
|
||||
assert pay.line_ids[0].amount_currency == 400
|
||||
assert pay.total == 400
|
||||
-
|
||||
I confirm the payment order.
|
||||
-
|
||||
!workflow {model: payment.order, action: open, ref: partial_payment_order_1}
|
||||
-
|
||||
I check that payment order is now "Confirmed".
|
||||
-
|
||||
!assert {model: payment.order, id: partial_payment_order_1, severity: error, string: Payment Order should be 'Confirmed'.}:
|
||||
- state == 'open'
|
||||
-
|
||||
I create the wizard for paying the payment
|
||||
-
|
||||
!record {model: payment.manual, id: payment_manual_partial}:
|
||||
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_1")]})
|
||||
self.button_ok(cr, uid, ref("payment_manual_partial"), context)
|
||||
-
|
||||
I check that the payment order is now "Sent".
|
||||
-
|
||||
!assert {model: payment.order, id: partial_payment_order_1, 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_refunded, 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_refunded"))
|
||||
payment1, payment2 = sorted(inv.payment_ids, key=lambda line: line.id)
|
||||
assert payment1.debit == 200
|
||||
assert payment2.debit == 400
|
||||
assert inv.payment_ids[0].reconcile_id.id != False
|
||||
-
|
||||
I check that the invoice balance (residual) is now 0 and the state is paid
|
||||
-
|
||||
!assert {model: account.invoice, id: account_invoice_supplier_refunded, severity: error, string: Invoice residual should be 0.}:
|
||||
- residual == 0
|
||||
- amount_total == 600
|
||||
- state == 'paid'
|
||||
164
account_banking_payment_transfer/test/test_payment_method.yml
Normal file
164
account_banking_payment_transfer/test/test_payment_method.yml
Normal file
@@ -0,0 +1,164 @@
|
||||
-
|
||||
I create a supplier invoice
|
||||
-
|
||||
!record {model: account.invoice, id: account_invoice_supplier0, view: account.invoice_supplier_form}:
|
||||
check_total: 450.0
|
||||
partner_id: base.res_partner_4
|
||||
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 expenses'
|
||||
price_unit: 450.0
|
||||
quantity: 1.0
|
||||
- account_id: account.a_expense
|
||||
name: 'Some other expenses'
|
||||
price_unit: 555.55
|
||||
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_supplier0"), {'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_supplier0}
|
||||
-
|
||||
I check that the invoice state is now "Open"
|
||||
-
|
||||
!assert {model: account.invoice, id: account_invoice_supplier0}:
|
||||
- state == 'open'
|
||||
- type == 'in_invoice'
|
||||
-
|
||||
I create a payment order on which I will select the invoice I created
|
||||
-
|
||||
!record {model: payment.order, id: payment_order_0}:
|
||||
mode: account_banking_payment_transfer.payment_mode0
|
||||
date_prefered: 'due'
|
||||
-
|
||||
!record {model: payment.order.create, id: payment_order_create_0}:
|
||||
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_0")], {
|
||||
"active_model": "payment.order", "active_ids": [ref("payment_order_0")],
|
||||
"active_id": ref("payment_order_0"), })
|
||||
-
|
||||
I create payment lines entries.
|
||||
-
|
||||
!python {model: payment.order.create}: |
|
||||
invoice = self.pool.get('account.invoice').browse(cr, uid, ref("account_invoice_supplier0"))
|
||||
entries = []
|
||||
for move_line in invoice.move_id.line_id:
|
||||
if move_line.credit and not move_line.debit:
|
||||
entries.append((6, 0, [move_line.id]))
|
||||
self.write(cr, uid, [ref("payment_order_create_0")], {'entries': entries})
|
||||
self.create_payment(cr, uid, [ref("payment_order_create_0")], {
|
||||
"active_model": "payment.order", "active_ids": [ref("payment_order_0")],
|
||||
"active_id": ref("payment_order_0")})
|
||||
pay_obj = self.pool.get('payment.order')
|
||||
pay = pay_obj.browse(cr, uid, ref('payment_order_0'))
|
||||
for line in pay.line_ids:
|
||||
assert line.amount != 0.0
|
||||
-
|
||||
I confirm the payment order.
|
||||
-
|
||||
!workflow {model: payment.order, action: open, ref: payment_order_0}
|
||||
-
|
||||
I check that payment order is now "Confirmed".
|
||||
-
|
||||
!assert {model: payment.order, id: payment_order_0, severity: error, string: Payment Order should be 'Confirmed'.}:
|
||||
- state == 'open'
|
||||
-
|
||||
I create the wizard for paying the payment
|
||||
-
|
||||
!record {model: payment.manual, id: payment_manual_0}:
|
||||
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("payment_order_0")]})
|
||||
self.button_ok(cr, uid, ref("payment_manual_0"), context)
|
||||
-
|
||||
I check that the payment order is now "Sent".
|
||||
-
|
||||
!assert {model: payment.order, id: payment_order_0, 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_supplier0, 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_supplier0"))
|
||||
assert round(inv.payment_ids[0].debit, 2) == 1005.55
|
||||
assert inv.payment_ids[0].credit == 0
|
||||
assert inv.payment_ids[0].reconcile_id.id != False
|
||||
assert inv.payment_ids[0].reconcile_ref != False
|
||||
assert inv.state == 'paid'
|
||||
-
|
||||
I create the bank statement to reconcile the transfer account move
|
||||
-
|
||||
!record {model: account.bank.statement, id: bank_statement_0}:
|
||||
name: BK test
|
||||
balance_end_real: 0.0
|
||||
balance_start: 0.0
|
||||
date: !eval time.strftime('%Y-%m-%d')
|
||||
journal_id: account.bank_journal
|
||||
-
|
||||
I create bank statement line
|
||||
-
|
||||
!python {model: account.bank.statement.line}: |
|
||||
vals = {
|
||||
'amount': -1005.55,
|
||||
'partner_id': ref('base.res_partner_4'),
|
||||
'statement_id': ref('bank_statement_0'),
|
||||
'name': 'Pay invoice',
|
||||
'journal_id': ref("account.bank_journal"),
|
||||
}
|
||||
line_id = self.create(cr, uid, vals)
|
||||
assert line_id, "Account bank statement line has not been created"
|
||||
-
|
||||
I reconcile the move transfer (not the invoice) with the payment.
|
||||
-
|
||||
!python {model: account.bank.statement}: |
|
||||
inv_obj = self.pool.get('account.invoice')
|
||||
statement_obj = self.pool.get('account.bank.statement.line')
|
||||
transfer_entry = inv_obj.browse(cr, uid, ref("account_invoice_supplier0")).payment_ids[0].move_id
|
||||
for line in transfer_entry.line_id:
|
||||
if not line.reconcile_id and line.credit:
|
||||
counterpart_move_line = line
|
||||
break
|
||||
browse_payment = self.browse(cr, uid, ref("bank_statement_0"))
|
||||
for line in browse_payment.line_ids:
|
||||
statement_obj.process_reconciliation(cr, uid, line.id, [{
|
||||
'counterpart_move_line_id': counterpart_move_line.id,
|
||||
'credit':0,
|
||||
'debit': counterpart_move_line.credit,
|
||||
'name': line.name,
|
||||
}])
|
||||
self.write(cr, uid, ref("bank_statement_0"), {'balance_end_real': -1005.55})
|
||||
self.button_confirm_bank(cr, uid, ref("bank_statement_0"))
|
||||
-
|
||||
I check that the bank statement is confirm
|
||||
-
|
||||
!assert {model: account.bank.statement, id: bank_statement_0, severity: error, string: Bank Statement should be confirm}:
|
||||
- state == 'confirm'
|
||||
-
|
||||
I check that the payment is done
|
||||
-
|
||||
!assert {model: payment.order, id: payment_order_0, severity: error, string: Payment Order should be done}:
|
||||
- state == 'done'
|
||||
Reference in New Issue
Block a user