diff --git a/account_bank_statement_import_ccoop/__manifest__.py b/account_bank_statement_import_ccoop/__manifest__.py index f995965..30eb56c 100644 --- a/account_bank_statement_import_ccoop/__manifest__.py +++ b/account_bank_statement_import_ccoop/__manifest__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2018 Fabien Bourgeois +# Copyright 2018-2020 Fabien Bourgeois # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -22,7 +22,7 @@ * For CSV published by Crédit Coopératif on their website customer space ; * Adds option on bank import statement wizard ; * Checks and processes file.""", - 'version': '10.0.0.1.3', + 'version': '10.0.0.1.4', 'category': 'Banking addons', 'author': 'Fabien Bourgeois', 'license': 'AGPL-3', diff --git a/account_bank_statement_import_ccoop/wizard/account_bank_statement_import.py b/account_bank_statement_import_ccoop/wizard/account_bank_statement_import.py index 943b118..59d68c1 100644 --- a/account_bank_statement_import_ccoop/wizard/account_bank_statement_import.py +++ b/account_bank_statement_import_ccoop/wizard/account_bank_statement_import.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2018 Fabien Bourgeois +# Copyright 2018-2020 Fabien Bourgeois # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -53,9 +53,13 @@ class AccountBankStatementImport(models.TransientModel): @api.model def _get_coop_transaction(self, account_number, line): """ Prepare transaction line """ + # CCoop format change : old was YY, now YYYY + if len(line[0]) <= 8: + parsed_date = time.strptime(line[0], '%d/%m/%y') + else: + parsed_date = time.strptime(line[0], '%d/%m/%Y') return {'name': line[2] or u'/', - 'date': time.strftime('%Y-%m-%d', - time.strptime(line[0], '%d/%m/%y')), + 'date': time.strftime('%Y-%m-%d', parsed_date), 'amount': str2float(line[3] or line[4]), 'unique_import_id': line[1], 'note': line[5], @@ -68,11 +72,18 @@ class AccountBankStatementImport(models.TransientModel): account_number = data[1][0].split(' : ')[1] if not len(data[-1]): # If last line is empty, remove it data.pop() + # Change in CSV produced from CCoop, now empty last cell + balance_start = data[-1][-1] + balance_end_real = data[3][-1] + if balance_start == '': + balance_start = data[-1][-2] + if balance_end_real == '': + balance_end_real = data[3][-2] bank_statement_data = { 'date': time.strftime( '%Y-%m-%d', time.strptime(data[0][3].split(' : ')[1], '%d/%m/%Y')), - 'balance_start': str2float(data[-1][-1]), - 'balance_end_real': str2float(data[3][-1]) + 'balance_start': str2float(balance_start), + 'balance_end_real': str2float(balance_end_real) } bank_statement_data['name'] = '%s - %s' % (account_number, bank_statement_data['date'])