gwm:probe42

This commit is contained in:
sriramv 2023-09-29 14:27:12 +05:30
parent aca57a7fd7
commit 8052e2c519
2 changed files with 23 additions and 4 deletions

View File

@ -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){

View File

@ -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); }