check balance early; cierre caja always debe
This commit is contained in:
parent
1d14d231d4
commit
0fb696365a
24
account.py
24
account.py
|
@ -1,3 +1,4 @@
|
|||
import logging
|
||||
from retrofix.exception import RetrofixException
|
||||
from retrofix.fields import Char, Date, Field, Integer
|
||||
from retrofix.record import Record
|
||||
|
@ -12,6 +13,7 @@ from trytond.transaction import Transaction
|
|||
__all__ = ['AccountImportContaplus', 'AccountImportContaplusStart',
|
||||
'ImportRecord', 'Move', 'Invoice']
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class DecimalField(Field):
|
||||
# decimals in files are separated by period '.'
|
||||
|
@ -88,7 +90,7 @@ def not_balance(move):
|
|||
lambda t_cd, line:
|
||||
add_tupla2(t_cd, (line.credit, line.debit)),
|
||||
move.lines,
|
||||
[0,0])
|
||||
[0, 0])
|
||||
return credit_debit[0] != credit_debit[1]
|
||||
|
||||
|
||||
|
@ -264,7 +266,8 @@ class AccountImportContaplus(Wizard):
|
|||
'DESEMBOLSO',
|
||||
'TRASP. A BAN',
|
||||
'TRASP. A BANC',
|
||||
'ANTICP-VALES'):
|
||||
'ANTICP-VALES',
|
||||
'cierre de caja'):
|
||||
line.debit = iline.euro_haber + iline.euro_debe
|
||||
line.credit = 0
|
||||
else:
|
||||
|
@ -287,6 +290,11 @@ class AccountImportContaplus(Wizard):
|
|||
def check_totals(self, invoices, totals):
|
||||
for invoice in invoices.values():
|
||||
if not invoice.total_amount == totals[invoice.number]:
|
||||
logger.info('unmatch total')
|
||||
logger.info(invoice.total_amount)
|
||||
logger.info(totals[invoice.number])
|
||||
for line in invoice.lines:
|
||||
logger.info(line.unit_price)
|
||||
self.raise_user_error('unmatch total invoice',
|
||||
{'invoice': invoice.number})
|
||||
return True
|
||||
|
@ -300,6 +308,7 @@ class AccountImportContaplus(Wizard):
|
|||
|
||||
def import_invoices(self, company, imp_record):
|
||||
|
||||
logger.info("start import invoice")
|
||||
pool = Pool()
|
||||
Invoice = pool.get('account.invoice')
|
||||
Line = pool.get('account.invoice.line')
|
||||
|
@ -383,11 +392,18 @@ class AccountImportContaplus(Wizard):
|
|||
self.add_tax_invoice(invoice, vat)
|
||||
|
||||
if to_create:
|
||||
logger.info("save")
|
||||
Invoice.save(to_create.values())
|
||||
logger.info("update_taxes")
|
||||
Invoice.update_taxes(to_create.values())
|
||||
Invoice.post(to_create.values())
|
||||
|
||||
logger.info("check total")
|
||||
self.check_totals(to_create, totals)
|
||||
logger.info("post")
|
||||
# for inv in to_create.values():
|
||||
# print("posting")
|
||||
# print(inv.number)
|
||||
# Invoice.post([inv])
|
||||
Invoice.post(to_create.values())
|
||||
|
||||
return to_create
|
||||
|
||||
|
|
Loading…
Reference in New Issue