diff --git a/app/controllers/obligation.controller.js b/app/controllers/obligation.controller.js index 4f380c2..37bf430 100644 --- a/app/controllers/obligation.controller.js +++ b/app/controllers/obligation.controller.js @@ -1,6 +1,7 @@ -const { sequelize,Test,ObligationMaster,ObligationBankStatement,EmiTracking} = require('../models') +const { sequelize,Test,ObligationMaster,ObligationBankStatement,EmiTracking,Gst} = require('../models') const { logMsg } = require('../services/logger.js'); -var swaggerSpecToPdf = require("swagger-spec-to-pdf") +var swaggerSpecToPdf = require("swagger-spec-to-pdf"); +const { Console } = require('winston/lib/winston/transports'); // get all Obligation master data @@ -149,8 +150,16 @@ exports.GetEmiTrackingMonth = async (req, res) => exports.CreateObligationEmiTrackingMonth = async (req, res) => { try - { - await EmiTracking.create(req.body) + { + var dateStore = [ ] + var date = new Date(req.body.month_6); + for (let i = 0; i < 5; i++) { + var a = date.setMonth(date.getMonth() - 1); + var b = date.toLocaleDateString("en-GB") + var yourdate = b.split("/").reverse().join("-"); + dateStore.push(yourdate) + } + await EmiTracking.create({los_id : req.body.los_id , month_1 : dateStore[4] , month_2 : dateStore[3] , month_3 : dateStore[2] ,month_4 : dateStore[1] , month_5 : dateStore[0] , month_6 : req.body.month_6 }) .then(data => { res.send({'status':200,'message':"success",'data': data}); @@ -176,7 +185,16 @@ exports.UpdateObligationEmiTracking = async (req, res) => id = req.body.id; delete req.body.id await EmiTracking.update({is_active : 0 },{ where: { id: id }}); - EmiTracking.create(req.body).then(data => + var dateStore = [ ] + var date = new Date(req.body.month_6); + for (let i = 0; i < 5; i++) { + var a = date.setMonth(date.getMonth() - 1); + var b = date.toLocaleDateString("en-GB") + var yourdate = b.split("/").reverse().join("-"); + dateStore.push(yourdate) + } + await EmiTracking.create({los_id : req.body.los_id , month_1 : dateStore[4] , month_2 : dateStore[3] , month_3 : dateStore[2] ,month_4 : dateStore[1] , month_5 : dateStore[0] , month_6 : req.body.month_6 }) + .then(data => { res.send({'status':200,'message':"success",'data':data}); }) @@ -193,3 +211,41 @@ exports.UpdateObligationEmiTracking = async (req, res) => +exports.excel = async (req, res) => +{ + const { getJsDateFromExcel } = require("excel-date-to-js"); + const reader = require('xlsx') + // Reading our test file + const file = reader.readFile('./cr_policy.xlsx') + + let data = [] + + + const sheets = file.SheetNames[1] + const temp = reader.utils.sheet_to_json( + file.Sheets[file.SheetNames[1]]) + temp.forEach(async(element) => { + var tempData ={ + property_ownership_document_available: Object.values(element)[0], + type_of_property: Object.values(element)[1], + property_used_in_business: Object.values(element)[2], + property_free_loan_taken: Object.values(element)[3], + property_in_the_name_of_applicant:Object.values(element)[4], + loan_obligated_in_cet:Object.values(element)[5], + property_created_in_last_eight_yr:Object.values(element)[6], + value_to_be_considered: Object.values(element)[7], + mv_to_be_added_to_atnw: Object.values(element)[8], + final_value_considered:Object.values(element)[9] + } + await Gst.create(tempData) + }); + + // CreditFacilityCurrentDertail.bulkCreate(data).then((data)=>res.send(data)).catch() + }; + + + + + + + diff --git a/app/routes/routes.js b/app/routes/routes.js index c098ae7..b2ecb3f 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -439,31 +439,6 @@ router.get("/getObligationBankStatement",Mycontroller.GetObligationBankStatement * type: string * description: los_id * example: 123ab -* month_1: -* type: string -* description: month_1 -* example: "2017-01-01" -* format: date -* month_2: -* type: string -* description: month_1 -* example: "2022-04-12" -* format: date -* month_3: -* type: string -* description: month_1 -* example: "2022-04-12" -* format: date -* month_4: -* type: string -* description: month_1 -* example: "2022-04-12" -* format: date -* month_5: -* type: string -* description: month_1 -* example: "2022-04-12" -* format: date * month_6: * type: string * description: month_1 @@ -507,31 +482,6 @@ router.post("/createObligationEmiTrackingMonth",Mycontroller.CreateObligationEmi * type: string * description: los_id * example: 123ab -* month_1: -* type: string -* description: month_1 -* example: "2017-01-01" -* format: date -* month_2: -* type: string -* description: month_1 -* example: "2022-04-12" -* format: date -* month_3: -* type: string -* description: month_1 -* example: "2022-04-12" -* format: date -* month_4: -* type: string -* description: month_1 -* example: "2022-04-12" -* format: date -* month_5: -* type: string -* description: month_1 -* example: "2022-04-12" -* format: date * month_6: * type: string * description: month_1 @@ -560,8 +510,6 @@ router.post("/createObligationEmiTrackingMonth",Mycontroller.CreateObligationEmi * description: failure in updating Obligation EmiTracking details */ router.post("/updateObligationEmiTracking",Mycontroller.UpdateObligationEmiTracking) - - // routes started here app.use('/api', router); diff --git a/cr_policy.xlsx b/cr_policy.xlsx new file mode 100644 index 0000000..126a3fc Binary files /dev/null and b/cr_policy.xlsx differ diff --git a/server.js b/server.js index 23a8609..48d83b5 100644 --- a/server.js +++ b/server.js @@ -62,4 +62,3 @@ app.listen({ port: PORT_NUMBER }, async () => { //await sequelize.authenticate() }) -