GWM:MEQ
This commit is contained in:
parent
21b7fad232
commit
d6d3fe500d
@ -29,7 +29,7 @@ exports.PullSalesPdData = async (req, res) =>
|
||||
Object.assign(values, { ref_no: req.body.pdid , product :req.body.product , case_no :req.body.caseno});
|
||||
await GeneralSection.create( values )
|
||||
.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+ " ERR =" + err); });
|
||||
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+" Error = "+err); }); };
|
||||
@ -51,14 +51,26 @@ exports.PullSalesPdData = async (req, res) =>
|
||||
Object.assign(values, { ref_no: req.body.pdid , product :req.body.product , case_no :req.body.caseno});
|
||||
await GeneralSection.create( values )
|
||||
.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+ " ERR =" + err); });
|
||||
|
||||
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+" 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+" 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+" Error = "+err);}); };
|
||||
if (keys == 'section5') {
|
||||
|
||||
if (keys == 'section4' && req.body.product == 'MEQ')
|
||||
{
|
||||
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("BreifOfBusiness insert failed ,PdId= "+storeId.pd_id+" Error = "+err);});
|
||||
}
|
||||
else 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' && req.body.product == 'MEQ')
|
||||
{
|
||||
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("BreifOfBusiness insert failed ,PdId= "+storeId.pd_id+" Error = "+err);});
|
||||
}
|
||||
else if (keys == 'section5') {
|
||||
//initially declare calculation values as 0
|
||||
pre_year_sales = 0;
|
||||
pre_year_net_profit = 0;
|
||||
@ -87,7 +99,39 @@ exports.PullSalesPdData = async (req, res) =>
|
||||
|
||||
}
|
||||
}
|
||||
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 == 'section6' && req.body.product == 'MEQ')
|
||||
{
|
||||
//initially declare calculation values as 0
|
||||
pre_year_sales = 0;
|
||||
pre_year_net_profit = 0;
|
||||
pre_year_net_pro_loss_per = 0;
|
||||
for (let i = 0; i < 4; i++)
|
||||
{
|
||||
if(values[i])
|
||||
{
|
||||
sales_revenue = values[i].sales_revenue;
|
||||
net_profit = values[i].net_profit;
|
||||
income_considered_per_month = parseFloat((values.income_considered / 12)).toFixed(2);
|
||||
net_profit_net_loss_to_sales = parseFloat(((net_profit / sales_revenue) * 100)).toFixed(2);
|
||||
sales_over_py = parseFloat((((sales_revenue - pre_year_sales) / pre_year_sales ) * 100)).toFixed(2);
|
||||
net_profit_over_py = parseFloat((((net_profit - pre_year_net_profit) / pre_year_net_profit ) * 100)).toFixed(2);
|
||||
net_profit_percentage_over_py = parseFloat(((( ((net_profit / sales_revenue ) * 100 ) - pre_year_net_pro_loss_per) / pre_year_net_pro_loss_per ) * 100)).toFixed(2);
|
||||
if(sales_over_py == "Infinity"){sales_over_py="NA";}if(net_profit_over_py == "Infinity"){net_profit_over_py="NA";}if(net_profit_percentage_over_py == "Infinity"){net_profit_percentage_over_py="NA";}
|
||||
//assign calculated value inside object(on fly object inside for loop)
|
||||
Object.assign(values[i], { pd_id: storeId.pd_id , income_considered: values.income_considered , income_assessment_program_recommended: values.income_assessment_program_recommended , fixed_obligations: values.fixed_obligations , income_considered_per_month:income_considered_per_month , net_profit_net_loss_to_sales:net_profit_net_loss_to_sales , sales_over_py:sales_over_py , net_profit_over_py:net_profit_over_py , net_profit_percentage_over_py:net_profit_percentage_over_py});
|
||||
//insert data here
|
||||
await FinancialInformation.create( values[i] ).then((successData)=>{logMsg.info("FinancialInformation insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("FinancialInformation insert failed ,PdId= "+storeId.pd_id+" Error = "+err);});
|
||||
//reset calculation values
|
||||
pre_year_sales = sales_revenue;
|
||||
pre_year_net_profit = net_profit;
|
||||
pre_year_net_pro_loss_per = ((net_profit / sales_revenue ) * 100 );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else 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);}); };
|
||||
@ -273,33 +317,16 @@ exports.SectionList = async (req, res) =>
|
||||
|
||||
pdId = req.query.pd_id;
|
||||
GeneralSection.findAll({ where:{ref_no:pdId,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: ProductInformation } , {model: InstitutionDetail } , {model: Photograph }] })
|
||||
.then(data =>
|
||||
{
|
||||
section_name_obj = {
|
||||
section1_key : "GeneralSection" ,
|
||||
section1_name : "General Section" ,
|
||||
section2_key : "FundRequirements",
|
||||
section2_name : "Fund Requirements",
|
||||
section3_key : "DetailsOfKeyShareHolders",
|
||||
section3_name : "Details Of Key Share Holders",
|
||||
section4_key : "BriefOfBusinesses",
|
||||
section4_name : "Brief Of Businesses",
|
||||
section5_key : "FinancialInformations",
|
||||
section5_name : "Financial Informations",
|
||||
section6_key : "PropertyInformations",
|
||||
section6_name : "Property Informations",
|
||||
section7_key : "FinalRemarks",
|
||||
section7_name : "Final Remarks",
|
||||
section8_key : "OfficerDetails",
|
||||
section8_name : "Officer Details",
|
||||
section9_key : "Photographs",
|
||||
section9_name : "Photographs",
|
||||
// section10_key : "InstitutionDetails",
|
||||
// section10_name : "Institution Details",
|
||||
// section11_key : "ProductInformations",
|
||||
// section11_name : "Product Informations",
|
||||
};
|
||||
{
|
||||
|
||||
if(data[0].dataValues.product == 'MEQ')
|
||||
{
|
||||
section_name_obj = {section1_key : "GeneralSection" ,section1_name : "General Section" ,section2_key : "FundRequirements",section2_name : "Fund Requirements",section3_key : "DetailsOfKeyShareHolders",section3_name : "Details Of Key Share Holders",section4_key : "InstitutionDetails",section4_name : "Institution Details",section5_key : "ProductInformations",section5_name : "Product Informations",section6_key : "FinancialInformations",section6_name : "Financial Informations",section7_key : "FinalRemarks",section7_name : "Final Remarks",section8_key : "OfficerDetails",section8_name : "Officer Details",section9_key : "Photographs",section9_name : "Photographs"};
|
||||
}else{
|
||||
section_name_obj = {section1_key : "GeneralSection" ,section1_name : "General Section" ,section2_key : "FundRequirements",section2_name : "Fund Requirements",section3_key : "DetailsOfKeyShareHolders",section3_name : "Details Of Key Share Holders",section4_key : "BriefOfBusinesses",section4_name : "Brief Of Businesses",section5_key : "FinancialInformations",section5_name : "Financial Informations",section6_key : "PropertyInformations",section6_name : "Property Informations",section7_key : "FinalRemarks",section7_name : "Final Remarks",section8_key : "OfficerDetails",section8_name : "Officer Details",section9_key : "Photographs",section9_name : "Photographs"};
|
||||
}
|
||||
|
||||
if(data.length > 0)
|
||||
{
|
||||
|
||||
@ -12,10 +12,16 @@ module.exports = (sequelize, DataTypes) => {
|
||||
instituion_vitage: { type: DataTypes.STRING },
|
||||
opening_new_branch: { type: DataTypes.STRING },
|
||||
property_ownership: { type: DataTypes.STRING },
|
||||
area_sq_feet: { type: DataTypes.INTEGER },
|
||||
floor: { type: DataTypes.INTEGER },
|
||||
staff_observer_number: { type: DataTypes.INTEGER },
|
||||
business_activity_seen: { type: DataTypes.STRING },
|
||||
area_sq_feet: { type: DataTypes.STRING },
|
||||
floor: { type: DataTypes.STRING },
|
||||
how_many_beds : {type: DataTypes.STRING},
|
||||
occupancy_ratio : {type: DataTypes.STRING},
|
||||
tot_doctors : {type: DataTypes.STRING},
|
||||
permanent_doctors : {type: DataTypes.STRING},
|
||||
temp_doctors : {type: DataTypes.STRING},
|
||||
business_activity_seen : {type: DataTypes.STRING},
|
||||
staff_observer_number: { type: DataTypes.STRING },
|
||||
|
||||
createdby: { type: DataTypes.INTEGER },
|
||||
updatedby: { type: DataTypes.INTEGER }
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user