package com.bankaudit.rest.process.service;

import java.time.LocalDate;
import java.util.List;

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.DataTableResponse;
import com.bankaudit.rest.process.dao.AuditReportAllocationDao;
import com.bankaudit.service.BusinessDateService;
import com.bankaudit.util.BankAuditUtil;

@Service("auditReportAllocationService")
@Transactional("transactionManager")
public class AuditReportAllocationServiceImpl implements AuditReportAllocationService {
	
	@Autowired(required=true)
	AuditReportAllocationDao auditReportAllocationDao;
	
	@Autowired
	BusinessDateService businessDateService;
	
	static final Logger logger = Logger.getLogger(AuditReportAllocationServiceImpl.class);

	@Override
	public DataTableResponse getAllocationAudits(int legalEntityCode, String userId, String roleId, String search, Integer orderColumn,
			String orderDirection, Integer page, Integer size, LocalDate financialYear, String auditTypeCode) {
		List<LocalDate>  financialYearStrtEndList=null;
		if(financialYear!=null) financialYearStrtEndList= BankAuditUtil.getFinancialStartEndDatesNxtFrom(financialYear);
		DataTableResponse ds=auditReportAllocationDao.getAllocationAudits(legalEntityCode,userId, roleId, search,orderColumn,orderDirection,page,size,
				financialYear, auditTypeCode, financialYearStrtEndList);
		return ds;
	}

}
