Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sven Franck
erp5
Commits
06753911
Commit
06753911
authored
Nov 28, 2013
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add validators for IBAN & BIC
parent
b4043cf5
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
249 additions
and
1 deletion
+249
-1
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/BankAccount_validateBIC.xml
...teItem/portal_skins/erp5_base/BankAccount_validateBIC.xml
+81
-0
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/BankAccount_validateIBAN.xml
...eItem/portal_skins/erp5_base/BankAccount_validateIBAN.xml
+140
-0
bt5/erp5_base/bt/revision
bt5/erp5_base/bt/revision
+1
-1
product/ERP5/tests/testERP5Base.py
product/ERP5/tests/testERP5Base.py
+27
-0
No files found.
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/BankAccount_validateBIC.xml
0 → 100644
View file @
06753911
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
"""External Validator for BIC on bank account\n
"""\n
if not editor:\n
return True\n
\n
if len(editor) not in (8, 11):\n
return False\n
\n
if not editor[:5].isalpha():\n
return False\n
\n
if not editor[5:].isalnum():\n
return False\n
\n
return True\n
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
editor, request
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
BankAccount_validateBIC
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/BankAccount_validateIBAN.xml
0 → 100644
View file @
06753911
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
"""External Validator for IBAN on bank account\n
"""\n
import string\n
if not editor:\n
return True\n
\n
editor = editor.replace(\' \', \'\').upper()\n
country_code = editor[:2]\n
checksum = editor[2:4]\n
bban = editor[4:]\n
\n
iban_len_dict = {\n
\'AD\': 24,\n
\'AT\': 20,\n
\'BA\': 20,\n
\'BE\': 16,\n
\'BG\': 22,\n
\'CH\': 21,\n
\'CY\': 28,\n
\'CZ\': 24,\n
\'DE\': 22,\n
\'DK\': 18,\n
\'EE\': 20,\n
\'ES\': 24,\n
\'FI\': 18,\n
\'FO\': 18,\n
\'FR\': 27,\n
\'GB\': 22,\n
\'GI\': 23,\n
\'GL\': 18,\n
\'GR\': 27,\n
\'HR\': 21,\n
\'HU\': 28,\n
\'IE\': 22,\n
\'IL\': 23,\n
\'IS\': 26,\n
\'IT\': 27,\n
\'LI\': 21,\n
\'LT\': 20,\n
\'LU\': 20,\n
\'LV\': 21,\n
\'MA\': 24,\n
\'MC\': 27,\n
\'ME\': 22,\n
\'MK\': 19,\n
\'MT\': 31,\n
\'NL\': 18,\n
\'NO\': 15,\n
\'PL\': 28,\n
\'PT\': 25,\n
\'RO\': 24,\n
\'RS\': 22,\n
\'SE\': 24,\n
\'SI\': 19,\n
\'SK\': 24,\n
\'SM\': 27,\n
\'TN\': 24,\n
\'TR\': 26\n
}\n
\n
if len(editor) != iban_len_dict.get(country_code, -1):\n
return False\n
\n
letter_code_dict = dict( zip(string.ascii_uppercase, range(10,36)) )\n
\n
iban_code = \'\'.join([str(letter_code_dict.get(x, x))\n
for x in bban + country_code + checksum])\n
\n
try:\n
iban_int = int(iban_code)\n
except ValueError:\n
return False\n
\n
return iban_int % 97 == 1\n
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
editor, request
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
BankAccount_validateIBAN
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_base/bt/revision
View file @
06753911
1052
1053
\ No newline at end of file
\ No newline at end of file
product/ERP5/tests/testERP5Base.py
View file @
06753911
...
@@ -1386,6 +1386,33 @@ class TestERP5Base(ERP5TypeTestCase):
...
@@ -1386,6 +1386,33 @@ class TestERP5Base(ERP5TypeTestCase):
# edit content_type on document which has no content_type property configured
# edit content_type on document which has no content_type property configured
person
.
edit
(
content_type
=
'text/xml'
)
person
.
edit
(
content_type
=
'text/xml'
)
def
test_BankAccount_validateIBAN
(
self
):
self
.
assertTrue
(
self
.
portal
.
BankAccount_validateIBAN
(
'GR1601101250000000012300695'
,
request
=
None
))
# spaces are allowed
self
.
assertTrue
(
self
.
portal
.
BankAccount_validateIBAN
(
'GR16 0110 1250 0000 0001 2300 695'
,
request
=
None
))
self
.
assertFalse
(
self
.
portal
.
BankAccount_validateIBAN
(
'GR16 0110 1250 0000 0001 2300 696'
,
request
=
None
))
self
.
assertFalse
(
self
.
portal
.
BankAccount_validateIBAN
(
'12345'
,
request
=
None
))
def
test_BankAccount_validateBIC
(
self
):
self
.
assertTrue
(
self
.
portal
.
BankAccount_validateBIC
(
'DEUTDEFF'
,
request
=
None
))
self
.
assertTrue
(
self
.
portal
.
BankAccount_validateBIC
(
'NEDSZAJJ'
,
request
=
None
))
self
.
assertFalse
(
self
.
portal
.
BankAccount_validateBIC
(
'X'
,
request
=
None
))
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestERP5Base
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestERP5Base
))
...
...
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