mirror of
https://gitlab.com/flectra-community/bank-payment.git
synced 2024-11-27 16:07:27 +00:00
135 lines
4.7 KiB
YAML
135 lines
4.7 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_refund
|
||
|
-
|
||
|
!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 create a payment order
|
||
|
-
|
||
|
!record {model: payment.order, id: partial_payment_order_1}:
|
||
|
mode: account_banking_payment_transfer.payment_mode0
|
||
|
date_prefered: 'now'
|
||
|
-
|
||
|
I run the select move line to pay wizard
|
||
|
-
|
||
|
!python {model: payment.order.create}: |
|
||
|
context = {
|
||
|
"active_model": "payment.order",
|
||
|
"active_ids": [ref("partial_payment_order_1")],
|
||
|
"active_id": ref("partial_payment_order_1"),
|
||
|
}
|
||
|
wiz_id = self.create(cr, uid, {}, context=context)
|
||
|
self.search_entries(cr, uid, [wiz_id], context=context)
|
||
|
mline_ids = []
|
||
|
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:
|
||
|
mline_ids.append(l.id)
|
||
|
break
|
||
|
refund = self.pool.get('account.invoice').browse(cr, uid, ref("account_refund_supplier_refunded"))
|
||
|
for l in refund.move_id.line_id:
|
||
|
if not l.credit and l.debit:
|
||
|
mline_ids.append(l.id)
|
||
|
break
|
||
|
self.write(cr, uid, [wiz_id], {'entries': [(6, 0, mline_ids)]})
|
||
|
self.create_payment(cr, uid, [wiz_id], context=context)
|
||
|
pay_obj = self.pool.get('payment.order')
|
||
|
pay = pay_obj.browse(cr, uid, ref('partial_payment_order_1'))
|
||
|
assert len(pay.line_ids) == 2
|
||
|
-
|
||
|
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'
|
||
|
- total == 400.0
|
||
|
-
|
||
|
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'
|