The voucher is no longer linked with the bank statement, use a new

phrase to generate the payment for the invoice using solely the voucher
This commit is contained in:
Guewen Baconnier
2014-10-30 11:39:35 +01:00
parent 267c9bbd53
commit e006b82b7b
2 changed files with 74 additions and 22 deletions

View File

@@ -20,25 +20,7 @@ Feature: Ensure that email credit line generation first pass is correct
@pay_invoice_si_19_part1
Scenario: I pay a part of the first part of the invoice SI 19,
Given I need a "account.bank.statement" with oid: scen.state_control_eur_1
And having:
| name | value |
| name | Bk.St.si_19_part1 |
| date | 2013-03-31 |
| journal_id | by oid: scen.eur_journal |
| period_id | by name: 03/2013 |
And I import invoice "SI_19" using import invoice button
And I should have a "account.bank.statement.line" with name: "SI_19" and amount: "450"
And I set the voucher paid amount to "300"
And I save the voucher
And I should have a "account.bank.statement.line" with name: "SI_19" and amount: "1050"
And I set the voucher paid amount to "0"
And I save the voucher
Then I modify the line amount to "0"
Given I need a "account.bank.statement" with oid: scen.state_control_eur_1
And I set bank statement end-balance
When I confirm bank statement
Given I pay 300.0 on the invoice "SI_19"
Then My invoice "SI_19" is in state "open" reconciled with a residual amount of "1200.0"
@account_credit_control_run_month_mar

View File

@@ -3,6 +3,76 @@
from support import *
import datetime
@step('I pay {amount:f} on the invoice "{inv_name}"')
def impl(ctx, amount, inv_name):
Partner = model('res.partner')
Invoice = model('account.invoice')
Voucher = model('account.voucher')
VoucherLine = model('account.voucher.line')
Journal = model('account.journal')
invoice = Invoice.get([('name', '=', inv_name)])
assert invoice
journal = Journal.get('scen.eur_journal')
values = {
'partner_id': invoice.partner_id.commercial_partner_id.id,
'reference': invoice.name,
'amount': amount,
'date': invoice.date_invoice,
'currency_id': invoice.currency_id.id,
'company_id': invoice.company_id.id,
'journal_id': journal.id,
}
if invoice.type in ('out_invoice','out_refund'):
values['type'] = 'receipt'
else:
values['type'] = 'payment'
onchange = Voucher.onchange_partner_id([], values['partner_id'],
values['journal_id'],
values['amount'],
values['currency_id'],
values['type'],
values['date'])
values.update(onchange['value'])
onchange = Voucher.onchange_date([], values['date'],
values['currency_id'],
False,
values['amount'],
values['company_id'])
values.update(onchange['value'])
onchange = Voucher.onchange_amount([], values['amount'],
False,
values['partner_id'],
values['journal_id'],
values['currency_id'],
values['type'],
values['date'],
False,
values['company_id'])
values.update(onchange['value'])
values['line_cr_ids'] = False
voucher = Voucher.create(values)
vals = voucher.recompute_voucher_lines(voucher.partner_id.id,
voucher.journal_id.id,
voucher.amount,
voucher.currency_id.id,
voucher.type,
voucher.date)
for line in vals['value']['line_cr_ids']:
line['voucher_id'] = voucher.id
VoucherLine.create(line)
for line in vals['value']['line_dr_ids']:
line['voucher_id'] = voucher.id
VoucherLine.create(line)
voucher.button_proforma_voucher()
@step('I import invoice "{inv_name}" using import invoice button')
def impl(ctx, inv_name):
invoice = model('account.invoice').get([('name', '=', inv_name)])
@@ -68,9 +138,9 @@ def impl(ctx):
def impl(ctx, amount):
assert ctx.line
# we have to change voucher amount before chaning statement line amount
if ctx.line.voucher_id:
model('account.voucher').write([ctx.line.voucher_id.id],
{'amount': float(amount)})
# if ctx.line.voucher_id:
# model('account.voucher').write([ctx.line.voucher_id.id],
# {'amount': float(amount)})
ctx.line.write({'amount': float(amount)})
@step('My invoice "{inv_name}" is in state "{state}" reconciled with a residual amount of "{amount:f}"')