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 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 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.1.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

panama_ruc_dv_calculator-1.0.1-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for panama-ruc-dv-calculator-1.0.1.tar.gz
Algorithm Hash digest
SHA256 a6e88ba4bc600fcd55fe7a0e91f06db8d12bec5a4a2cece38f88e85632c7af86
MD5 679d55805ade24aa0cdf530fb0a13684
BLAKE2b-256 7f9463d96669efec3979581afce6be1934f21bbed413df62162f07b7409ae081

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panama_ruc_dv_calculator-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7914cbb71a87a2581b7204477cc7549c52d7f22ac2487a147ae712e99e6ee372
MD5 1acd46243de2f9d136cbadc3bf897a67
BLAKE2b-256 fd2fd9210ca62bc07c071c156e2520189cd6a52745e88b192e06f664bde64f8b

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