susee
This commit is contained in:
parent
4b0d57198a
commit
8972610494
@ -5,11 +5,14 @@ const { sequelize,Test,CreditGeneralInformation,SizeAndGeographicalResearch,Cred
|
||||
CreditKeyShareholder,Covid19Questions,StockDetail,BusinessAsset,CreditFilterTable} = require('../models')
|
||||
const { logMsg } = require('../services/logger.js');
|
||||
const Credit_PdHelper = require('../services/CreditPdHelper.js');
|
||||
const moment = require('moment');
|
||||
var global = require('global')
|
||||
global.arr = [ CreditAddressDetail , CreditBorrowerAndGuarantorDetails , CreditBusinessAndPersonalBankingDetails , BusinessAsset ,
|
||||
ClientDetail , Covid19Questions , EmployeeStrength , CreditExistingLoanObligation ,
|
||||
FamilyMemberInvolvedInBusiness , CreditFinalRemarks , CreditFinancialAnalysis , CreditFinancialInformation ,
|
||||
CreditFuturePlans , CreditGeneralBusinessInformation , CreditGeneralInformation , CreditKeyProductBusinessContribution , CreditKeyShareholder , CreditLoanDetail , OverallPlanOfAction , PortFolioHealth , ProductAndProcess , CreditProfile , SizeAndGeographicalResearch , StockDetail , SupplierDetail , TotalOverallDebit , ValidationPoint , CreditManager ]
|
||||
CreditFuturePlans , CreditGeneralBusinessInformation , CreditGeneralInformation , CreditKeyProductBusinessContribution ,
|
||||
CreditKeyShareholder , CreditLoanDetail , OverallPlanOfAction , PortFolioHealth , ProductAndProcess , CreditProfile ,
|
||||
SizeAndGeographicalResearch , StockDetail , SupplierDetail , TotalOverallDebit , ValidationPoint , CreditManager ]
|
||||
|
||||
exports.Welcome = (req, res) =>
|
||||
{
|
||||
@ -29,41 +32,36 @@ exports.Welcome = (req, res) =>
|
||||
exports.CreditPd = async (req, res) =>
|
||||
{
|
||||
|
||||
const tempData =
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
// {
|
||||
// "pdid":"4526",
|
||||
// "product":"WCTL",
|
||||
// "data":"jsonstring
|
||||
// }
|
||||
|
||||
const tempData = { }
|
||||
|
||||
var obj = { }; // store obj
|
||||
let temp_obj = [ ]; // store array of obj
|
||||
var arr_ObjKey = [ ]
|
||||
var creditFilter_obj_key = [ ];
|
||||
var creditFilter_table_name = [ ];
|
||||
var name;
|
||||
var loan_amount;
|
||||
var pd_id = [ ];
|
||||
// var arrkeys = [ ];
|
||||
// var storeKeys;
|
||||
|
||||
for (const [key, value] of Object.entries(tempData)) {
|
||||
if (key == "Borrower & Guarantor Details") {
|
||||
for (const [key, value] of Object.entries(tempData)) {
|
||||
if (key == "Loan details" || key =="Borrower & Guarantor Details") {
|
||||
for (var [keys, element] of Object.entries(value)) {
|
||||
if ( Array.isArray(element) == true ) // array of object data
|
||||
{
|
||||
element.forEach(async(element , index) => {
|
||||
if ( keys == 'borrower_details' && index == 0 )
|
||||
{
|
||||
name = element['borrower_name'];
|
||||
// pd_id = await CreditGeneralInformation.create({ name : name }); // get main applicant name
|
||||
}
|
||||
});
|
||||
}
|
||||
if ( Array.isArray(element) == true ) { element.forEach(async(element , index) => {
|
||||
if ( keys == 'borrower_details' && index == 0 ) { Object.assign( obj , {name : element['borrower_name']}) } });
|
||||
} else { if ( keys == 'loan_amount') { { Object.assign( obj , { loan_amount : element })} } }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pd_id = await CreditGeneralInformation.create(obj);
|
||||
|
||||
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++)
|
||||
@ -73,8 +71,6 @@ exports.CreditPd = async (req, res) =>
|
||||
if (key == creditFilter_table_name[0].section) {
|
||||
temp_obj.length = 0 ; // clear array
|
||||
obj = { }; // clear obj
|
||||
// arrkeys = key;
|
||||
// storeKeys = Object.keys(value);
|
||||
for (var [arr_keys, arr_of_element] of Object.entries(value)) {
|
||||
if ( Array.isArray(arr_of_element) == true )
|
||||
{
|
||||
@ -88,11 +84,17 @@ exports.CreditPd = async (req, res) =>
|
||||
}
|
||||
else if( typeof arr_of_element === "object" && ( arr_of_element !== null ) )
|
||||
{
|
||||
delete arr_of_element.display_data;
|
||||
delete value.display_data;
|
||||
await Credit_PdHelper.CreditPd( arr_keys , arr_of_element , arr_ObjKey , obj )
|
||||
}
|
||||
else
|
||||
{
|
||||
Object.assign( obj, { [arr_keys] : arr_of_element });
|
||||
if (moment(arr_of_element, "DD-MM-YYYY", true).isValid() == true) {
|
||||
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 }); }
|
||||
}
|
||||
}// inner forLoop
|
||||
// DB insertion
|
||||
@ -105,7 +107,6 @@ exports.CreditPd = async (req, res) =>
|
||||
var index = creditFilter_table_name[0].table_name;
|
||||
var tableName = arr[index]
|
||||
await tableName.create( obj ).then((data)=>{}).catch((err)=>console.log(err));
|
||||
// console.log(obj);
|
||||
});
|
||||
}
|
||||
else
|
||||
@ -114,7 +115,6 @@ exports.CreditPd = async (req, res) =>
|
||||
var index = creditFilter_table_name[0].table_name;
|
||||
var tableName = arr[index]
|
||||
await tableName.create( obj ).then((data)=>{}).catch((err)=>console.log(err));
|
||||
// console.log(obj);
|
||||
}
|
||||
} // if end
|
||||
} // outer forLoop
|
||||
|
||||
@ -14,7 +14,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
address_type_others: { type: DataTypes.STRING },
|
||||
pd_locality: { type: DataTypes.STRING },
|
||||
locality_other: { type: DataTypes.STRING },
|
||||
pd_location: { type: DataTypes.STRING },
|
||||
pd_location: { type: DataTypes.STRING }, // gen info
|
||||
comment_locality: { type: DataTypes.STRING },
|
||||
business_estimated_area: { type: DataTypes.INTEGER },
|
||||
uom: { type: DataTypes.STRING },
|
||||
|
||||
@ -28,12 +28,12 @@ module.exports = (sequelize, DataTypes) => {
|
||||
sales_revenue: { type: DataTypes.STRING },
|
||||
net_profit: { type: DataTypes.STRING },
|
||||
net_profit_sales_percent: { type: DataTypes.STRING },
|
||||
sales_py: { type: DataTypes.INTEGER },
|
||||
netprofit_py: { type: DataTypes.INTEGER },
|
||||
netprofit_py_percent: { type: DataTypes.INTEGER },
|
||||
debtor_days_cet: { type: DataTypes.INTEGER },
|
||||
creditor_days_cet: { type: DataTypes.INTEGER },
|
||||
inventory_days_cet: { type: DataTypes.INTEGER },
|
||||
sales_py: { type: DataTypes.STRING },
|
||||
netprofit_py: { type: DataTypes.STRING },
|
||||
netprofit_py_percent: { type: DataTypes.STRING },
|
||||
debtor_days_cet: { type: DataTypes.STRING },
|
||||
creditor_days_cet: { type: DataTypes.STRING },
|
||||
inventory_days_cet: { type: DataTypes.STRING },
|
||||
company_name: { type: DataTypes.STRING },
|
||||
no_of_financial_years: { type: DataTypes.INTEGER },
|
||||
common_remarks: { type: DataTypes.STRING },
|
||||
|
||||
@ -7,7 +7,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
CreditKeyProductBusinessContribution.init(
|
||||
{
|
||||
pd_id: { type: DataTypes.INTEGER },
|
||||
product_name: { type: DataTypes.STRING },
|
||||
product_name: { type: DataTypes.STRING }, // gen info
|
||||
contribution_business_product: { type: DataTypes.STRING },
|
||||
remarks: { type: DataTypes.STRING },
|
||||
company_name: { type: DataTypes.STRING },
|
||||
|
||||
@ -7,7 +7,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
CreditLoanDetail.init(
|
||||
{
|
||||
pd_id: { type: DataTypes.INTEGER },
|
||||
loan_amount: { type: DataTypes.INTEGER },
|
||||
loan_amount: { type: DataTypes.INTEGER }, // gen info
|
||||
remarks_fund_source_balance: { type: DataTypes.STRING },
|
||||
loan_tenure: { type: DataTypes.INTEGER },
|
||||
sub_product: { type: DataTypes.STRING },
|
||||
|
||||
26
package-lock.json
generated
26
package-lock.json
generated
@ -11,11 +11,14 @@
|
||||
"dependencies": {
|
||||
"body-parser": "^1.19.0",
|
||||
"cors": "^2.8.5",
|
||||
"date-and-time": "^2.3.1",
|
||||
"dateformat": "^5.0.3",
|
||||
"dotenv": "^10.0.0",
|
||||
"express": "^4.17.1",
|
||||
"global": "^4.4.0",
|
||||
"lodash": "^4.17.21",
|
||||
"log4js": "^6.3.0",
|
||||
"moment": "^2.29.3",
|
||||
"mssql": "^7.2.0",
|
||||
"request": "^2.88.2",
|
||||
"sequelize": "^6.6.5",
|
||||
@ -1521,6 +1524,11 @@
|
||||
"node": ">=0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/date-and-time": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/date-and-time/-/date-and-time-2.3.1.tgz",
|
||||
"integrity": "sha512-OaIRmSJXifwEN21rMVVDs0Kz8uhJ3wWPYd86atkRiqN54liaMQYEbbrgjZQea75YXOBWL4ZFb3rG/waenw1TEg=="
|
||||
},
|
||||
"node_modules/date-format": {
|
||||
"version": "4.0.7",
|
||||
"resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.7.tgz",
|
||||
@ -1537,6 +1545,14 @@
|
||||
"node": ">0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/dateformat": {
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-5.0.3.tgz",
|
||||
"integrity": "sha512-Kvr6HmPXUMerlLcLF+Pwq3K7apHpYmGDVqrxcDasBg86UcKeTSNWbEzU8bwdXnxnR44FtMhJAxI4Bov6Y/KUfA==",
|
||||
"engines": {
|
||||
"node": ">=12.20"
|
||||
}
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
@ -6201,6 +6217,11 @@
|
||||
"assert-plus": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"date-and-time": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/date-and-time/-/date-and-time-2.3.1.tgz",
|
||||
"integrity": "sha512-OaIRmSJXifwEN21rMVVDs0Kz8uhJ3wWPYd86atkRiqN54liaMQYEbbrgjZQea75YXOBWL4ZFb3rG/waenw1TEg=="
|
||||
},
|
||||
"date-format": {
|
||||
"version": "4.0.7",
|
||||
"resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.7.tgz",
|
||||
@ -6211,6 +6232,11 @@
|
||||
"resolved": "https://registry.npmjs.org/date-utils/-/date-utils-1.2.21.tgz",
|
||||
"integrity": "sha1-YfsWzcEnSzyayq/+n8ad+HIKK2Q="
|
||||
},
|
||||
"dateformat": {
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-5.0.3.tgz",
|
||||
"integrity": "sha512-Kvr6HmPXUMerlLcLF+Pwq3K7apHpYmGDVqrxcDasBg86UcKeTSNWbEzU8bwdXnxnR44FtMhJAxI4Bov6Y/KUfA=="
|
||||
},
|
||||
"debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
|
||||
@ -11,11 +11,14 @@
|
||||
"dependencies": {
|
||||
"body-parser": "^1.19.0",
|
||||
"cors": "^2.8.5",
|
||||
"date-and-time": "^2.3.1",
|
||||
"dateformat": "^5.0.3",
|
||||
"dotenv": "^10.0.0",
|
||||
"express": "^4.17.1",
|
||||
"global": "^4.4.0",
|
||||
"lodash": "^4.17.21",
|
||||
"log4js": "^6.3.0",
|
||||
"moment": "^2.29.3",
|
||||
"mssql": "^7.2.0",
|
||||
"request": "^2.88.2",
|
||||
"sequelize": "^6.6.5",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user