Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. let qtdDebTotal = flow.getVar('qtdDebTotal')
  2. qtdDebTotal--
  3. flow.setVar('qtdDebTotal', qtdDebTotal)
  4.  
  5. const moment = require('moment')
  6. let dados = flow.getVar('checkDebt')
  7. let debitos = dados.debts;
  8. let cpf = flow.getVar('contatoCpf')
  9.  
  10. let dataPagamento = flow.getVar('dataPagamento')
  11. let dma = dataPagamento.split('/');
  12. let convertedDate = dma[2]+'-'+dma[1]+'-'+dma[0] + 'T03:00:00.000Z';
  13.  
  14.  
  15. let performAgreementBody = {
  16. "idFaturas": [debitos[qtdDebTotal].idFatura],
  17. "additionalParams": {
  18. "firstRequest": false,
  19. "ajustedValue": 2,
  20. "discountType": 2,
  21. "discountValue": 0,
  22. "totalTax": 0,
  23. "totalValue": debitos[qtdDebTotal].debtPrice,
  24. "vlrEntrada": debitos[qtdDebTotal].debtPrice,
  25. "dtPagamentoInicial": `${convertedDate}`,
  26. "cdTipoAcordo": "null"
  27. } ,
  28. "cpf": `${cpf}`,
  29. "username": "asc",
  30. "campaignId": "{#campaignAdvanced}",
  31. "parcelsQty": 1,
  32. "parcelsValue": [{
  33. "parcelNumber": 0,
  34. "value": debitos[qtdDebTotal].debtPrice,
  35. "duedate": `${convertedDate}`
  36. }]
  37. }
  38.  
  39. flow.setVar('performAgreementBody', performAgreementBody)
  40.  
  41. let cdiId = flow.getVar('cdiId')
  42. let celular_cliente = flow.getVar('celular_cliente')
  43. let somaDebitos = flow.getVar('somaDebitos')
  44. let promessa = flow.getVar("promessaPgt");
  45.  
  46. promessa = (debitos.map(v => {
  47. return {
  48.  
  49. idFatura: v.idFatura,
  50. debito: v.debtPrice,
  51. dtPag: v.maturityDate,
  52. barCode: v.barCode
  53. }
  54. }))
  55.  
  56. flow.setVar("promessaPgt", promessa);
  57.  
  58. let skipExt = flow.getVar('skipExternalModule')
  59.  
  60. let statusBody = {
  61. "status": "PROMESSA DE PAGAMENTO",
  62. "channel": "WHATSAPP",
  63. "date": `${convertedDate}`,
  64. "errorDescription": "null",
  65. "cdiId": `${cdiId}`,
  66. "skipExternalModule": skipExt,
  67. "source": "ASC",
  68. "username": "asc",
  69. "contact": `${celular_cliente}`,
  70. "additionalInfo": {
  71. "clientReturnInfo": {
  72. "complementReason": "",
  73. "complementText": "",
  74. "complementDate": "",
  75. "complementContact": `${celular_cliente}`,
  76. "complementContactType": "PHONE",
  77. "complementAgreementDate": `${convertedDate}`,
  78. "complementAgreementValue": `${somaDebitos}`,
  79. "complementAgreementType": "PROMISE",
  80. "debt": {
  81. "details":
  82. debitos.map(v => {
  83. return {
  84. idFatura: v.idFatura,
  85.  
  86. }
  87. })
  88.  
  89. }
  90. }
  91. }
  92. }
  93.  
  94. flow.setVar('statusBody', statusBody)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement