mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
162 lines
6.2 KiB
YAML
162 lines
6.2 KiB
YAML
-
|
|
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' |