finalcialInfo:GWM
This commit is contained in:
parent
ef58d2c320
commit
320e56ecec
@ -18,27 +18,43 @@ exports.PullSalesPdData = async (req, res) =>
|
|||||||
const len = Object.keys(tempData).length - 1;
|
const len = Object.keys(tempData).length - 1;
|
||||||
for (const [keys, values] of Object.entries(tempData)) {
|
for (const [keys, values] of Object.entries(tempData)) {
|
||||||
count++;
|
count++;
|
||||||
console.log(values);
|
|
||||||
if (Array.isArray(values) == true )
|
if (Array.isArray(values) == true )
|
||||||
{
|
{
|
||||||
|
pre_year_sales = 0;
|
||||||
|
pre_year_net_profit = 0;
|
||||||
|
pre_year_net_pro_loss_per = 0;
|
||||||
values.forEach(async(values) => {
|
values.forEach(async(values) => {
|
||||||
if (keys == 'section1') {
|
if (keys == 'section1') {
|
||||||
Object.assign(values, { ref_no: req.body.pdid , product :req.body.product , case_no :req.body.caseno});
|
Object.assign(values, { ref_no: req.body.pdid , product :req.body.product , case_no :req.body.caseno});
|
||||||
await GeneralSection.create( values )
|
await GeneralSection.create( values )
|
||||||
.then((successData)=>{logMsg.info("GeneralSection insert success ,PdId= "+successData.dataValues.pd_id);})
|
.then((successData)=>{logMsg.info("GeneralSection insert success ,PdId= "+successData.dataValues.pd_id);})
|
||||||
.catch((err)=>{ logMsg.info("GeneralSection insert failed ,PdId(ref_no)= "+req.body.pdid); });
|
.catch((err)=>{ logMsg.info("GeneralSection insert failed ,PdId(ref_no)= "+req.body.pdid); });
|
||||||
storeId = await GeneralSection.findOne({ where : { ref_no : req.body.pdid , is_active : 1 }});
|
storeId = await GeneralSection.findOne({ where : { ref_no : req.body.pdid ,case_no :req.body.caseno, is_active : 1 }});
|
||||||
};
|
};
|
||||||
if (keys == 'section2') { Object.assign(values, { pd_id: storeId.pd_id }); await FundRequirement.create( values ).then((successData)=>{logMsg.info("FundRequirement insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("FundRequirement insert failed ,PdId= "+storeId.pd_id); }); };
|
if (keys == 'section2') { Object.assign(values, { pd_id: storeId.pd_id }); await FundRequirement.create( values ).then((successData)=>{logMsg.info("FundRequirement insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("FundRequirement insert failed ,PdId= "+storeId.pd_id+" Error = "+err); }); };
|
||||||
if (keys == 'section3') { Object.assign(values, { pd_id: storeId.pd_id }); await DetailsOfKeyShareHolder.create( values).then((successData)=>{logMsg.info("DetailsOfKeyShareHolder insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("DetailsOfKeyShareHolder insert failed ,PdId= "+storeId.pd_id);}); };
|
if (keys == 'section3') { Object.assign(values, { pd_id: storeId.pd_id }); await DetailsOfKeyShareHolder.create( values).then((successData)=>{logMsg.info("DetailsOfKeyShareHolder insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("DetailsOfKeyShareHolder insert failed ,PdId= "+storeId.pd_id+" Error = "+err);}); };
|
||||||
if (keys == 'section4') { Object.assign(values, { pd_id: storeId.pd_id }); await BriefOfBusiness.create( values).then((successData)=>{logMsg.info("BreifOfBusiness insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("BreifOfBusiness insert failed ,PdId= "+storeId.pd_id);}); };
|
if (keys == 'section4') { Object.assign(values, { pd_id: storeId.pd_id }); await BriefOfBusiness.create( values).then((successData)=>{logMsg.info("BreifOfBusiness insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("BreifOfBusiness insert failed ,PdId= "+storeId.pd_id+" Error = "+err);}); };
|
||||||
if (keys == 'section5') {
|
if (keys == 'section5') {
|
||||||
Object.assign(values, { pd_id: storeId.pd_id });
|
Object.assign(values, { pd_id: storeId.pd_id });
|
||||||
Object.assign(values, values[0]);
|
Object.assign(values, values[0]);
|
||||||
await FinancialInformation.create( values).then((successData)=>{logMsg.info("FinancialInformation insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("FinancialInformation insert failed ,PdId= "+storeId.pd_id);}); };
|
net_profit_net_loss_to_sales = parseFloat(((values.net_profit / values.sales_revenue) * 100)).toFixed(2);
|
||||||
if (keys == 'section6') { Object.assign(values, { pd_id: storeId.pd_id }); await PropertyInformation.create( values).then((successData)=>{logMsg.info("PropertyInformation insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("PropertyInformation insert failed ,PdId= "+storeId.pd_id);}); };
|
income_considered_per_month = parseFloat((values.income_considered / 12)).toFixed(2);
|
||||||
if (keys == 'section7') { Object.assign(values, { pd_id: storeId.pd_id }); await FinalRemarks.create( values).then((successData)=>{logMsg.info("FinalRemarks insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("FinalRemarks insert failed ,PdId= "+storeId.pd_id);}); };
|
sales_over_py = parseFloat((((values.sales_revenue - pre_year_sales) / pre_year_sales ) * 100)).toFixed(2);
|
||||||
if (keys == 'section8') { Object.assign(values, { pd_id: storeId.pd_id }); await OfficerDetails.create( values).then((successData)=>{logMsg.info("OfficerDetails insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("OfficerDetails insert failed ,PdId= "+storeId.pd_id);}); };
|
net_profit_over_py = parseFloat((((values.net_profit - pre_year_net_profit) / pre_year_net_profit ) * 100)).toFixed(2);
|
||||||
|
net_profit_percentage_over_py = parseFloat(((( ((values.net_profit / values.sales_revenue ) * 100 ) - pre_year_net_pro_loss_per) / pre_year_net_pro_loss_per ) * 100)).toFixed(2);
|
||||||
|
// assign all calculated values
|
||||||
|
if(sales_over_py == "Infinity"){sales_over_py=null;}if(net_profit_over_py == "Infinity"){net_profit_over_py=null;}if(net_profit_percentage_over_py == "Infinity"){net_profit_percentage_over_py=null;}
|
||||||
|
Object.assign(values,{net_profit_net_loss_to_sales:net_profit_net_loss_to_sales , income_considered_per_month:income_considered_per_month , sales_over_py:sales_over_py , net_profit_over_py:net_profit_over_py , net_profit_percentage_over_py:net_profit_percentage_over_py});
|
||||||
|
await FinancialInformation.create( values).then((successData)=>{logMsg.info("FinancialInformation insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("FinancialInformation insert failed ,PdId= "+storeId.pd_id+" Error = "+err);});
|
||||||
|
pre_year_sales = values.sales_revenue;
|
||||||
|
pre_year_net_profit = values.net_profit;
|
||||||
|
pre_year_net_pro_loss_per = ((values.net_profit / values.sales_revenue ) * 100 );
|
||||||
|
|
||||||
|
};
|
||||||
|
if (keys == 'section6') { Object.assign(values, { pd_id: storeId.pd_id }); await PropertyInformation.create( values).then((successData)=>{logMsg.info("PropertyInformation insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("PropertyInformation insert failed ,PdId= "+storeId.pd_id+" Error = "+err);}); };
|
||||||
|
if (keys == 'section7') { Object.assign(values, { pd_id: storeId.pd_id }); await FinalRemarks.create( values).then((successData)=>{logMsg.info("FinalRemarks insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("FinalRemarks insert failed ,PdId= "+storeId.pd_id+" Error = "+err);}); };
|
||||||
|
if (keys == 'section8') { Object.assign(values, { pd_id: storeId.pd_id }); await OfficerDetails.create( values).then((successData)=>{logMsg.info("OfficerDetails insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("OfficerDetails insert failed ,PdId= "+storeId.pd_id+" Error = "+err);}); };
|
||||||
// if (keys == 'section10') { Object.assign(values, { pd_id: storeId.pd_id }); await InstitutionDetail.create( values).then((successData)=>{logMsg.info("InstitutionDetail insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("InstitutionDetail insert failed ,PdId= "+storeId.pd_id);}); };
|
// if (keys == 'section10') { Object.assign(values, { pd_id: storeId.pd_id }); await InstitutionDetail.create( values).then((successData)=>{logMsg.info("InstitutionDetail insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("InstitutionDetail insert failed ,PdId= "+storeId.pd_id);}); };
|
||||||
// if (keys == 'section11') { Object.assign(values, { pd_id: storeId.pd_id }); await ProductInformation.create( values).then((successData)=>{logMsg.info("ProductInformation insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("ProductInformation insert failed ,PdId= "+storeId.pd_id);}); };
|
// if (keys == 'section11') { Object.assign(values, { pd_id: storeId.pd_id }); await ProductInformation.create( values).then((successData)=>{logMsg.info("ProductInformation insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("ProductInformation insert failed ,PdId= "+storeId.pd_id);}); };
|
||||||
});
|
});
|
||||||
@ -51,18 +67,30 @@ exports.PullSalesPdData = async (req, res) =>
|
|||||||
.then((successData)=>{logMsg.info("GeneralSection insert success ,PdId= "+successData.dataValues.pd_id);})
|
.then((successData)=>{logMsg.info("GeneralSection insert success ,PdId= "+successData.dataValues.pd_id);})
|
||||||
.catch((err)=>{ logMsg.info("GeneralSection insert failed ,PdId(ref_no)= "+req.body.pdid); });
|
.catch((err)=>{ logMsg.info("GeneralSection insert failed ,PdId(ref_no)= "+req.body.pdid); });
|
||||||
|
|
||||||
storeId = await GeneralSection.findOne({ where : { ref_no : req.body.pdid , is_active : 1 }});
|
storeId = await GeneralSection.findOne({ where : { ref_no : req.body.pdid ,case_no :req.body.caseno, is_active : 1 }});
|
||||||
};
|
};
|
||||||
if (keys == 'section2') { Object.assign(values, { pd_id: storeId.pd_id }); await FundRequirement.create( values ).then((successData)=>{logMsg.info("FundRequirement insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("FundRequirement insert failed ,PdId= "+storeId.pd_id);}); };
|
if (keys == 'section2') { Object.assign(values, { pd_id: storeId.pd_id }); await FundRequirement.create( values ).then((successData)=>{logMsg.info("FundRequirement insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("FundRequirement insert failed ,PdId= "+storeId.pd_id+" Error = "+err);}); };
|
||||||
if (keys == 'section3') { Object.assign(values, { pd_id: storeId.pd_id }); await DetailsOfKeyShareHolder.create( values).then((successData)=>{logMsg.info("DetailsOfKeyShareHolder insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("DetailsOfKeyShareHolder insert failed ,PdId= "+storeId.pd_id);}); };
|
if (keys == 'section3') { Object.assign(values, { pd_id: storeId.pd_id }); await DetailsOfKeyShareHolder.create( values).then((successData)=>{logMsg.info("DetailsOfKeyShareHolder insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("DetailsOfKeyShareHolder insert failed ,PdId= "+storeId.pd_id+" Error = "+err);}); };
|
||||||
if (keys == 'section4') { Object.assign(values, { pd_id: storeId.pd_id }); await BriefOfBusiness.create( values).then((successData)=>{logMsg.info("BreifOfBusiness insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("BreifOfBusiness insert failed ,PdId= "+storeId.pd_id);}); };
|
if (keys == 'section4') { Object.assign(values, { pd_id: storeId.pd_id }); await BriefOfBusiness.create( values).then((successData)=>{logMsg.info("BreifOfBusiness insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("BreifOfBusiness insert failed ,PdId= "+storeId.pd_id+" Error = "+err);}); };
|
||||||
if (keys == 'section5') {
|
if (keys == 'section5') {
|
||||||
Object.assign(values, { pd_id: storeId.pd_id });
|
pre_year_sales = 0;
|
||||||
Object.assign(values, values[0]);
|
pre_year_net_profit = 0;
|
||||||
await FinancialInformation.create( values).then((successData)=>{logMsg.info("FinancialInformation insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("FinancialInformation insert failed ,PdId= "+storeId.pd_id);}); };
|
pre_year_net_pro_loss_per = 0;
|
||||||
if (keys == 'section6') { Object.assign(values, { pd_id: storeId.pd_id }); await PropertyInformation.create( values).then((successData)=>{logMsg.info("PropertyInformation insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("PropertyInformation insert failed ,PdId= "+storeId.pd_id);}); };
|
Object.assign(values, { pd_id: storeId.pd_id });
|
||||||
if (keys == 'section7') { Object.assign(values, { pd_id: storeId.pd_id }); await FinalRemarks.create( values).then((successData)=>{logMsg.info("FinalRemarks insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("FinalRemarks insert failed ,PdId= "+storeId.pd_id);}); };
|
Object.assign(values, values[0]);
|
||||||
if (keys == 'section8') { Object.assign(values, { pd_id: storeId.pd_id }); await OfficerDetails.create( values).then((successData)=>{logMsg.info("OfficerDetails insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("OfficerDetails insert failed ,PdId= "+storeId.pd_id);}); };
|
net_profit_net_loss_to_sales = parseFloat(((values.net_profit / values.sales_revenue) * 100)).toFixed(2);
|
||||||
|
income_considered_per_month = parseFloat((values.income_considered / 12)).toFixed(2);
|
||||||
|
sales_over_py = parseFloat((((values.sales_revenue - pre_year_sales) / pre_year_sales ) * 100)).toFixed(2);
|
||||||
|
net_profit_over_py = parseFloat((((values.net_profit - pre_year_net_profit) / pre_year_net_profit ) * 100)).toFixed(2);
|
||||||
|
net_profit_percentage_over_py = parseFloat(((( ((values.net_profit / values.sales_revenue ) * 100 ) - pre_year_net_pro_loss_per) / pre_year_net_pro_loss_per ) * 100)).toFixed(2);
|
||||||
|
// assign all calculated values
|
||||||
|
if(sales_over_py == "Infinity"){sales_over_py=null;}if(net_profit_over_py == "Infinity"){net_profit_over_py=null;}if(net_profit_percentage_over_py == "Infinity"){net_profit_percentage_over_py=null;}
|
||||||
|
Object.assign(values,{net_profit_net_loss_to_sales:net_profit_net_loss_to_sales , income_considered_per_month:income_considered_per_month , sales_over_py:sales_over_py , net_profit_over_py:net_profit_over_py , net_profit_percentage_over_py:net_profit_percentage_over_py});
|
||||||
|
await FinancialInformation.create( values).then((successData)=>{logMsg.info("FinancialInformation insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("FinancialInformation insert failed ,PdId= "+storeId.pd_id+" Error = "+err);});
|
||||||
|
}
|
||||||
|
if (keys == 'section6') { Object.assign(values, { pd_id: storeId.pd_id }); await PropertyInformation.create( values).then((successData)=>{logMsg.info("PropertyInformation insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("PropertyInformation insert failed ,PdId= "+storeId.pd_id+" Error = "+err);}); };
|
||||||
|
if (keys == 'section7') { Object.assign(values, { pd_id: storeId.pd_id }); await FinalRemarks.create( values).then((successData)=>{logMsg.info("FinalRemarks insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("FinalRemarks insert failed ,PdId= "+storeId.pd_id+" Error = "+err);}); };
|
||||||
|
if (keys == 'section8') { Object.assign(values, { pd_id: storeId.pd_id }); await OfficerDetails.create( values).then((successData)=>{logMsg.info("OfficerDetails insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("OfficerDetails insert failed ,PdId= "+storeId.pd_id+" Error = "+err);}); };
|
||||||
// if (keys == 'section10') { Object.assign(values, { pd_id: storeId.pd_id }); await InstitutionDetail.create( values).then((successData)=>{logMsg.info("InstitutionDetail insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("InstitutionDetail insert failed ,PdId= "+storeId.pd_id);}); };
|
// if (keys == 'section10') { Object.assign(values, { pd_id: storeId.pd_id }); await InstitutionDetail.create( values).then((successData)=>{logMsg.info("InstitutionDetail insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("InstitutionDetail insert failed ,PdId= "+storeId.pd_id);}); };
|
||||||
// if (keys == 'section11') { Object.assign(values, { pd_id: storeId.pd_id }); await ProductInformation.create( values).then((successData)=>{logMsg.info("ProductInformation insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("ProductInformation insert failed ,PdId= "+storeId.pd_id);}); };
|
// if (keys == 'section11') { Object.assign(values, { pd_id: storeId.pd_id }); await ProductInformation.create( values).then((successData)=>{logMsg.info("ProductInformation insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("ProductInformation insert failed ,PdId= "+storeId.pd_id);}); };
|
||||||
}
|
}
|
||||||
@ -87,14 +115,14 @@ exports.PullSalesPdPhotographsData = async (req, res) =>
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GeneralSectionData = await GeneralSection.findOne({ where : { ref_no : req.body.pdid , is_active : 1 }});
|
GeneralSectionData = await GeneralSection.findOne({ where : { ref_no : req.body.pdid ,case_no :req.body.caseno, is_active : 1 }});
|
||||||
PdId = GeneralSectionData.dataValues.pd_id;
|
PdId = GeneralSectionData.dataValues.pd_id;
|
||||||
|
|
||||||
const Photographdata =req.body.data;
|
const Photographdata =req.body.data;
|
||||||
|
|
||||||
for(const value of Photographdata)
|
for(const value of Photographdata)
|
||||||
{
|
{
|
||||||
Object.assign(value, { pd_id: PdId });
|
Object.assign(value, { pd_id: PdId , ref_no :req.body.pdid});
|
||||||
await Photograph.create( value)
|
await Photograph.create( value)
|
||||||
.then((successData)=>{logMsg.info("Photograph insert success ,PdId= "+PdId);})
|
.then((successData)=>{logMsg.info("Photograph insert success ,PdId= "+PdId);})
|
||||||
.catch((err)=>{ logMsg.info("Photograph insert failed ,PdId= "+PdId);});
|
.catch((err)=>{ logMsg.info("Photograph insert failed ,PdId= "+PdId);});
|
||||||
@ -191,10 +219,10 @@ exports.SectionList = async (req, res) =>
|
|||||||
{
|
{
|
||||||
applicantDetails = await ApiCallHelper.MainApplicantDetails(req.query.losid);
|
applicantDetails = await ApiCallHelper.MainApplicantDetails(req.query.losid);
|
||||||
MainApplicantDetails = JSON.parse(applicantDetails);
|
MainApplicantDetails = JSON.parse(applicantDetails);
|
||||||
|
|
||||||
if(MainApplicantDetails.status == 200)
|
if(MainApplicantDetails.status == 200)
|
||||||
{
|
{
|
||||||
GeneralSection.findAll({ where:{losid:req.query.losid,main_loan_applicant:MainApplicantDetails.data.name,is_active : 1},
|
GeneralSection.findAll({ where:{main_loan_applicant:MainApplicantDetails.data.name,is_active : 1},
|
||||||
include: [ {model: FundRequirement }, {model: DetailsOfKeyShareHolder }, {model: FinancialInformation }, {model: FinalRemarks }, {model: BriefOfBusiness }, {model: PropertyInformation }, {model: OfficerDetails }, {model: Photograph }] })
|
include: [ {model: FundRequirement }, {model: DetailsOfKeyShareHolder }, {model: FinancialInformation }, {model: FinalRemarks }, {model: BriefOfBusiness }, {model: PropertyInformation }, {model: OfficerDetails }, {model: Photograph }] })
|
||||||
.then(data =>
|
.then(data =>
|
||||||
{
|
{
|
||||||
|
|||||||
@ -14,6 +14,12 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
income_assessment_program_recommended: { type: DataTypes.STRING },
|
income_assessment_program_recommended: { type: DataTypes.STRING },
|
||||||
fixed_obligations: { type: DataTypes.INTEGER },
|
fixed_obligations: { type: DataTypes.INTEGER },
|
||||||
equipment_contribution_turnover: { type: DataTypes.STRING },
|
equipment_contribution_turnover: { type: DataTypes.STRING },
|
||||||
|
net_profit_net_loss_to_sales : { type: DataTypes.INTEGER },
|
||||||
|
income_considered_per_month : { type: DataTypes.INTEGER },
|
||||||
|
sales_over_py : { type: DataTypes.INTEGER },
|
||||||
|
net_profit_over_py : { type: DataTypes.INTEGER },
|
||||||
|
net_profit_percentage_over_py : { type: DataTypes.INTEGER },
|
||||||
|
|
||||||
createdby: { type: DataTypes.INTEGER },
|
createdby: { type: DataTypes.INTEGER },
|
||||||
updatedby: { type: DataTypes.INTEGER }
|
updatedby: { type: DataTypes.INTEGER }
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user