Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
weboob
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
177
Issues
177
List
Boards
Labels
Milestones
Merge Requests
49
Merge Requests
49
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
weboob
weboob
Commits
649d777a
Commit
649d777a
authored
Aug 29, 2014
by
Oleg Plakhotniuk
Committed by
Romain Bignon
Aug 30, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Transaction amounts cleaner helper for american banks.
Signed-off-by:
Oleg Plakhotniuk
<
olegus8@gmail.com
>
parent
449ea03f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
setup.cfg
setup.cfg
+1
-0
weboob/tools/capabilities/bank/transactions.py
weboob/tools/capabilities/bank/transactions.py
+24
-0
No files found.
setup.cfg
View file @
649d777a
...
...
@@ -4,6 +4,7 @@ detailed-errors = 1
with-doctest = 1
where = weboob
tests = weboob.capabilities.bank,
weboob.tools.capabilities.bank.transactions,
weboob.tools.capabilities.paste,
weboob.tools.application.formatters.json,
weboob.tools.application.formatters.table,
...
...
weboob/tools/capabilities/bank/transactions.py
View file @
649d777a
...
...
@@ -315,3 +315,27 @@ class FrenchTransaction(Transaction):
pass
return
Decimal
(
'0'
)
class
AmericanTransaction
(
Transaction
):
"""
Transaction with some helpers for american bank websites.
"""
@
classmethod
def
clean_amount
(
klass
,
text
):
"""
Clean a string containing an amount.
"""
# Convert "American" UUU.CC format to "French" UUU,CC format
if
re
.
search
(
r'\d\.\d\d(?: [A-Z]+)?$'
,
text
):
text
=
text
.
replace
(
','
,
' '
)
.
replace
(
'.'
,
','
)
return
FrenchTransaction
.
clean_amount
(
text
)
def
test
():
clean_amount
=
AmericanTransaction
.
clean_amount
assert
clean_amount
(
'42'
)
==
'42'
assert
clean_amount
(
'42,12'
)
==
'42.12'
assert
clean_amount
(
'42.12'
)
==
'42.12'
assert
clean_amount
(
'$42.12 USD'
)
==
'42.12'
assert
clean_amount
(
'$12.442,12 USD'
)
==
'12442.12'
assert
clean_amount
(
'$12,442.12 USD'
)
==
'12442.12'
Write
Preview
Markdown
is supported
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