Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Odoo
Coopdevs OCB mirror
Commits
93127099
Commit
93127099
authored
10 years ago
by
Sabrina Romero
Committed by
Martin Trigaux
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[ADD] base_vat: add VAT validation for Peruvian localization.
parent
a5531c1d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
addons/base_vat/base_vat.py
+37
-1
37 additions, 1 deletion
addons/base_vat/base_vat.py
with
37 additions
and
1 deletion
addons/base_vat/base_vat.py
+
37
−
1
View file @
93127099
...
...
@@ -63,6 +63,7 @@ _ref_vat = {
'
mx
'
:
'
MXABC123456T1B
'
,
'
nl
'
:
'
NL123456782B90
'
,
'
no
'
:
'
NO123456785
'
,
'
pe
'
:
'
PER10254824220 or PED10254824220
'
,
'
pl
'
:
'
PL1234567883
'
,
'
pt
'
:
'
PT123456789
'
,
'
ro
'
:
'
RO1234567897
'
,
...
...
@@ -219,7 +220,7 @@ class res_partner(osv.osv):
return
vat
[
7
]
==
self
.
_ie_check_char
(
vat
[
2
:
7
]
+
vat
[
0
]
+
vat
[
8
])
return
False
# Mexican VAT verification, contributed by
<moylop260@hotmail.com>
# Mexican VAT verification, contributed by
Vauxoo
# and Panos Christeas <p_christ@hol.gr>
__check_vat_mx_re
=
re
.
compile
(
r
"
(?P<primeras>[A-Za-z\xd1\xf1&]{3,4})
"
\
r
"
[ \-_]?
"
\
...
...
@@ -276,6 +277,41 @@ class res_partner(osv.osv):
return
False
return
check
==
int
(
vat
[
8
])
# Peruvian VAT validation, contributed by Vauxoo
def
check_vat_pe
(
self
,
vat
):
vat_type
,
vat
=
vat
and
len
(
vat
)
>=
2
and
(
vat
[
0
],
vat
[
1
:])
or
(
False
,
False
)
if
vat_type
and
vat_type
.
upper
()
==
'
D
'
:
#DNI
return
True
elif
vat_type
and
vat_type
.
upper
()
==
'
R
'
:
#verify RUC
factor
=
'
5432765432
'
sum
=
0
dig_check
=
False
if
len
(
vat
)
!=
11
:
return
False
try
:
int
(
vat
)
except
ValueError
:
return
False
for
f
in
range
(
0
,
10
):
sum
+=
int
(
factor
[
f
])
*
int
(
vat
[
f
])
subtraction
=
11
-
(
sum
%
11
)
if
subtraction
==
10
:
dig_check
=
0
elif
subtraction
==
11
:
dig_check
=
1
else
:
dig_check
=
subtraction
return
int
(
vat
[
10
])
==
dig_check
else
:
return
False
res_partner
()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment