1.3.1 • Published 2 years ago

sankhya-helper v1.3.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

sankhya-helper

NPM version NPM downloads NPM downloads

Utilitário para criar e formatar objetos JavaScript no padrão de JSON enviado na API de integrações Sankhya.

Instalação

npm i sankhya-helper

Uso

Todas as funções retornam um objeto JSON.

MobileLoginSP.login

const MobileLoginSP = require("sankhya-helper/lib/MobileLoginSP");

MobileLoginSP.login(nomusu: string, interno: string, keepconnected: "S" | "N");

Exemplo:

MobileLoginSP.login("usuario", "senha", "S");
/*{
   "serviceName":"MobileLoginSP.login",
   "requestBody":{
      "NOMUSU":{
         "$":"usuario"
      },
      "INTERNO":{
         "$":"senha"
      },
      "KEEPCONNECTED":{
         "$":"S"
      }
   }
}*/

MobileLoginSP.logout

const MobileLoginSP = require("sankhya-helper/lib/MobileLoginSP");

MobileLoginSP.logout();

Exemplo:

const body = MobileLoginSP.logout();
/*{
   "serviceName":"MobileLoginSP.logout",
   "status":"1",
   "pendingPrinting":"false"
}*/

CACSP.incluirNota

const CACSP = require("sankhya-helper/lib/CACSP");

CACSP.incluirNota(cabecalho: Object, itens: Object[], informarPreco: boolean);

Exemplo:

O campo "NUNOTA" é incluído pela função.

const cabecalho = {
    "CODPARC": 2,
    "DTNEG": "01/02/2021",
    "CODTIPOPER": 18,
    "CODTIPVENDA": 11,
    "CODVEND": 2,
    "CODEMP": 1,
    "TIPMOV": "P"
}

const itens = [
    {
        "CODPROD": 13,
        "QTDNEG": 1,
        "CODLOCALORIG": 0,
        "CODVOL": "UN"
    }
]

CACSP.incluirNota(cabecalho, itens, false);
/*{
   "serviceName":"CACSP.incluirNota",
   "requestBody":{
      "nota":{
         "cabecalho":{
            "NUNOTA":{
               
            },
            "CODPARC":{
               "$":"2"
            },
            "DTNEG":{
               "$":"01/02/2021"
            },
            "CODTIPOPER":{
               "$":"18"
            },
            "CODTIPVENDA":{
               "$":"11"
            },
            "CODVEND":{
               "$":"2"
            },
            "CODEMP":{
               "$":"1"
            },
            "TIPMOV":{
               "$":"P"
            }
         },
         "itens":{
            "INFORMARPRECO":"N",
            "item":[
               {
                  "CODPROD":{
                     "$":"13"
                  },
                  "QTDNEG":{
                     "$":"1"
                  },
                  "CODLOCALORIG":{
                     "$":"0"
                  },
                  "CODVOL":{
                     "$":"UN"
                  },
                  "NUNOTA":{
                     
                  }
               }
            ]
         }
      }
   }
}*/

CACSP.incluirAlterarItemNota

const CACSP = require("sankhya-helper/lib/CACSP");

CACSP.incluirAlterarItemNota(nunota: number | string, item: Object);

Exemplo:

const item = {
    "CODPROD": 129,
    "NUNOTA": 7468,
    "QTDNEG": 10,
    "VLRUNIT": 10,
    "VLRTOT": 432.38,
    "CODVOL": "UN",
    "VLRDESC": 0,
    "PERCDESC": 0,
    "SEQUENCIA": ""
}

CACSP.incluirAlterarItemNota(7468, item);
/*{
   "serviceName":"CACSP.incluirAlterarItemNota",
   "requestBody":{
      "nota":{
         "NUNOTA":"7468",
         "itens":{
            "item":{
               "CODPROD":{
                  "$":"129"
               },
               "NUNOTA":{
                  "$":"7468"
               },
               "QTDNEG":{
                  "$":"10"
               },
               "VLRUNIT":{
                  "$":"10"
               },
               "VLRTOT":{
                  "$":"432.38"
               },
               "CODVOL":{
                  "$":"UN"
               },
               "VLRDESC":{
                  "$":"0"
               },
               "PERCDESC":{
                  "$":"0"
               },
               "SEQUENCIA":{
                  "$":""
               }
            }
         }
      }
   }
}*/

CACSP.excluirItemNota

const CACSP = require("sankhya-helper/lib/CACSP");

CACSP.excluirItemNota(nunota: number | string, sequencia: number | string);

Exemplo:

CACSP.excluirItemNota(7468, 4);
/*{
   "serviceName":"CACSP.excluirItemNota",
   "requestBody":{
      "nota":{
         "itens":{
            "item":{
               "NUNOTA":{
                  "$":"7468"
               },
               "SEQUENCIA":{
                  "$":"4"
               }
            }
         }
      }
   }
}*/

CACSP.cancelarNota

const CACSP = require("sankhya-helper/lib/CACSP");

CACSP.cancelarNota(nunota: number | string, justificativa: string, validarProcessosWmsEmAndamento: boolean);

Exemplo:

CACSP.cancelarNota(3713703, "Lançamento indevido", true)
/*{
   "serviceName":"CACSP.cancelarNota",
   "requestBody":{
      "notasCanceladas":{
         "nunota":[
            {
               "$":"3713703"
            }
         ],
         "justificativa":"Lançamento indevido",
         "validarProcessosWmsEmAndamento":"true"
      }
   }
}*/

CRUDServiceProvider.saveRecord

const CRUDServiceProvider = require("sankhya-helper/lib/CRUDServiceProvider");

CRUDServiceProvider.saveRecord(entidade: string, input: Object, output: string);

Exemplo:

const cidade = {
   NOMECID: "UBERLANDIA",
   UF: 2
}

CRUDServiceProvider.saveRecord("Cidade", cidade, "CODCID,NOMECID,UF");
/*{
   "serviceName":"CRUDServiceProvider.saveRecord",
   "requestBody":{
      "dataSet":{
         "rootEntity":"Cidade",
         "includePresentationFields":"N",
         "dataRow":{
            "localFields":{
               "NOMECID":{
                  "$":"Uberlândia"
               },
               "UF":{
                  "$":"2"
               }
            }
         },
         "entity":{
            "fieldset":{
               "list":"CODCID,NOMECID,UF"
            }
         }
      }
   }
}*/

Licença

sankhya-helper é licenciado sob a licença MIT. MIT

sankhya-helper não é mantido pela Sankhya e sim por terceiros que criam soluções utilizando sua API de integração.

1.3.1

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago