npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

billbo-cuf

v0.0.12

Published

Utilities for the national tax billing system of Bolivia

Downloads

8

Readme

Summary: Utilities for the national tax billing system of Bolivian country.

Install:

        npm install billbo-cuf
        or
        npm install @arquetic/billbo
        or
        git clone https://github.com/aleftos/billbo

GENERACION CUF

El Código Único de Factura permite identificar como única una factura, debe ser generado automáticamente por el aplicativo del sujeto pasivo o tercero responsable utilizando para ello los siguientes campos:

Nota: Todos los campos deben completarse conforme a la longitud indicada.

Incorporar a la cadena (52 dígitos) resultante, un digito auto verificador utilizando Modulo 11. La cadena resultante debe ser codificada utilizando para ello Base 16 dando como resultado el CUF buscado (código Único de Factura).

Ejemplo:

  1. Con los siguientes datos:

                         • NIT EMISOR = 123456789
                         • FECHA / HORA = 20190113163721231
                         • SUCURSAL = 0
                         • MODALIDAD = 1
                         • TIPOEMISIÓN = 1
                         • CODIGO DOCUMENTO FISCAL = 1
                         • TIPO DOCUMENTO SECTOR = 1
                         • NUMERO DE FACTURA = 1
                         • POS: 0
  2. Se completa cada campo según la longitud definida con ceros a la izquierda:

                         • NIT EMISOR = 0000123456789
                         • FECHA / HORA = 20190113163721231
                         • SUCURSAL = 0000
                         • MODALIDAD = 1
                         • TIPOEMISIÓN = 1
                         • CODIGO DOCUMENTO FISCAL = 1
                         • TIPO DOCUMENTO SECTOR = 01
                         • NUMERO DE FACTURA = 00000001
                         • POS: 0000
  3. Se concatena los campos:

                 000012345678920190113163721231000011101000000010000
  4. Se obtiene el módulo 11 de la cadena y se lo adjunta al final de la cadena

                 0000123456789201901131637212310000111010000000100003
  5. Se aplica a la cadena resultante Base 16

                 159FFE6FB1986A24BB32DBE5A2A34214B245A6A3
let cuf = require('../lib/cuf');

console.log(
  'Test 1 NIT_EMISOR = 123456789, NÚMERO_FACTURA = 1, FECHA_HORA = 20190113163721231 :\n',
  cuf.cuf(
    123456789,
    1,
    20190113163721231
  )
)

console.log(
  'Test 2 most common call:\n',
  cuf.getCUF({
    NIT_EMISOR: '123456789',
    NÚMERO_FACTURA: '1',
    FECHA_HORA: '20190113163721231'
  })
)

console.log(
  'Test 3 FECHA_HORA takes data from module:\n',
  cuf.getCUF({
    NIT_EMISOR: '123456789',
    NÚMERO_FACTURA: '1',
    FECHA_HORA: cuf.getCUFTime()  // * local time
  })
)

console.log(
  'Test 4 FECHA_HORA is no present:\n',
  cuf.getCUF(
    {
      NIT_EMISOR: '123456789',
      NÚMERO_FACTURA: '29',
      // FECHA_HORA: cuf.getCUFTime(),  // * FECHA_HORA is no present
      SUCURSAL: '0',
      MODALIDAD: '1',
      TIPO_EMISIÓN: '2',
      CÓDIGO_DOCUMENTO_FISCAL: '2',
      TIPO_DOCUMENTO_SECTOR: '6',
      POS: '0'
    }
  )
)

console.log(
  'Test 5 NIT_EMISOR is number type, FECHA_HORA is no present:\n',
  cuf.getCUF(
    {
      NIT_EMISOR: 123456789,            // * number type
      NÚMERO_FACTURA: '29',
      // FECHA_HORA: cuf.getCUFTime(),  // * FECHA_HORA is no present
      SUCURSAL: '0',
      MODALIDAD: '1',
      TIPO_EMISIÓN: '2',
      CÓDIGO_DOCUMENTO_FISCAL: '2',
      TIPO_DOCUMENTO_SECTOR: '6',
      POS: '0'
    }
  )
)

console.log(
  'Test 6 FECHA_HORA is number type, TIPO_EMISIÓN contains non numeric type:',
  cuf.getCUF(
    {
      NIT_EMISOR: '123456789',
      NÚMERO_FACTURA: '29',
      FECHA_HORA: 20190113163721249,
      SUCURSAL: '0',
      MODALIDAD: '1',
      TIPO_EMISIÓN: '2A',           // * return ERROR
      CÓDIGO_DOCUMENTO_FISCAL: '2',
      TIPO_DOCUMENTO_SECTOR: '6',
      POS: '0'
    }
  )
)

console.log('Local time: ', cuf.getCUFTime());

// Output:

// Test 1 NIT_EMISOR = 123456789, NÚMERO_FACTURA = 1, FECHA_HORA = 20190113163721231 :
 { NIT_EMISOR: '123456789',
  'NÚMERO_FACTURA': '1',
  FECHA_HORA: '20190113163721230',
  SUCURSAL: '0',
  MODALIDAD: '1',
  'TIPO_EMISIÓN': '1',
  'CÓDIGO_DOCUMENTO_FISCAL': '1',
  TIPO_DOCUMENTO_SECTOR: '1',
  POS: '0',
  CUF: '159FFE6FB1986A24BB32D9C788C2785A0005A6A7' }

// Test 2 most common call:
 { NIT_EMISOR: '123456789',
  'NÚMERO_FACTURA': '1',
  FECHA_HORA: '20190113163721231',
  SUCURSAL: '0',
  MODALIDAD: '1',
  'TIPO_EMISIÓN': '1',
  'CÓDIGO_DOCUMENTO_FISCAL': '1',
  TIPO_DOCUMENTO_SECTOR: '1',
  POS: '0',
  CUF: '159FFE6FB1986A24BB32DBE5A2A34214B245A6A3' }

// Test 3 FECHA_HORA takes data from module:
 { NIT_EMISOR: '123456789',
  'NÚMERO_FACTURA': '1',
  FECHA_HORA: '20190328113205475',
  SUCURSAL: '0',
  MODALIDAD: '1',
  'TIPO_EMISIÓN': '1',
  'CÓDIGO_DOCUMENTO_FISCAL': '1',
  TIPO_DOCUMENTO_SECTOR: '1',
  POS: '0',
  CUF: '159FFE6FB198D41F2B9F4EDD635C98B1CF45A6A9' }

// Test 4 FECHA_HORA is no present:
 { NIT_EMISOR: '123456789',
  'NÚMERO_FACTURA': '29',
  FECHA_HORA: '20190328113205478',
  SUCURSAL: '0',
  MODALIDAD: '1',
  'TIPO_EMISIÓN': '2',
  'CÓDIGO_DOCUMENTO_FISCAL': '2',
  TIPO_DOCUMENTO_SECTOR: '6',
  POS: '0',
  CUF: '159FFE6FB198D41F2B9F5537B12637CC82F50027' }

// Test 5 NIT_EMISOR is number type, FECHA_HORA is no present:
 { NIT_EMISOR: '123456789',
  'NÚMERO_FACTURA': '29',
  FECHA_HORA: '20190328113205479',
  SUCURSAL: '0',
  MODALIDAD: '1',
  'TIPO_EMISIÓN': '2',
  'CÓDIGO_DOCUMENTO_FISCAL': '2',
  TIPO_DOCUMENTO_SECTOR: '6',
  POS: '0',
  CUF: '159FFE6FB198D41F2B9F5755CB07018735350023' }

// Test 6 FECHA_HORA is number type, TIPO_EMISIÓN contains non numeric type
 ERROR

// Get local time in required format

Local time:  20190328113205481

TBO