package report_package;

import java.io.Serializable;
import java.util.ArrayList;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

import main_package.LoanInfo;

@ManagedBean(name="centerLoanReports")
@ViewScoped

public class PrintCenterWiseReportBean implements Serializable
{
	private static final long serialVersionUID = 1L;
	ArrayList<LoanInfo> list;
	int totalHolders;
	String centerName;
	double totalamount,filecharge,maturityValue;
	
	@SuppressWarnings("unchecked")
	public PrintCenterWiseReportBean()
	{
		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		list = (ArrayList<LoanInfo>) ss.getAttribute("list");
		centerName=(String) ss.getAttribute("centerName");
		totalHolders = list.size();
		double d=0.0;
		int i=0;
		
		for(LoanInfo info:list)
		{
			info.setSno(++i);
			if(info.getFileCharge().isEmpty())
			{
				d = 0.0;
			}
			else
			{
				d= Double.valueOf(info.getFileCharge());
			}
			filecharge = filecharge + d;
			totalamount = totalamount + Double.valueOf(info.getLoanAmount());
		}
	}

	public ArrayList<LoanInfo> getList() {
		return list;
	}
	public void setList(ArrayList<LoanInfo> list) {
		this.list = list;
	}
	public int getTotalHolders() {
		return totalHolders;
	}
	public void setTotalHolders(int totalHolders) {
		this.totalHolders = totalHolders;
	}
	public double getTotalamount() {
		return totalamount;
	}
	public void setTotalamount(double totalamount) {
		this.totalamount = totalamount;
	}
	public double getFilecharge() {
		return filecharge;
	}
	public void setFilecharge(double filecharge) {
		this.filecharge = filecharge;
	}
	public double getMaturityValue() {
		return maturityValue;
	}
	public void setMaturityValue(double maturityValue) {
		this.maturityValue = maturityValue;
	}
	public String getCenterName() {
		return centerName;
	}
	public void setCenterName(String centerName) {
		this.centerName = centerName;
	}
}
