mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
[IMP] account_statement_transactionid_import: Fix PEP8
This commit is contained in:
@@ -19,42 +19,40 @@
|
|||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
{'name': "Bank statement transactionID import",
|
{
|
||||||
'version': '1.0',
|
'name': "Bank statement transactionID import",
|
||||||
'author': 'Camptocamp',
|
'version': '1.0',
|
||||||
'maintainer': 'Camptocamp',
|
'author': 'Camptocamp',
|
||||||
'category': 'Finance',
|
'maintainer': 'Camptocamp',
|
||||||
'complexity': 'normal',
|
'category': 'Finance',
|
||||||
'depends': [
|
'complexity': 'normal',
|
||||||
'account_statement_base_import',
|
'depends': [
|
||||||
'account_statement_transactionid_completion'
|
'account_statement_base_import',
|
||||||
],
|
'account_statement_transactionid_completion'
|
||||||
'description': """
|
],
|
||||||
|
'description': """
|
||||||
This module brings generic methods and fields on bank statement to deal with
|
This module brings generic methods and fields on bank statement to deal with
|
||||||
the importation of different bank and offices that uses transactionID.
|
the importation of different bank and offices that uses transactionID.
|
||||||
|
|
||||||
This module allows you to import your bank transactions with a standard .csv or .xls file
|
This module allows you to import your bank transactions with a standard .csv
|
||||||
(you'll find samples in the 'data' folder). It respects the chosen profile
|
or .xls file (you'll find samples in the 'data' folder). It respects the chosen
|
||||||
(model provided by the account_statement_ext module) to generate the entries.
|
profile (model provided by the account_statement_ext module) to generate the
|
||||||
|
entries.
|
||||||
|
|
||||||
This module can handle a commission taken by the payment office and has the following format:
|
This module can handle a commission taken by the payment office and has the
|
||||||
|
following format:
|
||||||
|
|
||||||
* transaction_id: the transaction ID given by the bank/office. It is used as reference
|
* transaction_id: the transaction ID given by the bank/office. It is used as
|
||||||
in the generated entries and is useful for reconciliation process
|
reference in the generated entries and is useful for reconciliation process
|
||||||
* date: date of the payment
|
* date: date of the payment
|
||||||
* amount: amount paid in the currency of the journal used in the importation profile
|
* amount: amount paid in the currency of the journal used in the importation
|
||||||
|
profile
|
||||||
* commission_amount: amount of the comission for each line
|
* commission_amount: amount of the comission for each line
|
||||||
* label: the comunication given by the payment office, used as communication in the
|
* label: the comunication given by the payment office, used as communication in
|
||||||
generated entries.
|
the generated entries.
|
||||||
""",
|
""",
|
||||||
'website': 'http://www.camptocamp.com',
|
'website': 'http://www.camptocamp.com',
|
||||||
'init_xml': [],
|
'installable': True,
|
||||||
'update_xml': [
|
'auto_install': False,
|
||||||
],
|
'license': 'AGPL-3',
|
||||||
'demo_xml': [],
|
}
|
||||||
'test': [],
|
|
||||||
'installable': True,
|
|
||||||
'images': [],
|
|
||||||
'auto_install': False,
|
|
||||||
'license': 'AGPL-3',
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -22,24 +22,24 @@ from account_statement_base_import.parser.file_parser import FileParser
|
|||||||
|
|
||||||
|
|
||||||
class TransactionIDFileParser(FileParser):
|
class TransactionIDFileParser(FileParser):
|
||||||
|
"""TransactionID parser that use a define format in csv or xls to import
|
||||||
"""
|
|
||||||
TransactionID parser that use a define format in csv or xls to import
|
|
||||||
bank statement.
|
bank statement.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, profile, ftype='csv', extra_fields=None, header=None, **kwargs):
|
def __init__(self, profile, ftype='csv', extra_fields=None, header=None,
|
||||||
"""
|
**kwargs):
|
||||||
Add transaction_id in header keys
|
"""Add transaction_id in header keys
|
||||||
:param char: profile: Reference to the profile
|
:param char: profile: Reference to the profile
|
||||||
:param char: ftype: extension of the file (could be csv or xls)
|
:param char: ftype: extension of the file (could be csv or xls)
|
||||||
:param dict: extra_fields: extra fields to add to the conversion dict. In the format
|
:param dict: extra_fields: extra fields to add to the conversion \
|
||||||
{fieldname: fieldtype}
|
dict. In the format {fieldname: fieldtype}
|
||||||
:param list: header : specify header fields if the csv file has no header
|
:param list: header : specify header fields if the csv file has no \
|
||||||
"""
|
header
|
||||||
|
"""
|
||||||
extra_fields = {'transaction_id': unicode}
|
extra_fields = {'transaction_id': unicode}
|
||||||
super(TransactionIDFileParser, self).__init__(profile, extra_fields=extra_fields,
|
super(TransactionIDFileParser, self).__init__(
|
||||||
ftype=ftype, header=header, **kwargs)
|
profile, extra_fields=extra_fields, ftype=ftype, header=header,
|
||||||
|
**kwargs)
|
||||||
# ref is replaced by transaction_id thus we delete it from check
|
# ref is replaced by transaction_id thus we delete it from check
|
||||||
self.keys_to_validate = [
|
self.keys_to_validate = [
|
||||||
k for k in self.keys_to_validate if k != 'ref']
|
k for k in self.keys_to_validate if k != 'ref']
|
||||||
@@ -47,21 +47,20 @@ class TransactionIDFileParser(FileParser):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def parser_for(cls, parser_name):
|
def parser_for(cls, parser_name):
|
||||||
"""
|
"""Used by the new_bank_statement_parser class factory. Return true if
|
||||||
Used by the new_bank_statement_parser class factory. Return true if
|
|
||||||
the providen name is generic_csvxls_transaction
|
the providen name is generic_csvxls_transaction
|
||||||
"""
|
"""
|
||||||
return parser_name == 'generic_csvxls_transaction'
|
return parser_name == 'generic_csvxls_transaction'
|
||||||
|
|
||||||
def get_st_line_vals(self, line, *args, **kwargs):
|
def get_st_line_vals(self, line, *args, **kwargs):
|
||||||
"""
|
"""This method must return a dict of vals that can be passed to create
|
||||||
This method must return a dict of vals that can be passed to create
|
|
||||||
method of statement line in order to record it. It is the responsibility
|
method of statement line in order to record it. It is the responsibility
|
||||||
of every parser to give this dict of vals, so each one can implement his
|
of every parser to give this dict of vals, so each one can implement his
|
||||||
own way of recording the lines.
|
own way of recording the lines.
|
||||||
:param: line: a dict of vals that represent a line of result_row_list
|
:param: line: a dict of vals that represent a line of \
|
||||||
:return: dict of values to give to the create method of statement line,
|
result_row_\list
|
||||||
it MUST contain at least:
|
:return: dict of values to give to the create method of statement \
|
||||||
|
line, it MUST contain at least:
|
||||||
{
|
{
|
||||||
'name':value,
|
'name':value,
|
||||||
'date':value,
|
'date':value,
|
||||||
@@ -70,13 +69,15 @@ class TransactionIDFileParser(FileParser):
|
|||||||
'label':value,
|
'label':value,
|
||||||
'commission_amount':value,
|
'commission_amount':value,
|
||||||
}
|
}
|
||||||
In this generic parser, the commission is given for every line, so we store it
|
In this generic parser, the commission is given for every line, so we
|
||||||
for each one.
|
store it for each one.
|
||||||
"""
|
"""
|
||||||
return {'name': line.get('label', line.get('ref', '/')),
|
return {
|
||||||
'date': line.get('date', datetime.datetime.now().date()),
|
'name': line.get('label', line.get('ref', '/')),
|
||||||
'amount': line.get('amount', 0.0),
|
'date': line.get('date', datetime.datetime.now().date()),
|
||||||
'ref': line.get('transaction_id', '/'),
|
'amount': line.get('amount', 0.0),
|
||||||
'label': line.get('label', ''),
|
'ref': line.get('transaction_id', '/'),
|
||||||
'transaction_id': line.get('transaction_id', '/'),
|
'label': line.get('label', ''),
|
||||||
'commission_amount': line.get('commission_amount', 0.0)}
|
'transaction_id': line.get('transaction_id', '/'),
|
||||||
|
'commission_amount': line.get('commission_amount', 0.0)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user