SET @prevDate = 20220731;

--
-- Master table values for StatusMaster
--
DELETE FROM StatusMaster;
INSERT INTO StatusMaster(name) VALUES
('Active'),
('Inactive'),
('Blacklisted');

-- Setting master values in variables for downstream usage
SELECT @activeStatusId := id FROM StatusMaster WHERE name = 'Active';
SELECT @inactiveStatusId := id FROM StatusMaster WHERE name = 'Inactive';


-- Setting master values in variables for downstream usage
SELECT @superUserId := id FROM User WHERE username = 'superuser';
SELECT @adminUserId := id FROM User WHERE username = 'admin';
SELECT @migrationUserId := id FROM User WHERE username = 'migration-user';
SELECT @systemUserId := id FROM User WHERE username = 'system-user';

--
-- Master table values for BusinessLogicTypeMaster
--
DELETE FROM BusinessLogicTypeMaster;
INSERT INTO BusinessLogicTypeMaster(name, ui_name) VALUES
('Entity Employment Type', 'Entity Employment Type'),
('Geo Location Types', 'Geo Location Types');

-- Setting master values in variables for downstream usage
SELECT @geoLocationBusTypeId := id FROM BusinessLogicTypeMaster WHERE name = 'Geo Location Types';

--
-- Master table values for BusinessLogicMaster
--
DELETE FROM BusinessLogicMaster;
INSERT INTO BusinessLogicMaster(type_id, name, ui_name, system_defined, is_active, is_visible) VALUES
(@geoLocationBusTypeId,'Customer Entity Geo Location', 'Customer Entity Geo Location', 1, 1, 1);

--
-- Master table values for ClientMapTypeMaster
--
DELETE FROM ClientMapTypeMaster;
INSERT INTO ClientMapTypeMaster(name, has_country) VALUES
('Caste', 1),
('Insurance Company', 1),
('Occupation', 0),
('Employee Title', 0),
('Employee Department', 0),
('Marital Status', 0),
('Religious Group', 0),
('Relation', 0),
('Education Level', 0),
('Customer Document Type', 0),
('Associate Document Type', 0),
('Account Document Type', 0),
('Pipeline Document Type', 0),
('Payment Group Document Type', 0),
('External Loan Source', 0),
('Decline/Cancel Reason', 0),
('Writeoff/Foreclosure Reason', 0),
('Household Income Source', 0),
('Household Expense Type', 0),
('Property Type', 0),
('Stationery Cancel Reason', 0),
('Loan Credit Remark Type', 0),
('Business Type', 0),
('Loan Utilization Remark', 0),
('Stationery Receipt Cancel Reason', 0),
('Jewel Type', 0),
('Loan Moratorium Type', 0),
('External Account Number', 0),
('Customer Dropout Reason', 0),
('Housing Category Type', 0),
('Housing Construction Type', 0),
('Area Measurement Unit', 0),
('Stationery Receipt Purpose', 0),
('Customer Address Type', 0),
('Client Type', 0),
('Institutional Form Type', 0),
('Funding Nature Of Facility', 0),
('Vehicle Type', 0),
('Battery Type', 0),
('Cross Sell Product', 0),
('Expenses/Withdrawal Purpose', 0),
('Entity Contact Type', 0),
('Entity Address Type', 0),
('Funder Type', 0),
('Financier Name', 0),
('Tax Paid Type', 0),
('Board Type', 0),
('Permit Type', 0),
('Fuel Type', 0),
('Device Type', 0),
('Employee Document Type', 0),
('Customer QC Reject Reason', 0),
('Server Details', 0),
('Loan Deal Source', 0),
('Document Template Type', 0),
('Pipeline Customer Remark Type', 0),
('Sourcing Comment Types', 0),
('Missed Repayment Reason', 0),
('Overdue Reason', 0),
('Kotak Insurance Response Document Type',1),
('Other Account Comment Reasons', 1),
('Unique Device Code Type', 0),
('Property Document Type', 0),
('Deed Document Type', 0),
('Employment Document Type', 0),
('Ownership Type', 0),
('Twinline Response Document Type', 0),
('Letzpay Request Document Type', 0),
('Letzpay Response Document Type', 0),
('Axis UPI Request Document Type', 0),
('Axis UPI Response Document Type', 0),
('Vendor Class', 0),
('Vendor Contact Type', 0),
('Vehicle Collateral Document Type', 0),
('Customer Bank Account Document Type', 0),
('Vehicle Price Type', 0),
('RBL UPI Response Document Type', 0),
('Pipeline Cancel Reason', 0),
('Pipeline Status Cancel Reason', 0),
('Insurance Claim Type', 0),
('RBL UPI Request Document Type', 0),
('AWS Rekognition Response Document Type', 0),
('Occupation Types', 0),
('Educational Institution Types', 0),
('Customer Pipeline Status Cancel Reason', 1),
('Business Constitution Type', 0),
('Claim Reason', 0),
('Loan Transactions Reference Number', 0),
('Cross Sell Categories', 0),
('Enterprise Member Type',0),
('Survey Document Type', 0),
('Insurance Claim Document Type', 0),
('Solar PV Module', 0),
('Solar Inverter', 0),
('Asset Category', 0),
('Finance Type', 0),
('TakeOver From Company', 1),
('Housing Document Type', 1),
('Property Category Type', 1),
('Property Construction Type', 1),
('Business Rule Override Reason', 0),
('Occupation Sector', 0);

-- Setting master values in variables for downstream usage
SELECT @maritalStatusMapTypeId := id FROM ClientMapTypeMaster WHERE name = 'Marital Status';
SELECT @religiousGroupMapTypeId := id FROM ClientMapTypeMaster WHERE name = 'Religious Group';
SELECT @relationMapTypeId := id FROM ClientMapTypeMaster WHERE name = 'Relation';
SELECT @custDocTypeMapTypeId := id FROM ClientMapTypeMaster WHERE name = 'Customer Document Type';
SELECT @acctDocTypeMapTypeId := id FROM ClientMapTypeMaster WHERE name = 'Account Document Type';
SELECT @loanMorTypeMapTypeId := id FROM ClientMapTypeMaster WHERE name = 'Loan Moratorium Type';
SELECT @extAccountNoMapTypeId := id FROM ClientMapTypeMaster WHERE name = 'External Account Number';
SELECT @entityContactTypeMapTypeId := id FROM ClientMapTypeMaster WHERE name = 'Entity Contact Type';
SELECT @vehicleTypeId := id FROM ClientMapTypeMaster WHERE name = 'Vehicle Type';
SELECT @batteryTypeId := id FROM ClientMapTypeMaster WHERE name = 'Battery Type';
SELECT @sRCancelReasonId := id FROM ClientMapTypeMaster WHERE name = 'Stationery Receipt Cancel Reason';
SELECT @externalAccountNumberId := id FROM ClientMapTypeMaster WHERE name = 'External Account Number';
SELECT @deviceTypeId := id FROM ClientMapTypeMaster WHERE name = 'Cross Sell Product';
SELECT @serverDetailsId := id FROM ClientMapTypeMaster WHERE name = 'Server Details';
SELECT @entityAddressTypeMapTypeId := id FROM ClientMapTypeMaster WHERE name = 'Entity Address Type';
SELECT @documentTemplateType := id FROM ClientMapTypeMaster WHERE name = 'Document Template Type';
SELECT @payGroupDocType := id FROM ClientMapTypeMaster WHERE name = 'Payment Group Document Type';
SELECT @awsRekogRespDocType := id FROM ClientMapTypeMaster WHERE name = 'AWS Rekognition Response Document Type';
SELECT @employeeDocType := id FROM ClientMapTypeMaster WHERE name = 'Employee Document Type';
SELECT @otherAccountCommentType := id FROM ClientMapTypeMaster WHERE name = 'Other Account Comment Reasons';
SELECT @kotakInsuranceDocType := id FROM ClientMapTypeMaster WHERE name = 'Kotak Insurance Response Document Type';
SELECT @UniqueDeviceCodeType := id FROM ClientMapTypeMaster WHERE name = 'Unique Device Code Type';
SELECT @tlResponseDocTypeId := id FROM ClientMapTypeMaster WHERE name = 'Twinline Response Document Type';
SELECT @letzpayRequestDocTypeId := id FROM ClientMapTypeMaster WHERE name = 'Letzpay Request Document Type';
SELECT @letzpayResponseDocTypeId := id FROM ClientMapTypeMaster WHERE name = 'Letzpay Response Document Type';
SELECT @axisUPIRequestDocTypeId := id FROM ClientMapTypeMaster WHERE name = 'Axis UPI Request Document Type';
SELECT @axisUPIResponseDocTypeId := id FROM ClientMapTypeMaster WHERE name = 'Axis UPI Response Document Type';
SELECT @rblUpiRequestDocTypeId := id FROM ClientMapTypeMaster WHERE name = 'RBL UPI Request Document Type';
SELECT @rblUpiResponseDocTypeId := id FROM ClientMapTypeMaster WHERE name = 'RBL UPI Response Document Type';
SELECT @pipelineDocTypeMapTypeId := id FROM ClientMapTypeMaster WHERE name = 'Pipeline Document Type';
SELECT @claimMapTypeId := id FROM ClientMapTypeMaster WHERE name = 'Insurance Claim Type';
SELECT @educationMapTypeId := id FROM ClientMapTypeMaster WHERE name = 'Education Level';
SELECT @vendorClassId := id FROM ClientMapTypeMaster WHERE name = 'Vendor Class';
SELECT @lpStatusCancelMapTypeId := id FROM ClientMapTypeMaster WHERE name = 'Pipeline Status Cancel Reason';
SELECT @cpStatusCancelMapTypeId := id FROM ClientMapTypeMaster WHERE name = 'Customer Pipeline Status Cancel Reason';
SELECT @pipelineCancelMapTypeId := id FROM ClientMapTypeMaster WHERE name = 'Pipeline Cancel Reason';
SELECT @declineCancelMapTypeId := id FROM ClientMapTypeMaster WHERE name = 'Decline/Cancel Reason';
SELECT @eduInstituteMapTypeId := id FROM ClientMapTypeMaster WHERE name = 'Educational Institution types';
SELECT @claimReasonMapTypeId := id FROM ClientMapTypeMaster WHERE name = 'Claim Reason';
SELECT @crossSellCategoriesId := id FROM ClientMapTypeMaster WHERE name = 'Cross Sell Categories';
SELECT @enterpriseTypeId := id FROM ClientMapTypeMaster WHERE name = 'Enterprise Member Type';
SELECT @solarPVModuleId := id FROM ClientMapTypeMaster WHERE name = 'Solar PV Module';
SELECT @solarInverterId := id FROM ClientMapTypeMaster WHERE name = 'Solar Inverter';
SELECT @assetCategoryId := id FROM ClientMapTypeMaster WHERE name = 'Asset Category';
SELECT @financeTypeId := id FROM ClientMapTypeMaster WHERE name = 'Finance Type';
SELECT @takeOverFromCompany := id FROM ClientMapTypeMaster WHERE name = 'TakeOver From Company';
--
-- Master table values for ClientMapMaster
--
INSERT INTO ClientMapMaster(map_type_id, name, ui_name, system_defined, code, allow_reuse) VALUES
(@maritalStatusMapTypeId, 'Single/Unmarried', 'Single/Unmarried', 1, NULL, 0),
(@maritalStatusMapTypeId, 'Married', 'Married', 1, NULL, 0),
(@maritalStatusMapTypeId, 'Widowed', 'Widowed', 1, NULL, 0),
(@maritalStatusMapTypeId, 'Divorced', 'Divorced', 1, NULL, 0),
(@religiousGroupMapTypeId, 'Hindu', 'Hindu', 1, NULL, 0),
(@religiousGroupMapTypeId, 'Muslim', 'Muslim', 1, NULL, 0),
(@religiousGroupMapTypeId, 'Christian', 'Christian', 1, NULL, 0),
(@religiousGroupMapTypeId, 'Others', 'Others', 1, NULL, 0),
(@relationMapTypeId, 'Self', 'Self', 1, NULL, 0),
(@relationMapTypeId, 'Husband', 'Husband', 1, NULL, 0),
(@relationMapTypeId, 'Wife', 'Wife', 1, NULL, 0),
(@relationMapTypeId, 'Father', 'Father', 1, NULL, 0),
(@relationMapTypeId, 'Mother', 'Mother', 1, NULL, 0),
(@relationMapTypeId, 'Son', 'Son', 1, NULL, 0),
(@relationMapTypeId, 'Daughter', 'Daughter', 1, NULL, 0),
(@relationMapTypeId, 'Brother', 'Brother', 1, NULL, 0),
(@relationMapTypeId, 'Sister', 'Sister', 1, NULL, 0),
(@relationMapTypeId, 'Father-in-law', 'Father-in-law', 1, NULL, 0),
(@relationMapTypeId, 'Mother-in-law', 'Mother-in-law', 1, NULL, 0),
(@relationMapTypeId, 'Son-in-law', 'Son-in-law', 1, NULL, 0),
(@relationMapTypeId, 'Daughter-in-law', 'Daughter-in-law', 1, NULL, 0),
(@relationMapTypeId, 'Brother-in-law', 'Brother-in-law', 1, NULL, 0),
(@relationMapTypeId, 'Sister-in-law', 'Sister-in-law', 1, NULL, 0),
(@relationMapTypeId, 'Nephew', 'Nephew', 1, NULL, 0),
(@relationMapTypeId, 'Niece', 'Niece', 1, NULL, 0),
(@relationMapTypeId, 'Grand-son', 'Grand-son', 1, NULL, 0),
(@relationMapTypeId, 'Grand-daughter', 'Grand-daughter', 1, NULL, 0),
(@relationMapTypeId, 'Uncle', 'Uncle', 1, NULL, 0),
(@relationMapTypeId, 'Aunt', 'Aunt', 1, NULL, 0),
(@relationMapTypeId, 'Grand-father', 'Grand-father', 1, NULL, 0),
(@relationMapTypeId, 'Grand-mother', 'Grand-mother', 1, NULL, 0),
(@loanMorTypeMapTypeId, 'Product Level', 'Product Level', 1, NULL, 0),
(@loanMorTypeMapTypeId, 'COVID-19 Rescheduling', 'COVID-19 Rescheduling', 1, NULL, 0),
(@extAccountNoMapTypeId, 'UMRN', 'UMRN', 1, NULL, 0),
(@entityContactTypeMapTypeId, 'Mobile Number', 'Mobile Number', 1, NULL, 0),
(@entityContactTypeMapTypeId, 'Landline Telephone Number', 'Landline Telephone Number', 1, NULL, 0),
(@entityContactTypeMapTypeId, 'Landline Facsimile Number', 'Landline Facsimile Number', 1, NULL, 0),
(@entityContactTypeMapTypeId, 'Digital Consent Mobile Number', 'Digital Consent Mobile Number', 1, NULL, 0),
(@entityContactTypeMapTypeId, 'Email Address', 'Email Address', 1, NULL, 0),
(@entityContactTypeMapTypeId, 'Website Address', 'Website Address', 1, NULL, 0),
(@entityAddressTypeMapTypeId, 'Office Address', 'Office Address', 1, NULL, 0),
(@entityAddressTypeMapTypeId, 'Residence Address', 'Residence Address', 1, NULL, 0),
(@vehicleTypeId, 'Intermediate Commercial Vehicle', 'Intermediate Commercial Vehicle', 1, NULL, 0),
(@vehicleTypeId, 'Light Commercial Vehicle', 'Light Commercial Vehicle', 1, NULL, 0),
(@vehicleTypeId, 'Medium & Heavy Commercial Vehicle', 'Medium & Heavy Commercial Vehicle', 1, NULL, 0),
(@vehicleTypeId, 'Small Commercial Vehicle', 'Small Commercial Vehicle', 1, NULL, 0),
(@vehicleTypeId, 'Others', 'Others', 1, NULL, 0),
(@vehicleTypeId, 'e-Rickshaw', 'e-Rickshaw', 1, NULL, 0),
(@batteryTypeId, 'E-Vehicle Battery', 'E-Vehicle Battery', 1, NULL, 0),
(@sRCancelReasonId, 'Transaction Cancelled', 'Transaction Cancelled', 1, NULL, 0),
(@deviceTypeId, 'Mobile Device', 'Mobile Device', 1, NULL, 0),
(@externalAccountNumberId, 'Barcode (Pawn Ticket)', 'Barcode (Pawn Ticket)', 1, NULL, 0),
(@externalAccountNumberId, 'Credit Insurance Policy Number (Customer)', 'Credit Insurance Policy Number (Customer)', 1, 'custCIN', 0),
(@externalAccountNumberId, 'Credit Insurance Policy Number (Guarantor)', 'Credit Insurance Policy Number (Guarantor)', 1, 'guarCIN', 0),
(@serverDetailsId, 'Server Domain/IP', 'Server Domain/IP', 1, NULL, 0),
(@serverDetailsId, 'Server Username', 'Server Username', 1, NULL, 0),
(@serverDetailsId, 'Server Password', 'Server Password', 1, NULL, 0),
(@serverDetailsId, 'Server Port', 'Server Port', 1, NULL, 0),
(@serverDetailsId, 'Server Directory Path', 'Server Directory Path', 1, NULL, 0),
(@serverDetailsId, 'Transport Scheme', 'Transport Scheme', 1, NULL, 0),
(@serverDetailsId, 'View Domain/IP', 'View Domain/IP', 1, NULL, 0),
(@serverDetailsId, 'View Directory Path', 'View Directory Path', 1, NULL, 0),
(@serverDetailsId, 'View Port', 'View Port', 1, NULL, 0),
(@otherAccountCommentType, 'Require COVID-19 Moratorium?', 'Require COVID-19 Moratorium?', 1, NULL, 0),
(@otherAccountCommentType, 'Moratorium Consent Video Transcription', 'Moratorium Consent Video Transcription', 1, NULL, 0),
(@otherAccountCommentType, 'Paper Consent Promise-To-Pay', 'Paper Consent Promise-To-Pay', 1, NULL, 0),
(@otherAccountCommentType, 'Digital Consent Promise-To-Pay', 'Digital Consent Promise-To-Pay', 1, NULL, 0),
(@educationMapTypeId, 'College Graduate', 'College Graduate', 1, NULL, 0),
(@educationMapTypeId, 'None', 'None', 1, NULL, 0),
(@educationMapTypeId, 'Primary Education', 'Primary Education', 1, NULL, 0),
(@educationMapTypeId, 'Secondary Education', 'Secondary Education', 1, NULL, 0),
(@UniqueDeviceCodeType, 'android device id', 'android device id', 1, NULL, 0),
(@UniqueDeviceCodeType, 'device#', 'device#', 1, NULL, 0),
(@UniqueDeviceCodeType, 'imei', 'imei', 1, NULL, 0),
(@UniqueDeviceCodeType, 'other imei', 'other imei', 1, NULL, 0),
(@documentTemplateType, 'Automated Digital Consent Letter Template', 'Automated Digital Consent Letter Template', 1, NULL, 0),
(@documentTemplateType, 'mShakti', 'mShakti', 1, NULL, 0),
(@acctDocTypeMapTypeId, 'Automated Digitial Consent Letter', 'Automated Digitial Consent Letter', 1, NULL, 0),
(@tlResponseDocTypeId, 'QR Code Document', 'QR Code Document', 1, NULL, 0),
(@tlResponseDocTypeId, 'SMS Request Document', 'SMS Request Document', 1, NULL, 0),
(@tlResponseDocTypeId, 'Unsync Response Document', 'Unsync Response Document', 1, NULL, 0),
(@tlResponseDocTypeId, 'Callback Response Document', 'Callback Response Document', 1, NULL, 0),
(@claimMapTypeId, 'definitional', 'Definitional', 1, NULL, 0),
(@claimMapTypeId, 'factual', 'Factual', 1, NULL, 0),
(@claimMapTypeId, 'policy', 'Policy', 1, NULL, 0),
(@claimMapTypeId, 'value', 'Value', 1, NULL, 0),
(@letzpayRequestDocTypeId, 'Customer QR Generation', 'Customer QR Generation', 1, NULL, 0),
(@letzpayRequestDocTypeId, 'Static UPI QR Sale Callback', 'Static UPI QR Sale Callback', 1, NULL, 0),
(@letzpayResponseDocTypeId, 'Customer QR Generation', 'Customer QR Generation', 1, NULL, 0),
(@letzpayResponseDocTypeId, 'Static UPI QR Sale Callback', 'Static UPI QR Sale Callback', 1, NULL, 0),
(@axisUPIRequestDocTypeId, 'Single Collect Request', 'Single Collect Request', 1, NULL, 0),
(@axisUPIRequestDocTypeId, 'Validate VPA', 'Validate VPA', 1, NULL, 0),
(@axisUPIRequestDocTypeId, 'Check Transaction Status', 'Check Transaction Status', 1, NULL, 0),
(@axisUPIResponseDocTypeId, 'Single Collect Request', 'Single Collect Request', 1, NULL, 0),
(@axisUPIResponseDocTypeId, 'Validate VPA', 'Validate VPA', 1, NULL, 0),
(@axisUPIResponseDocTypeId, 'Check Transaction Status', 'Check Transaction Status', 1, NULL, 0),
(@axisUPIResponseDocTypeId, 'Callback', 'Callback', 1, NULL, 0),
(@rblUpiRequestDocTypeId, 'Channel Partner Login', 'Channel Partner Login', 1, NULL, 0),
(@rblUpiRequestDocTypeId, 'Generate Auth Token', 'Generate Auth Token', 1, NULL, 0),
(@rblUpiRequestDocTypeId, 'Get Txn ID', 'Get Txn ID', 1, NULL, 0),
(@rblUpiRequestDocTypeId, 'Validate VPA', 'Validate VPA', 1, NULL, 0),
(@rblUpiRequestDocTypeId, 'Collect Money', 'Collect Money', 1, NULL, 0),
(@rblUpiRequestDocTypeId, 'Transaction Re Query', 'Transaction Re Query', 1, NULL, 0),
(@rblUpiRequestDocTypeId, 'QR Code', 'QR Code', 1, NULL, 0),
(@rblUpiRequestDocTypeId, 'Callback', 'Callback', 1, NULL, 0),
(@rblUpiResponseDocTypeId, 'Channel Partner Login', 'Channel Partner Login', 1, NULL, 0),
(@rblUpiResponseDocTypeId, 'Generate Auth Token', 'Generate Auth Token', 1, NULL, 0),
(@rblUpiResponseDocTypeId, 'Get Txn ID', 'Get Txn ID', 1, NULL, 0),
(@rblUpiResponseDocTypeId, 'Validate VPA', 'Validate VPA', 1, NULL, 0),
(@rblUpiResponseDocTypeId, 'Collect Money', 'Collect Money', 1, NULL, 0),
(@rblUpiResponseDocTypeId, 'Transaction Re Query', 'Transaction Re Query', 1, NULL, 0),
(@rblUpiResponseDocTypeId, 'QR Code', 'QR Code', 1, NULL, 0),
(@awsRekogRespDocType, 'Add Faces To Collection', 'Add Faces To Collection', 1, NULL, 0),
(@awsRekogRespDocType, 'Delete Faces From Collection', 'Delete Faces From Collection', 1, NULL, 0),
(@awsRekogRespDocType, 'Detect Faces Within Image', 'Detect Faces Within Image', 1, NULL, 0),
(@awsRekogRespDocType, 'Search Collection Using Image', 'Search Collection Using Image', 1, NULL, 0),
(@awsRekogRespDocType, 'Compare Faces', 'Compare Faces', 1, NULL, 0),
(@vendorClassId, 'Vehicle Dealer', 'Vehicle Dealer', 1, NULL, 0),
(@vendorClassId, 'Educational Institution', 'Educational Institution', 1, NULL, 0),
(@vendorClassId, 'Cross Sell Vendor', 'Cross Sell Vendor', 1, NULL, 0),
(@rblUpiResponseDocTypeId, 'Callback', 'Callback', 1, NULL, 0),
(@otherAccountCommentType, 'Insurance Claim', 'Insurance Claim', 1, NULL, 0),
(@lpStatusCancelMapTypeId, 'Survey Score Unsatisfactory', 'Survey Score Unsatisfactory', 1, NULL, 0),
(@cpStatusCancelMapTypeId, 'Survey Score Unsatisfactory', 'Survey Score Unsatisfactory', 1, NULL, 0),
(@loanMorTypeMapTypeId, 'Freeze DPD Value', 'Freeze DPD Value', 1, NULL, 0),
(@loanMorTypeMapTypeId, 'Template Schedule Accrual Freeze', 'Template Schedule Accrual Freeze', 1, NULL, 0),
(@pipelineCancelMapTypeId, 'Auto-rejection due to inactivity', 'Auto-rejection due to inactivity', 1, NULL, 0),
(@declineCancelMapTypeId, 'Auto-rejection due to inactivity', 'Auto-rejection due to inactivity', 1, NULL, 0),
(@eduInstituteMapTypeId, 'School', 'School', 1, NULL, 0),
(@eduInstituteMapTypeId, 'College', 'College', 1, NULL, 0),
(@eduInstituteMapTypeId, 'Tuition Center', 'Tuition Center', 1, NULL, 0),
(@claimReasonMapTypeId, 'Client Death', 'Client Death', 1, NULL, 0),
(@claimReasonMapTypeId, 'HO Submittion', 'HO Submittion', 1, NULL, 0),
(@claimReasonMapTypeId, 'HO Verification', 'HO Verification', 1, NULL, 0),
(@claimReasonMapTypeId, 'Manual Claim Status Update', 'Manual Claim Status Update', 1, NULL, 0),
(@declineCancelMapTypeId, 'Cancelled Due To Customer Reset', 'Cancelled Due To Customer Reset', 1, NULL, 0),
(@cpStatusCancelMapTypeId, 'Cancelled Due To Customer Reset', 'Cancelled Due To Customer Reset', 1, NULL, 0),
(@otherAccountCommentType, 'Foreclosure Payment Reason', 'Foreclosure Payment Reason', 1, NULL, 1),
(@crossSellCategoriesId, 'Cross Sell Product', 'Cross Sell Product', 1, 'CS', 0),
(@enterpriseTypeId,'Sole Proprietorship', 'Sole Proprietorship', 1, NULL, 0),
(@vendorClassId, 'Solar Installer', 'Solar Installer', 1, NULL, 0),
(@solarPVModuleId, 'Solar PV Module', 'Solar PV Module', 1, NULL, 0),
(@solarInverterId, 'Solar Inverter', 'Solar Inverter', 1, NULL, 0),
(@assetCategoryId, 'Movable', 'Movable', 1, NULL, 0),
(@assetCategoryId, 'Immovable', 'Immovable', 1, NULL, 0),
(@financeTypeId, 'Sole', 'Sole', 1, NULL, 0),
(@cpStatusCancelMapTypeId, 'Cancelled Due To Reset Expiry Loans', 'Cancelled Due To Reset Expiry Loans', 1, NULL, 0),
(@externalAccountNumberId, 'Kaleidofin ThirdParty Loan Co-Applicant Id', 'Kaleidofin ThirdParty Loan Co-Applicant Id', 1, NULL, 0),
(@externalAccountNumberId, 'Kaleidofin ThirdParty Loan Guarantor Id', 'Kaleidofin ThirdParty Loan Guarantor Id', 1, NULL, 0),
(@externalAccountNumberId, 'Deposit Account Security Code', 'Deposit Account Security Code', 1, 'DASC', 0);


--
-- Master table values for EmployeeTypeMaster
--
DELETE FROM EmployeeTypeMaster;
INSERT INTO EmployeeTypeMaster(name) VALUES
('Full Time Employee'),
('Part Time Employee');

--
-- Master table values for CompensationCategoryMaster
--
DELETE FROM CompensationCategoryMaster;
INSERT INTO CompensationCategoryMaster(name) VALUES
('Salary'),
('Deductions');

-- Setting master values in variables for downstream usage
SELECT @salaryCompCategoryId := id FROM CompensationCategoryMaster WHERE name = 'Salary';

--
-- Master table values for CompensationTypeMaster
--
    DELETE FROM CompensationTypeMaster;
INSERT INTO CompensationTypeMaster(category_id, name, sys_defined) VALUES
(@salaryCompCategoryId, 'Basic Pay', 1);

--
-- Master table values for MetaProductClassMaster
--
DELETE FROM MetaProductClassMaster;
INSERT INTO MetaProductClassMaster(name, is_visible) VALUES
('Net-Off Funding',1),
('Gold Loan',1),
('Cross Sell Product',1),
('PMSVA Nidhi Products',1),
('Flexi Product',0),
('OD Top-up Funding',0),
('Trade Advance',0),
('Optional Net-Off Funding',1),
('Education Loan',1),
('Cross-category Net-Off Funding',0),
('Gold Loan - TakeOver',0);

--
-- Master table values for ProductCategoryMaster
--
DELETE FROM ProductCategoryMaster;
INSERT INTO ProductCategoryMaster(name) VALUES
('Loan'),
('Deposit'),
('Savings'),
('Insurance');

-- Setting master values in variables for downstream usage
SELECT @loanProductCategoryId := id FROM ProductCategoryMaster WHERE name = 'Loan';

--
-- Master table values for LocaleMaster
--
DELETE FROM LocaleMaster;
INSERT INTO LocaleMaster(name) VALUES
('Urban'),
('Semi-urban'),
('Rural');

--
-- Master table values for OfficeStatusMaster
--
DELETE FROM OfficeStatusMaster;
INSERT INTO OfficeStatusMaster(name) VALUES
('Operational'),
('Non-operational'),
('Closed');

--
-- Master table values for CustomerStatusMaster
--
DELETE FROM CustomerStatusMaster;
INSERT INTO CustomerStatusMaster(name, order_id) VALUES
('Pending verification', 4),
('Enrolled', 5),
('Banned', 6),
('Partially Enrolled', 3),
('Partially Enrolled In Center/Branch', 1),
('Awaiting QC', 2),
('QC Rejected', 3),
('On Hold', 6),
('Died', 6);

--
-- Master table values for CustomerTypeMaster
--
DELETE FROM CustomerTypeMaster;
INSERT INTO CustomerTypeMaster(name) VALUES
('Individual'),
('Enterprise');

--
-- Master table values for EntityTypeMaster
--
DELETE FROM EntityTypeMaster;
INSERT INTO EntityTypeMaster(name) VALUES
('Customer'),
('Spouse'),
('Guarantor'),
('Household Member'),
('Co-applicant'),
('Nominee'),
('Children');

--
-- Master table values for LoanPurposeTypeMaster
--
DELETE FROM LoanPurposeTypeMaster;
INSERT INTO LoanPurposeTypeMaster(name) VALUES
('Income Generation'),
('Consumption'),
('Product');

--
-- Master table values for DealSourceMaster
--
DELETE FROM DealSourceMaster;
INSERT INTO DealSourceMaster(name) VALUES
('Direct'),
('DMA'),
('Sale Purchase Agent');

--
-- Master table values for LoanCreditNoteTypeMaster
--
DELETE FROM LoanCreditNoteTypeMaster;
INSERT INTO LoanCreditNoteTypeMaster(name) VALUES
('Deviation'),
('Mitigant'),
('Condition');

--
-- Master table values for AccountStatusMaster
--
DELETE FROM AccountStatusMaster;
INSERT INTO AccountStatusMaster(name, ui_name, order_id) VALUES
('Application under process', 'Application under process', 1),
('Credit check', 'Credit check', 2),
('Pre-approval review', 'Pre-approval review', 3),
('Awaiting approval', 'Awaiting approval', 4),
('Approved', 'Approved', 5),
('Declined', 'Declined', 5),
('Cancelled', 'Cancelled', 5),
('Approval expired', 'Approval expired', 6),
('Current', 'Current', 7),
('Delinquent', 'Delinquent', 8),
('Awaiting insurance claim', 'Awaiting insurance claim', 9),
('Written off', 'Written off', 10),
('Closed', 'Closed', 11);

--
-- Master table values for AssociateTypeMaster
--
DELETE FROM AssociateTypeMaster;
INSERT INTO AssociateTypeMaster(name, abbr, is_default) VALUES
('Co-applicant', 'COA',0),
('Guarantor', 'GUA', 1),
('Reference', 'REF',0),
('Nominee', NULL,0),
('Co-depositor', NULL,0),
('Authorized Signatory', 'AS',0),
('Guardian', NULL,0);

--
-- Master table values for FrequencyMaster
--
DELETE FROM FrequencyMaster;
INSERT INTO FrequencyMaster(name, ui_name) VALUES
('Daily','Daily'),
('Weekly','Weekly'),
('Fortnightly','Fortnightly'),
('Once Every Four Weeks','Once Every Four Weeks'),
('Monthly (Date-Based)','Monthly'),
('Monthly (Day-Based)','Monthly (Day-Based)'),
('Quarterly','Quarterly'),
('Half-Yearly','Half-Yearly'),
('Yearly','Yearly'),
('Bullet','Bullet');

--
-- Master table values for TenureMaster
--
DELETE FROM TenureMaster;
INSERT INTO TenureMaster(name) VALUES
('Days'),
('Weeks'),
('Months'),
('Years'),
('Installments');

--
-- Master table values for FeeTypeMaster
--
DELETE FROM FeeTypeMaster;
INSERT INTO FeeTypeMaster(name) VALUES
('Fee'),
('Insurance'),
('Commission'),
('Charge'),
('Tax');

--
-- Master table values for FeeCategoryMaster
--
DELETE FROM FeeCategoryMaster;
INSERT INTO FeeCategoryMaster(name) VALUES
('Customer'),
('Product'),
('Payment'),
('Account');

-- Setting master values in variables for downstream usage
SELECT @customerFeeCategoryId := id FROM FeeCategoryMaster WHERE name = 'Customer';
SELECT @productFeeCategoryId := id FROM FeeCategoryMaster WHERE name = 'Product';
SELECT @paymentFeeCategoryId := id FROM FeeCategoryMaster WHERE name = 'Payment';
SELECT @accountFeeCategoryId := id FROM FeeCategoryMaster WHERE name = 'Account';

--
-- Master table values for FeeFrequencyMaster
--
DELETE FROM FeeFrequencyMaster;
INSERT INTO FeeFrequencyMaster(name) VALUES
('One Time'),
('Periodic');

--
-- Master table values for FeeCalcTypeMaster
--
DELETE FROM FeeCalcTypeMaster;
INSERT INTO FeeCalcTypeMaster(name) VALUES
('Flat Amount'),
('Rate');

--
-- Master table values for FeeChargeTimeMaster
--
DELETE FROM FeeChargeTimeMaster;
INSERT INTO FeeChargeTimeMaster(fee_category_id, product_category_id, name) VALUES
(@customerFeeCategoryId, NULL, 'After Customer Enrollment'),
(@productFeeCategoryId, @loanProductCategoryId, 'After Loan Account Opening'),
(@productFeeCategoryId, @loanProductCategoryId, 'During Loan Disbursement'),
(@productFeeCategoryId, @loanProductCategoryId, 'During First Loan Repayment'),
(@productFeeCategoryId, @loanProductCategoryId, 'Days After Disbursement'),
(@paymentFeeCategoryId, @loanProductCategoryId, 'On Cheque Bounce'),
(@accountFeeCategoryId, @loanProductCategoryId, 'After Loan Account Opening'),
(@accountFeeCategoryId, @loanProductCategoryId, 'During Loan Disbursement'),
(@accountFeeCategoryId, @loanProductCategoryId, 'During First Loan Repayment'),
(@accountFeeCategoryId, @loanProductCategoryId, 'Current Day'),
(@accountFeeCategoryId, @loanProductCategoryId, 'Set Date'),
(@paymentFeeCategoryId, @loanProductCategoryId, 'On NACH Failure'),
(@accountFeeCategoryId, @loanProductCategoryId, 'Days After Disbursement');

--
-- Master table values for FeeRateTypeMaster
--
DELETE FROM FeeRateTypeMaster;
INSERT INTO FeeRateTypeMaster(name) VALUES
('Loan Amount'),
('Principal Outstanding'),
('Deposit Amount');

--
-- Master table values for FeeLevyAmountMaster
--
DELETE FROM FeeLevyAmountMaster;
INSERT INTO FeeLevyAmountMaster(name) VALUES
('For all amounts'),
('Slabbed');

--
-- Master table values for LoanCategoryMaster
--
DELETE FROM LoanCategoryMaster;
INSERT INTO LoanCategoryMaster(name) VALUES
('Individual Loan'),
('Group Loan');

--
-- Master table values for LoanTypeMaster
--
DELETE FROM LoanTypeMaster;
INSERT INTO LoanTypeMaster(name) VALUES
('Installment Loan'),
('Revolving Credit Loan');

--
-- Master table values for LoanInstallmentCalcTypeMaster
--
DELETE FROM LoanInstallmentCalcTypeMaster;
INSERT INTO LoanInstallmentCalcTypeMaster(name, abbr) VALUES
('Let System Calculate', 'LSC'),
('Set Directly For All Accounts', 'SDFAA'),
('Set Directly During Account Opening', 'SDDAO'),
('Set Directly For All Accounts With Fixed First Installment Principal', 'SDFAAFP'),
('Set Directly For All Accounts With Fixed Principal & Interest', 'SDFAAFPI');

--
-- Master table values for LoanInstallmentTypeMaster
--
DELETE FROM LoanInstallmentTypeMaster;
INSERT INTO LoanInstallmentTypeMaster(name) VALUES
('Advance'),
('Regular');

--
-- Master table values for LoanApplicationProcessMaster
--
DELETE FROM LoanApplicationProcessMaster;
INSERT INTO LoanApplicationProcessMaster(name, abbr, description) VALUES
('Application + Approval', 'AA', ''),
('Application + Credit Check + Review + Approval', 'ACRA', ''),
('One Step Approval', 'OSA', '');

--
-- Master table values for IntRateClassMaster
--
DELETE FROM IntRateClassMaster;
INSERT INTO IntRateClassMaster(name) VALUES
('Simple Interest'),
('Compounding Interest');

--
-- Master table values for IntRateTypeMaster
--
DELETE FROM IntRateTypeMaster;
INSERT INTO IntRateTypeMaster(name) VALUES
('Flat'),
('Reducing');

--
-- Master table values for IntRateCategoryMaster
--
DELETE FROM IntRateCategoryMaster;
INSERT INTO IntRateCategoryMaster(name) VALUES
('Fixed'),
('Variable'),
('Floating');

--
-- Master table values for IntRateUnitMaster
--
DELETE FROM IntRateUnitMaster;
INSERT INTO IntRateUnitMaster(name) VALUES
('per month'),
('per annum');

--
-- Master table values for PenaltyRateTypeMaster
--
DELETE FROM PenaltyRateTypeMaster;
INSERT INTO PenaltyRateTypeMaster(name) VALUES
('Overdue Principal'),
('Overdue Interest'),
('Overdue Principal+Interest'),
('Principal Outstanding+Overdue Interest');

--
-- Master table values for DepositCategoryMaster
--
DELETE FROM DepositCategoryMaster;
INSERT INTO DepositCategoryMaster(name) VALUES
('Fixed Deposit'),
('Recurring Deposit'),
('Savings Deposit');

--
-- Master table values for InsuranceCategoryMaster
--
DELETE FROM InsuranceCategoryMaster;
INSERT INTO InsuranceCategoryMaster(name) VALUES
('Health Insurance');

--
-- Master table values for DemandStatusMaster
--
DELETE FROM DemandStatusMaster;
INSERT INTO DemandStatusMaster(name) VALUES
('System Generated'),
('Added Directly'),
('System Generated And Waived'),
('Added Directly And Waived'),
('Cancellation under process'),
('Cancelled'),
('Cancellation Under Process (Reschedule)'),
('Cancelled (Reschedule)');
-- 
--
-- Master table values for PaymentClassMaster
--
DELETE FROM PaymentClassMaster;
INSERT INTO PaymentClassMaster(name) VALUES
('Disbursement'),
('Payment'),
('Deposit'),
('Withdrawal'),
('Waiver'),
('Posting'),
('Savings');

-- Setting master values in variables for downstream usage
SELECT @disbPaymentClassId := id FROM PaymentClassMaster WHERE name = 'Disbursement';
SELECT @payPaymentClassId := id FROM PaymentClassMaster WHERE name = 'Payment';
SELECT @depositPaymentClassId := id FROM PaymentClassMaster WHERE name = 'Deposit';
SELECT @withdrawalPaymentClassId := id FROM PaymentClassMaster WHERE name = 'Withdrawal';
SELECT @postingPaymentClassId := id FROM PaymentClassMaster WHERE name = 'Posting';
SELECT @demandPaymentClassId := id FROM PaymentClassMaster WHERE name = 'Waiver';
SELECT @savingsPaymentClassId := id FROM PaymentClassMaster WHERE name = 'Savings';

--
-- Master table values for PaymentTypeMaster
--
DELETE FROM PaymentTypeMaster;
INSERT INTO PaymentTypeMaster(payment_class_id, name) VALUES
(@disbPaymentClassId, 'Disbursement'),
(@disbPaymentClassId, 'Bulk Disbursement'),
(@disbPaymentClassId, 'Value-dated Disbursement'),
(@payPaymentClassId, 'Repayment'),
(@payPaymentClassId, 'Bulk Repayment'),
(@payPaymentClassId, 'Advance Bulk Repayment'),
(@payPaymentClassId, 'Loan Foreclosure'),
(@payPaymentClassId, 'Loan Write-off'),
(@payPaymentClassId, 'Value-dated Payment'),
(@payPaymentClassId, 'Direct Repayment'),
(@payPaymentClassId, 'Direct Value-dated Payment'),
(@payPaymentClassId, 'Bulk Loan Foreclosure'),
(@payPaymentClassId, 'Value-dated Loan Foreclosure'),
(@depositPaymentClassId, 'Deposit'),
(@depositPaymentClassId, 'Payment'),
(@demandPaymentClassId, 'Demand Waiver'),
(@demandPaymentClassId, 'Value-dated Demand Waiver'),
(@withdrawalPaymentClassId, 'Withdrawal'),
(@withdrawalPaymentClassId, 'Deposit Foreclosure'),
(@postingPaymentClassId, 'Current Posting'),
(@postingPaymentClassId, 'Value-Dated Posting'),
(@depositPaymentClassId, 'Value-Dated Deposit'),
(@withdrawalPaymentClassId, 'Value-Dated Withdrawal'),
(@payPaymentClassId, 'Write-off Recovery'),
(@payPaymentClassId, 'Value-dated Write-off Recovery'),
(@postingPaymentClassId, 'Multiple Current Posting'),
(@postingPaymentClassId, 'Multiple Value-Dated Posting'),
(@savingsPaymentClassId, 'Savings'),
(@savingsPaymentClassId, 'Value-Dated Savings'),
(@savingsPaymentClassId, 'Payment (Savings)'),
(@withdrawalPaymentClassId, 'Withdrawal (Savings)'),
(@withdrawalPaymentClassId, 'Value-Dated Withdrawal (Savings)'),
(@withdrawalPaymentClassId, 'Savings Foreclosure');

--
-- Master table values for PaymentModeMaster
--
DELETE FROM PaymentModeMaster;
INSERT INTO PaymentModeMaster(name) VALUES
('Cash'),
('Cheque'),
('ECS'),
('Wire Transfer'),
('Savings'),
('Demand Draft'),
('Prepaid Card'),
('Cash Deposit'),
('RTGS'),
('NEFT'),
('Journal'),
('IMPS'),
('IMPO'),
('BBPS'),
('UPI'),
('Advance Payment'),
('Inter Account Transfer');

--
-- Master table values for PaymentByMaster
--
DELETE FROM PaymentByMaster;
INSERT INTO PaymentByMaster(name) VALUES
('Borrower'),
('Group/Guarantor');

--
-- Master table values for PaymentStatusMaster
--
DELETE FROM PaymentStatusMaster;
INSERT INTO PaymentStatusMaster(name) VALUES
('Complete'),
('Under process'),
('Cancellation under process'),
('Cancelled');

--
-- Master table values for BalanceMaster
--
DELETE FROM BalanceMaster;
INSERT INTO BalanceMaster(name) VALUES
('Minimum Balance'),
('Average Balance');

--
-- Master table values for ChequeStatusMaster
--
DELETE FROM ChequeStatusMaster;
INSERT INTO ChequeStatusMaster(name) VALUES
('Unpresented'),
('Unpresented and on hold'),
('Unpresented and returned to client'),
('Presented'),
('Presented and cleared'),
('Presented and bounced'),
('Re-presented'),
('Re-presented and cleared'),
('Re-presented and bounced');

--
-- Master table values for ChequeTypeMaster
--
DELETE FROM ChequeTypeMaster;
INSERT INTO ChequeTypeMaster(name) VALUES
('Installment'),
('Security');

--
-- Master table values for StationeryBatchIssueMaster
--
DELETE FROM StationeryBatchIssueMaster;
INSERT INTO StationeryBatchIssueMaster(name) VALUES
('Officer'),
('Office'),
('State');

-- Setting master values in variables for downstream usage
SELECT @officeStationeryBatchIssueMasterId := id FROM StationeryBatchIssueMaster WHERE name = 'Office';

--
-- Master table values for StationeryReceiptIssueMaster
--
DELETE FROM StationeryReceiptIssueMaster;
INSERT INTO StationeryReceiptIssueMaster(name, for_document) VALUES
('Center', 0),
('Loan Customer', 0),
('Customer', 0),
('Multiple', 0),
('Account', 1),
('Customer', 1),
('Center Account', 1),
('Center Customer', 1),
('Collateral Owner',1),
('Payment', 1),
('Payment Group', 0),
('Group Account', 1),
('Group Customer', 1),
('Deposit Account', 1),
('Account Payment', 0);

-- Setting master values in variables for downstream usage
SELECT @multipleStationeryIssueMasterId := id FROM StationeryReceiptIssueMaster WHERE name = 'Multiple';

--
-- Master table values for ActionRuleMaster
--
DELETE FROM ActionRuleMaster;
INSERT INTO ActionRuleMaster(name, ui_name, category) VALUES
('Loan Account Opening','Loan Account Opening', 'Stationery'),
('Loan Disbursement','Loan Disbursement', 'Stationery'),
('Loan Utilization','Loan Utilization', 'Stationery'),
('Center Disbursement','Center Disbursement', 'Stationery'),
('Center Payment','Center Payment', 'Stationery'),
('Customer Enrollment','Customer Enrollment', 'Stationery'),
('Center Sanction','Center Sanction', 'Stationery'),
('Direct Issue','Direct Issue', 'Stationery'),
('Loan Scheduling','Loan Scheduling', 'Stationery'),
('CDS Generation','CDS Generation', 'Stationery'),
('Single Closure Repayment','Single Closure Repayment', 'Stationery'),
('Center Disbursement','Center Disbursement', 'Pipeline'),
('Customer Sanction','Customer Sanction', 'Pipeline'),
('Loan Account Approval','Loan Account Approval', 'EmployeeAlert'),
('Customer Collection (Web & Mobile)','Customer Collection Web & Mobile)', 'CustomerAlert'),
('Customer Collection (Mobile Only)','Customer Collection Mobile Only)', 'CustomerAlert'),
('Consolidated Center Collection (Web & Mobile)','Consolidated Center Collection Web & Mobile)', 'CustomerAlert'),
('Consolidated Center Collection (Mobile Only)','Consolidated Center Collection Mobile Only)', 'CustomerAlert'),
('Confirm EOD Completion','Confirm EOD Completion', 'EmployeeAlert'),
('Pipeline Status Update','Pipeline Status Update', 'EmployeeAlert'),
('Stationery Issue','Stationery Issue', 'EmployeeAlert'),
('Stationery Acknowledgement','Stationery Acknowledgement', 'EmployeeAlert'),
('Loan Approval','Loan Approval', 'Slab'),
('Loan Disbursement','Loan Disbursement', 'OTP'),
('ECS Disbursement','ECS Disbursement', 'OTP'),
('Entity Contact Verification','Contact Number Verification', 'OTP'),
('Pipeline Status Upcoming','Pipeline Status Upcoming', 'EmployeeAlert'),
('Bulk Loan Payment','Bulk Loan Payment', 'API Transaction'),
('Customer Documents','Customer Documents', 'API Transaction'),
('Pipeline Documents','Pipeline Documents', 'API Transaction'),
('Payment Group Documents','Payment Group Documents', 'API Transaction'),
('Survey Documents','Survey Documents', 'API Transaction'),
('Employee Documents','Employee Documents', 'API Transaction'),
('Create LoanPipeline','Create LoanPipeline', 'API Transaction'),
('Bene Validation Failure ','Bene Validation Failure ', 'EmployeeAlert'),
('ECS Transfer Failure','ECS Transfer Failure', 'EmployeeAlert'),
('Update LoanPipeline Status','Update LoanPipeline Status', 'API Transaction'),
('Start LoanPipeline Status','Start LoanPipeline Status', 'API Transaction'),
('End LoanPipeline Status','End LoanPipeline Status', 'API Transaction'),
('Customer Partial Enrollment','Customer Partial Enrollment', 'API Transaction'),
('Bulk Update QC Status','Bulk Update QC Status', 'API Transaction'),
('Perform Quality Check','Perform Quality Check', 'API Transaction'),
('User Change Password','User Change Password', 'API Transaction'),
('Create LoanCenter','Create LoanCenter', 'API Transaction'),
('Create LoanGroup','Create LoanGroup', 'API Transaction'),
('Update Loan Center Meeting','Update Loan Center Meeting', 'API Transaction'),
('LoanPipeline Attendance','LoanPipeline Attendance', 'API Transaction'),
('Attach Customers to Group','Attach Customers to Group', 'API Transaction'),
('Add Household Members','Add Household Members', 'API Transaction'),
('Update Household Members','Update Household Members', 'API Transaction'),
('Set Enquiry Status By Branch','Set Enquiry Status By Branch', 'API Transaction'),
('Customer Bene Validation','Customer Bene Validation', 'API Transaction'),
('Set Enquiry Status By Customer','Set Enquiry Status By Customer', 'API Transaction'),
('Pipeline Status Documents','Pipeline Status Documents', 'API Transaction'),
('Create Enquiry Request','Create Enquiry Request', 'API Transaction'),
('Update Nominee','Update Nominee', 'API Transaction'),
('Attach Customers to Loan Pipeline','Attach Customers to Loan Pipeline', 'API Transaction'),
('Entity Contact Verification (mShakti)','Entity Contact Verification mShakti)', 'API Transaction'),
('Update Customer Pipeline Status','Update Customer Pipeline Status', 'API Transaction'),
('Missed Call for Loan Details','Missed Call for Loan Details', 'CustomerAlert'),
('Password Expiry Alert','Password Expiry Alert','EmployeeAlert'),
('Jewel Loan Asset Verification','Jewel Loan Asset Verification', 'Stationery'),
('Add Account Comments','Add Account Comments', 'API Transaction'),
('Add Customer Comments','Add Customer Comments', 'API Transaction'),
('Loan Utilization','Loan Utilization', 'API Transaction'),
('Customer Collection (Third-Party)','Customer Collection Third-Party)', 'CustomerAlert'),
('Bulk Loan Attendance','Bulk Loan Attendance', 'API Transaction'),
('Written off  Loan Recovery Payment','Written off  Loan Recovery Payment', 'API Transaction'),
('Claim Insurance','Claim Insurance', 'API Transaction'),
('Update Entity Bank Details', 'Update Entity Bank Details', 'API Transaction'),
('Claim Insurance Documents','Claim Insurance Documents', 'API Transaction'),
('Loan Utilization','Loan Utilization', 'Loan Officer Allocation'),
('Set S3 Upload Success','Set S3 Upload Success', 'API Transaction'),
('Record Death','Record Death', 'API Transaction'),
('Visit Questionnaire','Visit Questionnaire', 'API Transaction'),
('Reconfirmation Of Customers Bank Account','Reconfirmation Of Customers Bank Account', 'API Transaction'),
('Cancel Customers from Loan Pipeline','Cancel Customers from Loan Pipeline', 'API Transaction'),
('Add Account Documents','Add Account Documents', 'API Transaction'),
('Update Account Documents','Update Account Documents', 'API Transaction'),
('Customer Collection UPI SMS Link','Customer Collection UPI SMS Link', 'CustomerAlert'),
('Loan Collection','Loan Collection', 'Loan Officer Allocation'),
('Telecalling','Telecalling', 'Loan Officer Allocation'),
('Loan Pipeline Status Survey','Loan Pipeline Status Survey', 'API Transaction'),
('Claim Entity Contact','Claim Entity Contact', 'API Transaction'),
('Digital Consent Contact Verification','Digital Consent Contact Verification', 'OTP'),
('Device Registration and Approval (mShakti)','Device Registration and Approval (mShakti)', 'API Transaction'),
('Device Registration and Approval','Device Registration and Approval', 'OTP'),
('Loan Disbursement','Loan Disbursement', 'CustomerAlert'),
('Installment Overdue','Installment Overdue', 'CustomerAlert'),
('Installment Reminder','Installment Reminder', 'CustomerAlert'),
('Cheque Bounce','Cheque Bounce', 'CustomerAlert'),
('Customer Pipeline Status Cancellation','Customer Pipeline Status Cancellation', 'API Transaction'),
('Center Pipeline Status Cancellation','Center Pipeline Status Cancellation', 'API Transaction'),
('Confirm Geo Location','Confirm Geo Location', 'API Transaction'),
('Claim Details on User Request','Claim Details on User Request', 'CustomerAlert'),
('Customer Collection UPI','Customer Collection UPI', 'CustomerAlert'),
('Loan Disbursement','Loan Disbursement', 'Stationery Manadatory'),
('Center Disbursement','Center Disbursement', 'Stationery Manadatory'),
('Set Disbursement Date','Set Disbursement Date', 'API Transaction'),
('Document Generation','Document Generation', 'Stationery'),
('Update Household Income and Expense','Update Household Income and Expense', 'API Transaction'),
('Add Entity Proof Details','Add Entity Proof Details', 'API Transaction'),
('Update Entity Proof Details','Update Entity Proof Details', 'API Transaction'),
('Document Generation','Document Generation', 'OTP'),
('Document Generation','Signature Verification', 'OTP');
('Consumer Durable Damaged Inventory','Consumer Durable Damaged Inventory', 'API Transaction'),
('Consumer Durable Branch Inventory','Consumer Durable Branch Inventory', 'API Transaction'),
('Finish Enrollment','Finish Enrollment', 'API Transaction'),
('Multi Reset Customer Status','Multi Reset Customer Status', 'API Transaction'),
('Loan Account Decline OR Reject','Loan Account Decline OR Reject', 'CustomerAlert'),
('Entity Geo Location','Entity Geo Location','API Transaction'),
('Update Customer Demographics','Update Customer Demographics', 'API Transaction'),
('Update Contact Details','Update Contact Details', 'API Transaction'),
('Update Bank Details','Update Bank Details', 'API Transaction'),
('Update Guarantor','Update Guarantor', 'API Transaction'),
('Center Sanction','Center Sanction', 'Pipeline'),
('Bulk Loan Payment','Bulk Loan Payment', 'Stationery'),
('DPD Loans','DPD Loans', 'CustomerAlert'),
('CB Consent SMS on User Request','CB Consent SMS on User Request', 'API Transaction'),
('CB Consent SMS on User Request','CB Consent SMS on User Request', 'OTP'),
('Single Overdue Repayment','Single Overdue Repayment','Stationery'),
('Single Advance Repayment','Single Advance Repayment','Stationery'),
('Single Current Repayment','Single Current Repayment','Stationery'),
('Single Write-off Recovery Repayment','Single Write-off Recovery Repayment','Stationery');
('Auto-Disbursement Cancellation on ECS failure(API)','Auto-Disbursement Cancellation on ECS failure(API)', 'CustomerAlert'),
('Payment Cancel','Payment Cancel', 'CustomerAlert'),
('ECS Failed As Cash Disbursement','ECS Failed As Cash Disbursement', 'CustomerAlert'),
('DPD Loans','DPD Loans', 'CustomerAlert'),
('Bulk Deposit Pay','Bulk Deposit Pay', 'API Transaction'),
('Add or Update Jewel Collateral','Add or Update Jewel Collateral', 'API Transaction'),
('Voter Id Verification','Voter Id Verification', 'API Transaction'),
('First Installment Overdue','First Installment Overdue', 'CustomerAlert'),
('Center Officer Transfer or Terminate Alert','Center Officer Transfer or Terminate Alert', 'CustomerAlert'),
('Center Officer Transfer or Terminate Cancel Alert','Center Officer Transfer or Terminate Cancel Alert', 'CustomerAlert'),
('Center New Officer Alert','Center New Officer Alert', 'CustomerAlert'),
('Customer Collection Web, Mobile & Third Party (All modes except Journal)', 'Customer Collection Web, Mobile & Third Party (All modes except Journal)', 'CustomerAlert'),
('Vehicle Collateral Documents','Vehicle Collateral Documents', 'API Transaction'),
('Add External Loan Source','Add External Loan Source', 'API Transaction'),
('Update External Loan Source','Update External Loan Source', 'API Transaction'),
('DPD Loans','DPD Loans', 'CustomerAlert'),
('Write-off Settlement','Write-off Settlement', 'CustomerAlert'),
('Write-off Closure','Write-off Closure', 'CustomerAlert'),
('Write-off Recovery','Write-off Recovery', 'CustomerAlert');

-- Setting master values in variables for downstream usage
SELECT @centerPaymentActionRuleId := id FROM ActionRuleMaster WHERE name = 'Center Payment' AND category = 'Stationery';
SELECT @directIssueActionRuleId := id FROM ActionRuleMaster WHERE name = 'Direct Issue' AND category = 'Stationery';
SELECT @loanApprovalSlabActionRuleId := id FROM ActionRuleMaster WHERE name = 'Loan Approval' AND category = 'Slab';
SELECT @customerOTPActionRuleId := id FROM ActionRuleMaster WHERE name = 'Customer Enrollment' AND category = 'Stationery';
SELECT @entityContactOTPActionRuleId := id FROM ActionRuleMaster WHERE name = 'Entity Contact Verification' AND category = 'OTP';
SELECT @digitalConsentOTPActionRuleId := id FROM ActionRuleMaster WHERE name = 'Digital Consent Contact Verification' AND category = 'OTP';
SELECT @deviceVerificationApprovalRuleId := id FROM ActionRuleMaster WHERE name = 'Device Registration and Approval' AND category = 'OTP';
SELECT @cbConsentRuleId := id FROM ActionRuleMaster WHERE name = 'CB Consent SMS on User Request' AND category = 'OTP';

--
-- Master table values for AlertClassMaster
--
DELETE FROM AlertClassMaster;
INSERT INTO AlertClassMaster(name) VALUES
('Employee'),
('Customer');

--
-- Master table values for StationeryRuleTypeMaster
--
DELETE FROM StationeryRuleTypeMaster;
INSERT INTO StationeryRuleTypeMaster(rule_id, name, abbr) VALUES
(@centerPaymentActionRuleId, 'One receipt for all payments', 'ONE_ALL'),
(@centerPaymentActionRuleId, 'One receipt each for group loan payments and individual loan payments', 'ONE_ALL_EACH'),
(@centerPaymentActionRuleId, 'One receipt for all group loan payments and one for each individual loan payment', 'ONE_EACH');

--
-- Master table values for StationeryStatusMaster
--
DELETE FROM StationeryStatusMaster;
INSERT INTO StationeryStatusMaster(name) VALUES
('Issued to branch'),
('Issued to village/area'),
('Issued to center'),
('Issued to officer'),
('Issued to loan customer'),
('In use'),
('Closed'),
('Cancelled'),
('Lost/Misplaced'),
('Returned to HO'),
('In Stock'),
('Issued to State');

--
-- Master table values for StationeryType
--
SELECT @officeStationeryBatchIssueMasterId := id FROM StationeryBatchIssueMaster WHERE name = 'Office';
DELETE FROM StationeryType;
INSERT INTO StationeryType(name, abbr, batch_issue_id, max_num_batches, is_active, mandatory_type_indicator, return_to_ho, specify_batch_no, rule_type_id, dms_link, collect_amount, request_based, is_system_defined, is_single_stationery, auto_sequence, show_request_popup, request_popup_count) VALUES
('Cheque Book','CHQ', @officeStationeryBatchIssueMasterId, 100, 1, 0, 1, 0, NULL, NULL, 1, 1, 1, 0, 0, 0, NULL),
('Demand Draft','DD', @officeStationeryBatchIssueMasterId, 1, 1, 0, 0, 0, NULL, NULL, 1, 0, 1, 1, 0, 0, NULL),
('Prepaid Card','PPC', @officeStationeryBatchIssueMasterId, 1, 1, 0, 0, 0, NULL, NULL, 1, 0, 1, 1, 0, 0, NULL);

-- Setting StatineryType master values in variables for rule and receipt issue insert usage
SELECT @chequeStationeryTypeId := id FROM StationeryType WHERE name = 'Cheque Book' AND abbr = 'CHQ';
SELECT @demandDraftStationeryTypeId := id FROM StationeryType WHERE name = 'Demand Draft' AND abbr = 'DD';
SELECT @prepaidCardStationeryTypeId := id FROM StationeryType WHERE name = 'Prepaid Card' AND abbr = 'PPC';
--
-- StationeryTypeRule for StationeryType master value
--
DELETE FROM StationeryTypeRule;
INSERT INTO StationeryTypeRule(type_id, rule_id) VALUES
(@chequeStationeryTypeId, @directIssueActionRuleId),
(@demandDraftStationeryTypeId, @directIssueActionRuleId),
(@prepaidCardStationeryTypeId, @directIssueActionRuleId);

--
-- StationeryTypeReceiptIssue for StationeryType master value
--
DELETE FROM StationeryTypeReceiptIssue;
INSERT INTO StationeryTypeReceiptIssue(type_id, receipt_issue_id) VALUES
(@chequeStationeryTypeId, @multipleStationeryIssueMasterId),
(@demandDraftStationeryTypeId, @multipleStationeryIssueMasterId),
(@prepaidCardStationeryTypeId, @multipleStationeryIssueMasterId);

-- Setting StatineryType master values in variables for rule and receipt issue insert usage
SELECT @inUseStationeryStatusId := id FROM StationeryStatusMaster WHERE name = 'In use';

--
-- StationeryTypeReceiptIssue for StationeryType master value
--
DELETE FROM Stationery;
INSERT INTO Stationery(type_id, batch_no, start_serial_no, end_serial_no, status) VALUES
(@demandDraftStationeryTypeId, '000001', '000001', '999999', @inUseStationeryStatusId),
(@prepaidCardStationeryTypeId, '000001', '0000000000000001', '9999999999999999',@inUseStationeryStatusId);

--
-- Master table values for CollateralTypeMaster
--
DELETE FROM CollateralTypeMaster;
INSERT INTO CollateralTypeMaster(name) VALUES
('Vehicle'),
('Jewel'),
('Deposit'),
('House'),
('Mortgage'),
('Machinery'),
('Solar');

--
-- Master table values for FundingTypeMaster
--
DELETE FROM FundingTypeMaster;
INSERT INTO FundingTypeMaster(name) VALUES
('Asset Sale'),
('Hypothecation'),
('On-lending'),
('Securitization'),
('Internal');

--
-- Master table values for FundRequestStatusMaster
--
DELETE FROM FundRequestStatusMaster;
INSERT INTO FundRequestStatusMaster(name, is_restricted) VALUES
('Requested', 0),
('Cancelled', 0),
('Approved', 0);

--
-- Master table values for TransactionClassMaster
--
DELETE FROM TransactionClassMaster;
INSERT INTO TransactionClassMaster(name) VALUES
('Principal'),
('Interest'),
('Non-accrual Interest'),
('Fees'),
('Insurance Premium'),
('Charges'),
('System'),
('Cash Transfer'),
('GL Posts'),
('Savings/Deposit'),
('Tax'),
('Capitalization');

-- Setting variables for all TransactionClassMaster entries to be used as FK in other tables
SELECT @principalTxClassId := id FROM TransactionClassMaster WHERE name = "Principal";
SELECT @interestTxClassId := id FROM TransactionClassMaster WHERE name = "Interest";
SELECT @nonAccrInterestTxClassId := id FROM TransactionClassMaster WHERE name = "Non-accrual Interest";
SELECT @feesTxClassId := id FROM TransactionClassMaster WHERE name = "Fees";
SELECT @insuPremTxClassId := id FROM TransactionClassMaster WHERE name = "Insurance Premium";
SELECT @chargesTxClassId := id FROM TransactionClassMaster WHERE name = "Charges";
SELECT @systemTxClassId := id FROM TransactionClassMaster WHERE name = "System";
SELECT @cashTransferTxClassId := id FROM TransactionClassMaster WHERE name = "Cash Transfer";
SELECT @glPostsTxClassId := id FROM TransactionClassMaster WHERE name = "GL Posts";
SELECT @depositTxClassId := id FROM TransactionClassMaster WHERE name = "Savings/Deposit";
SELECT @taxTxClassId := id FROM TransactionClassMaster WHERE name = "Tax";
SELECT @capTxClassId := id FROM TransactionClassMaster WHERE name = "Capitalization";

--
-- Master table values for TransactionTypeMaster
--
DELETE FROM TransactionTypeMaster;
INSERT INTO TransactionTypeMaster(transaction_class_id, name) VALUES
(@principalTxClassId, 'Disbursement'),
(@principalTxClassId, 'Principal'),
(@principalTxClassId, 'Prepayment of Principal'),
(@systemTxClassId, 'Interest Accrual'),
(@systemTxClassId, 'Interest Demand'),
(@systemTxClassId, 'Overdue Interest Demand'),
(@interestTxClassId, 'Prepayment of Interest'),
(@interestTxClassId, 'Interest'),
(@systemTxClassId, 'Interest Waiver Demand (Old)'),
(@systemTxClassId, 'Interest Waiver Demand'),
(@interestTxClassId, 'Overdue Interest'),
(@systemTxClassId, 'Overdue Interest Waiver Demand'),
(@systemTxClassId, 'Interest on Overdue Principal Demand'),
(@nonAccrInterestTxClassId, 'Interest on Overdue Principal'),
(@nonAccrInterestTxClassId, 'Interest on Overdue Principal (Cash)'),
(@systemTxClassId, 'Interest on Overdue Interest Demand'),
(@nonAccrInterestTxClassId, 'Interest on Overdue Interest'),
(@nonAccrInterestTxClassId, 'Interest on Overdue Interest (Cash)'),
(@systemTxClassId, 'Fee Demand'),
(@systemTxClassId, 'Fee (Cash) Waiver Demand'),
(@feesTxClassId, 'Fee'),
(@feesTxClassId, 'Fee (Cash)'),
(@systemTxClassId, 'Insurance Premium Demand'),
(@systemTxClassId, 'Insurance Premium (Cash) Waiver Demand'),
(@insuPremTxClassId, 'Insurance Premium'),
(@insuPremTxClassId, 'Insurance Premium (Cash)'),
(@systemTxClassId, 'Late Charge Demand'),
(@chargesTxClassId, 'Late Charge'),
(@chargesTxClassId, 'Late Charge (Cash)'),
(@systemTxClassId, 'Late Charge Waiver Demand'),
(@chargesTxClassId, 'Foreclosure Penalty'),
(@systemTxClassId, 'To Roundoff'),
(@cashTransferTxClassId, 'Cash Sent'),
(@cashTransferTxClassId, 'Cash In Transit'),
(@cashTransferTxClassId, 'Cash Received'),
(@glPostsTxClassId, 'GL Entry'),
(@depositTxClassId, 'Deposit'),
(@depositTxClassId, 'Withdrawal'),
(@systemTxClassId, 'Capitalization of Interest'),
(@systemTxClassId, 'Compounding of Interest'),
(@depositTxClassId, 'Early Withdrawal'),
(@chargesTxClassId, 'Early Withdrawal Penalty'),
(@systemTxClassId, 'Cheque Bounce Charge Demand'),
(@chargesTxClassId, 'Cheque Bounce Charge'),
(@chargesTxClassId, 'Cheque Bounce Charge (Cash)'),
(@systemTxClassId, 'Commission Demand'),
(@chargesTxClassId, 'Commission'),
(@systemTxClassId, 'Savings Interest Accrual'),
(@systemTxClassId, 'Interest Payout Demand'),
(@systemTxClassId, 'Compounded Interest Payout Demand'),
(@systemTxClassId, 'Overdue Interest Payout Demand'),
(@interestTxClassId, 'Pre-payout of Interest'),
(@interestTxClassId, 'Pre-payout of Compounded Interest'),
(@interestTxClassId, 'Interest Payout'),
(@interestTxClassId, 'Overdue Interest Payout'),
(@systemTxClassId, 'Interest Payout Waiver Demand'),
(@systemTxClassId, 'Service Tax Demand'),
(@taxTxClassId, 'Service Tax'),
(@systemTxClassId, 'GST Demand'),
(@systemTxClassId, 'GST (Cash) Waiver Demand'),
(@taxTxClassId, 'GST'),
(@taxTxClassId, 'GST (Cash)'),
(@systemTxClassId, 'TDS Receivable Demand'),
(@systemTxClassId, 'TDS Withholding'),
(@systemTxClassId, 'TDS Withholding (Deposit)'),
(@systemTxClassId, 'Advance Payment'),
(@systemTxClassId, 'Write off Recovery'),
(@interestTxClassId, 'Differential Interest'),
(@interestTxClassId, 'Differential Interest Payout'),
(@systemTxClassId, 'Late Charge (Cash) Waiver Demand'),
(@systemTxClassId, 'Interest on Overdue Interest (Cash) Waiver Demand'),
(@systemTxClassId, 'Interest on Overdue Principal (Cash) Waiver Demand'),
(@capTxClassId, 'Capitalization of Interest (IND)'),
(@capTxClassId, 'Capitalization of Interest (IAD)'),
(@capTxClassId, 'Capitalization of Interest (IOD)'),
(@systemTxClassId, 'Interest Realization'),
(@systemTxClassId, 'Moratorium Interest Accrual'),
(@interestTxClassId, 'Prepayment of Moratorium Interest'),
(@interestTxClassId, 'Moratorium Interest'),
(@systemTxClassId, 'Moratorium Interest Demand'),
(@interestTxClassId, 'Moratorium Differential Interest'),
(@systemTxClassId, 'Moratorium Interest Realization'),
(@systemTxClassId, 'Equated Moratorium Interest Demand'),
(@interestTxClassId, 'Equated Moratorium Interest'),
(@systemTxClassId, 'Moratorium Interest Waiver Demand'),
(@systemTxClassId, 'Equated Moratorium Interest Waiver Demand'),
(@systemTxClassId, 'Interest Accrual (NPA)'),
(@systemTxClassId, 'Interest Income Derecognition (to NPA)'),
(@systemTxClassId, 'Interest Recognition (From NPA to Unrealized)'),
(@systemTxClassId, 'Interest Recognition (From NPA to Realized)'),
(@systemTxClassId, 'Interest Waiver Demand (NPA)'),
(@systemTxClassId, 'Overdue Interest Waiver Demand (NPA)'),
(@interestTxClassId, 'Broken Period Interest'),
(@principalTxClassId, 'Principal (Claim)'),
(@systemTxClassId, 'Interest Demand Round Off');

--
-- Master table values for OTPMaster
--
SET @otpLength = 6;
DELETE FROM OTPMaster;
INSERT INTO OTPMaster(name,rule_id,length) VALUES
('Customer Enrollment',@customerOTPActionRuleId,@otpLength);
INSERT INTO OTPMaster(name,rule_id,length) VALUES
('Entity Contact Verification',@entityContactOTPActionRuleId,@otpLength);
INSERT INTO OTPMaster(name,rule_id,length) VALUES
('Digital Consent Contact Verification',@digitalConsentOTPActionRuleId,@otpLength),
('CB Consent Contact Verification',@cbConsentRuleId,@otpLength);
INSERT INTO OTPMaster(name,rule_id,length,applicable_for_all_offices) VALUES
('Device Registration and Approval',@deviceVerificationApprovalRuleId,@otpLength, 1);

-- Setting variables for all TransactionTypeMaster entries to be used as FK in other tables
SELECT @disbursementTypeId := id FROM TransactionTypeMaster WHERE name = "Disbursement";
SELECT @principalTypeId := id FROM TransactionTypeMaster WHERE name = "Principal";
SELECT @principalClaimTypeId := id FROM TransactionTypeMaster WHERE name = "Principal (Claim)";
SELECT @prepaymentofPrincipalTypeId := id FROM TransactionTypeMaster WHERE name = "Prepayment of Principal";
SELECT @interestAccrualTypeId := id FROM TransactionTypeMaster WHERE name = "Interest Accrual";
SELECT @interestDemandTypeId := id FROM TransactionTypeMaster WHERE name = "Interest Demand";
SELECT @interestWaiverDemandTypeId := id FROM TransactionTypeMaster WHERE name = "Interest Waiver Demand";
SELECT @overdueInterestDemandTypeId := id FROM TransactionTypeMaster WHERE name = "Overdue Interest Demand";
SELECT @overdueInterestWaiverDemandTypeId := id FROM TransactionTypeMaster WHERE name = "Overdue Interest Waiver Demand";
SELECT @interestOnOverduePrincipalDemandTypeId := id FROM TransactionTypeMaster WHERE name = "Interest on Overdue Principal Demand";
SELECT @interestOnOverduePrincipalTypeId := id FROM TransactionTypeMaster WHERE name = "Interest on Overdue Principal";
SELECT @interestOnOverduePrincipalCashTypeId := id FROM TransactionTypeMaster WHERE name = "Interest on Overdue Principal (Cash)";
SELECT @prepaymentofInterestTypeId := id FROM TransactionTypeMaster WHERE name = "Prepayment of Interest";
SELECT @interestTypeId := id FROM TransactionTypeMaster WHERE name = "Interest";
SELECT @overdueInterestTypeId := id FROM TransactionTypeMaster WHERE name = "Overdue Interest";
SELECT @interestOnOverdueInterestDemandTypeId := id FROM TransactionTypeMaster WHERE name = "Interest on Overdue Interest Demand";
SELECT @interestOnOverdueInterestTypeId := id FROM TransactionTypeMaster WHERE name = "Interest on Overdue Interest";
SELECT @interestOnOverdueInterestCashTypeId := id FROM TransactionTypeMaster WHERE name = "Interest on Overdue Interest (Cash)";
SELECT @differentialInterestTypeId := id FROM TransactionTypeMaster WHERE name = "Differential Interest";
SELECT @feeDemandTypeId := id FROM TransactionTypeMaster WHERE name = "Fee Demand";
SELECT @feeTypeId := id FROM TransactionTypeMaster WHERE name = "Fee";
SELECT @insurancePremiumDemandTypeId := id FROM TransactionTypeMaster WHERE name = "Insurance Premium Demand";
SELECT @insurancePremiumTypeId := id FROM TransactionTypeMaster WHERE name = "Insurance Premium";
SELECT @lateChargeDemandTypeId := id FROM TransactionTypeMaster WHERE name = "Late Charge Demand";
SELECT @lateChargeTypeId := id FROM TransactionTypeMaster WHERE name = "Late Charge";
SELECT @lateChargeCashTypeId := id FROM TransactionTypeMaster WHERE name = "Late Charge (Cash)";
SELECT @lateChargeWaiverDemandTypeId := id FROM TransactionTypeMaster WHERE name = "Late Charge Waiver Demand";
SELECT @foreclosurePenaltyTypeId := id FROM TransactionTypeMaster WHERE name = "Foreclosure Penalty";
SELECT @toRoundoffTypeId := id FROM TransactionTypeMaster WHERE name = "To Roundoff";
SELECT @cashSentTypeId := id FROM TransactionTypeMaster WHERE name = "Cash Sent";
SELECT @cashInTransitTypeId := id FROM TransactionTypeMaster WHERE name = "Cash In Transit";
SELECT @cashReceivedTypeId := id FROM TransactionTypeMaster WHERE name = "Cash Received";
SELECT @gLEntryTypeId := id FROM TransactionTypeMaster WHERE name = "GL Entry";
SELECT @depositTypeId := id FROM TransactionTypeMaster WHERE name = "Deposit";
SELECT @withdrawalTypeId := id FROM TransactionTypeMaster WHERE name = "Withdrawal";
SELECT @capitalizationOfInterestTypeId := id FROM TransactionTypeMaster WHERE name = "Capitalization of Interest";
SELECT @compoundingOfInterestTypeId := id FROM TransactionTypeMaster WHERE name = "Compounding of Interest";
SELECT @earlyWithdrawalTypeId := id FROM TransactionTypeMaster WHERE name = "Early Withdrawal";
SELECT @earlyWithdrawalPenaltyTypeId := id FROM TransactionTypeMaster WHERE name = "Early Withdrawal Penalty";
SELECT @chequeBounceChargeDemandTypeId := id FROM TransactionTypeMaster WHERE name = "Cheque Bounce Charge Demand";
SELECT @chequeBounceChargeTypeId := id FROM TransactionTypeMaster WHERE name = "Cheque Bounce Charge";
SELECT @commissionDemandTypeId := id FROM TransactionTypeMaster WHERE name = "Commission Demand";
SELECT @commissionTypeId := id FROM TransactionTypeMaster WHERE name = "Commission";
SELECT @savingsInterestAccrualTypeId := id FROM TransactionTypeMaster WHERE name = "Savings Interest Accrual";
SELECT @interestPayoutDemandTypeId := id FROM TransactionTypeMaster WHERE name = "Interest Payout Demand";
SELECT @interestPayoutWaiverDemandTypeId := id FROM TransactionTypeMaster WHERE name = "Interest Payout Waiver Demand";
SELECT @compoundedInterestPayoutDemandTypeId := id FROM TransactionTypeMaster WHERE name = "Compounded Interest Payout Demand";
SELECT @overdueInterestPayoutDemandTypeId := id FROM TransactionTypeMaster WHERE name = "Overdue Interest Payout Demand";
SELECT @prepayoutOfInterestTypeId := id FROM TransactionTypeMaster WHERE name = "Pre-payout of Interest";
SELECT @prepayoutOfCompoundedInterestTypeId := id FROM TransactionTypeMaster WHERE name = "Pre-payout of Compounded Interest";
SELECT @interestPayoutTypeId := id FROM TransactionTypeMaster WHERE name = "Interest Payout";
SELECT @overdueInterestPayoutTypeId := id FROM TransactionTypeMaster WHERE name = "Overdue Interest Payout";
SELECT @differentialInterestPayoutTypeId := id FROM TransactionTypeMaster WHERE name = "Differential Interest Payout";
SELECT @serviceTaxDemandTypeId := id FROM TransactionTypeMaster WHERE name = "Service Tax Demand";
SELECT @serviceTaxTypeId := id FROM TransactionTypeMaster WHERE name = "Service Tax";
SELECT @gstDemandTypeId := id FROM TransactionTypeMaster WHERE name = "GST Demand";
SELECT @gstTypeId := id FROM TransactionTypeMaster WHERE name = "GST";
SELECT @tdsReceivableDemandTypeId := id FROM TransactionTypeMaster WHERE name = "TDS Receivable Demand";
SELECT @tdsWithholdingTypeId := id FROM TransactionTypeMaster WHERE name = "TDS Withholding";
SELECT @tdsWithholdingDepositTypeId := id FROM TransactionTypeMaster WHERE name = "TDS Withholding (Deposit)";
SELECT @advancePaymentTypeId := id FROM TransactionTypeMaster WHERE name = "Advance Payment";
SELECT @writeOffRecoveryTypeId := id FROM TransactionTypeMaster WHERE name = "Write Off Recovery";
SELECT @overdueIntDemandWaiverTypeId := id FROM TransactionTypeMaster WHERE name = "Overdue Interest Waiver Demand";
SELECT @capitalizationIntAccNotDueTypeId := id FROM TransactionTypeMaster WHERE name = "Capitalization of Interest (IND)";
SELECT @capitalizationIntAccAndDueTypeId := id FROM TransactionTypeMaster WHERE name = "Capitalization of Interest (IAD)";
SELECT @capitalizationIntAccOverdueTypeId := id FROM TransactionTypeMaster WHERE name = "Capitalization of Interest (IOD)";
SELECT @intRealizationTypeId := id FROM TransactionTypeMaster WHERE name = "Interest Realization";
SELECT @moraIntAccrualTypeId := id FROM TransactionTypeMaster WHERE name = "Moratorium Interest Accrual";
SELECT @prepaymentMoraIntTypeId := id FROM TransactionTypeMaster WHERE name = "Prepayment of Moratorium Interest";
SELECT @moraIntTypeId := id FROM TransactionTypeMaster WHERE name = "Moratorium Interest";
SELECT @moraIntDemandTypeId := id FROM TransactionTypeMaster WHERE name = "Moratorium Interest Demand";
SELECT @moraDifferentialIntTypeId := id FROM TransactionTypeMaster WHERE name = "Moratorium Differential Interest";
SELECT @moraIntWaiverDemandTypeId := id FROM TransactionTypeMaster WHERE name = "Moratorium Interest Waiver Demand";
SELECT @moraIntRealizationTypeId := id FROM TransactionTypeMaster WHERE name = "Moratorium Interest Realization";
SELECT @equatedMoraIntDemandTypeId := id FROM TransactionTypeMaster WHERE name = "Equated Moratorium Interest Demand";
SELECT @equatedMoraIntTypeId := id FROM TransactionTypeMaster WHERE name = "Equated Moratorium Interest";
SELECT @equatedMoraIntWaiverDemandTypeId := id FROM TransactionTypeMaster WHERE name = "Equated Moratorium Interest Waiver Demand";
SELECT @intAccrualNPATypeId := id FROM TransactionTypeMaster WHERE name = "Interest Accrual (NPA)";
SELECT @intIncomeDerecognitionTypeId := id FROM TransactionTypeMaster WHERE name = "Interest Income Derecognition (to NPA)";
SELECT @intRecognizeNPAToUnrealizedTypeId := id FROM TransactionTypeMaster WHERE name = "Interest Recognition (From NPA to Unrealized)";
SELECT @intRecognizeNPAToRealizedTypeId := id FROM TransactionTypeMaster WHERE name = "Interest Recognition (From NPA to Realized)";
SELECT @intWaiverNPATypeId := id FROM TransactionTypeMaster WHERE name = "Interest Waiver Demand (NPA)";
SELECT @intOverdueWaiverTypeId := id FROM TransactionTypeMaster WHERE name = "Overdue Interest Waiver Demand (NPA)";
SELECT @feeCashTypeId := id FROM TransactionTypeMaster WHERE name = "Fee (Cash)";
SELECT @gstCashTypeId := id FROM TransactionTypeMaster WHERE name = "GST (Cash)";
SELECT @insurancePremiumCashTypeId := id FROM TransactionTypeMaster WHERE name = "Insurance Premium (Cash)";
--
-- Master table values for GLHeadMaster
--
DELETE FROM GLHeadMaster;
INSERT INTO GLHeadMaster(name, custom_gl_name) VALUES
("Assets", "Assets"),
("Liabilities", "Liabilities"),
("Income", "Income"),
("Expenses", "Expenses"),
("Fixed Assets", "Fixed Assets"),
("Investments", "Investments"),
("Cash Balances", "Cash Balances"),
("Vault Cash", "Vault Cash"),
("Petty Cash", "Petty Cash"),
("Bank Balances", "Bank Balances"),
("Bank Accounts", "Bank Accounts"),
("Prepaid Card Balances", "Prepaid Card Balances"),
("Prepaid Card", "Prepaid Card"),
("Deposits", "Deposits"),
("Loan Portfolio", "Loan Portfolio"),
("Loans and Advances", "Loans and Advances"),
("Loans And Advances (Claim)", "Loans And Advances (Claim)"),
("Loan Portfolio - Unsecured Loans to Clients", "Loan Portfolio - Unsecured Loans to Clients"),
("Loan Portfolio - Secured Loans to Clients", "Loan Portfolio - Secured Loans to Clients"),
("Loan Loss Provisions", "Loan Loss Provisions"),
("Provisions - Unsecured Loans to Clients", "Provisions - Unsecured Loans to Clients"),
("Provisions - Secured Loans to Clients", "Provisions - Secured Loans to Clients"),
("Interest Receivable", "Interest Receivable"),
("Interest Receivable - Unsecured Loans to Clients", "Interest Receivable - Unsecured Loans to Clients"),
("Interest Accrued And Due", "Interest Accrued And Due"),
("Interest Accrued Overdue", "Interest Accrued Overdue"),
("Penalty Interest", "Penalty Interest"),
("Interest on Overdue Principal", "Interest on Overdue Principal"),
("Interest on Overdue Interest", "Interest on Overdue Interest"),
("Interest Receivable - Secured Loans to Clients", "Interest Receivable - Secured Loans to Clients"),
("Interest Accrued", "Interest Accrued"),
("Interest Accrued - Unsecured Loans to Clients", "Interest Accrued - Unsecured Loans to Clients"),
("Interest Accrued Not Due", "Interest Accrued Not Due"),
("Interest Accrued - Secured Loans to Clients", "Interest Accrued - Secured Loans to Clients"),
("Sundry Debtors", "Sundry Debtors"),
("Fees, Charges and Commissions Receivable (FCCR)", "Fees, Charges and Commissions Receivable (FCCR)"),
("FCCR from Clients", "FCCR from Clients"),
("FCCR from Other Activities", "FCCR from Other Activities"),
("Other Deposits", "Other Deposits"),
("Equity", "Equity"),
("Reserves and Surplus", "Reserves and Surplus"),
("Secured Borrowings", "Secured Borrowings"),
("Interest Payable on Secured Borrowings", "Interest Payable on Secured Borrowings"),
("Unsecured Borrowings", "Unsecured Borrowings"),
("Interest Payable on Unsecured Borrowings", "Interest Payable on Unsecured Borrowings"),
("Customers' Deposits", "Customers' Deposits"),
("Savings Deposits from Clients", "Savings Deposits from Clients"),
("Mandatory Savings Accounts", "Mandatory Savings Accounts"),
("Voluntary Savings Accounts", "Voluntary Savings Accounts"),
("Term Deposits", "Term Deposits"),
("Interest Payable", "Interest Payable"),
("Interest Payable - Mandatory Savings Accounts", "Interest Payable - Mandatory Savings Accounts"),
("Interest Payable - Voluntary Savings Accounts", "Interest Payable - Voluntary Savings Accounts"),
("Interest Payable - Term Deposits", "Interest Payable - Term Deposits"),
("Interest Accrued And Due (L)", "Interest Accrued And Due (L)"),
("Interest Accrued Overdue (L)", "Interest Accrued Overdue (L)"),
("Interest Accrued - Mandatory Savings Accounts", "Interest Accrued - Mandatory Savings Accounts"),
("Interest Accrued - Voluntary Savings Accounts", "Interest Accrued - Voluntary Savings Accounts"),
("Interest Accrued - Term Deposits", "Interest Accrued - Term Deposits"),
("Interest Accrued Not Due (L)", "Interest Accrued Not Due (L)"),
("Interest Compounded Not Due", "Interest Compounded Not Due"),
("Sundry Creditors", "Sundry Creditors"),
("Payable to Banks", "Payable to Banks"),
("Statutory Dues", "Statutory Dues"),
("Tax Payable", "Tax Payable"),
("Service Tax Payable", "Service Tax Payable"),
("STP to Third Parties", "STP to Third Parties"),
("GST Payable (GSTP)", "GST Payable (GSTP)"),
("GSTP to Third Parties", "GSTP to Third Parties"),
("TDS Payable (TDSP)", "TDS Payable (TDSP)"),
("TDSP to Third Parties", "TDSP to Third Parties"),
("TDSP to Third Parties - Mandatory Savings Accounts", "TDSP to Third Parties - Mandatory Savings Accounts"),
("TDSP to Third Parties - Voluntary Savings Accounts", "TDSP to Third Parties - Voluntary Savings Accounts"),
("TDSP to Third Parties - Term Deposits", "TDSP to Third Parties - Term Deposits"),
("Sundry Creditors for Expense", "Sundry Creditors for Expense"),
("Commission Payable (CP)", "Commission Payable (CP)"),
("CP on Unsecured Loans to Clients", "CP on Unsecured Loans to Clients"),
("CP on Secured Loans to Clients", "CP on Secured Loans to Clients"),
("Insurance Premium Payable (IPP)", "Insurance Premium Payable (IPP)"),
("IPP to Third Parties", "IPP to Third Parties"),
("Sundry Creditors Others", "Sundry Creditors Others"),
("Provisions", "Provisions"),
("Current Liabilities", "Current Liabilities"),
("Operating Income", "Operating Income"),
("Interest Income - Unsecured Loans to Clients", "Interest Income - Unsecured Loans to Clients"),
("Interest Income (Unrealized)", "Interest Income (Unrealized)"),
("Interest Income (Realized)", "Interest Income (Realized)"),
("Interest Income (Unrecognized) - Unsecured Loans to Clients", "Interest Income (Unrecognized) - Unsecured Loans to Clients"),
("Interest Income (Unrecognized) - Secured Loans to Clients", "Interest Income (Unrecognized) - Secured Loans to Clients"),
("Interest Income (Unrecognized)", "Interest Income (Unrecognized)"),
("Penalty Interest Income", "Penalty Interest Income"),
("Interest Income - Secured Loans to Clients", "Interest Income - Secured Loans to Clients"),
("Fees, Charges and Commissions from Clients", "Fees, Charges and Commissions from Clients"),
("Fees, Charges and Commissions from Other Activities", "Fees, Charges and Commissions from Other Activities"),
("Other Operating Income", "Other Operating Income"),
("Income from Round-off Account", "Income from Round-off Account"),
("Interest Receivable - Mandatory Savings Accounts", "Interest Receivable - Mandatory Savings Accounts"),
("Interest Receivable - Voluntary Savings Accounts", "Interest Receivable - Voluntary Savings Accounts"),
("Interest Receivable - Term Deposits", "Interest Receivable - Term Deposits"),
("Penalty Interest (L)", "Penalty Interest (L)"),
("Interest Income - Mandatory Savings Accounts", "Interest Income - Mandatory Savings Accounts"),
("Interest Income - Voluntary Savings Accounts", "Interest Income - Voluntary Savings Accounts"),
("Interest Income - Term Deposits", "Interest Income - Term Deposits"),
("Penalty Interest Income (L)", "Penalty Interest Income (L)"),
("Non-operating Income", "Non-operating Income"),
("Operating Expense", "Operating Expense"),
("Interest Income Expense (IE)", "Interest Income Expense (IE)"),
("IE on Borrowings", "IE on Borrowings"),
("IE on Unsecured Borrowings", "IE on Unsecured Borrowings"),
("IE on Secured Borrowings", "IE on Secured Borrowings"),
("IE on Clients' Savings Deposits", "IE on Clients' Savings Deposits"),
("IE on Mandatory Savings Accounts", "IE on Mandatory Savings Accounts"),
("IE on Voluntary Savings Accounts", "IE on Voluntary Savings Accounts"),
("IE on Term Deposits", "IE on Term Deposits"),
("Commission Expense (CE)", "Commission Expense (CE)"),
("CE on Unsecured Loans to Clients", "CE on Unsecured Loans to Clients"),
("CE on Secured Loans to Clients", "CE on Secured Loans to Clients"),
("Write-offs", "Write-offs"),
("Write-offs - Loans to Clients", "Write-offs - Loans to Clients"),
("Write-offs - Receivable from Clients", "Write-offs - Receivable from Clients"),
("Write-offs - Unsecured Loans to Clients", "Write-offs - Unsecured Loans to Clients"),
("Write-offs - Secured Loans to Clients", "Write-offs - Secured Loans to Clients"),
("Write-offs - FCCR from Clients", "Write-offs - FCCR from Clients"),
("Write-offs - IPR from Clients", "Write-offs - IPR from Clients"),
("Write-offs - STR from Clients", "Write-offs - STR from Clients"),
("Write-offs - GSTR from Clients", "Write-offs - GSTR from Clients"),
("Other Write-offs", "Other Write-offs"),
("Depreciation and Amortization", "Depreciation and Amortization"),
("Non-operating Expense", "Non-operating Expense"),
("Taxes", "Taxes"),
("Insurance Premium Receivable (IPR)", "Insurance Premium Receivable (IPR)"),
("IPR from Clients", "IPR from Clients"),
("Tax Receivable", "Tax Receivable"),
("Service Tax Receivable (STR)", "Service Tax Receivable (STR)"),
("STR from Clients", "STR from Clients"),
("GST Receivable (GSTR)", "GST Receivable (GSTR)"),
("GSTR from Clients", "GSTR from Clients"),
("TDS Receivable (TDSR)", "TDS Receivable (TDSR)"),
("TDSR from Clients", "TDSR from Clients"),
("TDSR from Clients - Mandatory Savings Accounts", "TDSR from Clients - Mandatory Savings Accounts"),
("TDSR from Clients - Voluntary Savings Accounts", "TDSR from Clients - Voluntary Savings Accounts"),
("TDSR from Clients - Term Deposits", "TDSR from Clients - Term Deposits"),
("Sundry Debtors Others", "Sundry Debtors Others"),
("Funds Transfer", "Funds Transfer"),
("Cash In Transit", "Cash In Transit"),
("Tax Paid", "Tax Paid"),
("Advance from Clients", "Advance from Clients"),
("Write-off-recovery", "Write-off-recovery"),
("Write-off-recovery - Loans to Clients", "Write-off-recovery - Loans to Clients"),
("Write-off-recovery - Unsecured Loans to Clients", "Write-off-recovery - Unsecured Loans to Clients"),
("Write-off-recovery - Secured Loans to Clients", "Write-off-recovery - Secured Loans to Clients"),
("Current Assets", "Current Assets"),
("Non-current Assets", "Non-current Assets"),
("Non-current Liabilities", "Non-current Liabilities"),
("Shareholders' Funds", "Shareholders' Funds"),
("Capital", "Capital"),
("Moratorium Interest Income (Unrealized)", "Moratorium Interest Income (Unrealized)"),
("Moratorium Interest Income (Realized)", "Moratorium Interest Income (Realized)"),
("Moratorium Interest Accrued Not Due", "Moratorium Interest Accrued Not Due"),
("Moratorium Interest Accrued And Due", "Moratorium Interest Accrued And Due"),
("Equated Moratorium Interest Accrued And Due", "Equated Moratorium Interest Accrued And Due "),
("Collection Third Parties", "Collection Third Parties"),
("Interest Demand Round Off", "Interest Demand Round Off");

-- Setting variables for all GLHeadMaster entries to be used as FK in other tables
SELECT @AssetsHeadId := id FROM GLHeadMaster WHERE name = "Assets";
SELECT @LiabilitiesHeadId := id FROM GLHeadMaster WHERE name = "Liabilities";
SELECT @IncomeHeadId := id FROM GLHeadMaster WHERE name = "Income";
SELECT @ExpensesHeadId := id FROM GLHeadMaster WHERE name = "Expenses";
SELECT @FixedAssetsHeadId := id FROM GLHeadMaster WHERE name = "Fixed Assets";
SELECT @InvestmentsHeadId := id FROM GLHeadMaster WHERE name = "Investments";
SELECT @CashBalancesHeadId := id FROM GLHeadMaster WHERE name = "Cash Balances";
SELECT @VaultCashHeadId := id FROM GLHeadMaster WHERE name = "Vault Cash";
SELECT @PettyCashHeadId := id FROM GLHeadMaster WHERE name = "Petty Cash";
SELECT @BankBalancesHeadId := id FROM GLHeadMaster WHERE name = "Bank Balances";
SELECT @BankAccountsHeadId := id FROM GLHeadMaster WHERE name = "Bank Accounts";
SELECT @PrepaidCardBalancesHeadId := id FROM GLHeadMaster WHERE name = "Prepaid Card Balances";
SELECT @PrepaidCardHeadId := id FROM GLHeadMaster WHERE name = "Prepaid Card";
SELECT @DepositsHeadId := id FROM GLHeadMaster WHERE name = "Deposits";
SELECT @LoanPortfolioHeadId := id FROM GLHeadMaster WHERE name = "Loan Portfolio";
SELECT @LoansandAdvancesHeadId := id FROM GLHeadMaster WHERE name = "Loans and Advances";
SELECT @claimLoansandAdvancesHeadId := id FROM GLHeadMaster WHERE name = "Loans And Advances (Claim)";
SELECT @LoanPortfolioUnsecuredLoanstoClientsHeadId := id FROM GLHeadMaster WHERE name = "Loan Portfolio - Unsecured Loans to Clients";
SELECT @LoanPortfolioSecuredLoanstoClientsHeadId := id FROM GLHeadMaster WHERE name = "Loan Portfolio - Secured Loans to Clients";
SELECT @LoanLossProvisionsHeadId := id FROM GLHeadMaster WHERE name = "Loan Loss Provisions";
SELECT @ProvisionsUnsecuredLoanstoClientsHeadId := id FROM GLHeadMaster WHERE name = "Provisions - Unsecured Loans to Clients";
SELECT @ProvisionsSecuredLoanstoClientsHeadId := id FROM GLHeadMaster WHERE name = "Provisions - Secured Loans to Clients";
SELECT @InterestReceivableHeadId := id FROM GLHeadMaster WHERE name = "Interest Receivable";
SELECT @InterestReceivableUnsecuredLoanstoClientsHeadId := id FROM GLHeadMaster WHERE name = "Interest Receivable - Unsecured Loans to Clients";
SELECT @InterestAccruedAndDueHeadId := id FROM GLHeadMaster WHERE name = "Interest Accrued And Due";
SELECT @InterestAccruedOverdueHeadId := id FROM GLHeadMaster WHERE name = "Interest Accrued Overdue";
SELECT @PenaltyInterestHeadId := id FROM GLHeadMaster WHERE name = "Penalty Interest";
SELECT @InterestOnOverduePrincipalHeadId := id FROM GLHeadMaster WHERE name = "Interest on Overdue Principal";
SELECT @InterestOnOverdueInterestHeadId := id FROM GLHeadMaster WHERE name = "Interest on Overdue Interest";
SELECT @InterestReceivableSecuredLoanstoClientsHeadId := id FROM GLHeadMaster WHERE name = "Interest Receivable - Secured Loans to Clients";
SELECT @InterestAccruedHeadId := id FROM GLHeadMaster WHERE name = "Interest Accrued";
SELECT @InterestAccruedUnsecuredLoanstoClientsHeadId := id FROM GLHeadMaster WHERE name = "Interest Accrued - Unsecured Loans to Clients";
SELECT @InterestAccruedNotDueHeadId := id FROM GLHeadMaster WHERE name = "Interest Accrued Not Due";
SELECT @InterestAccruedSecuredLoanstoClientsHeadId := id FROM GLHeadMaster WHERE name = "Interest Accrued - Secured Loans to Clients";
SELECT @SundryDebtorsHeadId := id FROM GLHeadMaster WHERE name = "Sundry Debtors";
SELECT @FeesChargesandCommissionsReceivableFCCRHeadId := id FROM GLHeadMaster WHERE name = "Fees, Charges and Commissions Receivable (FCCR)";
SELECT @FCCRfromClientsHeadId := id FROM GLHeadMaster WHERE name = "FCCR from Clients";
SELECT @FCCRfromOtherActivitiesHeadId := id FROM GLHeadMaster WHERE name = "FCCR from Other Activities";
SELECT @OtherDepositsHeadId := id FROM GLHeadMaster WHERE name = "Other Deposits";
SELECT @EquityHeadId := id FROM GLHeadMaster WHERE name = "Equity";
SELECT @ReservesandSurplusHeadId := id FROM GLHeadMaster WHERE name = "Reserves and Surplus";
SELECT @SecuredBorrowingsHeadId := id FROM GLHeadMaster WHERE name = "Secured Borrowings";
SELECT @InterestPayableonSecuredBorrowingsHeadId := id FROM GLHeadMaster WHERE name = "Interest Payable on Secured Borrowings";
SELECT @UnsecuredBorrowingsHeadId := id FROM GLHeadMaster WHERE name = "Unsecured Borrowings";
SELECT @InterestPayableonUnsecuredBorrowingsHeadId := id FROM GLHeadMaster WHERE name = "Interest Payable on Unsecured Borrowings";
SELECT @CustomersDepositsHeadId := id FROM GLHeadMaster WHERE name = "Customers' Deposits";
SELECT @SavingsDepositsfromClientsHeadId := id FROM GLHeadMaster WHERE name = "Savings Deposits from Clients";
SELECT @MandatorySavingsAccountsHeadId := id FROM GLHeadMaster WHERE name = "Mandatory Savings Accounts";
SELECT @VoluntarySavingsAccountsHeadId := id FROM GLHeadMaster WHERE name = "Voluntary Savings Accounts";
SELECT @TermDepositsHeadId := id FROM GLHeadMaster WHERE name = "Term Deposits";
SELECT @InterestPayableHeadId := id FROM GLHeadMaster WHERE name = "Interest Payable";
SELECT @InterestPayableMandatorySavingsAccountsHeadId := id FROM GLHeadMaster WHERE name = "Interest Payable - Mandatory Savings Accounts";
SELECT @InterestPayableVoluntarySavingsAccountsHeadId := id FROM GLHeadMaster WHERE name = "Interest Payable - Voluntary Savings Accounts";
SELECT @InterestPayableTermDepositsHeadId := id FROM GLHeadMaster WHERE name = "Interest Payable - Term Deposits";
SELECT @InterestAccruedAndDueLHeadId := id FROM GLHeadMaster WHERE name = "Interest Accrued And Due (L)";
SELECT @InterestAccruedOverdueLHeadId := id FROM GLHeadMaster WHERE name = "Interest Accrued Overdue (L)";
SELECT @InterestAccruedMandatorySavingsAccountsHeadId := id FROM GLHeadMaster WHERE name = "Interest Accrued - Mandatory Savings Accounts";
SELECT @InterestAccruedVoluntarySavingsAccountsHeadId := id FROM GLHeadMaster WHERE name = "Interest Accrued - Voluntary Savings Accounts";
SELECT @InterestAccruedTermDepositsHeadId := id FROM GLHeadMaster WHERE name = "Interest Accrued - Term Deposits";
SELECT @InterestAccruedNotDueLHeadId := id FROM GLHeadMaster WHERE name = "Interest Accrued Not Due (L)";
SELECT @InterestCompoundedNotDueHeadId := id FROM GLHeadMaster WHERE name = "Interest Compounded Not Due";
SELECT @SundryCreditorsHeadId := id FROM GLHeadMaster WHERE name = "Sundry Creditors";
SELECT @PayabletoBanksHeadId := id FROM GLHeadMaster WHERE name = "Payable to Banks";
SELECT @StatutoryDuesHeadId := id FROM GLHeadMaster WHERE name = "Statutory Dues";
SELECT @TaxPayableHeadId := id FROM GLHeadMaster WHERE name = "Tax Payable";
SELECT @ServiceTaxPayableHeadId := id FROM GLHeadMaster WHERE name = "Service Tax Payable";
SELECT @STPtoThirdPartiesHeadId := id FROM GLHeadMaster WHERE name = "STP to Third Parties";
SELECT @GSTPayableGSTPHeadId := id FROM GLHeadMaster WHERE name = "GST Payable (GSTP)";
SELECT @GSTPtoThirdPartiesHeadId := id FROM GLHeadMaster WHERE name = "GSTP to Third Parties";
SELECT @TDSPayableTDSPHeadId := id FROM GLHeadMaster WHERE name = "TDS Payable (TDSP)";
SELECT @TDSPtoThirdPartiesHeadId := id FROM GLHeadMaster WHERE name = "TDSP to Third Parties";
SELECT @TDSPtoThirdPartiesMandatorySavingsAccountsHeadId := id FROM GLHeadMaster WHERE name = "TDSP to Third Parties - Mandatory Savings Accounts";
SELECT @TDSPtoThirdPartiesVoluntarySavingsAccountsHeadId := id FROM GLHeadMaster WHERE name = "TDSP to Third Parties - Voluntary Savings Accounts";
SELECT @TDSPtoThirdPartiesTermDepositsHeadId := id FROM GLHeadMaster WHERE name = "TDSP to Third Parties - Term Deposits";
SELECT @SundryCreditorsforExpenseHeadId := id FROM GLHeadMaster WHERE name = "Sundry Creditors for Expense";
SELECT @CommissionPayableCPHeadId := id FROM GLHeadMaster WHERE name = "Commission Payable (CP)";
SELECT @CPonUnsecuredLoanstoClientsHeadId := id FROM GLHeadMaster WHERE name = "CP on Unsecured Loans to Clients";
SELECT @CPonSecuredLoanstoClientsHeadId := id FROM GLHeadMaster WHERE name = "CP on Secured Loans to Clients";
SELECT @InsurancePremiumPayableIPPHeadId := id FROM GLHeadMaster WHERE name = "Insurance Premium Payable (IPP)";
SELECT @IPPtoThirdPartiesHeadId := id FROM GLHeadMaster WHERE name = "IPP to Third Parties";
SELECT @SundryCreditorsOthersHeadId := id FROM GLHeadMaster WHERE name = "Sundry Creditors Others";
SELECT @ProvisionsHeadId := id FROM GLHeadMaster WHERE name = "Provisions";
SELECT @CurrentLiabilitiesHeadId := id FROM GLHeadMaster WHERE name = "Current Liabilities";
SELECT @OperatingIncomeHeadId := id FROM GLHeadMaster WHERE name = "Operating Income";
SELECT @InterestIncomeUnsecuredLoanstoClientsHeadId := id FROM GLHeadMaster WHERE name = "Interest Income - Unsecured Loans to Clients";
SELECT @InterestIncomeUnrealizedHeadId := id FROM GLHeadMaster WHERE name = "Interest Income (Unrealized)";
SELECT @InterestIncomeHeadId := id FROM GLHeadMaster WHERE name = "Interest Income (Unrealized)";
SELECT @InterestIncomeRealizedHeadId := id FROM GLHeadMaster WHERE name = "Interest Income (Realized)";
SELECT @PenaltyInterestIncomeHeadId := id FROM GLHeadMaster WHERE name = "Penalty Interest Income";
SELECT @InterestIncomeSecuredLoanstoClientsHeadId := id FROM GLHeadMaster WHERE name = "Interest Income - Secured Loans to Clients";
SELECT @FeesChargesandCommissionsfromClientsHeadId := id FROM GLHeadMaster WHERE name = "Fees, Charges and Commissions from Clients";
SELECT @FeesChargesandCommissionsfromOtherActivitiesHeadId := id FROM GLHeadMaster WHERE name = "Fees, Charges and Commissions from Other Activities";
SELECT @OtherOperatingIncomeHeadId := id FROM GLHeadMaster WHERE name = "Other Operating Income";
SELECT @IncomefromRoundoffAccountHeadId := id FROM GLHeadMaster WHERE name = "Income from Round-off Account";
SELECT @InterestReceivableMandatorySavingsAccountsHeadId := id FROM GLHeadMaster WHERE name = "Interest Receivable - Mandatory Savings Accounts";
SELECT @InterestReceivableVoluntarySavingsAccountsHeadId := id FROM GLHeadMaster WHERE name = "Interest Receivable - Voluntary Savings Accounts";
SELECT @InterestReceivableTermDepositsHeadId := id FROM GLHeadMaster WHERE name = "Interest Receivable - Term Deposits";
SELECT @PenaltyInterestLHeadId := id FROM GLHeadMaster WHERE name = "Penalty Interest (L)";
SELECT @InterestIncomeMandatorySavingsAccountsHeadId := id FROM GLHeadMaster WHERE name = "Interest Income - Mandatory Savings Accounts";
SELECT @InterestIncomeVoluntarySavingsAccountsHeadId := id FROM GLHeadMaster WHERE name = "Interest Income - Voluntary Savings Accounts";
SELECT @InterestIncomeTermDepositsHeadId := id FROM GLHeadMaster WHERE name = "Interest Income - Term Deposits";
SELECT @PenaltyInterestIncomeLHeadId := id FROM GLHeadMaster WHERE name = "Penalty Interest Income (L)";
SELECT @NonoperatingIncomeHeadId := id FROM GLHeadMaster WHERE name = "Non-operating Income";
SELECT @OperatingExpenseHeadId := id FROM GLHeadMaster WHERE name = "Operating Expense";
SELECT @InterestIncomeExpenseIEHeadId := id FROM GLHeadMaster WHERE name = "Interest Income Expense (IE)";
SELECT @IEonBorrowingsHeadId := id FROM GLHeadMaster WHERE name = "IE on Borrowings";
SELECT @IEonUnsecuredBorrowingsHeadId := id FROM GLHeadMaster WHERE name = "IE on Unsecured Borrowings";
SELECT @IEonSecuredBorrowingsHeadId := id FROM GLHeadMaster WHERE name = "IE on Secured Borrowings";
SELECT @IEonClientsSavingsDepositsHeadId := id FROM GLHeadMaster WHERE name = "IE on Clients' Savings Deposits";
SELECT @IEonMandatorySavingsAccountsHeadId := id FROM GLHeadMaster WHERE name = "IE on Mandatory Savings Accounts";
SELECT @IEonVoluntarySavingsAccountsHeadId := id FROM GLHeadMaster WHERE name = "IE on Voluntary Savings Accounts";
SELECT @IEonTermDepositsHeadId := id FROM GLHeadMaster WHERE name = "IE on Term Deposits";
SELECT @CommissionExpenseCEHeadId := id FROM GLHeadMaster WHERE name = "Commission Expense (CE)";
SELECT @CEonUnsecuredLoanstoClientsHeadId := id FROM GLHeadMaster WHERE name = "CE on Unsecured Loans to Clients";
SELECT @CEonSecuredLoanstoClientsHeadId := id FROM GLHeadMaster WHERE name = "CE on Secured Loans to Clients";
SELECT @WriteoffsHeadId := id FROM GLHeadMaster WHERE name = "Write-offs";
SELECT @WriteoffsLoansToClientsHeadId := id FROM GLHeadMaster WHERE name = "Write-offs - Loans to Clients";
SELECT @WriteoffsReceivableFromClientsHeadId := id FROM GLHeadMaster WHERE name = "Write-offs - Receivable from Clients";
SELECT @WriteoffsUnsecuredLoanstoClientsHeadId := id FROM GLHeadMaster WHERE name = "Write-offs - Unsecured Loans to Clients";
SELECT @WriteoffsSecuredLoanstoClientsHeadId := id FROM GLHeadMaster WHERE name = "Write-offs - Secured Loans to Clients";
SELECT @WriteoffsFCCRFromClientsHeadId := id FROM GLHeadMaster WHERE name = "Write-offs - FCCR from Clients";
SELECT @WriteoffsIPRFromClientsHeadId := id FROM GLHeadMaster WHERE name = "Write-offs - IPR from Clients";
SELECT @WriteoffsSTRFromClientsHeadId := id FROM GLHeadMaster WHERE name = "Write-offs - STR from Clients";
SELECT @WriteoffsGSTRFromClientsHeadId := id FROM GLHeadMaster WHERE name = "Write-offs - GSTR from Clients";
SELECT @OtherWriteoffsHeadId := id FROM GLHeadMaster WHERE name = "Other Write-offs";
SELECT @DepreciationandAmortizationHeadId := id FROM GLHeadMaster WHERE name = "Depreciation and Amortization";
SELECT @NonoperatingExpenseHeadId := id FROM GLHeadMaster WHERE name = "Non-operating Expense";
SELECT @TaxesHeadId := id FROM GLHeadMaster WHERE name = "Taxes";
SELECT @InsurancePremiumReceivableIPRHeadId := id FROM GLHeadMaster WHERE name = "Insurance Premium Receivable (IPR)";
SELECT @IPRfromClientsHeadId := id FROM GLHeadMaster WHERE name = "IPR from Clients";
SELECT @TaxReceivableHeadId := id FROM GLHeadMaster WHERE name = "Tax Receivable";
SELECT @ServiceTaxReceivableSTRHeadId := id FROM GLHeadMaster WHERE name = "Service Tax Receivable (STR)";
SELECT @STRfromClientsHeadId := id FROM GLHeadMaster WHERE name = "STR from Clients";
SELECT @GSTReceivableGSTRHeadId := id FROM GLHeadMaster WHERE name = "GST Receivable (GSTR)";
SELECT @GSTRfromClientsHeadId := id FROM GLHeadMaster WHERE name = "GSTR from Clients";
SELECT @TDSReceivableTDSRHeadId := id FROM GLHeadMaster WHERE name = "TDS Receivable (TDSR)";
SELECT @TDSRfromClientsHeadId := id FROM GLHeadMaster WHERE name = "TDSR from Clients";
SELECT @TDSRfromClientsMandatorySavingsAccountsHeadId := id FROM GLHeadMaster WHERE name = "TDSR from Clients - Mandatory Savings Accounts";
SELECT @TDSRfromClientsVoluntarySavingsAccountsHeadId := id FROM GLHeadMaster WHERE name = "TDSR from Clients - Voluntary Savings Accounts";
SELECT @TDSRfromClientsTermDepositsHeadId := id FROM GLHeadMaster WHERE name = "TDSR from Clients - Term Deposits";
SELECT @SundryDebtorsOthersHeadId := id FROM GLHeadMaster WHERE name = "Sundry Debtors Others";
SELECT @CashTransferHeadId := id FROM GLHeadMaster WHERE name = "Funds Transfer";
SELECT @CashInTransitHeadId := id FROM GLHeadMaster WHERE name = "Cash In Transit";
SELECT @TaxPaidHeadId := id FROM GLHeadMaster WHERE name = "Tax Paid";
SELECT @AdvancefromClientsHeadId := id FROM GLHeadMaster WHERE name = "Advance from Clients";
SELECT @WriteOffRecoveryHeadId := id FROM GLHeadMaster WHERE name = "Write-off-recovery";
SELECT @WriteOffRecoveryLoansToClientsHeadId := id FROM GLHeadMaster WHERE name = "Write-off-recovery - Loans to Clients";
SELECT @WriteOffRecoverySecuredLoansToClientsHeadId := id FROM GLHeadMaster WHERE name = "Write-off-recovery - Secured Loans to Clients";
SELECT @WriteOffRecoveryUnSecuredLoansToClientsHeadId := id FROM GLHeadMaster WHERE name = "Write-off-recovery - Unsecured Loans to Clients";
SELECT @currentAssetsHeadId := id FROM GLHeadMaster WHERE name = "Current Assets";
SELECT @nonCurrentAssetsHeadId := id FROM GLHeadMaster WHERE name = "Non-current Assets";
SELECT @nonCurrentliabilitiesHeadId := id FROM GLHeadMaster WHERE name = "Non-current Liabilities";
SELECT @shareholdersFundsHeadId := id FROM GLHeadMaster WHERE name = "Shareholders' Funds";
SELECT @capital := id FROM GLHeadMaster WHERE name = "Capital";

SELECT @moraIntIncomeUnRealizedHeadId := id FROM GLHeadMaster WHERE name = "Moratorium Interest Income (Unrealized)";
SELECT @moraIntIncomeRealizedHeadId := id FROM GLHeadMaster WHERE name = "Moratorium Interest Income (Realized)";
SELECT @moraIntAccruedNotDueHeadId := id FROM GLHeadMaster WHERE name = "Moratorium Interest Accrued Not Due";
SELECT @moraIntAccruedAndDueHeadId := id FROM GLHeadMaster WHERE name = "Moratorium Interest Accrued And Due";
SELECT @equatedMoraIntAccruedAndDueHeadId := id FROM GLHeadMaster WHERE name = "Equated Moratorium Interest Accrued And Due";
SELECT @InterestIncomeHeadId := id FROM GLHeadMaster WHERE name = "Interest Income (Unrealized)";
SELECT @moraIntWaiverDemandTypeId := id FROM TransactionTypeMaster WHERE name = "Moratorium Interest Waiver Demand";
SELECT @InterestIncomeUnrecognizedUnsecuredHeadId := id FROM GLHeadMaster WHERE name = "Interest Income (Unrecognized) - Unsecured Loans to Clients";
SELECT @InterestIncomeUnrecognizedSecuredHeadId := id FROM GLHeadMaster WHERE name = "Interest Income (Unrecognized) - Secured Loans to Clients";
SELECT @InterestIncomeUnrecognizedHeadId := id FROM GLHeadMaster WHERE name = "Interest Income (Unrecognized)";
SELECT @InterestDemandRoundOffHeadId := id FROM GLHeadMaster WHERE name = "Interest Demand Round Off";
--
-- Master table values for GLTypeMaster
--
DELETE FROM GLTypeMaster;
INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1000000", "1000000", NULL, @AssetsHeadId, 1, 0, 1),
("2000000", "2000000", NULL, @LiabilitiesHeadId, 1, 0, 1),
("3000000", "3000000", NULL, @IncomeHeadId, 1, 0, 1),
("4000000", "4000000", NULL, @ExpensesHeadId, 1, 0, 1);

SELECT @1000000_codeId := id FROM GLTypeMaster WHERE gl_code = "1000000";
SELECT @2000000_codeId := id FROM GLTypeMaster WHERE gl_code = "2000000";
SELECT @3000000_codeId := id FROM GLTypeMaster WHERE gl_code = "3000000";
SELECT @4000000_codeId := id FROM GLTypeMaster WHERE gl_code = "4000000";

-- Insert Asset GL types
INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1100002", "1100002", @1000000_codeId, @currentAssetsHeadId, 1, 0, 1),
("1100003", "1100003", @1000000_codeId, @nonCurrentAssetsHeadId, 1, 0, 1);

SELECT @1100003_codeId := id FROM GLTypeMaster WHERE gl_code = "1100003";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1010000", "1010000", @1100003_codeId, @FixedAssetsHeadId, 1, 0, 1),
("1020000", "1020000", @1100003_codeId, @InvestmentsHeadId, 1, 0, 1),
("1030000", "1030000", @1000000_codeId, @CashBalancesHeadId, 1, 0, 1);

SELECT @1010000_codeId := id FROM GLTypeMaster WHERE gl_code = "1010000";
SELECT @1020000_codeId := id FROM GLTypeMaster WHERE gl_code = "1020000";
SELECT @1030000_codeId := id FROM GLTypeMaster WHERE gl_code = "1030000";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1030001", "1030001", @1030000_codeId, @VaultCashHeadId, 1, 0, 0),
("1030002", "1030002", @1030000_codeId, @PettyCashHeadId, 1, 0, 0),
("1040000", "1040000", @1000000_codeId, @BankBalancesHeadId, 1, 0, 1);

SELECT @1040000_codeId := id FROM GLTypeMaster WHERE gl_code = "1040000";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1040001", "1040001", @1040000_codeId, @BankAccountsHeadId, 1, 0, 1),
("1040002", "1040002", @1040000_codeId, @DepositsHeadId, 1, 0, 1),
("1050000", "1050000", @1000000_codeId, @LoanPortfolioHeadId, 1, 0, 1);

SELECT @1050000_codeId := id FROM GLTypeMaster WHERE gl_code = "1050000";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1050001", "1050001", @1050000_codeId, @LoansandAdvancesHeadId, 1, 0, 1);

SELECT @1050001_codeId := id FROM GLTypeMaster WHERE gl_code = "1050001";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1050002", "1050002", @1050001_codeId, @LoanPortfolioUnsecuredLoanstoClientsHeadId, 1, 0, 1),
("1050003", "1050003", @1050001_codeId, @LoanPortfolioSecuredLoanstoClientsHeadId, 1, 0, 1),
("1050004", "1050004", @1050000_codeId, @LoanLossProvisionsHeadId, 1, 0, 1);

SELECT @1050004_codeId := id FROM GLTypeMaster WHERE gl_code = "1050004";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1050005", "1050005", @1050004_codeId, @ProvisionsUnsecuredLoanstoClientsHeadId, 1, 0, 1),
("1050006", "1050006", @1050004_codeId, @ProvisionsSecuredLoanstoClientsHeadId, 1, 0, 1),
("1060000", "1060000", @1000000_codeId, @InterestReceivableHeadId, 1, 0, 1);

SELECT @1060000_codeId := id FROM GLTypeMaster WHERE gl_code = "1060000";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1060001", "1060001", @1060000_codeId, @InterestReceivableUnsecuredLoanstoClientsHeadId, 1, 0, 1);

SELECT @1060001_codeId := id FROM GLTypeMaster WHERE gl_code = "1060001";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1060002", "1060002", @1060001_codeId, @InterestAccruedAndDueHeadId, 1, 0, 1),
("1060003", "1060003", @1060001_codeId, @InterestAccruedOverdueHeadId, 1, 0, 1),
("1060004", "1060004", @1060001_codeId, @PenaltyInterestHeadId, 1, 0, 1),
("1060005", "1060005", @1060001_codeId, @InterestOnOverduePrincipalHeadId, 1, 0, 1),
("1060006", "1060006", @1060001_codeId, @InterestOnOverdueInterestHeadId, 1, 0, 1),
("1060007", "1060007", @1060000_codeId, @InterestReceivableSecuredLoanstoClientsHeadId, 1, 0, 1);

SELECT @1060007_codeId := id FROM GLTypeMaster WHERE gl_code = "1060007";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1060008", "1060008", @1060007_codeId, @InterestAccruedAndDueHeadId, 1, 0, 1),
("1060009", "1060009", @1060007_codeId, @InterestAccruedOverdueHeadId, 1, 0, 1),
("1060010", "1060010", @1060007_codeId, @PenaltyInterestHeadId, 1, 0, 1),
("1060011", "1060011", @1060007_codeId, @InterestOnOverduePrincipalHeadId, 1, 0, 1),
("1060012", "1060012", @1060007_codeId, @InterestOnOverdueInterestHeadId, 1, 0, 1),
("1060013", "1060013", @1060000_codeId, @InterestReceivableVoluntarySavingsAccountsHeadId, 1, 0, 1);

SELECT @1060013_codeId := id FROM GLTypeMaster WHERE gl_code = "1060013";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1060014", "1060014", @1060013_codeId, @PenaltyInterestLHeadId, 1, 0, 1),
("1060015", "1060015", @1060000_codeId, @InterestReceivableMandatorySavingsAccountsHeadId, 1, 0, 1);

SELECT @1060015_codeId := id FROM GLTypeMaster WHERE gl_code = "1060015";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1060016", "1060016", @1060015_codeId, @PenaltyInterestLHeadId, 1, 0, 1),
("1060017", "1060017", @1060000_codeId, @InterestReceivableTermDepositsHeadId, 1, 0, 1);

SELECT @1060017_codeId := id FROM GLTypeMaster WHERE gl_code = "1060017";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1060018", "1060018", @1060017_codeId, @PenaltyInterestLHeadId, 1, 0, 1);


INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1060019", "1060019", @1060001_codeId, @moraIntAccruedAndDueHeadId, 1, 0, 1),
("1060020", "1060020", @1060007_codeId, @moraIntAccruedAndDueHeadId, 1, 0, 1),
("1060021", "1060021", @1060001_codeId, @moraIntAccruedAndDueHeadId, 1, 0, 1),
("1060023", "1060023", @1060001_codeId, @equatedMoraIntAccruedAndDueHeadId, 1, 0, 1),
("1060022", "1060022", @1060007_codeId, @equatedMoraIntAccruedAndDueHeadId, 1, 0, 1);

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1070000", "1070000", @1000000_codeId, @InterestAccruedHeadId, 1, 0, 1);

SELECT @1070000_codeId := id FROM GLTypeMaster WHERE gl_code = "1070000";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1070001", "1070001", @1070000_codeId, @InterestAccruedUnsecuredLoanstoClientsHeadId, 1, 0, 1),
("1070003", "1070003", @1070000_codeId, @InterestAccruedSecuredLoanstoClientsHeadId, 1, 0, 1);

SELECT @1070001_codeId := id FROM GLTypeMaster WHERE gl_code = "1070001";
SELECT @1070003_codeId := id FROM GLTypeMaster WHERE gl_code = "1070003";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1070002", "1070002", @1070001_codeId, @InterestAccruedNotDueHeadId, 1, 0, 1),
("1070004", "1070004", @1070003_codeId, @InterestAccruedNotDueHeadId, 1, 0, 1),
("1070005", "1070005", @1070001_codeId, @moraIntAccruedNotDueHeadId, 1, 0, 1),
("1070006", "1070006", @1070003_codeId, @moraIntAccruedNotDueHeadId, 1, 0, 1),
("1080000", "1080000", @1000000_codeId, @SundryDebtorsHeadId, 1, 0, 1);

SELECT @1080000_codeId := id FROM GLTypeMaster WHERE gl_code = "1080000";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1080001", "1080001", @1080000_codeId, @FeesChargesandCommissionsReceivableFCCRHeadId, 1, 0, 1),
("1080004", "1080004", @1080000_codeId, @InsurancePremiumReceivableIPRHeadId, 1, 0, 1),
("1080006", "1080006", @1080000_codeId, @TaxReceivableHeadId, 1, 0, 1),
("1080016", "1080016", @1080000_codeId, @SundryDebtorsOthersHeadId, 1, 0, 1),
("1080018", "1080018", @1080000_codeId, @TaxPaidHeadId, 1, 0, 1);

SELECT @1080001_codeId := id FROM GLTypeMaster WHERE gl_code = "1080001";
SELECT @1080004_codeId := id FROM GLTypeMaster WHERE gl_code = "1080004";
SELECT @1080006_codeId := id FROM GLTypeMaster WHERE gl_code = "1080006";
SELECT @1080016_codeId := id FROM GLTypeMaster WHERE gl_code = "1080016";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1080002", "1080002", @1080001_codeId, @FCCRfromClientsHeadId, 1, 0, 1),
("1080003", "1080003", @1080001_codeId, @FCCRfromOtherActivitiesHeadId, 1, 0, 1),
("1080005", "1080005", @1080004_codeId, @IPRfromClientsHeadId, 1, 0, 1),
("1080007", "1080007", @1080006_codeId, @ServiceTaxReceivableSTRHeadId, 1, 0, 1),
("1080009", "1080009", @1080006_codeId, @GSTReceivableGSTRHeadId, 1, 0, 1),
("1080011", "1080011", @1080006_codeId, @TDSReceivableTDSRHeadId, 1, 0, 1),
("1080017", "1080017", @1080016_codeId, @CashTransferHeadId, 1, 0, 0),
("1090000", "1090000", @1000000_codeId, @OtherDepositsHeadId, 1, 0, 1),
("1100000", "1100000", @1000000_codeId, @PrepaidCardBalancesHeadId, 1, 0, 1),
("1120000", "1120000", @1000000_codeId, @InterestDemandRoundOffHeadId, 1, 0, 1);

SELECT @1080007_codeId := id FROM GLTypeMaster WHERE gl_code = "1080007";
SELECT @1080009_codeId := id FROM GLTypeMaster WHERE gl_code = "1080009";
SELECT @1080011_codeId := id FROM GLTypeMaster WHERE gl_code = "1080011";
SELECT @1100000_codeId := id FROM GLTypeMaster WHERE gl_code = "1100000";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1080008", "1080008", @1080007_codeId, @STRfromClientsHeadId, 1, 0, 1),
("1080010", "1080010", @1080009_codeId, @GSTRfromClientsHeadId, 1, 0, 1),
("1080012", "1080012", @1080011_codeId, @TDSRfromClientsHeadId, 1, 0, 1),
("1100001", "1100001", @1100000_codeId, @PrepaidCardHeadId, 1, 0, 1);

SELECT @1080012_codeId := id FROM GLTypeMaster WHERE gl_code = "1080012";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1080013", "1080013", @1080012_codeId, @TDSRfromClientsMandatorySavingsAccountsHeadId, 1, 0, 1),
("1080014", "1080014", @1080012_codeId, @TDSRfromClientsVoluntarySavingsAccountsHeadId, 1, 0, 1),
("1080015", "1080015", @1080012_codeId, @TDSRfromClientsTermDepositsHeadId, 1, 0, 1);

SELECT @1050001_codeId := id FROM GLTypeMaster WHERE gl_code = "1050001";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1080020", "1080020", @1050000_codeId, @claimLoansandAdvancesHeadId, 1, 0, 1);

SELECT @1080020_codeId := id FROM GLTypeMaster WHERE gl_code = "1080020";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("1080021", "1080016", @1080020_codeId, @LoanPortfolioUnsecuredLoanstoClientsHeadId, 1, 0, 1),
("1080022", "1080017", @1080020_codeId, @LoanPortfolioSecuredLoanstoClientsHeadId, 1, 0, 1);

-- Insert Liability GL types

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2100003", "2100003", @2000000_codeId, @shareholdersFundsHeadId, 1, 0, 1);

SELECT @2100003_codeId := id FROM GLTypeMaster WHERE gl_code = "2100003";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2010000", "2010000", @2100003_codeId, @EquityHeadId, 1, 0, 1),
("2020000", "2020000", @2100003_codeId, @ReservesandSurplusHeadId, 1, 0, 1),
("2030000", "2030000", @2000000_codeId, @SecuredBorrowingsHeadId, 1, 0, 1);

SELECT @2010000_codeId := id FROM GLTypeMaster WHERE gl_code = "2010000";
SELECT @2030000_codeId := id FROM GLTypeMaster WHERE gl_code = "2030000";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2030001", "2030001", @2030000_codeId, @SecuredBorrowingsHeadId, 1, 0, 1),
("2030002", "2030002", @2030000_codeId, @InterestPayableonSecuredBorrowingsHeadId, 1, 0, 1),
("2040000", "2040000", @2000000_codeId, @UnsecuredBorrowingsHeadId, 1, 0, 1);

SELECT @2040000_codeId := id FROM GLTypeMaster WHERE gl_code = "2040000";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2040001", "2040001", @2040000_codeId, @UnsecuredBorrowingsHeadId, 1, 0, 1),
("2040002", "2040002", @2040000_codeId, @InterestPayableonUnsecuredBorrowingsHeadId, 1, 0, 1),
("2050000", "2050000", @2000000_codeId, @CustomersDepositsHeadId, 1, 0, 1);

SELECT @2050000_codeId := id FROM GLTypeMaster WHERE gl_code = "2050000";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2050001", "2050001", @2050000_codeId, @SavingsDepositsfromClientsHeadId, 1, 0, 1);

SELECT @2050001_codeId := id FROM GLTypeMaster WHERE gl_code = "2050001";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2050002", "2050002", @2050001_codeId, @MandatorySavingsAccountsHeadId, 1, 0, 1),
("2050003", "2050003", @2050001_codeId, @VoluntarySavingsAccountsHeadId, 1, 0, 1),
("2050004", "2050004", @2050001_codeId, @TermDepositsHeadId, 1, 0, 1),
("2060000", "2060000", @2000000_codeId, @InterestPayableHeadId, 1, 0, 1);

SELECT @2060000_codeId := id FROM GLTypeMaster WHERE gl_code = "2060000";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2060001", "2060001", @2060000_codeId, @InterestPayableMandatorySavingsAccountsHeadId, 1, 0, 1),
("2060004", "2060004", @2060000_codeId, @InterestPayableVoluntarySavingsAccountsHeadId, 1, 0, 1),
("2060007", "2060007", @2060000_codeId, @InterestPayableTermDepositsHeadId, 1, 0, 1);

SELECT @2060001_codeId := id FROM GLTypeMaster WHERE gl_code = "2060001";
SELECT @2060004_codeId := id FROM GLTypeMaster WHERE gl_code = "2060004";
SELECT @2060007_codeId := id FROM GLTypeMaster WHERE gl_code = "2060007";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2060002", "2060002", @2060001_codeId, @InterestAccruedAndDueLHeadId, 1, 0, 1),
("2060003", "2060003", @2060001_codeId, @InterestAccruedOverdueLHeadId, 1, 0, 1),
("2060005", "2060005", @2060004_codeId, @InterestAccruedAndDueLHeadId, 1, 0, 1),
("2060006", "2060006", @2060004_codeId, @InterestAccruedOverdueLHeadId, 1, 0, 1),
("2060008", "2060008", @2060007_codeId, @InterestAccruedAndDueLHeadId, 1, 0, 1),
("2060009", "2060009", @2060007_codeId, @InterestAccruedOverdueLHeadId, 1, 0, 1),
("2070000", "2070000", @2000000_codeId, @InterestAccruedHeadId, 1, 0, 1);

SELECT @2070000_codeId := id FROM GLTypeMaster WHERE gl_code = "2070000";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2070001", "2070001", @2070000_codeId, @InterestAccruedMandatorySavingsAccountsHeadId, 1, 0, 1);

SELECT @2070001_codeId := id FROM GLTypeMaster WHERE gl_code = "2070001";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2070002", "2070002", @2070001_codeId, @InterestAccruedNotDueLHeadId, 1, 0, 1),
("2070003", "2070003", @2070001_codeId, @InterestCompoundedNotDueHeadId, 1, 0, 1);

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2070004", "2070004", @2070000_codeId, @InterestAccruedVoluntarySavingsAccountsHeadId, 1, 0, 1);

SELECT @2070004_codeId := id FROM GLTypeMaster WHERE gl_code = "2070004";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2070005", "2070005", @2070004_codeId, @InterestAccruedNotDueLHeadId, 1, 0, 1),
("2070006", "2070006", @2070004_codeId, @InterestCompoundedNotDueHeadId, 1, 0, 1);

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2070007", "2070007", @2070000_codeId, @InterestAccruedTermDepositsHeadId, 1, 0, 1);

SELECT @2070007_codeId := id FROM GLTypeMaster WHERE gl_code = "2070007";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2070008", "2070008", @2070007_codeId, @InterestAccruedNotDueLHeadId, 1, 0, 1),
("2070009", "2070009", @2070007_codeId, @InterestCompoundedNotDueHeadId, 1, 0, 1);

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2080000", "2080000", @2000000_codeId, @SundryCreditorsHeadId, 1, 0, 1);

SELECT @2080000_codeId := id FROM GLTypeMaster WHERE gl_code = "2080000";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2080001", "2080001", @2080000_codeId, @PayabletoBanksHeadId, 1, 0, 1),
("2080002", "2080002", @2080000_codeId, @StatutoryDuesHeadId, 1, 0, 1);

SELECT @2080002_codeId := id FROM GLTypeMaster WHERE gl_code = "2080002";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2080013", "2080013", @2080002_codeId, @TaxPayableHeadId, 1, 0, 1);

SELECT @2080013_codeId := id FROM GLTypeMaster WHERE gl_code = "2080013";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2080003", "2080003", @2080013_codeId, @ServiceTaxPayableHeadId, 1, 0, 1),
("2080014", "2080014", @2080013_codeId, @GSTPayableGSTPHeadId, 1, 0, 1),
("2080016", "2080016", @2080013_codeId, @TDSPayableTDSPHeadId, 1, 0, 1),
("2080004", "2080004", @2080000_codeId, @SundryCreditorsforExpenseHeadId, 1, 0, 1);

SELECT @2080004_codeId := id FROM GLTypeMaster WHERE gl_code = "2080004";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2080005", "2080005", @2080004_codeId, @CommissionPayableCPHeadId, 1, 0, 1);

SELECT @2080005_codeId := id FROM GLTypeMaster WHERE gl_code = "2080005";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2080006", "2080006", @2080005_codeId, @CPonUnsecuredLoanstoClientsHeadId, 1, 0, 1),
("2080007", "2080007", @2080005_codeId, @CPonSecuredLoanstoClientsHeadId, 1, 0, 1),
("2080008", "2080008", @2080000_codeId, @InsurancePremiumPayableIPPHeadId, 1, 0, 1);

SELECT @2080008_codeId := id FROM GLTypeMaster WHERE gl_code = "2080008";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2080009", "2080009", @2080008_codeId, @IPPtoThirdPartiesHeadId, 1, 0, 1),
("2080010", "2080010", @2080000_codeId, @SundryCreditorsOthersHeadId, 1, 0, 1);

SELECT @2080010_codeId := id FROM GLTypeMaster WHERE gl_code = "2080010";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2080011", "2080011", @2080010_codeId, @CashInTransitHeadId, 1, 0, 0),
("2090000", "2090000", @2000000_codeId, @ProvisionsHeadId, 1, 0, 1),
("2100000", "2100000", @2000000_codeId, @CurrentLiabilitiesHeadId, 1, 0, 1);

SELECT @2100000_codeId := id FROM GLTypeMaster WHERE gl_code = "2100000";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2100001", "2100001", @2100000_codeId, @AdvancefromClientsHeadId, 1, 0, 0);

SELECT @2080003_codeId := id FROM GLTypeMaster WHERE gl_code = "2080003";
SELECT @2080014_codeId := id FROM GLTypeMaster WHERE gl_code = "2080014";
SELECT @2080016_codeId := id FROM GLTypeMaster WHERE gl_code = "2080016";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2080012", "2080012", @2080003_codeId, @STPtoThirdPartiesHeadId, 1, 0, 1),
("2080015", "2080015", @2080014_codeId, @GSTPtoThirdPartiesHeadId, 1, 0, 1),
("2080017", "2080017", @2080016_codeId, @TDSPtoThirdPartiesHeadId, 1, 0, 1);

SELECT @2080017_codeId := id FROM GLTypeMaster WHERE gl_code = "2080017";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2080018", "2080018", @2080017_codeId, @TDSPtoThirdPartiesMandatorySavingsAccountsHeadId, 1, 0, 1),
("2080019", "2080019", @2080017_codeId, @TDSPtoThirdPartiesVoluntarySavingsAccountsHeadId, 1, 0, 1),
("2080020", "2080020", @2080017_codeId, @TDSPtoThirdPartiesTermDepositsHeadId, 1, 0, 1),
("2100002", "2100002", @2000000_codeId, @nonCurrentliabilitiesHeadId, 1, 0, 1);

SELECT @2110000_codeId := id FROM GLTypeMaster WHERE gl_code = "2110000";
SELECT @2120000_codeId := id FROM GLTypeMaster WHERE gl_code = "2120000";


INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2110000", "2110000", @2000000_codeId, @InterestIncomeUnrecognizedUnsecuredHeadId, 1, 0, 1),
("2120000", "2120000", @2000000_codeId, @InterestIncomeUnrecognizedSecuredHeadId, 1, 0, 1);

SELECT @2110000_codeId := id FROM GLTypeMaster WHERE gl_code = "2110000";
SELECT @2120000_codeId := id FROM GLTypeMaster WHERE gl_code = "2120000";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2110001", "2110001", @2110000_codeId, @InterestIncomeUnrecognizedHeadId, 1, 0, 1),
("2120001", "2120001", @2120000_codeId, @InterestIncomeUnrecognizedHeadId, 1, 0, 1);


-- Income GL types
INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("3010000", "3010000", @3000000_codeId, @OperatingIncomeHeadId, 1, 0, 1);

SELECT @3010000_codeId := id FROM GLTypeMaster WHERE gl_code = "3010000";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("3010001", "3010001", @3010000_codeId, @InterestIncomeUnsecuredLoanstoClientsHeadId, 1, 0, 1);

SELECT @3010001_codeId := id FROM GLTypeMaster WHERE gl_code = "3010001";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("3010002", "3010002", @3010001_codeId, @InterestIncomeHeadId, 1, 0, 1),
("3010021", "3010021", @3010001_codeId, @InterestIncomeRealizedHeadId, 1, 0, 1),
("3010003", "3010003", @3010001_codeId, @PenaltyInterestIncomeHeadId, 1, 0, 1),
("3010004", "3010004", @3010000_codeId, @InterestIncomeSecuredLoanstoClientsHeadId, 1, 0, 1),
("3010022", "3010022", @3010001_codeId, @moraIntIncomeUnRealizedHeadId, 1, 0, 1),
("3010023", "3010023", @3010001_codeId, @moraIntIncomeRealizedHeadId, 1, 0, 1);

SELECT @3010004_codeId := id FROM GLTypeMaster WHERE gl_code = "3010004";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("3010005", "3010005", @3010004_codeId, @InterestIncomeHeadId, 1, 0, 1),
("3010026", "3010026", @3010004_codeId, @InterestIncomeRealizedHeadId, 1, 0, 1),
("3010006", "3010006", @3010004_codeId, @PenaltyInterestIncomeHeadId, 1, 0, 1),
("3010007", "3010007", @3010000_codeId, @FeesChargesandCommissionsfromClientsHeadId, 1, 0, 1),
("3010008", "3010008", @3010000_codeId, @FeesChargesandCommissionsfromOtherActivitiesHeadId, 1, 0, 1),
("3010009", "3010009", @3010000_codeId, @OtherOperatingIncomeHeadId, 1, 0, 1),
("3010010", "3010010", @3010000_codeId, @IncomefromRoundoffAccountHeadId, 1, 0, 0),
("3010011", "3010011", @3010000_codeId, @InterestIncomeMandatorySavingsAccountsHeadId, 1, 0, 1),
("3010024", "3010024", @3010004_codeId, @moraIntIncomeUnRealizedHeadId, 1, 0, 1),
("3010025", "3010025", @3010004_codeId, @moraIntIncomeRealizedHeadId, 1, 0, 1);

SELECT @3010011_codeId := id FROM GLTypeMaster WHERE gl_code = "3010011";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("3010012", "3010012", @3010011_codeId, @PenaltyInterestIncomeLHeadId, 1, 0, 1),
("3010013", "3010013", @3010000_codeId, @InterestIncomeVoluntarySavingsAccountsHeadId, 1, 0, 1);

SELECT @3010013_codeId := id FROM GLTypeMaster WHERE gl_code = "3010013";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("3010014", "3010014", @3010013_codeId, @PenaltyInterestIncomeLHeadId, 1, 0, 1),
("3010015", "3010015", @3010000_codeId, @InterestIncomeTermDepositsHeadId, 1, 0, 1);

SELECT @3010015_codeId := id FROM GLTypeMaster WHERE gl_code = "3010015";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("3010016", "3010016", @3010015_codeId, @PenaltyInterestIncomeLHeadId, 1, 0, 1);

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("3010017", "3010017", @3010000_codeId, @WriteOffRecoveryHeadId, 1, 0, 1);

SELECT @3010017_codeId := id FROM GLTypeMaster WHERE gl_code = "3010017";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("3010018", "3010018", @3010017_codeId, @WriteOffRecoveryLoansToClientsHeadId, 1, 0, 1);

SELECT @3010018_codeId := id FROM GLTypeMaster WHERE gl_code = "3010018";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("3010019", "3010019", @3010018_codeId, @WriteOffRecoverySecuredLoansToClientsHeadId, 1, 0, 1),
("3010020", "3010020", @3010018_codeId, @WriteOffRecoveryUnSecuredLoansToClientsHeadId, 1, 0, 1);

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("3020000", "3020000", @3000000_codeId, @NonoperatingIncomeHeadId, 1, 0, 1);

-- Expenses GL types
INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("4010000", "4010000", @4000000_codeId, @OperatingExpenseHeadId, 1, 0, 1);

SELECT @4010000_codeId := id FROM GLTypeMaster WHERE gl_code = "4010000";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("4010001", "4010001", @4010000_codeId, @InterestIncomeExpenseIEHeadId, 1, 0, 1);

SELECT @4010001_codeId := id FROM GLTypeMaster WHERE gl_code = "4010001";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("4010002", "4010002", @4010001_codeId, @IEonBorrowingsHeadId, 1, 0, 1);

SELECT @4010002_codeId := id FROM GLTypeMaster WHERE gl_code = "4010002";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("4010003", "4010003", @4010002_codeId, @IEonUnsecuredBorrowingsHeadId, 1, 0, 1),
("4010004", "4010004", @4010002_codeId, @IEonSecuredBorrowingsHeadId, 1, 0, 1),
("4010005", "4010005", @4010001_codeId, @IEonClientsSavingsDepositsHeadId, 1, 0, 1);

SELECT @4010005_codeId := id FROM GLTypeMaster WHERE gl_code = "4010005";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("4010006", "4010006", @4010005_codeId, @IEonMandatorySavingsAccountsHeadId, 1, 0, 1),
("4010007", "4010007", @4010005_codeId, @IEonVoluntarySavingsAccountsHeadId, 1, 0, 1),
("4010008", "4010008", @4010005_codeId, @IEonTermDepositsHeadId, 1, 0, 1),
("4010009", "4010009", @4010000_codeId, @CommissionExpenseCEHeadId, 1, 0, 1);

SELECT @4010009_codeId := id FROM GLTypeMaster WHERE gl_code = "4010009";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("4010010", "4010010", @4010009_codeId, @CEonUnsecuredLoanstoClientsHeadId, 1, 0, 1),
("4010011", "4010011", @4010009_codeId, @CEonSecuredLoanstoClientsHeadId, 1, 0, 1),
("4010012", "4010012", @4010000_codeId, @WriteoffsHeadId, 1, 0, 1);

SELECT @4010012_codeId := id FROM GLTypeMaster WHERE gl_code = "4010012";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("4010013", "4010013", @4010012_codeId, @WriteoffsLoansToClientsHeadId, 1, 0, 1),
("4010014", "4010014", @4010012_codeId, @WriteoffsReceivableFromClientsHeadId, 1, 0, 1),
("4010015", "4010015", @4010012_codeId, @OtherWriteoffsHeadId, 1, 0, 1);

SELECT @4010013_codeId := id FROM GLTypeMaster WHERE gl_code = "4010013";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("4010016", "4010016", @4010013_codeId, @WriteoffsUnsecuredLoanstoClientsHeadId, 1, 0, 1),
("4010017", "4010017", @4010013_codeId, @WriteoffsSecuredLoanstoClientsHeadId, 1, 0, 1);

SELECT @4010014_codeId := id FROM GLTypeMaster WHERE gl_code = "4010014";

INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("4010018", "4010018", @4010014_codeId, @WriteoffsFCCRFromClientsHeadId, 1, 0, 1),
("4010019", "4010019", @4010014_codeId, @WriteoffsIPRFromClientsHeadId, 1, 0, 1),
("4010020", "4010020", @4010014_codeId, @WriteoffsSTRFromClientsHeadId, 1, 0, 1),
("4010021", "4010021", @4010014_codeId, @WriteoffsGSTRFromClientsHeadId, 1, 0, 1),
("4020000", "4020000", @4000000_codeId, @DepreciationandAmortizationHeadId, 1, 0, 1),
("4030000", "4030000", @4000000_codeId, @NonoperatingExpenseHeadId, 1, 0, 1),
("4040000", "4040000", @4000000_codeId, @TaxesHeadId, 1, 0, 1);

SELECT @2010003_codeId := id FROM GLTypeMaster WHERE gl_code = "2010003";
INSERT INTO GLTypeMaster(gl_code, custom_gl_code, parent_type_id, gl_head_id, system_defined, allow_manual_entry, is_category) VALUES
("2010003", "2010003", @2010003_codeId, @capital, 1, 1, 1);

SELECT @intAccrualNPATypeId := id FROM TransactionTypeMaster WHERE name = "Interest Accrual (NPA)";
SELECT @intIncomeDerecognitionTypeId := id FROM TransactionTypeMaster WHERE name = "Interest Income Derecognition (to NPA)";
SELECT @intRecognizeNPAToUnrealizedTypeId := id FROM TransactionTypeMaster WHERE name = "Interest Recognition (From NPA to Unrealized)";
SELECT @intRecognizeNPAToRealizedTypeId := id FROM TransactionTypeMaster WHERE name = "Interest Recognition (From NPA to Realized)";
SELECT @intWaiverNPATypeId := id FROM TransactionTypeMaster WHERE name = "Interest Waiver Demand (NPA)";
SELECT @intOverdueWaiverTypeId := id FROM TransactionTypeMaster WHERE name = "Overdue Interest Waiver Demand (NPA)";

SELECT @intDemandRoundOffTypeId := id FROM TransactionTypeMaster WHERE name = "Interest Demand Round Off";

--
-- Master table values for TransactionGLHeadMap
--
DELETE FROM TransactionGLHeadMap;
INSERT INTO TransactionGLHeadMap(tx_type_id, debit_gl_head_id, credit_gl_head_id, is_default) VALUES
(@disbursementTypeId, @LoansandAdvancesHeadId, @VaultCashHeadId, 1),
(@interestAccrualTypeId, @InterestAccruedNotDueHeadId, @InterestIncomeHeadId, 1),
(@interestDemandTypeId, @InterestAccruedAndDueHeadId, @InterestAccruedNotDueHeadId, 1),
(@overdueInterestDemandTypeId, @InterestAccruedOverdueHeadId, @InterestAccruedAndDueHeadId, 1),
(@interestTypeId, @VaultCashHeadId, @InterestAccruedAndDueHeadId, 1),
(@interestTypeId, @IncomefromRoundoffAccountHeadId, @InterestAccruedAndDueHeadId, 0),
(@interestTypeId, @WriteoffsLoansToClientsHeadId, @InterestAccruedAndDueHeadId, 0),
(@overdueInterestTypeId, @VaultCashHeadId, @InterestAccruedOverdueHeadId, 1),
(@interestOnOverdueInterestDemandTypeId, @InterestOnOverdueInterestHeadId, @PenaltyInterestIncomeHeadId, 1),
(@insurancePremiumDemandTypeId, @IPRfromClientsHeadId, @IPPtoThirdPartiesHeadId, 1),
(@lateChargeDemandTypeId, @PenaltyInterestHeadId, @PenaltyInterestIncomeHeadId, 1),
(@lateChargeWaiverDemandTypeId, @PenaltyInterestIncomeHeadId, @PenaltyInterestHeadId, 1),
(@feeDemandTypeId, @FCCRfromClientsHeadId, @FeesChargesandCommissionsfromClientsHeadId, 1),
(@principalTypeId, @IncomefromRoundoffAccountHeadId, @LoansandAdvancesHeadId, 0),
(@prepaymentofPrincipalTypeId, @IncomefromRoundoffAccountHeadId, @LoansandAdvancesHeadId, 0),
(@interestOnOverduePrincipalTypeId, @IncomefromRoundoffAccountHeadId, @InterestOnOverduePrincipalHeadId, 0),
(@interestOnOverduePrincipalCashTypeId, @IncomefromRoundoffAccountHeadId, @PenaltyInterestIncomeHeadId, 0),
(@prepaymentofInterestTypeId, @IncomefromRoundoffAccountHeadId, @InterestAccruedNotDueHeadId, 0),
(@overdueInterestTypeId, @IncomefromRoundoffAccountHeadId, @InterestAccruedOverdueHeadId, 0),
(@interestOnOverdueInterestTypeId, @IncomefromRoundoffAccountHeadId, @InterestOnOverdueInterestHeadId, 0),
(@interestOnOverdueInterestCashTypeId, @IncomefromRoundoffAccountHeadId, @PenaltyInterestIncomeHeadId, 0),
(@feeTypeId, @IncomefromRoundoffAccountHeadId, @FCCRfromClientsHeadId, 0),
(@insurancePremiumTypeId, @IncomefromRoundoffAccountHeadId, @IPRfromClientsHeadId, 0),
(@lateChargeTypeId, @IncomefromRoundoffAccountHeadId, @PenaltyInterestHeadId, 0),
(@lateChargeCashTypeId, @IncomefromRoundoffAccountHeadId, @PenaltyInterestIncomeHeadId, 0),
(@principalTypeId, @WriteoffsLoansToClientsHeadId, @LoansandAdvancesHeadId, 0),
(@prepaymentofPrincipalTypeId, @WriteoffsLoansToClientsHeadId, @LoansandAdvancesHeadId, 0),
(@interestOnOverduePrincipalDemandTypeId, @InterestOnOverduePrincipalHeadId, @PenaltyInterestIncomeHeadId, 0),
(@interestOnOverduePrincipalTypeId, @WriteoffsLoansToClientsHeadId, @InterestOnOverduePrincipalHeadId, 0),
(@interestOnOverduePrincipalCashTypeId, @WriteoffsLoansToClientsHeadId, @PenaltyInterestIncomeHeadId, 0),
(@prepaymentofInterestTypeId, @WriteoffsLoansToClientsHeadId, @InterestAccruedNotDueHeadId, 0),
(@overdueInterestTypeId, @WriteoffsLoansToClientsHeadId, @InterestAccruedOverdueHeadId, 0),
(@interestOnOverdueInterestTypeId, @WriteoffsLoansToClientsHeadId, @InterestOnOverdueInterestHeadId, 0),
(@interestOnOverdueInterestCashTypeId, @WriteoffsLoansToClientsHeadId, @PenaltyInterestIncomeHeadId, 0),
(@lateChargeTypeId, @WriteoffsLoansToClientsHeadId, @PenaltyInterestHeadId, 0),
(@lateChargeCashTypeId, @WriteoffsLoansToClientsHeadId, @PenaltyInterestIncomeHeadId, 0),
(@feeTypeId, @WriteoffsReceivableFromClientsHeadId, @FCCRfromClientsHeadId, 0),
(@insurancePremiumTypeId, @WriteoffsReceivableFromClientsHeadId, @IPRfromClientsHeadId, 0),
(@serviceTaxTypeId, @WriteoffsReceivableFromClientsHeadId, @STRfromClientsHeadId, 0),
(@gstTypeId, @WriteoffsReceivableFromClientsHeadId, @GSTRfromClientsHeadId, 0),
(@prepaymentofPrincipalTypeId, @VaultCashHeadId, @LoansandAdvancesHeadId, 0),
(@interestOnOverduePrincipalTypeId, @VaultCashHeadId, @InterestOnOverduePrincipalHeadId, 0),
(@interestOnOverduePrincipalCashTypeId, @VaultCashHeadId, @PenaltyInterestIncomeHeadId, 0),
(@prepaymentofInterestTypeId, @VaultCashHeadId, @InterestAccruedNotDueHeadId, 0),
(@interestOnOverdueInterestTypeId, @VaultCashHeadId, @InterestOnOverdueInterestHeadId, 0),
(@interestOnOverdueInterestCashTypeId, @VaultCashHeadId, @PenaltyInterestIncomeHeadId, 0),
(@feeTypeId, @VaultCashHeadId, @FCCRfromClientsHeadId, 0),
(@toRoundoffTypeId, @VaultCashHeadId, @IncomefromRoundoffAccountHeadId, 0),
(@principalTypeId, @VaultCashHeadId, @LoansandAdvancesHeadId, 0),
(@principalClaimTypeId, @VaultCashHeadId, @claimLoansandAdvancesHeadId, 0),
(@insurancePremiumTypeId, @VaultCashHeadId, @IPRfromClientsHeadId, 0),
(@lateChargeTypeId, @VaultCashHeadId, @PenaltyInterestHeadId, 0),
(@lateChargeCashTypeId, @VaultCashHeadId, @PenaltyInterestIncomeHeadId, 0),
(@foreclosurePenaltyTypeId, @VaultCashHeadId, @PenaltyInterestIncomeHeadId, 0),
(@differentialInterestTypeId, @VaultCashHeadId, @InterestIncomeHeadId, 1),
(@differentialInterestTypeId, @IncomefromRoundoffAccountHeadId, @InterestIncomeHeadId, 0),
(@differentialInterestTypeId, @WriteoffsLoansToClientsHeadId, @InterestIncomeHeadId, 0),
(@depositTypeId, @VaultCashHeadId, @SavingsDepositsfromClientsHeadId, 1),
(@capitalizationOfInterestTypeId, @InterestAccruedAndDueLHeadId, @SavingsDepositsfromClientsHeadId, 1),
(@compoundingOfInterestTypeId, @InterestAccruedNotDueLHeadId, @InterestCompoundedNotDueHeadId, 1),
(@earlyWithdrawalTypeId, @SavingsDepositsfromClientsHeadId, @VaultCashHeadId, 1),
(@commissionDemandTypeId, @CommissionExpenseCEHeadId, @CommissionPayableCPHeadId, 1),
(@commissionTypeId, @CommissionPayableCPHeadId, @VaultCashHeadId, 1),
(@withdrawalTypeId, @SavingsDepositsfromClientsHeadId, @VaultCashHeadId, 0),
(@earlyWithdrawalPenaltyTypeId, @VaultCashHeadId, @PenaltyInterestIncomeLHeadId, 0),
(@savingsInterestAccrualTypeId, @IEonClientsSavingsDepositsHeadId, @InterestAccruedNotDueLHeadId, 1),
(@interestPayoutDemandTypeId, @InterestAccruedNotDueLHeadId, @InterestAccruedAndDueLHeadId, 1),
(@interestPayoutWaiverDemandTypeId, @InterestAccruedAndDueLHeadId, @IEonClientsSavingsDepositsHeadId, 1),
(@compoundedInterestPayoutDemandTypeId, @InterestCompoundedNotDueHeadId, @InterestAccruedAndDueLHeadId, 1),
(@overdueInterestPayoutDemandTypeId, @InterestAccruedAndDueLHeadId, @InterestAccruedOverdueLHeadId, 1),
(@prepayoutOfInterestTypeId, @InterestAccruedNotDueLHeadId, @VaultCashHeadId, 1),
(@prepayoutOfCompoundedInterestTypeId, @InterestCompoundedNotDueHeadId, @VaultCashHeadId, 1),
(@interestPayoutTypeId, @InterestAccruedAndDueLHeadId, @VaultCashHeadId, 1),
(@overdueInterestPayoutTypeId, @InterestAccruedOverdueLHeadId, @VaultCashHeadId, 1),
(@differentialInterestPayoutTypeId, @IEonClientsSavingsDepositsHeadId, @VaultCashHeadId, 1),
(@serviceTaxTypeId, @VaultCashHeadId, @STRfromClientsHeadId, 1),
(@serviceTaxDemandTypeId, @STRfromClientsHeadId, @STPtoThirdPartiesHeadId, 1),
(@gstTypeId, @VaultCashHeadId, @GSTRfromClientsHeadId, 1),
(@gstDemandTypeId, @GSTRfromClientsHeadId, @GSTPtoThirdPartiesHeadId, 1),
(@tdsReceivableDemandTypeId, @TDSRfromClientsHeadId, @TDSPtoThirdPartiesHeadId, 1),
(@tdsWithholdingTypeId, @InterestAccruedNotDueLHeadId, @TDSRfromClientsHeadId, 1),
(@tdsWithholdingDepositTypeId, @SavingsDepositsfromClientsHeadId, @TDSRfromClientsHeadId, 1),
(@advancePaymentTypeId, @VaultCashHeadId, @AdvancefromClientsHeadId, 1),
(@writeOffRecoveryTypeId, @VaultCashHeadId, @WriteOffRecoveryLoansToClientsHeadId, 1),
(@interestWaiverDemandTypeId, @InterestIncomeHeadId, @InterestAccruedAndDueHeadId, 1),
(@overdueInterestWaiverDemandTypeId, @InterestIncomeHeadId, @InterestAccruedOverdueHeadId, 1),
(@disbursementTypeId, @LoansandAdvancesHeadId, @PrepaidCardHeadId, 1),
(@interestTypeId, @PrepaidCardHeadId, @InterestAccruedAndDueHeadId, 1),
(@overdueInterestTypeId, @PrepaidCardHeadId, @InterestAccruedOverdueHeadId, 1),
(@prepaymentofPrincipalTypeId, @PrepaidCardHeadId, @LoansandAdvancesHeadId, 0),
(@interestOnOverduePrincipalTypeId, @PrepaidCardHeadId, @InterestOnOverduePrincipalHeadId, 0),
(@interestOnOverduePrincipalCashTypeId, @PrepaidCardHeadId, @PenaltyInterestIncomeHeadId, 0),
(@prepaymentofInterestTypeId, @PrepaidCardHeadId, @InterestAccruedNotDueHeadId, 0),
(@interestOnOverdueInterestTypeId, @PrepaidCardHeadId, @InterestOnOverdueInterestHeadId, 0),
(@interestOnOverdueInterestCashTypeId, @PrepaidCardHeadId, @PenaltyInterestIncomeHeadId, 0),
(@feeTypeId, @PrepaidCardHeadId, @FCCRfromClientsHeadId, 0),
(@toRoundoffTypeId, @PrepaidCardHeadId, @IncomefromRoundoffAccountHeadId, 0),
(@principalTypeId, @PrepaidCardHeadId, @LoansandAdvancesHeadId, 0),
(@principalTypeId, @PrepaidCardHeadId, @ClaimLoansandAdvancesHeadId, 0),
(@insurancePremiumTypeId, @PrepaidCardHeadId, @IPRfromClientsHeadId, 0),
(@lateChargeTypeId, @PrepaidCardHeadId, @PenaltyInterestHeadId, 0),
(@lateChargeCashTypeId, @PrepaidCardHeadId, @PenaltyInterestIncomeHeadId, 0),
(@foreclosurePenaltyTypeId, @PrepaidCardHeadId, @PenaltyInterestIncomeHeadId, 0),
(@differentialInterestTypeId, @PrepaidCardHeadId, @InterestIncomeHeadId, 1),
(@depositTypeId, @PrepaidCardHeadId, @SavingsDepositsfromClientsHeadId, 1),
(@earlyWithdrawalTypeId, @SavingsDepositsfromClientsHeadId, @PrepaidCardHeadId, 1),
(@commissionTypeId, @CommissionPayableCPHeadId, @PrepaidCardHeadId, 1),
(@withdrawalTypeId, @SavingsDepositsfromClientsHeadId, @PrepaidCardHeadId, 0),
(@earlyWithdrawalPenaltyTypeId, @PrepaidCardHeadId, @PenaltyInterestIncomeLHeadId, 0),
(@prepayoutOfInterestTypeId, @InterestAccruedNotDueLHeadId, @PrepaidCardHeadId, 1),
(@prepayoutOfCompoundedInterestTypeId, @InterestCompoundedNotDueHeadId, @PrepaidCardHeadId, 1),
(@interestPayoutTypeId, @InterestAccruedAndDueLHeadId, @PrepaidCardHeadId, 1),
(@overdueInterestPayoutTypeId, @InterestAccruedOverdueLHeadId, @PrepaidCardHeadId, 1),
(@differentialInterestPayoutTypeId, @IEonClientsSavingsDepositsHeadId, @PrepaidCardHeadId, 1),
(@serviceTaxTypeId, @PrepaidCardHeadId, @STRfromClientsHeadId, 1),
(@gstTypeId, @PrepaidCardHeadId, @GSTRfromClientsHeadId, 1),
(@advancePaymentTypeId, @PrepaidCardHeadId, @AdvancefromClientsHeadId, 1),
(@capitalizationIntAccNotDueTypeId, @LoansandAdvancesHeadId, @InterestAccruedNotDueHeadId, 1),
(@capitalizationIntAccAndDueTypeId, @LoansandAdvancesHeadId, @InterestAccruedAndDueHeadId, 1),
(@capitalizationIntAccOverdueTypeId, @LoansandAdvancesHeadId, @InterestAccruedOverdueHeadId, 1),
(@intRealizationTypeId, @InterestIncomeUnrealizedHeadId, @InterestIncomeRealizedHeadId, 1),
(@moraIntRealizationTypeId, @moraIntIncomeUnRealizedHeadId, @moraIntIncomeRealizedHeadId, 1),
(@moraIntAccrualTypeId, @moraIntAccruedNotDueHeadId, @InterestIncomeHeadId, 1),
(@moraIntDemandTypeId, @moraIntAccruedAndDueHeadId, @moraIntAccruedNotDueHeadId, 1),
(@equatedMoraIntDemandTypeId, @equatedMoraIntAccruedAndDueHeadId, @moraIntAccruedAndDueHeadId, 1),
(@moraIntTypeId, @VaultCashHeadId, @moraIntAccruedAndDueHeadId, 1),
(@moraIntTypeId, @IncomefromRoundoffAccountHeadId, @moraIntAccruedAndDueHeadId, 0),
(@moraIntTypeId, @WriteoffsLoansToClientsHeadId, @moraIntAccruedAndDueHeadId, 0),
(@moraIntTypeId, @PrepaidCardHeadId, @moraIntAccruedAndDueHeadId, 1),
(@equatedMoraIntTypeId, @VaultCashHeadId, @equatedMoraIntAccruedAndDueHeadId, 1),
(@equatedMoraIntTypeId, @IncomefromRoundoffAccountHeadId, @equatedMoraIntAccruedAndDueHeadId, 0),
(@equatedMoraIntTypeId, @WriteoffsLoansToClientsHeadId, @equatedMoraIntAccruedAndDueHeadId, 0),
(@equatedMoraIntTypeId, @PrepaidCardHeadId, @equatedMoraIntAccruedAndDueHeadId, 1),
(@prepaymentMoraIntTypeId, @IncomefromRoundoffAccountHeadId, @moraIntAccruedNotDueHeadId, 0),
(@prepaymentMoraIntTypeId, @WriteoffsLoansToClientsHeadId, @moraIntAccruedNotDueHeadId, 0),
(@prepaymentMoraIntTypeId, @VaultCashHeadId, @moraIntAccruedNotDueHeadId, 0),
(@prepaymentMoraIntTypeId, @PrepaidCardHeadId, @moraIntAccruedNotDueHeadId, 0),
(@moraDifferentialIntTypeId, @VaultCashHeadId, @InterestIncomeHeadId, 1),
(@moraDifferentialIntTypeId, @IncomefromRoundoffAccountHeadId, @InterestIncomeHeadId, 0),
(@moraDifferentialIntTypeId, @WriteoffsLoansToClientsHeadId, @InterestIncomeHeadId, 0),
(@moraDifferentialIntTypeId, @PrepaidCardHeadId, @InterestIncomeHeadId, 1),
(@moraIntWaiverDemandTypeId, @InterestIncomeHeadId, @moraIntAccruedAndDueHeadId, 1),
(@equatedMoraIntWaiverDemandTypeId, @InterestIncomeHeadId, @equatedMoraIntAccruedAndDueHeadId, 1),
(@intAccrualNPATypeId, @InterestAccruedNotDueHeadId, @InterestIncomeUnrecognizedHeadId, 1),
(@intIncomeDerecognitionTypeId, @InterestIncomeUnrealizedHeadId, @InterestIncomeUnrecognizedHeadId, 1),
(@intRecognizeNPAToRealizedTypeId, @InterestIncomeUnrecognizedHeadId, @InterestIncomeRealizedHeadId, 1),
(@intRecognizeNPAToUnrealizedTypeId, @InterestIncomeUnrecognizedHeadId, @InterestIncomeUnrealizedHeadId, 1),
(@intWaiverNPATypeId, @InterestIncomeUnrecognizedHeadId, @InterestAccruedAndDueHeadId, 1),
(@intOverdueWaiverTypeId, @InterestIncomeUnrecognizedHeadId, @InterestAccruedOverdueHeadId, 1),
(@prepaymentofPrincipalTypeId, @advancePaymentTypeId, @LoansandAdvancesHeadId, 0),
(@interestOnOverduePrincipalTypeId, @advancePaymentTypeId, @InterestOnOverduePrincipalHeadId, 0),
(@interestOnOverduePrincipalCashTypeId, @advancePaymentTypeId, @PenaltyInterestIncomeHeadId, 0),
(@prepaymentofInterestTypeId, @advancePaymentTypeId, @InterestAccruedNotDueHeadId, 0),
(@interestOnOverdueInterestTypeId, @advancePaymentTypeId, @InterestOnOverdueInterestHeadId, 0),
(@interestOnOverdueInterestCashTypeId, @advancePaymentTypeId, @PenaltyInterestIncomeHeadId, 0),
(@feeTypeId, @advancePaymentTypeId, @FCCRfromClientsHeadId, 0),
(@toRoundoffTypeId, @advancePaymentTypeId, @IncomefromRoundoffAccountHeadId, 0),
(@principalTypeId, @advancePaymentTypeId, @LoansandAdvancesHeadId, 0),
(@insurancePremiumTypeId, @advancePaymentTypeId, @IPRfromClientsHeadId, 0),
(@lateChargeTypeId, @advancePaymentTypeId, @PenaltyInterestHeadId, 0),
(@lateChargeCashTypeId, @advancePaymentTypeId, @PenaltyInterestIncomeHeadId, 0),
(@foreclosurePenaltyTypeId, @advancePaymentTypeId, @PenaltyInterestIncomeHeadId, 0),
(@differentialInterestTypeId, @advancePaymentTypeId, @InterestIncomeHeadId, 1),
(@interestTypeId, @advancePaymentTypeId, @InterestAccruedAndDueHeadId, 1),
(@overdueInterestTypeId, @advancePaymentTypeId, @InterestAccruedOverdueHeadId, 1),
(@depositTypeId, @advancePaymentTypeId, @SavingsDepositsfromClientsHeadId, 1),
(@earlyWithdrawalPenaltyTypeId, @advancePaymentTypeId, @PenaltyInterestIncomeLHeadId, 0),
(@serviceTaxTypeId, @advancePaymentTypeId, @STRfromClientsHeadId, 1),
(@gstTypeId, @advancePaymentTypeId, @GSTRfromClientsHeadId, 1),
(@advancePaymentTypeId, @advancePaymentTypeId, @AdvancefromClientsHeadId, 1),
(@writeOffRecoveryTypeId, @advancePaymentTypeId, @WriteOffRecoveryLoansToClientsHeadId, 1),
(@prepaymentMoraIntTypeId, @advancePaymentTypeId, @moraIntAccruedNotDueHeadId, 0),
(@moraIntTypeId, @advancePaymentTypeId, @moraIntAccruedAndDueHeadId, 1),
(@equatedMoraIntTypeId, @advancePaymentTypeId, @equatedMoraIntAccruedAndDueHeadId, 1),
(@moraDifferentialIntTypeId, @advancePaymentTypeId, @InterestIncomeHeadId, 1),
(@feeCashTypeId, @advancePaymentTypeId, @FeesChargesandCommissionsfromClientsHeadId, 1),
(@gstCashTypeId, @advancePaymentTypeId, @GSTPtoThirdPartiesHeadId, 1),
(@insurancePremiumCashTypeId, @advancePaymentTypeId, @IPPtoThirdPartiesHeadId, 1),
(@feeCashTypeId, @VaultCashHeadId, @FeesChargesandCommissionsfromClientsHeadId, 1),
(@gstCashTypeId, @VaultCashHeadId, @GSTPtoThirdPartiesHeadId, 1),
(@insurancePremiumCashTypeId, @VaultCashHeadId, @IPPtoThirdPartiesHeadId, 1),
(@intDemandRoundOffTypeId, @InterestDemandRoundOffHeadId, @InterestDemandRoundOffHeadId, 1);

SELECT @roundOffTxGLHeadId := id FROM TransactionGLHeadMap WHERE tx_type_id=@toRoundoffTypeId AND debit_gl_head_id=@VaultCashHeadId AND credit_gl_head_id=@IncomefromRoundoffAccountHeadId;
SELECT @vaultCashGLTypeId := id FROM GLTypeMaster WHERE gl_head_id = @VaultCashHeadId;
SELECT @incomeFromRoundoffAccountGLTypeId := id FROM GLTypeMaster WHERE gl_head_id = @IncomefromRoundoffAccountHeadId;
SELECT @advancePaymentTxGLHeadId := id FROM TransactionGLHeadMap WHERE tx_type_id=@advancePaymentTypeId AND debit_gl_head_id=@VaultCashHeadId AND credit_gl_head_id=@AdvancefromClientsHeadId;
SELECT @advanceFromClientsGLTypeId := id FROM GLTypeMaster WHERE gl_head_id = @AdvancefromClientsHeadId;
SELECT @writeOffRecoveryTxGLHeadId := id FROM TransactionGLHeadMap WHERE tx_type_id=@writeOffRecoveryTypeId AND debit_gl_head_id=@VaultCashHeadId AND credit_gl_head_id=@WriteOffRecoveryLoansToClientsHeadId;

SELECT @intDemandRoundOffTxGLHeadId := id FROM TransactionGLHeadMap WHERE tx_type_id=@intDemandRoundOffTypeId AND debit_gl_head_id=@InterestDemandRoundOffHeadId AND credit_gl_head_id=@InterestDemandRoundOffHeadId;
SELECT @intDemandRoundOffGLTypeId := id FROM GLTypeMaster WHERE gl_head_id = @InterestDemandRoundOffHeadId;
--
-- Master table values for TransactionGLTypeMap
--
DELETE FROM TransactionGLTypeMap;
INSERT INTO TransactionGLTypeMap(tx_gl_head_id, debit_gl_type_id, credit_gl_type_id) VALUES
(@roundOffTxGLHeadId, @vaultCashGLTypeId, @incomeFromRoundoffAccountGLTypeId),
(@advancePaymentTxGLHeadId, @vaultCashGLTypeId, @advanceFromClientsGLTypeId),
(@intDemandRoundOffTxGLHeadId, @intDemandRoundOffGLTypeId, @intDemandRoundOffGLTypeId);


--
-- Master table values for HolidayRuleMaster
--
DELETE FROM HolidayRuleMaster;
INSERT INTO HolidayRuleMaster(name) VALUES
('Next Repayment Day'),
('Same Day'),
('Previous Working Day'),
('Next Working Day'),
('Moratorium');

--
-- Master table values for OrgSettingTypeMaster
--
DELETE FROM OrgSettingTypeMaster;
INSERT INTO OrgSettingTypeMaster(id, attribute, description) VALUES
(1,'country','Country'),
(2,'organization_name','Organization Name'),
(3,'work_week_days','Work-week Days'),
(6,'max_secured_loans_per_customer','Maximum Secured Loans Per Customer'),
(7,'max_unsecured_group_loans_per_customer','Maximum Unsecured Group Loans Per Customer'),
(8,'max_outstanding_per_customer_for_group_loans','Maximum Debt Outstanding Per Customer For Group Loans'),
(9,'rural_household_income_floor','Rural Household Income Floor'),
(10,'nonrural_household_income_floor','Non-rural Household Income Floor'),
(13,'rural_household_expense_floor','Rural Household Expense Floor'),
(14,'nonrural_household_expense_floor','Non-rural Household Expense Floor'),
(15,'max_allowed_percentage_of_hh_income_as_expense','Maximum Allowed Percentage Of Household Income To Be Accepted As Expense'),
(17,'change_password_days','Force Password Change In (Days)'),
(18,'max_meetings_per_day','Maximum Meetings Per Day'),
(19,'max_group_loans_per_center','Maximum Group Loans Per Center'),
(21,'min_time_between_center_meetings','Minimum time (minutes) between two center meetings for an officer'),
(22,'max_unsecured_individual_loans_per_customer','Maximum Unsecured Individual Loans Per Customer'),
(25,'show_written_off_in_cds_in_days','No. of days of non-recovery to hide W/O accounts from CDS'),
(26,'gold_tareweight_tolerance_percentage','Gold TareWeight Tolerance %'),
(27,'gold_grossweight_tolerance_percentage','Gold GrossWeight Tolerance %'),
(28,'minimum_attendance_percentage_of_previous_loans','Minimum Attendance Percentage Of Previous Loans'),
(29,'sticker_weight_for_jewel_loans','Sticker Weight For Jewel Loans (grams)'),
(30,'max_outstanding_per_customer_for_individual_loans','Maximum Debt Outstanding Per Customer For Individual Loans'),
(31,'inactive_user_days','Inactive user not login once within (Days)'),
(32,'mShakti_unapproved_collections_cutoff_time','Cut-off Time For Unapproved mShakti Collection Posting'),
(33,'eod_suspense_entry_limit','EOD Suspense Entry Limit'),
(34,'max_distance_between_customer_and_area','Maximum Distance(Km) Between Area and Customer GeoLocation'),
(35,'center_meeting_time','List of Allowed Center Meeting Times'),
(36,'max_groups_per_center','Maximum Groups Per Center'),
(37,'mShakti_min_version','Minimum Version of mShakti'),
(38,'mShakti_latest_version','Latest Version of mShakti'),
(39,'max_distance_between_center_and_branch','Maximum Distance(Km) Between Center and Branch GeoLocation'),
(40,'number_of_days_to_reset_customer','Number of Days to allow Reset of Customer'),
(41,'max_advance_collection_days','Maximum Days Allowed For Advance Collections in Shakti/mShakti'),
(42,'remember_password_history_in_days','Remember Password History (in Days)'),
(43,'no_of_old_passwords_to_remember','No. of Old Passwords to Remember'),
(44,'max_time_allowed_for_digital_consent','Maximum Time Allowed For Digital Consent(In Seconds).'),
(45,'allowed_meeting_schedules','List of Allowed Center Meeting Schedules'),
(46,'center_meeting_start_time','Center Meeting - Minimum Start Time'),
(47,'center_meeting_end_time','Center Meeting - Maximum End Time.'),
(48,'days_to_deactivate_bank_account_during_customer_reset_for_reconfirmation','Days to deactivate bank account during Customer Reset for Reconfirmation'),
(49,'rural_household_income_limit','Rural Household Income Limit'),
(50,'nonrural_household_income_limit','Non-rural Household Income Limit'),
(51,'rural_household_expense_limit','Rural Household Expense Limit'),
(52,'nonrural_household_expense_limit','Non-rural Household Expense Limit'),
(53,'auto_cancel_pipeline_days','Days To Auto Cancel LoanPipeLine'),
(54,'no_of_days_to_reuse_documents_from_cancelled_loans','Number Of Days To Reuse Documents From Cancelled Loans'),
(55,'no_of_days_for_expiry_of_customer_contact_otp_verification','Number of days for expiry of Customer Contact OTP Verification'),
(56,'no_of_offices_for_area','Number of offices for an area(zero,one,greater than one)'),
(57,'disbursement_work_week_days','Disbursement work-week days'),
(58,'Block Enrollments/Disbursements based on monthly PAR %','Block Enrollments/Disbursements based on monthly PAR %'),
(59,'voterid_name_match_percentage','Voter ID Name Match Percentage'),
(60,'no_of_days_for_expiry_of_cb_consent_otp_verification','Number of days for expiry of CB Consent OTP Verification'),
(61,'aadhar_name_match_percentage','Aadhar Name Match Percentage'),
(62,'eligible_installment_amount_percentage','Percentage of Eligible Installment Amount for Loan Origination'),
(63,'minimum_payment_amount_percentage_for_settlement_marking','Minimum Payment Percentage to Mark Account as Write-off Settled'),
(64,'no_of_days_for_expiry_of_entity_geo_location','Number of days for Customer/Entity Geo Location Expiry');

--
-- Master table values for LoanGroupTypeMaster
--
DELETE FROM LoanGroupTypeMaster;
INSERT INTO LoanGroupTypeMaster(name, min_customers_per_group, max_customers_per_group, min_loans_per_group, max_loans_per_group, is_active) VALUES
('JLG', 0, 100, 0, 10, 1),
('SHG', 0, 100, 0, 100, 0);

--
-- Master table values for AttendanceMaster
--
DELETE FROM AttendanceMaster;
INSERT INTO AttendanceMaster(name, ui_name) VALUES
('Present', 'Yes'),
('Absent', 'No');

--
-- Master table values for LogActionTypeMaster
--
DELETE FROM LogActionTypeMaster;
INSERT INTO LogActionTypeMaster(name) VALUES
('Create'),
('Update'),
('Delete');

--
-- Master table values for MonthlyPeriodicityMaster
--
DELETE FROM MonthlyPeriodicityMaster;
INSERT INTO MonthlyPeriodicityMaster(name) VALUES
('First'),
('Second'),
('Third'),
('Fourth'),
('Last');

--
-- Master table values for QuestionnaireClassMaster
--
DELETE FROM QuestionnaireClassMaster;
INSERT INTO QuestionnaireClassMaster(name) VALUES
('Audit'),
('Survey'),
('Visit');

-- Setting master values in variables for downstream usage
SELECT @auditQuestionnaireClassId := id FROM QuestionnaireClassMaster WHERE name = 'Audit';
SELECT @surveyQuestionnaireClassId := id FROM QuestionnaireClassMaster WHERE name = 'Survey';
SELECT @visitQuestionnaireClassId := id FROM QuestionnaireClassMaster WHERE name = 'Visit';

--
-- Master table values for QuestionnaireStatusMaster
--
DELETE FROM QuestionnaireStatusMaster;
INSERT INTO QuestionnaireStatusMaster(name) VALUES
('Under Creation'),
('Under Update'),
('Complete'),
('Closed');

--
-- Master table values for QuestionnaireTypeMaster
--
DELETE FROM QuestionnaireTypeMaster;
INSERT INTO QuestionnaireTypeMaster(questionnaire_class_id, name) VALUES
(@auditQuestionnaireClassId, 'Grading Mode'),
(@auditQuestionnaireClassId, 'Answering Mode With Ratio'),
(@auditQuestionnaireClassId, 'Answering Mode Without Score'),
(@auditQuestionnaireClassId, 'Answering Mode With Score'),
(@surveyQuestionnaireClassId, 'Grading Mode'),
(@surveyQuestionnaireClassId, 'Answering Mode Without Score'),
(@surveyQuestionnaireClassId, 'Answering Mode With Score'),
(@visitQuestionnaireClassId, 'Answering Mode Without Score'),
(@visitQuestionnaireClassId, 'Answering Mode With Score');

--
-- Master table values for QuestionnaireOnMaster
--
DELETE FROM QuestionnaireOnMaster;
INSERT INTO QuestionnaireOnMaster(questionnaire_class_id, name) VALUES
(@auditQuestionnaireClassId, 'Branch'),
(@auditQuestionnaireClassId, 'Center'),
(@surveyQuestionnaireClassId, 'Customer'),
(@surveyQuestionnaireClassId, 'Center'),
(@surveyQuestionnaireClassId, 'Loan Pipeline'),
(@surveyQuestionnaireClassId, 'Loan Pipeline Status'),
(@surveyQuestionnaireClassId, 'Area'),
(@visitQuestionnaireClassId, 'Branch'),
(@visitQuestionnaireClassId, 'Center');

--
-- Master table values for AnswerTypeMaster
--
DELETE FROM AnswerTypeMaster;
INSERT INTO AnswerTypeMaster(name) VALUES
('Text'),
('Yes/No'),
('List - Single Select'),
('List - Multiple Select'),
('Date'),
('Time'),
('Date - And - Time'),
('Landline - Telephone - Number'),
('Mobile - Number');

-- Setting master values in variables for downstream usage
SELECT @textAnswerTypeId := id FROM AnswerTypeMaster WHERE name = 'Text';
SELECT @yesNoAnswerTypeId := id FROM AnswerTypeMaster WHERE name = 'Yes/No';
SELECT @listSingleAnswerTypeId := id FROM AnswerTypeMaster WHERE name = 'List - Single Select';
SELECT @listMultipleAnswerTypeId := id FROM AnswerTypeMaster WHERE name = 'List - Multiple Select';


--
-- Master table values for AmountTransferTypeMaster
--
DELETE FROM AmountTransferTypeMaster;
INSERT INTO AmountTransferTypeMaster(category, name, ui_name) VALUES
('Interest Payout', 'Cash', 'Cash'),
('Interest Payout', 'Cheque', 'Cheque'),
('Interest Payout', 'ECS', 'ECS'),
('Interest Payout', 'Savings Account', 'Savings Account'),
('Deposit Maturity', 'Cash', 'Cash'),
('Deposit Maturity', 'Cheque', 'Cheque'),
('Deposit Maturity', 'ECS', 'ECS'),
('Deposit Maturity', 'Savings Account', 'Savings Account'),
('Deposit Maturity', 'Renew Deposit', 'Renew Deposit');

--
-- Master table values for MetaEntityTypeMaster
--
DELETE FROM MetaEntityTypeMaster;
INSERT INTO MetaEntityTypeMaster(name) VALUES
('Employee'),
('Funding Source');

--
-- Master table values for LanguageMaster
--
DELETE FROM LanguageMaster;
INSERT INTO LanguageMaster(name, language) VALUES
('English', 'en_IN'),
('Tamil', 'ta_IN'),
('Hindi', 'hi_IN'),
('Gujarati', 'gj_IN'),
('Punjabi', 'pj_IN'),
('Oriya', 'or_IN'),
('Malayalam', 'ml_IN'),
('Assamese', 'as_IN'),
('Bengali', 'bn_IN'),
('Kannada', 'kn_IN'),
('Telugu', 'te_IN');

--
-- Master table values for ValueTypeMaster
--
DELETE FROM ValueTypeMaster;
INSERT INTO ValueTypeMaster(name, abbr) VALUES
('Absolute', 'abs'),
('Percentage', '%'),
('Per Thousand', '/1000');

--
-- Master table values for PurityStatusMaster
--
DELETE FROM PurityStatusMaster;
INSERT INTO PurityStatusMaster(name) VALUES
('Fully Spurious'),
('Partly Spurious'),
('Fully Low Quality'),
('Partly Low Quality');

--
-- Master table values for ActionApproveTypeMaster
--
DELETE FROM ActionApproveTypeMaster;
INSERT INTO ActionApproveTypeMaster(name) VALUES
('Override Ornament Restriction'),
('Allow Manual Jewel Pledge'),
('Approve Settlement Without Pawn Ticket');

--
-- Master table values for JewelDeductionTypeMaster
--
DELETE FROM JewelDeductionTypeMaster;
INSERT INTO JewelDeductionTypeMaster(name) VALUES
('Purity %'),
('Stone Weight %');

--

-- Master table values for ThirdPartyCategoryMaster
--
--
DELETE FROM ThirdPartyCategoryMaster;
INSERT INTO ThirdPartyCategoryMaster(name) VALUES
('Default Org'),
('Credit Bureau'),
('BC Bank/FI'),
('API Banking'),
('Mobile App'),
('Storage Server'),
('eKYC Vendor'),
('Bank Recon'),
('Bank Disbursement'),
('Tax Processing'),
('Insurance Company'),
('AWS Rekognition Service'),
('Payment Gateway'),
('Calling Gateway'),
('RPA Service'),
('Co-lender  Integeration'),
('SMS Service'),
('Decision Maker'),
('Automated Clearing'),
('Decision Maker'),
('Automated Clearing - Offline'),
('Verification & Validation'),
('SMS Service');

SELECT @cbCategoryId := id FROM ThirdPartyCategoryMaster WHERE name = 'Credit Bureau';
SELECT @bankingCategoryId := id FROM ThirdPartyCategoryMaster WHERE name = 'API Banking';
SELECT @mobAppCategoryId := id FROM ThirdPartyCategoryMaster WHERE name = 'Mobile App';
SELECT @paymentGatewayCategoryId := id FROM ThirdPartyCategoryMaster WHERE name = 'Payment Gateway';
SELECT @taxProcessingId := id FROM ThirdPartyCategoryMaster WHERE name = 'Tax Processing';
SELECT @insuranceCompanyId := id FROM ThirdPartyCategoryMaster WHERE name = 'Insurance Company';
SELECT @awsRekogService := id FROM ThirdPartyCategoryMaster WHERE name = 'AWS Rekognition Service';
SELECT @coLenderService := id FROM ThirdPartyCategoryMaster WHERE name = 'Co-lender  Integeration';
SELECT @callingGateway := id FROM ThirdPartyCategoryMaster WHERE name = 'Calling Gateway';
SELECT @rpaServiceId := id FROM ThirdPartyCategoryMaster WHERE name = 'RPA Service';
SELECT @autoMatedClearingId := id FROM ThirdPartyCategoryMaster WHERE name = 'Automated Clearing';
SELECT @autoMatedClearingOfflineId := id FROM ThirdPartyCategoryMaster WHERE name = 'Automated Clearing - Offline';
SELECT @bcBankServiceId := id FROM ThirdPartyCategoryMaster WHERE name = 'BC Bank/FI';
SELECT @decisionMakerId := id FROM ThirdPartyCategoryMaster WHERE name = 'Decision Maker';
SELECT @bankDisbId := id FROM ThirdPartyCategoryMaster WHERE name = 'Bank Disbursement';
SELECT @verificationServiceId := id FROM ThirdPartyCategoryMaster WHERE name = 'Verification & Validation';

-- Master table values for ThirdPartyMaster
--
DELETE FROM ThirdPartyMaster;
INSERT INTO ThirdPartyMaster(name,registered_address1, system_defined, category_id, is_enabled, code) VALUES
('Highmark', '', 1, @cbCategoryId, 1, 'HIM'),
('Equifax', '', 1, @cbCategoryId, 1, 'EQF'),
('CIBIL',  '', 1, @cbCategoryId, 1, 'CBL'),
('RBL Bank Limited',  '', 1, @bankingCategoryId, 1, 'RBL'),
('Axis Bank',  '', 1, @bankingCategoryId, 1, 'AXB'),
('HSBC BANK', '', 1, @bankingCategoryId, 1, 'HSB'),
('mShakti', '', 1, @mobAppCategoryId, 1, 'MSH'),
('Government I-T', '', 1, @taxProcessingId, 1,'GIT'),
('Kotak', '', 1, @insuranceCompanyId, 1, 'KOTAK'),
('Amazon Rekognition', '', 1, @awsRekogService, 0, 'AMREK'),
('AWS Detect Faces','', 1, @awsRekogService,0, 'AWSDT'),
('AWS Index Faces','', 1, @awsRekogService, 0, 'AWSIF'),
('AWS Delete Faces','', 1, @awsRekogService, 0, 'AWSDL'),
('AWS Search Faces By Image','', 1, @awsRekogService,0, 'AWSSI'),
('AWS Compare Faces', '', 1, @awsRekogService, 0, 'AWSCF'),
('FingPay', '', 1, @paymentGatewayCategoryId,1, 'FNP'),
('PayU', '', 1, @paymentGatewayCategoryId,0, ''),
('Sbi', '', 1, @paymentGatewayCategoryId,0, ''),
('Twinline','',1,@paymentGatewayCategoryId,1, ''),
('Letzpay Solution Private Limited','',1,@paymentGatewayCategoryId,0, ''),
('Knowlarity','',1,@callingGateway,0, 'KLRTY'),
('Bajaj Allianz General Insurance Claim','',1,@insuranceCompanyId,1,''),
('Cred Avenue','',1,@coLenderService,0, 'CRED'),
('Rezo ai','',1,@rpaServiceId,1,''),
('Kaleidofin','',1,@bcBankServiceId,1,'KAFIN'),
('NACH','',1,@autoMatedClearingOfflineId,0,'NACH'),
('StrategyOne','',1,@decisionMakerId,0,'S1'),
('Digio','',1,@bankingCategoryId,0,'Digio'),
('Bank of Baroda','',1,@bankDisbId,0,'BOB'),
('Sprint Verify','',1,@verificationServiceId,0,'Sprint'),
('MiddleWare S1','',1,@decisionMakerId,1,'MWS1'),
('BureauOne','',1,@cbCategoryId,0,'BR1'),
('Surepass CB','',1,@cbCategoryId,1,'SURPCB'),
('Surepass','',1,@verificationServiceId,1,'SURP'),
('UltraCash','',1,@paymentGatewayCategoryId,0,'ULCA');

SELECT @amazonRekognitionId := id FROM ThirdPartyMaster WHERE name= 'Amazon Rekognition';
SELECT @kotakInsuranceCompanyId := id FROM ThirdPartyMaster WHERE name = 'Kotak';
SELECT @twinlineId := id FROM ThirdPartyMaster WHERE name = 'Twinline';
SELECT @letzpayId := id FROM ThirdPartyMaster WHERE name = 'Letzpay Solution Private Limited';
SELECT @axisBankId := id FROM ThirdPartyMaster WHERE name = 'Axis Bank';
SELECT @rblId := id FROM ThirdPartyMaster WHERE name = 'RBL Bank Limited';
SELECT @kbajajInsuranceCompanyId := id FROM ThirdPartyMaster WHERE name = 'Bajaj Allianz General Insurance Claim';
SELECT @credAvenueId := id FROM ThirdPartyMaster WHERE name = 'Cred Avenue';
SELECT @payuId := id FROM ThirdPartyMaster WHERE name = 'PayU';
SELECT @digioId := id FROM ThirdPartyMaster WHERE name = 'Digio';
SELECT @sbiId := id FROM ThirdPartyMaster WHERE name = 'Sbi';
SELECT @sprintVerifyId := id FROM ThirdPartyMaster WHERE name = 'Sprint Verify';
SELECT @ultraCasId := id FROM ThirdPartyMaster WHERE name = 'UltraCash';

SELECT @knowlarityId := id FROM ThirdPartyMaster WHERE name = 'Knowlarity';
SELECT @rezoId := id FROM ThirdPartyMaster WHERE name = 'Rezo ai';
SELECT @kaleidofinId := id FROM ThirdPartyMaster WHERE name = 'Kaleidofin';
SELECT @strategyOneId := id FROM ThirdPartyMaster WHERE name = 'StrategyOne';
SELECT @middleWareS1Id := id FROM ThirdPartyMaster WHERE name= 'MiddleWare S1';
SELECT @sprintVerifyId := id FROM ThirdPartyMaster WHERE name= 'Sprint Verify';
SELECT @bureauOneId := id FROM ThirdPartyMaster WHERE name= 'BureauOne';
SELECT @surepassThirdPartyId := id FROM ThirdPartyMaster WHERE name = 'Surepass';

-- Master table values for NewThirdPartyServiceMaster
--
DELETE FROM NewThirdPartyServiceMaster;
INSERT INTO NewThirdPartyServiceMaster(third_party_id,name,is_active) VALUES
(@kotakInsuranceCompanyId, 'Send Loan Application', 1),
(@twinlineId, 'Loan Account Creation', 0),
(@twinlineId, 'QR Code Generation', 0),
(@twinlineId, 'Data Sending For SMS', 0),
(@twinlineId, 'Unsync Transaction', 0),
(@twinlineId, 'Track Transaction', 0),
(@twinlineId, 'Callback Payment', 0),
(@twinlineId, 'Twinline UPI Payment', 0),
(@letzpayId, 'Letzpay UPI Payment', 0),
(@axisBankId, 'Axis UPI Payment', 0),
(@rblId, 'RBL UPI Payment', 0),
(@amazonRekognitionId, 'Compare Faces', 0),
(@kbajajInsuranceCompanyId, 'Bajaj Claim Processing', 0),
(@credAvenueId, 'Cred Avenue Service', 0),
(@payuId, 'Bharat Bill Payment System (BBPS)', 0),
(@knowlarityId, 'Softphone Solution for Remote Calling', 0),
(@rezoId, 'RPA Web Service', 0),
(@digioId, 'Digio Debit Request', 0),
(@digioId, 'Digio Mandate Request', 0),
(@strategyOneId, 'S1 Decision Making', 0),
(@digioId, 'Enach Payment', 0),
(@middleWareS1Id, 'Middleware S1 Decision Making', 0),
(@sbiId, 'Bharat Bill Payment System (BBPS)', 0),
(@kaleidofinId, 'KiScore Service', 0),
(@sprintVerifyId, 'Sprint Verify', 0),
(@sprintVerifyId, 'Sprint Verify Penny Drop Verification', 0),
(@ultraCasId, 'UltraCash Service', 0),
(@axisBankId, 'Axis BBPS Payment', 0),
(@sprintVerifyId, 'Sprint Voter ID Verification', 0),
(@bureauOneId, 'BureauOne', 0),
(@surepassBankVerifyId, 'Surepass Bank Verification', 0);

SELECT @kotakServiceId := id FROM NewThirdPartyServiceMaster WHERE name = 'Send Loan Application';
SELECT @tlAccountServiceId := id FROM NewThirdPartyServiceMaster WHERE name = 'Loan Account Creation';
SELECT @tlQRServiceId := id FROM NewThirdPartyServiceMaster WHERE name = 'QR Code Generation';
SELECT @tlSmsId := id FROM NewThirdPartyServiceMaster WHERE name = 'Data Sending For SMS';
SELECT @tlUnsyncId := id FROM NewThirdPartyServiceMaster WHERE name = 'Unsync Transaction';
SELECT @tlTrackId := id FROM NewThirdPartyServiceMaster WHERE name = 'Track Transaction';
SELECT @tlCallbackId := id FROM NewThirdPartyServiceMaster WHERE name = 'Callback Payment';
SELECT @letzpayUPIPaymentId := id FROM NewThirdPartyServiceMaster WHERE name = 'Letzpay UPI Payment';
SELECT @axisUPIPaymentId := id FROM NewThirdPartyServiceMaster WHERE name = 'Axis UPI Payment';
SELECT @rblUpiPaymentId := id FROM NewThirdPartyServiceMaster WHERE third_party_id = @rblId AND name = 'RBL UPI Payment';
SELECT @rekogCompareFacesServiceId := id FROM NewThirdPartyServiceMaster WHERE third_party_id = @amazonRekgnitionId AND name = 'Compare Faces';
SELECT @bajajServiceId := id FROM NewThirdPartyServiceMaster WHERE name = 'Bajaj Claim Processing';
SELECT @credAvenueServiceId := id FROM NewThirdPartyServiceMaster WHERE third_party_id = @credAvenueId AND name = 'Cred Avenue Service';
SELECT @payuBBPSId := id FROM NewThirdPartyServiceMaster WHERE third_party_id = @payuId AND name = 'Bharat Bill Payment System (BBPS)';
SELECT @digioNachId := id FROM NewThirdPartyServiceMaster WHERE third_party_id = @digioId AND name = 'Enach Payment';
SELECT @digioDebitRequestId := id FROM NewThirdPartyServiceMaster WHERE third_party_id = @digioId AND name = 'Digio Debit Request';
SELECT @digioMandateRequestId := id FROM NewThirdPartyServiceMaster WHERE third_party_id = @digioId AND name = 'Digio Mandate Request';
SELECT @sbiBBPSId := id FROM NewThirdPartyServiceMaster WHERE third_party_id = @sbiId AND name = 'Bharat Bill Payment System (BBPS)';
SELECT @knowlarityCallId := id FROM NewThirdPartyServiceMaster WHERE third_party_id = @knowlarityId AND name = 'Softphone Solution for Remote Calling';
SELECT @rezoServiceId := id FROM NewThirdPartyServiceMaster WHERE third_party_id = @rezoId AND name = 'RPA Web Service';
SELECT @kiscoreServiceId := id FROM NewThirdPartyServiceMaster WHERE third_party_id = @kaleidofinId AND name = 'KiScore Service';
SELECT @strategyOneServiceId := id FROM NewThirdPartyServiceMaster WHERE third_party_id = @strategyOneId AND name = 'S1 Decision Making';
SELECT @sprintVerifyServiceId := id FROM NewThirdPartyServiceMaster WHERE third_party_id = @sprintVerifyId AND name = 'Sprint Verify OTP eKYC';
SELECT @sprintVerifyPennyServId := id FROM NewThirdPartyServiceMaster WHERE third_party_id = @sprintVerifyId AND name = 'Sprint Verify Penny Drop Verification';
SELECT @ultraCashServiceId := id FROM NewThirdPartyServiceMaster WHERE third_party_id = @ultraCasId AND name = 'UltraCash Service';
SELECT @axisBbpsPaymentId := id FROM NewThirdPartyServiceMaster WHERE third_party_id = @axisBankId AND name = 'Axis BBPS Payment';
SELECT @sprintVerifyVoterServId := id FROM NewThirdPartyServiceMaster WHERE third_party_id = @sprintVerifyId AND name = 'Sprint Voter ID Verification';
SELECT @bureauOneServId := id FROM NewThirdPartyServiceMaster WHERE third_party_id = @bureauOneId AND name = 'BureauOne';
SELECT @surepassBankVerifyServiceId := id FROM NewThirdPartyServiceMaster WHERE third_party_id = @surepassBankVerifyId AND name = 'Surepass Bank Verification';

--
-- Master table values for ThirdPartyServiceConfig
--
DELETE FROM ThirdPartyServiceConfig;
INSERT INTO ThirdPartyServiceConfig(service_id, name, value) VALUES
(@rekogCompareFacesServiceId, 'Similarity Threshold', 99);

-- Master table values for ThirdPartyRequestTypeMaster
--
DELETE FROM ThirdPartyRequestTypeMaster;
INSERT INTO ThirdPartyRequestTypeMaster(service_id,name,is_active) VALUES
(@kotakServiceId, 'Account Insurance', 1),
(@tlAccountServiceId, 'UPI-Account Creation', 0),
(@tlQRServiceId, 'UPI-Account QR Generation', 0),
(@tlSmsId, 'UPI-Account SMS Sending', 0),
(@tlUnsyncId, 'UPI-Unsync Transaction',0),
(@tlTrackId, 'UPI-Track Transaction', 0),
(@tlCallbackId, 'UPI-Callback Payment', 0),
(@letzpayUPIPaymentId, 'Customer QR Generation', 0),
(@letzpayUPIPaymentId, 'Static UPI QR Sale Callback', 0),
(@axisUPIPaymentId, 'Single Collect', 0),
(@axisUPIPaymentId, 'Validate VPA', 0),
(@axisUPIPaymentId, 'Check Transaction Status', 0),
(@axisUPIPaymentId, 'Callback', 0),
(@axisUPIPaymentId, 'QR Code', 0),
(@axisUPIPaymentId, 'MIS Report', 0),
(@rblUpiPaymentId, 'Channel Partner Login', 0),
(@rblUpiPaymentId, 'Generate Auth Token', 0),
(@rblUpiPaymentId, 'Get Txn ID', 0),
(@rblUpiPaymentId, 'Validate VPA', 0),
(@rblUpiPaymentId, 'Collect Money', 0),
(@rblUpiPaymentId, 'Transaction Re Query', 0),
(@rblUpiPaymentId, 'QR Code', 0),
(@rblUpiPaymentId, 'Callback', 0),
(@bajajServiceId, 'Claim Processing', 0),
(@bajajServiceId, 'Document Upload', 0),
(@bajajServiceId, 'Get Claim Status', 0),
(@payuBBPSId, 'Bill Fetch Receipt', 0),
(@payuBBPSId, 'Bill Payment Receipt', 0),
(@payuBBPSId, 'Payment Status', 0),
(@sbiBBPSId, 'Bill Fetch Receipt', 0),
(@sbiBBPSId, 'Bill Payment Receipt', 0),
(@sbiBBPSId, 'Payment Status', 0),
(@rblUpiPaymentId, 'MIS Report', 0),
(@credAvenueServiceId, 'Create Loan', 0),
(@credAvenueServiceId, 'Update Loan', 0),
(@credAvenueServiceId, 'Get Loan Details', 0),
(@credAvenueServiceId, 'Agreement Signed', 0),
(@credAvenueServiceId, 'Post disbursement', 0),
(@credAvenueServiceId, 'Update Disbursement', 0),
(@credAvenueServiceId, 'Create Repayment Schedule', 0),
(@credAvenueServiceId, 'Update Loan Status', 0),
(@credAvenueServiceId, 'Post Disbursement Details', 0),
(@knowlarityCallId, 'Make Outbound Call', 0),
(@kiscoreServiceId, 'CreditAnalytics', 0),
(@digioNachId, 'Callback', 0),
(@digioDebitRequestId, 'Single Debit Transaction', 0),
(@digioDebitRequestId, 'Multiple Debit Transaction', 0),
(@digioDebitRequestId, 'Get Debit Request Status', 0),
(@digioDebitRequestId, 'Update Debit Request Status', 0),
(@digioDebitRequestId, 'Get Single Debit Transaction Status', 0),
(@digioDebitRequestId, 'Get Scheduled Debit Transaction Status', 0),
(@digioDebitRequestId, 'Scheduled Debit Plan Action', 0),
(@strategyOneServiceId, 'Decision Making', 0),
(@strategyOneServiceId, 'MW Decision Making', 0),
(@digioMandateRequestId, 'Get Mandate Registration Data', 0),
(@kiscoreServiceId, 'Create Loan', 0),
(@kiscoreServiceId, 'Loan Documents Upload', 0),
(@kiscoreServiceId, 'KYC Documents Upload', 0),
(@sprintVerifyServiceId, 'EKYC Generate OTP', 0),
(@sprintVerifyServiceId, 'EKYC Validate OTP', 0),
(@sprintVerifyPennyServId, 'Penny Drop Verification', 0),
(@ultraCashServiceId, 'Pull Loan Details By Mobile No', 0),
(@ultraCashServiceId, 'Pull Loan Details By Account No', 0),
(@ultraCashServiceId, 'Push Payment Details', 0),
(@axisBbpsPaymentId, 'Fetch Bill Payment', 0),
(@axisBbpsPaymentId, 'Post Bill Payment', 0),
(@sprintVerifyVoterServId, 'Sprint Voter Id Verification', 0);
(@surepassBankVerifyServiceId, 'Surepass Bank Verification', 0);


SELECT @accountInsRequestTypeId := id FROM ThirdPartyRequestTypeMaster WHERE name = 'Account Insurance';
SELECT @tlAccountRequestTypeId := id FROM ThirdPartyRequestTypeMaster WHERE name = 'UPI-Account Creation';
SELECT @tlQrcodeRequestTypeId := id FROM ThirdPartyRequestTypeMaster WHERE name = 'UPI-Account QR Generation';
SELECT @tlSmsRequestTypeId := id FROM ThirdPartyRequestTypeMaster WHERE name = 'UPI-Account SMS Sending';
SELECT @tlUnsynTxnRequestTypeId := id FROM ThirdPartyRequestTypeMaster WHERE name = 'UPI-Unsync Transaction';
SELECT @tlTrackRequestTypeId := id FROM ThirdPartyRequestTypeMaster WHERE name = 'UPI-Track Transaction';
SELECT @tlCallbackRequestTypeId := id FROM ThirdPartyRequestTypeMaster WHERE name = 'UPI-Callback Payment';
SELECT @letzpayCallbackReqTypeId := id FROM ThirdPartyRequestTypeMaster WHERE service_id = letzpayUPIPaymentId AND name = 'Customer QR Generation';
SELECT @letzpayQrCodeReqTypeId := id FROM ThirdPartyRequestTypeMaster WHERE service_id = letzpayUPIPaymentId AND name = 'Static UPI QR Sale Callback';
SELECT @axisSingleCollectTypeId := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @axisUPIPaymentId AND name = 'Single Collect';
SELECT @axisValidateVPATypeId := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @axisUPIPaymentId AND name = 'Validate VPA';
SELECT @axisCheckTransactionTypeId := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @axisUPIPaymentId AND name = 'Check Transaction Status';
SELECT @axisCallbackTypeId := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @axisUPIPaymentId AND name = 'Callback';
SELECT @axisQRCodeId := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @axisUPIPaymentId AND name = 'QR Code';
SELECT @axisMisReportId := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @axisUPIPaymentId AND name = 'MIS Report';
SELECT @rblUpiCPLogin := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @rblUpiPaymentId AND name = 'Channel Partner Login';
SELECT @rblUpiGenAuthToken := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @rblUpiPaymentId AND name = 'Generate Auth Token';
SELECT @rblUpiGetTxnId := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @rblUpiPaymentId AND name = 'Get Txn ID';
SELECT @rblUpiValidateVPA := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @rblUpiPaymentId AND name = 'Validate VPA';
SELECT @rblUpiCollectMoney := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @rblUpiPaymentId AND name = 'Collect Money';
SELECT @rblUpiTxnReQuery := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @rblUpiPaymentId AND name = 'Transaction Re Query';
SELECT @rblUpiQRCode := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @rblUpiPaymentId AND name = 'QR Code';
SELECT @rblUpiCallback := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @rblUpiPaymentId AND name = 'Callback';

SELECT @bajajClaim := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @bajajServiceId AND name = 'Claim Processing';
SELECT @bajajDocUpload := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @bajajServiceId AND name = 'Document Upload';
SELECT @bajajClaimStatus := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @bajajServiceId AND name = 'Get Claim Status';

SELECT @payuBBPSBillFetch := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @payuBBPSId AND name = 'Bill Fetch Receipt';
SELECT @payuBBPSBillPayment := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @payuBBPSId AND name = 'Bill Payment Receipt';
SELECT @payuBBPSStatus := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @payuBBPSId AND name = 'Payment Status';

SELECT @sbiBBPSBillFetch := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @sbiBBPSId AND name = 'Bill Fetch Receipt';
SELECT @sbiBBPSBillPayment := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @sbiBBPSId AND name = 'Bill Payment Receipt';
SELECT @sbiBBPSStatus := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @sbiBBPSId AND name = 'Payment Status';

SELECT @rblUpiMisReport := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @rblUpiPaymentId AND name = 'MIS Report';

SELECT @credAvenueCreateLoan := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @credAvenueServiceId AND name = 'Create Loan';
SELECT @credAvenueUpdateLoan := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @credAvenueServiceId AND name = 'Update Loan';
SELECT @credAvenueGetLoan := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @credAvenueServiceId AND name = 'Get Loan Details';
SELECT @credAvenueAgrement := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @credAvenueServiceId AND name = 'Agreement Signed';
SELECT @credAvenuePostDisb := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @credAvenueServiceId AND name = 'Post disbursement';
SELECT @credAvenueUpdateDisb := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @credAvenueServiceId AND name = 'Update Disbursement';
SELECT @credAvenueRepayment := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @credAvenueServiceId AND name = 'Create Repayment Schedule';
SELECT @credAvenueUpdateStatus := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @credAvenueServiceId AND name = 'Update Loan Status';
SELECT @credAvenueDisbDetails := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @credAvenueServiceId AND name = 'Post Disbursement Details';
SELECT @makeOutboundCall := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @knowlarityCallId AND name = 'Make Outbound Call';
SELECT @creditAnalytics := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @kiscoreServiceId AND name = 'CreditAnalytics';
SELECT @kiCredit := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @kiscoreServiceId AND name = 'Create Loan';
SELECT @KiLoanDocs := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @kiscoreServiceId AND name = 'Loan Documents Upload';
SELECT @KiKYCDocs := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @kiscoreServiceId AND name = 'KYC Documents Upload';

-- 
-- Digio request type ids
--
SELECT @singleDebitTxnId := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @digioDebitRequestId AND name = 'Single Debit Transaction';
SELECT @multipleDebitTxnId := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @digioDebitRequestId AND name = 'Multiple Debit Transaction';
SELECT @schdDebitActionStatusId := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @digioDebitRequestId AND name = 'Scheduled Debit Plan Action';
SELECT @mandateRegStatusId := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @digioMandateRequestId AND name = 'Get Mandate Registration Data';
SELECT @generateReqTypeId := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @sprintVerifyServiceId AND name = 'EKYC Generate OTP';
SELECT @validateReqTypeId := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @sprintVerifyServiceId AND name = 'EKYC Validate OTP';
SELECT @sVPennyDropId := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @sprintVerifyPennyServId AND name = 'Penny Drop Verification';
SELECT @ulPullLoanByAccount := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @ultraCashServiceId AND name = 'Pull Loan Details By Account No';
SELECT @ulPullLoanByContact := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @ultraCashServiceId AND name = 'Pull Loan Details By Mobile No';
SELECT @ulPushPayment := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @ultraCashServiceId AND name = 'Push Payment Details';
SELECT @fetchBillPayment := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @axisBbpsPaymentId AND name = 'Fetch Bill Payment';
SELECT @pushBillPayment := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @axisBbpsPaymentId AND name = 'Post Bill Payment';
SELECT @voterIdReqTypeId := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @sprintVerifyServiceId AND name = 'Sprint Voter Id Verification';
SELECT @surepassBankReqTypeId := id FROM ThirdPartyRequestTypeMaster WHERE service_id = @surepassBankVerifyServiceId AND name = 'Surepass Bank Verification';

-- Master table values for ThirdPartyRequestStatusMaster
--
DELETE FROM ThirdPartyRequestStatusMaster;
INSERT INTO ThirdPartyRequestStatusMaster(name,request_type_id, is_active) VALUES
('New',@accountInsRequestTypeId, 1),
('Approved',@accountInsRequestTypeId, 1),
('Ready to Send',@accountInsRequestTypeId, 1),
('Sent',@accountInsRequestTypeId, 1),
('Failed',@accountInsRequestTypeId, 1),
('Success',@accountInsRequestTypeId, 1),
('COI New',@accountInsRequestTypeId, 1),
('COI Passed',@accountInsRequestTypeId, 1),

('New',@tlAccountRequestTypeId, 0),
('Under Process',@tlAccountRequestTypeId, 0),
('Success',@tlAccountRequestTypeId, 0),
('Failed',@tlAccountRequestTypeId, 0),

('New',@tlQrcodeRequestTypeId, 0),
('Under Process',@tlQrcodeRequestTypeId, 0),
('QR Received',@tlQrcodeRequestTypeId, 0),
('QR Not Received',@tlQrcodeRequestTypeId, 0),

('New',@tlSmsRequestTypeId, 0),
('Under Process',@tlSmsRequestTypeId, 0),
('Success',@tlSmsRequestTypeId, 0),
('Failed',@tlSmsRequestTypeId, 0),

('New',@tlUnsynTxnRequestTypeId, 0),
('Under Process',@tlUnsynTxnRequestTypeId, 0),
('Success',@tlUnsynTxnRequestTypeId, 0),
('Failed',@tlUnsynTxnRequestTypeId, 0),

('New',@tlTrackRequestTypeId, 0),
('Under Process',@tlTrackRequestTypeId, 0),
('Success',@tlTrackRequestTypeId, 0),
('Failed',@tlTrackRequestTypeId, 0),

('New',@tlCallbackRequestTypeId, 0),
('Under Process',@tlCallbackRequestTypeId, 0),
('Success',@tlCallbackRequestTypeId, 0),
('Failed',@tlCallbackRequestTypeId, 0),

('Success', @letzpayCallbackReqTypeId, 1),
('Failed', @letzpayCallbackReqTypeId, 1),
('Unknown', @letzpayCallbackReqTypeId, 1),

('New', @letzpayQrCodeReqTypeId, 1),
('Under Process', @letzpayQrCodeReqTypeId, 1),
('Success', @letzpayQrCodeReqTypeId, 1),
('Failed', @letzpayQrCodeReqTypeId, 1),
('Unknown', @letzpayQrCodeReqTypeId, 1),

('Initiated', @axisSingleCollectTypeId, 0),
('Success', @axisSingleCollectTypeId, 0),
('Failed', @axisSingleCollectTypeId, 0),
('Expired', @axisSingleCollectTypeId, 0),
('Rejected', @axisSingleCollectTypeId, 0),
('Under Process', @axisSingleCollectTypeId, 0),
('Pending', @axisSingleCollectTypeId, 0),
('Unknown', @axisSingleCollectTypeId, 0),

('Success', @axisCallbackTypeId, 0),
('Failed', @axisCallbackTypeId, 0),
('Expired', @axisCallbackTypeId, 0),
('Rejected', @axisCallbackTypeId, 0),
('Pending', @axisCallbackTypeId, 0),
('Unknown', @axisCallbackTypeId, 0),

('Success', @axisCheckTransactionTypeId, 0),
('Failed', @axisCheckTransactionTypeId, 0),
('Expired', @axisCheckTransactionTypeId, 0),
('Rejected', @axisCheckTransactionTypeId, 0),
('Pending', @axisCheckTransactionTypeId, 0),
('Under Process', @axisCheckTransactionTypeId, 0),
('Unknown', @axisCheckTransactionTypeId, 0),

('Initiated', @axisQRCodeId, 1),
('Success', @axisQRCodeId, 1),
('Failed', @axisQRCodeId, 1),
('Unknown', @axisQRCodeId, 1),

('Success', @axisMisReportId, 1),
('Failed', @axisMisReportId, 1),
('Unknown', @axisMisReportId, 1),

('Success', @axisValidateVPATypeId, 1),
('Failed', @axisValidateVPATypeId, 1),

('Success', @rblUpiCPLogin, 1),
('Failed', @rblUpiCPLogin, 1),
('Success', @rblUpiGenAuthToken, 1),
('Failed', @rblUpiGenAuthToken, 1),
('Success', @rblUpiGetTxnId, 1),
('Failed', @rblUpiGetTxnId, 1),
('Success', @rblUpiValidateVPA, 1),
('Failed', @rblUpiValidateVPA, 1),
('Initiated', @rblUpiCollectMoney, 1),
('Success', @rblUpiCollectMoney, 1),
('Failed', @rblUpiCollectMoney, 1),
('Success', @rblUpiTxnReQuery, 1),
('Under Process', @rblUpiTxnReQuery, 1),
('Failed', @rblUpiTxnReQuery, 1),
('Unknown', @rblUpiTxnReQuery, 1),
('Success', @rblUpiQRCode, 1),
('Failed', @rblUpiQRCode, 1),
('Unknown', @rblUpiQRCode, 1),
('Initiated', @rblUpiQRCode, 1),
('Success', @rblUpiCallback, 1),
('Failed', @rblUpiCallback, 1),
('Unknown', @rblUpiCallback, 1),
('Success', @bajajClaim, 1),
('Rejected', @bajajClaim, 1),
('Ready to Send', @bajajClaim, 1),
('Success', @bajajDocUpload, 1),
('Rejected', @bajajDocUpload, 1),
('Ready to Send', @bajajDocUpload, 1),
('Success', @bajajClaimStatus, 1),
('Rejected', @bajajClaimStatus, 1),
('Ready to Send', @bajajClaimStatus, 1),
('Failed', @payuBBPSBillFetch, 1),
('Success', @payuBBPSBillFetch, 1),
('Failed', @payuBBPSBillPayment, 1),
('Success', @payuBBPSBillPayment, 1),
('Under Process', @payuBBPSBillPayment, 1),
('Failed', @payuBBPSStatus, 1),
('Success', @payuBBPSStatus, 1),
('Failed', @sbiBBPSBillFetch, 1),
('Success', @sbiuBBPSBillFetch, 1),
('Failed', @sbiBBPSBillPayment, 1),
('Success', @sbiBBPSBillPayment, 1),
('Under Process', @sbiBBPSBillPayment, 1),
('Failed', @sbiBBPSStatus, 1),
('Success', @sbiBBPSStatus, 1),
('Success', @rblUpiMisReport, 1),
('Failed', @rblUpiMisReport, 1),
('Unknown', @rblUpiMisReport, 1),
('Success', @credAvenueCreateLoan, 1),
('Failed', @credAvenueCreateLoan, 1),
('Success', @credAvenueUpdateLoan, 1),
('Failed', @credAvenueUpdateLoan, 1),
('Success', @credAvenueGetLoan, 1),
('Failed', @credAvenueGetLoan, 1),
('Success', @credAvenueAgrement, 1),
('Failed', @credAvenueAgrement, 1),
('Success', @credAvenuePostDisb, 1),
('Failed', @credAvenuePostDisb, 1),
('Success', @credAvenueUpdateDisb, 1),
('Failed', @credAvenueUpdateDisb, 1),
('Success', @credAvenueRepayment, 1),
('Failed', @credAvenueRepayment, 1),
('Success', @credAvenueUpdateStatus, 1),
('Failed', @credAvenueUpdateStatus, 1),
('Success', @credAvenueDisbDetails, 1),
('Failed', @credAvenueDisbDetails, 1),
('Failed', @makeOutboundCall, 1),
('Success', @makeOutboundCall, 1),
('Accept', @creditAnalytics, 1),
('Reject', @creditAnalytics, 1),
('Success', @singleDebitTxnId, 1),
('Failed', @singleDebitTxnId, 1),
('Success', @multipleDebitTxnId, 1),
('Failed', @multipleDebitTxnId, 1),
('Success', @schdDebitActionStatusId, 1),
('Failed', @schdDebitActionStatusId, 1),
('Success', @mandateRegStatusId, 1),
('Failed', @mandateRegStatusId, 1),
('Accept', @kiCredit, 1),
('Reject', @kiCredit, 1),
('Accept', @KiLoanDocs, 1),
('Reject', @KiLoanDocs, 1),
('Accept', @KiKYCDocs, 1),
('Reject', @KiKYCDocs, 1),
('Failed', @generateReqTypeId, 1),
('Success', @generateReqTypeId, 1),
('Failed', @validateReqTypeId, 1),
('Success', @validateReqTypeId, 1),
('Under Process', @sVPennyDropId, 1),
('Failed', @sVPennyDropId, 1),
('Passed', @sVPennyDropId, 1),
('Success', @ulPullLoanByAccount, 1),
('Failed', @ulPullLoanByAccount, 1),
('Success', @ulPullLoanByContact, 1),
('Failed', @ulPullLoanByContact, 1),
('Success', @ulPushPayment, 1),
('Failed', @ulPushPayment, 1),
('Under Process', @ulPushPayment, 1),
('Success', @fetchBillPayment, 1),
('Failed', @fetchBillPayment, 1),
('Success', @pushBillPayment, 1),
('Failed', @pushBillPayment, 1),
('Under Process', @pushBillPayment, 1),
('Success', @voterIdReqTypeId, 1),
('Failed', @voterIdReqTypeId, 1),
('Success', @surepassBankReqTypeId, 1),
('Failed', @surepassBankReqTypeId, 1);

SELECT @highmarkThirdPartyId := id FROM ThirdPartyMaster WHERE name = 'Highmark';
SELECT @equifaxThirdPartyId := id FROM ThirdPartyMaster WHERE name = 'Equifax';
SELECT @cibilThirdPartyId := id FROM ThirdPartyMaster WHERE name = 'CIBIL';
SELECT @surepassCbThirdPartyId := id FROM ThirdPartyMaster WHERE name = 'Surepass CB';

--
-- Master table values for CreditBureauRequestTypeMaster
--
DELETE FROM CreditBureauRequestTypeMaster;
INSERT INTO CreditBureauRequestTypeMaster(third_party_master_id, name) VALUES
(@highmarkThirdPartyId, 'Submit'),
(@highmarkThirdPartyId, 'Issue'),
(@highmarkThirdPartyId, 'Force New'),
(@highmarkThirdPartyId, 'Re-issue'),
(@highmarkThirdPartyId, 'Update'),
(@highmarkThirdPartyId, 'Upgrade'),
(@highmarkThirdPartyId, 'Status Update'),
(@equifaxThirdPartyId, 'Offline'),
(@equifaxThirdPartyId, 'Submit'),
(@cibilThirdPartyId, 'Submit'),
(@cibilThirdPartyId, 'Offline'),
(@bureauOneId, 'Offline'),
(@bureauOneId, 'Submit'),
(@surepassCbThirdPartyId, 'Submit'),
(@surepassCbThirdPartyId, 'Offline');

-- Setting master values in variables for downstream usage
--
SELECT @submitHmCBRequestTypeId := id FROM CreditBureauRequestTypeMaster WHERE third_party_master_id = @highmarkThirdPartyId AND name = 'Submit';
SELECT @issueHmCBRequestTypeId := id FROM CreditBureauRequestTypeMaster WHERE third_party_master_id = @highmarkThirdPartyId AND name = 'Issue';
SELECT @forceNewHmCBRequestTypeId := id FROM CreditBureauRequestTypeMaster WHERE third_party_master_id = @highmarkThirdPartyId AND name = 'Force New';
SELECT @reissueHmCBRequestTypeId := id FROM CreditBureauRequestTypeMaster WHERE third_party_master_id = @highmarkThirdPartyId AND name = 'Re-issue';
SELECT @updateHmCBRequestTypeId := id FROM CreditBureauRequestTypeMaster WHERE third_party_master_id = @highmarkThirdPartyId AND name = 'Update';
SELECT @upgradeHmCBRequestTypeId := id FROM CreditBureauRequestTypeMaster WHERE third_party_master_id = @highmarkThirdPartyId AND name = 'Upgrade';
SELECT @statusUpdateHmCBRequestTypeId := id FROM CreditBureauRequestTypeMaster WHERE third_party_master_id = @highmarkThirdPartyId AND name = 'Status Update';

SELECT @offlineEqCBRequestTypeId := id FROM CreditBureauRequestTypeMaster WHERE third_party_master_id = @equifaxThirdPartyId AND name = 'Offline';
SELECT @submitEqCBRequestTypeId := id FROM CreditBureauRequestTypeMaster WHERE third_party_master_id = @equifaxThirdPartyId AND name = 'Submit';
SELECT @offlineB1CBRequestTypeId := id FROM CreditBureauRequestTypeMaster WHERE third_party_master_id = @bureauOneId AND name = 'Offline';
SELECT @submitB1CBRequestTypeId := id FROM CreditBureauRequestTypeMaster WHERE third_party_master_id = @bureauOneId AND name = 'Submit';

SELECT @offlineSurepassTypeId := id FROM CreditBureauRequestTypeMaster WHERE third_party_master_id = @surepassCbThirdPartyId AND name = 'Offline';
SELECT @submitSurepassTypeId := id FROM CreditBureauRequestTypeMaster WHERE third_party_master_id = @surepassCbThirdPartyId AND name = 'Submit';

SELECT @submitCibilCBRequestTypeId := id FROM CreditBureauRequestTypeMaster WHERE third_party_master_id = @cibilThirdPartyId AND name = 'Submit';
SELECT @offlineCibilCBRequestTypeId := id FROM CreditBureauRequestTypeMaster WHERE third_party_master_id = @cibilThirdPartyId AND name = 'Offline';

--
-- Master table values for `CreditBureauRequestStatusMaster`
--
INSERT INTO CreditBureauRequestStatusMaster(request_type_id, name, is_active, is_internal) VALUES
(@submitHmCBRequestTypeId, 'New', 1, 0),
(@submitHmCBRequestTypeId, 'Error', 1, 0),
(@submitHmCBRequestTypeId, 'Acknowledged', 1, 0),
(@submitHmCBRequestTypeId, 'Received', 1, 0),
(@submitHmCBRequestTypeId, 'Report Error', 1, 0),
(@submitHmCBRequestTypeId, 'Ready For Enquiry', 1, 1),
(@submitHmCBRequestTypeId, 'In Progress', 1, 1),
(@submitHmCBRequestTypeId, 'Offline Done', 1, 1),
(@issueHmCBRequestTypeId, 'Ready For Enquiry', 1, 1),
(@issueHmCBRequestTypeId, 'In Progress', 1, 1),
(@issueHmCBRequestTypeId, 'Offline Done', 1, 1),
(@issueHmCBRequestTypeId, 'Error', 1, 0),
(@issueHmCBRequestTypeId, 'Acknowledged', 1, 0),
(@issueHmCBRequestTypeId, 'Received', 1, 0),
(@issueHmCBRequestTypeId, 'Report Error', 1, 0),
(@forceNewHmCBRequestTypeId, 'Ready For Enquiry', 1, 1),
(@forceNewHmCBRequestTypeId, 'In Progress', 1, 1),
(@forceNewHmCBRequestTypeId, 'Offline Done', 1, 1),
(@forceNewHmCBRequestTypeId, 'Error', 1, 0),
(@forceNewHmCBRequestTypeId, 'Acknowledged', 1, 0),
(@forceNewHmCBRequestTypeId, 'Received', 1, 0),
(@forceNewHmCBRequestTypeId, 'Report Error', 1, 0),
(@reissueHmCBRequestTypeId, 'Ready For Enquiry', 1, 1),
(@reissueHmCBRequestTypeId, 'In Progress', 1, 1),
(@reissueHmCBRequestTypeId, 'Offline Done', 1, 1),
(@reissueHmCBRequestTypeId, 'Error', 1, 0),
(@reissueHmCBRequestTypeId, 'Acknowledged', 1, 0),
(@reissueHmCBRequestTypeId, 'Received', 1, 0),
(@reissueHmCBRequestTypeId, 'Report Error', 1, 0),
(@updateHmCBRequestTypeId, 'Ready For Enquiry', 1, 1),
(@updateHmCBRequestTypeId, 'In Progress', 1, 1),
(@updateHmCBRequestTypeId, 'Offline Done', 1, 1),
(@updateHmCBRequestTypeId, 'Error', 1, 0),
(@updateHmCBRequestTypeId, 'Acknowledged', 1, 0),
(@updateHmCBRequestTypeId, 'Received', 1, 0),
(@updateHmCBRequestTypeId, 'Report Error', 1, 0),
(@upgradeHmCBRequestTypeId, 'Ready For Enquiry', 1, 1),
(@upgradeHmCBRequestTypeId, 'In Progress', 1, 1),
(@upgradeHmCBRequestTypeId, 'Offline Done', 1, 1),
(@upgradeHmCBRequestTypeId, 'Error', 1, 0),
(@upgradeHmCBRequestTypeId, 'Acknowledged', 1, 0),
(@upgradeHmCBRequestTypeId, 'Received', 1, 0),
(@upgradeHmCBRequestTypeId, 'Report Error', 1, 0),
(@statusUpdateHmCBRequestTypeId, 'Ready For Enquiry', 1, 1),
(@statusUpdateHmCBRequestTypeId, 'In Progress', 1, 1),
(@statusUpdateHmCBRequestTypeId, 'Offline Done', 1, 1),
(@statusUpdateHmCBRequestTypeId, 'Error', 1, 0),
(@statusUpdateHmCBRequestTypeId, 'Acknowledged', 1, 0),
(@statusUpdateHmCBRequestTypeId, 'Received', 1, 0),
(@statusUpdateHmCBRequestTypeId, 'Report Error', 1, 0),
(@submitEqCBRequestTypeId, 'New', 1, 0),
(@submitEqCBRequestTypeId, 'Error', 1, 0),
(@submitEqCBRequestTypeId, 'Report Not Ready', 1, 0),
(@submitEqCBRequestTypeId, 'Received', 1, 0),
(@submitEqCBRequestTypeId, 'Report Error', 1, 0),
(@submitEqCBRequestTypeId, 'Acknowledged', 1, 0),
(@offlineEqCBRequestTypeId, 'In Progress', 1, 1),
(@offlineEqCBRequestTypeId, 'Offline Done', 1, 1),
(@offlineEqCBRequestTypeId, 'Ready For Enquiry', 1, 1),
(@submitCibilCBRequestTypeId, 'New', 1, 0),
(@submitCibilCBRequestTypeId, 'Error', 1, 0),
(@submitCibilCBRequestTypeId, 'Received', 1, 0),
(@submitCibilCBRequestTypeId, 'Report Error', 1, 0),
(@offlineCibilCBRequestTypeId, 'Ready For Enquiry', 1, 0),
(@offlineCibilCBRequestTypeId, 'In Progress', 1, 0),
(@offlineCibilCBRequestTypeId, 'Offline Done', 1, 0),
(@submitB1CBRequestTypeId, 'New', 1, 0),
(@submitB1CBRequestTypeId, 'Error', 1, 0),
(@submitB1CBRequestTypeId, 'Received', 1, 0),
(@submitB1CBRequestTypeId, 'Report Error', 1, 0),
(@offlineB1CBRequestTypeId, 'In Progress', 1, 1),
(@offlineB1CBRequestTypeId, 'Offline Done', 1, 1),
(@offlineB1CBRequestTypeId, 'Ready For Enquiry', 1, 1),
(@offlineSurepassTypeId, 'New', 1, 1),
(@offlineSurepassTypeId, 'Error', 1, 1),
(@offlineSurepassTypeId, 'Report Error', 1, 1),
(@offlineSurepassTypeId, 'Received', 1, 1),
(@submitSurepassTypeId, 'Ready For Enquiry', 1, 1),
(@submitSurepassTypeId, 'In Progress', 1, 1),
(@submitSurepassTypeId, 'Offline Done', 1, 1);

--
-- Master table values for CreditBureauStatusMaster
--
DELETE FROM CreditBureauStatusMaster;
INSERT INTO CreditBureauStatusMaster(name, is_active, third_party_id) VALUES
('Ready For Enquiry', 0, @highmarkThirdPartyId),
('In Progress', 0, @highmarkThirdPartyId),
('Positive', 1, @highmarkThirdPartyId),
('Negative', 1, @highmarkThirdPartyId),
('Positive', 1, @equifaxThirdPartyId),
('Negative', 1, @equifaxThirdPartyId),
('None', 1, @equifaxThirdPartyId),
('Positive', 1, @cibilThirdPartyId),
('Negative', 1, @cibilThirdPartyId),
('Positive', 1, @bureauOneId),
('Negative', 1, @bureauOneId),
('None', 1, @bureauOneId);

--
-- Master table values for ReportFieldOperatorMaster
--
DELETE FROM ReportFieldOperatorMaster;
INSERT INTO ReportFieldOperatorMaster(name) VALUES
('='),
('!='),
('<'),
('>'),
('<='),
('>='),
('in'),
('not in'),
('between'),
('list between'),
('bucket');

-- Setting variables for all ReportFieldOperatorMaster entries to be used as FK in other tables
--
SELECT @equalsOperatorId := id FROM ReportFieldOperatorMaster WHERE name = "=";
SELECT @notEqualsOperatorId := id FROM ReportFieldOperatorMaster WHERE name = "!=";
SELECT @lesserOperatorId := id FROM ReportFieldOperatorMaster WHERE name = "<";
SELECT @greaterOperatorId := id FROM ReportFieldOperatorMaster WHERE name = ">";
SELECT @lesserEqualOperatorId := id FROM ReportFieldOperatorMaster WHERE name = "<=";
SELECT @greaterEqualOperatorId := id FROM ReportFieldOperatorMaster WHERE name = ">=";
SELECT @inOperatorId := id FROM ReportFieldOperatorMaster WHERE name = "in";
SELECT @betweenOperatorId := id FROM ReportFieldOperatorMaster WHERE name = "between";
SELECT @listBetweenOperatorId := id FROM ReportFieldOperatorMaster WHERE name = "list between";
SELECT @bucketOperatorId := id FROM ReportFieldOperatorMaster WHERE name = "bucket";

--
-- Master table values for ReportDataTypeMaster
--
DELETE FROM ReportDataTypeMaster;
INSERT INTO ReportDataTypeMaster(name) VALUES
('Aggregation'),
('Bucket'),
('Daily Data'),
('Cumulative Data'),
('Par Cumulative Data'),
('Internal Derived Data'),
('Current Stat Data');

-- Setting variables for all ReportDataTypeMaster entries to be used as FK in other tables
--
SELECT @dataTypeAggregationId := id FROM ReportDataTypeMaster WHERE name = "Aggregation";
SELECT @dataTypeBucketId := id FROM ReportDataTypeMaster WHERE name = "Bucket";
SELECT @dataTypeDailyDataId := id FROM ReportDataTypeMaster WHERE name = "Daily Data";
SELECT @dataTypeCumulativeDataId := id FROM ReportDataTypeMaster WHERE name = "Cumulative Data";
SELECT @dataTypeParCumulativeDataId := id FROM ReportDataTypeMaster WHERE name = "Par Cumulative Data";
SELECT @dataTypeCurrentStatDataId := id FROM ReportDataTypeMaster WHERE name = "Current Stat Data";
SELECT @internalDerivedData := id FROM ReportDataTypeMaster WHERE name = "Internal Derived Data";

--
-- Master table values for ReportRuleOperatorMaster
--
DELETE FROM ReportRuleOperatorMaster;
INSERT INTO ReportRuleOperatorMaster(name) VALUES
('AND'),
('OR');

--
-- Master table values for Report
--
DELETE FROM Report;
INSERT INTO Report(name, description, static_date_flag, num_aggregations, num_buckets, show_filters, show_groups, show_output_views, show_start_date, show_suppress_value, system_defined) VALUES
("Qbe", "Qbe", 0, 2,2, 1, 1, 1, 1, 1,1),
("Account Qbe", "Account Qbe", 0, 2,2, 1, 0, 1, 1, 1, 1),
("Demand Collection", "Demand Collection", 0, 2,2,1, 1, 0, 1, 0, 1),
("Portfolio Outstandings", "Portfolio Outstandings", 0, 2,2, 1, 1, 0, 1, 0, 1),
("Loan Disbursements", "Loan Disbursements", 0,2,2, 1, 1, 0, 1, 0, 1),
("Portfolio At Risk(PAR)", "Portfolio At Risk(PAR)", 0, 2,2, 1, 1, 0, 0, 1, 1),
("Pipeline Qbe", "Pipeline Qbe", 0, 2,2, 1, 1, 1, 1, 1, 1),
("HighMark Weekly Report (Group Loan)", "HighMark Weekly Report (Group Loan)", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("HighMark Monthly Report (Group Loan)", "HighMark Monthly Report (Group Loan)", 1, 0, 0,  0, 0, 0, 0, 0, 1),
("Static Pool Data (Compressed)", "Static pool data without repayment schedules", 1, 0, 0, 0, 0, 0, 0, 0, 1),
("Static Pool Data (Compressed) (Light)", "Lighter version of Compressed Static Pool Data", 1, 0, 0, 0, 0, 0, 0, 0, 1),
("Static Pool Data", "Static pool data with repayment schedules", 1, 0, 0, 0, 0, 0, 0, 0, 1),
("BC Inception Pool Data (Compressed)", "Static pool data for closed loans", 1, 0, 0, 0, 0, 0, 0, 0, 1),
("Future Demand Summary", "Future Demand Summary", 3, 0, 0, 0, 0, 0, 0, 0, 1),
("Date Wise Future Demand Summary", "Date wise Future Demand Summary", 3, 0, 0, 0, 0, 0, 0, 0, 1),
("Customer Drop-out Report", "Report of closed loans over a date range and another loan disbursed, if any", 3, 0, 0, 0, 0, 0, 0, 0, 1),
("Center Meeting Report", "Details of center meeting schedules", 1, 0, 0, 0, 0, 0, 0, 0, 1),
("Center Master Report", "Center Master Report", 1, 0, 0, 0, 0, 0, 0, 0, 1),
("Hidden Delinquency Report", "Details of payments by borrower and group/guarantor", 2, 0, 0, 0, 0, 0, 0, 0, 1),
("Customer Household Information", "List of customers, their demographics and household information", 3, 0, 0, 0, 0, 0, 0, 0, 1),
("KPMG Report", "KPMG loan data in pre-defined format", 5, 0, 0, 0, 0, 0, 0, 0, 1),
("M-CRIL Loan Report", "M-CRIL loan data in pre-defined format", 5, 0, 0, 0, 0, 0, 0, 0, 1),
("M-CRIL Center Report", "M-CRIL center data in pre-defined format", 5, 0, 0, 0, 0, 0, 0, 0, 1),
("Loan Write-off Report", "Report of all loans written-off over the period", 3, 0, 0, 0, 0, 0, 0, 0, 1),
("Social Performance Report", "Customer-wise social performance report", 3, 0, 0, 0, 0, 0, 0, 0, 1),
("Customer PPI Report", "PPI data for all customers", 3, 0, 0, 0, 0, 0, 0, 0, 1),
("Loan PPI Report", "PPI data for all loan customers", 3, 0, 0, 0, 0, 0, 0, 0, 1),
("Customer Bank Account Report", "Bank account details for customers and guarantors", 2, 0, 0, 0, 0, 0, 0,0, 1),
("Interest Accured Not Due Report", "Interest Accured Not Due Report", 1, 0, 0, 0, 0, 0, 0, 0, 1),
("Periodic Alerts", "Periodic Alerts", 0, 0, 0, 0, 0, 0, 0, 0, 1),
("Loan Collection And Balances", "Loan Collection And Balances", 0, 1, 0, 1, 0, 0, 1, 0, 1),
("On Hold Alert", "Pipeline On Hold Alert", 0, 0, 0, 0, 0, 0, 0, 0, 1),
("SANCTION Alert", "SANCTION Alert", 0, 0, 0, 0, 0, 0, 0, 0, 1),
("Confirm EOD Completion Alert", "Confirm EOD Completion Alert", 0, 0, 0, 0, 0, 0, 0, 0, 1),
("Pipeline Status Update Alert", "Pipeline Status Update Alert", 0, 0, 0, 0, 0, 0, 0, 0, 1),
("Future Cash In-Flow", "Future Cash In-Flow", 0, 2,2, 1, 1, 0, 0, 1, 1),
("Mudra Submission Report", "Mudra Submission Report", 0, 2,2, 1, 1, 0, 0, 0, 1),
("Book Debt Report", "Book Debt Report", 0, 0, 0, 1, 0, 1, 0, 0, 1),
("Loan-wise Portfolio (Funding Sources)", "Loan-wise Portfolio (Funding Sources)", 0, 0, 0, 1, 0, 1, 0, 0, 1),
("Management Report", "Management Report", 0, 2,2, 1, 1, 0, 1, 0, 1),
("Portfolio Reconciliation Report", "Portfolio Reconciliation Report", 0, 2,2, 1, 1, 0, 1, 0, 1),
("HighMark Weekly Report (3 files)", "HighMark Weekly Report (3 files)", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("HighMark Monthly Report (3 files)", "HighMark Monthly Report (3 files)", 1, 0, 0, 0, 0, 0, 0, 0, 1),
("Client Wise CAD Report", "Client Wise CAD Report", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Collection Report", "Collection Report", 0, 1, 1, 1, 1, 0, 1, 0, 1),
("Customer Collection Alert", "Customer Collection Alert", 0, 0, 0, 0, 0, 0, 0, 0, 1),
("Loan Account Approval Alert", "Loan Account Approval Alert", 0, 0, 0, 0, 0, 0, 0, 0, 1),
("Interest Accrual/Income Report", "Interest Accrual/Income Report", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("HighMark Monthly Report (3 files) (Individual Loan)", "HighMark Monthly Report (3 files) (Individual Loan)", 1, 0, 0, 0, 0, 0, 0, 0, 1),
("HighMark Weekly Report (3 files) (Individual Loan)", "HighMark Weekly Report (3 files) (Individual Loan)", 2, 0, 0, 0, 0, 0, 0, 0, 1),
("HighMark Monthly Report (Individual Loan)", "HighMark Monthly Report (Individual Loan)", 1, 0, 0, 0, 0, 0, 0, 0, 1),
("HighMark Weekly Report (Individual Loan)", "HighMark Weekly Report (Individual Loan)", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Overdue Report", "Overdue Report", 1, 0, 0, 0, 0, 0, 0, 0, 1),
("Equifax Weekly Report (3 files)", "Equifax Weekly Report (3 files)", 2, 0, 0, 0, 0, 0, 0, 0, 1),
("Attendance Report Loan Wise (Installment Based)", "Attendance Report Loan Wise (Installment Based)", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Equifax Monthly Report (3 files)", "Equifax Monthly Report (3 files)", 1, 0, 0, 0, 0, 0, 0, 0, 1),
("Pipeline Status Upcoming Alert", "Pipeline Status Upcoming Alert", 0, 0, 0, 0, 0, 0, 0, 0, 1),
("Report Rule Set", "Report Rule Set", 0, 0, 0, 0, 0, 0, 0, 0, 1),
("Officer Allocation Type", "Officer Allocation Type", 0, 0, 0, 0, 0, 0, 0, 0, 1),
("Stationery Receipt Cancel Alert", "Stationery Receipt Cancel Alert", 0, 0, 0, 0, 0, 0, 0, 0, 1),
("Bene Validation Failure Alert", "Bene Validation Failure Alert", 0, 0, 0, 0, 0, 0, 0, 0, 1),
("ECS Transfer Failure Alert", "ECS Transfer Failure Alert", 0, 0, 0, 0, 0, 0, 0, 0, 1),
("View Loan Payments (With Input Filters)", "View Loan Payments (With Input Filters)", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Branch-Wise Reconciliation Report", "Branch-Wise Reconciliation Report", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Loan-Wise Cash Reconciliation Report", "Loan-Wise Cash Reconciliation Report", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Schedule Collection Report (3 files)", "Schedule Collection Report (3 files)", 0, 0, 0, 0, 0, 0, 0, 0, 1),
("Schedule Collection Report With Date Range (3 files)", "Schedule Collection Report (3 files) with date range", 3, 0, 0, 0, 0, 0, 0, 0, 1),
("mShakti Usage Report","mShakti Usage Report", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Future Cash Out-Flow", "Future Cash Out-Flow", 0, 2,2, 1, 1, 0, 0, 1, 1),
("Demand Vs Collection Report (New Format)", "Demand Vs Collection Report (New Format)", 0, 2,2, 1, 1, 1, 1, 0, 1),
("Interest Accrual/Expense Report (Deposit)","Interest Accrual/Expense Report (Deposit)", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Highmark Summary Report (Credit Bureau Report Date-Wise)","Highmark Summary Report (Credit Bureau Report Date-Wise)", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Highmark Summary Report (Loan Disbursement Date-Wise)","Highmark Summary Report (Loan Disbursement Date-Wise)", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Equifax Summary Report (Credit Bureau Report Date-Wise)","Equifax Summary Report (Credit Bureau Report Date-Wise)", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Equifax Summary Report (Loan Disbursement Date-Wise)","Equifax Summary Report (Loan Disbursement Date-Wise)", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Date-wise Collection Against Date-wise Demand Report","Date-wise Collection Against Date-wise Demand Report", 6, 0, 0, 0, 0, 0, 0, 0, 1),
("Document Template Rule","Document Template Rule", 0, 0, 0, 0, 0, 0, 0, 0, 1),
("Loan-wise Collection Against Date-wise Demand Report","Loan-wise Collection Against Date-wise Demand Report", 6, 0, 0, 0, 0, 0, 0, 0, 1),
("Accounting Entries Dump Report", "Accounting Entries Dump Report", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Ledger Dump Report", "Ledger Dump Report", 2, 0, 0, 0, 0, 0, 0, 0, 1),
("MI Demand-Collection Report", "MI Demand-Collection Report", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Vintage Portfolio At Risk(PAR)", "Vintage Portfolio At Risk(PAR)", 0, 4, 4, 1, 1, 0, 1, 1, 1),
("Vintage Portfolio At Risk(PAR) 30", "Vintage Portfolio At Risk(PAR) 30", 0, 4, 4, 1, 1, 0, 1, 1, 1),
("Vintage Portfolio At Risk(PAR) 90", "Vintage Portfolio At Risk(PAR) 90", 0, 4, 4, 1, 1, 0, 1, 1, 1),
("Vintage Portfolio At Risk(PAR) 180", "Vintage Portfolio At Risk(PAR) 180", 0, 4, 4, 1, 1, 0, 1, 1, 1),
("Moratorium Adjusted Overdue Report Version 1", "Moratorium Adjusted Overdue Report Version 1", 1, 0, 0, 0, 0, 0, 0, 0, 1),
("Moratorium Adjusted Overdue Report Version 2", "Moratorium Adjusted Overdue Report Version 2", 1, 0, 0, 0, 0, 0, 0, 0, 1),
("Recon Data Report", "Recon Data Report", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Loan Account Statement Report", "This report provides account wise appropriation break up similar loan account statement", 2, 0, 0, 0, 0, 0, 0, 0, 1),
("GST Fee Collection Report", "GST Fee Collection Report", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("GST Interest Collection Report", "GST Interest Collection Report", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("GST Invoice Collection Count Report", "GST Invoice Collection Count Report", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("View Loan Payments (Only Cancelled Payments)", "View Loan Payments (Only Cancelled Payments)", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Moratorium Demand And Collection Report", "Moratorium Demand And Collection Report Breakup Details", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Date-Wise Moratorium Demand And Collection Report", "Date-Wise Moratorium Demand And Collection Report", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Collection Against Demand(Payment Mode wise)", "Collection Against Demand(Payment Mode wise)", 6, 0, 0, 0, 0, 0, 0, 0, 1),
("Moratorium Adjusted Overdue Report Version 3", "Moratorium Adjusted Overdue Report Version 3", 1, 0, 0, 0, 0, 0, 0, 0, 1),
("Pipeline Report By Status (Status Date Filter)", "Pipeline Report By Status (Status Date Filter) for all statuses and all pipeline types", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Loan Origination Status Report", "Loan Origination Status Report", 7, 0, 0, 0, 0, 0, 0, 1, 1),
("S1 Usage Report", "S1 Usage Report", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Loan Approved/Declined Report with S1 Decision", "Loan Approved/Declined Report with S1 Decision", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Credit Bureau Monthly Report (CDF format)", "Credit Bureau Monthly Report (CDF format)", 1, 0, 0, 0, 0, 0, 0, 0, 1),
("Credit Bureau Weekly Report (CDF format)", "Credit Bureau Weekly Report (CDF format)", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Officer Based Demand And Collection Report", "Officer Based Demand And Collection Report", 1, 0, 0, 0, 0, 0, 0, 0, 1),
("CCR FOIR Details", "CCR FOIR Details",11, 0, 0, 0, 0, 0, 0, 0, 1),
("View Loan Payments (Only Cancelled Payments with cancelled user)", "View Loan Payments (Only Cancelled Payments with cancelled user)", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Loan Installment Paid Report (Closed Accounts)", "Paid installment count for closed accounts",2, 0, 0, 0, 0, 0, 0, 0, 1),
("Pause Disbursement based on PAR30 Report", "Pause Disbursement based on PAR30 Report", 1, 0, 0, 0, 0, 0, 0, 0, 1),
("Collection Efficiency Report", "Collection Efficiency Report", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Officer Wise PAR30 Report","Officer Wise PAR30 Report",1, 0, 0, 0, 0, 0, 0, 0, 1),
("Customer-Wise Net Disbursement Report","Customer-Wise Net Disbursement Report",7, 0, 0, 0, 0, 0, 0, 0, 1);
("New Provisioning Report", "New Provisioning Report", 1, 0, 0, 0, 0, 0, 0, 0, 1),
("Customer-loyalty Program Report", "Customer-loyalty Program Report", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Deposit Maturity Report", "Deposit Maturity Report", 14, 0, 0, 0, 0, 0, 0, 0, 1),
("Otp Report (3 files)", "Otp Report (3 files)", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Account Transaction Dump","Account Transaction Dump",2,0,0,0,0,0,0,0,1),
("Loan Demand Dump","Loan Demand Dump",2,0,0,0,0,0,0,0,1),
("Loan Information Dump","Loan Information Dump",2,0,0,0,0,0,0,0,1),
("Account Payment Dump","Account Payment Dump",2,0,0,0,0,0,0,0,1),
("Account Balance Dump","Account Balance Dump",2,0,0,0,0,0,0,0,1),
("Demand Waiver Dump","Demand Waiver Dump",2,0,0,0,0,0,0,0,1),
("Unmasked KYC Details Report","Unmasked KYC Details Report", 1, 0, 0, 0, 0, 0, 0, 0, 1),
("Customer Geolocation Distance Report","Customer Geolocation Distance Report", 1, 0, 0, 0, 0, 0, 0, 0, 1),
("Identity Verification Report","Identity Verification Report", 1, 0, 0, 0, 0, 0, 0, 0, 1),
<<<<<<< HEAD
("Journal-based Collection Report", "Journal-based Collection Report", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Cibil Report","Cibil Report",1, 0, 0, 0, 0, 0, 0, 0, 1),
("Deposit Origination Report","Deposit Origination Report",7, 0, 0, 0, 0, 0, 0, 0, 1);
=======
("Cibil Report","Cibil Report",1, 0, 0, 0, 0, 0, 0, 0, 1),
("Deposit Origination Report","Deposit Origination Report",7, 0, 0, 0, 0, 0, 0, 0, 1),
("Journal-based Collection Report", "Journal-based Collection Report", 7, 0, 0, 0, 0, 0, 0, 0, 1),
("Cibil Report","Cibil Report",1, 0, 0, 0, 0, 0, 0, 0, 1);
>>>>>>> TLM-numberFormatFix1


--
-- Master table values for ReportField
--
DELETE FROM ReportField;

-- Aggregation fields
INSERT INTO ReportField(name, ui_name, description, data_type_id, tag) VALUES
("Loan Account Number", "Loan Account Number", "Loan Account Number", @dataTypeAggregationId,"${account_number}"),
("Customer Name", "Customer Name", "Customer Name", @dataTypeAggregationId,"${customer_name}"),
("Date", "Date", "Date", @dataTypeAggregationId,NULL),
("Moratorium Interest", "Moratorium Interest", "Moratorium Interest", @dataTypeAggregationId,NULL),
("Month", "Month", "Month", @dataTypeAggregationId,NULL),
("Office", "Office", "Office", @dataTypeAggregationId,NULL),
("Parent Office1", "Parent Office1", "Office one level above lowest-level office", @dataTypeAggregationId,NULL),
("Parent Office2", "Parent Office2", "Office two levels above lowest-level office", @dataTypeAggregationId,NULL),
("Parent Office3", "Parent Office3", "Office three levels above lowest-level office", @dataTypeAggregationId,NULL),
("Parent Office4", "Parent Office4", "Office four levels above lowest-level office", @dataTypeAggregationId,NULL),
("Product", "Product", "Product", @dataTypeAggregationId,NULL),
("Officer", "Officer", "Relationship Officer", @dataTypeAggregationId,"${Officer}"),
("Center", "Center", "Loan Center", @dataTypeAggregationId,NULL),
("Funder", "Funder", "Funder", @dataTypeAggregationId,NULL),
("Funding Source", "Funding Source", "Funding Source", @dataTypeAggregationId,NULL),
("Weekday", "Weekday", "Weekday", @dataTypeAggregationId,NULL),
("Disbursement Date", "Loan Disbursement Date", "Disbursement Date", @dataTypeAggregationId,NULL),
("Disbursement Month", "Loan Disbursement Month", "Disbursement Month", @dataTypeAggregationId,NULL),
("Maturity Month", "Maturity Month", "Loan Maturity Month", @dataTypeAggregationId,NULL),
("Office Locale", "Office Locale", "Locale of the office", @dataTypeAggregationId,NULL),
("Customer Locale", "Customer Locale", "Locale of the customer", @dataTypeAggregationId,NULL),
("State (Customer)", "State (Customer)", "State (Customer)", @dataTypeAggregationId,NULL),
("District", "District", "District", @dataTypeAggregationId,NULL),
("Product Category", "Product Category", "Product Category", @dataTypeAggregationId,NULL),
("Product Type", "Product Type", "Product Type", @dataTypeAggregationId,NULL),
("Compounding Frequency", "Compounding Frequency", "Compounding Frequency", @dataTypeAggregationId,NULL),
("Interest Rate %", "Interest Rate %", "Interest Rate %", @dataTypeAggregationId,NULL),
("Interest Rate Type", "Interest Rate Type", "Interest Rate Type", @dataTypeAggregationId,NULL),
("Funding Type", "Funding Type", "Funding Type", @dataTypeAggregationId,NULL),
("Loan Purpose", "Loan Purpose", "Loan Purpose", @dataTypeAggregationId,NULL),
("Loan Purpose Category", "Loan Purpose Category", "Loan Purpose Category", @dataTypeAggregationId,NULL),
("Loan Purpose Type", "Loan Purpose Type", "Loan Purpose Type", @dataTypeAggregationId,NULL),
("Utilized Amount", "Utilized Amount", "Utilized Loan Amount", @dataTypeAggregationId,NULL),
("Foreclosure Reason", "Foreclosure Reason", "Foreclosure Reason", @dataTypeAggregationId,NULL),
("Write-off Reason", "Write-off Reason", "Write-off Reason", @dataTypeAggregationId,NULL),
("Repayment Frequency", "Repayment Frequency", "Repayment Frequency", @dataTypeAggregationId,NULL),
("Account Status", "Account Status", "Account Status", @dataTypeAggregationId,NULL),
("Loan Ticket Size", "Loan Ticket Size", "Loan Ticket Size", @dataTypeAggregationId,NULL),
("Religious Group", "Religious Group", "Religious Group", @dataTypeAggregationId,NULL),
("Caste", "Caste", "Caste", @dataTypeAggregationId,NULL),
("Occupation", "Occupation", "Occupation", @dataTypeAggregationId,NULL),
("Education Level", "Education Level", "Education Level", @dataTypeAggregationId,NULL),
("Marital Status", "Marital Status", "Marital Status", @dataTypeAggregationId,NULL),
("Collateral Size", "Collateral Size", "Collateral Size", @dataTypeAggregationId,NULL),
("Gender", "Gender", "Gender", @dataTypeAggregationId,NULL),
("Employee Title", "Employee Title", "Employee Title", @dataTypeAggregationId,NULL),
("Property Type", "Property Type", "Property Type", @dataTypeAggregationId,NULL),
("Office Code", "Office Code", "Office Code", @dataTypeAggregationId,NULL),
("Center Code", "Center Code", "Center Code", @dataTypeAggregationId,NULL),
("Group", "Group", "Group", @dataTypeAggregationId,NULL),
("Group Code", "Group Code", "Group Code", @dataTypeAggregationId,NULL),
("Spouse Name", "Spouse Name", "Spouse Name", @dataTypeAggregationId,NULL),
("Guarantor Name(Customer)", "Guarantor Name(Customer)", "Guarantor Name(Customer)", @dataTypeAggregationId,NULL),
("Address", "Address", "Address", @dataTypeAggregationId,NULL),
("Village", "Village", "Village", @dataTypeAggregationId,NULL),
("Pincode", "Pincode", "Pincode", @dataTypeAggregationId,NULL),
("Telephone", "Telephone", "Telephone", @dataTypeAggregationId,NULL),
("Tenure", "Tenure", "Tenure", @dataTypeAggregationId,"${tenure}"),
("Tenure Unit", "Tenure Unit", "Tenure Unit", @dataTypeAggregationId,NULL),
("Customer Number", "Customer Number", "Customer Number", @dataTypeAggregationId,"${customer_number}"),
("Approved Loan Amount", "Approved Loan Amount", "Approved Loan Amount", @dataTypeAggregationId,"${approved_loan_amount}"),
("Receipt Number", "Receipt Number", "Receipt Number", @dataTypeAggregationId,"${receipt_number}"),
("Loan Cycle Number", "Loan Cycle Number", "Loan Cycle Number", @dataTypeAggregationId,NULL),
("Primary Identity Proof", "Primary Identity Proof", "Primary Identity Proof", @dataTypeAggregationId,NULL),
("Primary Identity Proof Number", "Primary Identity Proof Number", "Primary Identity Proof Number", @dataTypeAggregationId,NULL),
("Primary Address Proof", "Primary Address Proof", "Primary Address Proof", @dataTypeAggregationId,NULL),
("Primary Address Proof Number", "Primary Address Proof Number", "Primary Address Proof Number", @dataTypeAggregationId,NULL),
("First Installment Date", "First Installment Date", "First Installment Date", @dataTypeAggregationId,"${first_installment_date}"),
("Last Installment Date", "Last Installment Date", "Last Installment Date", @dataTypeAggregationId,NULL),
("Mode Of Repayment", "Mode Of Repayment", "Mode Of Repayment", @dataTypeAggregationId,NULL),
("Employee Manager", "Employee Manager", "Employee Manager", @dataTypeAggregationId,NULL),
("Days Since Disbursement", "Days Since Disbursement", "Days Since Disbursement", @dataTypeAggregationId,NULL),
("First Installment Month", "First Installment Month", "First Installment Month", @dataTypeAggregationId,NULL),
("Center Status Remarks", "Center Status Remarks", "Center Status Remarks", @dataTypeAggregationId,NULL),
("Third Party", "Third Party", "Third Party", @dataTypeAggregationId,NULL),
("Guarantor Name(Loan)", "Guarantor Name(Loan)", "Guarantor Name(Loan)", @dataTypeAggregationId,NULL),
("Business Type", "Business Type", "Business Type", @dataTypeAggregationId,NULL),
("State (Office)", "State (Office)", "State (Office)", @dataTypeAggregationId,NULL),
("Pipeline Status", "Pipeline Status", "Pipeline Status", @dataTypeAggregationId,NULL),
("Pipeline", "Pipeline", "Pipeline", @dataTypeAggregationId,NULL),
("Cancel Reason", "Cancel Reason", "Cancel Reason", @dataTypeAggregationId,NULL),
("Bank Account Number", "Bank Account Number", "Bank Account Number", @dataTypeAggregationId,NULL),
("Failure Reason", "Failure Reason", "Bene or ECS Failure Reason", @dataTypeAggregationId,NULL),
("Product Class", "Product Class", "Product Class", @dataTypeAggregationId,NULL),
("Insurance Company", "Insurance Company", "Insurance Company", @dataTypeAggregationId,NULL),
("Payment Amount", "Payment Amount", "Payment Amount", @dataTypeAggregationId,"${payment_amount}"),
("Payment Date", "Payment Date", "Payment Date", @dataTypeAggregationId,"${payment_date}"),
("Total Payment Collection", "Total Payment Collection", "Total Payment Collection", @dataTypeAggregationId,"${total_payment_collection}"),
("Payment Mode", "Payment Mode", "Payment Mode", @dataTypeAggregationId,"${payment_mode}"),
("Payment Group Id", "Payment Group Id", "Payment Group Id", @dataTypeAggregationId,NULL),
("Customer Age", "Customer Age", "Customer Age", @dataTypeAggregationId,NULL),
("Installment Amount", "Installment Amount", "Installment Amount", @dataTypeAggregationId,"${installment_amount}"),
("Cheque Number", "Cheque Number", "Cheque Number", @dataTypeAggregationId,"${cheque_no}"),
("Cheque Date", "Cheque Date", "Cheque Date", @dataTypeAggregationId,"${cheque_date}"),
("Demand Date", "Demand Date", "Demand Date", @dataTypeAggregationId,NULL),
("Is Disbursed", "Is Disbursed?", "Is Disbursed?", @dataTypeAggregationId,NULL),
("Disbursement Date (Custom)", "Disbursement Date (Custom)", "Disbursement Date (Custom)", @dataTypeAggregationId,NULL),
("Customer CB No HIT", "Customer CB No HIT", "Customer CB No HIT", @dataTypeAggregationId,NULL),
("Customer Land Holding (acres)", "Customer Land Holding (acres)", "Customer Land Holding (acres)", @dataTypeAggregationId,NULL),
("Loan Passbook Number", "Loan Passbook Number", "Loan Passbook Number", @dataTypeAggregationId, "${loan_passbook_number}"),
("Installment Month", "Installment Month", "Installment Month", @dataTypeAggregationId,NULL),
("Installment Date", "Installment Date", "Installment Date", @dataTypeAggregationId,NULL),
("Last Date of the Month", "Last Date of the Month", "Last Date of the Month", @dataTypeAggregationId,NULL),
("Next Installment Number", "Next Installment Number", "Next Installment Number", @dataTypeAggregationId, "${next_installment_number}"),
("Next Installment Amount", "Next Installment Amount", "Next Installment Amount", @dataTypeAggregationId, "${next_installment_amount}"),
("First Repayment Date Allowed Weeks", "First Repayment Date Allowed Weeks", "First Repayment Date Allowed Weeks", @dataTypeAggregationId,NULL),
("Current Officer", "Current Officer", "Current Officer", @dataTypeAggregationId, "${current_officer}"),
("Future Officer", "Future Officer", "Future Officer", @dataTypeAggregationId, "${future_officer}"),
("Transfer Date", "Transfer Date", "Transfer Date", @dataTypeAggregationId, "${transfer_date}"),
("State (Customer Primary Bank Account)", "State (Customer Primary Bank Account)", "State (Customer Primary Bank Account)", @dataTypeAggregationId, NULL),
("Number of Other Active Lenders", "Number of Other Active Lenders", "Number of lenders the customer currently has active loans with except own company", @dataTypeAggregationId, NULL),
("Number of Active Loans", "Number of Active Loans", "Number of active loans the customer has, as per the Credit Bureau report", @dataTypeAggregationId, NULL),
("Total Other Current Balance", "Total Other Current Balance", "Total current outstanding balance the customer has with other lenders", @dataTypeAggregationId, NULL),
("Bureau Vintage (In Days)", "Bureau Vintage (In Days)", "Number of days since the customer took their first loan, as per the Credit Bureau report", @dataTypeAggregationId, NULL),
("Bureau Score", "Bureau Score", "Bureau Score", @dataTypeAggregationId, NULL),
("Credit Bureau Service", "Credit Bureau Service", "Credit Bureau Service", @dataTypeAggregationId, NULL),
("Loan Amount (Previous Cycle)", "Loan Amount (Previous Cycle)", "Loan Amount (Previous Cycle)", @dataTypeAggregationId, NULL),
("Next Installment Amount", "Next Installment Amount", "Next Installment Amount", @dataTypeAggregationId, "${next_installment_amount}"), 
("EStationery Receipt Number", "EStationery Receipt Number", "EStationery Receipt Number", @dataTypeAggregationId, "${eStat"),
("Customer Income", "Customer Income", "Customer Income", @dataTypeAggregationId, "${eStat"),
("Number Of Loans (Active & Closed)", "Number Of Loans (Active & Closed)", "Number Of Loans (Active & Closed)", @dataTypeAggregationId, "${eStat"),
("Total Current Balance", "Total Current Balance", "Total Current Balance", @dataTypeAggregationId, NULL),
("Savings Withdrawal Count", "Savings Withdrawal Count", "Savings Withdrawal Count", @dataTypeAggregationId, NULL),
("Savings Minimum Balance", "Savings Minimum Balance", "Savings Minimum Balance", @dataTypeAggregationId, NULL),
("Total No of mandatory deposit", "Total No of mandatory deposit", "Total No of mandatory deposit", @dataTypeAggregationId, NULL),
("Name Match Percentage (%)", "Name Match Percentage (%)", "Name Match Percentage (%) between the customer name in Shakti and the name returned by the bank", @dataTypeAggregationId, NULL),
("Is Membership deposit paid", "Is Membership deposit paid ?", "Is Membership deposit paid", @dataTypeAggregationId, NULL);

-- Bucket fields
INSERT INTO ReportField(name, ui_name, description, data_type_id) VALUES
("Loan Ticket Size", "Loan Ticket Size", "Loan Ticket Size", @dataTypeBucketId),
("Age (years)", "Age (years)", "Age (years)", @dataTypeBucketId),
("Land Holding (acres)", "Land Holding (acres)", "Land Holding (acres)", @dataTypeBucketId),
("Household Income", "Household Income", "Household Income", @dataTypeBucketId),
("Household Expenses", "Household Expenses", "Household Expenses", @dataTypeBucketId),
("Disbursements", "Disbursements", "Disbursements", @dataTypeBucketId),
("Collections", "Collections", "Collections", @dataTypeBucketId),
("Principal Demands", "Principal Demands", "Principal Demands", @dataTypeBucketId),
("Interest Demands", "Interest Demands", "Interest Demands", @dataTypeBucketId),
("Loan Fee Demands", "Loan Fee Demands", "Loan Fee Demands", @dataTypeBucketId),
("Insurance Premium Demands", "Insurance Premium Demands", "Insurance Premium Demands", @dataTypeBucketId),
("Other Demands", "Other Demands", "Other Demands", @dataTypeBucketId),
("Total Demands", "Total Demands", "Total Demands", @dataTypeBucketId),
("Current Principal Payments", "Current Principal Payments", "Principal amount that got appropriated on the demand date", @dataTypeBucketId),
("Current Interest Payments", "Current Interest Payments", "Interest amount that got appropriated on the demand date", @dataTypeBucketId),
("Current Fee Payments", "Current Fee Payments", "Fee amount that got appropriated on the demand date", @dataTypeBucketId),
("Current Insurance Payments", "Current Insurance Payments", "Insurance amount that got appropriated on the demand date", @dataTypeBucketId),
("Other Current Payments", "Other Current Payments", "Other amount, excluding principal, interest, fee & insurance, that got appropriated on the demand date", @dataTypeBucketId),
("Total Current Payments (On Demands)", "Total Current Payments (On Demands)", "Total amount that got appropriated against demands on the demand date", @dataTypeBucketId),
("Principal Prepayments", "Principal Prepayments", "Principal amount that got appropriated as prepayment (no demands)", @dataTypeBucketId),
("Interest Prepayments", "Interest Prepayments", "Interest amount that got appropriated as prepayment (no demands)", @dataTypeBucketId),
("Other Prepayments", "Other Prepayments", "Other amount, excluding principal & interest, that got appropriated as prepayment (no demands)", @dataTypeBucketId),
("Total Prepayments (No Demands)", "Total Prepayments (No Demands)", "Total amount that got appropriated as prepayment (no demands)", @dataTypeBucketId),
("Principal Late Payments", "Principal Late Payments", "Principal amount that got appropriated against overdue demands", @dataTypeBucketId),
("Interest Late Payments", "Interest Late Payments", "Interest amount that got appropriated against overdue demands", @dataTypeBucketId),
("Other Late Payments", "Other Late Payments", "Other amount, exluding principal & interest, that got appropriated against overdue demands", @dataTypeBucketId),
("Total Late Payments", "Total Late Payments", "Total amount that got appropriated against overdue demands", @dataTypeBucketId),
("Total Principal Payments", "Total Principal Payments", "Total principal amount appropriated - includes current, prepayment and overdues", @dataTypeBucketId),
("Total Interest Payments", "Total Interest Payments", "Total interest amount appropriated - includes current, prepayment and overdues", @dataTypeBucketId),
("Disbursed Loan Amount", "Disbursed Loan Amount", "Disbursed Loan Amount", @dataTypeBucketId),
("Portfolio Outstanding", "Portfolio Outstanding", "Portfolio Outstanding", @dataTypeBucketId),
("Interest Accrued Not Due", "Interest Accrued Not Due", "Interest Accrued Not Due", @dataTypeBucketId),
("Interest Collected", "Interest Collected", "Interest Collected", @dataTypeBucketId),
("Interest Outstanding", "Interest Outstanding", "Interest Outstanding", @dataTypeBucketId),
("Advance/Parked Amount", "Advance/Parked Amount", "Amount in advance/parked as of a given date", @dataTypeBucketId),
("Overdue Interest", "Overdue Interest", "Overdue Interest", @dataTypeBucketId),
("Overdue Principal", "Overdue Principal", "Overdue Principal", @dataTypeBucketId),
("Overdue Amount", "Overdue Amount", "Overdue Amount", @dataTypeBucketId),
("# Overdue Days", "# Overdue Days", "# Overdue Days", @dataTypeBucketId),
("Overdue Principal Outstanding", "Overdue Principal Outstanding", "Overdue Principal Outstanding", @dataTypeBucketId),
("Installment Date", "Installment Date", "Installment Date", @dataTypeBucketId),
("Utilized Amount", "Utilized Amount", "Utilized Amount", @dataTypeBucketId),
("Current Portfolio Outstanding", "Current Portfolio Outstanding", "Current Portfolio Outstanding", @dataTypeBucketId),
("Advance/Parked Payments", "Advance/Parked Payments", "Total advance collection", @dataTypeBucketId),
("Collateral Size", "Collateral Size", "Collateral Size", @dataTypeBucketId),
("Installment Number", "Installment Number", "Installment Number", @dataTypeBucketId),
("Days since first repay date", "Days since first repay date", "Days since first repay date", @dataTypeBucketId),
("Days Since Disbursement", "Days Since Disbursement", "Days Since Disbursement", @dataTypeBucketId),
("Incorrect Observation Percentage", "Incorrect Observation Percentage", "Incorrect Observation Percentage", @dataTypeBucketId),
("# Overdue Days (Customer)", "# Overdue Days (Customer)", "# Overdue Days (Customer)", @dataTypeBucketId),
("Savings Principal Balance", "Savings Principal Balance","Savings Principal Balance" ,@dataTypeBucketId),
("Funding Installment Date", "Funding Installment Date", "Funding Installment Date", @dataTypeBucketId);

-- Daily data fields
INSERT INTO ReportField(name, ui_name, description, data_type_id, tag) VALUES
("Principal Demands", "Principal Demands", "Principal Demands", @dataTypeDailyDataId,NULL),
("Interest Demands", "Interest Demands", "Interest Demands", @dataTypeDailyDataId,NULL),
("Installment Demands", "Installment Demands", "Installment Demands", @dataTypeDailyDataId,NULL),
("Loan Fee Demands", "Loan Fee Demands", "Loan Fee Demands", @dataTypeDailyDataId,NULL),
("Insurance Premium Demands", "Insurance Premium Demands", "Insurance Premium Demands", @dataTypeDailyDataId,NULL),
("Other Demands", "Other Demands", "Other Demands", @dataTypeDailyDataId,NULL),
("Total Demands", "Total Demands", "Total Demands", @dataTypeDailyDataId,NULL),
("Future Interest Demand", "Future Interest Demand", "Future Interest Demand", @dataTypeDailyDataId,NULL),
("Future Principal Demand", "Future Principal Demand", "Future Principal Demand", @dataTypeDailyDataId,NULL),
("Future Total Demand", "Future Total Demand", "Future Total Demand", @dataTypeDailyDataId,NULL),
("Total Principal Payments", "Total Principal Payments", "Total principal amount appropriated - includes current, prepayment and overdues", @dataTypeDailyDataId,NULL),
("Total Interest Payments", "Total Interest Payments", "Total interest amount appropriated - includes current, prepayment and overdues", @dataTypeDailyDataId,NULL),
("Current Principal Payments", "Current Principal Payments", "Principal amount that got appropriated on the demand date", @dataTypeDailyDataId,NULL),
("Principal Prepayments", "Principal Prepayments", "Principal Prepayments", @dataTypeDailyDataId,NULL),
("Principal Overdue Recovery", "Principal Overdue Recovery", "Principal amount recovered against overdue demands", @dataTypeDailyDataId,NULL),
("Current Interest Payments", "Current Interest Payments", "Interest amount that got appropriated on the demand date", @dataTypeDailyDataId,NULL),
("Interest Prepayments", "Interest Prepayments", "Interest Prepayments", @dataTypeDailyDataId,NULL),
("Interest Overdue Recovery", "Interest Overdue Recovery", "Interest amount recovered against overdue demands", @dataTypeDailyDataId,NULL),
("Current Fee Payments", "Current Fee Payments", "Fee amount that got appropriated on the demand date", @dataTypeDailyDataId,NULL),
("Current Insurance Payments", "Current Insurance Payments", "Insurance amount that got appropriated on the demand date", @dataTypeDailyDataId,NULL),
("Other Current Payments", "Other Current Payments", "Other amount, excluding principal, interest, fee & insurance, that got appropriated on the demand date", @dataTypeDailyDataId,NULL),
("Total Current Payments (On Demands)", "Total Current Payments (On Demands)", "Total amount that got appropriated against demands on the demand date", @dataTypeDailyDataId,NULL),
("Other Prepayments ", "Other Prepayments ", "Other amount, excluding principal & interest, that got appropriated as prepayment (no demands)", @dataTypeDailyDataId,NULL),
("Total Prepayments (No Demands)", "Total Prepayments (No Demands)", "Total amount that got appropriated as prepayment (no demands)", @dataTypeDailyDataId,NULL),
("Other Late Payments", "Other Late Payments", "Other amount, exluding principal & interest, that got appropriated against overdue demands", @dataTypeDailyDataId,NULL),
("Total Overdue Recovery", "Total Overdue Recovery", "Total amount recovered against overdue demands", @dataTypeDailyDataId,NULL),
("Advance Appropriation", "Advance Appropriation", "Advance amount appropriated against current demands", @dataTypeDailyDataId,NULL),
("Advance/Parked Payments", "Advance/Parked Payments", "Advance/Parked Payments", @dataTypeDailyDataId,NULL),
("Collections (Unappropriated)", "Collections (Unappropriated)", "Total collections received on a given date (Unappropriated)", @dataTypeDailyDataId,NULL),
("Installment+Advance Collections", "Installment+Advance Collections", "Total principal+interest amounts appropriated + advance collection", @dataTypeDailyDataId,NULL),
("Total Disbursed Amount", "Total Disbursed Amount", "Total Disbursed Amount", @dataTypeDailyDataId,NULL),
("# Disbursements", "# Disbursements", "# Disbursements", @dataTypeDailyDataId,NULL),
("# Foreclosures", "# Foreclosures", "# Foreclosures", @dataTypeDailyDataId,NULL),
("Average Disbursements Per Officer", "Average Disbursements Per Officer", "Average Disbursements Per Officer", @dataTypeDailyDataId,NULL),
("Collection Percentage (%)", "Collection Percentage (%)", "Ratio of total installment amount appropriated against total installment demands total installment amount appropriated(%)", @dataTypeDailyDataId,NULL),
("Total Approved Amount", "Total Approved Amount", "Total Approved Amount", @dataTypeDailyDataId,NULL),
("Current Installment Payments", "Current Installment Payments", "Total installment amount appropriated against current demands", @dataTypeDailyDataId,NULL),
("Date Of Completion", "Date Of Completion", "Date Of Completion", @dataTypeDailyDataId,NULL),
("Center Size", "Center Size", "Center Size", @dataTypeDailyDataId,NULL),
("Cycle Number", "Cycle Number", "Cycle Number", @dataTypeDailyDataId,NULL),
("Amount", "Amount", "Amount", @dataTypeDailyDataId,NULL),
("Completed Pipeline", "Completed Pipeline", "Completed Pipeline", @dataTypeDailyDataId,NULL),
("Collection Amount", "Collection Amount", "Collection Amount", @dataTypeDailyDataId,NULL),
("Total Waived Amount", "Total Waived Amount", "Total Waived Amount", @dataTypeDailyDataId,NULL),
("Differential Interest", "Differential Interest", "Differential Interest", @dataTypeDailyDataId,NULL),
("Future Interest Payable", "Future Interest Payable", "Future Interest Payable", @dataTypeDailyDataId,NULL),
("Future Principal Payable", "Future Principal Payable", "Future Principal Payable", @dataTypeDailyDataId,NULL),
("Future Total Payable", "Future Total Payable", "Future Total Payable", @dataTypeDailyDataId,NULL),
("Interest Accrued Not Due(BOD)", "Interest Accrued Not Due(BOD)", "Interest Accrued Not Due(BOD)", @dataTypeDailyDataId,NULL),
("Interest Accrued Not Due(EOD)", "Interest Accrued Not Due(EOD)", "Interest Accrued Not Due(EOD)", @dataTypeDailyDataId,NULL),
("Tenure(In Months)", "Tenure(In Months)", "Tenure(In Months)", @dataTypeDailyDataId,NULL),
("Tenure(In Weeks)", "Tenure(In Weeks)", "Tenure(In Weeks)", @dataTypeDailyDataId,NULL),
("Principal Demands(Exclude Closed Accounts)", "Principal Demands(Exclude Closed Accounts)", "Principal Demands(Exclude Closed Accounts)", @dataTypeDailyDataId,NULL),
("Interest Demands(Exclude Closed Accounts)", "Interest Demands(Exclude Closed Accounts)", "Interest Demands(Exclude Closed Accounts)", @dataTypeDailyDataId,NULL),
("Total Demands(Exclude Closed Accounts)", "Total Demands(Exclude Closed Accounts)", "Total Demands(Exclude Closed Accounts)", @dataTypeDailyDataId,NULL),
("Current Principal Payments(Exclude Closed Accounts)", "Current Principal Payments(Exclude Closed Accounts)", "Current Principal Payments(Exclude Closed Accounts)", @dataTypeDailyDataId,NULL),
("Current Interest Payments(Exclude Closed Accounts)", "Current Interest Payments(Exclude Closed Accounts)", "Current Interest Payments(Exclude Closed Accounts)", @dataTypeDailyDataId,NULL),
("Total Principal Payments(Exclude Closed Accounts)", "Total Principal Payments(Exclude Closed Accounts)", "Total Principal Payments(Exclude Closed Accounts)", @dataTypeDailyDataId,NULL),
("Total Interest Payments(Exclude Closed Accounts)", "Total Interest Payments(Exclude Closed Accounts)", "Total Interest Payments(Exclude Closed Accounts)", @dataTypeDailyDataId,NULL),
("Foreclosure Principal Payments", "Foreclosure Principal Payments", "Foreclosure Principal Payments", @dataTypeDailyDataId,NULL),
("Foreclosure Interest Payments", "Foreclosure Interest Payments", "Foreclosure Interest Payments", @dataTypeDailyDataId,NULL),
("Death Principal Payments", "Death Principal Payments", "Death Principal Payments", @dataTypeDailyDataId,NULL),
("Moratorium Interest Collected", "Moratorium Interest Collected", "Moratorium Interest Collected", @dataTypeDailyDataId,NULL),
("Equated Moratorium Interest Demand", "Equated Moratorium Interest Demand", "Equated Moratorium Interest Demand", @dataTypeDailyDataId,NULL),
("From Round-off", "From Round-off", "From Round-off", @dataTypeDailyDataId,NULL),
("To Round-off", "To Round-off", "To Round-off", @dataTypeDailyDataId,NULL),
("Customer Age", "Customer Age", "Customer Age", @dataTypeDailyDataId,NULL),
("Next Repay Date", "Next Installment Date", "Next Installment Date", @dataTypeDailyDataId, "${next_installment_date}"),
("Death Interest Payments", "Death Interest Payments", "Death Interest Payments", @dataTypeDailyDataId,NULL);
-- Cumulative data fields
 INSERT INTO ReportField(name, ui_name, description, data_type_id, tag) VALUES
("Disbursed Loan Amount", "Disbursed Loan Amount", "Disbursed Loan Amount", @dataTypeCumulativeDataId,NULL),
("Portfolio Outstanding", "Portfolio Outstanding", "Portfolio Outstanding", @dataTypeCumulativeDataId,"${current_pos}"),
("Interest Accrued Not Due(BOD)", "Interest Accrued Not Due(BOD)", "Interest Accrued Not Due(BOD)", @dataTypeCumulativeDataId,NULL),
("Interest Accrued Not Due(EOD)", "Interest Accrued Not Due(EOD)", "Interest Accrued Not Due(EOD)", @dataTypeCumulativeDataId,NULL),
("Interest Collected", "Interest Collected", "Interest Collected", @dataTypeCumulativeDataId,NULL),
("Interest Outstanding", "Interest Outstanding", "Interest Outstanding", @dataTypeCumulativeDataId,NULL),
("Advance/Parked Amount", "Advance/Parked Amount", "Advance/Parked Amount", @dataTypeCumulativeDataId,NULL),
("Overdue Interest", "Overdue Interest", "Overdue Interest", @dataTypeCumulativeDataId,NULL),
("Overdue Principal", "Overdue Principal", "Overdue Principal", @dataTypeCumulativeDataId,NULL),
("Overdue Amount", "Overdue Amount", "Overdue Amount", @dataTypeCumulativeDataId,"${overdue_amount}"),
("Overdue Principal Days", "Overdue Principal Days", "Overdue Principal Days", @dataTypeCumulativeDataId,NULL),
("# Current Loan Accounts", "# Current Loan Accounts", "# Current Loan Accounts", @dataTypeCumulativeDataId,NULL),
("# Open Loan Accounts", "# Open Loan Accounts", "# Open Loan Accounts", @dataTypeCumulativeDataId,NULL),
("# Active Loan Customers", "# Active Loan Customers", "# Active Loan Customers", @dataTypeCumulativeDataId,NULL),
("# Open Loan Customers", "# Open Loan Customers", "# Open Loan Customers", @dataTypeCumulativeDataId,NULL),
("# Open Loan Centers", "# Open Loan Centers", "# Open Loan Centers", @dataTypeCumulativeDataId,NULL),
("Average Loan Size", "Average Loan Size", "Average Loan Size", @dataTypeCumulativeDataId,NULL),
("# Enrollments", "# Enrollments", "# Enrollments", @dataTypeCumulativeDataId,NULL),
("# Open Loans (excl. New Disb)", "# Open Loans (excl. New Disb)", "# Open Loans (excl. New Disb)", @dataTypeCumulativeDataId,NULL),
("Loan Utilization Check (%)", "Loan Utilization Check (%)", "Loan Utilization Check (%)", @dataTypeCumulativeDataId,NULL),
("Installment Amount", "Installment Amount", "Installment Amount", @dataTypeCumulativeDataId,NULL),
("Advance Installment Amount", "Advance Installment Amount", "Advance Installment Amount", @dataTypeCumulativeDataId,NULL),
("Future Installment Amount", "Future Installment Amount", "Future Installment Amount", @dataTypeCumulativeDataId,NULL),
("Remaining Tenure (In Days)", "Remaining Tenure (In Days)", "Remaining Tenure (In Days)", @dataTypeCumulativeDataId,NULL),
("Total Interest Expected", "Total Interest Expected", "Total Interest Expected", @dataTypeCumulativeDataId,NULL),
("# Overdue Installments", "# Overdue Installments", "# Overdue Installments", @dataTypeCumulativeDataId,NULL),
("Total Outstanding", "Total Outstanding", "Total Outstanding", @dataTypeCumulativeDataId,NULL),
("Days Since Disbursement", "Days Since Disbursement", "Days Since Disbursement", @dataTypeCumulativeDataId,NULL),
("# Centers", "# Centers", "# Centers", @dataTypeCumulativeDataId,NULL),
("Average Loans Per Center", "Average Loans Per Center", "Average Loans Per Center", @dataTypeCumulativeDataId,NULL),
("# Officers", "# Officers", "# Officers", @dataTypeCumulativeDataId,NULL),
("Average Loans Per Officer", "Average Loans Per Officer", "Average Loans Per Officer", @dataTypeCumulativeDataId,NULL),
("Average Portfolio Outstanding Per Officer", "Average Portfolio Outstanding Per Officer", "Average Portfolio Outstanding Per Officer", @dataTypeCumulativeDataId,NULL),
("# Customers with Aadhar Card", "# Customers with Aadhar Card", "Number of loan customers with Aadhar card", @dataTypeCumulativeDataId,NULL),
("Customers with Aadhar Card (%)", "Customers with Aadhar Card (%)", "Percentage of loan customers with Aadhar card", @dataTypeCumulativeDataId,NULL),
("# Customers with Telephone", "# Customers with Telephone", "Number of loan customers with telephone number", @dataTypeCumulativeDataId,NULL),
("Customers with Telephone (%)", "Customers with Telephone (%)", "Percentage of loan customers with telephone number", @dataTypeCumulativeDataId,NULL),
("Derived Portfolio Outstanding", "Derived Portfolio Outstanding", "Portfolio outstanding derived = Opening portfolio outstanding + New loan disbursements - Principal collections appropriated", @dataTypeCumulativeDataId,NULL),
("Opening Portfolio Outstanding", "Opening Portfolio Outstanding", "Opening portfolio outstanding", @dataTypeCumulativeDataId,NULL),
("Closing Portfolio Outstanding", "Closing Portfolio Outstanding", "Closing porfolio outstanding", @dataTypeCumulativeDataId,NULL),
("Opening Advance/Parked Amount", "Opening Advance/Parked Amount", "Amount in advance/parked at the opening a given date", @dataTypeCumulativeDataId,NULL),
("Days since first repay date", "Days since first repay date", "Days since first repay date", @dataTypeCumulativeDataId,NULL),
("Tenure Maximum overdue principal days", "Tenure Maximum overdue principal days", "Tenure Maximum overdue principal days", @dataTypeCumulativeDataId,NULL),
("Attendance Percentage", "Attendance Percentage", "Attendance Percentage", @dataTypeCumulativeDataId,NULL),
("Closing Advance/Parked Amount", "Closing Advance/Parked Amount", "Amount in advance/parked at the closing a given date", @dataTypeCumulativeDataId,NULL),
("Future Funding Installment Amount", "Future Funding Installment Amount", "Future Funding Installment Amount", @dataTypeCumulativeDataId,NULL),
("# Funding Installments", "# Funding Installments", "# Funding Installments", @dataTypeCumulativeDataId,NULL),
("Overdue Principal(Exclude Closed Accounts)", "Overdue Principal(Exclude Closed Accounts)", "Overdue Principal(Exclude Closed Accounts)", @dataTypeCumulativeDataId,NULL),
("Overdue Interest(Exclude Closed Accounts)", "Overdue Interest(Exclude Closed Accounts)", "Overdue Interest(Exclude Closed Accounts)", @dataTypeCumulativeDataId,NULL),
("Loan Amount", "Loan Amount", "Loan Amount", @dataTypeCumulativeDataId,NULL),
("Moratorium Interest Collected (Till Date)", "Moratorium Interest Collected (Till Date)", "Moratorium Interest Collected (Till Date)", @dataTypeCumulativeDataId,NULL),
("Principal Outstanding(Exclude Closed Accounts)", "Principal Outstanding(Exclude Closed Accounts)", "Principal Outstanding(Exclude Closed Accounts)", @dataTypeCumulativeDataId,NULL),
("Total Overdue Amount", "Total Overdue Amount", "Total Overdue Amount", @dataTypeCumulativeDataId,"${total_overdue_amount}"),
("Total Overdue Amount + Installment Amount", "Total Overdue Amount + Installment Amount", "Total Overdue Amount + Installment Amount", @dataTypeCumulativeDataId,"${total_overdue_and_installment_amount}"),
("ECS Failed As Cash Disbursed", "ECS Failed As Cash Disbursed", "ECS Failed and disbursed as Cash", @dataTypeCumulativeDataId,NULL),
("# Overdue Accounts", "# Overdue Accounts", "# Overdue Accounts", @dataTypeCumulativeDataId,NULL);
--
-- PAR cumulative data fields
INSERT INTO ReportField(name, ui_name, description, data_type_id) VALUES
("Portfolio At Risk (%)", "Portfolio At Risk (%)", "Portfolio At Risk (%)", @dataTypeParCumulativeDataId),
("Arrears Rate (%)", "Arrears Rate (%)", "Arrears Rate (%)", @dataTypeParCumulativeDataId),
("OTRR-1 (excl. Claim)", "OTRR-1 (excl. Claim)", "OTRR-1", @dataTypeParCumulativeDataId);

-- Current stat fields
INSERT INTO ReportField(name, ui_name, description, data_type_id) VALUES
("Current Portfolio Outstanding", "Current Portfolio Outstanding", "Current Portfolio Outstanding", @dataTypeCurrentStatDataId);

-- Internal Derived Data fields
INSERT INTO ReportField(name, ui_name, description, data_type_id) VALUES
("Moratorium Interest Collected", "Moratorium Interest Collected", "Moratorium Interest Collected", @internalDerivedData),
("Next Repay Date", "Next Installment Date", "Next Installment Date", @internalDerivedData),
("FOIR Calculation", "FOIR Calculation", "New Household FOIR calculation", @internalDerivedData),
("Loan Installment Amount", "Loan Installment Amount", "Loan Installment Amount", @internalDerivedData),
("# Overdue Days (Customer)", "# Overdue Days (Customer)", "# Overdue Days (Customer)", @internalDerivedData),
("Loan Passbook Number", "Loan Passbook Number", "Loan Passbook Number", @internalDerivedData),
("Total Overdue Amount", "Total Overdue Amount", "Total Overdue Amount", @internalDerivedData),
("Equated Moratorium Interest Demand", "Equated Moratorium Interest Demand", "Equated Moratorium Interest Demand", @internalDerivedData),
("Loan Passbook Number", "Loan Passbook Number", "Loan Passbook Number", @internalDerivedData),
("Total Overdue Amount", "Total Overdue Amount", "Total Overdue Amount", @internalDerivedData),
("Next Installment Number", "Next Installment Number", "Next Installment Number", @internalDerivedData),
("Is Office PAR30 crossed thershold value?", "Is Office PAR30 crossed thershold value?", "User defined Office PAR Thershold to block an office for enrollments and disbursements", @internalDerivedData);


-- Setting variables for all ReportField entries to be used as FK in other tables
-- Aggregation fields
SELECT @loanAccountNumberAggrFieldId := id FROM ReportField WHERE name = "Loan Account Number" AND data_type_id = @dataTypeAggregationId;
SELECT @customerNameAggrFieldId := id FROM ReportField WHERE name = "Customer Name" AND data_type_id = @dataTypeAggregationId;
SELECT @dateAggrFieldId := id FROM ReportField WHERE name = "Date" AND data_type_id = @dataTypeAggregationId;
SELECT @monthAggrFieldId := id FROM ReportField WHERE name = "Month" AND data_type_id = @dataTypeAggregationId;
SELECT @officeAggrFieldId := id FROM ReportField WHERE name = "Office" AND data_type_id = @dataTypeAggregationId;
SELECT @parentOffice1AggrFieldId := id FROM ReportField WHERE name = "Parent Office1" AND data_type_id = @dataTypeAggregationId;
SELECT @parentOffice2AggrFieldId := id FROM ReportField WHERE name = "Parent Office2" AND data_type_id = @dataTypeAggregationId;
SELECT @parentOffice3AggrFieldId := id FROM ReportField WHERE name = "Parent Office3" AND data_type_id = @dataTypeAggregationId;
SELECT @parentOffice4AggrFieldId := id FROM ReportField WHERE name = "Parent Office4" AND data_type_id = @dataTypeAggregationId;
SELECT @productAggrFieldId := id FROM ReportField WHERE name = "Product" AND data_type_id = @dataTypeAggregationId;
SELECT @officerAggrFieldId := id FROM ReportField WHERE name = "Officer" AND data_type_id = @dataTypeAggregationId;
SELECT @centerAggrFieldId := id FROM ReportField WHERE name = "Center" AND data_type_id = @dataTypeAggregationId;
SELECT @funderAggrFieldId := id FROM ReportField WHERE name = "Funder" AND data_type_id = @dataTypeAggregationId;
SELECT @fundingSourceAggrFieldId := id FROM ReportField WHERE name = "Funding Source" AND data_type_id = @dataTypeAggregationId;
SELECT @weekdayAggrFieldId := id FROM ReportField WHERE name = "Weekday" AND data_type_id = @dataTypeAggregationId;
SELECT @disbursementDateAggrFieldId := id FROM ReportField WHERE name = "Disbursement Date" AND data_type_id = @dataTypeAggregationId;
SELECT @disbursementMonthAggrFieldId := id FROM ReportField WHERE name = "Disbursement Month" AND data_type_id = @dataTypeAggregationId;
SELECT @maturityMonthAggrFieldId := id FROM ReportField WHERE name = "Maturity Month" AND data_type_id = @dataTypeAggregationId;
SELECT @officeLocaleAggrFieldId := id FROM ReportField WHERE name = "Office Locale" AND data_type_id = @dataTypeAggregationId;
SELECT @customerLocaleAggrFieldId := id FROM ReportField WHERE name = "Customer Locale" AND data_type_id = @dataTypeAggregationId;
SELECT @stateCustomerAggrFieldId := id FROM ReportField WHERE name = "State (Customer)" AND data_type_id = @dataTypeAggregationId;
SELECT @districtAggrFieldId := id FROM ReportField WHERE name = "District" AND data_type_id = @dataTypeAggregationId;
SELECT @productCategoryAggrFieldId := id FROM ReportField WHERE name = "Product Category" AND data_type_id = @dataTypeAggregationId;
SELECT @productTypeAggrFieldId := id FROM ReportField WHERE name = "Product Type" AND data_type_id = @dataTypeAggregationId;
SELECT @compoundingFrequencyAggrFieldId := id FROM ReportField WHERE name = "Compounding Frequency" AND data_type_id = @dataTypeAggregationId;
SELECT @interestRateAggrFieldId := id FROM ReportField WHERE name = "Interest Rate %" AND data_type_id = @dataTypeAggregationId;
SELECT @interestRateTypeAggrFieldId := id FROM ReportField WHERE name = "Interest Rate Type" AND data_type_id = @dataTypeAggregationId;
SELECT @fundingTypeAggrFieldId := id FROM ReportField WHERE name = "Funding Type" AND data_type_id = @dataTypeAggregationId;
SELECT @loanPurposeAggrFieldId := id FROM ReportField WHERE name = "Loan Purpose" AND data_type_id = @dataTypeAggregationId;
SELECT @loanPurposeCategoryAggrFieldId := id FROM ReportField WHERE name = "Loan Purpose Category" AND data_type_id = @dataTypeAggregationId;
SELECT @loanPurposeTypeAggrFieldId := id FROM ReportField WHERE name = "Loan Purpose Type" AND data_type_id = @dataTypeAggregationId;
SELECT @utilizedAmountAggrFieldId := id FROM ReportField WHERE name = "Utilized Amount" AND data_type_id = @dataTypeAggregationId;
SELECT @foreclosureReasonAggrFieldId := id FROM ReportField WHERE name = "Foreclosure Reason" AND data_type_id = @dataTypeAggregationId;
SELECT @writeoffReasonAggrFieldId := id FROM ReportField WHERE name = "Write-off Reason" AND data_type_id = @dataTypeAggregationId;
SELECT @repaymentFrequencyAggrFieldId := id FROM ReportField WHERE name = "Repayment Frequency" AND data_type_id = @dataTypeAggregationId;
SELECT @accountStatusAggrFieldId := id FROM ReportField WHERE name = "Account Status" AND data_type_id = @dataTypeAggregationId;
SELECT @loanTicketSizeAggrFieldId := id FROM ReportField WHERE name = "Loan Ticket Size" AND data_type_id = @dataTypeAggregationId;
SELECT @religiousGroupAggrFieldId := id FROM ReportField WHERE name = "Religious Group" AND data_type_id = @dataTypeAggregationId;
SELECT @casteAggrFieldId := id FROM ReportField WHERE name = "Caste" AND data_type_id = @dataTypeAggregationId;
SELECT @occupationAggrFieldId := id FROM ReportField WHERE name = "Occupation" AND data_type_id = @dataTypeAggregationId;
SELECT @educationLevelAggrFieldId := id FROM ReportField WHERE name = "Education Level" AND data_type_id = @dataTypeAggregationId;
SELECT @maritalStatusAggrFieldId := id FROM ReportField WHERE name = "Marital Status" AND data_type_id = @dataTypeAggregationId;
SELECT @collateralSizeAggrFieldId := id FROM ReportField WHERE name = "Collateral Size" AND data_type_id = @dataTypeAggregationId;
SELECT @genderAggrFieldId := id FROM ReportField WHERE name = "Gender" AND data_type_id = @dataTypeAggregationId;
SELECT @employeeTitleAggrFieldId := id FROM ReportField WHERE name = "Employee Title" AND data_type_id = @dataTypeAggregationId;
SELECT @propertyTypeAggrFieldId := id FROM ReportField WHERE name = "Property Type" AND data_type_id = @dataTypeAggregationId;
SELECT @officeCodeAggrFieldId := id FROM ReportField WHERE name = "Office Code" AND data_type_id = @dataTypeAggregationId;
SELECT @centerCodeAggrFieldId := id FROM ReportField WHERE name = "Center Code" AND data_type_id = @dataTypeAggregationId;
SELECT @groupAggrFieldId := id FROM ReportField WHERE name = "Group" AND data_type_id = @dataTypeAggregationId;
SELECT @groupCodeAggrFieldId := id FROM ReportField WHERE name = "Group Code" AND data_type_id = @dataTypeAggregationId;
SELECT @spouseNameAggrFieldId := id FROM ReportField WHERE name = "Spouse Name" AND data_type_id = @dataTypeAggregationId;
SELECT @gurantorNameCustomerAggrFieldId := id FROM ReportField WHERE name = "Guarantor Name(Customer)" AND data_type_id = @dataTypeAggregationId;
SELECT @addressAggrFieldId := id FROM ReportField WHERE name = "Address" AND data_type_id = @dataTypeAggregationId;
SELECT @villageAggrFieldId := id FROM ReportField WHERE name = "Village" AND data_type_id = @dataTypeAggregationId;
SELECT @pincodeAggrFieldId := id FROM ReportField WHERE name = "Pincode" AND data_type_id = @dataTypeAggregationId;
SELECT @telephoneAggrFieldId := id FROM ReportField WHERE name = "Telephone" AND data_type_id = @dataTypeAggregationId;
SELECT @tenureAggrFieldId := id FROM ReportField WHERE name = "Tenure" AND data_type_id = @dataTypeAggregationId;
SELECT @tenureUnitAggrFieldId := id FROM ReportField WHERE name = "Tenure Unit" AND data_type_id = @dataTypeAggregationId;
SELECT @customerNumberAggrFieldId := id FROM ReportField WHERE name = "Customer Number" AND data_type_id = @dataTypeAggregationId;
SELECT @loanCycleNumberAggrFieldId := id FROM ReportField WHERE name = "Loan Cycle Number" AND data_type_id = @dataTypeAggregationId;
SELECT @primaryIdentityProofAggrFieldId := id FROM ReportField WHERE name = "Primary Identity Proof" AND data_type_id = @dataTypeAggregationId;
SELECT @primaryIdentityProofNumberAggrFieldId := id FROM ReportField WHERE name = "Primary Identity Proof Number" AND data_type_id = @dataTypeAggregationId;
SELECT @primaryAddressProofAggrFieldId := id FROM ReportField WHERE name = "Primary Address Proof" AND data_type_id = @dataTypeAggregationId;
SELECT @primaryAddressProofNumberAggrFieldId := id FROM ReportField WHERE name = "Primary Address Proof Number" AND data_type_id = @dataTypeAggregationId;
SELECT @firstInstallmentDateAggrFieldId := id FROM ReportField WHERE name = "First Installment Date" AND data_type_id = @dataTypeAggregationId;
SELECT @lastInstallmentDateAggrFieldId := id FROM ReportField WHERE name = "Last Installment Date" AND data_type_id = @dataTypeAggregationId;
SELECT @modeOfRepaymentAggrFieldId := id FROM ReportField WHERE name = "Mode Of Repayment" AND data_type_id = @dataTypeAggregationId;
SELECT @employeeManagerAggrFieldId := id FROM ReportField WHERE name = "Employee Manager" AND data_type_id = @dataTypeAggregationId;
SELECT @daysSinceDisbursementAggrFieldId := id FROM ReportField WHERE name = "Days Since Disbursement" AND data_type_id = @dataTypeAggregationId;
SELECT @firstInstallmentMonthAggrFieldId := id FROM ReportField WHERE name = "First Installment Month" AND data_type_id = @dataTypeAggregationId;
SELECT @centerStatusRemarksAggrFieldId := id FROM ReportField WHERE name = "Center Status Remarks" AND data_type_id = @dataTypeAggregationId;
SELECT @gurantorNameLoanAggrFieldId := id FROM ReportField WHERE name = "Guarantor Name(Loan)" AND data_type_id = @dataTypeAggregationId;
SELECT @businessTypeAggrFieldId := id FROM ReportField WHERE name = "Business Type" AND data_type_id = @dataTypeAggregationId;
SELECT @stateOfficeAggrFieldId := id FROM ReportField WHERE name = "State (Office)" AND data_type_id = @dataTypeAggregationId;
SELECT @thirdPartyAggrFieldId := id FROM ReportField WHERE name = "Third Party" AND data_type_id = @dataTypeAggregationId;
SELECT @pipelineStatusAggrFieldId := id FROM ReportField WHERE name = "Pipeline Status" AND data_type_id = @dataTypeAggregationId;
SELECT @pipelineAggrFieldId := id FROM ReportField WHERE name = "Pipeline" AND data_type_id = @dataTypeAggregationId;
SELECT @cancelReasonId := id FROM ReportField WHERE name = "Cancel Reason" AND data_type_id = @dataTypeAggregationId;
SELECT @failureReasonId := id FROM ReportField WHERE name = "Failure Reason" AND data_type_id = @dataTypeAggregationId;
SELECT @bankAccountNumberFieldId := id FROM ReportField WHERE name = "Bank Account Number" AND data_type_id = @dataTypeAggregationId;
SELECT @customerAgeAggrFieldId := id FROM ReportField WHERE name = "Customer Age" AND data_type_id = @dataTypeAggregationId;
SELECT @productClassAggrFieldId := id FROM ReportField WHERE name = "Product Class" AND data_type_id = @dataTypeAggregationId;
SELECT @lastDateOfTheMonth := id FROM ReportField WHERE name = "Last Date Of The Month" AND data_type_id = @dataTypeAggregationId;
SELECT @isDisbursed := id FROM ReportField WHERE name = "Is Disbursed" AND data_type_id = @dataTypeAggregationId;
SELECT @cbNohitAggrId := id FROM ReportField WHERE name = "Customer CB No HIT" AND data_type_id = @dataTypeAggregationId;
SELECT @landholdingAggrId := id FROM ReportField WHERE name = "Customer Land Holding (acres)" AND data_type_id = @dataTypeAggregationId;
SELECT @firstRepayWeekAggrFieldId := id FROM ReportField WHERE name = "First Repayment Date Allowed Weeks" AND data_type_id = @dataTypeAggregationId;
SELECT @customerBankAccountStateId := id FROM ReportField WHERE name = "State (Customer Primary Bank Account)" AND data_type_id = @dataTypeAggregationId;
SELECT @numOtherLenderId := id FROM ReportField WHERE name = "Number of Other Active Lenders" AND data_type_id = @dataTypeAggregationId;
SELECT @numActiveAccountsId := id FROM ReportField WHERE name = "Number of Active Loans" AND data_type_id = @dataTypeAggregationId;
SELECT @totalOtherBalanceId := id FROM ReportField WHERE name = "Total Other Current Balance" AND data_type_id = @dataTypeAggregationId;
SELECT @bureauVintageId := id FROM ReportField WHERE name = "Bureau Vintage (In Days)" AND data_type_id = @dataTypeAggregationId;
SELECT @bureauScoreId := id FROM ReportField WHERE name = "Bureau Score" AND data_type_id = @dataTypeAggregationId;
SELECT @cbServiceId := id FROM ReportField WHERE name = "Credit Bureau Service" AND data_type_id = @dataTypeAggregationId;
SELECT @previousCycleLoanAmountId := id FROM ReportField WHERE name = "Loan Amount (Previous Cycle)" AND data_type_id = @dataTypeAggregationId;
SELECT @customerIncomeAggrId := id FROM ReportField WHERE name = "Customer Income" AND data_type_id = @dataTypeAggregationId;
SELECT @numberOfLoansAggrId := id FROM ReportField WHERE name = "Number Of Loans (Active & Closed)" AND data_type_id = @dataTypeAggregationId;
SELECT @totalCurrentBalanceAggrId := id FROM ReportField WHERE name = "Total Current Balance" AND data_type_id = @dataTypeAggregationId;
SELECT @savingsWithdrawalCountId := id FROM ReportField WHERE name = "Savings Withdrawal Count" AND data_type_id = @dataTypeAggregationId;
SELECT @savingsMinimumBalanceId := id FROM ReportField WHERE name = "Savings Minimum Balance" AND data_type_id = @dataTypeAggregationId;
SELECT @totalNoOfMandatoryDepositId := id FROM ReportField WHERE name = "Total No of mandatory deposit" AND data_type_id = @dataTypeAggregationId;
SELECT @isMembershipDepositPaidId := id FROM ReportField WHERE name = "Is Membership deposit paid" AND data_type_id = @dataTypeAggregationId;
SELECT @nameMatchPercentage := id FROM ReportField WHERE name = "Name Match Percentage (%)" AND data_type_id = @dataTypeAggregationId;

-- Bucket fields
SELECT @loanTicketSizeBucketFieldId := id FROM ReportField WHERE name = "Loan Ticket Size" AND data_type_id = @dataTypeBucketId;
SELECT @ageYearsBucketFieldId := id FROM ReportField WHERE name = "Age (years)" AND data_type_id = @dataTypeBucketId;
SELECT @landHoldingAcresBucketFieldId := id FROM ReportField WHERE name = "Land Holding (acres)" AND data_type_id = @dataTypeBucketId;
SELECT @householdIncomeBucketFieldId := id FROM ReportField WHERE name = "Household Income" AND data_type_id = @dataTypeBucketId;
SELECT @householdExpensesBucketFieldId := id FROM ReportField WHERE name = "Household Expenses" AND data_type_id = @dataTypeBucketId;
SELECT @disbursementsBucketFieldId := id FROM ReportField WHERE name = "Disbursements" AND data_type_id = @dataTypeBucketId;
SELECT @collectionsBucketFieldId := id FROM ReportField WHERE name = "Collections" AND data_type_id = @dataTypeBucketId;
SELECT @principalDemandsBucketFieldId := id FROM ReportField WHERE name = "Principal Demands" AND data_type_id = @dataTypeBucketId;
SELECT @interestDemandsBucketFieldId := id FROM ReportField WHERE name = "Interest Demands" AND data_type_id = @dataTypeBucketId;
SELECT @loanFeeDemandsBucketFieldId := id FROM ReportField WHERE name = "Loan Fee Demands" AND data_type_id = @dataTypeBucketId;
SELECT @insurancePremiumDemandsBucketFieldId := id FROM ReportField WHERE name = "Insurance Premium Demands" AND data_type_id = @dataTypeBucketId;
SELECT @otherDemandsBucketFieldId := id FROM ReportField WHERE name = "Other Demands" AND data_type_id = @dataTypeBucketId;
SELECT @totalDemandsBucketFieldId := id FROM ReportField WHERE name = "Total Demands" AND data_type_id = @dataTypeBucketId;
SELECT @currentPrincipalPaymentsBucketFieldId := id FROM ReportField WHERE name = "Current Principal Payments" AND data_type_id = @dataTypeBucketId;
SELECT @currentInterestPaymentsBucketFieldId := id FROM ReportField WHERE name = "Current Interest Payments" AND data_type_id = @dataTypeBucketId;
SELECT @currentFeePaymentsBucketFieldId := id FROM ReportField WHERE name = "Current Fee Payments" AND data_type_id = @dataTypeBucketId;
SELECT @currentInsurancePaymentsBucketFieldId := id FROM ReportField WHERE name = "Current Insurance Payments" AND data_type_id = @dataTypeBucketId;
SELECT @otherCurrentPaymentsBucketFieldId := id FROM ReportField WHERE name = "Other Current Payments" AND data_type_id = @dataTypeBucketId;
SELECT @totalCurrentPaymentsOnDemandsBucketFieldId := id FROM ReportField WHERE name = "Total Current Payments (On Demands)" AND data_type_id = @dataTypeBucketId;
SELECT @principalPrepaymentsBucketFieldId := id FROM ReportField WHERE name = "Principal Prepayments" AND data_type_id = @dataTypeBucketId;
SELECT @interestPrepaymentsBucketFieldId := id FROM ReportField WHERE name = "Interest Prepayments" AND data_type_id = @dataTypeBucketId;
SELECT @otherPrepaymentsBucketFieldId := id FROM ReportField WHERE name = "Other Prepayments" AND data_type_id = @dataTypeBucketId;
SELECT @totalPrepaymentsNoDemandsBucketFieldId := id FROM ReportField WHERE name = "Total Prepayments (No Demands)" AND data_type_id = @dataTypeBucketId;
SELECT @principalLatePaymentsBucketFieldId := id FROM ReportField WHERE name = "Principal Late Payments" AND data_type_id = @dataTypeBucketId;
SELECT @interestLatePaymentsBucketFieldId := id FROM ReportField WHERE name = "Interest Late Payments" AND data_type_id = @dataTypeBucketId;
SELECT @otherLatePaymentsBucketFieldId := id FROM ReportField WHERE name = "Other Late Payments" AND data_type_id = @dataTypeBucketId;
SELECT @totalLatePaymentsBucketFieldId := id FROM ReportField WHERE name = "Total Late Payments" AND data_type_id = @dataTypeBucketId;
SELECT @totalPrincipalPaymentsBucketFieldId := id FROM ReportField WHERE name = "Total Principal Payments" AND data_type_id = @dataTypeBucketId;
SELECT @totalInterestPaymentsBucketFieldId := id FROM ReportField WHERE name = "Total Interest Payments" AND data_type_id = @dataTypeBucketId;
SELECT @disbursedLoanAmountBucketFieldId := id FROM ReportField WHERE name = "Disbursed Loan Amount" AND data_type_id = @dataTypeBucketId;
SELECT @portfolioOutstandingBucketFieldId := id FROM ReportField WHERE name = "Portfolio Outstanding" AND data_type_id = @dataTypeBucketId;
SELECT @interestAccruedNotDueBucketFieldId := id FROM ReportField WHERE name = "Interest Accrued Not Due" AND data_type_id = @dataTypeBucketId;
SELECT @interestCollectedBucketFieldId := id FROM ReportField WHERE name = "Interest Collected" AND data_type_id = @dataTypeBucketId;
SELECT @interestOutstandingBucketFieldId := id FROM ReportField WHERE name = "Interest Outstanding" AND data_type_id = @dataTypeBucketId;
SELECT @advanceParkedAmountBucketFieldId := id FROM ReportField WHERE name = "Advance/Parked Amount" AND data_type_id = @dataTypeBucketId;
SELECT @overdueInterestBucketFieldId := id FROM ReportField WHERE name = "Overdue Interest" AND data_type_id = @dataTypeBucketId;
SELECT @overduePrincipalBucketFieldId := id FROM ReportField WHERE name = "Overdue Principal" AND data_type_id = @dataTypeBucketId;
SELECT @overdueAmountBucketFieldId := id FROM ReportField WHERE name = "Overdue Amount" AND data_type_id = @dataTypeBucketId;
SELECT @numOverdueDaysBucketFieldId := id FROM ReportField WHERE name = "# Overdue Days" AND data_type_id = @dataTypeBucketId;
SELECT @overduePrincipalOutstandingBucketFieldId := id FROM ReportField WHERE name = "Overdue Principal Outstanding" AND data_type_id = @dataTypeBucketId;
SELECT @installmentDateBucketFieldId := id FROM ReportField WHERE name = "Installment Date" AND data_type_id = @dataTypeBucketId;
SELECT @utilizedAmountBucketFieldId := id FROM ReportField WHERE name = "Utilized Amount" AND data_type_id = @dataTypeBucketId;
SELECT @currentPrincipalOutstandingBucketFieldId := id FROM ReportField WHERE name = "Current Principal Outstanding" AND data_type_id = @dataTypeBucketId;
SELECT @advanceCollectionBucketFieldId := id FROM ReportField WHERE name = "Advance/Parked Payments" AND data_type_id = @dataTypeBucketId;
SELECT @collateralSizeBucketFieldId := id FROM ReportField WHERE name = "Collateral Size" AND data_type_id = @dataTypeBucketId;
SELECT @daysSinceDisbursementBucketFieldId := id FROM ReportField WHERE name = "Days Since Disbursement" AND data_type_id = @dataTypeBucketId;
SELECT @fundingInstallmentDateBucketFieldId := id FROM ReportField WHERE name = "Funding Installment Date" AND data_type_id = @dataTypeBucketId;

-- Daily data fields
SELECT @principalDemandsDailyFieldId := id FROM ReportField WHERE name = "Principal Demands" AND data_type_id = @dataTypeDailyDataId;
SELECT @interestDemandsDailyFieldId := id FROM ReportField WHERE name = "Interest Demands" AND data_type_id = @dataTypeDailyDataId;
SELECT @installmentDemandsDailyFieldId := id FROM ReportField WHERE name = "Installment Demands" AND data_type_id=@dataTypeDailyDataId;
SELECT @loanFeeDemandsDailyFieldId := id FROM ReportField WHERE name = "Loan Fee Demands" AND data_type_id = @dataTypeDailyDataId;
SELECT @insurancePremiumDemandsDailyFieldId := id FROM ReportField WHERE name = "Insurance Premium Demands" AND data_type_id = @dataTypeDailyDataId;
SELECT @otherDemandsDailyFieldId := id FROM ReportField WHERE name = "Other Demands" AND data_type_id = @dataTypeDailyDataId;
SELECT @totalDemandsDailyFieldId := id FROM ReportField WHERE name = "Total Demands" AND data_type_id = @dataTypeDailyDataId;
SELECT @futureInterestDemandDailyFieldId := id FROM ReportField WHERE name = "Future Interest Demand" AND data_type_id = @dataTypeDailyDataId;
SELECT @futurePrincipalDemandDailyFieldId := id FROM ReportField WHERE name = "Future Principal Demand" AND data_type_id = @dataTypeDailyDataId;
SELECT @futureTotalDemandDailyFieldId := id FROM ReportField WHERE name = "Future Total Demand" AND data_type_id = @dataTypeDailyDataId;
SELECT @currentPrincipalPaymentsDailyFieldId := id FROM ReportField WHERE name = "Current Principal Payments" AND data_type_id = @dataTypeDailyDataId;
SELECT @principalPrepaymentsDailyFieldId := id FROM ReportField WHERE name = "Principal Prepayments" AND data_type_id = @dataTypeDailyDataId;
SELECT @principalOverdueRecoveryDailyFieldId := id FROM ReportField WHERE name = "Principal Overdue Recovery" AND data_type_id = @dataTypeDailyDataId;
SELECT @totalPrincipalPaymentsDailyFieldId := id FROM ReportField WHERE name = "Total Principal Payments" AND data_type_id = @dataTypeDailyDataId;
SELECT @currentInterestPaymentsDailyFieldId := id FROM ReportField WHERE name = "Current Interest Payments" AND data_type_id = @dataTypeDailyDataId;
SELECT @interestPrepaymentsDailyFieldId := id FROM ReportField WHERE name = "Interest Prepayments" AND data_type_id = @dataTypeDailyDataId;
SELECT @interestOverdueRecoveryDailyFieldId := id FROM ReportField WHERE name = "Interest Overdue Recovery" AND data_type_id = @dataTypeDailyDataId;
SELECT @totalInterestPaymentsDailyFieldId := id FROM ReportField WHERE name = "Total Interest Payments" AND data_type_id = @dataTypeDailyDataId;
SELECT @currentInstallmentPaymentsDailyFieldId := id FROM ReportField WHERE name = "Current Installment Payments" AND data_type_id=@dataTypeDailyDataId;
SELECT @currentFeePaymentsDailyFieldId := id FROM ReportField WHERE name = "Current Fee Payments" AND data_type_id = @dataTypeDailyDataId;
SELECT @currentInsurancePaymentsDailyFieldId := id FROM ReportField WHERE name = "Current Insurance Payments" AND data_type_id = @dataTypeDailyDataId;
SELECT @otherCurrentPaymentsDailyFieldId := id FROM ReportField WHERE name = "Other Current Payments" AND data_type_id=@dataTypeDailyDataId;
SELECT @totalCurrentPaymentsOnDemandsDailyFieldId := id FROM ReportField WHERE name = "Total Current Payments (On Demands)" AND data_type_id=@dataTypeDailyDataId;
SELECT @otherPrepaymentsDailyFieldId := id FROM ReportField WHERE name = "Other Prepayments" AND data_type_id = @dataTypeDailyDataId;
SELECT @totalPrepaymentsNoDemandsDailyFieldId := id FROM ReportField WHERE name = "Total Prepayments (No Demands)" AND data_type_id = @dataTypeDailyDataId;
SELECT @otherLatePaymentsDailyFieldId := id FROM ReportField WHERE name = "Other Late Payments" AND data_type_id = @dataTypeDailyDataId;
SELECT @totalOverdueRecoveryDailyFieldId := id FROM ReportField WHERE name = "Total Overdue Recovery" AND data_type_id=@dataTypeDailyDataId;
SELECT @advanceAppropriationDailyFieldId := id FROM ReportField WHERE name = "Advance Appropriation" AND data_type_id = @dataTypeDailyDataId;
SELECT @advanceCollectionDailyFieldId := id FROM ReportField WHERE name = "Advance/Parked Payments" AND data_type_id = @dataTypeDailyDataId;
SELECT @collectionsUnappropriatedDailyFieldId := id FROM ReportField WHERE name = "Collections (Unappropriated)" AND data_type_id=@dataTypeDailyDataId;
SELECT @totalCollectionDailyFieldId := id FROM ReportField WHERE name = "Installment+Advance Collections" AND data_type_id=@dataTypeDailyDataId;
SELECT @totalDisbursedAmountDailyFieldId := id FROM ReportField WHERE name = "Total Disbursed Amount" AND data_type_id=@dataTypeDailyDataId;
SELECT @numDisbursementsDailyFieldId := id FROM ReportField WHERE name = "# Disbursements" AND data_type_id=@dataTypeDailyDataId;
SELECT @numForeclosuresDailyFieldId := id FROM ReportField WHERE name = "# Foreclosures" AND data_type_id=@dataTypeDailyDataId;
SELECT @averageDisbursementsPerOfficerDailyFieldId := id FROM ReportField WHERE name = "Average Disbursements Per Officer" AND data_type_id=@dataTypeDailyDataId;
SELECT @collectionPercentageDailyFieldId := id FROM ReportField WHERE name = "Collection Percentage (%)" AND data_type_id=@dataTypeDailyDataId;
SELECT @totalApprovedAmountDailyFieldId := id FROM ReportField WHERE name = "Total Approved Amount" AND data_type_id = @dataTypeDailyDataId;
SELECT @collectionAmountDailyFieldId := id FROM ReportField WHERE name = "Collection Amount" AND data_type_id = @dataTypeDailyDataId;
SELECT @totalWaivedAmtDailyFieldId := id FROM ReportField WHERE name = "Total Waived Amount" AND data_type_id = @dataTypeDailyDataId;
SELECT @differentailIntDailyFieldId := id FROM ReportField WHERE name = "Differential Interest" AND data_type_id = @dataTypeDailyDataId;
SELECT @principalDemandsExcludeClosedAccountsDailyFieldId := id FROM ReportField WHERE name = "Principal Demands(Exclude Closed Accounts)" AND data_type_id = @dataTypeDailyDataId;
SELECT @interestDemandsExcludeClosedAccountsDailyFieldId := id FROM ReportField WHERE name = "Interest Demands(Exclude Closed Accounts)" AND data_type_id = @dataTypeDailyDataId;
SELECT @totalDemandsExcludeClosedAccountsDailyFieldId := id FROM ReportField WHERE name = "Total Demands(Exclude Closed Accounts)" AND data_type_id = @dataTypeDailyDataId;
SELECT @currentPrincipalPaymentsExcludeClosedAccountsDailyFieldId := id FROM ReportField WHERE name = "Current Principal Payments(Exclude Closed Accounts)" AND data_type_id = @dataTypeDailyDataId;
SELECT @currentInterestPaymentsExcludeClosedAccountsDailyFieldId := id FROM ReportField WHERE name = "Current Interest Payments(Exclude Closed Accounts)" AND data_type_id = @dataTypeDailyDataId;
SELECT @totalPrincipalPaymentsExcludeClosedAccountsDailyFieldId := id FROM ReportField WHERE name = "Total Principal Payments(Exclude Closed Accounts)" AND data_type_id = @dataTypeDailyDataId;
SELECT @totalInterestPaymentsExcludeClosedAccountsDailyFieldId := id FROM ReportField WHERE name = "Total Interest Payments(Exclude Closed Accounts)" AND data_type_id = @dataTypeDailyDataId;
SELECT @foreclosurePrincipalPaymentsDailyFieldId := id FROM ReportField WHERE name = "Foreclosure Principal Payments" AND data_type_id = @dataTypeDailyDataId;
SELECT @foreclosureInterestPaymentsDailyFieldId := id FROM ReportField WHERE name = "Foreclosure Interest Payments" AND data_type_id = @dataTypeDailyDataId;
SELECT @deathPrincipalPaymentsDailyFieldId := id FROM ReportField WHERE name = "Death Principal Payments" AND data_type_id = @dataTypeDailyDataId;
SELECT @deathInterestPaymentsDailyFieldId := id FROM ReportField WHERE name = "Death Interest Payments" AND data_type_id = @dataTypeDailyDataId;
SELECT @interestAccruedBODDailyFieldId := id FROM ReportField WHERE name = "Interest Accrued Not Due(BOD)" AND data_type_id = @dataTypeDailyDataId;
SELECT @interestAccruedEODDailyFieldId := id FROM ReportField WHERE name = "Interest Accrued Not Due(EOD)" AND data_type_id = @dataTypeDailyDataId;
SELECT @morIntCollectedDailyFieldId := id FROM ReportField WHERE name = "Moratorium Interest Collected" AND data_type_id = @dataTypeDailyDataId;
SELECT @equMorIntDemandDailyFieldId := id FROM ReportField WHERE name = "Equated Moratorium Interest Demand" AND data_type_id = @dataTypeDailyDataId;
SELECT @fromRoundOffDailyFieldId := id FROM ReportField WHERE name = "From Round-off" AND data_type_id = @dataTypeDailyDataId;
SELECT @toRoundOffDailyFieldId := id FROM ReportField WHERE name = "To Round-off" AND data_type_id = @dataTypeDailyDataId;

-- Pipeline fields
SELECT @completedPipelineDailyFieldId := id FROM ReportField WHERE name = "Completed Pipeline" AND data_type_id=@dataTypeDailyDataId;
SELECT @dateOfCompletionDailyFieldId := id FROM ReportField WHERE name = "Date Of Completion" AND data_type_id=@dataTypeDailyDataId;
SELECT @centerSizeDailyFieldId := id FROM ReportField WHERE name = "Center Size" AND data_type_id=@dataTypeDailyDataId;
SELECT @cycleNumberDailyFieldId := id FROM ReportField WHERE name = "Cycle Number" AND data_type_id=@dataTypeDailyDataId;
SELECT @amountDailyFieldId := id FROM ReportField WHERE name = "Amount" AND data_type_id=@dataTypeDailyDataId;

SELECT @futureInterestPayableDailyFieldId := id FROM ReportField WHERE name = "Future Interest Payable" AND data_type_id = @dataTypeDailyDataId;
SELECT @futurePrincipalPayableDailyFieldId := id FROM ReportField WHERE name = "Future Principal Payable" AND data_type_id = @dataTypeDailyDataId;
SELECT @futureTotalPayableDailyFieldId := id FROM ReportField WHERE name = "Future Total Payable" AND data_type_id = @dataTypeDailyDataId;

-- Cumulative data fields
SELECT @disbursedLoanAmountCumuFieldId := id FROM ReportField WHERE name = "Disbursed Loan Amount" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @portfolioOutstandingCumuFieldId := id FROM ReportField WHERE name = "Portfolio Outstanding" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @interestCollectedCumuFieldId := id FROM ReportField WHERE name = "Interest Collected" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @interestOutstandingCumuFieldId := id FROM ReportField WHERE name = "Interest Outstanding" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @totalOutstandingCumuFieldId := id FROM ReportField WHERE name = "Total Outstanding" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @advanceParkedAmountCumuFieldId := id FROM ReportField WHERE name = "Advance/Parked Amount" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @overdueInterestCumuFieldId := id FROM ReportField WHERE name = "Overdue Interest" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @overduePrincipalCumuFieldId := id FROM ReportField WHERE name = "Overdue Principal" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @overdueAmountCumuFieldId := id FROM ReportField WHERE name = "Overdue Amount" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @overduePrincipalDaysCumuFieldId := id FROM ReportField WHERE name = "Overdue Principal Days" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @numCurrentLoanAccountsCumuFieldId := id FROM ReportField WHERE name = "# Current Loan Accounts" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @numOpenLoanAccountsCumuFieldId := id FROM ReportField WHERE name = "# Open Loan Accounts" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @numActiveLoanCustomersCumuFieldId := id FROM ReportField WHERE name = "# Active Loan Customers" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @numOpenLoanCustomersCumuFieldId := id FROM ReportField WHERE name = "# Open Loan Customers" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @numOpenLoanCentersCumuFieldId := id FROM ReportField WHERE name = "# Open Loan Centers" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @averageLoanSizeCumuFieldId := id FROM ReportField WHERE name = "Average Loan Size" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @numEnrollmentsCumuFieldId := id FROM ReportField WHERE name = "# Enrollments" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @openLoansExclNewDisbCumuFieldId := id FROM ReportField WHERE name = "# Open Loans (excl. New Disb)" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @loanUtilizationCheckCumuFieldId := id FROM ReportField WHERE name = "Loan Utilization Check (%)" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @installmentAmountCumuFieldId := id FROM ReportField WHERE name = "Installment Amount" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @advanceInstallmentAmountCumuFieldId := id FROM ReportField WHERE name = "Advance Installment Amount" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @futureInstallmentAmountCumuFieldId := id FROM ReportField WHERE name = "Future Installment Amount" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @remainingTenureInDaysCumuFieldId := id FROM ReportField WHERE name = "Remaining Tenure (In Days)" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @totalInterestExpectedCumuFieldId := id FROM ReportField WHERE name = "Total Interest Expected" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @numOverdueInstallmentsCumuFieldId := id FROM ReportField WHERE name = "# Overdue Installments" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @daysSinceDisbursementCumuFieldId := id FROM ReportField WHERE name = "Days Since Disbursement" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @numCentersCumuFieldId := id FROM ReportField WHERE name = "# Centers" AND data_type_id=@dataTypeCumulativeDataId;
SELECT @averageLoansPerCenterCumuFieldId := id FROM ReportField WHERE name = "Average Loans Per Center" AND data_type_id=@dataTypeCumulativeDataId;
SELECT @numOfficersCumuFieldId := id FROM ReportField WHERE name = "# Officers" AND data_type_id=@dataTypeCumulativeDataId;
SELECT @averageLoansPerOfficerCumuFieldId := id FROM ReportField WHERE name = "Average Loans Per Officer" AND data_type_id=@dataTypeCumulativeDataId;
SELECT @averagePortfolioOutstandingPerOfficerCumuFieldId := id FROM ReportField WHERE name = "Average Portfolio Outstanding Per Officer" AND data_type_id=@dataTypeCumulativeDataId;
SELECT @numCustomersWithAadharCardCumuFieldId := id FROM ReportField WHERE name = "# Customers with Aadhar Card" AND data_type_id=@dataTypeCumulativeDataId;
SELECT @customersWithAadharCardPercentageCumuFieldId := id FROM ReportField WHERE name = "Customers with Aadhar Card (%)" AND data_type_id=@dataTypeCumulativeDataId;
SELECT @telephoneCumuFieldId := id FROM ReportField WHERE name = "# Customers with Telephone" AND data_type_id=@dataTypeCumulativeDataId;
SELECT @telephonePercentageCumuFieldId := id FROM ReportField WHERE name = "Customers with Telephone (%)" AND data_type_id=@dataTypeCumulativeDataId;
SELECT @derivedPortfolioCumuFieldId := id FROM ReportField WHERE name = "Derived Portfolio Outstanding" AND data_type_id=@dataTypeCumulativeDataId;
SELECT @openingOutstandingCumuFieldId := id FROM ReportField WHERE name = "Opening Portfolio Outstanding" AND data_type_id=@dataTypeCumulativeDataId;
SELECT @closingOutstandingCumuFieldId := id FROM ReportField WHERE name = "Closing Portfolio Outstanding" AND data_type_id=@dataTypeCumulativeDataId;
SELECT @openingAdvanceCumuFieldId := id FROM ReportField WHERE name = "Opening Advance/Parked Amount" AND data_type_id=@dataTypeCumulativeDataId;
SELECT @closingAdvanceCumuFieldId := id FROM ReportField WHERE name = "Closing Advance/Parked Amount" AND data_type_id=@dataTypeCumulativeDataId;
SELECT @daysSinceFirstRepayDateId := id FROM ReportField WHERE name = "Days since first repay date" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @attendancePercentageId := id FROM ReportField WHERE name = "Attendance Percentage" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @tenureMaximumOverduePrincipalDaysId := id FROM ReportField WHERE name = "Tenure Maximum overdue principal days" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @fundingInstallmentsId := id FROM ReportField WHERE name = "# Funding Installments" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @fundingInstallmentAmountId := id FROM ReportField WHERE name = "Future Funding Installment Amount" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @interestAccruedBODCumuFieldId := id FROM ReportField WHERE name = "Interest Accrued Not Due(BOD)" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @interestAccruedEODCumuFieldId := id FROM ReportField WHERE name = "Interest Accrued Not Due(EOD)" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @overduePrincipalExcludeClosedAccountsCumuFieldId := id FROM ReportField WHERE name = "Overdue Principal(Exclude Closed Accounts)" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @overdueInterestExcludeClosedAccountsCumuFieldId := id FROM ReportField WHERE name = "Overdue Interest(Exclude Closed Accounts)" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @principalOutstandingExcludeClosedAccountsCumuFieldId := id FROM ReportField WHERE name = "Principal Outstanding(Exclude Closed Accounts)" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @loanAmountCumId := id FROM ReportField WHERE name = "Loan Amount" AND data_type_id = @dataTypeCumulativeDataId;
SELECT @morIntCollectedCumId := id FROM ReportField WHERE name = "Moratorium Interest Collected (Till Date)" AND data_type_id = @dataTypeCumulativeDataId;

-- Par cumulative data fields
SELECT @portfolioAtRiskParCumuFieldId := id FROM ReportField WHERE name = "Portfolio At Risk (%)" AND data_type_id = @dataTypeParCumulativeDataId;
SELECT @arrearsRateParCumuFieldId := id FROM ReportField WHERE name = "Arrears Rate (%)" AND data_type_id = @dataTypeParCumulativeDataId;
SELECT @otrr1ExclClaimParCumuFieldId := id FROM ReportField WHERE name = "OTRR-1 (excl. Claim)" AND data_type_id = @dataTypeParCumulativeDataId;

-- Current stat fields
SELECT @currentPortfolioOutstandingStatFieldId := id FROM ReportField WHERE name = "Current Portfolio Outstanding" AND data_type_id = @dataTypeCurrentStatDataId;

--
-- Master table values for ReportFieldOperator
--
DELETE FROM ReportFieldOperator;

-- Aggregation fields
INSERT INTO ReportFieldOperator(report_field_id, operator_id) VALUES
(@dateAggrFieldId, @betweenOperatorId),
(@monthAggrFieldId, @betweenOperatorId),
(@officeAggrFieldId, @inOperatorId),
(@parentOffice1AggrFieldId, @inOperatorId),
(@parentOffice2AggrFieldId, @inOperatorId),
(@parentOffice3AggrFieldId, @inOperatorId),
(@parentOffice4AggrFieldId, @inOperatorId),
(@productAggrFieldId, @inOperatorId),
(@officerAggrFieldId, @inOperatorId),
(@centerAggrFieldId, @inOperatorId),
(@funderAggrFieldId, @inOperatorId),
(@fundingSourceAggrFieldId, @inOperatorId),
(@weekdayAggrFieldId, @inOperatorId),
(@disbursementDateAggrFieldId, @listBetweenOperatorId),
(@disbursementMonthAggrFieldId, @listBetweenOperatorId),
(@maturityMonthAggrFieldId, @listBetweenOperatorId),
(@officeLocaleAggrFieldId, @inOperatorId),
(@customerLocaleAggrFieldId, @inOperatorId),
(@stateCustomerAggrFieldId, @inOperatorId),
(@districtAggrFieldId, @inOperatorId),
(@stateOfficeAggrFieldId, @inOperatorId),
(@productCategoryAggrFieldId, @inOperatorId),
(@productTypeAggrFieldId, @inOperatorId),
(@compoundingFrequencyAggrFieldId, @inOperatorId),
(@interestRateAggrFieldId, @betweenOperatorId),
(@interestRateTypeAggrFieldId, @inOperatorId),
(@fundingTypeAggrFieldId, @inOperatorId),
(@loanPurposeAggrFieldId, @inOperatorId),
(@loanPurposeCategoryAggrFieldId, @inOperatorId),
(@loanPurposeTypeAggrFieldId, @inOperatorId),
(@utilizedAmountAggrFieldId, @betweenOperatorId),
(@foreclosureReasonAggrFieldId, @inOperatorId),
(@writeoffReasonAggrFieldId, @inOperatorId),
(@repaymentFrequencyAggrFieldId, @inOperatorId),
(@accountStatusAggrFieldId, @inOperatorId),
(@loanTicketSizeAggrFieldId, @betweenOperatorId),
(@religiousGroupAggrFieldId, @inOperatorId),
(@casteAggrFieldId, @inOperatorId),
(@occupationAggrFieldId, @inOperatorId),
(@educationLevelAggrFieldId, @inOperatorId),
(@maritalStatusAggrFieldId, @inOperatorId),
(@collateralSizeAggrFieldId, @inOperatorId),
(@genderAggrFieldId, @inOperatorId),
(@employeeTitleAggrFieldId, @inOperatorId),
(@propertyTypeAggrFieldId, @inOperatorId),
(@officeCodeAggrFieldId, @inOperatorId),
(@centerCodeAggrFieldId, @inOperatorId),
(@villageAggrFieldId, @inOperatorId),
(@pincodeAggrFieldId, @inOperatorId),
(@tenureAggrFieldId, @inOperatorId),
(@tenureUnitAggrFieldId, @inOperatorId),
(@loanCycleNumberAggrFieldId, @inOperatorId),
(@primaryIdentityProofAggrFieldId, @inOperatorId),
(@primaryAddressProofAggrFieldId, @inOperatorId),
(@firstInstallmentDateAggrFieldId, @betweenOperatorId),
(@lastInstallmentDateAggrFieldId, @betweenOperatorId),
(@modeOfRepaymentAggrFieldId, @inOperatorId),
(@employeeManagerAggrFieldId, @inOperatorId),
(@daysSinceDisbursementAggrFieldId, @inOperatorId),
(@firstInstallmentMonthAggrFieldId, @listBetweenOperatorId),
(@businessTypeAggrFieldId, @inOperatorId),
(@thirdPartyAggrFieldId, @inOperatorId),
(@pipelineStatusAggrFieldId, @equalsOperatorId);

-- Bucket fields
INSERT INTO ReportFieldOperator(report_field_id, operator_id) VALUES
(@interestDemandsBucketFieldId, @betweenOperatorId),
(@loanFeeDemandsBucketFieldId, @betweenOperatorId),
(@insurancePremiumDemandsBucketFieldId, @betweenOperatorId),
(@otherDemandsBucketFieldId, @betweenOperatorId),
(@totalDemandsBucketFieldId, @betweenOperatorId),
(@currentPrincipalPaymentsBucketFieldId, @betweenOperatorId),
(@currentInterestPaymentsBucketFieldId, @betweenOperatorId),
(@currentFeePaymentsBucketFieldId, @betweenOperatorId),
(@currentInsurancePaymentsBucketFieldId, @betweenOperatorId),
(@otherCurrentPaymentsBucketFieldId, @betweenOperatorId),
(@totalCurrentPaymentsOnDemandsBucketFieldId, @betweenOperatorId),
(@principalPrepaymentsBucketFieldId, @betweenOperatorId),
(@interestPrepaymentsBucketFieldId, @betweenOperatorId),
(@otherPrepaymentsBucketFieldId, @betweenOperatorId),
(@totalPrepaymentsNoDemandsBucketFieldId, @betweenOperatorId),
(@principalLatePaymentsBucketFieldId, @betweenOperatorId),
(@interestLatePaymentsBucketFieldId, @betweenOperatorId),
(@otherLatePaymentsBucketFieldId, @betweenOperatorId),
(@totalLatePaymentsBucketFieldId, @betweenOperatorId),
(@totalPrincipalPaymentsBucketFieldId, @betweenOperatorId),
(@totalInterestPaymentsBucketFieldId, @betweenOperatorId),
(@advanceCollectionBucketFieldId, @betweenOperatorId),
(@disbursedLoanAmountBucketFieldId, @betweenOperatorId),
(@portfolioOutstandingBucketFieldId, @betweenOperatorId),
(@interestCollectedBucketFieldId, @betweenOperatorId),
(@interestOutstandingBucketFieldId, @betweenOperatorId),
(@advanceParkedAmountBucketFieldId, @betweenOperatorId),
(@overdueInterestBucketFieldId, @betweenOperatorId),
(@overduePrincipalBucketFieldId, @betweenOperatorId),
(@overdueAmountBucketFieldId, @betweenOperatorId),
(@numOverdueDaysBucketFieldId, @betweenOperatorId),
(@installmentDateBucketFieldId, @betweenOperatorId);

-- Daily data fields
INSERT INTO ReportFieldOperator(report_field_id, operator_id) VALUES
(@principalDemandsDailyFieldId, @equalsOperatorId),
(@principalDemandsDailyFieldId, @notEqualsOperatorId),
(@principalDemandsDailyFieldId, @lesserOperatorId),
(@principalDemandsDailyFieldId, @greaterOperatorId),
(@principalDemandsDailyFieldId, @lesserEqualOperatorId),
(@principalDemandsDailyFieldId, @greaterEqualOperatorId),
(@principalDemandsDailyFieldId, @inOperatorId),
(@principalDemandsDailyFieldId, @betweenOperatorId),
(@interestDemandsDailyFieldId, @equalsOperatorId),
(@interestDemandsDailyFieldId, @notEqualsOperatorId),
(@interestDemandsDailyFieldId, @lesserOperatorId),
(@interestDemandsDailyFieldId, @greaterOperatorId),
(@interestDemandsDailyFieldId, @lesserEqualOperatorId),
(@interestDemandsDailyFieldId, @greaterEqualOperatorId),
(@interestDemandsDailyFieldId, @inOperatorId),
(@interestDemandsDailyFieldId, @betweenOperatorId),
(@installmentDemandsDailyFieldId, @equalsOperatorId),
(@installmentDemandsDailyFieldId, @notEqualsOperatorId),
(@installmentDemandsDailyFieldId, @lesserOperatorId),
(@installmentDemandsDailyFieldId, @greaterOperatorId),
(@installmentDemandsDailyFieldId, @lesserEqualOperatorId),
(@installmentDemandsDailyFieldId, @greaterEqualOperatorId),
(@installmentDemandsDailyFieldId, @inOperatorId),
(@installmentDemandsDailyFieldId, @betweenOperatorId),
(@loanFeeDemandsDailyFieldId, @equalsOperatorId),
(@loanFeeDemandsDailyFieldId, @notEqualsOperatorId),
(@loanFeeDemandsDailyFieldId, @lesserOperatorId),
(@loanFeeDemandsDailyFieldId, @greaterOperatorId),
(@loanFeeDemandsDailyFieldId, @lesserEqualOperatorId),
(@loanFeeDemandsDailyFieldId, @greaterEqualOperatorId),
(@loanFeeDemandsDailyFieldId, @inOperatorId),
(@loanFeeDemandsDailyFieldId, @betweenOperatorId),
(@insurancePremiumDemandsDailyFieldId, @equalsOperatorId),
(@insurancePremiumDemandsDailyFieldId, @notEqualsOperatorId),
(@insurancePremiumDemandsDailyFieldId, @lesserOperatorId),
(@insurancePremiumDemandsDailyFieldId, @greaterOperatorId),
(@insurancePremiumDemandsDailyFieldId, @lesserEqualOperatorId),
(@insurancePremiumDemandsDailyFieldId, @greaterEqualOperatorId),
(@insurancePremiumDemandsDailyFieldId, @inOperatorId),
(@insurancePremiumDemandsDailyFieldId, @betweenOperatorId),
(@otherDemandsDailyFieldId, @equalsOperatorId),
(@otherDemandsDailyFieldId, @notEqualsOperatorId),
(@otherDemandsDailyFieldId, @lesserOperatorId),
(@otherDemandsDailyFieldId, @greaterOperatorId),
(@otherDemandsDailyFieldId, @lesserEqualOperatorId),
(@otherDemandsDailyFieldId, @greaterEqualOperatorId),
(@otherDemandsDailyFieldId, @inOperatorId),
(@otherDemandsDailyFieldId, @betweenOperatorId),
(@totalDemandsDailyFieldId, @equalsOperatorId),
(@totalDemandsDailyFieldId, @notEqualsOperatorId),
(@totalDemandsDailyFieldId, @lesserOperatorId),
(@totalDemandsDailyFieldId, @greaterOperatorId),
(@totalDemandsDailyFieldId, @lesserEqualOperatorId),
(@totalDemandsDailyFieldId, @greaterEqualOperatorId),
(@totalDemandsDailyFieldId, @inOperatorId),
(@totalDemandsDailyFieldId, @betweenOperatorId),
(@futureInterestDemandDailyFieldId, @equalsOperatorId),
(@futureInterestDemandDailyFieldId, @notEqualsOperatorId),
(@futureInterestDemandDailyFieldId, @lesserOperatorId),
(@futureInterestDemandDailyFieldId, @greaterOperatorId),
(@futureInterestDemandDailyFieldId, @lesserEqualOperatorId),
(@futureInterestDemandDailyFieldId, @greaterEqualOperatorId),
(@futureInterestDemandDailyFieldId, @inOperatorId),
(@futureInterestDemandDailyFieldId, @betweenOperatorId),
(@futurePrincipalDemandDailyFieldId, @equalsOperatorId),
(@futurePrincipalDemandDailyFieldId, @notEqualsOperatorId),
(@futurePrincipalDemandDailyFieldId, @lesserOperatorId),
(@futurePrincipalDemandDailyFieldId, @greaterOperatorId),
(@futurePrincipalDemandDailyFieldId, @lesserEqualOperatorId),
(@futurePrincipalDemandDailyFieldId, @greaterEqualOperatorId),
(@futurePrincipalDemandDailyFieldId, @inOperatorId),
(@futurePrincipalDemandDailyFieldId, @betweenOperatorId),
(@futureTotalDemandDailyFieldId, @equalsOperatorId),
(@futureTotalDemandDailyFieldId, @notEqualsOperatorId),
(@futureTotalDemandDailyFieldId, @lesserOperatorId),
(@futureTotalDemandDailyFieldId, @greaterOperatorId),
(@futureTotalDemandDailyFieldId, @lesserEqualOperatorId),
(@futureTotalDemandDailyFieldId, @greaterEqualOperatorId),
(@futureTotalDemandDailyFieldId, @inOperatorId),
(@futureTotalDemandDailyFieldId, @betweenOperatorId),
(@currentPrincipalPaymentsDailyFieldId, @equalsOperatorId),
(@currentPrincipalPaymentsDailyFieldId, @notEqualsOperatorId),
(@currentPrincipalPaymentsDailyFieldId, @lesserOperatorId),
(@currentPrincipalPaymentsDailyFieldId, @greaterOperatorId),
(@currentPrincipalPaymentsDailyFieldId, @lesserEqualOperatorId),
(@currentPrincipalPaymentsDailyFieldId, @greaterEqualOperatorId),
(@currentPrincipalPaymentsDailyFieldId, @inOperatorId),
(@currentPrincipalPaymentsDailyFieldId, @betweenOperatorId),
(@principalPrepaymentsDailyFieldId, @equalsOperatorId),
(@principalPrepaymentsDailyFieldId, @notEqualsOperatorId),
(@principalPrepaymentsDailyFieldId, @lesserOperatorId),
(@principalPrepaymentsDailyFieldId, @greaterOperatorId),
(@principalPrepaymentsDailyFieldId, @lesserEqualOperatorId),
(@principalPrepaymentsDailyFieldId, @greaterEqualOperatorId),
(@principalPrepaymentsDailyFieldId, @inOperatorId),
(@principalPrepaymentsDailyFieldId, @betweenOperatorId),
(@principalOverdueRecoveryDailyFieldId, @equalsOperatorId),
(@principalOverdueRecoveryDailyFieldId, @notEqualsOperatorId),
(@principalOverdueRecoveryDailyFieldId, @lesserOperatorId),
(@principalOverdueRecoveryDailyFieldId, @greaterOperatorId),
(@principalOverdueRecoveryDailyFieldId, @lesserEqualOperatorId),
(@principalOverdueRecoveryDailyFieldId, @greaterEqualOperatorId),
(@principalOverdueRecoveryDailyFieldId, @inOperatorId),
(@principalOverdueRecoveryDailyFieldId, @betweenOperatorId),
(@totalPrincipalPaymentsDailyFieldId, @equalsOperatorId),
(@totalPrincipalPaymentsDailyFieldId, @notEqualsOperatorId),
(@totalPrincipalPaymentsDailyFieldId, @lesserOperatorId),
(@totalPrincipalPaymentsDailyFieldId, @greaterOperatorId),
(@totalPrincipalPaymentsDailyFieldId, @lesserEqualOperatorId),
(@totalPrincipalPaymentsDailyFieldId, @greaterEqualOperatorId),
(@totalPrincipalPaymentsDailyFieldId, @inOperatorId),
(@totalPrincipalPaymentsDailyFieldId, @betweenOperatorId),
(@currentInterestPaymentsDailyFieldId, @equalsOperatorId),
(@currentInterestPaymentsDailyFieldId, @notEqualsOperatorId),
(@currentInterestPaymentsDailyFieldId, @lesserOperatorId),
(@currentInterestPaymentsDailyFieldId, @greaterOperatorId),
(@currentInterestPaymentsDailyFieldId, @lesserEqualOperatorId),
(@currentInterestPaymentsDailyFieldId, @greaterEqualOperatorId),
(@currentInterestPaymentsDailyFieldId, @inOperatorId),
(@currentInterestPaymentsDailyFieldId, @betweenOperatorId),
(@interestPrepaymentsDailyFieldId, @equalsOperatorId),
(@interestPrepaymentsDailyFieldId, @notEqualsOperatorId),
(@interestPrepaymentsDailyFieldId, @lesserOperatorId),
(@interestPrepaymentsDailyFieldId, @greaterOperatorId),
(@interestPrepaymentsDailyFieldId, @lesserEqualOperatorId),
(@interestPrepaymentsDailyFieldId, @greaterEqualOperatorId),
(@interestPrepaymentsDailyFieldId, @inOperatorId),
(@interestPrepaymentsDailyFieldId, @betweenOperatorId),
(@interestOverdueRecoveryDailyFieldId, @equalsOperatorId),
(@interestOverdueRecoveryDailyFieldId, @notEqualsOperatorId),
(@interestOverdueRecoveryDailyFieldId, @lesserOperatorId),
(@interestOverdueRecoveryDailyFieldId, @greaterOperatorId),
(@interestOverdueRecoveryDailyFieldId, @lesserEqualOperatorId),
(@interestOverdueRecoveryDailyFieldId, @greaterEqualOperatorId),
(@interestOverdueRecoveryDailyFieldId, @inOperatorId),
(@interestOverdueRecoveryDailyFieldId, @betweenOperatorId),
(@totalInterestPaymentsDailyFieldId, @equalsOperatorId),
(@totalInterestPaymentsDailyFieldId, @notEqualsOperatorId),
(@totalInterestPaymentsDailyFieldId, @lesserOperatorId),
(@totalInterestPaymentsDailyFieldId, @greaterOperatorId),
(@totalInterestPaymentsDailyFieldId, @lesserEqualOperatorId),
(@totalInterestPaymentsDailyFieldId, @greaterEqualOperatorId),
(@totalInterestPaymentsDailyFieldId, @inOperatorId),
(@totalInterestPaymentsDailyFieldId, @betweenOperatorId),
(@currentInstallmentPaymentsDailyFieldId, @equalsOperatorId),
(@currentInstallmentPaymentsDailyFieldId, @notEqualsOperatorId),
(@currentInstallmentPaymentsDailyFieldId, @lesserOperatorId),
(@currentInstallmentPaymentsDailyFieldId, @greaterOperatorId),
(@currentInstallmentPaymentsDailyFieldId, @lesserEqualOperatorId),
(@currentInstallmentPaymentsDailyFieldId, @greaterEqualOperatorId),
(@currentInstallmentPaymentsDailyFieldId, @inOperatorId),
(@currentInstallmentPaymentsDailyFieldId, @betweenOperatorId),
(@currentFeePaymentsDailyFieldId, @equalsOperatorId),
(@currentFeePaymentsDailyFieldId, @notEqualsOperatorId),
(@currentFeePaymentsDailyFieldId, @lesserOperatorId),
(@currentFeePaymentsDailyFieldId, @greaterOperatorId),
(@currentFeePaymentsDailyFieldId, @lesserEqualOperatorId),
(@currentFeePaymentsDailyFieldId, @greaterEqualOperatorId),
(@currentFeePaymentsDailyFieldId, @inOperatorId),
(@currentFeePaymentsDailyFieldId, @betweenOperatorId),
(@currentInsurancePaymentsDailyFieldId, @equalsOperatorId),
(@currentInsurancePaymentsDailyFieldId, @notEqualsOperatorId),
(@currentInsurancePaymentsDailyFieldId, @lesserOperatorId),
(@currentInsurancePaymentsDailyFieldId, @greaterOperatorId),
(@currentInsurancePaymentsDailyFieldId, @lesserEqualOperatorId),
(@currentInsurancePaymentsDailyFieldId, @greaterEqualOperatorId),
(@currentInsurancePaymentsDailyFieldId, @inOperatorId),
(@currentInsurancePaymentsDailyFieldId, @betweenOperatorId),
(@otherCurrentPaymentsDailyFieldId, @equalsOperatorId),
(@otherCurrentPaymentsDailyFieldId, @notEqualsOperatorId),
(@otherCurrentPaymentsDailyFieldId, @lesserOperatorId),
(@otherCurrentPaymentsDailyFieldId, @greaterOperatorId),
(@otherCurrentPaymentsDailyFieldId, @lesserEqualOperatorId),
(@otherCurrentPaymentsDailyFieldId, @greaterEqualOperatorId),
(@otherCurrentPaymentsDailyFieldId, @inOperatorId),
(@otherCurrentPaymentsDailyFieldId, @betweenOperatorId),
(@totalCurrentPaymentsOnDemandsDailyFieldId, @equalsOperatorId),
(@totalCurrentPaymentsOnDemandsDailyFieldId, @notEqualsOperatorId),
(@totalCurrentPaymentsOnDemandsDailyFieldId, @lesserOperatorId),
(@totalCurrentPaymentsOnDemandsDailyFieldId, @greaterOperatorId),
(@totalCurrentPaymentsOnDemandsDailyFieldId, @lesserEqualOperatorId),
(@totalCurrentPaymentsOnDemandsDailyFieldId, @greaterEqualOperatorId),
(@totalCurrentPaymentsOnDemandsDailyFieldId, @inOperatorId),
(@totalCurrentPaymentsOnDemandsDailyFieldId, @betweenOperatorId),
(@otherPrepaymentsDailyFieldId, @equalsOperatorId),
(@otherPrepaymentsDailyFieldId, @notEqualsOperatorId),
(@otherPrepaymentsDailyFieldId, @lesserOperatorId),
(@otherPrepaymentsDailyFieldId, @greaterOperatorId),
(@otherPrepaymentsDailyFieldId, @lesserEqualOperatorId),
(@otherPrepaymentsDailyFieldId, @greaterEqualOperatorId),
(@otherPrepaymentsDailyFieldId, @inOperatorId),
(@otherPrepaymentsDailyFieldId, @betweenOperatorId),
(@totalPrepaymentsNoDemandsDailyFieldId, @equalsOperatorId),
(@totalPrepaymentsNoDemandsDailyFieldId, @notEqualsOperatorId),
(@totalPrepaymentsNoDemandsDailyFieldId, @lesserOperatorId),
(@totalPrepaymentsNoDemandsDailyFieldId, @greaterOperatorId),
(@totalPrepaymentsNoDemandsDailyFieldId, @lesserEqualOperatorId),
(@totalPrepaymentsNoDemandsDailyFieldId, @greaterEqualOperatorId),
(@totalPrepaymentsNoDemandsDailyFieldId, @inOperatorId),
(@totalPrepaymentsNoDemandsDailyFieldId, @betweenOperatorId),
(@otherLatePaymentsDailyFieldId, @equalsOperatorId),
(@otherLatePaymentsDailyFieldId, @notEqualsOperatorId),
(@otherLatePaymentsDailyFieldId, @lesserOperatorId),
(@otherLatePaymentsDailyFieldId, @greaterOperatorId),
(@otherLatePaymentsDailyFieldId, @lesserEqualOperatorId),
(@otherLatePaymentsDailyFieldId, @greaterEqualOperatorId),
(@otherLatePaymentsDailyFieldId, @inOperatorId),
(@otherLatePaymentsDailyFieldId, @betweenOperatorId),
(@totalOverdueRecoveryDailyFieldId, @equalsOperatorId),
(@totalOverdueRecoveryDailyFieldId, @notEqualsOperatorId),
(@totalOverdueRecoveryDailyFieldId, @lesserOperatorId),
(@totalOverdueRecoveryDailyFieldId, @greaterOperatorId),
(@totalOverdueRecoveryDailyFieldId, @lesserEqualOperatorId),
(@totalOverdueRecoveryDailyFieldId, @greaterEqualOperatorId),
(@totalOverdueRecoveryDailyFieldId, @inOperatorId),
(@totalOverdueRecoveryDailyFieldId, @betweenOperatorId),
(@advanceAppropriationDailyFieldId, @equalsOperatorId),
(@advanceAppropriationDailyFieldId, @notEqualsOperatorId),
(@advanceAppropriationDailyFieldId, @lesserOperatorId),
(@advanceAppropriationDailyFieldId, @greaterOperatorId),
(@advanceAppropriationDailyFieldId, @lesserEqualOperatorId),
(@advanceAppropriationDailyFieldId, @greaterEqualOperatorId),
(@advanceAppropriationDailyFieldId, @inOperatorId),
(@advanceAppropriationDailyFieldId, @betweenOperatorId),
(@advanceCollectionDailyFieldId, @equalsOperatorId),
(@advanceCollectionDailyFieldId, @notEqualsOperatorId),
(@advanceCollectionDailyFieldId, @lesserOperatorId),
(@advanceCollectionDailyFieldId, @greaterOperatorId),
(@advanceCollectionDailyFieldId, @lesserEqualOperatorId),
(@advanceCollectionDailyFieldId, @greaterEqualOperatorId),
(@advanceCollectionDailyFieldId, @inOperatorId),
(@advanceCollectionDailyFieldId, @betweenOperatorId),
(@collectionsUnappropriatedDailyFieldId, @equalsOperatorId),
(@collectionsUnappropriatedDailyFieldId, @notEqualsOperatorId),
(@collectionsUnappropriatedDailyFieldId, @lesserOperatorId),
(@collectionsUnappropriatedDailyFieldId, @greaterOperatorId),
(@collectionsUnappropriatedDailyFieldId, @lesserEqualOperatorId),
(@collectionsUnappropriatedDailyFieldId, @greaterEqualOperatorId),
(@collectionsUnappropriatedDailyFieldId, @inOperatorId),
(@collectionsUnappropriatedDailyFieldId, @betweenOperatorId),
(@totalCollectionDailyFieldId, @equalsOperatorId),
(@totalCollectionDailyFieldId, @notEqualsOperatorId),
(@totalCollectionDailyFieldId, @lesserOperatorId),
(@totalCollectionDailyFieldId, @greaterOperatorId),
(@totalCollectionDailyFieldId, @lesserEqualOperatorId),
(@totalCollectionDailyFieldId, @greaterEqualOperatorId),
(@totalCollectionDailyFieldId, @inOperatorId),
(@totalCollectionDailyFieldId, @betweenOperatorId),
(@totalDisbursedAmountDailyFieldId, @equalsOperatorId),
(@totalDisbursedAmountDailyFieldId, @notEqualsOperatorId),
(@totalDisbursedAmountDailyFieldId, @lesserOperatorId),
(@totalDisbursedAmountDailyFieldId, @greaterOperatorId),
(@totalDisbursedAmountDailyFieldId, @lesserEqualOperatorId),
(@totalDisbursedAmountDailyFieldId, @greaterEqualOperatorId),
(@totalDisbursedAmountDailyFieldId, @inOperatorId),
(@totalDisbursedAmountDailyFieldId, @betweenOperatorId),
(@numDisbursementsDailyFieldId, @equalsOperatorId),
(@numDisbursementsDailyFieldId, @notEqualsOperatorId),
(@numDisbursementsDailyFieldId, @lesserOperatorId),
(@numDisbursementsDailyFieldId, @greaterOperatorId),
(@numDisbursementsDailyFieldId, @lesserEqualOperatorId),
(@numDisbursementsDailyFieldId, @greaterEqualOperatorId),
(@numDisbursementsDailyFieldId, @inOperatorId),
(@numDisbursementsDailyFieldId, @betweenOperatorId),
(@numDisbursementsDailyFieldId, @bucketOperatorId),
(@numForeclosuresDailyFieldId, @equalsOperatorId),
(@numForeclosuresDailyFieldId, @notEqualsOperatorId),
(@numForeclosuresDailyFieldId, @lesserOperatorId),
(@numForeclosuresDailyFieldId, @greaterOperatorId),
(@numForeclosuresDailyFieldId, @lesserEqualOperatorId),
(@numForeclosuresDailyFieldId, @greaterEqualOperatorId),
(@numForeclosuresDailyFieldId, @inOperatorId),
(@numForeclosuresDailyFieldId, @betweenOperatorId),
(@averageDisbursementsPerOfficerDailyFieldId, @equalsOperatorId),
(@averageDisbursementsPerOfficerDailyFieldId, @notEqualsOperatorId),
(@averageDisbursementsPerOfficerDailyFieldId, @lesserOperatorId),
(@averageDisbursementsPerOfficerDailyFieldId, @greaterOperatorId),
(@averageDisbursementsPerOfficerDailyFieldId, @lesserEqualOperatorId),
(@averageDisbursementsPerOfficerDailyFieldId, @greaterEqualOperatorId),
(@averageDisbursementsPerOfficerDailyFieldId, @inOperatorId),
(@averageDisbursementsPerOfficerDailyFieldId, @betweenOperatorId),
(@averageDisbursementsPerOfficerDailyFieldId, @bucketOperatorId),
(@collectionPercentageDailyFieldId, @equalsOperatorId),
(@collectionPercentageDailyFieldId, @notEqualsOperatorId),
(@collectionPercentageDailyFieldId, @lesserOperatorId),
(@collectionPercentageDailyFieldId, @greaterOperatorId),
(@collectionPercentageDailyFieldId, @lesserEqualOperatorId),
(@collectionPercentageDailyFieldId, @greaterEqualOperatorId),
(@collectionPercentageDailyFieldId, @inOperatorId),
(@collectionPercentageDailyFieldId, @betweenOperatorId),
(@collectionPercentageDailyFieldId, @bucketOperatorId),
(@totalApprovedAmountDailyFieldId, @equalsOperatorId),
(@totalApprovedAmountDailyFieldId, @notEqualsOperatorId),
(@totalApprovedAmountDailyFieldId, @lesserOperatorId),
(@totalApprovedAmountDailyFieldId, @greaterOperatorId),
(@totalApprovedAmountDailyFieldId, @lesserEqualOperatorId),
(@totalApprovedAmountDailyFieldId, @greaterEqualOperatorId),
(@totalApprovedAmountDailyFieldId, @inOperatorId),
(@totalApprovedAmountDailyFieldId, @betweenOperatorId),
(@dateOfCompletionDailyFieldId, @betweenOperatorId),
(@centerSizeDailyFieldId, @betweenOperatorId),
(@centerSizeDailyFieldId, @bucketOperatorId),
(@cycleNumberDailyFieldId, @betweenOperatorId),
(@amountDailyFieldId, @betweenOperatorId);

-- Cumulative data fields
INSERT INTO ReportFieldOperator(report_field_id, operator_id) VALUES
(@disbursedLoanAmountCumuFieldId, @equalsOperatorId),
(@disbursedLoanAmountCumuFieldId, @notEqualsOperatorId),
(@disbursedLoanAmountCumuFieldId, @lesserOperatorId),
(@disbursedLoanAmountCumuFieldId, @greaterOperatorId),
(@disbursedLoanAmountCumuFieldId, @lesserEqualOperatorId),
(@disbursedLoanAmountCumuFieldId, @greaterEqualOperatorId),
(@disbursedLoanAmountCumuFieldId, @inOperatorId),
(@disbursedLoanAmountCumuFieldId, @betweenOperatorId),
(@portfolioOutstandingCumuFieldId, @equalsOperatorId),
(@portfolioOutstandingCumuFieldId, @notEqualsOperatorId),
(@portfolioOutstandingCumuFieldId, @lesserOperatorId),
(@portfolioOutstandingCumuFieldId, @greaterOperatorId),
(@portfolioOutstandingCumuFieldId, @lesserEqualOperatorId),
(@portfolioOutstandingCumuFieldId, @greaterEqualOperatorId),
(@portfolioOutstandingCumuFieldId, @inOperatorId),
(@portfolioOutstandingCumuFieldId, @betweenOperatorId),
(@interestAccruedBODCumuFieldId, @equalsOperatorId),
(@interestAccruedBODCumuFieldId, @notEqualsOperatorId),
(@interestAccruedBODCumuFieldId, @lesserOperatorId),
(@interestAccruedBODCumuFieldId, @greaterOperatorId),
(@interestAccruedBODCumuFieldId, @lesserEqualOperatorId),
(@interestAccruedBODCumuFieldId, @greaterEqualOperatorId),
(@interestAccruedBODCumuFieldId, @inOperatorId),
(@interestAccruedBODCumuFieldId, @betweenOperatorId),
(@interestCollectedCumuFieldId, @equalsOperatorId),
(@interestCollectedCumuFieldId, @notEqualsOperatorId),
(@interestCollectedCumuFieldId, @lesserOperatorId),
(@interestCollectedCumuFieldId, @greaterOperatorId),
(@interestCollectedCumuFieldId, @lesserEqualOperatorId),
(@interestCollectedCumuFieldId, @greaterEqualOperatorId),
(@interestCollectedCumuFieldId, @inOperatorId),
(@interestCollectedCumuFieldId, @betweenOperatorId),
(@interestOutstandingCumuFieldId, @equalsOperatorId),
(@interestOutstandingCumuFieldId, @notEqualsOperatorId),
(@interestOutstandingCumuFieldId, @lesserOperatorId),
(@interestOutstandingCumuFieldId, @greaterOperatorId),
(@interestOutstandingCumuFieldId, @lesserEqualOperatorId),
(@interestOutstandingCumuFieldId, @greaterEqualOperatorId),
(@interestOutstandingCumuFieldId, @inOperatorId),
(@interestOutstandingCumuFieldId, @betweenOperatorId),
(@totalOutstandingCumuFieldId, @equalsOperatorId),
(@totalOutstandingCumuFieldId, @notEqualsOperatorId),
(@totalOutstandingCumuFieldId, @lesserOperatorId),
(@totalOutstandingCumuFieldId, @greaterOperatorId),
(@totalOutstandingCumuFieldId, @lesserEqualOperatorId),
(@totalOutstandingCumuFieldId, @greaterEqualOperatorId),
(@totalOutstandingCumuFieldId, @inOperatorId),
(@totalOutstandingCumuFieldId, @betweenOperatorId),
(@advanceParkedAmountCumuFieldId, @equalsOperatorId),
(@advanceParkedAmountCumuFieldId, @notEqualsOperatorId),
(@advanceParkedAmountCumuFieldId, @lesserOperatorId),
(@advanceParkedAmountCumuFieldId, @greaterOperatorId),
(@advanceParkedAmountCumuFieldId, @lesserEqualOperatorId),
(@advanceParkedAmountCumuFieldId, @greaterEqualOperatorId),
(@advanceParkedAmountCumuFieldId, @inOperatorId),
(@advanceParkedAmountCumuFieldId, @betweenOperatorId),
(@overdueInterestCumuFieldId, @equalsOperatorId),
(@overdueInterestCumuFieldId, @notEqualsOperatorId),
(@overdueInterestCumuFieldId, @lesserOperatorId),
(@overdueInterestCumuFieldId, @greaterOperatorId),
(@overdueInterestCumuFieldId, @lesserEqualOperatorId),
(@overdueInterestCumuFieldId, @greaterEqualOperatorId),
(@overdueInterestCumuFieldId, @inOperatorId),
(@overdueInterestCumuFieldId, @betweenOperatorId),
(@overduePrincipalCumuFieldId, @equalsOperatorId),
(@overduePrincipalCumuFieldId, @notEqualsOperatorId),
(@overduePrincipalCumuFieldId, @lesserOperatorId),
(@overduePrincipalCumuFieldId, @greaterOperatorId),
(@overduePrincipalCumuFieldId, @lesserEqualOperatorId),
(@overduePrincipalCumuFieldId, @greaterEqualOperatorId),
(@overduePrincipalCumuFieldId, @inOperatorId),
(@overduePrincipalCumuFieldId, @betweenOperatorId),
(@overdueAmountCumuFieldId, @equalsOperatorId),
(@overdueAmountCumuFieldId, @notEqualsOperatorId),
(@overdueAmountCumuFieldId, @lesserOperatorId),
(@overdueAmountCumuFieldId, @greaterOperatorId),
(@overdueAmountCumuFieldId, @lesserEqualOperatorId),
(@overdueAmountCumuFieldId, @greaterEqualOperatorId),
(@overdueAmountCumuFieldId, @inOperatorId),
(@overdueAmountCumuFieldId, @betweenOperatorId),
(@overduePrincipalDaysCumuFieldId, @equalsOperatorId),
(@overduePrincipalDaysCumuFieldId, @notEqualsOperatorId),
(@overduePrincipalDaysCumuFieldId, @lesserOperatorId),
(@overduePrincipalDaysCumuFieldId, @greaterOperatorId),
(@overduePrincipalDaysCumuFieldId, @lesserEqualOperatorId),
(@overduePrincipalDaysCumuFieldId, @greaterEqualOperatorId),
(@overduePrincipalDaysCumuFieldId, @inOperatorId),
(@overduePrincipalDaysCumuFieldId, @betweenOperatorId),
(@numCurrentLoanAccountsCumuFieldId, @equalsOperatorId),
(@numCurrentLoanAccountsCumuFieldId, @notEqualsOperatorId),
(@numCurrentLoanAccountsCumuFieldId, @lesserOperatorId),
(@numCurrentLoanAccountsCumuFieldId, @greaterOperatorId),
(@numCurrentLoanAccountsCumuFieldId, @lesserEqualOperatorId),
(@numCurrentLoanAccountsCumuFieldId, @greaterEqualOperatorId),
(@numCurrentLoanAccountsCumuFieldId, @inOperatorId),
(@numCurrentLoanAccountsCumuFieldId, @betweenOperatorId),
(@numOpenLoanAccountsCumuFieldId, @equalsOperatorId),
(@numOpenLoanAccountsCumuFieldId, @notEqualsOperatorId),
(@numOpenLoanAccountsCumuFieldId, @lesserOperatorId),
(@numOpenLoanAccountsCumuFieldId, @greaterOperatorId),
(@numOpenLoanAccountsCumuFieldId, @lesserEqualOperatorId),
(@numOpenLoanAccountsCumuFieldId, @greaterEqualOperatorId),
(@numOpenLoanAccountsCumuFieldId, @inOperatorId),
(@numOpenLoanAccountsCumuFieldId, @betweenOperatorId),
(@numActiveLoanCustomersCumuFieldId, @equalsOperatorId),
(@numActiveLoanCustomersCumuFieldId, @notEqualsOperatorId),
(@numActiveLoanCustomersCumuFieldId, @lesserOperatorId),
(@numActiveLoanCustomersCumuFieldId, @greaterOperatorId),
(@numActiveLoanCustomersCumuFieldId, @lesserEqualOperatorId),
(@numActiveLoanCustomersCumuFieldId, @greaterEqualOperatorId),
(@numActiveLoanCustomersCumuFieldId, @inOperatorId),
(@numActiveLoanCustomersCumuFieldId, @betweenOperatorId),
(@numOpenLoanCustomersCumuFieldId, @equalsOperatorId),
(@numOpenLoanCustomersCumuFieldId, @notEqualsOperatorId),
(@numOpenLoanCustomersCumuFieldId, @lesserOperatorId),
(@numOpenLoanCustomersCumuFieldId, @greaterOperatorId),
(@numOpenLoanCustomersCumuFieldId, @lesserEqualOperatorId),
(@numOpenLoanCustomersCumuFieldId, @greaterEqualOperatorId),
(@numOpenLoanCustomersCumuFieldId, @inOperatorId),
(@numOpenLoanCustomersCumuFieldId, @betweenOperatorId),
(@numOpenLoanCentersCumuFieldId, @equalsOperatorId),
(@numOpenLoanCentersCumuFieldId, @notEqualsOperatorId),
(@numOpenLoanCentersCumuFieldId, @lesserOperatorId),
(@numOpenLoanCentersCumuFieldId, @greaterOperatorId),
(@numOpenLoanCentersCumuFieldId, @lesserEqualOperatorId),
(@numOpenLoanCentersCumuFieldId, @greaterEqualOperatorId),
(@numOpenLoanCentersCumuFieldId, @inOperatorId),
(@numOpenLoanCentersCumuFieldId, @betweenOperatorId),
(@averageLoanSizeCumuFieldId, @equalsOperatorId),
(@averageLoanSizeCumuFieldId, @notEqualsOperatorId),
(@averageLoanSizeCumuFieldId, @lesserOperatorId),
(@averageLoanSizeCumuFieldId, @greaterOperatorId),
(@averageLoanSizeCumuFieldId, @lesserEqualOperatorId),
(@averageLoanSizeCumuFieldId, @greaterEqualOperatorId),
(@averageLoanSizeCumuFieldId, @inOperatorId),
(@averageLoanSizeCumuFieldId, @betweenOperatorId),
(@numEnrollmentsCumuFieldId, @equalsOperatorId),
(@numEnrollmentsCumuFieldId, @notEqualsOperatorId),
(@numEnrollmentsCumuFieldId, @lesserOperatorId),
(@numEnrollmentsCumuFieldId, @greaterOperatorId),
(@numEnrollmentsCumuFieldId, @lesserEqualOperatorId),
(@numEnrollmentsCumuFieldId, @greaterEqualOperatorId),
(@numEnrollmentsCumuFieldId, @inOperatorId),
(@numEnrollmentsCumuFieldId, @betweenOperatorId),
(@openLoansExclNewDisbCumuFieldId, @equalsOperatorId),
(@openLoansExclNewDisbCumuFieldId, @notEqualsOperatorId),
(@openLoansExclNewDisbCumuFieldId, @lesserOperatorId),
(@openLoansExclNewDisbCumuFieldId, @greaterOperatorId),
(@openLoansExclNewDisbCumuFieldId, @lesserEqualOperatorId),
(@openLoansExclNewDisbCumuFieldId, @greaterEqualOperatorId),
(@openLoansExclNewDisbCumuFieldId, @inOperatorId),
(@openLoansExclNewDisbCumuFieldId, @betweenOperatorId),
(@openLoansExclNewDisbCumuFieldId, @bucketOperatorId),
(@loanUtilizationCheckCumuFieldId, @equalsOperatorId),
(@loanUtilizationCheckCumuFieldId, @notEqualsOperatorId),
(@loanUtilizationCheckCumuFieldId, @lesserOperatorId),
(@loanUtilizationCheckCumuFieldId, @greaterOperatorId),
(@loanUtilizationCheckCumuFieldId, @lesserEqualOperatorId),
(@loanUtilizationCheckCumuFieldId, @greaterEqualOperatorId),
(@loanUtilizationCheckCumuFieldId, @inOperatorId),
(@loanUtilizationCheckCumuFieldId, @betweenOperatorId),
(@loanUtilizationCheckCumuFieldId, @bucketOperatorId),
(@installmentAmountCumuFieldId, @equalsOperatorId),
(@installmentAmountCumuFieldId, @notEqualsOperatorId),
(@installmentAmountCumuFieldId, @lesserOperatorId),
(@installmentAmountCumuFieldId, @greaterOperatorId),
(@installmentAmountCumuFieldId, @lesserEqualOperatorId),
(@installmentAmountCumuFieldId, @greaterEqualOperatorId),
(@installmentAmountCumuFieldId, @inOperatorId),
(@installmentAmountCumuFieldId, @betweenOperatorId),
(@advanceInstallmentAmountCumuFieldId, @equalsOperatorId),
(@advanceInstallmentAmountCumuFieldId, @notEqualsOperatorId),
(@advanceInstallmentAmountCumuFieldId, @lesserOperatorId),
(@advanceInstallmentAmountCumuFieldId, @greaterOperatorId),
(@advanceInstallmentAmountCumuFieldId, @lesserEqualOperatorId),
(@advanceInstallmentAmountCumuFieldId, @greaterEqualOperatorId),
(@advanceInstallmentAmountCumuFieldId, @inOperatorId),
(@advanceInstallmentAmountCumuFieldId, @betweenOperatorId),
(@futureInstallmentAmountCumuFieldId, @equalsOperatorId),
(@futureInstallmentAmountCumuFieldId, @notEqualsOperatorId),
(@futureInstallmentAmountCumuFieldId, @lesserOperatorId),
(@futureInstallmentAmountCumuFieldId, @greaterOperatorId),
(@futureInstallmentAmountCumuFieldId, @lesserEqualOperatorId),
(@futureInstallmentAmountCumuFieldId, @greaterEqualOperatorId),
(@futureInstallmentAmountCumuFieldId, @inOperatorId),
(@futureInstallmentAmountCumuFieldId, @betweenOperatorId),
(@remainingTenureInDaysCumuFieldId, @equalsOperatorId),
(@remainingTenureInDaysCumuFieldId, @notEqualsOperatorId),
(@remainingTenureInDaysCumuFieldId, @lesserOperatorId),
(@remainingTenureInDaysCumuFieldId, @greaterOperatorId),
(@remainingTenureInDaysCumuFieldId, @lesserEqualOperatorId),
(@remainingTenureInDaysCumuFieldId, @greaterEqualOperatorId),
(@remainingTenureInDaysCumuFieldId, @inOperatorId),
(@remainingTenureInDaysCumuFieldId, @betweenOperatorId),
(@totalInterestExpectedCumuFieldId, @equalsOperatorId),
(@totalInterestExpectedCumuFieldId, @notEqualsOperatorId),
(@totalInterestExpectedCumuFieldId, @lesserOperatorId),
(@totalInterestExpectedCumuFieldId, @greaterOperatorId),
(@totalInterestExpectedCumuFieldId, @lesserEqualOperatorId),
(@totalInterestExpectedCumuFieldId, @greaterEqualOperatorId),
(@totalInterestExpectedCumuFieldId, @inOperatorId),
(@totalInterestExpectedCumuFieldId, @betweenOperatorId),
(@numOverdueInstallmentsCumuFieldId, @equalsOperatorId),
(@numOverdueInstallmentsCumuFieldId, @notEqualsOperatorId),
(@numOverdueInstallmentsCumuFieldId, @lesserOperatorId),
(@numOverdueInstallmentsCumuFieldId, @greaterOperatorId),
(@numOverdueInstallmentsCumuFieldId, @lesserEqualOperatorId),
(@numOverdueInstallmentsCumuFieldId, @greaterEqualOperatorId),
(@numOverdueInstallmentsCumuFieldId, @inOperatorId),
(@numOverdueInstallmentsCumuFieldId, @betweenOperatorId),
(@daysSinceDisbursementCumuFieldId, @equalsOperatorId),
(@daysSinceDisbursementCumuFieldId, @notEqualsOperatorId),
(@daysSinceDisbursementCumuFieldId, @lesserOperatorId),
(@daysSinceDisbursementCumuFieldId, @greaterOperatorId),
(@daysSinceDisbursementCumuFieldId, @lesserEqualOperatorId),
(@daysSinceDisbursementCumuFieldId, @greaterEqualOperatorId),
(@daysSinceDisbursementCumuFieldId, @inOperatorId),
(@daysSinceDisbursementCumuFieldId, @betweenOperatorId),
(@daysSinceDisbursementCumuFieldId, @bucketOperatorId),
(@numCentersCumuFieldId, @equalsOperatorId),
(@numCentersCumuFieldId, @notEqualsOperatorId),
(@numCentersCumuFieldId, @lesserOperatorId),
(@numCentersCumuFieldId, @greaterOperatorId),
(@numCentersCumuFieldId, @lesserEqualOperatorId),
(@numCentersCumuFieldId, @greaterEqualOperatorId),
(@numCentersCumuFieldId, @inOperatorId),
(@numCentersCumuFieldId, @betweenOperatorId),
(@averageLoansPerCenterCumuFieldId, @equalsOperatorId),
(@averageLoansPerCenterCumuFieldId, @notEqualsOperatorId),
(@averageLoansPerCenterCumuFieldId, @lesserOperatorId),
(@averageLoansPerCenterCumuFieldId, @greaterOperatorId),
(@averageLoansPerCenterCumuFieldId, @lesserEqualOperatorId),
(@averageLoansPerCenterCumuFieldId, @greaterEqualOperatorId),
(@averageLoansPerCenterCumuFieldId, @inOperatorId),
(@averageLoansPerCenterCumuFieldId, @betweenOperatorId),
(@numOfficersCumuFieldId, @equalsOperatorId),
(@numOfficersCumuFieldId, @notEqualsOperatorId),
(@numOfficersCumuFieldId, @lesserOperatorId),
(@numOfficersCumuFieldId, @greaterOperatorId),
(@numOfficersCumuFieldId, @lesserEqualOperatorId),
(@numOfficersCumuFieldId, @greaterEqualOperatorId),
(@numOfficersCumuFieldId, @inOperatorId),
(@numOfficersCumuFieldId, @betweenOperatorId),
(@averageLoansPerOfficerCumuFieldId, @equalsOperatorId),
(@averageLoansPerOfficerCumuFieldId, @notEqualsOperatorId),
(@averageLoansPerOfficerCumuFieldId, @lesserOperatorId),
(@averageLoansPerOfficerCumuFieldId, @greaterOperatorId),
(@averageLoansPerOfficerCumuFieldId, @lesserEqualOperatorId),
(@averageLoansPerOfficerCumuFieldId, @greaterEqualOperatorId),
(@averageLoansPerOfficerCumuFieldId, @inOperatorId),
(@averageLoansPerOfficerCumuFieldId, @betweenOperatorId),
(@averagePortfolioOutstandingPerOfficerCumuFieldId, @equalsOperatorId),
(@averagePortfolioOutstandingPerOfficerCumuFieldId, @notEqualsOperatorId),
(@averagePortfolioOutstandingPerOfficerCumuFieldId, @lesserOperatorId),
(@averagePortfolioOutstandingPerOfficerCumuFieldId, @greaterOperatorId),
(@averagePortfolioOutstandingPerOfficerCumuFieldId, @lesserEqualOperatorId),
(@averagePortfolioOutstandingPerOfficerCumuFieldId, @greaterEqualOperatorId),
(@averagePortfolioOutstandingPerOfficerCumuFieldId, @inOperatorId),
(@averagePortfolioOutstandingPerOfficerCumuFieldId, @betweenOperatorId),
(@numCustomersWithAadharCardCumuFieldId, @equalsOperatorId),
(@numCustomersWithAadharCardCumuFieldId, @notEqualsOperatorId),
(@numCustomersWithAadharCardCumuFieldId, @lesserOperatorId),
(@numCustomersWithAadharCardCumuFieldId, @greaterOperatorId),
(@numCustomersWithAadharCardCumuFieldId, @lesserEqualOperatorId),
(@numCustomersWithAadharCardCumuFieldId, @greaterEqualOperatorId),
(@numCustomersWithAadharCardCumuFieldId, @inOperatorId),
(@numCustomersWithAadharCardCumuFieldId, @betweenOperatorId),
(@customersWithAadharCardPercentageCumuFieldId, @equalsOperatorId),
(@customersWithAadharCardPercentageCumuFieldId, @notEqualsOperatorId),
(@customersWithAadharCardPercentageCumuFieldId, @lesserOperatorId),
(@customersWithAadharCardPercentageCumuFieldId, @greaterOperatorId),
(@customersWithAadharCardPercentageCumuFieldId, @lesserEqualOperatorId),
(@customersWithAadharCardPercentageCumuFieldId, @greaterEqualOperatorId),
(@customersWithAadharCardPercentageCumuFieldId, @inOperatorId),
(@customersWithAadharCardPercentageCumuFieldId, @betweenOperatorId),
(@telephonePercentageCumuFieldId, @equalsOperatorId),
(@telephonePercentageCumuFieldId, @notEqualsOperatorId),
(@telephonePercentageCumuFieldId, @lesserOperatorId),
(@telephonePercentageCumuFieldId, @greaterOperatorId),
(@telephonePercentageCumuFieldId, @lesserEqualOperatorId),
(@telephonePercentageCumuFieldId, @greaterEqualOperatorId),
(@telephonePercentageCumuFieldId, @inOperatorId),
(@telephonePercentageCumuFieldId, @betweenOperatorId),
(@derivedPortfolioCumuFieldId, @equalsOperatorId),
(@derivedPortfolioCumuFieldId, @notEqualsOperatorId),
(@derivedPortfolioCumuFieldId, @lesserOperatorId),
(@derivedPortfolioCumuFieldId, @greaterOperatorId),
(@derivedPortfolioCumuFieldId, @lesserEqualOperatorId),
(@derivedPortfolioCumuFieldId, @greaterEqualOperatorId),
(@derivedPortfolioCumuFieldId, @inOperatorId),
(@derivedPortfolioCumuFieldId, @betweenOperatorId),
(@openingOutstandingCumuFieldId, @equalsOperatorId),
(@openingOutstandingCumuFieldId, @notEqualsOperatorId),
(@openingOutstandingCumuFieldId, @lesserOperatorId),
(@openingOutstandingCumuFieldId, @greaterOperatorId),
(@openingOutstandingCumuFieldId, @lesserEqualOperatorId),
(@openingOutstandingCumuFieldId, @greaterEqualOperatorId),
(@openingOutstandingCumuFieldId, @inOperatorId),
(@openingOutstandingCumuFieldId, @betweenOperatorId),
(@closingOutstandingCumuFieldId, @equalsOperatorId),
(@closingOutstandingCumuFieldId, @notEqualsOperatorId),
(@closingOutstandingCumuFieldId, @lesserOperatorId),
(@closingOutstandingCumuFieldId, @greaterOperatorId),
(@closingOutstandingCumuFieldId, @lesserEqualOperatorId),
(@closingOutstandingCumuFieldId, @greaterEqualOperatorId),
(@closingOutstandingCumuFieldId, @inOperatorId),
(@closingOutstandingCumuFieldId, @betweenOperatorId),
(@openingAdvanceCumuFieldId, @equalsOperatorId),
(@openingAdvanceCumuFieldId, @notEqualsOperatorId),
(@openingAdvanceCumuFieldId, @lesserOperatorId),
(@openingAdvanceCumuFieldId, @greaterOperatorId),
(@openingAdvanceCumuFieldId, @lesserEqualOperatorId),
(@openingAdvanceCumuFieldId, @greaterEqualOperatorId),
(@openingAdvanceCumuFieldId, @inOperatorId),
(@openingAdvanceCumuFieldId, @betweenOperatorId),
(@closingAdvanceCumuFieldId, @equalsOperatorId),
(@closingAdvanceCumuFieldId, @notEqualsOperatorId),
(@closingAdvanceCumuFieldId, @lesserOperatorId),
(@closingAdvanceCumuFieldId, @greaterOperatorId),
(@closingAdvanceCumuFieldId, @lesserEqualOperatorId),
(@closingAdvanceCumuFieldId, @greaterEqualOperatorId),
(@closingAdvanceCumuFieldId, @inOperatorId),
(@closingAdvanceCumuFieldId, @betweenOperatorId);

-- Par cumulative data fields
INSERT INTO ReportFieldOperator(report_field_id, operator_id) VALUES
(@portfolioAtRiskParCumuFieldId, @equalsOperatorId),
(@portfolioAtRiskParCumuFieldId, @notEqualsOperatorId),
(@portfolioAtRiskParCumuFieldId, @lesserOperatorId),
(@portfolioAtRiskParCumuFieldId, @greaterOperatorId),
(@portfolioAtRiskParCumuFieldId, @lesserEqualOperatorId),
(@portfolioAtRiskParCumuFieldId, @greaterEqualOperatorId),
(@portfolioAtRiskParCumuFieldId, @inOperatorId),
(@portfolioAtRiskParCumuFieldId, @betweenOperatorId),
(@portfolioAtRiskParCumuFieldId, @bucketOperatorId),
(@arrearsRateParCumuFieldId, @equalsOperatorId),
(@arrearsRateParCumuFieldId, @notEqualsOperatorId),
(@arrearsRateParCumuFieldId, @lesserOperatorId),
(@arrearsRateParCumuFieldId, @greaterOperatorId),
(@arrearsRateParCumuFieldId, @lesserEqualOperatorId),
(@arrearsRateParCumuFieldId, @greaterEqualOperatorId),
(@arrearsRateParCumuFieldId, @inOperatorId),
(@arrearsRateParCumuFieldId, @betweenOperatorId),
(@arrearsRateParCumuFieldId, @bucketOperatorId),
(@otrr1ExclClaimParCumuFieldId, @equalsOperatorId),
(@otrr1ExclClaimParCumuFieldId, @notEqualsOperatorId),
(@otrr1ExclClaimParCumuFieldId, @lesserOperatorId),
(@otrr1ExclClaimParCumuFieldId, @greaterOperatorId),
(@otrr1ExclClaimParCumuFieldId, @lesserEqualOperatorId),
(@otrr1ExclClaimParCumuFieldId, @greaterEqualOperatorId),
(@otrr1ExclClaimParCumuFieldId, @inOperatorId),
(@otrr1ExclClaimParCumuFieldId, @betweenOperatorId),
(@otrr1ExclClaimParCumuFieldId, @bucketOperatorId);

-- Current stat fields
INSERT INTO ReportFieldOperator(report_field_id, operator_id) VALUES
(@currentPortfolioOutstandingStatFieldId, @betweenOperatorId);

-- Setting variables for all Report entries to be used as FK in other tables
SELECT @qbeReportId := id FROM Report WHERE name = "Qbe";
SELECT @accountQbeReportId := id FROM Report WHERE name = "Account Qbe";
SELECT @dcReportId := id FROM Report WHERE name = "Demand Collection";
SELECT @posReportId := id FROM Report WHERE name = "Portfolio Outstandings";
SELECT @disbReportId := id FROM Report WHERE name = "Loan Disbursements";
SELECT @parReportId := id FROM Report WHERE name = "Portfolio At Risk(PAR)";
SELECT @pipelineQbeReportId := id FROM Report WHERE name = "Pipeline Qbe";
SELECT @periodicAlertId := id FROM Report WHERE name = "Periodic Alerts";
SELECT @centerOnHoldAlertId := id FROM Report WHERE name = "On Hold Alert";
SELECT @centerSanctionAlertId := id FROM Report WHERE name = "SANCTION Alert";
SELECT @confirmEODAlertId := id FROM Report WHERE name = "Confirm EOD Completion Alert";
SELECT @pipelinestatusAlertId := id FROM Report WHERE name = "Pipeline Status Update Alert";
SELECT @lcbaReportId := id FROM Report WHERE name = "Loan Collection And Balances";
SELECT @cashflowReportId := id FROM Report WHERE name = "Future Cash In-Flow";
SELECT @cashOutflowReportId := id FROM Report WHERE name = "Future Cash Out-Flow";
SELECT @mudraReportId := id FROM Report WHERE name = "Mudra Submission Report";
SELECT @bookDebtReportid := id FROM Report WHERE name = "Book Debt Report";
SELECT @portfolioReportId := id FROM Report WHERE name = "Loan-wise Portfolio (Funding Sources)";
SELECT @managementReportId := id FROM Report WHERE name = "Management Report";
SELECT @portfolioReconReportId := id FROM Report WHERE name = "Portfolio Reconciliation Report";
SELECT @collectionReportId := id FROM Report WHERE name = "Collection Report";
SELECT @collectionPaymentAlertId := id FROM Report WHERE name = "Customer Collection Alert";
SELECT @loanAccountApprovalAlertId := id FROM Report WHERE name = "Loan Account Approval Alert";
SELECT @pipelinestatusUpcomingAlertId := id FROM Report WHERE name = "Pipeline Status Upcoming Alert";
SELECT @stationeryReceiptCancelAlertId := id FROM Report WHERE name = "Stationery Receipt Cancel Alert";
SELECT @beneValidationFailureAlertId := id FROM Report WHERE name = "Bene Validation Failure Alert";
SELECT @ecsTransferFailureAlertId := id FROM Report WHERE name = "ECS Transfer Failure Alert";
SELECT @reportRuleSetId := id FROM Report WHERE name = "Report Rule Set";
SELECT @officerAllocationType := id FROM Report WHERE name = "Officer Allocation Type";
SELECT @documentRuleId := id FROM Report WHERE name = "Document Template Rule";
SELECT @dVsCReportId := id FROM Report WHERE name = "Demand Vs Collection Report (New Format)";
SELECT @vintageQbeReportId := id FROM Report WHERE name = "Vintage Portfolio At Risk(PAR)";
SELECT @vintageQbe30ReportId := id FROM Report WHERE name = "Vintage Portfolio At Risk(PAR) 30";
SELECT @vintageQbe90ReportId := id FROM Report WHERE name = "Vintage Portfolio At Risk(PAR) 90";
SELECT @vintageQbe180ReportId := id FROM Report WHERE name = "Vintage Portfolio At Risk(PAR) 180";

--
-- Master table values for ReportFieldMap
--
DELETE FROM ReportFieldMap;

-- Qbe
-- Insert aggregation fields for 'Qbe'
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@qbeReportId, @dateAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @monthAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @officeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @parentOffice1AggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @lastDateOfTheMonth, 0, 0, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @parentOffice2AggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @parentOffice3AggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @productAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @officerAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @centerAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @funderAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @fundingSourceAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @weekdayAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @disbursementMonthAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @maturityMonthAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @officeLocaleAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @customerLocaleAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @stateCustomerAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @districtAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @stateOfficeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @thirdPartyAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @productCategoryAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @productTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @compoundingFrequencyAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @interestRateAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @interestRateTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @repaymentFrequencyAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @fundingTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @loanPurposeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @loanPurposeCategoryAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @loanPurposeTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @loanCycleNumberAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @accountStatusAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @loanTicketSizeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @utilizedAmountAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @foreclosureReasonAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @writeoffReasonAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @religiousGroupAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @casteAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @occupationAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @educationLevelAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @maritalStatusAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @genderAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @employeeTitleAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @primaryIdentityProofAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @primaryAddressProofAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @collateralSizeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@qbeReportId, @morIntCollectedDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @equMorIntDemandDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @toRoundOffDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @fromRoundOffDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @morIntCollectedCumId, 0, 0, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @propertyTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0);
-- Insert bucket fields for 'Qbe'
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@qbeReportId, @loanTicketSizeBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @ageYearsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @landHoldingAcresBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @householdIncomeBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @householdExpensesBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @disbursementsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @collectionsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @principalDemandsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @interestDemandsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @loanFeeDemandsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @insurancePremiumDemandsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @otherDemandsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @totalDemandsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @currentPrincipalPaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @currentInterestPaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @currentFeePaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @currentInsurancePaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @otherCurrentPaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @totalCurrentPaymentsOnDemandsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @principalPrepaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @interestPrepaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @otherPrepaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @totalPrepaymentsNoDemandsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @principalLatePaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @interestLatePaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @otherLatePaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @totalLatePaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @totalPrincipalPaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @totalInterestPaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @disbursedLoanAmountBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @portfolioOutstandingBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @interestAccruedNotDueBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @interestCollectedBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @interestOutstandingBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @advanceParkedAmountBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @overdueInterestBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @overduePrincipalBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @overdueAmountBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @numOverdueDaysBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @utilizedAmountBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@qbeReportId, @collateralSizeBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0);
-- Insert daily data fields for 'Qbe'
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@qbeReportId, @principalDemandsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @interestDemandsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @loanFeeDemandsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @insurancePremiumDemandsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @otherDemandsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @totalDemandsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @totalPrincipalPaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @totalInterestPaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @currentPrincipalPaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @principalPrepaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @principalOverdueRecoveryDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @currentInterestPaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @interestPrepaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @interestOverdueRecoveryDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @currentFeePaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @currentInsurancePaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @otherCurrentPaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @totalCurrentPaymentsOnDemandsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @otherPrepaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @totalPrepaymentsNoDemandsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @otherLatePaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @totalOverdueRecoveryDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @collectionsUnappropriatedDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @advanceCollectionDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @advanceAppropriationDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @totalDisbursedAmountDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @numDisbursementsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @numForeclosuresDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @totalWaivedAmtDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @differentailIntDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @interestAccruedBODDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @interestAccruedEODDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 0);
-- Insert cumulative data fields for 'Qbe'
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@qbeReportId, @disbursedLoanAmountCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @portfolioOutstandingCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @interestAccruedBODCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @interestAccruedEODCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @interestCollectedCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @interestOutstandingCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @advanceParkedAmountCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @overdueInterestCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @overduePrincipalCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @overdueAmountCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @overduePrincipalDaysCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @numCurrentLoanAccountsCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @numOpenLoanAccountsCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @numActiveLoanCustomersCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @numOpenLoanCustomersCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@qbeReportId, @numOpenLoanCentersCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 0);


-- Account Qbe
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@accountQbeReportId, @loanAccountNumberAggrFieldId, 0, 0, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @customerNameAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @dateAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @monthAggrFieldId, 0, 0, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @officeAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @parentOffice1AggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @parentOffice2AggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @parentOffice3AggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @productAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @officerAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @centerAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @funderAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @fundingSourceAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @weekdayAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @disbursementDateAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @disbursementMonthAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @maturityMonthAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @officeLocaleAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @customerLocaleAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @stateCustomerAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @districtAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @productCategoryAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @productTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @compoundingFrequencyAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @interestRateAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @interestRateTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @fundingTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @loanPurposeAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @loanPurposeCategoryAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @loanPurposeTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @utilizedAmountAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @foreclosureReasonAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @writeoffReasonAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @repaymentFrequencyAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @accountStatusAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @loanTicketSizeAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @religiousGroupAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @casteAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @occupationAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @educationLevelAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @maritalStatusAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @stateOfficeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@accountQbeReportId, @loanTicketSizeBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @ageYearsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @landHoldingAcresBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @householdIncomeBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @householdExpensesBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @disbursementsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @collectionsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @principalDemandsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @interestDemandsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @loanFeeDemandsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @insurancePremiumDemandsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @otherDemandsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @totalDemandsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @currentPrincipalPaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @currentInterestPaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @currentFeePaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @currentInsurancePaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @otherCurrentPaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @totalCurrentPaymentsOnDemandsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @principalPrepaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @interestPrepaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @otherPrepaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @totalPrepaymentsNoDemandsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @principalLatePaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @interestLatePaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @otherLatePaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @totalLatePaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @totalPrincipalPaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @totalInterestPaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @disbursedLoanAmountBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @portfolioOutstandingBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @interestAccruedNotDueBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @interestCollectedBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @interestOutstandingBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @advanceParkedAmountBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @overdueInterestBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @overduePrincipalBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @overdueAmountBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @numOverdueDaysBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @utilizedAmountBucketFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @principalDemandsDailyFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @interestDemandsDailyFieldId, 0, 0, 0, 0, 1, 0, 1, 0),
(@accountQbeReportId, @loanFeeDemandsDailyFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @insurancePremiumDemandsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @otherDemandsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @totalDemandsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @totalPrincipalPaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @totalInterestPaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @currentPrincipalPaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @principalPrepaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @principalOverdueRecoveryDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @currentInterestPaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @interestPrepaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @interestOverdueRecoveryDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @currentFeePaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @currentInsurancePaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @otherCurrentPaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @totalCurrentPaymentsOnDemandsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @otherPrepaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @totalPrepaymentsNoDemandsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @otherLatePaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @totalOverdueRecoveryDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @collectionsUnappropriatedDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @totalDisbursedAmountDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @numDisbursementsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @numForeclosuresDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @dateOfCompletionDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @centerSizeDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @cycleNumberDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @disbursedLoanAmountCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @portfolioOutstandingCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @interestAccruedBODCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @interestCollectedCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @interestOutstandingCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @advanceParkedAmountCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @overdueInterestCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @overduePrincipalCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @overdueAmountCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @overduePrincipalDaysCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @numCurrentLoanAccountsCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @numOpenLoanAccountsCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @numActiveLoanCustomersCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @numOpenLoanCustomersCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @portfolioAtRiskParCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @arrearsRateParCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @currentPortfolioOutstandingStatFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @collateralSizeAggrFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @collateralSizeBucketFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @propertyTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @officeCodeAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @centerCodeAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @groupAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @groupCodeAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @spouseNameAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @gurantorNameCustomerAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @addressAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @villageAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @pincodeAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @telephoneAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @tenureAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @tenureUnitAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @customerNumberAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @loanCycleNumberAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @primaryIdentityProofAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @primaryIdentityProofNumberAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @primaryAddressProofAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @primaryAddressProofNumberAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @firstInstallmentDateAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @lastInstallmentDateAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @employeeManagerAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @daysSinceDisbursementAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @totalApprovedAmountDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @installmentAmountCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @futureInstallmentAmountCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @remainingTenureInDaysCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @totalInterestExpectedCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @numOverdueInstallmentsCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @totalOutstandingCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @firstInstallmentMonthAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@accountQbeReportId, @advanceAppropriationDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@accountQbeReportId, @gurantorNameLoanAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 0);

-- Demand Collection
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@dcReportId, @dateAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@dcReportId, @monthAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@dcReportId, @officeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@dcReportId, @productAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@dcReportId, @officerAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@dcReportId, @centerAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@dcReportId, @funderAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@dcReportId, @fundingSourceAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@dcReportId, @weekdayAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@dcReportId, @principalDemandsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@dcReportId, @currentPrincipalPaymentsBucketFieldId, 0, 0, 0, 0, 1, 0, 0, 0),
(@dcReportId, @insurancePremiumDemandsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dcReportId, @otherDemandsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dcReportId, @totalDemandsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dcReportId, @totalPrincipalPaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dcReportId, @totalInterestPaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dcReportId, @currentPrincipalPaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dcReportId, @currentInterestPaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dcReportId, @interestPrepaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dcReportId, @interestOverdueRecoveryDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dcReportId, @currentFeePaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dcReportId, @currentInsurancePaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dcReportId, @otherCurrentPaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dcReportId, @totalCurrentPaymentsOnDemandsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dcReportId, @otherPrepaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dcReportId, @totalPrepaymentsNoDemandsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dcReportId, @otherLatePaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dcReportId, @totalOverdueRecoveryDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dcReportId, @totalDisbursedAmountDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dcReportId, @numForeclosuresDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1);

-- Portfolio Outstandings
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@posReportId, @dateAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@posReportId, @monthAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@posReportId, @officeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@posReportId, @productAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@posReportId, @officerAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@posReportId, @centerAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@posReportId, @funderAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@posReportId, @fundingSourceAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@posReportId, @weekdayAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@posReportId, @advanceParkedAmountCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 1),
(@posReportId, @overduePrincipalCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@posReportId, @overdueInterestCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@posReportId, @overdueAmountCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@posReportId, @numOpenLoanAccountsCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@posReportId, @numOpenLoanCustomersCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@posReportId, @numOpenLoanCentersCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1);

-- Loan Disbursements
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@disbReportId, @dateAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@disbReportId, @monthAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@disbReportId, @officeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@disbReportId, @productAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@disbReportId, @officerAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@disbReportId, @centerAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@disbReportId, @funderAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@disbReportId, @fundingSourceAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@disbReportId, @weekdayAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@disbReportId, @dateOfCompletionDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 1),
(@disbReportId, @centerSizeDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 1);

-- Demand Vs COllection Report (New Format)
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@dVsCReportId, @officeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@dVsCReportId, @productClassAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@dVsCReportId, @principalDemandsExcludeClosedAccountsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dVsCReportId, @interestDemandsExcludeClosedAccountsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dVsCReportId, @totalDemandsExcludeClosedAccountsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dVsCReportId, @currentPrincipalPaymentsExcludeClosedAccountsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dVsCReportId, @currentInterestPaymentsExcludeClosedAccountsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dVsCReportId, @totalPrincipalPaymentsExcludeClosedAccountsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dVsCReportId, @totalInterestPaymentsExcludeClosedAccountsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dVsCReportId, @foreclosurePrincipalPaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dVsCReportId, @deathPrincipalPaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dVsCReportId, @deathInterestPaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dVsCReportId, @overduePrincipalExcludeClosedAccountsCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dVsCReportId, @overdueInterestExcludeClosedAccountsCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dVsCReportId, @principalOutstandingExcludeClosedAccountsCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@dVsCReportId, @foreclosureInterestPaymentsDailyFieldId,0, 0, 0, 0, 0, 0, 1, 1);

-- Portfolio At Risk(PAR)
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@parReportId, @officeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @parentOffice1AggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @parentOffice2AggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @parentOffice3AggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @productAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @officerAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @funderAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @fundingSourceAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @disbursementMonthAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @stateCustomerAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @loanPurposeCategoryAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @repaymentFrequencyAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @accountStatusAggrFieldId, 1, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @genderAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@parReportId, @numOpenLoanAccountsCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@parReportId, @numOverdueDaysBucketFieldId, 0, 0, 0, 0, 1, 1, 0, 0),
(@parReportId, @portfolioOutstandingCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@parReportId, @overdueInterestCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@parReportId, @overduePrincipalCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@parReportId, @portfolioAtRiskParCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@parReportId, @arrearsRateParCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@parReportId, @officeLocaleAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @customerLocaleAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @stateOfficeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @districtAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @centerAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @groupAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @groupCodeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @officeCodeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @centerCodeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @productCategoryAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @productTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @productClassAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @compoundingFrequencyAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @interestRateAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @interestRateTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @fundingTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @loanPurposeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @loanPurposeTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @loanTicketSizeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @loanCycleNumberAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @addressAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @villageAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @pincodeAggrFieldId,0, 1, 1, 0, 0, 0, 0, 0),
(@parReportId, @customerAgeAggrFieldId, 0, 0, 1, 1, 0, 0, 0, 0),
(@parReportId, @maritalStatusAggrFieldId, 0, 0, 1, 1, 0, 0, 0, 0),
(@parReportId, @maturityMonthAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@parReportId, @tenureAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@parReportId, @tenureUnitAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0);

-- Pipeline Qbe
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@pipelineQbeReportId, @officeAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@pipelineQbeReportId, @officerAggrFieldId, 0, 1, 1, 0, 0, 0, 1, 0),
(@pipelineQbeReportId, @centerAggrFieldId, 0, 0, 0, 0, 0, 0, 0, 0),
(@pipelineQbeReportId, @pipelineStatusAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@pipelineQbeReportId, @pipelineAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@pipelineQbeReportId, @amountDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@pipelineQbeReportId, @completedPipelineDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@pipelineQbeReportId, @disbursedLoanAmountCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 0),
(@pipelineQbeReportId, @portfolioOutstandingCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 0);

-- Periodic Alerts
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@periodicAlertId, @totalDisbursedAmountDailyFieldId, 0, 0, 0, 0, 0, 0, 0, 0),
(@periodicAlertId, @numDisbursementsDailyFieldId, 0, 0, 0, 0, 0, 0, 0, 0),
(@periodicAlertId, @portfolioOutstandingCumuFieldId, 0, 0, 0, 0, 0, 0, 0, 0),
(@periodicAlertId, @numActiveLoanCustomersCumuFieldId, 0, 0, 0, 0, 0, 0, 0, 0),
(@periodicAlertId, @totalApprovedAmountDailyFieldId, 0, 0, 0, 0, 0, 0, 0, 0);

-- Center On Hold Alert
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@centerOnHoldAlertId, @centerStatusRemarksAggrFieldId, 0, 0, 0, 0, 0, 0, 0, 1);

-- Center Sanction Alert
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@centerSanctionAlertId, @totalApprovedAmountDailyFieldId, 0, 0, 0, 0, 0, 0, 0, 1);

-- Confirm EOD Completion Alert
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@confirmEODAlertId, @totalDisbursedAmountDailyFieldId, 0, 0, 0, 0, 0, 0, 0, 1),
(@confirmEODAlertId, @totalApprovedAmountDailyFieldId, 0, 0, 0, 0, 0, 0, 0, 1);

-- Pipeline Status Update Alert
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@pipelinestatusAlertId, @centerSizeDailyFieldId, 0, 0, 0, 0, 0, 0, 0, 1),
(@pipelinestatusAlertId, @amountDailyFieldId, 0, 0, 0, 0, 0, 0, 0, 1),
(@pipelinestatusAlertId, @pipelineStatusAggrFieldId, 0, 0, 0, 0, 0, 0, 0, 1);

-- Pipeline Status Upcoming Alert
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@pipelinestatusUpcomingAlertId, @centerSizeDailyFieldId, 0, 0, 0, 0, 0, 0, 0, 1),
(@pipelinestatusUpcomingAlertId, @amountDailyFieldId, 0, 0, 0, 0, 0, 0, 0, 1),
(@pipelinestatusUpcomingAlertId, @pipelineStatusAggrFieldId, 0, 0, 0, 0, 0, 0, 0, 1);

-- Customer Collection Report
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@collectionPaymentAlertId, @collectionAmountDailyFieldId, 0, 0, 0, 0, 0, 0, 0, 1),
(@collectionPaymentAlertId, @dateAggrFieldId, 0, 0, 0, 0, 0, 0, 0, 1);

-- Loan Account Approval Alert
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@loanAccountApprovalAlertId, @totalApprovedAmountDailyFieldId, 0, 0, 0, 0, 0, 0, 0, 1);

-- Stationery Receipt Cancel Report
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@stationeryReceiptCancelAlertId, @cancelReasonId, 0, 0, 0, 0, 0, 0, 0, 1);

-- Bene Validation Failure Alert
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@beneValidationFailureAlertId, @customerNameAggrFieldId, 0, 0, 0, 0, 0, 0, 0, 1),
(@beneValidationFailureAlertId, @customerNumberAggrFieldId, 0, 0, 0, 0, 0, 0, 0, 1),
(@beneValidationFailureAlertId, @bankAccountNumberFieldId, 0, 0, 0, 0, 0, 0, 0, 1),
(@beneValidationFailureAlertId, @failureReasonId, 0, 0, 0, 0, 0, 0, 0, 1);

-- ECS Transfer Failure Alert
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@ecsTransferFailureAlertId, @customerNameAggrFieldId, 0, 0, 0, 0, 0, 0, 0, 1),
(@ecsTransferFailureAlertId, @customerNumberAggrFieldId, 0, 0, 0, 0, 0, 0, 0, 1),
(@ecsTransferFailureAlertId, @officeAggrFieldId, 0, 0, 0, 0, 0, 0, 0, 1),
(@ecsTransferFailureAlertId, @loanAccountNumberAggrFieldId, 0, 0, 0, 0, 0, 0, 0, 1),
(@ecsTransferFailureAlertId, @failureReasonId, 0, 0, 0, 0, 0, 0, 0, 1);

-- Loan Collection And Balances
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@lcbaReportId, @loanAccountNumberAggrFieldId, 0, 0, 1, 1, 0, 0, 1, 1),
(@lcbaReportId, @customerNameAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @officeAggrFieldId, 0, 0, 1, 0, 0, 0, 1, 1),
(@lcbaReportId, @productAggrFieldId, 0, 0, 1, 0, 0, 0, 1, 1),
(@lcbaReportId, @officerAggrFieldId, 0, 0, 0, 0, 0, 0, 0, 0),
(@lcbaReportId, @disbursementDateAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @productCategoryAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @productTypeAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @loanPurposeAggrFieldId, 0, 0, 1, 0, 0, 0, 1, 1),
(@lcbaReportId, @loanPurposeCategoryAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @loanPurposeTypeAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @religiousGroupAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @casteAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @occupationAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @maritalStatusAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @principalDemandsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @interestDemandsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @loanFeeDemandsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @insurancePremiumDemandsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @otherDemandsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @totalDemandsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @totalPrincipalPaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @totalInterestPaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @currentPrincipalPaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @principalPrepaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @principalOverdueRecoveryDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @currentInterestPaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @interestPrepaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @interestOverdueRecoveryDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @currentFeePaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @currentInsurancePaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @otherCurrentPaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @totalCurrentPaymentsOnDemandsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @otherPrepaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @totalPrepaymentsNoDemandsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @totalOverdueRecoveryDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @totalDisbursedAmountDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @portfolioOutstandingCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @interestAccruedBODCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @interestOutstandingCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @overdueInterestCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @overduePrincipalCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @overdueAmountCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @overduePrincipalDaysCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @genderAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @spouseNameAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @gurantorNameCustomerAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @addressAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @telephoneAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @customerNumberAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @loanCycleNumberAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @primaryIdentityProofAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @primaryIdentityProofNumberAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @primaryAddressProofAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @primaryAddressProofNumberAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @employeeManagerAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@lcbaReportId, @advanceAppropriationDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1);

-- Cash In-Flow Qbe
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@cashflowReportId, @officeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashflowReportId, @parentOffice1AggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashflowReportId, @parentOffice2AggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashflowReportId, @parentOffice3AggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashflowReportId, @productAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashflowReportId, @officerAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashflowReportId, @funderAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashflowReportId, @fundingSourceAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashflowReportId, @thirdPartyAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashflowReportId, @disbursementMonthAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashflowReportId, @stateCustomerAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashflowReportId, @loanPurposeCategoryAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashflowReportId, @repaymentFrequencyAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashflowReportId, @accountStatusAggrFieldId, 1, 1, 1, 0, 0, 0, 0, 0),
(@cashflowReportId, @installmentDateBucketFieldId, 0, 0, 0, 0, 1, 1, 0, 0),
(@cashflowReportId, @futureInterestDemandDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@cashflowReportId, @futurePrincipalDemandDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@cashflowReportId, @futureTotalDemandDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1);

-- Cash Out-Flow Qbe
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@cashOutflowReportId, @officeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashOutflowReportId, @parentOffice1AggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashOutflowReportId, @parentOffice2AggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashOutflowReportId, @parentOffice3AggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashOutflowReportId, @productAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashOutflowReportId, @officerAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashOutflowReportId, @funderAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashOutflowReportId, @fundingSourceAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashOutflowReportId, @thirdPartyAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashOutflowReportId, @disbursementMonthAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashOutflowReportId, @stateCustomerAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashOutflowReportId, @loanPurposeCategoryAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashOutflowReportId, @repaymentFrequencyAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@cashOutflowReportId, @accountStatusAggrFieldId, 1, 1, 1, 0, 0, 0, 0, 0),
(@cashOutflowReportId, @futureInterestPayableDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@cashOutflowReportId, @futurePrincipalPayableDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@cashOutflowReportId, @futureTotalPayableDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@cashOutflowReportId, @fundingInstallmentsId, 0, 0, 0, 0, 0, 0, 1, 1),
(@cashOutflowReportId, @fundingInstallmentDateBucketFieldId, 0, 0, 0, 0, 1, 1, 0, 0),
(@cashOutflowReportId, @fundingInstallmentAmountId, 0, 0, 0, 0, 0, 0, 1, 1);

-- Mudra Submission Report
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@mudraReportId, @officeAggrFieldId, 0, 1, 0, 0, 0, 0, 0, 1),
(@mudraReportId, @disbursementDateAggrFieldId, 0, 1, 0, 0, 0, 0, 0, 1),
(@mudraReportId, @stateCustomerAggrFieldId, 0, 1, 0, 0, 0, 0, 0, 1),
(@mudraReportId, @casteAggrFieldId, 0, 1, 0, 0, 0, 0, 0, 1),
(@mudraReportId, @loanTicketSizeBucketFieldId, 0, 1, 0, 0, 0, 0, 0, 1),
(@mudraReportId, @disbursedLoanAmountCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@mudraReportId, @portfolioOutstandingCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@mudraReportId, @numOpenLoanAccountsCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@mudraReportId, @totalApprovedAmountDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@mudraReportId, @stateOfficeAggrFieldId, 0, 1, 0, 0, 0, 0, 0, 1),
(@mudraReportId, @loanPurposeCategoryAggrFieldId, 0, 1, 0, 0, 0, 0, 0, 1);

-- Book Debt Report
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@bookDebtReportId, @loanAccountNumberAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@bookDebtReportId, @customerNameAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @officeAggrFieldId, 0, 1, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @centerAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @fundingSourceAggrFieldId, 0, 1, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @disbursementDateAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @stateCustomerAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @districtAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @interestRateAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @loanPurposeAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @repaymentFrequencyAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @occupationAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @currentFeePaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @currentInsurancePaymentsDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @disbursedLoanAmountCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @overdueAmountCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @overduePrincipalDaysCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @totalApprovedAmountDailyFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @officeCodeAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @centerCodeAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @groupAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @groupCodeAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @spouseNameAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @gurantorNameCustomerAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @addressAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @villageAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @pincodeAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @telephoneAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @tenureAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @tenureUnitAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @primaryIdentityProofAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @primaryAddressProofAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @firstInstallmentDateAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @lastInstallmentDateAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @futureInstallmentAmountCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @remainingTenureInDaysCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @totalInterestExpectedCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @numOverdueInstallmentsCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@bookDebtReportId, @totalOutstandingCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1);

-- Portfolio Report
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@portfolioReportId, @loanAccountNumberAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@portfolioReportId, @customerNameAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@portfolioReportId, @officeAggrFieldId, 0, 1, 0, 0, 0, 0, 1, 1),
(@portfolioReportId, @centerAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@portfolioReportId, @fundingSourceAggrFieldId, 0, 1, 0, 0, 0, 0, 1, 1),
(@portfolioReportId, @disbursementDateAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@portfolioReportId, @loanPurposeAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@portfolioReportId, @repaymentFrequencyAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@portfolioReportId, @casteAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@portfolioReportId, @interestOutstandingCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@portfolioReportId, @overdueInterestCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@portfolioReportId, @overduePrincipalCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@portfolioReportId, @overduePrincipalDaysCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@portfolioReportId, @genderAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@portfolioReportId, @officeCodeAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@portfolioReportId, @centerCodeAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@portfolioReportId, @addressAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@portfolioReportId, @firstInstallmentDateAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@portfolioReportId, @lastInstallmentDateAggrFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@portfolioReportId, @daysSinceDisbursementCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@portfolioReportId, @installmentAmountCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1);

-- Management Report
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@managementReportId, @numCentersCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@managementReportId, @averageLoansPerCenterCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@managementReportId, @numOfficersCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@managementReportId, @averageLoansPerOfficerCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@managementReportId, @averagePortfolioOutstandingPerOfficerCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@managementReportId, @installmentDemandsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@managementReportId, @currentInstallmentPaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@managementReportId, @collectionPercentageDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@managementReportId, @numCustomersWithAadharCardCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@managementReportId, @customersWithAadharCardPercentageCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@managementReportId, @telephoneCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@managementReportId, @telephonePercentageCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@managementReportId, @officeAggrFieldId, 0, 1, 1, 1, 0, 0, 0, 0),
(@managementReportId, @overdueAmountCumuFieldId,0, 1, 0, 0, 0, 0, 1, 0),
(@managementReportId, @portfolioOutstandingCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@managementReportId, @numOpenLoanCustomersCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@managementReportId, @accountStatusAggrFieldId, 0, 1, 0, 0, 0, 0, 0, 0);

-- Portfolio Report
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@portfolioReconReportId, @openingOutstandingCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@portfolioReconReportId, @totalPrincipalPaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@portfolioReconReportId, @totalDisbursedAmountDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@portfolioReconReportId, @closingOutstandingCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@portfolioReconReportId, @derivedPortfolioCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@portfolioReconReportId, @dateAggrFieldId, 0, 1, 1, 1, 0, 0, 0, 0);

-- Collection Report
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@collectionReportId, @totalPrincipalPaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@collectionReportId, @totalInterestPaymentsDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@collectionReportId, @advanceCollectionDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@collectionReportId, @totalCollectionDailyFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@collectionReportId, @portfolioOutstandingCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@collectionReportId, @openingAdvanceCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@collectionReportId, @closingAdvanceCumuFieldId, 0, 1, 0, 0, 0, 0, 1, 0),
(@collectionReportId, @officeAggrFieldId, 0, 1, 1, 1, 0, 0, 0, 0);

-- ReportRuleSet
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@reportRuleSetId, @daysSinceDisbursementCumuFieldId, 0, 1, 1, 1, 0, 0, 0, 0),
(@reportRuleSetId, @productCategoryAggrFieldId, 0, 1, 1, 1, 0, 0, 0, 0),
(@reportRuleSetId, @overduePrincipalDaysCumuFieldId, 0, 1, 1, 1, 0, 0, 0, 0),
(@reportRuleSetId, @loanCycleNumberAggrFieldId, 0, 1, 1, 1, 0, 0, 0, 0),
(@reportRuleSetId, @daysSinceFirstRepayDateId, 0, 1, 1, 1, 0, 0, 0, 0),
(@reportRuleSetId, @attendancePercentageId, 0, 1, 1, 1, 0, 0, 0, 0),
(@reportRuleSetId, @tenureMaximumOverduePrincipalDaysId, 0, 1, 1, 1, 0, 0, 0, 0),
(@reportRuleSetId, @customerLocaleAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@reportRuleSetId, @loanAmountCumId, 0, 0, 1, 0, 0, 0, 0, 0),
(@reportRuleSetId, @isDisbursed, 0, 0, 1, 0, 0, 0, 0, 0),
(@reportRuleSetId, @customerAgeAggrFieldId, 0, 0, 0, 1, 0, 0, 0, 0),
(@reportRuleSetId, @cbNohitAggrId, 0, 0, 0, 1, 0, 0, 0, 0),
(@reportRuleSetId, @landholdingAggrId, 0, 0, 0, 1, 0, 0, 0, 0),
(@reportRuleSetId, @customerBankAccountStateId, 0, 0, 0, 1, 0, 0, 0, 0),
(@reportRuleSetId, @maritalStatusAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@reportRuleSetId, @firstRepayWeekAggrFieldId, 0, 1, 0, 0, 0, 0, 0, 0),
(@reportRuleSetId, @numOtherLenderId, 0, 0, 1, 0, 0, 0, 0, 0),
(@reportRuleSetId, @numActiveAccountsId, 0, 0, 1, 0, 0, 0, 0, 0),
(@reportRuleSetId, @totalOtherBalanceId, 0, 0, 1, 0, 0, 0, 0, 0),
(@reportRuleSetId, @bureauVintageId, 0, 0, 1, 0, 0, 0, 0, 0),
(@reportRuleSetId, @bureauScoreId, 0, 0, 1, 0, 0, 0, 0, 0),
(@reportRuleSetId, @cbServiceId, 0, 0, 1, 0, 0, 0, 0, 0),
(@reportRuleSetId, @previousCycleLoanAmountId, 0, 0, 1, 0, 0, 0, 0, 0),
(@reportRuleSetId, @customerIncomeAggrId, 0, 0, 1, 0, 0, 0, 0, 0),
(@reportRuleSetId, @numberOfLoansAggrId, 0, 0, 1, 0, 0, 0, 0, 0),
(@reportRuleSetId, @totalCurrentBalanceAggrId, 0, 0, 1, 0, 0, 0, 0, 0),
(@reportRuleSetId, @nameMatchPercentage, 0, 0, 1, 0, 0, 0, 0, 0),
(@reportRuleSetId, @occupationAggrFieldId, 0, 0, 1, 0, 0, 0, 0, 0),
(@reportRuleSetId, @savingsWithdrawalCountId, 0, 0, 1, 0, 0, 0, 0, 0),
(@reportRuleSetId, @savingsMinimumBalanceId, 0, 0, 1, 0, 0, 0, 0, 0),
(@reportRuleSetId, @totalNoOfMandatoryDepositId, 0, 0, 1, 0, 0, 0, 0, 0),
(@reportRuleSetId, @isMembershipDepositPaidId, 0, 0, 1, 0, 0, 0, 0, 0);

INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@officerAllocationType, @daysSinceDisbursementCumuFieldId, 0, 1, 1, 1, 0, 0, 0, 0),
(@officerAllocationType, @overdueAmountCumuFieldId, 0, 1, 1, 1, 0, 0, 0, 0),
(@officerAllocationType, @overduePrincipalDaysCumuFieldId, 0, 1, 1, 1, 0, 0, 0, 0);

-- ReportRuleSet
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@documentRuleId, @daysSinceDisbursementCumuFieldId, 0, 0, 0, 1, 0, 0, 0, 0),
(@documentRuleId, @loanAmountCumId, 0, 0, 0, 1, 0, 0, 0, 0),
(@documentRuleId, @productClassAggrFieldId, 0, 0, 0, 1, 0, 0, 0, 0);

-- Vintage PAR All bucket Qbe
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@vintageQbeReportId, @officeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbeReportId, @productAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbeReportId, @officerAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbeReportId, @funderAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbeReportId, @fundingSourceAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbeReportId, @disbursementMonthAggrFieldId,1, 1, 1, 1, 0, 0, 0, 0),
(@vintageQbeReportId, @districtAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbeReportId, @productCategoryAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbeReportId, @productTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbeReportId, @interestRateAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbeReportId, @interestRateTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbeReportId, @loanPurposeCategoryAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbeReportId, @loanPurposeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbeReportId, @loanPurposeTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbeReportId, @repaymentFrequencyAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbeReportId, @accountStatusAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbeReportId, @officeCodeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbeReportId, @centerCodeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbeReportId, @loanCycleNumberAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbeReportId, @lastDateOfTheMonth, 0, 0, 1, 1, 0, 0, 0, 0),
(@vintageQbeReportId, @numOverdueDaysBucketFieldId, 0, 0, 0, 0, 1, 1, 0, 0),
(@vintageQbeReportId, @advanceCollectionBucketFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbeReportId, @portfolioOutstandingBucketFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbeReportId, @overdueInterestBucketFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbeReportId, @overduePrincipalBucketFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbeReportId, @numOpenLoanAccountsCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbeReportId, @portfolioAtRiskParCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbeReportId, @arrearsRateParCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1);

-- Vintage PAR 30 Qbe
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@vintageQbe30ReportId, @officeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe30ReportId, @productAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe30ReportId, @officerAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe30ReportId, @funderAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe30ReportId, @fundingSourceAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe30ReportId, @disbursementMonthAggrFieldId,1, 1, 1, 1, 0, 0, 0, 0),
(@vintageQbe30ReportId, @districtAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe30ReportId, @productCategoryAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe30ReportId, @productTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe30ReportId, @interestRateAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe30ReportId, @interestRateTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe30ReportId, @loanPurposeCategoryAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe30ReportId, @loanPurposeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe30ReportId, @loanPurposeTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe30ReportId, @repaymentFrequencyAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe30ReportId, @accountStatusAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe30ReportId, @officeCodeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe30ReportId, @centerCodeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe30ReportId, @loanCycleNumberAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe30ReportId, @lastDateOfTheMonth, 0, 0, 1, 1, 0, 0, 0, 0),
(@vintageQbe30ReportId, @numOverdueDaysBucketFieldId, 0, 0, 0, 0, 0, 0, 0, 0),
(@vintageQbe30ReportId, @advanceCollectionBucketFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbe30ReportId, @portfolioOutstandingBucketFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbe30ReportId, @overdueInterestBucketFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbe30ReportId, @overduePrincipalBucketFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbe30ReportId, @numOpenLoanAccountsCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbe30ReportId, @portfolioAtRiskParCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbe30ReportId, @arrearsRateParCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1);

-- Vintage PAR 90 Qbe
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@vintageQbe90ReportId, @officeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe90ReportId, @productAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe90ReportId, @officerAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe90ReportId, @funderAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe90ReportId, @fundingSourceAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe90ReportId, @disbursementMonthAggrFieldId,1, 1, 1, 1, 0, 0, 0, 0),
(@vintageQbe90ReportId, @districtAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe90ReportId, @productCategoryAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe90ReportId, @productTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe90ReportId, @interestRateAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe90ReportId, @interestRateTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe90ReportId, @loanPurposeCategoryAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe90ReportId, @loanPurposeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe90ReportId, @loanPurposeTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe90ReportId, @repaymentFrequencyAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe90ReportId, @accountStatusAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe90ReportId, @officeCodeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe90ReportId, @centerCodeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe90ReportId, @loanCycleNumberAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe90ReportId, @lastDateOfTheMonth, 0, 0, 1, 1, 0, 0, 0, 0),
(@vintageQbe90ReportId, @numOverdueDaysBucketFieldId, 0, 0, 0, 0, 0, 0, 0, 0),
(@vintageQbe90ReportId, @advanceCollectionBucketFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbe90ReportId, @portfolioOutstandingBucketFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbe90ReportId, @overdueInterestBucketFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbe90ReportId, @overduePrincipalBucketFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbe90ReportId, @numOpenLoanAccountsCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbe90ReportId, @portfolioAtRiskParCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbe90ReportId, @arrearsRateParCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1);

-- Vintage PAR 180 Qbe
INSERT INTO ReportFieldMap(report_id, report_field_id, is_def_filter, can_filter, can_aggregate, default_aggregate, can_bucket, default_bucket, is_output_view, default_output) VALUES
(@vintageQbe180ReportId, @officeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe180ReportId, @productAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe180ReportId, @officerAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe180ReportId, @funderAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe180ReportId, @fundingSourceAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe180ReportId, @disbursementMonthAggrFieldId,1, 1, 1, 1, 0, 0, 0, 0),
(@vintageQbe180ReportId, @districtAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe180ReportId, @productCategoryAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe180ReportId, @productTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe180ReportId, @interestRateAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe180ReportId, @interestRateTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe180ReportId, @loanPurposeCategoryAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe180ReportId, @loanPurposeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe180ReportId, @loanPurposeTypeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe180ReportId, @repaymentFrequencyAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe180ReportId, @accountStatusAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe180ReportId, @officeCodeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe180ReportId, @centerCodeAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe180ReportId, @loanCycleNumberAggrFieldId, 0, 1, 1, 0, 0, 0, 0, 0),
(@vintageQbe180ReportId, @lastDateOfTheMonth, 0, 0, 1, 1, 0, 0, 0, 0),
(@vintageQbe180ReportId, @numOverdueDaysBucketFieldId, 0, 0, 0, 0, 0, 0, 0, 0),
(@vintageQbe180ReportId, @advanceCollectionBucketFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbe180ReportId, @portfolioOutstandingBucketFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbe180ReportId, @overdueInterestBucketFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbe180ReportId, @overduePrincipalBucketFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbe180ReportId, @numOpenLoanAccountsCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbe180ReportId, @portfolioAtRiskParCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1),
(@vintageQbe180ReportId, @arrearsRateParCumuFieldId, 0, 0, 0, 0, 0, 0, 1, 1);
--
-- Master table values for ActionSlabTypeMaster
--
DELETE FROM ActionSlabTypeMaster;
INSERT INTO ActionSlabTypeMaster(product_category_id, action_rule_id, report_field_id) VALUES
(@loanProductCategoryId, @loanApprovalSlabActionRuleId, @interestRateAggrFieldId),
(@loanProductCategoryId, @loanApprovalSlabActionRuleId, @totalApprovedAmountDailyFieldId);

--
-- Master table values for EndOfDaySchedule
--
DELETE FROM EndOfDaySchedule;
INSERT INTO EndOfDaySchedule(eod_day) VALUES
('Sunday'),
('Monday'),
('Tuesday'),
('Wednesday'),
('Thursday'),
('Friday'),
('Saturday');

--
-- Master table values for AccountDirectAppropTypeMaster
--
DELETE FROM AccountDirectAppropTypeMaster;
INSERT INTO AccountDirectAppropTypeMaster(tx_type_id, meta_fee_id) VALUES
(@lateChargeCashTypeId, NULL),
(@interestOnOverduePrincipalCashTypeId, NULL),
(@interestOnOverdueInterestCashTypeId, NULL),
(@chequeBounceChargeTypeId, NULL);

--
-- Master table values for CreditBureauServiceMaster
--
DELETE FROM CreditBureauServiceMaster;
INSERT INTO CreditBureauServiceMaster(third_party_id, name, is_enabled, set_no_hit_as_positive) VALUES
(@highmarkThirdPartyId, 'HIGHMARK-ENQUIRY-MCR', 0, 0),
(@highmarkThirdPartyId, 'HIGHMARK-ENQUIRY-CCR', 0, 0),
(@highmarkThirdPartyId, 'HIGHMARK-IDENCHECK', 0, NULL),
(@equifaxThirdPartyId, 'EQUIFAX-ENQUIRY-MCR', 0, 0),
(@equifaxThirdPartyId, 'EQUIFAX-ENQUIRY-CCR', 0, 0),
(@equifaxThirdPartyId, 'EQUIFAX_VERIFY360', 0, 0),
(@cibilThirdPartyId, 'CIBIL-ENQUIRY', 0, 0),
(@bureauOneId, 'BUREAUONE-ENQUIRY', 0, 0),
(@surepassCbThirdPartyId, 'SUREPASS', 0, 0),

SELECT @highmarkMcrEnquiryServiceId := id FROM CreditBureauServiceMaster WHERE third_party_id=@highmarkThirdPartyId AND name = 'HIGHMARK-ENQUIRY-MCR';
SELECT @highmarkCcrEnquiryServiceId := id FROM CreditBureauServiceMaster WHERE third_party_id=@highmarkThirdPartyId AND name = 'HIGHMARK-ENQUIRY-CCR';
SELECT @highmarkIdenCheckServiceId := id FROM CreditBureauServiceMaster WHERE third_party_id=@highmarkThirdPartyId AND name = 'HIGHMARK-IDENCHECK';
SELECT @equifaxIdenCheckServiceId := id FROM CreditBureauServiceMaster WHERE third_party_id=@equifaxThirdPartyId AND name = 'EQUIFAX_VERIFY360';
SELECT @equifaxMcrEnquiryServiceId := id FROM CreditBureauServiceMaster WHERE third_party_id=@equifaxThirdPartyId AND name = 'EQUIFAX-ENQUIRY-MCR';
SELECT @equifaxCcrEnquiryServiceId := id FROM CreditBureauServiceMaster WHERE third_party_id=@equifaxThirdPartyId AND name = 'EQUIFAX-ENQUIRY-CCR';
SELECT @cibilEnquiryServiceId := id FROM CreditBureauServiceMaster WHERE third_party_id=@cibilThirdPartyId AND name = 'CIBIL-ENQUIRY';
SELECT @bureauOneEnquiryServiceId := id FROM CreditBureauServiceMaster WHERE third_party_id=@bureauOneId AND name = 'BUREAUONE-ENQUIRY';
SELECT @surepassServiceId := id FROM CreditBureauServiceMaster WHERE third_party_id=@surepassCbThirdPartyId AND name = 'SUREPASS';

SELECT @partiallyEnrolledStatusId := id FROM CustomerStatusMaster WHERE name = 'Partially Enrolled';
SELECT @partiallyEnrolledInCenterStatusId := id FROM CustomerStatusMaster WHERE name = 'Partially Enrolled In Center/Branch';
SELECT @pendingVerificationStatusId := id FROM CustomerStatusMaster WHERE name = 'Pending verification';
SELECT @awaitingQCStatusId := id FROM CustomerStatusMaster WHERE name = 'Awaiting QC';

--
-- Master table values for CreditBureauServiceCustomerStatus
--
DELETE FROM CreditBureauServiceCustomerStatus;
INSERT INTO CreditBureauServiceCustomerStatus(cb_service_id, status_id) VALUES
(@highmarkMcrEnquiryServiceId, @partiallyEnrolledStatusId),
(@highmarkMcrEnquiryServiceId, @partiallyEnrolledInCenterStatusId),
(@highmarkMcrEnquiryServiceId, @pendingVerificationStatusId),
(@highmarkCcrEnquiryServiceId, @partiallyEnrolledStatusId),
(@highmarkCcrEnquiryServiceId, @partiallyEnrolledInCenterStatusId),
(@highmarkCcrEnquiryServiceId, @pendingVerificationStatusId),
(@equifaxMcrEnquiryServiceId, @partiallyEnrolledStatusId),
(@equifaxMcrEnquiryServiceId, @partiallyEnrolledInCenterStatusId),
(@equifaxMcrEnquiryServiceId, @pendingVerificationStatusId),
(@equifaxCcrEnquiryServiceId, @partiallyEnrolledStatusId),
(@equifaxCcrEnquiryServiceId, @partiallyEnrolledInCenterStatusId),
(@equifaxCcrEnquiryServiceId, @pendingVerificationStatusId),
(@highmarkIdenCheckServiceId, @partiallyEnrolledStatusId),
(@highmarkIdenCheckServiceId, @partiallyEnrolledInCenterStatusId),
(@highmarkIdenCheckServiceId, @pendingVerificationStatusId),
(@highmarkIdenCheckServiceId, @awaitingQCStatusId),
(@equifaxIdenCheckServiceId, @partiallyEnrolledStatusId),
(@equifaxIdenCheckServiceId, @partiallyEnrolledInCenterStatusId),
(@equifaxIdenCheckServiceId, @pendingVerificationStatusId),
(@equifaxIdenCheckServiceId, @awaitingQCStatusId),
(@bureauOneEnquiryServiceId, @partiallyEnrolledStatusId),
(@bureauOneEnquiryServiceId, @partiallyEnrolledInCenterStatusId),
(@bureauOneEnquiryServiceId, @pendingVerificationStatusId),
(@bureauOneEnquiryServiceId, @awaitingQCStatusId),
(@surepassServiceId, @pendingVerificationStatusId),
(@surepassServiceId, @partiallyEnrolledStatusId),
(@surepassServiceId, @partiallyEnrolledInCenterStatusId),
(@surepassServiceId, @awaitingQCStatusId);

--
-- Master table values for AppEventMaster
--

DELETE FROM AppEventMaster;
INSERT INTO AppEventMaster(name) VALUES
('Loan Opening'),
('Loan Approval'),
('Customer Enrollment'),
('Finish Enrollment'),
('Update Customer Loan Details'),
('Account Level Fee/Insurance/Charge Creation'),
('Loan Disbursement'),
('Loan Disbursement Cancel'),
('Area Creation'),
('Center Creation'),
('Area Checker/Approval'),
('Area Geolocation Maker'),
('Area Geolocation Checker'),
('Area remapped to another branch'),
('Center Geolocation Maker'),
('Center Geolocation Checker'),
('Center Address Change'),
('Center transfer to another branch'),
('Customer Geolocation Maker'),
('Customer Geolocation Checker'),
('Customer Address Change'),
('Customer transfer to another branch'),
('Customer transfer to another center'),
('Loan Approval + Scheduling'),
('Loan Payment'),
('Update First Repayment Date'),
('CDS Generation'),
('Loan Payment'),
('Savings Withdrawal'),
('Deposit Account Opening'),
('Savings Account Opening');

--
-- Master table values for SystemParam
--
DELETE FROM SystemParam;
INSERT INTO SystemParam(param, name,  default_value,limit_value,data_type, description) VALUES
('max_vdt_payments','Total no. of value-dated payments allowed for posting', '300','1000','int', 'This is the total number of value-dated payments allowed to post in Shakti. Total n. Note: EOD time will get delayed.'),
('max_foreclose_payments_vdt_days','Open value-dated calendar for Foreclosure Payments', '3','100','int', 'No. of days the calendar needs to be opened for making Foreclosure Payments. Note: EOD time will get delayed.'),
('max_payment_vdt_days', 'Open value-dated calendar for Regular Payments', '3','100','int', 'No. of days the calendar needs to be opened for making Regular Payments. Note: EOD time will get delayed.'),
('max_disbursement_vdt_days', 'Open value-dated calendar for Disbursements and Scheduling Disbursements', '3','100','int', 'No. of days the calendar needs to be opened for making Disbursements. Note: EOD time will get delayed.'),
('max_accounting_vdt_days', 'Open value-dated calendar for Accounting entries', '3','100','int', 'No. of days the calendar needs to be opened for making Accounting entries. Note: EOD time will get delayed.'),
('max_deposit_vdt_days', 'Open value-dated calendar for posting Deposit entries', '5','100','int', 'No. of days the calendar needs to be opened for making Deposit entries. Note: EOD time will get delayed.'),
('max_first_repayment_Days', 'Open value-dated calendar for allowing First Repayment date to be in past', '30','100','int', 'No. of days the calendar needs to be opened for selecting past dates for First Repayment date.'),
('pipeline_schd_date_block_start', 'Start time to block Update Pipeline Schedule Disbursement date', '09:00:00','23:59:59','time', ' Start time to un-block Update Pipeline Schedule Disbursement date'),
('pipeline_schd_date_block_stop', 'Start time to un-block Update Pipeline Schedule Disbursement date', '11:00:00','23:59:59','time', 'Start time to un-block updating of Pipeline Schedule Disbursement date. Note: Start Time needs to be set.'),
('max_vdt_fund_tagging_days', 'Open value-dated calendar for allowing Fund Tagging date to be in past', '30','100','int', 'No. of days the calendar needs to be opened for selecting past dates for Fund Tagging date.'),
('max_moratorium_rescheduling_vdt_days','Open value-dated calendar for Moratorium Rescheduling with Interest Accrual', '1','1','int', 'No. of days the calendar needs to be opened for making moratorium rescheduling. Note: EOD time will get delayed.'),
('max_bank_disburse_file_days','Days to open the calender for bank disburse file', '30','200','int', 'Days to open the calender for bank disburse file'),
('open_financial_previous_year','Allow value-dated posting for previous financial year(s). Total n. Note: EOD time will get delayed.','0',null,'boolean', 'Allow value-dated posting for previous financial year(s). Total n. Note: EOD time will get delayed.'),
('active_pipeline_days','Days to Expire Pipeline Due to Inactivity','30','100','int', 'Days to Expire Pipeline Due to Inactivity'),
('max_ecs_failed_disbursement_vdt_days','Open value-dated calendar for ECS failed as Cash Disbursements','15','100','int', 'No. of days the calendar needs to be opened for making Cash Disbursements for ECS failed. Note: EOD time will get delayed.'),
('max_account_level_fee_vdt_days', 'Open value-dated calendar for Account-level Fees & Charges.', '1', '100', 'int', 'No. of days the calendar needs to be opened to configure Account-level Fees & Charges. Note: EOD time will get delayed.');

INSERT INTO SystemParam(param, name,  default_value,limit_value,data_type, description,is_visible) VALUES
('business_rules_on_current_report_data','Business Rule Engine Rules to be Run on Current Report Data',0,NULL,'int', 'Business Rule Engine Rules to be Run on Current Report Data',0),
('enable_upload_loan_origination_activity','Enable Loan origination Activity',0,NULL,'int', 'Enable Loan origination Activity Upload Option',0),
('takeOver_jewel_threshold_limit','Return Days for the TakeOver Loan Jewel',3,3,int,'Return Days for the TakeOver Loan Jewel',0);



--
-- Master table values for BusinessLogicTypeMaster
--
INSERT INTO BusinessLogicTypeMaster(name, ui_name, parent_type_id, description, system_defined,is_active ) VALUES
('Enrollment Setting Type', 'Enrollment Setting Type', NULL, NULL, 1, 1),
('Enrollment Setting Category', 'Enrollment Setting Category', NULL, NULL, 1, 1),
('Loan Process Category', 'Loan Process Category', NULL, NULL, 1, 1),
('Third Party Account Status', 'Third Party Account Status', NULL, NULL, 1, 1),
('Nach Mandate Authentication Type', 'Nach Mandate Authentication Type', NULL, NULL, 1, 1),
('NACH Mandate Presentation Status', 'NACH Mandate Presentation Status', NULL, NULL, 1, 1),
('NACH Presentation Frequency', 'NACH Presentation Frequency', NULL, NULL, 1, 1),
('NACH Mandate Registration Status', 'NACH Mandate Registration Status', NULL, NULL, 1, 1),
('Accounting Entries', 'Accounting Entries', NULL, NULL, 1, 1),
('Customer Process Category', 'Customer Process Category', NULL, NULL, 1, 1), 
('Entity CB Stat Type', 'Entity CB Stat Type', NULL, NULL, 1, 1),
('Par Action Blocking Types', 'Par Action Blocking Types', NULL, NULL, 1, 1);


SELECT @enrolmentSettingTypeId := id FROM BusinessLogicTypeMaster WHERE name = 'Enrollment Setting Type';
SELECT @enrolmentSettingCategoryId := id FROM BusinessLogicTypeMaster WHERE name = 'Enrollment Setting Category';
SELECT @loanProcessCategoryId := id FROM BusinessLogicTypeMaster WHERE name = 'Loan Process Category';
SELECT @thirdPartyAccountStatusId := id FROM BusinessLogicTypeMaster WHERE name = 'Third Party Account Status';
SELECT @nachAuthTypeId := id FROM BusinessLogicTypeMaster WHERE name = 'Nach Mandate Authentication Type';
SELECT @nachPresentationStatusTypeId := id FROM BusinessLogicTypeMaster WHERE name = 'NACH Mandate Presentation Status';
SELECT @nachPresentationFreqTypeId := id FROM BusinessLogicTypeMaster WHERE name = 'NACH Presentation Frequency';
SELECT @nachMandateStatusTypeId := id FROM BusinessLogicTypeMaster WHERE name = 'NACH Mandate Registration Status';
SELECT @accountingEntryId := id FROM BusinessLogicTypeMaster WHERE name = 'Third Party Account Status';
SELECT @customerProcessCategoryId := id FROM BusinessLogicTypeMaster WHERE name = 'Customer Process Category';
SELECT @entityCbStatTypeId := id FROM BusinessLogicTypeMaster WHERE name = 'Entity CB Stat Type';
SELECT @parActionTypeId := id FROM BusinessLogicTypeMaster WHERE name = 'Par Action Blocking Types';
--
-- Master table values for BusinessLogicMaster
--
DELETE FROM BusinessLogicMaster;
INSERT INTO BusinessLogicMaster(type_id, name, ui_name, abbr, description, system_defined,is_active, is_visible) VALUES
(@enrolmentSettingTypeId, 'Partial Enrollment', 'Partial Enrollment', NULL, NULL, 1, 1, 1),
(@enrolmentSettingTypeId, 'Full Enrollment', 'Full Enrollment', NULL, NULL, 1, 1, 1),
(@enrolmentSettingTypeId, 'QC Approve', 'QC Approve', NULL, NULL, 1, 1, 1),
(@loanProcessCategoryId, 'Loan Origination', 'Loan Origination', NULL, NULL, 1, 1, 1),
(@loanProcessCategoryId, 'Loan Scheduling', 'Loan Scheduling', NULL, NULL, 1, 1, 1),
(@loanProcessCategoryId, 'Loan Disbursement', 'Loan Disbursement', NULL, NULL, 1, 1, 1),
(@loanProcessCategoryId, 'mShakti Center Collection', 'mShakti Center Collection', NULL, NULL, 1, 1, 1),
(@loanProcessCategoryId, 'ECS Failed as Cash Disburse', 'ECS Failed as Cash Disburse', NULL, NULL, 1, 1, 1),
(@loanProcessCategoryId, 'Loan Approval', 'Loan Approval', NULL, NULL, 1, 1, 1),
(@customerProcessCategoryId, 'Attach Customer Group', 'Attach Customer Group', NULL, NULL, 1, 1, 1),
(@entityCbStatTypeId, 'Total Installment Amount', 'Total Installment Amount', NULL, NULL, 1, 1, 1),
(@thirdPartyAccountStatusId, 'new', 'new', NULL, NULL, 1, 1, 1),
(@thirdPartyAccountStatusId, 'approved', 'approved', NULL, NULL, 1, 1, 1),
(@thirdPartyAccountStatusId, 'rejected', 'rejected', NULL, NULL, 1, 1, 1),
(@thirdPartyAccountStatusId, 'agreement_signed', 'agreement_signed', NULL, NULL, 1, 1, 1),
(@thirdPartyAccountStatusId, 'disbursement_ready', 'disbursement_ready', NULL, NULL, 1, 1, 1),
(@thirdPartyAccountStatusId, 'dropped', 'dropped', NULL, NULL, 1, 1, 1),
(@thirdPartyAccountStatusId, 'disbursed', 'disbursed', NULL, NULL, 1, 1, 1),
(@thirdPartyAccountStatusId, 'matured', 'matured', NULL, NULL, 1, 1, 1),
(@thirdPartyAccountStatusId, 'borrower_disbursed', 'borrower_disbursed', NULL, NULL, 1, 1, 1),
(@enrolmentSettingCategoryId, 'Customer Information', 'Customer Information', NULL, NULL, 1, 1, 1),
(@enrolmentSettingCategoryId, 'Guarantor Information', 'Guarantor Information', NULL, NULL, 1, 1, 1),
(@enrolmentSettingCategoryId, 'Household Members', 'Household Members', NULL, NULL, 1, 1, 1),
(@enrolmentSettingCategoryId, 'Spouse Information', 'Spouse Information', NULL, NULL, 1, 1, 1),
(@enrolmentSettingCategoryId, 'Nominee Information', 'Nominee Information', NULL, NULL, 1, 1, 1),
(@nachAuthTypeId, 'Physical Mandate', 'Physical Mandate', NULL, NULL, 1, 1, 1),
(@nachAuthTypeId, 'API Mandate', 'API Mandate', NULL, NULL, 1, 1, 1),
(@nachAuthTypeId, 'eSign Mandate', 'eSign Mandate', NULL, NULL, 1, 1, 1),
(@nachPresentationStatusTypeId, 'READY TO PAUSE', 'READY TO PAUSE', NULL, NULL, 1, 1, 1),
(@nachPresentationStatusTypeId, 'PAUSE', 'PAUSE', NULL, NULL, 1, 1, 1),
(@nachPresentationStatusTypeId, 'READY TO CANCEL', 'READY TO CANCEL', NULL, NULL, 1, 1, 1),
(@nachPresentationStatusTypeId, 'CANCELED', 'CANCELED', NULL, NULL, 1, 1, 1),
(@nachPresentationStatusTypeId, 'CREATED', 'CREATED', NULL, NULL, 1, 1, 1),
(@nachPresentationStatusTypeId, 'READY TO RESUME', 'READY TO RESUME', NULL, NULL, 1, 1, 1),
(@nachPresentationStatusTypeId, 'COMPLETED', 'COMPLETED', NULL, NULL, 1, 1, 1),
(@nachPresentationStatusTypeId, 'FAILED', 'FAILED', NULL, NULL, 1, 1, 1),
(@nachPresentationStatusTypeId, 'Txn Created', 'Txn Created', NULL, NULL, 1, 1, 1),
(@nachPresentationStatusTypeId, 'Txn Spon Bank Accept', 'Txn Spon Bank Accept', NULL, NULL, 1, 1, 1),
(@nachPresentationStatusTypeId, 'Txn Spon Bank Reject', 'Txn Spon Bank Reject', NULL, NULL, 1, 1, 1),
(@nachPresentationStatusTypeId, 'Txn Success', 'Txn Success', NULL, NULL, 1, 1, 1),
(@nachPresentationStatusTypeId, 'Txn Failed', 'Txn Failed', NULL, NULL, 1, 1, 1),
(@nachPresentationStatusTypeId, 'Txn Skipped', 'Txn Skipped', NULL, NULL, 1, 1, 1),
(@nachPresentationFreqTypeId, 'Adhoc', 'Adhoc', NULL, NULL, 1, 1, 1),
(@nachPresentationFreqTypeId, 'ONETIME', 'ONETIME', NULL, NULL, 1, 1, 1),
(@nachPresentationFreqTypeId, 'IntraDay', 'IntraDay', NULL, NULL, 1, 1, 1),
(@nachPresentationFreqTypeId, 'Daily', 'Daily', NULL, NULL, 1, 1, 1),
(@nachPresentationFreqTypeId, 'Weekly', 'Weekly', NULL, NULL, 1, 1, 1),
(@nachPresentationFreqTypeId, 'Monthly', 'Monthly', NULL, NULL, 1, 1, 1),
(@nachPresentationFreqTypeId, 'BiMonthly', 'BiMonthly', NULL, NULL, 1, 1, 1),
(@nachPresentationFreqTypeId, 'Quarterly', 'Quarterly', NULL, NULL, 1, 1, 1),
(@nachPresentationFreqTypeId, 'Semiannually', 'Semiannually', NULL, NULL, 1, 1, 1),
(@nachPresentationFreqTypeId, 'Yearly', 'Yearly', NULL, NULL, 1, 1, 1),
(@nachMandateStatusTypeId, 'Mandate Created', 'Mandate Created', NULL, NULL, 1, 1, 1),
(@nachMandateStatusTypeId, 'Mandate Signed', 'Mandate Signed', NULL, NULL, 1, 1, 1),
(@nachMandateStatusTypeId, 'Mandate Transfer Success', 'Mandate Transfer Success', NULL, NULL, 1, 1, 1),
(@nachMandateStatusTypeId, 'Mandate Transfer Failed', 'Mandate Transfer Failed', NULL, NULL, 1, 1, 1),
(@nachMandateStatusTypeId, 'Sponsor Bank Mandate Accept', 'Sponsor Bank Mandate Accept', NULL, NULL, 1, 1, 1),
(@nachMandateStatusTypeId, 'NPCI Mandate Accept', 'NPCI Mandate Accept', NULL, NULL, 1, 1, 1),
(@nachMandateStatusTypeId, 'Destination Bank Mandate Accept', 'Destination Bank Mandate Accept', NULL, NULL, 1, 1, 1),
(@nachMandateStatusTypeId, 'Mandate Approved', 'Mandate Approved', NULL, NULL, 1, 1, 1),
(@nachMandateStatusTypeId, 'Sponsor Bank Mandate Reject', 'Sponsor Bank Mandate Reject', NULL, NULL, 1, 1, 1),
(@nachMandateStatusTypeId, 'NPCI Mandate Reject', 'NPCI Mandate Reject', NULL, NULL, 1, 1, 1),
(@nachMandateStatusTypeId, 'Destination Bank Mandate Reject', 'Destination Bank Mandate Reject', NULL, NULL, 1, 1, 1),
(@nachMandateStatusTypeId, 'Mandate Cancellation Underprocess', 'Mandate Cancellation Underprocess', NULL, NULL, 1, 1, 1),
(@nachMandateStatusTypeId, 'Mandate Cancelled', 'Mandate Cancelled', NULL, NULL, 1, 1, 1),
(@enrolmentSettingCategoryId, 'Accounting - Bank Deposit Entry', 'Accounting - Bank Deposit Entry', NULL, NULL, 1, 1, 1),
(@enrolmentSettingCategoryId, 'Accounting - Bank Withdrawal Entry', 'Accounting - Bank Withdrawal Entry', NULL, NULL, 1, 1, 1),
(@enrolmentSettingCategoryId, 'Accounting - Journal Entry', 'Accounting - Journal Entry', NULL, NULL, 1, 1, 1),
(@enrolmentSettingCategoryId, 'Accounting - Payment Entry', 'Accounting - Payment Entry', NULL, NULL, 1, 1, 1),
(@enrolmentSettingCategoryId, 'Accounting - Receipt Entry', 'Accounting - Receipt Entry', NULL, NULL, 1, 1, 1),
(@enrolmentSettingCategoryId, 'Co-applicant Information', 'Co-applicant Information', NULL, NULL, 1, 1, 1),
(@parActionTypeId, 'Office Blocking', 'Office Blocking', NULL, NULL, 1, 1, 1);



--
-- Master table values for DocumentTypeMaster
--
DELETE FROM DocumentTypeMaster;
INSERT INTO DocumentTypeMaster(name, ui_name) VALUES
('Entity','Entity'),                                 
('EntityIdentityProof','Entity Identity Proof'),     
('Account','Account'),                                
('EntityBankAccount','Entity Bank Account'),
('Pipeline','Pipeline'),                              
('PipelineInfo','Pipeline Status'),                   
('Survey','Survey') ,                                 
('FundingSource','Funding Source') ,                  
('Employee','Employee'),                              
('BankAccountRecon','Bank Account Recon'),            
('VehicleCollateral','Vehicle Collateral'),           
('DocumentTemplate','Document Template'),             
('PaymentGroup','Payment Group'),                   
('ThirdpartyResponse','Thirdparty Response') ,        
('AwsRekognitionResponse','Aws Rekognition Response'),
('KotakInsuranceResponse','Kotak Insurance Response'),
('TwinlineResponse','Twinline Response'),          
('UpiPayRequestResponse','UPI Pay Request & Response'),
('AccountClaim','AccountClaim'),
('Employment','Employment'),
('PropertyCollateral','Property Collateral'),
('PropertyDeedCollateral','Property Deed Collateral'),
('DigioRequestResponse','Digio Request & Response'),
('Center Account','Center Account'),
('Accounting - Journal Entry','Accounting - Journal Entry'),
('Accounting - Receipt Entry','Accounting - Receipt Entry'),
('Accounting - Payment Entry','Accounting - Payment Entry'),
('Accounting - Bank Withdrawal Entry','Accounting - Bank Withdrawal Entry'),
('Accounting - Bank Deposit Entry','Accounting - Bank Deposit Entry'),
('Consumer Durable Damaged Inventory','Consumer Durable Damaged Inventory'),
('Accounting - Bank Expense Entry','Accounting - Bank Expense Entry'),
('Vendor', 'Vendor');

--
-- Master table values for CreditBureauReportValueMaster
--
DELETE FROM CreditBureauReportValueMaster;
INSERT INTO CreditBureauReportValueMaster(value) VALUES
('Medium'),                                 
('Low'),     
('Very Low'),                                
('Very High'),
('High'),                              
('No Match');                 

SELECT @entityDocTypeId := id FROM DocumentTypeMaster WHERE name = 'Entity';
SELECT @entityProofDocTypeId := id FROM DocumentTypeMaster WHERE name = 'EntityIdentityProof';
SELECT @accountDocTypeId := id FROM DocumentTypeMaster WHERE name = 'Account';
SELECT @entityBankAccountDocTypeId := id FROM DocumentTypeMaster WHERE name = 'EntityBankAccount';
SELECT @pipelineDocTypeId := id FROM DocumentTypeMaster WHERE name = 'Pipeline';
SELECT @pipelineInfoDocTypeId := id FROM DocumentTypeMaster WHERE name = 'PipelineInfo';
SELECT @surveyDocTypeId := id FROM DocumentTypeMaster WHERE name = 'Survey';
SELECT @fundingSourceDocTypeId := id FROM DocumentTypeMaster WHERE name = 'FundingSource';
SELECT @employeeDocTypeId := id FROM DocumentTypeMaster WHERE name = 'Employee';
SELECT @bankAccountReconDocTypeId := id FROM DocumentTypeMaster WHERE name = 'BankAccountRecon';
SELECT @vehicleCollateralDocTypeId := id FROM DocumentTypeMaster WHERE name = 'VehicleCollateral';
SELECT @documentTemplateDocTypeId := id FROM DocumentTypeMaster WHERE name = 'DocumentTemplate';
SELECT @paymentGroupDocTypeId := id FROM DocumentTypeMaster WHERE name = 'PaymentGroup';
SELECT @thirdpartyResponseDocTypeId := id FROM DocumentTypeMaster WHERE name = 'ThirdpartyResponse';
SELECT @awsRekognitionResponseDocTypeId := id FROM DocumentTypeMaster WHERE name = 'AwsRekognitionResponse';
SELECT @kotakInsuranceResponseDocTypeId := id FROM DocumentTypeMaster WHERE name = 'KotakInsuranceResponse';
SELECT @twinlineResponseDocTypeId := id FROM DocumentTypeMaster WHERE name = 'TwinlineResponse';
SELECT @upiPayRequestResponseDocTypeId := id FROM DocumentTypeMaster WHERE name = 'UpiPayRequestResponse';
SELECT @employmentDocTypeId := id FROM DocumentTypeMaster WHERE name = 'Employment';
SELECT @propertyCollateralDocTypeId := id FROM DocumentTypeMaster WHERE name = 'PropertyCollateral';
SELECT @propertyDeedCollateralDocTypeId := id FROM DocumentTypeMaster WHERE name = 'PropertyDeedCollateral';

--
-- Master table values for DocumentMaster
--
INSERT INTO DocumentMaster(type_id, name, effective_date, min_no_of_pages, max_no_of_pages, is_front_back_format, allow_reuse,system_defined) VALUES 
(@entityDocTypeId , 'Photo', 20100101, 1, 1, 0,0,1),
(@entityDocTypeId , 'None', 20100101, 1, 1, 0,0,1),
(@entityDocTypeId , 'Cheque', 20100101, 1, 1, 0,0,1),
(@entityDocTypeId , 'Others', 20100101, 1, 1, 0,0,1),
(@entityDocTypeId , 'KYC DOCUMENT', 20100101, 1, 1, 0,0,1),
(@entityDocTypeId , 'Aadhaar_Photo', 20100101, 2, 2, 0,0,1),
(@entityDocTypeId , 'Nominee Photo', 20100101, 1, 1, 0,0,1),
(@entityDocTypeId , 'House_Photo', 20100101, 1, 1, 0,0,1),
(@entityDocTypeId , 'Digital Consent', 20100101, 1, 1, 0,0,1),
(@entityDocTypeId , 'Paper Consent Moratorium 3', 20100101, 1, 1, 0,0,1),
(@entityDocTypeId , 'Paper Consent Restructured', 20100101, 1, 1, 0,0,1),
(@entityDocTypeId , 'Paper Consent', 20100101, 1, 1, 0,0,1),
(@entityDocTypeId , 'Credit Bureau Request Document', 20100101, 1, 1, 0,0,1),
(@entityDocTypeId , 'ECS Mandate', 20100101, 1, 1, 0,0,1),
(@entityDocTypeId , 'Guarantor Photo', 20100101, 1, 1, 0,0,1),
(@entityDocTypeId , 'College Graduate', 20100101, 1, 1, 0,0,1),
(@entityDocTypeId , 'Primary Education', 20100101, 1, 1, 0,0,1),
(@entityDocTypeId , 'Secondary Education', 20100101, 1, 1, 0,0,1),
(@entityDocTypeId , 'Verification Photo', 20100101, 1, 1, 0,0,1),
(@entityDocTypeId , 'Customer Signature', 20100101, 1, 1, 0,0,1),
(@entityDocTypeId , 'Guarantor Signature', 20100101, 1, 1, 0,0,1),
(@entityDocTypeId , 'Customer Signature Photo', 20100101, 1, 1, 0,0,1),
(@entityDocTypeId , 'Guarantor Signature Photo', 20100101, 1, 1, 0,0,1),
(@accountDocTypeId , 'Indemnity Form', 20100101, 1, 1, 0,0,1),
(@accountDocTypeId , 'Photo', 20100101, 1, 1, 0,0,1),
(@accountDocTypeId , 'Cheque', 20100101, 1, 1, 0,0,1),
(@accountDocTypeId , 'Automated Digitial Consent Letter', 20100101, 1, 1, 0,0,1),
(@accountDocTypeId , 'Others', 20100101, 1, 1, 0,0,1),
(@accountDocTypeId , 'Picture of Collateral', 20100101, 1, 1, 0,0,1),
(@accountDocTypeId , 'KYC Document', 20100101, 1, 1, 0,0,1),
(@accountDocTypeId , 'ECS Mandate', 20100101, 1, 1, 0,0,1),
(@accountDocTypeId , 'LUC Document', 20100101, 1, 1, 0,0,1),
(@accountDocTypeId , 'Pledge Card Photo', 20100101, 1, 1, 0,0,1),
(@accountDocTypeId , 'Disbursement Photo', 20100101, 1, 1, 0,0,1),
(@pipelineDocTypeId , 'Another MFI', 20100101, 1, 1, 0,0,1),
(@pipelineDocTypeId , 'Bank', 20100101, 1, 1, 0,0,1),
(@pipelineDocTypeId , 'Informal sources', 20100101, 1, 1, 0,0,1),
(@employeeDocTypeId , 'Employee Photo', 20100101, 1, 1, 0,0,1),
(@employeeDocTypeId , 'Verification Photo', 20100101, 1, 1, 0,0,1),
(@documentTemplateDocTypeId , 'Document Template', 20100101, 1, 1, 0,0,1),
(@documentTemplateDocTypeId , 'Hard Copy Consent Letter', 20100101, 1, 1, 0,0,1),
(@documentTemplateDocTypeId , 'Hard Copy Consent Letter 3', 20100101, 1, 1, 0,0,1),
(@documentTemplateDocTypeId , 'Automated Digital Consent Letter Template', 20100101, 1, 1, 0,0,1),
(@documentTemplateDocTypeId , 'Hard Copy Restructured Consent Letter', 20100101, 1, 1, 0,0,1),
(@awsRekognitionResponseDocTypeId , 'Add Faces To Collection', 20100101, 1, 1, 0,0,1),
(@awsRekognitionResponseDocTypeId , 'Delete Faces From Collection', 20100101, 1, 1, 0,0,1),
(@awsRekognitionResponseDocTypeId , 'Detect Faces Within Image', 20100101, 1, 1, 0,0,1),
(@awsRekognitionResponseDocTypeId , 'Search Collection Using Image', 20100101, 1, 1, 0,0,1),
(@awsRekognitionResponseDocTypeId , 'Compare Faces', 20100101, 1, 1, 0,0,1),
(@kotakInsuranceResponseDocTypeId , 'Calc Premium Document', 20100101, 1, 1, 0,0,1),
(@kotakInsuranceResponseDocTypeId , 'COI Document', 20100101, 1, 1, 0,0,1),
(@kotakInsuranceResponseDocTypeId , 'Send Application Document', 20100101, 1, 1, 0,0,1),
(@thirdpartyResponseDocTypeId , 'Fingpay', 20100101, 1, 1, 0,0,1),
(@twinlineResponseDocTypeId , 'Callback Response Document', 20100101, 1, 1, 0,0,1),
(@twinlineResponseDocTypeId , 'QR Code Document', 20100101, 1, 1, 0,0,1),
(@twinlineResponseDocTypeId , 'SMS Request Document', 20100101, 1, 1, 0,0,1),
(@twinlineResponseDocTypeId , 'Unsync Response Document', 20100101, 1, 1, 0,0,1),
(@paymentGroupDocTypeId , 'Payment Group Photo', 20100101, 1, 1, 0,0,1),
(@upiPayRequestResponseDocTypeId , 'Check Transaction Status', 20100101, 1, 1, 0,0,1),
(@upiPayRequestResponseDocTypeId , 'Single Collect', 20100101, 1, 1, 0,0,1),
(@upiPayRequestResponseDocTypeId , 'Callback', 20100101, 1, 1, 0,0,1),
(@upiPayRequestResponseDocTypeId , 'QR Code', 20100101, 1, 1, 0,0,1),
(@upiPayRequestResponseDocTypeId , 'Validate VPA', 20100101, 1, 1, 0,0,1),
(@upiPayRequestResponseDocTypeId , 'Channel Partner Login', 20100101, 1, 1, 0,0,1),
(@upiPayRequestResponseDocTypeId , 'Generate Auth Token', 20100101, 1, 1, 0,0,1),
(@upiPayRequestResponseDocTypeId , 'Get Txn ID', 20100101, 1, 1, 0,0,1),
(@upiPayRequestResponseDocTypeId , 'Collect Money', 20100101, 1, 1, 0,0,1),
(@upiPayRequestResponseDocTypeId , 'Transaction Re Query', 20100101, 1, 1, 0,0,1);

--
-- Master table values for CreditBureauReportValueMaster
--
SELECT @groupLoanCatId := id FROM LoanCategoryMaster WHERE name='Group Loan';
DELETE FROM LoanPipelineTypeMaster;
INSERT INTO LoanPipelineTypeMaster(name,abbr,loan_category_id) VALUES
('Regular','Regular',@groupLoanCatId);

--
-- Master table values for CreditBureauCheck
--
SELECT @loanOriginationId := id FROM BusinessLogicMaster WHERE name = 'Loan Origination' and type_id=@loanProcessCategoryId;
SELECT @loanApprovalId := id FROM BusinessLogicMaster WHERE name = 'Loan Approval' and type_id=@loanProcessCategoryId;
SELECT @loanScheduleId := id FROM BusinessLogicMaster WHERE name = 'Loan Scheduling' and type_id=@loanProcessCategoryId;
SELECT @loanDisbursmentId := id FROM BusinessLogicMaster WHERE name = 'Loan Disbursement' and type_id=@loanProcessCategoryId;
SELECT @loanDisbursmentId := id FROM BusinessLogicMaster WHERE name = 'Loan Disbursement' and type_id=@loanProcessCategoryId;
SELECT @attachCustomerGroupId := id FROM BusinessLogicMaster WHERE name = 'Attach Customer Group' and type_id=@customerProcessCategoryId;

DELETE FROM CreditBureauCheck;
INSERT INTO CreditBureauCheck(check_action_id) VALUES (@loanOriginationId);
INSERT INTO CreditBureauCheck(check_action_id) VALUES (@loanApprovalId);
INSERT INTO CreditBureauCheck(check_action_id) VALUES (@loanScheduleId);
INSERT INTO CreditBureauCheck(check_action_id) VALUES (@loanDisbursmentId);
INSERT INTO CreditBureauCheck(check_action_id) VALUES (@attachCustomerGroupId);

--
-- Master table values for AppEventMaster
--
SELECT @loanPaymentEventId := id FROM AppEventMaster WHERE name = 'Loan Payment';
SELECT @loanDisbEventId := id FROM AppEventMaster WHERE name = 'Loan Disbursement';
SELECT @loanApprovalEventId := id FROM AppEventMaster WHERE name = 'Loan Approval';
SELECT @loanOpeningEventId := id FROM AppEventMaster WHERE name = 'Loan Opening';
SELECT @loanApproveSchdEventId := id FROM AppEventMaster WHERE name = 'Loan Approval + Scheduling';
DELETE FROM ValidationTypeMaster;
INSERT INTO ValidationTypeMaster(app_event_id, name, description) VALUES
(@loanPaymentEventId,'Futute Payment Check','Future payments available check in value-dated payment posting.'),
(@loanPaymentEventId,'Futute Waiver Check','You cannot make a value-dated payment for this date because demand waived on a later date'),
(@loanDisbEventId,'Consument Durable Product Check','Disbursed Inventory not available in this branch and product; No Inventory for this branch and product to disburse. Please check with HO team, then do disbursement.'),
(@loanApprovalEventId,'Active Pipeline Check','There is no active pipeline available for this center and pipeline type.'),
(@loanOpeningEventId,'Document Mandatory Validation','Customer documents should be uploaded.'),
(@loanApprovalEventId,'Primary Bank Account Maker Checker Completed','Primary Bank Account for this customer not yet checked. Use "Maker-Checker for Customer Primary Bank Account Details" to check.'),
(@loanApprovalEventId,'S1 Mandatory Check','S1 Mandatory Check'),
(@loanApproveSchdEventId,'Maximum Officer Meeting Check','Relationship officer has X meetings already for the following dates'),
(@loanApproveSchdEventId,'Bank Account Office Check',"Bank Account Office does not have GL Office;Bank Account Office does not belongs to this loan's office;Bank Account does not have GL Account Entry."),
(@loanDisbEventId,'Document Mandatory Validation','Customer documents should be uploaded.');
(@loanPaymentEventId,'Payment Group Stationery Check','Payment Group Stationery Check During Single Loan Payment');
