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

degust-cupom-txt

v0.6.0

Published

Module capaz de extrair os dados dos cupons .txt que o PDV Linx Degust gera

Downloads

18

Readme

degust-cupom-txt

npm-version build status coverage status known vulnerabilities downloads license

Biblioteca capaz de extrair os dados dos cupons .txt que o sistema de PDV Linx Degust emite.

Exemplo

Entrada:

0V0010020000003200000000030000000000000020210131234559
1202101310000000001N1000000030700101                          F00000000000000                                                                                                                        000000000600A00000000000000000000000000000000000020210131234559000000000000000 0         NOME TESTE                                             0000000000000  000006000000000000000000000000000000000000000000000000N
2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
3A0010000000008               AGUA SEM GAS                                      UN    000001000000000006000000000600N                                        
3B00001DINHEIRO                                000000600000000000000000                                                                                                                
500000200000000010000000000000006000000000000060000000000000600
9000001000002000007

Saída:

{
    "loja_cnpj": "00000000000000",
    "data": "2021-01-31",
    "hora": "23:45:59",
    "tipo_venda": 1,
    "numero_abertura": 1,
    "controle_interno": 1,
    "controle_especifico": 307,
    "codigo_pdv": 1,
    "cancelada": false,
    "forma_pagamento": [
        {
            "nome": "DINHEIRO",
            "valor": 6
        }
    ],
    "quantidade_total_de_produtos": 1,
    "somatorio_valor_produtos": 6,
    "somatorio_valor_unitario": 6,
    "somatorio_valor_subtotal_item": 6,
    "somatorio_valor_pagamento": 6,
    "acrescimo_desconto": null,
    "cliente": null,
    "itens": [
        {
            "sequencia_item": 1,
            "codigo": 8,
            "nome": "AGUA SEM GAS",
            "cancelado": false,
            "quantidade": 1,
            "valor_unitario": 6,
            "subtotal_item": 6,
            "observacao": null
        }
    ]
}

Instalação

npm install --save degust-cupom-txt

Como usar

const fs = require('fs');
const parseCupom = require('degust-cupom-txt');

/*
    **** IMPORTANTE ****
    Sempre utilize a opção encoding: 'latin1', pois é o encoding que o sistema
    de PDV Linx Degust usa.
*/
const txt = fs.readFileSync('./cupom.txt', { encoding: 'latin1' }).toString();
const venda = parseCupom(txt);

Informações disponíveis

Observação: muitos campos podem ser retornados como null, pois nem todos os dados são obrigatórios.

{
    "loja_cnpj": "00000000000000",
    "data": "2021-01-31",
    "hora": "14:53:55",
    "tipo_venda": 8,
    "numero_abertura": 1,
    "controle_interno": 2,
    "controle_especifico": 843,
    "codigo_pdv": 1,
    "cancelada": false,
    "forma_pagamento": [
        {
            "nome": "DINHEIRO",
            "valor": 41.01
        }
    ],
    "quantidade_total_de_produtos": 4,
    "somatorio_valor_produtos": 49,
    "somatorio_valor_unitario": 49,
    "somatorio_valor_subtotal_item": 49,
    "somatorio_valor_pagamento": 41.01,
    "acrescimo_desconto": {
        "tipo": "D",
        "valor": 7.99
    },
    "cliente": {
        "cpf": "00000000000",
        "cnpj": null,
        "email": "[email protected]",
        "nome": "Nome Teste",
        "telefone": "21988887777",
        "sexo": "M",
        "endereco": {
            "logradouro": "Av. Lucio Costa",
            "numero": "12060",
            "complemento": "Bloco 7 Apto 101",
            "bairro": "Barra da Tijuca",
            "cep": "22000000",
            "municipio": "RIO DE JANEIRO",
            "uf": "RJ",
            "referencia": "Prédios perto ao shopping center"
        },
        "observacao": "Alérgico a amendoim",
        "data_nascimento": "1995-12-31",
        "data_cadastro": "2020-12-14"
    },
    "itens": [
        {
            "sequencia_item": 1,
            "codigo": 2,
            "nome": "Lanche 1",
            "cancelado": false,
            "quantidade": 1,
            "valor_unitario": 49,
            "subtotal_item": 49,
            "observacao": null
        },
        {
            "sequencia_item": 2,
            "codigo": 80,
            "nome": "Acompanhamento 1",
            "cancelado": false,
            "quantidade": 1,
            "valor_unitario": 0,
            "subtotal_item": 0,
            "observacao": null
        },
        {
            "sequencia_item": 3,
            "codigo": 100,
            "nome": "Acompanhamento 3",
            "cancelado": false,
            "quantidade": 1,
            "valor_unitario": 0,
            "subtotal_item": 0,
            "observacao": "Sem sal, por favor"
        },
        {
            "sequencia_item": 4,
            "codigo": 212,
            "nome": "Bebida 4",
            "cancelado": false,
            "quantidade": 1,
            "valor_unitario": 0,
            "subtotal_item": 0,
            "observacao": null
        }
    ]
}

Documentação

A biblioteca foi 100% documentada usando @JSDoc, de modo que IDEs possam oferecer autocomplete informativo, incluindo tipos e descrição dos campos. Testado e funcionando com Visual Studio Code.

Unit testing e coverage

Esta biblioteca ainda não teve seus testes implementados, portanto deve ser considerada como experimental. Os testes serão implementados em breve, visando atingir 100% de cobertura (coverage).

Licença

As marcas Linx® e Degust® são propriedades intelectuais
pertencentes à LINX SISTEMAS E CONSULTORIA LTDA.

CNPJ: 54.517.628/0001-98

Todos os direitos reservados.

Este projeto não possui vínculos com a empresa Linx.

Licença sobre todo o código e artefatos desta biblioteca
MIT License

Copyright (c) 2021 Patrick Pissurno

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.