Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let qtdDebTotal = flow.getVar('qtdDebTotal')
- qtdDebTotal--
- flow.setVar('qtdDebTotal', qtdDebTotal)
- const moment = require('moment')
- let dados = flow.getVar('checkDebt')
- let debitos = dados.debts;
- let cpf = flow.getVar('contatoCpf')
- let dataPagamento = flow.getVar('dataPagamento')
- let dma = dataPagamento.split('/');
- let convertedDate = dma[2]+'-'+dma[1]+'-'+dma[0] + 'T03:00:00.000Z';
- let performAgreementBody = {
- "idFaturas": [debitos[qtdDebTotal].idFatura],
- "additionalParams": {
- "firstRequest": false,
- "ajustedValue": 2,
- "discountType": 2,
- "discountValue": 0,
- "totalTax": 0,
- "totalValue": debitos[qtdDebTotal].debtPrice,
- "vlrEntrada": debitos[qtdDebTotal].debtPrice,
- "dtPagamentoInicial": `${convertedDate}`,
- "cdTipoAcordo": "null"
- } ,
- "cpf": `${cpf}`,
- "username": "asc",
- "campaignId": "{#campaignAdvanced}",
- "parcelsQty": 1,
- "parcelsValue": [{
- "parcelNumber": 0,
- "value": debitos[qtdDebTotal].debtPrice,
- "duedate": `${convertedDate}`
- }]
- }
- flow.setVar('performAgreementBody', performAgreementBody)
- let cdiId = flow.getVar('cdiId')
- let celular_cliente = flow.getVar('celular_cliente')
- let somaDebitos = flow.getVar('somaDebitos')
- let promessa = flow.getVar("promessaPgt");
- promessa = (debitos.map(v => {
- return {
- idFatura: v.idFatura,
- debito: v.debtPrice,
- dtPag: v.maturityDate,
- barCode: v.barCode
- }
- }))
- flow.setVar("promessaPgt", promessa);
- let skipExt = flow.getVar('skipExternalModule')
- let statusBody = {
- "status": "PROMESSA DE PAGAMENTO",
- "channel": "WHATSAPP",
- "date": `${convertedDate}`,
- "errorDescription": "null",
- "cdiId": `${cdiId}`,
- "skipExternalModule": skipExt,
- "source": "ASC",
- "username": "asc",
- "contact": `${celular_cliente}`,
- "additionalInfo": {
- "clientReturnInfo": {
- "complementReason": "",
- "complementText": "",
- "complementDate": "",
- "complementContact": `${celular_cliente}`,
- "complementContactType": "PHONE",
- "complementAgreementDate": `${convertedDate}`,
- "complementAgreementValue": `${somaDebitos}`,
- "complementAgreementType": "PROMISE",
- "debt": {
- "details":
- debitos.map(v => {
- return {
- idFatura: v.idFatura,
- }
- })
- }
- }
- }
- }
- flow.setVar('statusBody', statusBody)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement