From 8052e2c519286cc541638b3e6f6a7fc0955c86d6 Mon Sep 17 00:00:00 2001 From: sriramv Date: Fri, 29 Sep 2023 14:27:12 +0530 Subject: [PATCH] gwm:probe42 --- app/controllers/financial.controller.js | 22 ++++++++++++++++++++-- app/services/financials.apicall.helper.js | 5 +++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/controllers/financial.controller.js b/app/controllers/financial.controller.js index 882f62d..654cae5 100644 --- a/app/controllers/financial.controller.js +++ b/app/controllers/financial.controller.js @@ -6,6 +6,7 @@ const ApiCallHelper = require('../services/financials.apicall.helper.js'); const Probe42DataMappingHelper = require('../services/probe42lineitem.mapping.helper.js'); const Sync = require('sync'); const { Op } = require("sequelize"); +const { Console } = require('winston/lib/winston/transports'); @@ -94,7 +95,7 @@ exports.MenuList = async (req, res) => { Entities.create({ "losid":Pro42Datavalue.loginNo,"pan":Pro42Datavalue.pan,"cin":cin_number,"bizname":Pro42Datavalue.entityName,"entity_type":Pro42Datavalue.entityType,"probe42_data_status":1,"is_verified":0,"createdby":Pro42Datavalue.createdby}) .then(Entitydata => { logMsg.info("entity created , data:"+Entitydata); - + const entityid = Entitydata.dataValues.id; if(Entitydata.dataValues.entity_type == 'COMPANY' || (Entitydata.dataValues.entity_type == 'PARTNERSHIP' && Entitydata.dataValues.bizname.slice(-3) == 'LLP')) @@ -118,7 +119,8 @@ exports.MenuList = async (req, res) => { entity_identify_number_type = 'llp'; } } - + console.log("entity_identify_number = "+entity_identify_number); + console.log("entity_identify_number_type = "+entity_identify_number_type); @@ -129,14 +131,30 @@ exports.MenuList = async (req, res) => { financials_data_api_response.then(function(result){ if(result == false) { + console.log("probe42ApiCall failed"); // create skeleton here financialControllerHelper.createSkeleton(losid,entityid); } else { + // update cin/llp (if not get from redirection api) + if(cin == "" || cin == null) + { + if(Entitydata.dataValues.entity_type == 'COMPANY') + { + Entities.update({ "cin":result.company.cin}, {where : { id: entityid }}); + }else if(Entitydata.dataValues.entity_type == 'PARTNERSHIP' && Entitydata.dataValues.bizname.slice(-3) == 'LLP') + { + Entities.update({ "cin":result.llp.llpin}, {where : { id: entityid }}); + } + + } + + if(result.financials.length > 0) { + console.log("probe42ApiCall success"); //filter lineitems from api responce and construct to needed format lineItem_data = Probe42DataMappingHelper.lineItemFetching(result.financials); lineItem_data.then(function(lineItem_result){ diff --git a/app/services/financials.apicall.helper.js b/app/services/financials.apicall.helper.js index 2bcd816..f3a53b6 100644 --- a/app/services/financials.apicall.helper.js +++ b/app/services/financials.apicall.helper.js @@ -23,15 +23,16 @@ function probe42ApiCall(entity_identify_number,entity_identify_number_type) { "Cin_Llpin_Or_Pan": entity_identify_number, "Identifier_type" : entity_identify_number_type }; + console.log(myJSONObject) return new Promise((resolve, reject) => { request({ url: probe_url, method: "POST", json: true, body: myJSONObject - }, function (error, response, body) { + }, function (error, response, body) { console.log(body); if (body != undefined) { - if (response.statusCode == 200 && body.hasOwnProperty("data") && body.data.financials.length != 0) { + if (response.statusCode == 200 && body.hasOwnProperty("data") ) { financial_data = body.data; resolve(financial_data); } else { resolve(false); }