mirror of
https://gitlab.com/flectra-community/bank-payment.git
synced 2024-11-22 13:42:07 +00:00
253 lines
9.2 KiB
YAML
253 lines
9.2 KiB
YAML
-
|
|
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
|
|
-
|
|
!record {model: payment.order, id: partial_payment_order_2}:
|
|
mode: account_banking_payment_transfer.payment_mode0
|
|
date_prefered: 'due'
|
|
-
|
|
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_2")],
|
|
"active_id": ref("partial_payment_order_2"),
|
|
}
|
|
wiz_id = self.create(cr, uid, {}, context=context)
|
|
self.search_entries(cr, uid, [wiz_id], context=context)
|
|
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, [wiz_id], {'entries': [(6, 0, [move_line.id])]})
|
|
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_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'
|
|
-
|
|
I search for the invoice entries to make the payment.
|
|
-
|
|
!python {model: payment.order.create}: |
|
|
context = {
|
|
"active_model": "payment.order",
|
|
"active_ids": [ref("partial_partial_payment_order_2")],
|
|
"active_id": ref("partial_partial_payment_order_2"),
|
|
}
|
|
wiz_id = self.create(cr, uid, {}, context=context)
|
|
self.search_entries(cr, uid, [wiz_id], context=context)
|
|
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, [wiz_id], {'entries': [(6,0,[move_line.id])]})
|
|
self.create_payment(cr, uid, [wiz_id], context=context)
|
|
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'
|
|
-
|
|
I search for the invoice entries to make the payment.
|
|
-
|
|
!python {model: payment.order.create}: |
|
|
context = {
|
|
"active_model": "payment.order",
|
|
"active_ids": [ref("partial_partial_payment_order_3")],
|
|
"active_id": ref("partial_partial_payment_order_3"),
|
|
}
|
|
wiz_id = self.create(cr, uid, {}, context=context)
|
|
self.search_entries(cr, uid, [wiz_id], context=context)
|
|
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, [wiz_id], {'entries': [(6, 0, [move_line.id])]})
|
|
self.create_payment(cr, uid, [wiz_id], context=context)
|
|
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'
|