Skip to main content

A DV calculator for Panama RUC

Project description

Panama RUC DV Calculator

Documentación en español aquí.

For questions and issues, please open an issue on the GitHub repository at https://github.com/juancorradine/panama-ruc-dv-calculator.

Description

Checksum (DV) calculator for RUCs (Unique Taxpayer Registry) in Panama.

You need to know the type of RUC in order to initialize the correct class since it's not always possible to determine the type just by having the RUC number. The algorithm to calculate the DV varies depending on the RUC type.

If the RUC does not have the correct format, a ValueError exception is raised.

Supported RUC Types:

  • Persona Natural
  • Persona Natural Extranjera (E)
  • Persona Natural Naturalizada (N)
  • Persona Natural Panameño Extranjero (PE)
  • Persona Natural Antes de Vigencia (AV)
  • Persona Natural Panameño Indigena (PI)
  • Persona Natural NT
  • Persona Juridica
  • Persona Juridica Antigua
  • Persona Juridica NT

Python classes:

  • RucNatural (Supports E, N, PE, AV y PI)
  • RUCNaturalNT
  • RUCJuridica (Supports RUC Juridica Antiguo)
  • RUCJuridicaNT

Installation:

pip install panama-ruc-dv-calculator

Usage examples:

More xamples in the examples directory.

#1 - Persona Natural

from panama_ruc_dv_calculator.ruc_natural import RucNatural

try:
    ruc = RucNatural("1-184-921")

    print(f"RUC:           {ruc.ruc}")
    print(f"DV:            {ruc.dv}")
    print(f"Provincia:     {ruc.provincia.nombre}")
    print(f"Letra:         {ruc.letra.letra}")
    print(f"Letra Desc:    {ruc.letra.nombre}")
    print(f"Folio/Imagen:  {ruc.folio_imagen}")
    print(f"Asiento/Ficha: {ruc.asiento_ficha}")
    
except ValueError as e:
    print(str(e))

Results:

RUC:           1-184-921
DV:            49
Provincia:     Bocas Del Toro
Letra:         
Letra Desc:    Sin Letra
Folio/Imagen:  184
Asiento/Ficha: 921

#2 - Persona Juridica

from panama_ruc_dv_calculator.ruc_juridica import RucJuridica

try:
    ruc = RucJuridica("2588017-1-831938")

    print(f"RUC:             {ruc.ruc}")
    print(f"DV:              {ruc.dv}")
    print(f"Rollo/Tomo:      {ruc.rollo_tomo}")
    print(f"Folio/Imagen:    {ruc.folio_imagen}")
    print(f"Asiento/Ficha:   {ruc.asiento_ficha}")
    print(f"Es RUC Antiguo?: {str(ruc.is_ruc_antiguo)}")
    
except ValueError as e:
    print(str(e))

Results:

RUC:             2588017-1-831938
DV:              20
Rollo/Tomo:      2588017
Folio/Imagen:    1
Asiento/Ficha:   831938
Es RUC Antiguo?: False

DV Calculation Testing and Validation:

DV calculation tests in the tests directory.

To validate other generated DVs, you can use the DGI page > ETax 2.0 > Digit Verifier.

Documentación DGI

The file Calculo Digito Verificador RUC issued by the DGI, located in the dgi folder, explains the algorithm for generating the DV.

Pending tasks

  • DV generation for fincas.
  • On the page of the DGI for DV validation, there are the letters SB and EE. There is no documentation on what these letters mean or the algorithm to calculate their DV.

Disclaimer

I do not work for the DGI. This code may contain errors. It is your responsibility to perform the relevant tests.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

panama-ruc-dv-calculator-1.0.2.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

panama_ruc_dv_calculator-1.0.2-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file panama-ruc-dv-calculator-1.0.2.tar.gz.

File metadata

File hashes

Hashes for panama-ruc-dv-calculator-1.0.2.tar.gz
Algorithm Hash digest
SHA256 6fd0030221d026aa7c59e309fa776fd2a7d3f21be3877ac6751ba164fee42e5f
MD5 5d6af9dff87233e82ea5a046e121aa70
BLAKE2b-256 b908b1324786d0ee71481a8c2165e672fe006b24ab00617a3f6dd1ad68d1786d

See more details on using hashes here.

File details

Details for the file panama_ruc_dv_calculator-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for panama_ruc_dv_calculator-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7af0086c1ea44c38d754d813859ac06579b0f3daa39ff1535b93be32e48f50c1
MD5 f7eed1b1cb85156dac929cb79289ec88
BLAKE2b-256 fbc051932e2332df515d06846b66416e5cd2ba372c6ee4f0c3d60eb736936d48

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page