Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Le Filament
account_bank_statement_import_bpce
Commits
971eb71e
Commit
971eb71e
authored
Nov 19, 2020
by
Rémi - Le Filament
Browse files
Do not modify data_file which is used by other import methods
parent
bc55fc44
Changes
1
Hide whitespace changes
Inline
Side-by-side
wizard/account_bank_statement_import.py
View file @
971eb71e
...
...
@@ -69,7 +69,6 @@ class AccountBankStatementImport(models.TransientModel):
if
(
test_versionB
==
None
):
# for files generated after december 2017
file_version
=
"version_C"
parse_line_1
=
re
.
compile
(
self
.
regexp_version
[
file_version
][
'line_1'
]).
search
(
data_file
[
0
])
bank_group_code
=
parse_line_1
.
group
(
'bank_group_code'
)
...
...
@@ -85,7 +84,7 @@ class AccountBankStatementImport(models.TransientModel):
opening_balance
=
float
(
re
.
compile
(
self
.
regexp_version
[
file_version
][
'line_opening_balance'
]).
search
(
data_file
[
len
(
data_file
)
-
1
]).
group
(
'balance'
).
replace
(
','
,
'.'
))
except
Exception
as
e
:
_logger
.
error
(
e
)
_logger
.
debug
(
e
)
return
False
return
(
file_version
,
bank_group_code
,
openning_date
,
closing_date
,
bank_account_number
,
opening_balance
,
closing_balance
,
...
...
@@ -93,8 +92,8 @@ class AccountBankStatementImport(models.TransientModel):
@
api
.
model
def
_parse_file
(
self
,
data_file
):
data_file
=
data_file
.
decode
(
'iso-8859-1'
).
splitlines
()
result
=
self
.
_check_file
(
data_file
)
data_file
_split
=
data_file
.
decode
(
'iso-8859-1'
).
splitlines
()
result
=
self
.
_check_file
(
data_file
_split
)
if
not
result
:
return
super
(
AccountBankStatementImport
,
self
).
_parse_file
(
data_file
)
...
...
@@ -104,7 +103,7 @@ class AccountBankStatementImport(models.TransientModel):
total_amt
=
0.00
try
:
index
=
0
for
line
in
data_file
[
5
:
len
(
data_file
)
-
1
]:
for
line
in
data_file
_split
[
5
:
len
(
data_file
_split
)
-
1
]:
transaction
=
re
.
compile
(
self
.
regexp_version
[
file_version
][
'line_debit'
]).
search
(
line
)
if
(
transaction
!=
None
):
transaction_amount
=
float
(
transaction
.
group
(
'debit'
).
replace
(
','
,
'.'
))
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment