mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[IMP] upgrade payment roundtrip test suite
Support native v8 bank statement reconcile and extend it to test the reconciliation state of transfer moves.
This commit is contained in:
@@ -121,7 +121,7 @@ class TestPaymentRoundtrip(SingleTransactionCase):
|
||||
can be validated properly.
|
||||
"""
|
||||
partner_model = reg('res.partner')
|
||||
supplier1 = partner_model.create(
|
||||
self.supplier1 = partner_model.create(
|
||||
cr, uid, {
|
||||
'name': 'Supplier 1',
|
||||
'supplier': True,
|
||||
@@ -135,7 +135,7 @@ class TestPaymentRoundtrip(SingleTransactionCase):
|
||||
})
|
||||
],
|
||||
}, context=context)
|
||||
supplier2 = partner_model.create(
|
||||
self.supplier2 = partner_model.create(
|
||||
cr, uid, {
|
||||
'name': 'Supplier 2',
|
||||
'supplier': True,
|
||||
@@ -160,7 +160,7 @@ class TestPaymentRoundtrip(SingleTransactionCase):
|
||||
invoice_model = reg('account.invoice')
|
||||
values = {
|
||||
'type': 'in_invoice',
|
||||
'partner_id': supplier1,
|
||||
'partner_id': self.supplier1,
|
||||
'account_id': self.payable_id,
|
||||
'invoice_line': [
|
||||
(0, False, {
|
||||
@@ -179,7 +179,7 @@ class TestPaymentRoundtrip(SingleTransactionCase):
|
||||
'type': 'in_invoice',
|
||||
})]
|
||||
values.update({
|
||||
'partner_id': supplier2,
|
||||
'partner_id': self.supplier2,
|
||||
'name': 'Purchase 2',
|
||||
'reference_type': 'structured',
|
||||
'supplier_invoice_number': 'INV2',
|
||||
@@ -312,7 +312,6 @@ class TestPaymentRoundtrip(SingleTransactionCase):
|
||||
"""
|
||||
statement_model = reg('account.bank.statement')
|
||||
line_model = reg('account.bank.statement.line')
|
||||
wizard_model = reg('banking.transaction.wizard')
|
||||
statement_id = statement_model.create(
|
||||
cr, uid, {
|
||||
'name': 'Statement',
|
||||
@@ -320,19 +319,36 @@ class TestPaymentRoundtrip(SingleTransactionCase):
|
||||
'balance_end_real': -200.0,
|
||||
'period_id': reg('account.period').find(cr, uid)[0]
|
||||
})
|
||||
line_id = line_model.create(
|
||||
line1_id = line_model.create(
|
||||
cr, uid, {
|
||||
'name': 'Statement line',
|
||||
'statement_id': statement_id,
|
||||
'amount': -200.0,
|
||||
'amount': -100.0,
|
||||
'account_id': self.payable_id,
|
||||
'partner_id': self.supplier1,
|
||||
})
|
||||
wizard_id = wizard_model.create(
|
||||
cr, uid, {'statement_line_id': line_id})
|
||||
wizard_model.write(
|
||||
cr, uid, [wizard_id], {
|
||||
'manual_payment_order_id': self.payment_order_id})
|
||||
statement_model.button_confirm_bank(cr, uid, [statement_id])
|
||||
line1 = line_model.browse(cr, uid, line1_id)
|
||||
rec_line1 = line_model.\
|
||||
get_reconciliation_proposition(cr, uid, line1)[0]
|
||||
line_model.process_reconciliation(cr, uid, line1_id, [
|
||||
{'counterpart_move_line_id': rec_line1['id'],
|
||||
'debit': rec_line1['credit'],
|
||||
'credit': rec_line1['debit']}])
|
||||
line2_id = line_model.create(
|
||||
cr, uid, {
|
||||
'name': 'Statement line',
|
||||
'statement_id': statement_id,
|
||||
'amount': -100.0,
|
||||
'account_id': self.payable_id,
|
||||
'partner_id': self.supplier2,
|
||||
})
|
||||
line2 = line_model.browse(cr, uid, line2_id)
|
||||
rec_line2 = line_model.\
|
||||
get_reconciliation_proposition(cr, uid, line2)[0]
|
||||
line_model.process_reconciliation(cr, uid, line2_id, [
|
||||
{'counterpart_move_line_id': rec_line2['id'],
|
||||
'debit': rec_line2['credit'],
|
||||
'credit': rec_line2['debit']}])
|
||||
self.assert_payment_order_state('done')
|
||||
|
||||
def check_reconciliations(self, reg, cr, uid):
|
||||
@@ -340,6 +356,10 @@ class TestPaymentRoundtrip(SingleTransactionCase):
|
||||
Check if the payment order has any lines and that
|
||||
the transit move lines of those payment lines are
|
||||
reconciled by now.
|
||||
|
||||
The transit move line is the line that pays the invoice
|
||||
so it is reconciled as soon as the payment order
|
||||
is sent.
|
||||
"""
|
||||
payment_order = reg('payment.order').browse(
|
||||
cr, uid, self.payment_order_id)
|
||||
@@ -348,6 +368,21 @@ class TestPaymentRoundtrip(SingleTransactionCase):
|
||||
assert line.transit_move_line_id, \
|
||||
'Payment order has no transfer move line'
|
||||
assert line.transit_move_line_id.reconcile_id, \
|
||||
'Transit move line on payment line is not reconciled'
|
||||
|
||||
def check_reconciliations_after_bank_statement(self, reg, cr, uid):
|
||||
"""
|
||||
Check if the payment order has any lines and that
|
||||
the transfer move lines of those payment lines are
|
||||
reconciled by now.
|
||||
"""
|
||||
payment_order = reg('payment.order').browse(
|
||||
cr, uid, self.payment_order_id)
|
||||
assert payment_order.line_ids, 'Payment order has no payment lines'
|
||||
for line in payment_order.line_ids:
|
||||
assert line.transfer_move_line_id, \
|
||||
'Payment order has no transfer move line'
|
||||
assert line.transfer_move_line_id.reconcile_id, \
|
||||
'Transfer move line on payment line is not reconciled'
|
||||
|
||||
def test_payment_roundtrip(self):
|
||||
@@ -358,5 +393,6 @@ class TestPaymentRoundtrip(SingleTransactionCase):
|
||||
self.setup_payment_config(reg, cr, uid)
|
||||
self.setup_payment(reg, cr, uid)
|
||||
self.export_payment(reg, cr, uid)
|
||||
# self.setup_bank_statement(reg, cr, uid)
|
||||
self.check_reconciliations(reg, cr, uid)
|
||||
self.setup_bank_statement(reg, cr, uid)
|
||||
self.check_reconciliations_after_bank_statement(reg, cr, uid)
|
||||
|
||||
Reference in New Issue
Block a user