Skip to content

Commit

Permalink
Boton Pagar. Ahora acepta multilineas.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukio committed Oct 17, 2016
1 parent 7cc5231 commit eef79f6
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions invoice.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#This file is part of the account_voucher_ar module for Tryton.
#The COPYRIGHT file at the top level of this repository contains
#the full copyright notices and license terms.
from decimal import Decimal
from trytond.wizard import Wizard, StateView, Button
from trytond.transaction import Transaction
from trytond.pool import Pool
Expand Down Expand Up @@ -32,27 +31,27 @@ def default_start(self, fields):
default['currency'] = invoice.currency.id
default['pay_invoice'] = invoice.id

amount_to_pay = Decimal('0.0')
if invoice.type == 'in':
default['voucher_type'] = 'payment'
line_type = 'cr'
elif invoice.type == 'out':
default['voucher_type'] = 'receipt'
line_type = 'dr'
amount_to_pay = invoice.amount_to_pay

line_to_pay, = invoice.lines_to_pay

lines = {
'name': invoice.number,
'account': invoice.account.id,
'amount': amount_to_pay,
'amount_original': invoice.total_amount,
'amount_unreconciled': invoice.amount_to_pay,
'line_type': line_type,
'move_line': line_to_pay.id,
'date': invoice.invoice_date,
}
default['lines'].append(lines)

for line in invoice.lines_to_pay:
amount = line.debit
amount_residual = abs(line.amount_residual)

lines = {
'name': invoice.number,
'account': invoice.account.id,
'amount': line.amount,
'amount_original': amount,
'amount_unreconciled': amount_residual,
'line_type': line_type,
'move_line': line.id,
'date': invoice.invoice_date,
}
default['lines'].append(lines)

return default

0 comments on commit eef79f6

Please sign in to comment.