1 parent
779ece7045
commit
ba7e60e9a3
2 files changed
+17
-33
No files matched your search
@@ -41,7 +41,7 @@ else:
|
||||
download_url = 'http://downloads.tryton.org/%s.%s/' % (
|
||||
major_version, minor_version)
|
||||
|
||||
requires = ['python-stdnum', 'csb43>=0.8']
|
||||
requires = ['aeb43']
|
||||
for dep in info.get('depends', []):
|
||||
if not re.match(r'(ir|res)(\W|$)', dep):
|
||||
requires.append(get_require_version('trytond_%s' % dep))
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from io import BytesIO, TextIOWrapper
|
||||
|
||||
from csb43 import csb43
|
||||
from stdnum.es.ccc import calc_check_digits, to_iban
|
||||
from aeb43 import AEB43
|
||||
|
||||
from trytond.i18n import gettext
|
||||
from trytond.modules.account_statement.exceptions import ImportStatementError
|
||||
@@ -25,7 +24,7 @@ class ImportStatement(metaclass=PoolMeta):
|
||||
|
||||
def parse_aeb43(self, encoding='iso-8859-1'):
|
||||
file_ = TextIOWrapper(BytesIO(self.start.file_), encoding=encoding)
|
||||
aeb43 = csb43.File(file_, strict=False)
|
||||
aeb43 = AEB43(file_)
|
||||
|
||||
for account in aeb43.accounts:
|
||||
statement = self.aeb43_statement(account)
|
||||
@@ -40,57 +39,42 @@ class ImportStatement(metaclass=PoolMeta):
|
||||
Statement = pool.get('account.statement')
|
||||
Journal = pool.get('account.statement.journal')
|
||||
|
||||
# Compute IBAN code from spanish format
|
||||
bank_code = account.bankCode
|
||||
branch_code = account.branchCode
|
||||
account_number = account.accountNumber
|
||||
check_digits = calc_check_digits(
|
||||
bank_code + branch_code + '00' + account_number)
|
||||
bank_account = to_iban(
|
||||
bank_code + branch_code + check_digits + account_number)
|
||||
journal = Journal.get_by_bank_account(self.start.company, bank_account)
|
||||
journal = Journal.get_by_bank_account(self.start.company, account.iban)
|
||||
if not journal:
|
||||
raise ImportStatementError(
|
||||
gettext('account_statement.msg_import_no_journal',
|
||||
account=bank_account))
|
||||
account=account.iban))
|
||||
|
||||
statement = Statement()
|
||||
statement.name = '%(account)s@(%(start_date)s/%(end_date)s)' % {
|
||||
'account': bank_account,
|
||||
'start_date': account.initialDate,
|
||||
'end_date': account.finalDate,
|
||||
'account': account.ccc,
|
||||
'start_date': account.start_date,
|
||||
'end_date': account.end_date,
|
||||
}
|
||||
statement.company = self.start.company
|
||||
statement.journal = journal
|
||||
statement.start_balance = account.initialBalance
|
||||
statement.end_balance = account.abstract.balance
|
||||
statement.number_of_lines = (
|
||||
account.abstract.incomeEntries + account.abstract.expenseEntries)
|
||||
statement.start_balance = account.initial_balance
|
||||
statement.end_balance = account.final_balance
|
||||
statement.number_of_lines = len(account.transactions)
|
||||
statement.total_amount = (
|
||||
account.abstract.income - account.abstract.expense)
|
||||
account.final_balance - account.initial_balance)
|
||||
return statement
|
||||
|
||||
def aeb43_origin(self, statement, transaction):
|
||||
pool = Pool()
|
||||
Origin = pool.get('account.statement.origin')
|
||||
origin = Origin()
|
||||
origin.date = transaction.transactionDate
|
||||
origin.date = transaction.transaction_date
|
||||
origin.amount = transaction.amount
|
||||
descriptions = []
|
||||
for item in transaction.optionalItems:
|
||||
if item.item1:
|
||||
descriptions.append(item.item1)
|
||||
if item.item2:
|
||||
descriptions.append(item.item2)
|
||||
origin.description = ''.join(descriptions)
|
||||
origin.description = ''.join(transaction.items)
|
||||
origin.information = self.aeb43_information(statement, transaction)
|
||||
return [origin]
|
||||
|
||||
def aeb43_information(self, statement, transaction):
|
||||
return {
|
||||
'aeb43_operation_date': transaction.transactionDate,
|
||||
'aeb43_record_type': transaction.sharedItem,
|
||||
'aeb43_document_number': transaction.documentNumber,
|
||||
'aeb43_operation_date': transaction.transaction_date,
|
||||
'aeb43_record_type': transaction.shared_item,
|
||||
'aeb43_document_number': transaction.document,
|
||||
'aeb43_first_reference': transaction.reference1,
|
||||
'aeb43_second_reference': transaction.reference2,
|
||||
}
|
||||
Reference in new issue
Block a user