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

Uploaded Source

Built Distribution

panama_ruc_dv_calculator-1.0.4-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for panama-ruc-dv-calculator-1.0.4.tar.gz
Algorithm Hash digest
SHA256 b896254954c07add0ff4bb72c3caf1cd0348937644bb913f2f1b663408fb9094
MD5 007bf0335dc823f4cdc5925b31f1aad1
BLAKE2b-256 91f3692d31d6fb3d098435c04fd81e1dbb93b9ebdb23023618c83c7b6d3a0cb2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panama_ruc_dv_calculator-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f94fe3bebba2daa9bdd84011e9672769f714e00a23e7b3d692fce721943e18a7
MD5 0f90c8ebbeb6fa2b91c8b72df72c1c10
BLAKE2b-256 ddfd4c4af67b1ebcb19f35331e2254c58ff12a3b7d76afd6031f45ad33e596d8

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