diff --git a/src/assets/data/sales_pd_templates/22.json b/src/assets/data/sales_pd_templates/22.json new file mode 100644 index 0000000..cc83217 --- /dev/null +++ b/src/assets/data/sales_pd_templates/22.json @@ -0,0 +1,1654 @@ +{ + "form_name":"Personal Discussion Sheet - Business Loans (For Sales Team)", + "config":[ + { + "purpose":"LOCAL_OR_API_FORM_VALUES", + "expression":"(function () {if(control.question_key == 'constitution'){addorUpdateLocalStorage('constitution',control.answer_value);}return true}());", + "value_keys":[{"key_names":["constitution"],"section_id":"1"},{"key_names":["institution_type"],"section_id":"4"}] + } + ], + "sections":[ + { + "section_id":"1", + "section_name":"General Section", + "onsubmit":[ + { + "key_name":"constitution", + "expression":"(function () {if(control.question_key == 'constitution'){addorUpdateLocalStorage('constitution',control.answer_value);}return true}());", + "msg":"" + } + ], + "questions":[ + { + "question":"Name of The Main Loan Applicant", + "question_key":"main_loan_applicant", + "place_holder":"Enter text", + "type":"1", + "answers":null, + "api_properties":null, + "is_repeatable":null, + "field_type":"string", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Main Loan Applicant Name Required", + "value":null + }, + { + "name":"pattern", + "isactive":"1", + "validator":"[A-Za-z ]*", + "message":"alphabets only ", + "value":null + } + ], + "onchange_properties":null + }, + { + "question":"Name of the Company", + "question_key":"company_name", + "place_holder":"Enter text", + "type":"1", + "answers":null, + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Company Name Required", + "value":null + }, + { + "name":"pattern", + "isactive":"1", + "validator":"[A-Za-z ]*", + "message":"alphabets only ", + "value":null + } + ] + }, + { + "question":"Constitution", + "question_key":"constitution", + "place_holder":"Enter text", + "type":"1", + "answers":null, + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Constitution Required", + "value":null + }, + { + "name":"pattern", + "isactive":"1", + "validator":"[A-Za-z ]*", + "message":"alphabets only ", + "value":null + } + ] + }, + { + "question":"Name of the Person Met during visit", + "question_key":"person_met_during_visit", + "place_holder":"Enter text", + "type":"1", + "answers":null, + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Person Met Name Required", + "value":null + }, + { + "name":"pattern", + "isactive":"1", + "validator":"[A-Za-z ]*", + "message":"alphabets only ", + "value":null + } + ] + }, + { + "question":"Person Met Designation", + "question_key":"person_met_designation", + "type":"8", + "answers":null, + "api_properties":{ + "api":"getListOfMaster", + "api_method":"POST", + "params":{ + "master_name":"DESIGNATION" + }, + "fields":[ + "designation_id", + "designation" + ] + }, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Designation Required", + "value":null + } + ] + }, + { + "question":"Person Met Contact No", + "question_key":"person_met_contact_no", + "type":"1", + "field_type":"num", + "place_holder":"Enter the number", + "answers":null, + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Contact no Required", + "value":null + }, + { + "name":"pattern", + "isactive":"1", + "validator":"[0-9]{10,12}", + "message":"Mobile number must be 10 digit", + "value":null + } + ] + }, + { + "question":"Address Visited", + "question_key":"address_visited", + "place_holder":"Enter door no,street", + "type":"1", + "answers":null, + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Address Required", + "value":null + } + ] + }, + { + "question":"State", + "question_key":"state", + "type":"8", + "answers":null, + "api_properties":{ + "api":"getListOfMaster", + "api_method":"POST", + "params":{ + "master_name":"STATE" + }, + "fields":[ + "state_id", + "name" + ] + }, + "onchange_properties":[ + { + "purpose":"api", + "api":"getListOfStatesAndCities", + "api_method":"POST", + "params":"{records:{state_id:'value_of_answer'}}", + "fields":[ + "state_id", + "name" + ], + "local_variable":"local_city" + } + ], + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"State Required", + "value":null + } + ] + }, + { + "question":"City", + "question_key":"city", + "type":"8", + "answers":null, + "api_properties":"local_city", + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"CIty Required", + "value":null + } + ] + }, + { + "question":"Pincode", + "question_key":"pincode", + "type":"8", + "answers":null, + "api_properties":"local_pincode", + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Pincode Required", + "value":null + } + ] + } + ] + }, + { + "section_id":"2", + "section_name":"Fund Requirement", + "onsubmit":null, + "questions":[ + { + "question":"Loan Amount (Rs)", + "question_key":"loan_amount_applied", + "place_holder":"Enter amount", + "type":"1", + "answers":null, + "api_properties":null, + "is_repeatable":null, + "field_type":"numtoword", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Loan amount Required", + "value":null + } + ], + "onchange_properties":[ + ] + }, + { + "question":"Loan Tenure (Months)", + "question_key":"loan_tenure", + "place_holder":"Enter number", + "type":"1", + "answers":null, + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"num", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Loan tenure Required" + }, + { + "name":"maxLength", + "validator":"3", + "isactive":"1", + "message":"loan tenure 3 digit only", + "value":null + } + ] + }, + { + "question":"Loan Purpose (End-Use)", + "question_key":"loan_purpose", + "type":"4", + "answers":[ + { + "answer_id":"Puchase of Medical Equipment", + "answer":"Puchase of Medical Equipment", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + }, + { + "answer_id":"Refinance", + "answer":"Refinance", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + }, + { + "answer_id":"Others (Specify)", + "answer":"Others (Specify)", + "subfield_key":"other_end_use", + "subfield_caption":"Specifiy Other End Use", + "subfield_type":"1" + } + ], + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Loan purpose Required", + "value":null + } + ] + } + ] + }, + { + "section_id":"3", + "section_name":"Details of key stakeholders", + "onsubmit":[ + { + "key_name":"share_holding", + "expression":"(function () {let sum_val=null;let ques_key=[];control.questions_group.forEach(ques_obj=>{ques_obj.questions.map(ques=>{if(ques.question_key == 'share_holding'){ques_key.push(ques)}})});if(ques_key.length > 0){sum_val= ques_key.map(val=>val.answer_value).reduce((tot,val)=>{return parseInt(tot)+parseInt(val)})}return sum_val<=100}())", + "msg":"Sum of shareholding should be equal to 100" + } + ], + "questions":[ + { + "question":[ + { + "question":"Name", + "question_key":"name", + "place_holder":"Enter text", + "type":"1", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Name Required", + "value":null + }, + { + "name":"pattern", + "isactive":"1", + "validator":"[A-Za-z ]*", + "message":"alphabets only ", + "value":null + } + ] + }, + { + "question":"Share Holding (%)", + "question_key":"share_holding", + "place_holder":"Enter number", + "type":"1", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"num", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Share value Required", + "value":null + }, + { + "name":"max", + "validator":"100", + "isactive":"1", + "message":"Number must be less than 100", + "value":null + } + ] + }, + { + "question":"Vintage in Current Business", + "question_key":"vintage_in_current_biz", + "place_holder":"Enter in years", + "type":"1", + "api_properties":null, + "answers":null, + "is_repeatable":null, + "field_type":"num", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Current vintage Required", + "value":null + }, + { + "name":"pattern", + "isactive":"1", + "validator":"[0-9]{0,3}", + "message":"Year should be 3 digit", + "value":null + } + ], + "onchange_properties":[ + { + "purpose":"validations", + "validations":[ + { + "name":"max", + "isactive":"1", + "validator":"", + "message":"should be less or equal to Total Work Exp", + "value":"total_work_exp", + "validation_to":null, + "value_keys":null + } + ] + }, + { + "purpose":"FORM_CTRL", + "form_controls":[ + { + "insert_index":"total_work_exp", + "expression":"(total_work_exp > vintage_in_current_biz)", + "value_keys":[ + "total_work_exp", + "vintage_in_current_biz" + ], + "questions":[ + { + "question_key":"previous_experience_details", + "question":"Previous Experience Details", + "place_holder":"Enter text", + "type":"1", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Previous Experience Required", + "value":null + } + ] + } + ] + } + ] + } + ] + }, + { + "question":"Total Work Exp", + "question_key":"total_work_exp", + "place_holder":"Enter in years", + "type":"1", + "api_properties":null, + "answers":null, + "is_repeatable":null, + "field_type":"num", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Total experience Required", + "value":null + }, + { + "name":"maxLength", + "isactive":"1", + "validator":"2", + "message":"Year should be two digit", + "value":null + } + ], + "onchange_properties":[ + { + "purpose":"validations", + "validations":[ + { + "name":"min", + "isactive":"1", + "validator":"", + "message":"should be greater or equal to current work exp", + "value":"vintage_in_current_biz", + "validation_to":null, + "value_keys":null + } + ] + }, + { + "purpose":"FORM_CTRL", + "form_controls":[ + { + "insert_index":"total_work_exp", + "expression":"(total_work_exp > vintage_in_current_biz)", + "value_keys":[ + "total_work_exp", + "vintage_in_current_biz" + ], + "questions":[ + { + "question":"Previous Experience Details", + "question_key":"previous_experience_details", + "place_holder":"Enter text", + "type":"1", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Previous Experience Required", + "value":null + } + ] + } + ] + } + ] + } + ] + }, + { + "question":"Started Business", + "question_key":"started_biz", + "type":"3", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "answers":[ + { + "answer_id":"Yes", + "answer":"Yes", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + }, + { + "answer_id":"No", + "answer":"No", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + } + ], + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Started Business Required", + "value":null + } + ] + } + ], + "is_repeatable":"1", + "group_title":"Details of Key Stakeholders in the Business" + } + ] + }, + { + "section_id": "4", + "section_name": "Institution Details", + "onsubmit":[ + { + "key_name":"institution_type", + "expression":"(function () {if(control.question_key == 'institution_type'){addorUpdateLocalStorage('institution_type',control.answer_value);}return true}());", + "msg":"" + } + ], + "questions": [ + { + "question":"Type of institution", + "question_key":"institution_type", + "type":"3", + "api_properties":null, + "onchange_properties":[ + { + "purpose":"FORM_CTRL", + "form_controls":[ + { + "insert_index":"occupancy_ratio", + "expression":"(String('institution_type') == String('Hospital')) || (String('institution_type') == String('Nursing Home'))", + "value_keys":[ + "institution_type" + ], + "questions":[ + { + "question_key":"tot_doctors", + "question":"How many doctor’s", + "place_holder": "Enter the number", + "type": "1", + "api_properties": null, + "answers": null, + "onchange_properties": null, + "is_repeatable": null, + "field_type": "num", + "validations": [ + { + "name": "required", + "isactive": "1", + "validator": "Validators.required", + "message": "Required", + "value": null + }, + { + "name": "pattern", + "isactive": "1", + "validator": "[0-9]*", + "message": "Number only accepted", + "value": null + } + ] + }, + { + "question_key":"permanent_doctors", + "question":"Permanent", + "place_holder": "Enter the number", + "type": "1", + "api_properties": null, + "answers": null, + "onchange_properties": null, + "is_repeatable": null, + "field_type": "num", + "validations": [ + { + "name": "required", + "isactive": "1", + "validator": "Validators.required", + "message": "Required", + "value": null + }, + { + "name": "pattern", + "isactive": "1", + "validator": "[0-9]*", + "message": "Number only accepted", + "value": null + } + ] + }, + { + "question_key":"temp_doctors", + "question":"Temporary", + "place_holder": "Enter the number", + "type": "1", + "api_properties": null, + "answers": null, + "onchange_properties": null, + "is_repeatable": null, + "field_type": "num", + "validations": [ + { + "name": "required", + "isactive": "1", + "validator": "Validators.required", + "message": "Required", + "value": null + }, + { + "name": "pattern", + "isactive": "1", + "validator": "[0-9]*", + "message": "Number only accepted", + "value": null + } + ] + } + ] + } + ] + } + ], + "is_repeatable":null, + "answers":[ + { + "answer_id":"Hospital", + "answer":"Hospital", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + }, + { + "answer_id":"Nursing Home", + "answer":"Nursing Home", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + }, + { + "answer_id":"Diagnostic Centre", + "answer":"Diagnostic Centre", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + } + ], + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Required", + "value":null + } + ] + }, + { + "question":"About the Locality", + "question_key":"about_locality", + "type":"4", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "answers":[ + { + "answer_id":"Hospital area", + "answer":"Hospital area", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + }, + { + "answer_id":"Commercial area", + "answer":"Commercial area", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + }, + { + "answer_id":"Residential area", + "answer":"Residential area", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + } + ], + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Required", + "value":null + } + ] + }, + { + "question":"Institution Vintage", + "question_key":"instituion_vitage", + "type":"3", + "api_properties":null, + "onchange_properties":[ + { + "purpose":"FORM_CTRL", + "form_controls":[ + { + "insert_index":"instituion_vitage", + "expression":"(String('instituion_vitage') == String('Existing'))", + "value_keys":[ + "instituion_vitage" + ], + "questions":[ + { + "question_key":"existing_since", + "question":"Existing Since", + "place_holder": "Enter the number", + "type": "1", + "api_properties": null, + "answers": null, + "onchange_properties": null, + "is_repeatable": null, + "field_type": "num", + "validations": [ + { + "name": "required", + "isactive": "1", + "validator": "Validators.required", + "message": "Required", + "value": null + }, + { + "name": "pattern", + "isactive": "1", + "validator": "[0-9]*", + "message": "Number only accepted", + "value": null + } + ] + } + ] + } + ] + } + ], + "is_repeatable":null, + "answers":[ + { + "answer_id":"New (Startup)", + "answer":"New (Startup)", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + }, + { + "answer_id":"Existing", + "answer":"Existing", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + } + ], + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Required", + "value":null + } + ] + }, + { + "question":"Opening New Branch (Yes/No)", + "question_key":"opening_new_branch", + "type":"3", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "answers":[ + { + "answer_id":"Yes", + "answer":"Yes", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + }, + { + "answer_id":"No", + "answer":"No", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + } + ], + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Required", + "value":null + } + ] + }, + { + "question":"Property Ownership", + "question_key":"property_ownership", + "type":"3", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "answers":[ + { + "answer_id":"Owned", + "answer":"Owned", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + }, + { + "answer_id":"Rented", + "answer":"Rented", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + } + ], + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Required", + "value":null + } + ] + }, + { + "question":"Area (Sq Feet)", + "question_key":"area_sq_feet", + "type":"1", + "place_holder": "Enter the number", + "field_type":"num", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "answers":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Required", + "value":null + } + ] + }, + { + "question":"Floors", + "question_key":"floor", + "type":"1", + "field_type":"num", + "place_holder": "Enter the number", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "answers":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Required", + "value":null + } + ] + }, + { + "question":"How many Bedded", + "question_key":"how_many_beds", + "type":"1", + "field_type":"num", + "place_holder": "Enter the number", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "answers":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Required", + "value":null + } + ] + }, + { + "question":"Occupancy Ratio", + "question_key":"occupancy_ratio", + "type":"1", + "field_type":"num", + "place_holder": "Enter the number", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "answers":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Required", + "value":null + } + ] + }, + { + "question":"Number of staff observed", + "question_key":"staff_observer_number", + "type":"1", + "field_type":"num", + "place_holder": "Enter the number", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "answers":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Required", + "value":null + } + ] + }, + { + "question":"Business activity seen (Yes/No)", + "question_key":"business_activity_seen", + "type":"3", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "answers":[ + { + "answer_id":"Yes", + "answer":"Yes", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + }, + { + "answer_id":"No", + "answer":"No", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + } + ], + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Required", + "value":null + } + ] + } + ] + }, + { + "section_id":"5", + "section_name":"Product Information", + "onsubmit":null, + "questions":[ + { + "question":"Equipment List", + "question_key":"equipment_list", + "type":"8", + "is_multiple":"1", + "api_properties":{ + "api":"getListOfMaster", + "api_method":"POST", + "params":{ + "master_name":"SALESEQUIPMENTLIST" + }, + "fields":[ + "id", + "equipment" + ] + }, + "onchange_properties":null, + "is_repeatable":null, + "answers":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Required", + "value":null + } + ] + }, + { + "question":"Total invoice value of the selected product", + "question_key":"tot_product_invoice_value", + "type":"1", + "field_type":"num", + "place_holder": "Enter the number", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "answers":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Required", + "value":null + } + ] + }, + { + "question":"Vendor list", + "question_key":"vendor_list", + "type":"8", + "is_multiple":"1", + "api_properties":{ + "api":"getListOfMaster", + "api_method":"POST", + "params":{ + "master_name":"SALESVENDORLIST" + }, + "fields":[ + "id", + "vendor" + ] + }, + "onchange_properties":null, + "is_repeatable":null, + "answers":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Required", + "value":null + } + ] + } + ] + }, + { + "section_id":"6", + "section_name":"Financial Information", + "onsubmit":[ + { + "expression":"(function (){let sum_val=null;let ques_key=[];control.questions_group.forEach(ques_obj=>{ques_obj.questions.map(ques=>{if(ques.question_key == submitProperty.key_name){ques_key.push(ques.answer_value)}})});console.log('none',ques_key);return new Set(ques_key).size === ques_key.length}())", + "key_name":"fy", + "msg":"Year already entered earlier" + } + ], + "questions":[ + { + "question":[ + { + "question":"Enter FY", + "question_key":"fy", + "type":"3", + "answers":[ + + ], + "answer_value":"GET_FY_YEARS", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"num", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Fin Yr Required", + "value":null + } + ] + }, + { + "question":"Sales / Revenue (Rs) ", + "question_key":"sales_revenue", + "place_holder":"Enter amount", + "type":"1", + "answers":null, + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"numtoword", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Sales/Revenue Required", + "value":null + } + ] + }, + { + "question":"Net Profit / (Net Loss) (Rs) ", + "question_key":"net_profit", + "place_holder":"Enter amount", + "type":"1", + "answers":null, + "api_properties":null, + "is_repeatable":null, + "field_type":"numtoword", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Net profit/loss Required", + "value":null + } + ], + "onchange_properties":[ + { + "purpose":"validations", + "validations":[ + { + "name":"max", + "isactive":"1", + "validator":"", + "message":"should be less then sales", + "value":"sales_revenue", + "validation_to":null, + "value_keys":null + } + ] + } + ] + } + ], + "is_repeatable":"1", + "group_title":"Particulars of Financials as per books of Accounts" + }, + { + "question":"Income Considered (Rs Per Annum) ", + "question_key":"income_considered", + "place_holder":"Enter amount", + "type":"1", + "answers":null, + "api_properties":null, + "is_repeatable":null, + "field_type":"numtoword", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Income Considered Required", + "value":null + } + ], + "onchange_properties":[ + + ] + }, + { + "question":"Income assessment Program ", + "question_key":"income_assessment_program_recommended", + "type":"3", + "answers":[ + { + "answer_id":"Vanilla", + "answer":"Vanilla", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + }, + { + "answer_id":"Projection based", + "answer":"Projection based", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + } + ], + "api_properties":null, + "onchange_properties":null, + "field_type":"string", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Income assessment Program Required", + "value":null + } + ] + }, + { + "question":"Fixed Obligations (Rs per month) ", + "question_key":"fixed_obligations", + "place_holder":"Enter amount", + "type":"1", + "answers":null, + "api_properties":null, + "is_repeatable":null, + "field_type":"numtoword", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Fixed Obligations Required", + "value":null + } + ], + "onchange_properties":null + }, + { + "question":"Selected equipment contribution in trunover", + "question_key":"equipment_contribution_turnover", + "place_holder":"Enter text", + "question_enable":"PD_FORM_VALUES.institution_type == String('Diagnostic Centre')", + "type":"1", + "answers":null, + "api_properties":null, + "is_repeatable":null, + "field_type":"string", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Required", + "value":null + } + ], + "onchange_properties":null + } + ] + }, + { + "section_id":"7", + "section_name":"Final Remarks of PD officer", + "onsubmit":null, + "questions":[ + { + "question":"Business activity seen during visit ", + "question_key":"business_activity_seen", + "type":"2", + "answers":[ + { + "answer_id":"Yes", + "answer":"Yes", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + }, + { + "answer_id":"No", + "answer":"No ", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + } + ], + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Location of workplace suits the business", + "question_key":"location_workplace_suits_business", + "type":"2", + "answers":[ + { + "answer_id":"Yes", + "answer":"Yes", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + }, + { + "answer_id":"No", + "answer":"No ", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + } + ], + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Overall Assessment", + "question_key":"overall_assessment", + "type":"2", + "answers":[ + { + "answer_id":"Positive", + "answer":"Positive", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + }, + { + "answer_id":"Negative", + "answer":"Negative ", + "subfield_key":"", + "subfield_caption":"", + "subfield_type":"" + } + ], + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Recommended ROI for the case (%)", + "question_key":"recommended_roi", + "place_holder":"Enter number", + "type":"1", + "answers":null, + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"num", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + }, + { + "name":"maxLength", + "isactive":"1", + "validator":"2", + "message":"Two digit only", + "value":null + } + ] + }, + { + "question":"What are the future expansion plans of business", + "question_key":"future_business_expansion_plans", + "place_holder":"Enter text", + "type":"1", + "answers":null, + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "validations":[ + + ] + }, + { + "question":"Any Other remarks ", + "question_key":"any_other_remarks", + "place_holder":"Enter text", + "type":"1", + "answers":null, + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "validations":[ + + ] + } + ] + }, + { + "section_id":"8", + "section_name":"Officer Details", + "onsubmit":null, + "questions":[ + { + "question":"Name of Sales Team Member", + "question_key":"name_of_sales_team_member", + "place_holder":"Enter text", + "type":"1", + "field_type":"string", + "answers":null, + "answer_value":"CURRENT_USER", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Designation", + "question_key":"designation", + "place_holder":"Enter text", + "type":"1", + "answers":null, + "answer_value":"", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Date", + "question_key":"date", + "place_holder":"Enter date", + "type":"1", + "answers":null, + "answer_value":"CURRENT_DATE", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + } + ] + }, + { + "section_id":"9", + "section_name":"Photograph's", + "onsubmit":[ + { + "expression":"(function () {let sum_val=null;let ques_key=[];if(control.question_key == submitProperty.key_name && control.answer_value == ''){return false}else{return true}return sum_val}())", + "key_name":"selfie_with_person_met", + "msg":"Please take selfie with person met" + } + ], + "questions":[ + { + "question":"Selfie with person met", + "question_key":"selfie_with_person_met", + "type":"6", + "answers":null, + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + + ] + }, + { + "question":[ + { + "question":"Hospital building photo", + "question_key":"hospital_building", + "type":"6", + "answers":null, + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + + ] + } + ], + "is_repeatable":"1", + "group_title":"Hospital building photo", + "group_type":"6" + } + ] + } + ] + } \ No newline at end of file diff --git a/src/pages/sales_pd/components/ques-template/ques-template.html b/src/pages/sales_pd/components/ques-template/ques-template.html index 059366b..df28b6f 100755 --- a/src/pages/sales_pd/components/ques-template/ques-template.html +++ b/src/pages/sales_pd/components/ques-template/ques-template.html @@ -12,7 +12,7 @@ {{parent_ques.get('question').value}} @@ -120,7 +120,7 @@ {{parent_ques.get('question').value}} - + - -- + -- {{val.answer}} @@ -235,7 +235,7 @@ {{parent_ques.get('question').value}} - + - -- + -- {{val.answer}} diff --git a/src/pages/sales_pd/components/ques-template/ques-template.ts b/src/pages/sales_pd/components/ques-template/ques-template.ts index 479a831..56bf9dd 100755 --- a/src/pages/sales_pd/components/ques-template/ques-template.ts +++ b/src/pages/sales_pd/components/ques-template/ques-template.ts @@ -824,10 +824,11 @@ this.proceedonChangeProperty(modified) if(control_value_obj.answer_value == ''){ control_value_obj.answer_value =0 } - expression_value=expression_value.replace(res,control_value_obj.answer_value) + // expression_value=expression_value.replace(res,control_value_obj.answer_value) + expression_value = expression_value.split(res).join(control_value_obj.answer_value) } }) - + let calc_exp=eval(expression_value) if(calc_exp != false){ @@ -1021,6 +1022,7 @@ this.proceedonChangeProperty(modified) // ] // console.log(this.local_ques_JSON); if(this.local_ques_JSON.hasOwnProperty('onsubmit') && this.local_ques_JSON.onsubmit != null){ + this.salesPDProvider.getData_fromLocal('sales_pd_id_PRIMARYKEY').then((sales_pd_id)=>{ for(let i=0; i{ let parent_ques @@ -1034,7 +1036,7 @@ this.proceedonChangeProperty(modified) return_val.length = 0 - let val=this.calculation(parent_ques,submitProperty) + let val=this.calculation(parent_ques,submitProperty,sales_pd_id) if(val != true && val != 100){ this.toastProvider.lenderappmessage(submitProperty.msg) @@ -1045,6 +1047,16 @@ this.proceedonChangeProperty(modified) return_val.push(true) ; } } + else if(parent_ques.question_key == submitProperty.key_name) { + let val=this.calculation(parent_ques,submitProperty,sales_pd_id) + if(val != true) { + this.toastProvider.lenderappmessage(submitProperty.msg) + return_val.push(false) ; + } + else{ + return_val.push(true) ; + } + } else{ send_val =true } @@ -1056,6 +1068,7 @@ this.proceedonChangeProperty(modified) break; } } +}) console.log(return_val) if(return_val.length > 0){ if(return_val.filter(res=>res == false).length > 0){ @@ -1068,27 +1081,30 @@ this.proceedonChangeProperty(modified) } return send_val } - calculation(control,submitProperty){ - // console.log("control",control) - // let exp=` - // (function () {let sum_val=null - // let ques_key=[] - // control.questions_group.forEach(ques_obj=>{ - // ques_obj.questions.map(ques=>{ - // // console.log(ques) - // if(ques.question_key == 'share_holding'){ - // ques_key.push(ques) - // } - // }) - // }) - // if(ques_key.length > 0){ - // console.log(ques_key) - // sum_val= ques_key.map(val=>val.answer_value).reduce((tot,val)=>{ - // console.log(">>>>",tot,val) - // return parseInt(tot)+parseInt(val) - // }) - // } - // return sum_val == 100}());` + calculation(control,submitProperty,sales_pd_id?){ + function addorUpdateLocalStorage(key,value) { + + + let storageKey = 'PD_FORM_VALUES-'+sales_pd_id + let existing_value:any = localStorage.getItem(storageKey) + if(existing_value ) { + existing_value = JSON.parse(existing_value); + if(Object.keys(existing_value).length > 0) { + existing_value[key] = value + } + // existing_value.push(value) + } + else { + existing_value = {} + existing_value[key] =value + } + localStorage.setItem(storageKey,JSON.stringify(existing_value)) + + } + + console.log("control",control) + // let exp=` + // (function () {if(control.question_key == 'constitution'){addorUpdateLocalStorage('constitution',control.answer_value);}return true}());` //for image total check // let exp=` @@ -1112,10 +1128,29 @@ this.proceedonChangeProperty(modified) let val= eval(submitProperty.expression); + // let val = eval(exp); console.log(val) return val } + // addorUpdateLocalStorage(key,value) { + + // this.salesPDProvider.getData_fromLocal('sales_pd_id_PRIMARYKEY').then((sales_pd_id)=>{ + // let storageKey = 'PD_FORM_VALUES-'+sales_pd_id + // let existing_value:any = localStorage.getItem(storageKey) + // if(existing_value ) { + // existing_value = JSON.parse(existing_value); + // if(Object.keys(existing_value).length > 0) { + // existing_value[key] = value + // } + // // existing_value.push(value) + // } + // else { + // existing_value[key] =value + // } + // localStorage.setItem(storageKey,JSON.stringify(existing_value)) + // }) + // } searchFun(control,index){ console.log(control,index); diff --git a/src/pages/sales_pd/pages/section-list/section-list.ts b/src/pages/sales_pd/pages/section-list/section-list.ts index 606c35d..1ed569d 100755 --- a/src/pages/sales_pd/pages/section-list/section-list.ts +++ b/src/pages/sales_pd/pages/section-list/section-list.ts @@ -6,6 +6,7 @@ import { ToastProvider } from '../../../../providers/common-provider/toast'; import { OfflineManagerProvider } from '../../providers/offline-manager/offline-manager'; import { ConstantsProvider } from '../../../../providers/constants/constants'; import { SocialSharing } from '@ionic-native/social-sharing'; +import { Observable, Observer } from 'rxjs'; /** * Generated class for the SectionListPage page. * @@ -29,6 +30,7 @@ export class SectionListPage { customer_link:string='' sales_pd_type: string; customer_link_with_text: string; + config_expression: any; constructor(public navCtrl: NavController, public navParams: NavParams,private SalesPDService:SalesPdProvider,private toastProvider:ToastProvider, private offlineManager:OfflineManagerProvider,private constantProvider:ConstantsProvider, private socialSharing:SocialSharing) { @@ -50,10 +52,142 @@ export class SectionListPage { this.getSectionStats() },50) } + checkTemplateConfig() { + if(this.raw_data && this.raw_data.hasOwnProperty('config') && this.raw_data.config && this.sales_pd_id != null && this.sales_pd_id) { + this.raw_data.config.forEach(singleConfig=>{ + if(singleConfig.purpose == 'LOCAL_OR_API_FORM_VALUES') { + this.getLocalFormValues(singleConfig) + } + + }) + } + } + getLocalFormValues(temp_config) { + if(temp_config.hasOwnProperty('value_keys') && temp_config.value_keys != null ) { + let storageKey ='PD_FORM_VALUES-'+this.sales_pd_id + let currFormDatas:any = localStorage.getItem(storageKey) + if(currFormDatas) { + currFormDatas = JSON.parse(currFormDatas) + } + else { + currFormDatas = {} + } + this.config_expression = `(function () {console.log("c",'constitution'.toLowerCase() == 'trust');if('constitution'.toLowerCase() == 'trust' || 'constitution'.toLowerCase() == 'society'){ removeSection('3') } else { addSection('3')}return true}());` + temp_config.value_keys.forEach((obj,index)=>{ + console.log(currFormDatas[obj.key_names[0]]) + // FOR VERIFY SECTION VALUE STORED + if(!currFormDatas || !currFormDatas[obj.key_names[0]]) { + return this.getSectionDatas(obj.section_id,obj.key_names).subscribe(val=>{ + console.log(val); + // this.SalesPDService.addorUpdateLocalStorage() + currFormDatas = {...currFormDatas,...val} + this.updateToLocalStorage(storageKey,currFormDatas) + this.proceedConfigCheck(temp_config,currFormDatas,index) + }) + } + else { + this.proceedConfigCheck(temp_config,currFormDatas,index) + } + }) + } + return + } + proceedConfigCheck(config,datas,index,section_template = this.section_template,raw_section_template = this.raw_data.sections) { + console.log("At last",datas) + // debugger; + config.value_keys[index].key_names.forEach(val=>{ + console.log(val) + this.config_expression = this.config_expression.split(val).join(datas[val]) + }) + if(config.value_keys.length-1 == index) { + console.log("last obj",this.config_expression) + let exp = eval(this.config_expression) + } + // let raw_template = this.section_template + + function addSection(section_id){ + console.log("add",section_id); + if(section_template.filter(vv=>vv.section_id == section_id).length == 0) { + let curr_obj_index = raw_section_template.findIndex(vv=>vv.section_id == section_id) + let index_to_insert + if(section_id == 0) { + index_to_insert = 0 + } + else { + index_to_insert = section_template.findIndex(vv=>vv.section_id == section_id-1) + } + if(curr_obj_index != -1 && index_to_insert != -1) { + console.log(index_to_insert) + section_template.splice(index_to_insert+1,0,raw_section_template[curr_obj_index]) + } + } + } + function removeSection(section_id){ + console.log("Remove",section_id,section_template) + section_template = section_template.filter(vv=>vv.section_id != section_id) + console.log(section_template) + } + this.section_template = section_template + // expression_value.split(res).join(control_value_obj.answer_value) + } + + updateToLocalStorage(storageKey,values) { + let storageValue:any = localStorage.getItem(storageKey) + if(storageValue) { + storageValue = JSON.parse(storageValue) + storageValue = {...storageValue,...values} + } + else { + storageValue = values + } + localStorage.setItem(storageKey,JSON.stringify(storageValue)) + } + getSectionDatas(section_id,keys_acquired) { + return new Observable((observer: Observer) => { + + let params={sales_pd_id:this.sales_pd_id,section_id:section_id} + return this.SalesPDService.getSalesPDSectionData(params).subscribe(response=>{ + let obj + if(response['dataStatus']){ + let original_result_data=response['records'][0].section_data + original_result_data = JSON.parse(original_result_data); + obj = this.updateKeyValues(keys_acquired,original_result_data.questions) + } + else{ + obj = this.updateKeyValues(keys_acquired,null) + } + observer.next(obj); + observer.complete(); + }) + }) + } + updateKeyValues(keys_acquired ,data_from_api) { + let return_value = {} + if(keys_acquired.length > 0) { + keys_acquired.forEach(key_name=>{ + if(data_from_api != null) { + console.log("api",data_from_api); + let value = data_from_api.filter(vv=>vv.question_key == key_name)[0] + if(!value || !value.hasOwnProperty('answer_value')) { + value = null + } + else { + value = value.answer_value + } + return_value[key_name] = value + } + else{ + return_value[key_name]= null + } + }) + return return_value + } + } getSectionStats() { this.SalesPDService.getData_fromLocal('sales_pd_id_PRIMARYKEY').then((key_value)=>{ if(key_value && key_value != null && key_value != '' && key_value != undefined){ this.sales_pd_id=key_value + this.checkTemplateConfig() if(!this.sales_pd_id.includes('local')) { this.SalesPDService.getData_fromLocal('sales_rand_string').then((rand_string_sales)=>{ if(rand_string_sales) { diff --git a/src/pages/sales_pd/providers/ques-service/ques-service.ts b/src/pages/sales_pd/providers/ques-service/ques-service.ts index 767d4fa..1f044b3 100755 --- a/src/pages/sales_pd/providers/ques-service/ques-service.ts +++ b/src/pages/sales_pd/providers/ques-service/ques-service.ts @@ -179,6 +179,7 @@ export class QuesServiceProvider { "onchange_properties":[data.onchange_properties], "answers":[answers_from_client.length != 0 ? answers_from_client: data.answers], "is_repeatable":[data.is_repeatable || null], + "is_multiple":[data.is_multiple || 0], "group_title":[data.group_title || null] }) } @@ -301,6 +302,29 @@ export class QuesServiceProvider { curr_control.controls[curr_index].addControl('is_image_status',new FormControl(false)) } + if(data.hasOwnProperty('question_enable') && data.question_enable != null && data.question_enable) { + let expression= data.question_enable; + console.log("Check started",expression,expression.includes('PD_FORM_VALUES')); + if(expression.includes('PD_FORM_VALUES')) { + this.salesPDProvider.getData_fromLocal('sales_pd_id_PRIMARYKEY').then(sales_pd_id => { + if(sales_pd_id) { + let PD_FORM_VALUES = localStorage.getItem('PD_FORM_VALUES-'+sales_pd_id) + if(PD_FORM_VALUES) { + PD_FORM_VALUES = JSON.parse(PD_FORM_VALUES) + // expression = expression.split('PD_FORM_VALUES').join(local_pd_form_values) + console.log("ex",expression) + let result = eval(expression) + console.log(result); + if(!result) { + curr_control.removeAt(curr_index); + } + } + } + }) + } + // expression = expression.split(res).join(control_value_obj.answer_value) + } + //FOR SETTING THE VALIDATORS this.settingArrayofValidators(data,curr_control.controls[curr_index],curr_index) } diff --git a/src/pages/sales_pd/providers/sales-pd/sales-pd.ts b/src/pages/sales_pd/providers/sales-pd/sales-pd.ts index 3fd3f71..c4cf704 100755 --- a/src/pages/sales_pd/providers/sales-pd/sales-pd.ts +++ b/src/pages/sales_pd/providers/sales-pd/sales-pd.ts @@ -11,6 +11,7 @@ import { IonicStorageProvider } from '../../../../providers/ionic-storage/ionic- import { OfflineManagerProvider } from '../offline-manager/offline-manager'; import { PdtriggerProvider } from '../../../../providers/pdtrigger/pdtrigger'; import { ApiServiceProvider } from '../../../credit_pd/providers/api-service/api-service'; +import { Platform } from 'ionic-angular'; // import {environment} from '../../../../providers/constants/constants' /* @@ -28,7 +29,8 @@ available_sections:any; original_rawData:any; current_section:any; constructor(public http: HttpClient,private constantProvider:ConstantsProvider,private storage:Storage,private aws:AwsServiceProvider,private cameraService:CameraProvider, - private networkProvider:NetworkDetectionProvider,private ionicStorageProvider:IonicStorageProvider,private offlineManagerProvider:OfflineManagerProvider,private creditPDService:ApiServiceProvider) { + private networkProvider:NetworkDetectionProvider,private ionicStorageProvider:IonicStorageProvider,private offlineManagerProvider:OfflineManagerProvider,private creditPDService:ApiServiceProvider, + private platform:Platform) { console.log('Hello SalesPdProvider Provider'); this.apiUrl=this.constantProvider.environment().url } @@ -38,7 +40,15 @@ current_section:any; let params = {records:{lender_id:users.fk_entity_id,product_id:product_id,sales_pd_type:sales_pd_type}} return Observable.create((observer:any)=>{ if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) { - return this.http.post(this.apiUrl+'loadSalesPDTemplate',{records:{lender_id:users.fk_entity_id,product_id:product_id,sales_pd_type:sales_pd_type}}).subscribe(result=>{ + console.log(this.platform.is('cordova')) + let api_properties = {method:'post', api_name:this.apiUrl+'loadSalesPDTemplate',params : params} + if(!this.platform.is('cordova')) { + // api_properties = {method:'get', api_name:`assets/data/sales_pd_templates/${product_id}.json`,params : params + } + return this.http[api_properties.method](api_properties.api_name,api_properties.params).subscribe(result=>{ + if(!this.platform.is('cordova') && !result.hasOwnProperty('dataStatus')) { + result = {dataStatus:true,status:200,records:{template:JSON.stringify(result)}} + } if(result['dataStatus']) { return this.ionicStorageProvider.checkAndInsertApiDataLocally(result,params,'loadSalesPDTemplate',true).then(res=>{ observer.next(result)