diff --git a/app/controllers/cibil.controller.js b/app/controllers/cibil.controller.js index 02a8165..e34dbf4 100644 --- a/app/controllers/cibil.controller.js +++ b/app/controllers/cibil.controller.js @@ -568,21 +568,22 @@ exports.ConsolidatedActiveAndClosedLoansReviewAction =async (req, res) => var LoanDataPromises = new Promise(async(resolve, reject) => { FinalLoanData = []; - LoanData[0].forEach(async(value,index,array) => { + + for(const [index,value] of LoanData[0].entries()) + { if(value.loan_count == 1) { - Object.assign(value , {subValue : [] }); - if (index === array.length -1) { resolve(FinalLoanData); } + Object.assign(value , {children : [] }); + FinalLoanData.push(value); + if (index === LoanData[0].length -1) { resolve(FinalLoanData); } }else{ subValue = await OutputActiveAndClosedLoans.findAll({raw:true,where:{losid:value.losid,grp_str:value.grp_str}}) .catch(err=>{ }); - Object.assign(value , {subValue : subValue }); - if (index === array.length -1) { resolve(FinalLoanData); } + Object.assign(value , {children : subValue }); + FinalLoanData.push(value); + if (index === LoanData[0].length -1) { resolve(FinalLoanData); } } - - FinalLoanData.push(value); - - }); + } }); LoanDataPromises.then(async(FinalLoanData)=>{ setTimeout(() => { @@ -826,10 +827,13 @@ exports.test = async (req, res) => { - // date = '04-AUG-2017'; - // data = moment(new Date(date)).format("YYYY-MM-DD"); - // console.log(data); - res.send({"gwm":"data"}); + x = '01-01-1996'; + data = { + "date" : null || moment(new Date(x)).format("YYYY-MM-DD") + } + + console.log(data); + res.send({"data":data}); } catch(err) { res.status(500).send({'status':404,