package com.bankaudit.rest.process.service;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.jboss.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.bankaudit.dto.process.ComplianceTrackingReportDto;
import com.bankaudit.dto.process.LettersAuditDto;
import com.bankaudit.dto.process.RatingFinancialParameterDto;
import com.bankaudit.dto.process.ReportDto;
import com.bankaudit.dto.process.ReportMISDto;
import com.bankaudit.rest.process.dao.DashboardDaoImpl;
import com.bankaudit.rest.process.dao.ReportDao;
import com.bankaudit.service.MaintEntityService;
import com.bankaudit.util.BankAuditUtil;

@Service
@Transactional("transactionManager")
public class ReportServiceImpl implements ReportService {
	
	@Autowired
	ReportDao reportDao;
	
	@Autowired
	MaintEntityService maintEntityService;
	
	static final Logger logger = Logger.getLogger(DashboardDaoImpl.class);
	
	@Override
	public List<List<ReportDto>> getListofRisks(int legalEntityCodeStr, String userId,String unitId, String role,LocalDate asOfDate, String reportType) {
		boolean isDeptAsRMD =false;
		List<String> deptList = null;
		List<String> unitList = null;
		List<String> assessmentList = null;
		List<ReportDto> risksList = null;
		List<ReportDto> reportDto= null;
		List<List<ReportDto>> listRiskUnitUserDtls =null;
		try {
			//String unitId="";
			unitList = new ArrayList();
			logger.info("SrvcImpl getListofRisks legalEntityCodeStr.. "+ legalEntityCodeStr +" userId.."+ userId +" role.. "+ role + " asOfDate .. "+asOfDate + " reportType .."+reportType);
			if("G2".equalsIgnoreCase(role) || "G8".equalsIgnoreCase(role) || "Assessor".equalsIgnoreCase(role) ) {   // Particular Unit + Dept --> RMD (No), (Dept1, Dept2,...)
				isDeptAsRMD = reportDao.isDeptAsRMD(legalEntityCodeStr, role, userId); 
				if(!isDeptAsRMD) 
					deptList =reportDao.getDeptList(legalEntityCodeStr, role, userId);
				unitList.add(unitId);
			}else if("G3".equalsIgnoreCase(role) || "Auditor".equalsIgnoreCase(role) ) {  // Particular Unit + No Department
				isDeptAsRMD = true; // for Auditor, he is allowed to see/access all the Dept data
				unitList.add(unitId);
			}else if("G4".equalsIgnoreCase(role) || "G7".equalsIgnoreCase(role) || "Advisor".equalsIgnoreCase(role) || "Lead Advisor".equalsIgnoreCase(role)) { // Particular Unit + Dept --> RMD (No), (Dept1, Dept2,...)
				isDeptAsRMD = reportDao.isDeptAsRMD(legalEntityCodeStr, role, userId);
				if(!isDeptAsRMD) 
					deptList =reportDao.getDeptList(legalEntityCodeStr, role, userId);
				unitList.add(unitId);
			}else if("G1".equalsIgnoreCase(role) || "Operations".equalsIgnoreCase(role) ) { // Unit (HO + RO)  + Dept --> RMD
				isDeptAsRMD = reportDao.isDeptAsRMD(legalEntityCodeStr, role, userId);
				if(!isDeptAsRMD) 
					deptList =reportDao.getDeptList(legalEntityCodeStr, role, userId);
				unitList = getUnitList(legalEntityCodeStr, role, "user", userId);
			}else if("G6".equalsIgnoreCase(role) || "Management".equalsIgnoreCase(role) ) { // Unit (HO + RO)  + Dept --> RMD
				isDeptAsRMD = reportDao.isDeptAsRMD(legalEntityCodeStr, role, userId);
				if(!isDeptAsRMD) 
					deptList =reportDao.getDeptList(legalEntityCodeStr, role, userId);
				unitList = getUnitList(legalEntityCodeStr, role, "user", userId);
			}else {
				isDeptAsRMD = reportDao.isDeptAsRMD(legalEntityCodeStr, role, userId);
				if(!isDeptAsRMD) 
					deptList =reportDao.getDeptList(legalEntityCodeStr, role, userId);
				unitList = getUnitList(legalEntityCodeStr, role, "user", userId);
			}
			logger.info(" deptList .."+ deptList);
			logger.info(" unitList .."+ unitList);
			assessmentList = reportDao.getAssessmentList(legalEntityCodeStr, role, userId, asOfDate, isDeptAsRMD, deptList, unitList);
			risksList = reportDao.getListofRisks( legalEntityCodeStr,  userId,  role, asOfDate,  reportType,assessmentList);
			
			reportDto = reportDao.getUnitNameAddressUserName (legalEntityCodeStr, userId, unitId);
			listRiskUnitUserDtls = new ArrayList<List<ReportDto>>();
			listRiskUnitUserDtls.add(reportDto);
			listRiskUnitUserDtls.add(risksList);
			logger.info(" listRiskUnitUserDtls .."+ listRiskUnitUserDtls);
		}catch(Exception e) {
			e.printStackTrace(System.out);
		}
		return listRiskUnitUserDtls;
	}
	
	@Override
	public List<List<ReportDto>> getHealthIndexforRCSAUnits(int legalEntityCodeStr, String userId, String unitId, String role,LocalDate asOfDate, String reportType) {
		boolean isDeptAsRMD =false;
		List<String> deptList = null;
		List<String> unitList = null;
		List<String> assessmentList = null;
		List<ReportDto> healthIdexRCSAUnitsList = null;
		List<ReportDto> reportDto= null;
		List<List<ReportDto>> healthIdexRCSAUnitsListUnitUserDtls =null;
		try {
			unitList = new ArrayList();
			//String unitId="";
			/*logger.info("SrvcImpl getHealthIndexforRCSAUnits legalEntityCodeStr.. "+ legalEntityCodeStr +" userId.."+ userId +" role.. "+ role + " asOfDate .. "+asOfDate + " reportType .."+reportType);
			isDeptAsRMD = reportDao.isDeptAsRMD(legalEntityCodeStr, role, userId);
			if(!isDeptAsRMD) 
				deptList =reportDao.getDeptList(legalEntityCodeStr, role, userId);
			logger.info(" deptList .."+ deptList);
			unitList = getUnitList(legalEntityCodeStr, role, "user", userId);
			*/
			if("G2".equalsIgnoreCase(role) || "G8".equalsIgnoreCase(role) || "Assessor".equalsIgnoreCase(role) ) {   // Particular Unit + Dept --> RMD (No), (Dept1, Dept2,...)
				isDeptAsRMD = reportDao.isDeptAsRMD(legalEntityCodeStr, role, userId); 
				if(!isDeptAsRMD) 
					deptList =reportDao.getDeptList(legalEntityCodeStr, role, userId);
				unitList.add(unitId);
			}else if("G3".equalsIgnoreCase(role) || "Auditor".equalsIgnoreCase(role) ) {  // Particular Unit + No Department
				isDeptAsRMD = true; // for Auditor, he is allowed to see/access all the Dept data
				unitList.add(unitId);
			}else if("G4".equalsIgnoreCase(role) || "G7".equalsIgnoreCase(role) || "Advisor".equalsIgnoreCase(role) || "Lead Advisor".equalsIgnoreCase(role)) { // Particular Unit + Dept --> RMD (No), (Dept1, Dept2,...)
				isDeptAsRMD = reportDao.isDeptAsRMD(legalEntityCodeStr, role, userId);
				if(!isDeptAsRMD) 
					deptList =reportDao.getDeptList(legalEntityCodeStr, role, userId);
				unitList.add(unitId);
			}else if("G1".equalsIgnoreCase(role) || "Operations".equalsIgnoreCase(role) ) { // Unit (HO + RO)  + Dept --> RMD
				isDeptAsRMD = reportDao.isDeptAsRMD(legalEntityCodeStr, role, userId);
				if(!isDeptAsRMD) 
					deptList =reportDao.getDeptList(legalEntityCodeStr, role, userId);
				unitList = getUnitList(legalEntityCodeStr, role, "user", userId);
			}else if("G6".equalsIgnoreCase(role) || "Management".equalsIgnoreCase(role) ) { // Unit (HO + RO)  + Dept --> RMD
				isDeptAsRMD = reportDao.isDeptAsRMD(legalEntityCodeStr, role, userId);
				if(!isDeptAsRMD) 
					deptList =reportDao.getDeptList(legalEntityCodeStr, role, userId);
				unitList = getUnitList(legalEntityCodeStr, role, "user", userId);
			}else {
				isDeptAsRMD = reportDao.isDeptAsRMD(legalEntityCodeStr, role, userId);
				if(!isDeptAsRMD) 
					deptList =reportDao.getDeptList(legalEntityCodeStr, role, userId);
				unitList = getUnitList(legalEntityCodeStr, role, "user", userId);
			}
			logger.info(" deptList .."+ deptList);
			logger.info(" unitList .."+ unitList);
			assessmentList = reportDao.getAssessmentList(legalEntityCodeStr, role, userId, asOfDate, isDeptAsRMD, deptList, unitList);
			healthIdexRCSAUnitsList =reportDao.getHealthIndexforRCSAUnits( legalEntityCodeStr,  userId,  role, asOfDate,  reportType,assessmentList);
			reportDto = reportDao.getUnitNameAddressUserName (legalEntityCodeStr, userId, unitId);
			
			healthIdexRCSAUnitsListUnitUserDtls = new ArrayList<List<ReportDto>>();
			healthIdexRCSAUnitsListUnitUserDtls.add(reportDto);
			healthIdexRCSAUnitsListUnitUserDtls.add(healthIdexRCSAUnitsList);
			logger.info(" healthIdexRCSAUnitsListUnitUserDtls .."+ healthIdexRCSAUnitsListUnitUserDtls);
			
		}catch(Exception e) {
			e.printStackTrace(System.out);
		}
		return healthIdexRCSAUnitsListUnitUserDtls;
	}
	
	@Override
	public List<List<ReportDto>> getRCSAProgressStatus(int legalEntityCodeStr, String userId, String unitId, String role, LocalDate asOfDate, String reportType) {
		boolean isDeptAsRMD =false;
		List<String> deptList = null;
		List<String> unitList = null;
		List<String> assessmentList = null;
		List<ReportDto> rCSAProgressUnitsList = null;
		List<ReportDto> reportDto= null;
		List<List<ReportDto>> rCSAProgressDtls =null;
		try {
			unitList = new ArrayList();
			logger.info("Inside getRCSAProgressStatus "+ userId +" :: "+ unitId+" :: "+role +" :: "+asOfDate +" :: "+reportType);
			//String unitId="";
			/*logger.info("SrvcImpl getHealthIndexforRCSAUnits legalEntityCodeStr.. "+ legalEntityCodeStr +" userId.."+ userId +" role.. "+ role + " asOfDate .. "+asOfDate + " reportType .."+reportType);
			isDeptAsRMD = reportDao.isDeptAsRMD(legalEntityCodeStr, role, userId);
			if(!isDeptAsRMD) 
				deptList =reportDao.getDeptList(legalEntityCodeStr, role, userId);
			logger.info(" deptList .."+ deptList);
			unitList = getUnitList(legalEntityCodeStr, role, "user", userId);
			*/
			if("G2".equalsIgnoreCase(role) || "G8".equalsIgnoreCase(role) || "Assessor".equalsIgnoreCase(role) ) {   // Particular Unit + Dept --> RMD (No), (Dept1, Dept2,...)
				isDeptAsRMD = reportDao.isDeptAsRMD(legalEntityCodeStr, role, userId); 
				if(!isDeptAsRMD) 
					deptList =reportDao.getDeptList(legalEntityCodeStr, role, userId);
				unitList.add(unitId);
			}else if("G3".equalsIgnoreCase(role) || "Auditor".equalsIgnoreCase(role) ) {  // Particular Unit + No Department
				isDeptAsRMD = true; // for Auditor, he is allowed to see/access all the Dept data
				unitList.add(unitId);
			}else if("G4".equalsIgnoreCase(role) || "G7".equalsIgnoreCase(role) || "Advisor".equalsIgnoreCase(role) || "Lead Advisor".equalsIgnoreCase(role)) { // Particular Unit + Dept --> RMD (No), (Dept1, Dept2,...)
				isDeptAsRMD = reportDao.isDeptAsRMD(legalEntityCodeStr, role, userId);
				if(!isDeptAsRMD) 
					deptList =reportDao.getDeptList(legalEntityCodeStr, role, userId);
				unitList.add(unitId);
			}else if("G1".equalsIgnoreCase(role) || "Operations".equalsIgnoreCase(role) ) { // Unit (HO + RO)  + Dept --> RMD
				isDeptAsRMD = reportDao.isDeptAsRMD(legalEntityCodeStr, role, userId);
				if(!isDeptAsRMD) 
					deptList =reportDao.getDeptList(legalEntityCodeStr, role, userId);
				unitList = getUnitList(legalEntityCodeStr, role, "user", userId);
			}else if("G6".equalsIgnoreCase(role) || "Management".equalsIgnoreCase(role) ) { // Unit (HO + RO)  + Dept --> RMD
				isDeptAsRMD = reportDao.isDeptAsRMD(legalEntityCodeStr, role, userId);
				if(!isDeptAsRMD) 
					deptList =reportDao.getDeptList(legalEntityCodeStr, role, userId);
				unitList = getUnitList(legalEntityCodeStr, role, "user", userId);
			}else {
				isDeptAsRMD = reportDao.isDeptAsRMD(legalEntityCodeStr, role, userId);
				if(!isDeptAsRMD) 
					deptList =reportDao.getDeptList(legalEntityCodeStr, role, userId);
				unitList = getUnitList(legalEntityCodeStr, role, "user", userId);
			}
			logger.info(" deptList .."+ deptList);
			logger.info(" unitList .."+ unitList);
			Map<String, LocalDate> finYrDateMap= BankAuditUtil.getFinancialYearDates(null);
			assessmentList = reportDao.getAssessmentList(legalEntityCodeStr, role, userId, asOfDate, isDeptAsRMD, deptList, unitList);
			rCSAProgressUnitsList =reportDao.getRCSAProgressStatus( legalEntityCodeStr,  userId,  role, asOfDate,  reportType,assessmentList, finYrDateMap.get("FIN_YR_START_DATE"), finYrDateMap.get("FIN_YR_END_DATE"));
			reportDto = reportDao.getUnitNameAddressUserName(legalEntityCodeStr, userId, unitId);
			
			rCSAProgressDtls = new ArrayList<List<ReportDto>>();
			rCSAProgressDtls.add(reportDto);
			rCSAProgressDtls.add(rCSAProgressUnitsList);
			logger.info(" healthIdexRCSAUnitsListUnitUserDtls .."+ rCSAProgressDtls);
			
		}catch(Exception e) {
			e.printStackTrace(System.out);
		}
		return rCSAProgressDtls;
	}
	
	private List<String> getUnitList(Integer legalEntityCode ,String role, String type,String userIdOrUnitId ){
		logger.info("userIdOrUnitId ::"+userIdOrUnitId+" type::"+type);
		List<String> maintEntities=maintEntityService.getSubBranchesGyUserIdOrUnitId(legalEntityCode,type,userIdOrUnitId);
		return  maintEntities;
	}

	public String updateDynamicStatements(int legalEntityCode, String auditId, String auditTypeCode, String statementId){
		return reportDao.updateDynamicStatements(legalEntityCode, auditId, auditTypeCode, statementId);
	}

	@Override
	public List<Date> getFinancialYearList(String legalEntityCode) {
		return reportDao.getFinancialYearEndDate(Integer.parseInt(legalEntityCode));
	}

	@Override
	public List<ComplianceTrackingReportDto> getComplianceTrackingReport(Integer legalEntityCode, String userId, LocalDate financialYear, String auditTypeCode) {
		logger.info("Inside getComplianceTrackingReport srvcImpl .. "+ userId+" :: "+financialYear+" :: "+auditTypeCode);
		List<String> unitList =  maintEntityService.getSubBranchesGyUserIdOrUnitId(legalEntityCode,"user",userId);
		List<LocalDate>  financialYearList = BankAuditUtil.getFinancialStartEndDatesFrom(financialYear);
		List<String> auditList = reportDao.getAuditScheduleUnitIdsList(legalEntityCode, unitList,financialYear, auditTypeCode, financialYearList);
		if(auditList!= null && !auditList.isEmpty()) {
			return reportDao.getAuditScheduleReportList(legalEntityCode, auditList, financialYear, auditTypeCode, financialYearList);
		}
		return Collections.emptyList();
	}
	
	@Override
	public List<RatingFinancialParameterDto> getAuditRatingList(Integer legalEntityCode, String userId, LocalDate financialYear, String auditTypeCode){
		List<String> unitList =  maintEntityService.getSubBranchesGyUserIdOrUnitId(legalEntityCode,"user",userId); 
		List<LocalDate>  financialYearList = BankAuditUtil.getFinancialStartEndDatesFrom(financialYear);
		return reportDao.getAuditRatingList(legalEntityCode, unitList, financialYear, auditTypeCode, financialYearList);
	}
	
	@Override
	public List<RatingFinancialParameterDto> getAuditFinancialParameterList(Integer legalEntityCode, String userId, LocalDate financialYear, String auditTypeCode){
		List<String> unitList =  maintEntityService.getSubBranchesGyUserIdOrUnitId(legalEntityCode,"user",userId); 
		List<LocalDate>  financialYearList = BankAuditUtil.getFinancialStartEndDatesFrom(financialYear);
		return reportDao.getAuditFinancialParameterList(legalEntityCode, unitList, financialYear, auditTypeCode, financialYearList);
	}
	
	@Override
	public List<LettersAuditDto> getAuditDetail(Integer legalEntityCode, String userId, LocalDate financialYear, String auditTypeCode) {
		List<String> unitList =  maintEntityService.getSubBranchesGyUserIdOrUnitId(legalEntityCode,"user",userId); 
		List<LocalDate>  financialYearList = BankAuditUtil.getFinancialStartEndDatesFrom(financialYear);
		return reportDao.getAuditDetail(legalEntityCode, financialYear, auditTypeCode, unitList, financialYearList);
	}
	
	@Override
	public List<LettersAuditDto> getLettersDetail(Integer legalEntityCode, String userId, LocalDate financialYear, String auditTypeCode ){
		List<String> unitList =  maintEntityService.getSubBranchesGyUserIdOrUnitId(legalEntityCode,"user",userId); 
		List<LocalDate>  financialYearList = BankAuditUtil.getFinancialStartEndDatesFrom(financialYear);
		return reportDao.getLettersDetail(legalEntityCode, financialYear, auditTypeCode, unitList, financialYearList);
	}

	private List<LocalDate> getFinancialYearDates(LocalDate financialYear){ 		
		LocalDate financialYearStartDt = LocalDate.parse((financialYear.getYear())+"-04-01");
		LocalDate financialYearEndDt = LocalDate.parse((financialYear.getYear()+1)+"-03-31");

		List<LocalDate>  financialYearList = new ArrayList<>();
		financialYearList.add(financialYearStartDt);
		financialYearList.add(financialYearEndDt);
		return financialYearList;
	}
	
	/********************Start MIS Reports ***********************/

	@Override
	public List<ReportMISDto> reportStatusFinalisationDateMISReport(Integer legalEntityCode, String userId, LocalDate financialYear, String auditTypeCode) {
		logger.info("Inside reportStatusFinalisationDateReport srvcImpl .. "+ userId+" :: "+financialYear+" :: "+auditTypeCode);
		List<String> unitList =  maintEntityService.getSubBranchesGyUserIdOrUnitId(legalEntityCode,"user",userId);
		List<LocalDate>  financialYearList = BankAuditUtil.getFinancialStartEndDatesNxtFrom(financialYear); 		 
		return reportDao.reportStatusFinalisationDateMISReport(legalEntityCode, auditTypeCode, financialYear, financialYearList, unitList);	  
	}
	
	@Override
	public List<ReportMISDto> auditStatusMISReport(Integer legalEntityCode, String userId, LocalDate financialYear, String auditTypeCode) {
		logger.info("Inside auditStatusReport srvcImpl .. "+ userId+" :: "+financialYear+" :: "+auditTypeCode);
		List<String> unitList =  maintEntityService.getSubBranchesGyUserIdOrUnitId(legalEntityCode,"user",userId);
		List<LocalDate>  financialYearList = BankAuditUtil.getFinancialStartEndDatesNxtFrom(financialYear); 		 
		return reportDao.auditStatusMISReport(legalEntityCode, auditTypeCode, financialYear, financialYearList, unitList);	  
	}
	
	@Override
	public List<ReportMISDto> complianceStatusMISReport(Integer legalEntityCode, String userId, LocalDate financialYear, String auditTypeCode) {
		logger.info("Inside complianceStatusReport srvcImpl .. "+ userId+" :: "+financialYear+" :: "+auditTypeCode);
		List<String> unitList =  maintEntityService.getSubBranchesGyUserIdOrUnitId(legalEntityCode,"user",userId);
		List<LocalDate>  financialYearList = BankAuditUtil.getFinancialStartEndDatesNxtFrom(financialYear); 		 
		return reportDao.complianceStatusMISReport(legalEntityCode, auditTypeCode, financialYear, financialYearList, unitList);	  
	}
	
	@Override
	public List<ReportMISDto> supervisoryRatingMISReport(Integer legalEntityCode, String userId, LocalDate financialYear, String auditTypeCode){
		logger.info("Inside supervisoryRatingMISReport srvcImpl .. "+ userId+" :: "+financialYear+" :: "+auditTypeCode);
		List<String> unitList =  maintEntityService.getSubBranchesGyUserIdOrUnitId(legalEntityCode,"user",userId);
		List<LocalDate>  financialYearList = BankAuditUtil.getFinancialStartEndDatesNxtFrom(financialYear); 		 
		return reportDao.supervisoryRatingMISReport(legalEntityCode, auditTypeCode, financialYear, financialYearList, unitList);	
	}
	
	@Override
	public List<ReportMISDto> supervisoryRating3YearsMISReport(Integer legalEntityCode, String userId, LocalDate financialYear, String auditTypeCode){
		logger.info("Inside supervisoryRating3YearsMISReport srvcImpl .. "+ userId+" :: "+financialYear+" :: "+auditTypeCode);
		List<String> unitList =  maintEntityService.getSubBranchesGyUserIdOrUnitId(legalEntityCode,"user",userId);
		List<LocalDate>  financialYearList = BankAuditUtil.getFinancialStartEndDatesNxtFrom(financialYear); 		 
		return reportDao.supervisoryRating3YearsMISReport(legalEntityCode, auditTypeCode, financialYear, financialYearList, unitList);	
	}
	
	@Override
	public List<ReportMISDto> lettersMISReport(Integer legalEntityCode, String userId, LocalDate financialYear, String auditTypeCode){
		logger.info("Inside lettersMISReport srvcImpl .. "+ userId+" :: "+financialYear+" :: "+auditTypeCode);
		List<String> unitList =  maintEntityService.getSubBranchesGyUserIdOrUnitId(legalEntityCode,"user",userId);
		List<LocalDate>  financialYearList = BankAuditUtil.getFinancialStartEndDatesFrom(financialYear); 		 
		return reportDao.lettersMISReport(legalEntityCode, auditTypeCode, financialYear, financialYearList, unitList);	
	}
	
	@Override
	public List<ReportMISDto> qsoGradingMISReport(Integer legalEntityCode, String userId, LocalDate financialYear, String auditTypeCode){
		logger.info("Inside qsoGradingMISReport srvcImpl .. "+ userId+" :: "+financialYear+" :: "+auditTypeCode);
		List<String> unitList =  maintEntityService.getSubBranchesGyUserIdOrUnitId(legalEntityCode,"user",userId);
		List<LocalDate>  financialYearList = BankAuditUtil.getFinancialStartEndDatesNxtFrom(financialYear); 		 
		return reportDao.qsoGradingMISReport(legalEntityCode, auditTypeCode, financialYear, financialYearList, unitList);	
	}
	
	@Override
	public List<ReportMISDto> complianceRating3YearsMISReport(Integer legalEntityCode, String userId, LocalDate financialYear, String auditTypeCode){
		logger.info("Inside complianceRating3YearsMISReport srvcImpl .. "+ userId+" :: "+financialYear+" :: "+auditTypeCode);
		List<String> unitList =  maintEntityService.getSubBranchesGyUserIdOrUnitId(legalEntityCode,"user",userId);
		List<LocalDate>  financialYearList = BankAuditUtil.getFinancialStartEndDatesNxtFrom(financialYear); 		 
		return reportDao.complianceRating3YearsMISReport(legalEntityCode, auditTypeCode, financialYear, financialYearList, unitList);	
	}
	
	@Override
	public List<ReportMISDto> complianceRatingMISReport(Integer legalEntityCode, String userId, LocalDate financialYear, String auditTypeCode){
		logger.info("Inside complianceRatingMISReport srvcImpl .. "+ userId+" :: "+financialYear+" :: "+auditTypeCode);
		List<String> unitList =  maintEntityService.getSubBranchesGyUserIdOrUnitId(legalEntityCode,"user",userId);
		List<LocalDate>  financialYearList = BankAuditUtil.getFinancialStartEndDatesNxtFrom(financialYear); 		 
		return reportDao.complianceRatingMISReport(legalEntityCode, auditTypeCode, financialYear, financialYearList, unitList);	
	}
	/********************End MIS Reports   ***********************/
	
}
