|
|
@@ -0,0 +1,217 @@
|
|
|
+const axios = require("axios");
|
|
|
+const { Integracao } = require("../../models/Integracao.model");
|
|
|
+
|
|
|
+module.exports = {
|
|
|
+ BuscaContratos: async (iddocliente) => {
|
|
|
+ var integracao = await Integracao.query()
|
|
|
+ .where("Tipo", 2)
|
|
|
+ .first()
|
|
|
+ .then((integraca) => integraca);
|
|
|
+ if (integracao != []) {
|
|
|
+ return axios
|
|
|
+ .post(
|
|
|
+ integracao.Url + "webservice/v1/cliente_contrato",
|
|
|
+ {
|
|
|
+ qtype: "cliente_contrato.id_cliente",
|
|
|
+ query: iddocliente,
|
|
|
+ oper: "=",
|
|
|
+ page: "1",
|
|
|
+ rp: "200",
|
|
|
+
|
|
|
+ sortname: "cliente_contrato.id",
|
|
|
+ sortorder: "asc",
|
|
|
+ /*grid_param: JSON.stringify([
|
|
|
+ { TB: "fn_areceber.liberado", OP: "=", P: "S" },
|
|
|
+ { TB: "fn_areceber.status", OP: "!=", P: "C" },
|
|
|
+ { TB: "fn_areceber.status", OP: "!=", P: "R" },
|
|
|
+ ]),*/
|
|
|
+ json: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ headers: {
|
|
|
+ "Content-Type": "application/json",
|
|
|
+ Authorization:
|
|
|
+ "Basic " + new Buffer.from(integracao.Token).toString("base64"),
|
|
|
+ ixcsoft: "listar",
|
|
|
+ },
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .then(async function (response) {
|
|
|
+ return { status: true, dados: response.data };
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ console.log(error);
|
|
|
+ return { status: false, msg: error };
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ console.log("## Core IXC Logins ", "Integração não configurada!!");
|
|
|
+ return { status: false, msg: "Integração não configurada!!" };
|
|
|
+ }
|
|
|
+ },
|
|
|
+ BuscaFinanceiro: async (iddocliente, inicio, fim) => {
|
|
|
+ var integracao = await Integracao.query()
|
|
|
+ .where("Tipo", 2)
|
|
|
+ .first()
|
|
|
+ .then((integraca) => integraca);
|
|
|
+ if (integracao != []) {
|
|
|
+ return axios
|
|
|
+ .post(
|
|
|
+ integracao.Url + "webservice/v1/fn_areceber",
|
|
|
+ {
|
|
|
+ qtype: "fn_areceber.id_cliente",
|
|
|
+ query: iddocliente,
|
|
|
+ oper: "=",
|
|
|
+ page: "1",
|
|
|
+ rp: "200",
|
|
|
+
|
|
|
+ sortname: "fn_areceber.data_vencimento",
|
|
|
+ sortorder: "asc",
|
|
|
+ grid_param: JSON.stringify([
|
|
|
+ { TB: "fn_areceber.liberado", OP: "=", P: "S" },
|
|
|
+ { TB: "fn_areceber.status", OP: "!=", P: "C" },
|
|
|
+ { TB: "fn_areceber.status", OP: "=", P: "R" },
|
|
|
+ { TB: "fn_areceber.data_vencimento", OP: ">", P: inicio },
|
|
|
+ { TB: "fn_areceber.data_vencimento", OP: "<", P: fim },
|
|
|
+ ]),
|
|
|
+ json: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ headers: {
|
|
|
+ "Content-Type": "application/json",
|
|
|
+ Authorization:
|
|
|
+ "Basic " + new Buffer.from(integracao.Token).toString("base64"),
|
|
|
+ ixcsoft: "listar",
|
|
|
+ },
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .then(async function (response) {
|
|
|
+ return { status: true, dados: response.data };
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ console.log(error);
|
|
|
+ return { status: false, msg: error };
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ console.log("## Core IXC Logins ", "Integração não configurada!!");
|
|
|
+ return { status: false, msg: "Integração não configurada!!" };
|
|
|
+ }
|
|
|
+ },
|
|
|
+ BuscaFinanceiroAberto: async (iddocliente) => {
|
|
|
+ var integracao = await Integracao.query()
|
|
|
+ .where("Tipo", 2)
|
|
|
+ .first()
|
|
|
+ .then((integraca) => integraca);
|
|
|
+ if (integracao != []) {
|
|
|
+ return axios
|
|
|
+ .post(
|
|
|
+ integracao.Url + "webservice/v1/fn_areceber",
|
|
|
+ {
|
|
|
+ qtype: "fn_areceber.id_cliente",
|
|
|
+ query: iddocliente,
|
|
|
+ oper: "=",
|
|
|
+ page: "1",
|
|
|
+ rp: "20000",
|
|
|
+
|
|
|
+ sortname: "fn_areceber.data_vencimento",
|
|
|
+ sortorder: "asc",
|
|
|
+ grid_param: JSON.stringify([
|
|
|
+ { TB: "fn_areceber.liberado", OP: "=", P: "S" },
|
|
|
+ { TB: "fn_areceber.status", OP: "!=", P: "C" },
|
|
|
+ { TB: "fn_areceber.status", OP: "!=", P: "R" },
|
|
|
+ ]),
|
|
|
+ json: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ headers: {
|
|
|
+ "Content-Type": "application/json",
|
|
|
+ Authorization:
|
|
|
+ "Basic " + new Buffer.from(integracao.Token).toString("base64"),
|
|
|
+ ixcsoft: "listar",
|
|
|
+ },
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .then(async function (response) {
|
|
|
+ return { status: true, dados: response.data };
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ console.log(error);
|
|
|
+ return { status: false, msg: error };
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ console.log("## Core IXC Logins ", "Integração não configurada!!");
|
|
|
+ return { status: false, msg: "Integração não configurada!!" };
|
|
|
+ }
|
|
|
+ },
|
|
|
+ buscaPix: async (idlogin) => {
|
|
|
+ var integracao = await Integracao.query()
|
|
|
+ .where("Tipo", 2)
|
|
|
+ .first()
|
|
|
+ .then((integraca) => integraca);
|
|
|
+ if (integracao != []) {
|
|
|
+ return axios
|
|
|
+ .post(
|
|
|
+ integracao.Url + "webservice/v1/get_pix",
|
|
|
+ {
|
|
|
+ id_areceber: idlogin,
|
|
|
+
|
|
|
+ json: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ headers: {
|
|
|
+ "Content-Type": "application/json",
|
|
|
+ Authorization:
|
|
|
+ "Basic " + new Buffer.from(integracao.Token).toString("base64"),
|
|
|
+ ixcsoft: "listar",
|
|
|
+ },
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .then(async function (response) {
|
|
|
+ return { status: true, dados: response.data };
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ console.log(error);
|
|
|
+ return { status: false, msg: error };
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ console.log("## Core IXC Logins ", "Integração não configurada!!");
|
|
|
+ return { status: false, msg: "Integração não configurada!!" };
|
|
|
+ }
|
|
|
+ },
|
|
|
+ buscaFaturaPdf: async (IdBoleto) => {
|
|
|
+ var integracao = await Integracao.query()
|
|
|
+ .where("Tipo", 2)
|
|
|
+ .first()
|
|
|
+ .then((integraca) => integraca);
|
|
|
+ if (integracao != []) {
|
|
|
+ return axios
|
|
|
+ .post(
|
|
|
+ integracao.Url + "webservice/v1/get_boleto",
|
|
|
+ {
|
|
|
+ boletos: IdBoleto,
|
|
|
+ juro: "N",
|
|
|
+ multa: "N",
|
|
|
+ atualiza_boleto: "N",
|
|
|
+ tipo_boleto: "arquivo",
|
|
|
+ base64: "S",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ headers: {
|
|
|
+ Authorization:
|
|
|
+ "Basic " + new Buffer.from(integracao.Token).toString("base64"),
|
|
|
+ ixcsoft: "listar",
|
|
|
+ },
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .then(async function (response) {
|
|
|
+ return { status: true, dados: response.data };
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ console.log(error);
|
|
|
+ return { status: false, msg: error };
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ console.log("## Core IXC Logins ", "Integração não configurada!!");
|
|
|
+ return { status: false, msg: "Integração não configurada!!" };
|
|
|
+ }
|
|
|
+ },
|
|
|
+};
|