susee
This commit is contained in:
parent
e14f0637aa
commit
e1bd17df26
3
.gitignore
vendored
3
.gitignore
vendored
@ -4,5 +4,4 @@
|
||||
/storage/uploads/
|
||||
!storage
|
||||
storage/*
|
||||
storage/uploads/*
|
||||
!uploads/.gitkeep
|
||||
!storage/uploads/
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
const { keys, values } = require('lodash');
|
||||
const { keys, values, forEach } = require('lodash');
|
||||
const { sequelize,Test,CreditGeneralInformation,SizeAndGeographicalResearch,CreditProfile,ProductAndProcess,PortFolioHealth,TotalOverallDebit,OverallPlanOfAction,ValidationPoint,
|
||||
CreditLoanDetail,CreditFinalRemarks,CreditGeneralBusinessInformation,CreditKeyProductBusinessContribution,EmployeeStrength,CreditBusinessAndPersonalBankingDetails,CreditFinancialInformation,
|
||||
SupplierDetail ,ClientDetail,CreditFuturePlans,CreditExistingLoanObligation,FamilyMemberInvolvedInBusiness,CreditManager,CreditBorrowerAndGuarantorDetails,CreditFinancialAnalysis,CreditAddressDetail,
|
||||
@ -49,17 +49,21 @@ exports.PullCreditPdData = async (req, res) =>
|
||||
{
|
||||
const tempData = JSON.parse(JSON.stringify(req.body.data));
|
||||
var obj = { };
|
||||
let temp_obj = [ ];
|
||||
var temp_obj = [ ];
|
||||
var arr_ObjKey = [ ]
|
||||
var creditFilter_obj_key = [ ];
|
||||
var creditFilter_table_name = [ ];
|
||||
var key_for_arrays = [ ];
|
||||
var name;
|
||||
var loan_amount;
|
||||
var pd_id = [ ];
|
||||
var resPonse = [ ];
|
||||
|
||||
|
||||
// create creditGeneralInormationData
|
||||
resPonse.length = 0 ; // clear array datas
|
||||
for (const [key, value] of Object.entries(tempData)) {
|
||||
if (key == "Loan details" || key =="Borrower & Guarantor Details") {
|
||||
if (key == "Loan details" || key =="Borrower & Guarantor Details" || key == "Officer Details") {
|
||||
for (var [keys, element] of Object.entries(value)) {
|
||||
if ( Array.isArray(element) == true ) {
|
||||
element.forEach(async(element , index) => {
|
||||
@ -68,11 +72,27 @@ exports.PullCreditPdData = async (req, res) =>
|
||||
Object.assign(obj, { ref_no: req.body.pdid , product :req.body.product , case_no :req.body.caseno});
|
||||
}
|
||||
});
|
||||
} else { if ( keys == 'loan_amount') { { Object.assign( obj , { loan_amount : element })} } }
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( key == "Borrower & Guarantor Details" && keys == 'common_remarks') { Object.assign( obj , {remarks : element}) }
|
||||
if ( keys == 'loan_amount') { { Object.assign( obj , { loan_amount : element })} };
|
||||
if ( key == "Officer Details") {
|
||||
if (moment(element, "DD/MM/YYYY hh:mm:ss A", true).isValid() == true) {
|
||||
var mydate = moment(element, "DD/MM/YYYY hh:MM:ss A"); // convert dd/mm/yyyy to yyyy/mm/dd
|
||||
var my_date = moment(mydate).format("YYYY-MM-DD HH:mm:ss A")
|
||||
Object.assign( obj, { [keys] : my_date });
|
||||
}
|
||||
else{
|
||||
Object.assign(obj, { [ keys ] : element });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Object.assign( obj , { ref_no : req.body.pdid });
|
||||
console.log(obj);
|
||||
pd_id = await CreditGeneralInformation.create(obj)
|
||||
// .then((successData)=>{logMsg.info("GeneralInformation insert success ,PdId= "+successData.dataValues.pd_id);})
|
||||
// .catch((err)=>{ logMsg.info("GeneralInformation insert failed ,PdId(ref_no)= "+req.body.pdid); });
|
||||
@ -81,6 +101,7 @@ exports.PullCreditPdData = async (req, res) =>
|
||||
|
||||
// loop to check if the data is array or nestedObject or objects
|
||||
for (const [key, value] of Object.entries(tempData)) {
|
||||
console.log(key);
|
||||
creditFilter_obj_key = await CreditFilterTable.findAll({ raw: true , attributes: [ 'mul_key' ], where : { section : key , is_active : 1 , is_mul : 1}})
|
||||
creditFilter_table_name = await CreditFilterTable.findAll({ raw: true, attributes: [ 'table_name' ,'section' ,'ques_key'], where : { section : key , is_active : 1 } , group: ['table_name' , 'section' ,'ques_key']})
|
||||
for (let index = 0; index < creditFilter_obj_key.length; index++)
|
||||
@ -92,21 +113,35 @@ exports.PullCreditPdData = async (req, res) =>
|
||||
obj = { }; // clear obj datas
|
||||
|
||||
// Check if the data is array or not
|
||||
for (var [arr_keys, arr_of_element] of Object.entries(value)) {
|
||||
for (var [arr_keys, arr_of_element] of Object.entries(value)) {
|
||||
if ( Array.isArray(arr_of_element) == true )
|
||||
{
|
||||
arr_of_element.forEach(async(iter_element , index) => {
|
||||
// assign only value with in array
|
||||
if (Object.keys(iter_element)[0] == '0') {
|
||||
temp_obj.push({ [arr_keys] : iter_element })
|
||||
}
|
||||
// assign array of objects
|
||||
else
|
||||
{
|
||||
temp_obj.push(iter_element) ;
|
||||
}
|
||||
if (Object.keys(iter_element)[0] == '0') {
|
||||
Object.assign( obj, { [arr_keys] : iter_element });
|
||||
}
|
||||
// assign array of objects
|
||||
else {
|
||||
key_for_arrays = Object.keys(iter_element);
|
||||
Object.values(iter_element).forEach( async (element_ele , index ) => {
|
||||
if ( typeof element_ele === "object" && ( element_ele !== null ))
|
||||
{
|
||||
delete element_ele.display_data;
|
||||
delete value.display_data;
|
||||
await Credit_PdHelper.CreditPd( key_for_arrays[index] , element_ele , arr_ObjKey , obj )
|
||||
}
|
||||
else
|
||||
{
|
||||
// temp_obj.push(iter_element) ;
|
||||
Object.assign( obj, { [key_for_arrays[index]] : element_ele });
|
||||
}
|
||||
});
|
||||
}
|
||||
temp_obj.push(obj)
|
||||
obj = { }; // clear obj datas
|
||||
});
|
||||
}
|
||||
// end of array
|
||||
// assign nestedObject datas
|
||||
else if( typeof arr_of_element === "object" && ( arr_of_element !== null ) )
|
||||
{
|
||||
@ -121,11 +156,14 @@ exports.PullCreditPdData = async (req, res) =>
|
||||
var mydate = moment(arr_of_element, "DD-MM-YYYY"); // convert dd/mm/yyyy to yyyy/mm/dd
|
||||
var my_date = moment(mydate).format("YYYY-MM-DD")
|
||||
Object.assign( obj, { [arr_keys] : my_date });
|
||||
} else { Object.assign( obj, { [arr_keys] : arr_of_element }); }
|
||||
} else {
|
||||
Object.assign( obj, { [arr_keys] : arr_of_element });
|
||||
}
|
||||
}
|
||||
}// end of inner forLoop
|
||||
// DB insertion
|
||||
// insert array of object datas
|
||||
|
||||
if (temp_obj.length != 0 )
|
||||
{
|
||||
temp_obj.forEach( async (temp_obj_element) =>
|
||||
@ -312,3 +350,46 @@ exports.GetCreditPdData = async (req, res) =>
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// // test
|
||||
|
||||
// exports.testGetCreditPdData = async (req, res) =>
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// var resData = await CreditGeneralInformation.findAll({ where : { pd_id : req.query.pdid ,is_active : 1},
|
||||
// include : [
|
||||
// {model: CreditAddressDetail }, {model: CreditFuturePlans },
|
||||
// {model : CreditBorrowerAndGuarantorDetails },
|
||||
// {model: CreditBusinessAndPersonalBankingDetails }, {model: BusinessAsset },
|
||||
// {model: CreditFinancialInformation }, {model: CreditKeyShareholder },
|
||||
// {model: CreditKeyProductBusinessContribution }, {model: EmployeeStrength },
|
||||
// {model: ClientDetail }, {model: StockDetail },
|
||||
// {model: CreditExistingLoanObligation }, {model: FamilyMemberInvolvedInBusiness },
|
||||
// {model : CreditManager }, {model: Photograph },
|
||||
// {model: CreditFinalRemarks }, {model: CreditLoanDetail },
|
||||
// {model: CreditGeneralBusinessInformation }, {model: SupplierDetail }
|
||||
// ]
|
||||
// })
|
||||
// res.send({'status':200,'message':"success",'data':resData});
|
||||
// }
|
||||
// catch(err) {
|
||||
// res.status(500).send({'status':404,
|
||||
// message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
|
||||
// });
|
||||
// }
|
||||
|
||||
// };
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
business_pd_visited_remark: { type: DataTypes.STRING },
|
||||
business_ownership_type: { type: DataTypes.STRING },
|
||||
business_approximate_market_value: { type: DataTypes.INTEGER },
|
||||
business_name_of_the_owner: { type: DataTypes.STRING }, // DataTypes.ARRAY(DataTypes.STRING),
|
||||
business_name_of_the_owner: { type: DataTypes.STRING },
|
||||
business_vintage: { type: DataTypes.INTEGER },
|
||||
business_purchase_year: { type: DataTypes.INTEGER },
|
||||
business_emi: { type: DataTypes.INTEGER },
|
||||
@ -24,6 +24,8 @@ module.exports = (sequelize, DataTypes) => {
|
||||
business_assets_mode: { type: DataTypes.STRING },
|
||||
other_asset_description: { type: DataTypes.STRING },
|
||||
company_name: { type: DataTypes.STRING },
|
||||
business_assets_mode_name: { type: DataTypes.STRING },
|
||||
business_owner_name: { type: DataTypes.STRING },
|
||||
createdby: { type: DataTypes.INTEGER },
|
||||
updatedby: { type: DataTypes.INTEGER }
|
||||
|
||||
|
||||
@ -12,18 +12,21 @@ module.exports = (sequelize, DataTypes) => {
|
||||
provider_name: { type: DataTypes.STRING },
|
||||
client_name: { type: DataTypes.INTEGER },
|
||||
contact_person_name: { type: DataTypes.STRING },
|
||||
contact_person_designation: { type: DataTypes.STRING },
|
||||
contact_person_mobile_no: { type: DataTypes.INTEGER },
|
||||
contact_person_designation: { type: DataTypes.INTEGER },
|
||||
contact_person_mobile_no: { type: DataTypes.STRING },
|
||||
person_stdcode: { type: DataTypes.INTEGER },
|
||||
person_landline: { type: DataTypes.INTEGER },
|
||||
payment_type: { type: DataTypes.STRING },
|
||||
payment_type: { type: DataTypes.INTEGER },
|
||||
credit_period_no: { type: DataTypes.INTEGER },
|
||||
credit_total_purchase: { type: DataTypes.INTEGER },
|
||||
payment_mode: { type: DataTypes.STRING },
|
||||
company_name: { type: DataTypes.STRING },
|
||||
company_name: { type: DataTypes.INTEGER },
|
||||
common_remarks: { type: DataTypes.STRING },
|
||||
createdby: { type: DataTypes.INTEGER },
|
||||
updatedby: { type: DataTypes.INTEGER }
|
||||
updatedby: { type: DataTypes.INTEGER },
|
||||
type_of_payment : { type: DataTypes.STRING }, // new
|
||||
name_of_the_company: { type: DataTypes.STRING }, // new
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
@ -12,6 +12,8 @@ module.exports = (sequelize, DataTypes) => {
|
||||
business_location_suited: { type: DataTypes.STRING },
|
||||
pd_officer_recommendation: { type: DataTypes.STRING },
|
||||
pd_officer_recommendation_other: { type: DataTypes.STRING },
|
||||
pd_officer_recommendation_name: { type: DataTypes.STRING },
|
||||
customer_behaviour_name: { type: DataTypes.STRING },
|
||||
reason: { type: DataTypes.STRING },
|
||||
final_form_remarks: { type: DataTypes.STRING },
|
||||
createdby: { type: DataTypes.INTEGER },
|
||||
|
||||
@ -16,7 +16,9 @@ module.exports = (sequelize, DataTypes) => {
|
||||
low_sale_month: { type: DataTypes.STRING },
|
||||
common_remarks: { type: DataTypes.STRING },
|
||||
createdby: { type: DataTypes.INTEGER },
|
||||
updatedby: { type: DataTypes.INTEGER }
|
||||
updatedby: { type: DataTypes.INTEGER },
|
||||
name_of_the_company: { type: DataTypes.STRING }, // new
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
@ -17,6 +17,11 @@ module.exports = (sequelize, DataTypes) => {
|
||||
location: { type: DataTypes.STRING },
|
||||
ref_no: { type: DataTypes.INTEGER },
|
||||
case_no: { type: DataTypes.STRING },
|
||||
officer_id: { type: DataTypes.INTEGER },
|
||||
email: { type: DataTypes.STRING },
|
||||
mobile_no: { type: DataTypes.INTEGER },
|
||||
officer: { type: DataTypes.STRING },
|
||||
pd_visit_date: { type: DataTypes.STRING },
|
||||
createdby: { type: DataTypes.INTEGER },
|
||||
updatedby: { type: DataTypes.INTEGER }
|
||||
},
|
||||
|
||||
@ -14,7 +14,9 @@ module.exports = (sequelize, DataTypes) => {
|
||||
business_process: { type: DataTypes.STRING },
|
||||
common_remarks: { type: DataTypes.STRING },
|
||||
createdby: { type: DataTypes.INTEGER },
|
||||
updatedby: { type: DataTypes.INTEGER }
|
||||
updatedby: { type: DataTypes.INTEGER },
|
||||
name_of_the_company: { type: DataTypes.STRING }, // new
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
@ -17,7 +17,9 @@ module.exports = (sequelize, DataTypes) => {
|
||||
started_biz: { type: DataTypes.STRING },
|
||||
common_remarks: { type: DataTypes.STRING },
|
||||
createdby: { type: DataTypes.INTEGER },
|
||||
updatedby: { type: DataTypes.INTEGER }
|
||||
updatedby: { type: DataTypes.INTEGER },
|
||||
name_of_the_company: { type: DataTypes.STRING }, // new
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
@ -18,6 +18,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
estimated_stock_value: { type: DataTypes.INTEGER },
|
||||
company_name: { type: DataTypes.STRING },
|
||||
common_remarks: { type: DataTypes.STRING },
|
||||
name_of_the_company: { type: DataTypes.STRING }, // new
|
||||
createdby: { type: DataTypes.INTEGER },
|
||||
updatedby: { type: DataTypes.INTEGER }
|
||||
|
||||
|
||||
@ -12,15 +12,16 @@ module.exports = (sequelize, DataTypes) => {
|
||||
provider_name: { type: DataTypes.STRING },
|
||||
supplier_name: { type: DataTypes.STRING },
|
||||
contact_person_name: { type: DataTypes.STRING },
|
||||
contact_person_designation: { type: DataTypes.STRING },
|
||||
contact_person_mobile_no: { type: DataTypes.INTEGER },
|
||||
contact_person_designation: { type: DataTypes.INTEGER },
|
||||
contact_person_mobile_no: { type: DataTypes.STRING },
|
||||
person_stdcode: { type: DataTypes.INTEGER },
|
||||
person_landline: { type: DataTypes.INTEGER },
|
||||
payment_type: { type: DataTypes.STRING },
|
||||
type_of_payment : { type: DataTypes.STRING }, // new
|
||||
payment_mode: { type: DataTypes.STRING },
|
||||
credit_period_no: { type: DataTypes.INTEGER },
|
||||
credit_total_purchase: { type: DataTypes.INTEGER },
|
||||
company_name: { type: DataTypes.STRING },
|
||||
company_name: { type: DataTypes.INTEGER },
|
||||
name_of_the_company: { type: DataTypes.STRING }, // new
|
||||
common_remarks: { type: DataTypes.STRING },
|
||||
createdby: { type: DataTypes.INTEGER },
|
||||
updatedby: { type: DataTypes.INTEGER }
|
||||
|
||||
@ -216,7 +216,27 @@ router.get('/GetCreditPdData',CreditPdController.GetCreditPdData)
|
||||
router.get("/DownloadPdReport", CreditPdController.DownloadPdReport);
|
||||
|
||||
|
||||
// // test
|
||||
|
||||
// //get credit pd data List Api
|
||||
// /**
|
||||
// * @swagger
|
||||
// * /api/testGetCreditPdData:
|
||||
// * get:
|
||||
// * summary: Get testGetCreditPdData Data List
|
||||
// * description: Get testGetCreditPdData Data List
|
||||
// * parameters:
|
||||
// * - in: query
|
||||
// * name: pdid
|
||||
// * schema:
|
||||
// * type: integer
|
||||
// * required: true
|
||||
// * example: 206
|
||||
// * responses:
|
||||
// * 200:
|
||||
// * description: success
|
||||
// */
|
||||
// router.get('/testGetCreditPdData',CreditPdController.testGetCreditPdData)
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user