diff --git a/app/models/Financials.js b/app/models/Financials.js index 6dbf0e3..f6c29ae 100644 --- a/app/models/Financials.js +++ b/app/models/Financials.js @@ -24,7 +24,8 @@ module.exports = (sequelize, DataTypes) => { is_editable: { type: DataTypes.INTEGER }, is_active: { type: DataTypes.INTEGER }, value: { type: DataTypes.INTEGER }, - sub_value: { type: DataTypes.STRING }, + sub_value: { type: DataTypes.STRING }, + inr_value: { type: DataTypes.INTEGER }, createdby: { type: DataTypes.INTEGER }, updatedby: { type: DataTypes.INTEGER }, diff --git a/app/services/financials.apicall.helper.js b/app/services/financials.apicall.helper.js index 1cca28d..d5ca0e7 100644 --- a/app/services/financials.apicall.helper.js +++ b/app/services/financials.apicall.helper.js @@ -26,7 +26,7 @@ function probe42ApiCall(cin) { method: "POST", json: true, body: myJSONObject - }, function (error, response, body) { + }, function (error, response, body) { if (body != undefined) { if (response.statusCode == 200 && body.hasOwnProperty("data") && body.data.financials.length != 0) { financial_data = body.data.financials; diff --git a/app/services/probe42lineitem.mapping.helper.js b/app/services/probe42lineitem.mapping.helper.js index 9f48c66..2e8a707 100644 --- a/app/services/probe42lineitem.mapping.helper.js +++ b/app/services/probe42lineitem.mapping.helper.js @@ -94,9 +94,12 @@ const { logMsg } = require('../services/logger.js'); 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); }); + // Replace this with the INR value you want to convert + lakhsValue = convertINRtoLakhs(value.value); + + Financials.update( { inr_value:value.value,value: lakhsValue , 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); }); } if (index === update_array_data.length -1) { resolve(); } }); @@ -131,7 +134,13 @@ const { logMsg } = require('../services/logger.js'); console.log(error); } } - + + + function convertINRtoLakhs(inrValue) { + return inrValue / 100000; +} + + module.exports = { lineItemFetching : lineItemFetching , diff --git a/server.js b/server.js index 1da7cc0..8464392 100644 --- a/server.js +++ b/server.js @@ -68,4 +68,5 @@ app.listen({ port: PORT_NUMBER }, async () => { console.log('Server up on http://localhost:'+PORT_NUMBER) //await sequelize.authenticate() -}) \ No newline at end of file +}) +