Merge lp:~vauxoo/openobject-addons/7.0_addons_base_vat_peru_dev_jorge into lp:openobject-addons/7.0

Status: Needs review
Proposed branch: lp:~vauxoo/openobject-addons/7.0_addons_base_vat_peru_dev_jorge
Merge into: lp:openobject-addons/7.0
Diff against target: 62 lines (+37/-1)
1 file modified
base_vat/base_vat.py (+37/-1)
To merge this branch: bzr merge lp:~vauxoo/openobject-addons/7.0_addons_base_vat_peru_dev_jorge
Reviewer Review Type Date Requested Status
Moisés López - http://www.vauxoo.com (community) 2014-06-03 Approve on 2014-06-25
Jorge Angel Naranjo Rogel - http://www.vauxoo.com (community) Resubmit on 2014-06-23
Nhomar - Vauxoo 2014-06-03 Pending
Sabrina Romero - http://www.vauxoo.com 2014-06-03 Pending
Review via email: mp+221817@code.launchpad.net

Description of the change

Validation of the RUC is added to peru in field vat

To post a comment you must log in.
10065. By Jorge Angel Naranjo Rogel - http://www.vauxoo.com on 2014-06-20

[FIX][base_vat] Changed validation for RUC aUC and DNI, this changed was add R or D in vat

10066. By Jorge Angel Naranjo Rogel - http://www.vauxoo.com on 2014-06-23

[MERGE] Merge from lp:openobject-addons/7.0

@Jorge,
Cambia la autoría a "...by Vauxoo", por favor.

Y además, agrega la validacion explícita para ambos algoritmos de RUC o DNI, de la siguiente forma.

if vat[0].upper() == 'D':
            return True
elif vat[0].upper() == 'R':
      #verify RUC
else:
   False

review: Needs Fixing
10067. By Jorge Angel Naranjo Rogel - http://www.vauxoo.com on 2014-06-23

[IMP][base_vat] Validate R in Vat and changanged contibutions by Vauxoo

10068. By Jorge Angel Naranjo Rogel - http://www.vauxoo.com on 2014-06-23

[IMP][base_vat] Add coments

Se agrega la validación si es un RUC (R) o si es DNI (D). En caso contario retornara un False

review: Resubmit
Download full text (4.5 KiB)

Error si capturo PE, solito. :(

Client Traceback (most recent call last):
  File "/home/runbotns/runbot7_vauxoo_stable/openerp-runbot/static/vauxoo-private-testall-opl-clubj-264/server/openerp/addons/web/http.py", line 204, in dispatch
    response["result"] = method(self, **self.params)
  File "/home/runbotns/runbot7_vauxoo_stable/openerp-runbot/static/vauxoo-private-testall-opl-clubj-264/server/openerp/addons/web/controllers/main.py", line 1128, in call_kw
    return self._call_kw(req, model, method, args, kwargs)
  File "/home/runbotns/runbot7_vauxoo_stable/openerp-runbot/static/vauxoo-private-testall-opl-clubj-264/server/openerp/addons/web/controllers/main.py", line 1120, in _call_kw
    return getattr(req.session.model(model), method)(*args, **kwargs)
  File "/home/runbotns/runbot7_vauxoo_stable/openerp-runbot/static/vauxoo-private-testall-opl-clubj-264/server/openerp/addons/web/session.py", line 42, in proxy
    result = self.proxy.execute_kw(self.session._db, self.session._uid, self.session._password, self.model, method, args, kw)
  File "/home/runbotns/runbot7_vauxoo_stable/openerp-runbot/static/vauxoo-private-testall-opl-clubj-264/server/openerp/addons/web/session.py", line 30, in proxy_method
    result = self.session.send(self.service_name, method, *args)
  File "/home/runbotns/runbot7_vauxoo_stable/openerp-runbot/static/vauxoo-private-testall-opl-clubj-264/server/openerp/addons/web/session.py", line 103, in send
    raise xmlrpclib.Fault(openerp.tools.ustr(e), formatted_info)

Server Traceback (most recent call last):
  File "/home/runbotns/runbot7_vauxoo_stable/openerp-runbot/static/vauxoo-private-testall-opl-clubj-264/server/openerp/addons/web/session.py", line 89, in send
    return openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/home/runbotns/runbot7_vauxoo_stable/openerp-runbot/static/vauxoo-private-testall-opl-clubj-264/server/openerp/netsvc.py", line 296, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/home/runbotns/runbot7_vauxoo_stable/openerp-runbot/static/vauxoo-private-testall-opl-clubj-264/server/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/home/runbotns/runbot7_vauxoo_stable/openerp-runbot/static/vauxoo-private-testall-opl-clubj-264/server/openerp/osv/osv.py", line 190, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/home/runbotns/runbot7_vauxoo_stable/openerp-runbot/static/vauxoo-private-testall-opl-clubj-264/server/openerp/osv/osv.py", line 132, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/runbotns/runbot7_vauxoo_stable/openerp-runbot/static/vauxoo-private-testall-opl-clubj-264/server/openerp/osv/osv.py", line 199, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/runbotns/runbot7_vauxoo_stable/openerp-runbot/static/vauxoo-private-testall-opl-clubj-264/server/openerp/osv/osv.py", line 187, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/runbotns/runbot7_vauxoo_stable/openerp-runbot/static/vauxoo-private-testall-opl-clubj-264/server/openerp/addons/base/res/res...

Read more...

10069. By Jorge Angel Naranjo Rogel - http://www.vauxoo.com on 2014-06-23

[FIX][base_vat] Fixed error when you write only PE in vat

@Moy

Se corrige el error cuando solamente es mandando el PE en VAT

review: Resubmit

@Jorge,
Algo le pasó a launchpad, que no tomó tu commit...

Por mi aprobado

review: Approve

NOTA: Se migrará este branch a github.

Unmerged revisions

10069. By Jorge Angel Naranjo Rogel - http://www.vauxoo.com on 2014-06-23

[FIX][base_vat] Fixed error when you write only PE in vat

10068. By Jorge Angel Naranjo Rogel - http://www.vauxoo.com on 2014-06-23

[IMP][base_vat] Add coments

10067. By Jorge Angel Naranjo Rogel - http://www.vauxoo.com on 2014-06-23

[IMP][base_vat] Validate R in Vat and changanged contibutions by Vauxoo

10066. By Jorge Angel Naranjo Rogel - http://www.vauxoo.com on 2014-06-23

[MERGE] Merge from lp:openobject-addons/7.0

10065. By Jorge Angel Naranjo Rogel - http://www.vauxoo.com on 2014-06-20

[FIX][base_vat] Changed validation for RUC aUC and DNI, this changed was add R or D in vat

10064. By Jorge Angel Naranjo Rogel - http://www.vauxoo.com on 2014-06-02

[ADD][base_vat] Add RUC validation of Peru

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'base_vat/base_vat.py' (properties changed: -x to +x)
2--- base_vat/base_vat.py 2014-02-13 14:12:46 +0000
3+++ base_vat/base_vat.py 2014-06-24 14:17:41 +0000
4@@ -63,6 +63,7 @@
5 'mx': 'MXABC123456T1B',
6 'nl': 'NL123456782B90',
7 'no': 'NO123456785',
8+ 'pe': 'PER10254824220 or PED10254824220',
9 'pl': 'PL1234567883',
10 'pt': 'PT123456789',
11 'ro': 'RO1234567897',
12@@ -219,7 +220,7 @@
13 return vat[7] == self._ie_check_char(vat[2:7] + vat[0] + vat[8])
14 return False
15
16- # Mexican VAT verification, contributed by <moylop260@hotmail.com>
17+ # Mexican VAT verification, contributed by Vauxoo
18 # and Panos Christeas <p_christ@hol.gr>
19 __check_vat_mx_re = re.compile(r"(?P<primeras>[A-Za-z\xd1\xf1&]{3,4})" \
20 r"[ \-_]?" \
21@@ -276,6 +277,41 @@
22 return False
23 return check == int(vat[8])
24
25+ # Perú RUC verification, contributed by Vauxoo
26+ def check_vat_pe(self,vat):
27+
28+ vat_type,vat = vat and len(vat)>=2 and (vat[0], vat[1:]) or (False, False)
29+
30+ if vat_type and vat_type.upper() == 'D':
31+ #DNI
32+ return True
33+ elif vat_type and vat_type.upper() == 'R':
34+ #verify RUC
35+ factor = '5432765432'
36+ sum = 0
37+ dig_check = False
38+ if len(vat) != 11:
39+ return False
40+ try:
41+ int(vat)
42+ except ValueError:
43+ return False
44+
45+ for f in range(0,10):
46+ sum += int(factor[f]) * int(vat[f])
47+
48+ subtraction = 11 - (sum % 11)
49+ if subtraction == 10:
50+ dig_check = 0
51+ elif subtraction == 11:
52+ dig_check = 1
53+ else:
54+ dig_check = subtraction
55+
56+ return int(vat[10]) == dig_check
57+ else:
58+ return False
59+
60 res_partner()
61
62 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: