banking-addons-team team mailing list archive
-
banking-addons-team team
-
Mailing list archive
-
Message #01051
lp:~camptocamp/banking-addons/bank-statement-reconcile-70-fix-1248616-yvr into lp:banking-addons/bank-statement-reconcile-7.0
Yannick Vaucher @ Camptocamp has proposed merging lp:~camptocamp/banking-addons/bank-statement-reconcile-70-fix-1248616-yvr into lp:banking-addons/bank-statement-reconcile-7.0.
Requested reviews:
Banking Addons Core Editors (banking-addons-team)
Related bugs:
Bug #1248616 in Banking Addons: "[7.0] account_statement_transactionid_import - file parser doesn't match specifications of account_statement_base_import"
https://bugs.launchpad.net/banking-addons/+bug/1248616
For more details, see:
https://code.launchpad.net/~camptocamp/banking-addons/bank-statement-reconcile-70-fix-1248616-yvr/+merge/194186
Adapt to extraction of account_statement_commission
--
https://code.launchpad.net/~camptocamp/banking-addons/bank-statement-reconcile-70-fix-1248616-yvr/+merge/194186
Your team Banking Addons Core Editors is requested to review the proposed merge of lp:~camptocamp/banking-addons/bank-statement-reconcile-70-fix-1248616-yvr into lp:banking-addons/bank-statement-reconcile-7.0.
=== modified file 'account_statement_transactionid_import/parser/transactionid_file_parser.py'
--- account_statement_transactionid_import/parser/transactionid_file_parser.py 2013-04-24 10:44:39 +0000
+++ account_statement_transactionid_import/parser/transactionid_file_parser.py 2013-11-06 16:38:40 +0000
@@ -27,16 +27,21 @@
bank statement.
"""
- def __init__(self, parse_name, ftype='csv'):
- conversion_dict = {'transaction_id': unicode,
- 'label': unicode,
- 'date': datetime.datetime,
- 'amount': float,
- 'commission_amount': float}
- # Order of cols does not matter but first row of the file has to be header
- keys_to_validate = ['transaction_id', 'label', 'date', 'amount', 'commission_amount']
- super(TransactionIDFileParser, self).__init__(parse_name, keys_to_validate=keys_to_validate,
- ftype=ftype, conversion_dict=conversion_dict)
+ def __init__(self, parse_name, ftype='csv', extra_fields=None, header=None, **kwargs):
+ """
+ Add transaction_id in header keys
+ :param char: parse_name: The name of the parser
+ :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
+ {fieldname: fieldtype}
+ :param list: header : specify header fields if the csv file has no header
+ """
+ extra_fields = {'transaction_id': unicode}
+ super(TransactionIDFileParser, self).__init__(parse_name, extra_fields=extra_fields,
+ ftype=ftype, header=header, **kwargs)
+ # ref is replaced by transaction_id thus we delete it from check
+ self.keys_to_validate = [k for k in self.keys_to_validate if k != 'ref']
+ del self.conversion_dict['ref']
@classmethod
def parser_for(cls, parser_name):
@@ -73,14 +78,3 @@
'label': line.get('label', ''),
'transaction_id': line.get('transaction_id', '/'),
'commission_amount': line.get('commission_amount', 0.0)}
-
- def _post(self, *args, **kwargs):
- """
- Compute the commission from value of each line
- """
- res = super(TransactionIDFileParser, self)._post(*args, **kwargs)
- val = 0.0
- for row in self.result_row_list:
- val += row.get('commission_amount', 0.0)
- self.commission_global_amount = val
- return res
Follow ups