probe42dataupdate:GWM
This commit is contained in:
parent
d06e6fef6e
commit
951a125ce7
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,8 +1,3 @@
|
||||
/node_modules
|
||||
/storage
|
||||
.env
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
29
app/models/Entityfinyear.js
Normal file
29
app/models/Entityfinyear.js
Normal file
@ -0,0 +1,29 @@
|
||||
'use strict'
|
||||
const { Model } = require('sequelize')
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
class Entityfinyear extends Model {
|
||||
|
||||
|
||||
}
|
||||
Entityfinyear.init(
|
||||
{
|
||||
losid: { type: DataTypes.STRING },
|
||||
entityid: { type: DataTypes.INTEGER },
|
||||
FY: { type: DataTypes.INTEGER },
|
||||
st_type: { type: DataTypes.INTEGER },
|
||||
additional_year_type: { type: DataTypes.INTEGER },
|
||||
createdby: { type: DataTypes.INTEGER },
|
||||
updatedby: { type: DataTypes.INTEGER },
|
||||
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
tableName: 'entity_fin_year',
|
||||
modelName: 'Entityfinyear',
|
||||
createdAt: 'createdon',
|
||||
updatedAt: 'updatedon',
|
||||
|
||||
}
|
||||
)
|
||||
return Entityfinyear
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
'use strict'
|
||||
const { Model } = require('sequelize')
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
class Entityfinyears extends Model {
|
||||
|
||||
|
||||
}
|
||||
Entityfinyears.init(
|
||||
{
|
||||
losid: { type: DataTypes.STRING },
|
||||
entityid: { type: DataTypes.INTEGER },
|
||||
Y1: { type: DataTypes.INTEGER },
|
||||
Y2: { type: DataTypes.INTEGER },
|
||||
Y3: { type: DataTypes.INTEGER },
|
||||
Y4: { type: DataTypes.INTEGER },
|
||||
Y1_st_type: { type: DataTypes.INTEGER },
|
||||
Y2_st_type: { type: DataTypes.INTEGER },
|
||||
Y3_st_type: { type: DataTypes.INTEGER },
|
||||
Y4_st_type: { type: DataTypes.INTEGER },
|
||||
additional_year_type: { type: DataTypes.INTEGER },
|
||||
createdby: { type: DataTypes.INTEGER },
|
||||
updatedby: { type: DataTypes.INTEGER },
|
||||
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
tableName: 'entity_fin_years',
|
||||
modelName: 'Entityfinyears',
|
||||
createdAt: 'createdon',
|
||||
updatedAt: 'updatedon',
|
||||
|
||||
}
|
||||
)
|
||||
return Entityfinyears
|
||||
}
|
||||
@ -21,6 +21,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
fy: { type: DataTypes.STRING },
|
||||
st_type:{ type: DataTypes.STRING },
|
||||
itemid: { type: DataTypes.INTEGER },
|
||||
is_editable: { type: DataTypes.INTEGER },
|
||||
is_active: { type: DataTypes.INTEGER },
|
||||
value: { type: DataTypes.INTEGER },
|
||||
createdby: { type: DataTypes.INTEGER },
|
||||
|
||||
@ -29,6 +29,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
section: { type: DataTypes.INTEGER },
|
||||
subsection: { type: DataTypes.INTEGER },
|
||||
itemtext: { type: DataTypes.STRING },
|
||||
pvtltditemkey: { type: DataTypes.STRING },
|
||||
is_active: { type: DataTypes.INTEGER },
|
||||
pvtltd: { type: DataTypes.INTEGER },
|
||||
llp: { type: DataTypes.INTEGER },
|
||||
|
||||
@ -8,9 +8,7 @@ module.exports = app => {
|
||||
var router = require("express").Router();
|
||||
|
||||
|
||||
// router.get("/camunda", financials.camunda);
|
||||
// router.get("/test", financials.test);
|
||||
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/ConsolidatedSummary:
|
||||
|
||||
42
app/services/financials.apicall.helper.js
Normal file
42
app/services/financials.apicall.helper.js
Normal file
@ -0,0 +1,42 @@
|
||||
const request = require('request');
|
||||
const PROBE42_URL = process.env.PROBE42_URL
|
||||
PROBE42_USER_ID = process.env.PROBE42_USER_ID
|
||||
PROBE42_PASSWORD = process.env.PROBE42_PASSWORD
|
||||
PROBE42_APPLICATION_NAME = process.env.PROBE42_APPLICATION_NAME
|
||||
|
||||
function probe42ApiCall(cin)
|
||||
{
|
||||
try
|
||||
{
|
||||
const probe_url = PROBE42_URL+"companycomprehensivedetails";
|
||||
const myJSONObject = { "UserId": PROBE42_USER_ID,
|
||||
"Password": PROBE42_PASSWORD,
|
||||
"ApplicationName": PROBE42_APPLICATION_NAME,
|
||||
"Cin": cin };
|
||||
return new Promise((resolve, reject) => {
|
||||
request({
|
||||
url: probe_url,
|
||||
method: "POST",
|
||||
json: true,
|
||||
body: myJSONObject
|
||||
}, function (error, response, body){
|
||||
let data = body
|
||||
financial_data = data.data.financials;
|
||||
resolve(financial_data);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
catch (error)
|
||||
{
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
module.exports = {
|
||||
probe42ApiCall : probe42ApiCall
|
||||
|
||||
|
||||
}
|
||||
107
app/services/probe42lineitem.mapping.helper.js
Normal file
107
app/services/probe42lineitem.mapping.helper.js
Normal file
@ -0,0 +1,107 @@
|
||||
const { sequelize, Financials , Itemsmaster } = require('../models')
|
||||
const { Op } = require("sequelize");
|
||||
const { logMsg } = require('../services/logger.js');
|
||||
function lineItemFetching(financials_data)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new Promise((resolve, reject) => {
|
||||
let data = [];
|
||||
financials_data.forEach((value, index, array) => {
|
||||
if(value.nature == "STANDALONE" && index == 0 || index == 1 || index == 2)
|
||||
{
|
||||
let object = {};
|
||||
current_year_in_object = value.year;
|
||||
fin_data_year = current_year_in_object.substring(0, 4);
|
||||
let year = {"year": fin_data_year };
|
||||
// get balance sheet line items here
|
||||
let balance_sheet = value.bs;
|
||||
for (const [bs_key, bs_value ] of Object.entries(balance_sheet)) {
|
||||
if(bs_key === "assets" || bs_key === "liabilities" || bs_key === "subTotals")
|
||||
{
|
||||
Object.assign(object, year, bs_value)
|
||||
}
|
||||
} // end of balance_sheet object for loop
|
||||
// get profit and loss line items here
|
||||
let profit_and_loss = value.pnl;
|
||||
for (const [pnl_key, pnl_value ] of Object.entries(profit_and_loss)) {
|
||||
if(pnl_key === "lineItems" || pnl_key === "subTotals")
|
||||
{
|
||||
Object.assign(object, year, pnl_value)
|
||||
}
|
||||
} // end of profit_and_loss object for loop
|
||||
setTimeout(() => { data.push(object); }, 100);
|
||||
} // end of if condition
|
||||
|
||||
}); // end of financials data foreach
|
||||
setTimeout(() => {
|
||||
resolve(data);
|
||||
}, 500);
|
||||
});
|
||||
}
|
||||
catch (error)
|
||||
{
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
function lineItemMapping(financials_lineitems_data_object,entityid)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new Promise((resolve, reject) => {
|
||||
Itemsmaster.findAll({where : { pvtltditemkey: {[Op.ne]: 'NULL'} } , attributes: [ 'id','pvtltditemkey' ] })
|
||||
.then(ItemsmasterData => {
|
||||
let data = [];
|
||||
|
||||
year = financials_lineitems_data_object.year;
|
||||
ItemsmasterData.forEach((element , key) => {
|
||||
|
||||
for (const [key, item_value ] of Object.entries(financials_lineitems_data_object)) {
|
||||
remove_underscore = key.replace(/_/g, "");
|
||||
converted_item_key = remove_underscore.toLowerCase();
|
||||
if(element.dataValues.pvtltditemkey === converted_item_key)
|
||||
{
|
||||
let obj = {entityid : entityid ,itemid : element.dataValues.id , value : item_value , year : year};
|
||||
data.push(obj);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
setTimeout(() => { resolve(data); }, 500);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
catch (error)
|
||||
{
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function lineItemUpdate(update_array_data)
|
||||
{
|
||||
try
|
||||
{
|
||||
update_array_data.forEach((value,index) => {
|
||||
if(value.value != null)
|
||||
{
|
||||
Financials.update( { value: value.value , is_editable : 0 } , { where: { entity_id: value.entityid , itemid: value.itemid , fy:value.year} })
|
||||
.then(data => { logMsg.info("update success : "+ data); })
|
||||
.catch(err => { logMsg.info("update failed : " + err); });
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (error)
|
||||
{
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
lineItemFetching : lineItemFetching ,
|
||||
lineItemMapping : lineItemMapping ,
|
||||
lineItemUpdate :lineItemUpdate
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user