[FIX]Account Bank Statement Import CCoop : handling new CSV format
* Empty last cells on balance lines ; * New year with YYYY (old : YY).
This commit is contained in:
parent
c5e3aff7df
commit
c01a61ba1c
@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright 2018 Fabien Bourgeois <fabien@yaltik.com>
|
# Copyright 2018-2020 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Affero General Public License as
|
# 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 ;
|
* For CSV published by Crédit Coopératif on their website customer space ;
|
||||||
* Adds option on bank import statement wizard ;
|
* Adds option on bank import statement wizard ;
|
||||||
* Checks and processes file.""",
|
* Checks and processes file.""",
|
||||||
'version': '10.0.0.1.3',
|
'version': '10.0.0.1.4',
|
||||||
'category': 'Banking addons',
|
'category': 'Banking addons',
|
||||||
'author': 'Fabien Bourgeois',
|
'author': 'Fabien Bourgeois',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright 2018 Fabien Bourgeois <fabien@yaltik.com>
|
# Copyright 2018-2020 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Affero General Public License as
|
# it under the terms of the GNU Affero General Public License as
|
||||||
@ -53,9 +53,13 @@ class AccountBankStatementImport(models.TransientModel):
|
|||||||
@api.model
|
@api.model
|
||||||
def _get_coop_transaction(self, account_number, line):
|
def _get_coop_transaction(self, account_number, line):
|
||||||
""" Prepare transaction 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'/',
|
return {'name': line[2] or u'/',
|
||||||
'date': time.strftime('%Y-%m-%d',
|
'date': time.strftime('%Y-%m-%d', parsed_date),
|
||||||
time.strptime(line[0], '%d/%m/%y')),
|
|
||||||
'amount': str2float(line[3] or line[4]),
|
'amount': str2float(line[3] or line[4]),
|
||||||
'unique_import_id': line[1],
|
'unique_import_id': line[1],
|
||||||
'note': line[5],
|
'note': line[5],
|
||||||
@ -68,11 +72,18 @@ class AccountBankStatementImport(models.TransientModel):
|
|||||||
account_number = data[1][0].split(' : ')[1]
|
account_number = data[1][0].split(' : ')[1]
|
||||||
if not len(data[-1]): # If last line is empty, remove it
|
if not len(data[-1]): # If last line is empty, remove it
|
||||||
data.pop()
|
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 = {
|
bank_statement_data = {
|
||||||
'date': time.strftime(
|
'date': time.strftime(
|
||||||
'%Y-%m-%d', time.strptime(data[0][3].split(' : ')[1], '%d/%m/%Y')),
|
'%Y-%m-%d', time.strptime(data[0][3].split(' : ')[1], '%d/%m/%Y')),
|
||||||
'balance_start': str2float(data[-1][-1]),
|
'balance_start': str2float(balance_start),
|
||||||
'balance_end_real': str2float(data[3][-1])
|
'balance_end_real': str2float(balance_end_real)
|
||||||
}
|
}
|
||||||
bank_statement_data['name'] = '%s - %s' % (account_number,
|
bank_statement_data['name'] = '%s - %s' % (account_number,
|
||||||
bank_statement_data['date'])
|
bank_statement_data['date'])
|
||||||
|
Loading…
Reference in New Issue
Block a user