package com.reallinkbilling.download;

import static java.awt.Color.WHITE;
import static org.apache.pdfbox.pdmodel.font.PDType1Font.HELVETICA;
import static org.vandeseer.easytable.settings.HorizontalAlignment.CENTER;
import static org.vandeseer.easytable.settings.HorizontalAlignment.LEFT;
import static org.vandeseer.easytable.settings.HorizontalAlignment.RIGHT;

import java.awt.Color;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.fontbox.ttf.TTFParser;
import org.apache.fontbox.ttf.TrueTypeFont;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageContentStream;
import org.apache.pdfbox.pdmodel.common.PDRectangle;
import org.apache.pdfbox.pdmodel.font.PDFont;
import org.apache.pdfbox.pdmodel.font.PDType0Font;
import org.apache.pdfbox.pdmodel.font.PDType1Font;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.dispatcher.SessionMap;
import org.apache.struts2.interceptor.SessionAware;
import org.vandeseer.easytable.TableDrawer;
import org.vandeseer.easytable.structure.Row;
import org.vandeseer.easytable.structure.Table;
import org.vandeseer.easytable.structure.Table.TableBuilder;
import org.vandeseer.easytable.structure.cell.TextCell;

import com.opensymphony.xwork2.ActionSupport;
import com.reallinkbilling.DAO.CustomerAccountDetailsDAO;
import com.reallinkbilling.cipher.EncryptionDecryption;
import com.reallinkbilling.db.GetDBConnection;

public class DownloadCustomerAccStmtReport extends ActionSupport implements SessionAware{

	/**
	 * 
	 */
	private static final long serialVersionUID = -8067551982812238850L;
	
	public HttpServletRequest request;
	public HttpServletResponse response;

	private final static Color BLUE_DARK = new Color(76, 129, 190);
    private final static Color BLUE_LIGHT_1 = new Color(186, 206, 230);
    private final static Color BLUE_LIGHT_2 = new Color(218, 230, 242);

    private final static Color GRAY_LIGHT_1 = new Color(245, 245, 245);
    private final static Color GRAY_LIGHT_2 = new Color(240, 240, 240);
    private final static Color GRAY_LIGHT_3 = new Color(216, 216, 216);
    private static final float PADDING5 = 5f;
    private static final float PADDING10 = 10f;
    private static final float PADDING20 = 20f;
    private static final float PADDING30 = 30f;
    private static final float PADDING40 = 40f;
    private static final float PADDING50 = 50f;
    
    private HttpSession session;
    private String returnMessage;
	private String key;
    private String custName;
	private String custMobile;
	private String custAddress;
	private String fromDate;
	private String toDate;
	private String totalBillAmountBeforeDate;
	private String totalAmountPaidBeforeDate;
	private String totalOutStandingAmountBeforeDate;
	
	private String totalBillAmountAllTheTime;
	private String totalAmountPaidAllTheTime;
	private String totalOutStandingAmountAllTheTime;
	private String smsData;
	private List<CustomerAccountDetailsDAO> customerAccountDetailsList = new ArrayList<CustomerAccountDetailsDAO>();
	private List<CustomerAccountDetailsDAO> customerAccountDetailsSoretdList = new ArrayList<CustomerAccountDetailsDAO>();
	private Float custOpeningBalnce = 0.0F;
	private String opeingBalancUpdatedBy;
	private String opeingBalanceUpdateDate;
	private SessionMap<String,Object> sessionMap; 

    public void download() throws ParseException
	
    {
		String result = "login";
		session=ServletActionContext.getRequest().getSession(false); 
		 
	        if(session==null || session.getAttribute("login")==null){ 
	        	addActionMessage("Please Login First !!!");
	        	result = "login";
	        }  
	        else{
	        	
	        	response = ServletActionContext.getResponse();
				request = ServletActionContext.getRequest();
				

	        	String shopId = (String) this.getSessionMap().get("shopId");
	    		String shopCode = (String) this.getSessionMap().get("shopCode");
	         	
	    		
	        	String custId = EncryptionDecryption.decrypt(getKey());	
	        	
	        	setKey(EncryptionDecryption.encrypt(custId));
	    
	        	Connection connection = null;
	       		PreparedStatement preparedStatement= null;
	       		ResultSet resultSet = null;
	       		
	       		
	       		String sql = "";
	       		String db = (String) this.getSessionMap().get("db");
	       		try {
	       			
	       			
	       			
					connection = GetDBConnection.getDBConnection(db);
	       			
	       			sql =  "SELECT "
	       					+ "customer_name,"
	       					+ "billing_address "
	       					+ "FROM "
	       					+ "shop_customer_master "
	       					+ "WHERE "
	       					+ "shop_id = ? "
	       					+ "AND "
	       					+ "shop_code = ? "
	       					+ "AND "
	       					+ "customer_id = ? ";
	       			
	       			preparedStatement = connection.prepareStatement(sql);
	       			
	       			preparedStatement.setString(1, shopId);
	       			preparedStatement.setString(2, shopCode);
	       			preparedStatement.setString(3, custId);
	       			
	       			resultSet = preparedStatement.executeQuery();
	       			
	       			if(resultSet.next())
	       			{
	       				this.setCustName(resultSet.getString(1));
	       				this.setCustAddress(resultSet.getString(2));
	       			}
	       					
	       					
	       			
		       		PreparedStatement getOpeningBalPSMT = null;
       				ResultSet getOpeningBalRs = null;
       				String getOpeningBalSQL = "SELECT "
       						+ "opening_balance,"
       						+ "DATE_FORMAT(opening_bal_update_date,'%d/%m/%Y'),"
       						+ "updated_by "
       						+ "FROM "
       						+ "shop_cust_close_open_bal_master "
       						+ "WHERE "
       						+ "customer_id = ? "
       						+ "AND "
       						+ "shop_id = ? "
       						+ "AND "
       						+ "shop_code = ?";
       				getOpeningBalPSMT = connection.prepareStatement(getOpeningBalSQL);
       				
       				getOpeningBalPSMT.setString(1, custId);
       				getOpeningBalPSMT.setString(2, shopId);
       				getOpeningBalPSMT.setString(3, shopCode);
       			
       				getOpeningBalRs = getOpeningBalPSMT.executeQuery();
       				
       				if(getOpeningBalRs.next())
       				{
       					this.setCustOpeningBalnce(getOpeningBalRs.getFloat(1));
       					this.setOpeingBalanceUpdateDate(getOpeningBalRs.getString(2));
       					this.setOpeingBalancUpdatedBy(getOpeningBalRs.getString(3));
       				}
       				else
       				{
       					this.setCustOpeningBalnce(0.0F);
       				}
       				if(getOpeningBalRs != null)
       				{
       					getOpeningBalRs.close();
       					getOpeningBalRs = null;
       				}
       				if(getOpeningBalPSMT != null)
       				{
       					getOpeningBalPSMT.close();
       					getOpeningBalPSMT = null;
       				}
       				
       				
       				if(resultSet != null)
       				{
       					resultSet.close();
       					resultSet = null;
       				}
       				
       				if(preparedStatement != null)       					
       				{
       					preparedStatement.close();
       					preparedStatement = null;
       				}
	       			
	       			sql = "SELECT "
	       					+ "SUM(payment_amount) "
	       					+ "FROM "
	       					+ "shop_customer_payment_master "
	       					+ "where "
	       					+ "shop_id = ? "
	       					+ "AND "
	       					+ "shop_code = ? "
	       					+ "AND "
	       					+ "customer_id = ? "
	       					+ "AND "
	       					+ "entry_date < STR_TO_DATE(?, '%d-%m-%Y')";
	       			
	       			preparedStatement = connection.prepareStatement(sql);
	       			preparedStatement.setString(1, shopId);
	       			preparedStatement.setString(2, shopCode	);
	       			preparedStatement.setString(3, custId);
	       			preparedStatement.setString(4, this.getFromDate());
	       			resultSet = preparedStatement.executeQuery();
	       			
	       			if(resultSet.next())
	       			{
	       				if(resultSet.getString(1) != null)
	       				{
	       				setTotalAmountPaidBeforeDate(resultSet.getString(1));
	       				}
	       				else
	       				{
	       					setTotalAmountPaidBeforeDate("0.0");
	       				}
	       			}
	       			else
	       			{
	       				setTotalAmountPaidBeforeDate("0.0");
	       			}
	       			
	       			//System.out.println(" Amount Paid :"+getTotalAmountPaidBeforeDate());
	       			
	       			if(preparedStatement != null)
       				{
       					preparedStatement.close();
       				}
	       			
	       			float floatTotalAmt = 0.0F;
       				float floatAmtReceived = 0.0F;
       				float floatBalanceAmt = 0.0F;
       				float totalBalanceAmt = 0.0F;
       				float totalAmountReceived = Float.parseFloat(this.getTotalAmountPaidBeforeDate());
       				float totalBillAmountBeforeDate = 0.0F;
       				
       				
       				
       				sql = "SELECT "	           					
           					+ "bill_total_amount,"
           					+ "bill_amount_received,"
           					+ "bill_amount_retrurn "
           					+ "FROM "
           					+ "shop_bill_info_master "
           					+ "WHERE "		           					
           					+ "customer_id = ? "
           					+ "AND "
           					+ "bill_date < STR_TO_DATE(?, '%d-%m-%Y') "
           					+ "AND "
           					+ "shop_id = ? "
           					+ "AND "
           					+ "shop_code = ? "
           					+ "AND "
           					+ "(bill_source IN ('ORIGINAL','BARCODEBILL'))";
       				preparedStatement = connection.prepareStatement(sql);
       				preparedStatement.setString(1, custId);
	       			preparedStatement.setString(2, this.getFromDate());
	       			preparedStatement.setString(3, shopId);
	       			preparedStatement.setString(4, shopCode);
	       			
	       			
       				ResultSet resultSetBillInfo = preparedStatement.executeQuery();
       				
       				while(resultSetBillInfo.next())
       				{
       					try
       					{
	       					floatTotalAmt = Float.parseFloat(resultSetBillInfo.getString(1));
	           				floatAmtReceived = Float.parseFloat(resultSetBillInfo.getString(2));
	           				
	           				totalBillAmountBeforeDate = totalBillAmountBeforeDate + floatTotalAmt;
	           				floatBalanceAmt = floatTotalAmt - floatAmtReceived;
	           			
	           				
	           				if(floatBalanceAmt > 0)
	           				{
	           					totalAmountReceived = totalAmountReceived + floatAmtReceived;
	           					totalBalanceAmt = totalBalanceAmt+floatBalanceAmt; 	           					
	           				}
	           				else if(floatBalanceAmt == 0)
	           				{
	           					totalAmountReceived = totalAmountReceived + floatTotalAmt;
	           				}
	           				
       					}catch(NumberFormatException nfe)
       					{
       						result = "error";
       						
       					}
       				}
       				
       				
       				
       				float floatTotalAmtPaidBeforeDate = 0.0F;
       				if(getTotalAmountPaidBeforeDate() != null)
       				{
       					try
       					{
       					floatTotalAmtPaidBeforeDate = totalAmountReceived;
       					
       					}
       					catch(NumberFormatException nfe)
       					{
       						result = "error";
       						addActionError("Error while parsing in before date calculation !");
       					}
       				}
       				setTotalOutStandingAmountBeforeDate(""+(totalBillAmountBeforeDate-floatTotalAmtPaidBeforeDate));
       				setTotalAmountPaidBeforeDate(""+floatTotalAmtPaidBeforeDate);
	       			setTotalBillAmountBeforeDate(""+totalBillAmountBeforeDate);
	       			
	       			if(resultSetBillInfo != null)
	       			{
	       				resultSetBillInfo.close();
	       			}
	       			if(resultSet != null)
	       			{
	       				resultSet.close();
	       			}
	       			if(preparedStatement != null)
       				{
       					preparedStatement.close();
       				}
	       			
	       			
	       			sql = "SELECT "
	       					+ "DATE_FORMAT(entry_date, '%d/%m/%Y'),"
	       					+ "payment_amount,"
	       					+ "payment_details,"
	       					+ "payment_received_by,"
	       					+ "entry_id "
	       					+ "FROM "
	       					+ "shop_customer_payment_master "
	       					+ "WHERE "
	       					+ "shop_id = ? "
	       					+ "AND "
	       					+ "shop_code = ? "
	       					+ "AND "
	       					+ "customer_id = ? "
	       					+ "AND "
	       					+ "(entry_date BETWEEN "
		   					+ "STR_TO_DATE(?, '%d-%m-%Y') "
		   					+ "AND "
		   					+ "STR_TO_DATE(?, '%d-%m-%Y'))";
	       			
	       			preparedStatement = connection.prepareStatement(sql);
	       			preparedStatement.setString(1, shopId);
	       			preparedStatement.setString(2, shopCode);
	       			preparedStatement.setString(3, custId);
	       			preparedStatement.setString(4, this.getFromDate());
	       			preparedStatement.setString(5, this.getToDate());
	       			
	       			resultSet = preparedStatement.executeQuery();
	       		
	       			
	       			while(resultSet.next())	       				
	       			{
	       				
	       				CustomerAccountDetailsDAO accountDetailsDAO = new CustomerAccountDetailsDAO();
	       				Date date1=new SimpleDateFormat("dd/MM/yyyy").parse(resultSet.getString(1)); 
	       				
	       				accountDetailsDAO.setDate(date1);
	       				accountDetailsDAO.setAmountPaid(resultSet.getString(2));
	       				accountDetailsDAO.setComments(resultSet.getString(3));
	       				accountDetailsDAO.setBilledBy(resultSet.getString(4));
	       				accountDetailsDAO.setBalanceAmount("0.0");
	       				accountDetailsDAO.setBillNumber("RECEIVED");
	       				accountDetailsDAO.setCustPaymentId(resultSet.getString(5));
	       				accountDetailsDAO.setBillAmount("0.0");
	       				
	       				customerAccountDetailsList.add(accountDetailsDAO);
	       				
	       			}
	       			
	       			if(preparedStatement != null)
       				{
       					preparedStatement.close();
       				}
	       			
	       			sql = "SELECT "
	       					+ "bill_number,"
	       					+ "DATE_FORMAT(bill_date, '%d/%m/%Y'),"
	       					+ "comments,"	           					
           					+ "bill_total_amount,"
           					+ "bill_amount_received,"
           					+ "bill_amount_retrurn,"
           					+ "billed_by "
           					+ "FROM "
           					+ "shop_bill_info_master "
           					+ "WHERE "
           					+ "shop_id = ? "
           					+ "AND "
           					+ "shop_code = ? "
           					+ "AND "		           					
           					+ "customer_id = ? "
           					+ "AND "
           					+ "(bill_date between "
		   					+ "STR_TO_DATE(?, '%d-%m-%Y') "
		   					+ "AND "
		   					+ "STR_TO_DATE(?, '%d-%m-%Y')) "
			       			+ "AND "
			       			+ "(bill_source IN ('ORIGINAL','BARCODEBILL'))";
       						preparedStatement = connection.prepareStatement(sql);
       						preparedStatement.setString(1, shopId);
       						preparedStatement.setString(2, shopCode);
       						preparedStatement.setString(3, custId);
       		       			preparedStatement.setString(4, this.getFromDate());
       		       			preparedStatement.setString(5, this.getToDate());

       		       		
       		       			resultSet = preparedStatement.executeQuery();
       						
       						
       						while(resultSet.next())
       						{

       		       				CustomerAccountDetailsDAO accountDetailsDAO = new CustomerAccountDetailsDAO();
       		       				
       		       			Date date1=new SimpleDateFormat("dd/MM/yyyy").parse(resultSet.getString(2)); 
    	       				
    	       			
       		       				
       		       				accountDetailsDAO.setBillNumber(resultSet.getString(1));
       		       				accountDetailsDAO.setDate(date1);
       		       				accountDetailsDAO.setBillAmount(resultSet.getString(4));
       		       				accountDetailsDAO.setComments(resultSet.getString(3));
       		       				accountDetailsDAO.setBilledBy(resultSet.getString(7));
       		       				
       		       				
       		       			
       		       				
       		       			try
	       					{
		       					floatTotalAmt = Float.parseFloat(resultSet.getString(4));
		           				floatAmtReceived = Float.parseFloat(resultSet.getString(5));
		           				floatBalanceAmt = floatTotalAmt - floatAmtReceived;
		           				
		           				if(floatBalanceAmt > 0)
		           				{
		           					accountDetailsDAO.setBalanceAmount(""+floatBalanceAmt); 
		           					accountDetailsDAO.setAmountPaid(resultSet.getString(5));
		           				}
		           				else
		           				{
		           					accountDetailsDAO.setAmountPaid(resultSet.getString(4));
		           					accountDetailsDAO.setBalanceAmount("0.0"); 
		           				}
		           				
	       					}catch(NumberFormatException nfe)
	       					{
	       						result = "error";
	       						addActionError("Error While Formatting while calculating balance amount!"+nfe.getMessage());
	       					}
       		       				       		       				
       		       				customerAccountDetailsList.add(accountDetailsDAO);
       						}
       						
       						
       						// CHALLAN ACCOUNT DETAILS

       						if(resultSet != null)
       						{
       							resultSet.close();
       							resultSet = null;
       						}
       						
       						if(preparedStatement != null)
       	       				{
       	       					preparedStatement.close();
       	       					preparedStatement = null;
       	       				}
       		       			
       		       			sql = "SELECT "
       		       					+ "challan_number,"
       		       					+ "DATE_FORMAT(challan_date, '%d/%m/%Y'),"
       		       					+ "comments,"	           					
       	           					+ "challan_total_amount,"
       	           					+ "challan_amount_received,"
       	           					+ "challan_amount_retrurn,"
       	           					+ "challan_by,"
       	           					+ "DATE_FORMAT(challan_date, '%d-%m-%Y') "
       	           					+ "FROM "
       	           					+ "shop_challan_info_master "
       	           					+ "WHERE "
       	           					+ "shop_id = ? "
       	           					+ "AND "
       	           					+ "shop_code = ? "
       	           					+ "AND "		           					
       	           					+ "customer_id = ? "
       	           					+ "AND "
       	           					+ "(challan_date between "
       			   					+ "STR_TO_DATE(?, '%d-%m-%Y') "
       			   					+ "AND "
       			   					+ "STR_TO_DATE(?, '%d-%m-%Y'))";
       		       			
       	       						preparedStatement = connection.prepareStatement(sql);
       	       						preparedStatement.setString(1, shopId);
       	       						preparedStatement.setString(2, shopCode);
       	       						preparedStatement.setString(3, custId);
       	       		       			preparedStatement.setString(4, this.getFromDate());
       	       		       			preparedStatement.setString(5, this.getToDate());

       	       		       			resultSet = preparedStatement.executeQuery();
       	       						
       	       						
       	       						while(resultSet.next())
       	       						{

       	       		       				CustomerAccountDetailsDAO accountDetailsDAO = new CustomerAccountDetailsDAO();
       	       		       				
       	       		       			Date date1=new SimpleDateFormat("dd/MM/yyyy").parse(resultSet.getString(2)); 
       	    	       				
       	    	       			
       	       		       				
       	       		       				accountDetailsDAO.setBillNumber(resultSet.getString(1));
       	       		       				accountDetailsDAO.setDate(date1);
       	       		       				accountDetailsDAO.setBillAmount(resultSet.getString(4));
       	       		       				accountDetailsDAO.setComments(resultSet.getString(3));
       	       		       				accountDetailsDAO.setBilledBy(resultSet.getString(7));
       	       		       				accountDetailsDAO.setBillType("CHALLAN");
       	       		       				accountDetailsDAO.setDateAsStringType2(resultSet.getString(8));
       	       		       			
       	       		       				
       	       		       			try
       		       					{
       			       					floatTotalAmt = Float.parseFloat(resultSet.getString(4));
       			           				floatAmtReceived = Float.parseFloat(resultSet.getString(5));
       			           				floatBalanceAmt = floatTotalAmt - floatAmtReceived;
       			           				
       			           				if(floatBalanceAmt > 0)
       			           				{
       			           					accountDetailsDAO.setBalanceAmount(""+floatBalanceAmt); 
       			           					accountDetailsDAO.setAmountPaid(resultSet.getString(5));
       			           				}
       			           				else
       			           				{
       			           					accountDetailsDAO.setAmountPaid(resultSet.getString(4));
       			           					accountDetailsDAO.setBalanceAmount("0.0"); 
       			           				}
       			           				
       		       					}catch(NumberFormatException nfe)
       		       					{
       		       						result = "error";
       		       						addActionError("Error While Formatting while calculating balance amount!"+nfe.getMessage());
       		       					}
       	       		       				       		       				
       	       		       			this.getCustomerAccountDetailsList().add(accountDetailsDAO);
       	       						}
       	       						
       						float totalBillAmount = 0.0F;
       						float totalPaymentReceived = 0.0F;
       						float totalOutStandingAmount = 0.0F;
       						
       						float totalOutSAmtBeforeDate = Float.parseFloat(this.getTotalOutStandingAmountBeforeDate());
						
       						float dueAmt = this.getCustOpeningBalnce()+totalOutSAmtBeforeDate;
       						
       					 for(CustomerAccountDetailsDAO dao : customerAccountDetailsList)
       					 {
       						 
       						 
       						
       						
       							
	       						 try
	       						 {
	       							 
	       							 float billAmount = Float.parseFloat(dao.getBillAmount());
	       							 float paymentReceived = Float.parseFloat(dao.getAmountPaid());
	       							 
	       							totalBillAmount = totalBillAmount+billAmount;
	       							totalPaymentReceived = totalPaymentReceived + paymentReceived;
	       							
	       						 }
	       						 catch(NumberFormatException nfe)
	       						 {
	       							 nfe.printStackTrace();
	       							 result = "error";
	       							 addActionError("Error while parsing 3 !");
	       						 }
       						 
       						 
       					 }
       					totalOutStandingAmount = (totalBillAmountBeforeDate+totalBillAmount) - (floatTotalAmtPaidBeforeDate+totalPaymentReceived);
       					 
       					totalOutStandingAmount = totalOutStandingAmount + +this.getCustOpeningBalnce();
       					 setTotalBillAmountAllTheTime(""+(totalBillAmountBeforeDate+totalBillAmount));
       					 setTotalAmountPaidAllTheTime(""+(floatTotalAmtPaidBeforeDate+totalPaymentReceived));
       					 setTotalOutStandingAmountAllTheTime(""+totalOutStandingAmount);
       					 
       					 
       					 
       					
    					 
    					 	//System.out.println(dateList);
    					 	
    						// System.out.println(sortedDateList);
    					 
    						 
    						 Collections.sort(customerAccountDetailsList, new Comparator<CustomerAccountDetailsDAO>() {
    							  public int compare(CustomerAccountDetailsDAO o1, CustomerAccountDetailsDAO o2) {
    							      if (o1.getDate() == null || o2.getDate() == null)
    							        return 0;
    							      return o1.getDate().compareTo(o2.getDate());
    							  }
    							});
    					
    					
    						  
    						
       					
       					 for(CustomerAccountDetailsDAO dao : customerAccountDetailsList)
       					 {
       						 DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yy");  
							 Date d = dao.getDate();
							 dao.setDateAsString(dateFormat.format(d));
							 
							  if(dao.getBillNumber().equals("RECEIVED"))
							  {
								 
								  dueAmt = dueAmt-Float.parseFloat(dao.getAmountPaid());
								
								  dao.setDueAmount(""+dueAmt);
								 
							  }
							  else
							  {								
								
								  dueAmt = dueAmt+Float.parseFloat(dao.getBalanceAmount());
								
								  dao.setDueAmount(""+dueAmt);
							  }
       					 }
    						 
    						 
       					 String path=	request.getSession().getServletContext().getRealPath("/images/");
    			    			PDDocument document = new PDDocument(); 
    							PDPage page = null;
    							
    							SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-Y");
    							Date date = new Date();
    							
    							String dateToday = sdf.format(date); 
    							page = 	new PDPage(PDRectangle.A4);
    							
    							 File fontFile  =  new File( request.getSession().getServletContext().getRealPath("/fonts/Nirmala.ttf"));
    							 TrueTypeFont ttf1 = new TTFParser().parse(fontFile);
    							 PDFont fontMarathi = PDType0Font.load(document, ttf1, true);
    							
    						        document.addPage(page);
    						         PDPageContentStream contentStream = new PDPageContentStream(document, page);
    						         int pageCount = 1;
    					    			 
    						         Table header;
    					    			
    					    			
    					    			  TableBuilder tableHeaderBuilder = Table.builder()
    								                .addColumnsOfWidth(585)				                
    								                .font(HELVETICA)
    								                .borderColor(Color.BLACK)
    								                .horizontalAlignment(CENTER);
    							         
    							          Row headerName = Row.builder()
    								                .add(TextCell.builder().text((String)this.getSessionMap().get("shopnameenglish")).horizontalAlignment(CENTER).borderWidth(0).lineSpacing(10F).build())				               
    								                .backgroundColor(WHITE)
    								                .textColor(Color.BLACK)
    								                .font(PDType1Font.HELVETICA_BOLD).fontSize(20)				              
    								                .horizontalAlignment(CENTER)
    								                .build();
    							          Row address = Row.builder()
  								                .add(TextCell.builder().text((String)this.getSessionMap().get("shopaddresseng")).horizontalAlignment(CENTER).borderWidth(0).lineSpacing(10F).build())				               
  								                .backgroundColor(WHITE)
  								                .textColor(Color.BLACK)
  								                .font(PDType1Font.HELVETICA_BOLD).fontSize(10)				              
  								                .horizontalAlignment(CENTER)
  								                .build();
    							          
    							          
    							          Row info1 = Row.builder()
    								                .add(TextCell.builder().text("Customer Account Statement").borderWidthBottom(0.0F).horizontalAlignment(CENTER).build())				               
    								                .backgroundColor(WHITE)
    								                .textColor(Color.BLACK)
    								                .font(PDType1Font.HELVETICA_BOLD).fontSize(10)
    								                .horizontalAlignment(CENTER)
    								                .build();
    							          
    							          Row info2 = Row.builder()
    								                .add(TextCell.builder().text("Name :- "+this.getCustName()+"   Address:- "+this.getCustAddress()+"  (Opening Bal:"+this.getCustOpeningBalnce()+")").borderWidthBottom(0.0F).horizontalAlignment(CENTER).build())				               
    								                .backgroundColor(WHITE)
    								                .textColor(Color.BLACK)
    								                .font(PDType1Font.HELVETICA_BOLD).fontSize(7)
    								                .horizontalAlignment(CENTER)
    								                .build();
    							          
    							          Row info3 = Row.builder()
  								                .add(TextCell.builder().text("From Date: "
  								                			+this.getFromDate()+" To Date : "+this.getToDate() +"       Page No . : "+pageCount).borderWidthBottom(0.0F).horizontalAlignment(CENTER).build())				               
  								                .backgroundColor(WHITE)
  								                .textColor(Color.BLACK)
  								                .font(PDType1Font.HELVETICA_BOLD).fontSize(10)
  								                .horizontalAlignment(CENTER)
  								                .build();
    							          
    							       
    							          tableHeaderBuilder.addRow(headerName);
    							          tableHeaderBuilder.addRow(address);
    							          tableHeaderBuilder.addRow(info1);
    							          tableHeaderBuilder.addRow(info2);
    							          tableHeaderBuilder.addRow(info3);
    							          header = tableHeaderBuilder.build();
    							          
    							          
    							          
    							          Table stateMentDetails ;
    							          
    							          TableBuilder statementDetailsBuilder = Table.builder()
    								                .addColumnsOfWidth(30,60,65,80,80,80,130,60)				                
    								                .font(HELVETICA)
    								                .borderWidth(0.5F)
    								                .borderColor(Color.BLACK)
    								                .horizontalAlignment(CENTER);
    							          
    							          
    							          Row tableDetailsHeader = Row.builder()
  							        		    .add(TextCell.builder().text("Sr No.").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                

    							        		    .add(TextCell.builder().text("Date").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
    								                .add(TextCell.builder().text("Bill No.").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
    								                .add(TextCell.builder().text("Bill Amount").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())									                
    								                .add(TextCell.builder().text("Amount Received").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())									                
    								                .add(TextCell.builder().text("Credit Amount").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())									                
    								                .add(TextCell.builder().text("Comments").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())									                
    								                .add(TextCell.builder().text("Billed By").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())									                
    								                      
    								                .backgroundColor(Color.LIGHT_GRAY)
    								                .textColor(Color.BLACK)
    								                .font(PDType1Font.HELVETICA_BOLD).fontSize(8)				              
    								                .horizontalAlignment(CENTER)
    								                .build();
    							          statementDetailsBuilder.addRow(tableDetailsHeader);
    							          
    							          
    							          int size = customerAccountDetailsList.size();
    							          
    							          float startY = page.getMediaBox().getHeight() - PADDING20;
    							          float currentY = startY;
    							          TableDrawer.builder()
    						                .contentStream(contentStream)
    						                .table(header)
    						                .startX(PADDING30)
    						                .startY(startY)
    						                .build()
    						                .draw();

    						        	  for(int s=0;s<size;s++)
    						        	  {
    						        		  if(currentY < 130)
    						        		  {
    						        			  pageCount++;
    						        			  stateMentDetails = statementDetailsBuilder.build();
    						        			  TableDrawer.builder()
    								                .contentStream(contentStream)
    								                .table(stateMentDetails)
    								                .startX(PADDING5)
    								                .startY(startY-90)
    								                .build()
    								                .draw();
    						        			  
    						        			  contentStream.close();
    						        			  
    						        			  header = null;
    						        			  
    						        			  

    	    					    			  tableHeaderBuilder = Table.builder()
    	    								                .addColumnsOfWidth(585)				                
    	    								                .font(HELVETICA)
    	    								                .borderColor(Color.BLACK)
    	    								                .horizontalAlignment(CENTER);
    	    							         
    	    							          headerName =  Row.builder()
    	    								                .add(TextCell.builder().text((String)this.getSessionMap().get("shopnameenglish")).horizontalAlignment(CENTER).borderWidth(0).lineSpacing(10F).build())				               
    	    								                .backgroundColor(WHITE)
    	    								                .textColor(Color.BLACK)
    	    								                .font(PDType1Font.HELVETICA_BOLD).fontSize(20)				              
    	    								                .horizontalAlignment(CENTER)
    	    								                .build();
    	    							          address = Row.builder()
    	    								                .add(TextCell.builder().text((String)this.getSessionMap().get("shopaddresseng")).horizontalAlignment(CENTER).borderWidth(0).lineSpacing(10F).build())				               
    	    								                .backgroundColor(WHITE)
    	    								                .textColor(Color.BLACK)
    	    								                .font(PDType1Font.HELVETICA_BOLD).fontSize(10)				              
    	    								                .horizontalAlignment(CENTER)
    	    								                .build();
    	    							           info1 = Row.builder()
    	    								                .add(TextCell.builder().text("Customer Account Statement").borderWidthBottom(0.0F).horizontalAlignment(CENTER).build())				               
    	    								                .backgroundColor(WHITE)
    	    								                .textColor(Color.BLACK)
    	    								                .font(PDType1Font.HELVETICA_BOLD).fontSize(10)
    	    								                .horizontalAlignment(CENTER)
    	    								                .build();
    	    							          
    	    							           info2 = Row.builder()
    	    								                .add(TextCell.builder().text("Name :- "+this.getCustName()+"   Address:- "+this.getCustAddress()).borderWidthBottom(0.0F).horizontalAlignment(CENTER).build())				               
    	    								                .backgroundColor(WHITE)
    	    								                .textColor(Color.BLACK)
    	    								                .font(PDType1Font.HELVETICA_BOLD).fontSize(7)
    	    								                .horizontalAlignment(CENTER)
    	    								                .build();
    	    							          
    	    							           info3 = Row.builder()
    	  								                .add(TextCell.builder().text("From Date: "
    	  								                			+this.getFromDate()+" To Date : "+this.getToDate() +"       Page No . : "+pageCount).borderWidthBottom(0.0F).horizontalAlignment(CENTER).build())				               
    	  								                .backgroundColor(WHITE)
    	  								                .textColor(Color.BLACK)
    	  								                .font(PDType1Font.HELVETICA_BOLD).fontSize(10)
    	  								                .horizontalAlignment(CENTER)
    	  								                .build();
    	    							          
    	    							       
    	    							          tableHeaderBuilder.addRow(headerName);
    	    							          tableHeaderBuilder.addRow(address);
    	    							          tableHeaderBuilder.addRow(info1);
    	    							          tableHeaderBuilder.addRow(info2);
    	    							          tableHeaderBuilder.addRow(info3);
    	    							          header = tableHeaderBuilder.build();
    	    							          
    	    							          
    	    							          
    	    							          
    	    							          
    	    							          statementDetailsBuilder = Table.builder()
    	    							        		  .addColumnsOfWidth(30,60,65,80,80,80,130,60)				                
    	    								                .font(HELVETICA)
    	    								                .borderWidth(0.5F)
    	    								                .borderColor(Color.BLACK)
    	    								                .horizontalAlignment(CENTER);
    	    							          
    	    							          
    	    							          tableDetailsHeader = Row.builder()
    	    							        		    .add(TextCell.builder().text("Sr No.").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                

    	    							        		  .add(TextCell.builder().text("Date").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
    	    								                .add(TextCell.builder().text("Bill No.").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
    	    								                .add(TextCell.builder().text("Bill Amount").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())									                
    	    								                .add(TextCell.builder().text("Amount Received").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())									                
    	    								                .add(TextCell.builder().text("Credit Amount").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())									                
    	    								                .add(TextCell.builder().text("Comments").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())									                
    	    								                .add(TextCell.builder().text("Billed By").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())									                
    	    								                     
    	    								                .backgroundColor(Color.LIGHT_GRAY)
    	    								                .textColor(Color.BLACK)
    	    								                .font(PDType1Font.HELVETICA_BOLD).fontSize(8)				              
    	    								                .horizontalAlignment(CENTER)
    	    								                .build();
    	    							          statementDetailsBuilder.addRow(tableDetailsHeader);
    						        			  
    	    							          
    	    							      	PDPage newPage = new PDPage(PDRectangle.A4);
   								        	 contentStream = new PDPageContentStream(document,newPage);
   								        	currentY =  newPage.getMediaBox().getHeight() - PADDING20;
   								             document.addPage( newPage );
   								             
   								             TableDrawer.builder()
   								                .contentStream(contentStream)
   								                .table(header)
   								                .startX(PADDING30)
   								                .startY(currentY)
   								                .build()
   								                .draw();
    						        		  }
    						        		  
    						        		  
    						        		  CustomerAccountDetailsDAO dao = customerAccountDetailsList.get(s);
    						        		  
    						        		
    						        		 String billNumberS = "";
    						        		 
    						        			 
    						        		 if(dao.getBillType() != null)
    						        		 {
    						        		 
	    						        		 if(dao.getBillType().equals("CHALLAN"))
	    						        		 {
	    						        			 billNumberS = dao.getBillNumber() + "(Challan)";
	    						        		 }
	    						        		 else
	    						        		 {
	    						        			 billNumberS = dao.getBillNumber() ;
	    						        		 }
    						        		 }else
    						        		 {
    						        			 billNumberS = dao.getBillNumber() ;
    						        		 }
    						        		  
    						        		Row custInfo = Row.builder()
							        			  	.add(TextCell.builder().text("" + (s + 1)).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                

    							        			  	.add(TextCell.builder().text(dao.getDateAsString()).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
    							        				.add(TextCell.builder().text(billNumberS).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(1F).build())				                
    							        			  	.add(TextCell.builder().text(dao.getBillAmount()).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(1F).build())				                
    							        			  	.add(TextCell.builder().text(dao.getAmountPaid()).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(1F).build())				                
    							        			  	.add(TextCell.builder().text(dao.getDueAmount()).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(1F).build())				                
    							        				.add(TextCell.builder().text(dao.getComments()).font(fontMarathi).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(1F).build())				                
    							        				.add(TextCell.builder().text(""+dao.getBilledBy()).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(1F).build())				                
    							        			  	
    							        			  	.backgroundColor(Color.WHITE)
    									                .textColor(Color.BLACK)
    									                .font(PDType1Font.HELVETICA)
    									                .fontSize(8)				              
    									                .horizontalAlignment(CENTER)
    									                .height(25F)					                
    									                .build();
    							        	  
    						        			statementDetailsBuilder.addRow(custInfo);
    							        	 
    							        	  currentY = currentY -25;
    						        		  
    						        	  }
    						        	  
    						        	  stateMentDetails = statementDetailsBuilder.build();
    						        	  
    						        	  
    						        	 Table totalInfo ;
    						        	  
    						        	  TableBuilder  totalTableBuilder = Table.builder()
  								                .addColumnsOfWidth(133,133)				                
  								                .font(HELVETICA)
  								                .borderWidth(0.5F)
  								                .borderColor(Color.BLACK)
  								                .horizontalAlignment(CENTER);

    						        	  Row totalBillAmt = Row.builder()
							        			  	.add(TextCell.builder().text("Total Bill Amount : ").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
							        			  	.add(TextCell.builder().text(""+this.getTotalBillAmountAllTheTime()).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
							        			  	.backgroundColor(Color.WHITE)
									                .textColor(Color.BLACK)
									                .font(PDType1Font.HELVETICA)
									                .fontSize(10)				              
									                .horizontalAlignment(CENTER)
									                .height(25F)					                
									                .build();
    						        	  Row totalAmtReceived = Row.builder()
							        			  	.add(TextCell.builder().text("Total Amount Received: ").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
							        			  	.add(TextCell.builder().text(""+this.getTotalAmountPaidAllTheTime()).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
							        			  	.backgroundColor(Color.WHITE)
									                .textColor(Color.BLACK)
									                .font(PDType1Font.HELVETICA)
									                .fontSize(10)				              
									                .horizontalAlignment(CENTER)
									                .height(25F)					                
									                .build();
    						        	  
    						        	  Row openBalAmt = Row.builder()
							        			  	.add(TextCell.builder().text("Opening Balance Amount : ").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
							        			  	.add(TextCell.builder().text(""+this.getCustOpeningBalnce()).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
							        			  	.backgroundColor(Color.WHITE)
									                .textColor(Color.BLACK)
									                .font(PDType1Font.HELVETICA)
									                .fontSize(10)				              
									                .horizontalAlignment(CENTER)
									                .height(25F)					                
									                .build();
    						        	  Row totalAmtOutstanding = Row.builder()
							        			  	.add(TextCell.builder().text("Total Amount Outstanding: ").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
							        			  	.add(TextCell.builder().text(""+this.getTotalOutStandingAmountAllTheTime()).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
							        			  	.backgroundColor(Color.WHITE)
									                .textColor(Color.BLACK)
									                .font(PDType1Font.HELVETICA)
									                .fontSize(10)				              
									                .horizontalAlignment(CENTER)
									                .height(25F)					                
									                .build();
							        	  
    						        	  totalTableBuilder.addRow(totalBillAmt);
    						        	  totalTableBuilder.addRow(totalAmtReceived);
    						        	  totalTableBuilder.addRow(openBalAmt);
    						        	  totalTableBuilder.addRow(totalAmtOutstanding);
    						        	  totalInfo = totalTableBuilder.build();  
    						          
    						          TableDrawer.builder()
    					                .contentStream(contentStream)
    					                .table(stateMentDetails)
    					                .startX(PADDING5)
    					                .startY(startY-90)
    					                .build()
    					                .draw();
    						          
    						        
    						          
    						          
    						        
    						        if(currentY < 150)
    						          {
    						        	  pageCount++;
					        			
					        			  
					        			  contentStream.close();
					        			  
					        			  header = null;
					        			  
					        			  

    					    			  tableHeaderBuilder = Table.builder()
    								                .addColumnsOfWidth(830)				                
    								                .font(HELVETICA)
    								                .borderColor(Color.BLACK)
    								                .horizontalAlignment(CENTER);
    							         
    							          headerName = Row.builder()
    								                .add(TextCell.builder().text((String)this.getSessionMap().get("shopnameenglish")).horizontalAlignment(CENTER).borderWidth(0).lineSpacing(10F).build())				               
    								                .backgroundColor(WHITE)
    								                .textColor(Color.BLACK)
    								                .font(PDType1Font.HELVETICA_BOLD).fontSize(20)				              
    								                .horizontalAlignment(CENTER)
    								                .build();
    							          
    							          address = Row.builder()
  								                .add(TextCell.builder().text((String)this.getSessionMap().get("shopaddresseng")).horizontalAlignment(CENTER).borderWidth(0).lineSpacing(10F).build())				               
  								                .backgroundColor(WHITE)
  								                .textColor(Color.BLACK)
  								                .font(PDType1Font.HELVETICA_BOLD).fontSize(10)				              
  								                .horizontalAlignment(CENTER)
  								                .build();
    							          
    							           info1 = Row.builder()
    								                .add(TextCell.builder().text("Customer Account Statement").borderWidthBottom(0.0F).horizontalAlignment(CENTER).build())				               
    								                .backgroundColor(WHITE)
    								                .textColor(Color.BLACK)
    								                .font(PDType1Font.HELVETICA_BOLD).fontSize(10)
    								                .horizontalAlignment(CENTER)
    								                .build();
    							          
    							           info2 = Row.builder()
    								                .add(TextCell.builder().text("Name :- "+this.getCustName()+"   Address:- "+this.getCustAddress()).borderWidthBottom(0.0F).horizontalAlignment(CENTER).build())				               
    								                .backgroundColor(WHITE)
    								                .textColor(Color.BLACK)
    								                .font(PDType1Font.HELVETICA_BOLD).fontSize(10)
    								                .horizontalAlignment(CENTER)
    								                .build();
    							          
    							           info3 = Row.builder()
  								                .add(TextCell.builder().text("From Date: "
  								                			+this.getFromDate()+" To Date : "+this.getToDate() +"       Page No . : "+pageCount).borderWidthBottom(0.0F).horizontalAlignment(CENTER).build())				               
  								                .backgroundColor(WHITE)
  								                .textColor(Color.BLACK)
  								                .font(PDType1Font.HELVETICA_BOLD).fontSize(10)
  								                .horizontalAlignment(CENTER)
  								                .build();
    							          
    							       
    							          tableHeaderBuilder.addRow(headerName);
    							          tableHeaderBuilder.addRow(info1);
    							          tableHeaderBuilder.addRow(info2);
    							          tableHeaderBuilder.addRow(info3);
    							          header = tableHeaderBuilder.build();
    							          
    							          
    							          PDPage newPage = new PDPage(new PDRectangle(830,580));
								        	 contentStream = new PDPageContentStream(document,newPage);
								        	currentY =  newPage.getMediaBox().getHeight() - PADDING20;
								             document.addPage( newPage );
								             
								             TableDrawer.builder()
								                .contentStream(contentStream)
								                .table(header)
								                .startX(PADDING30)
								                .startY(currentY)
								                .build()
								                .draw();
								             TableDrawer.builder()
		       					                .contentStream(contentStream)
		       					                .table(totalInfo)
		       					                .startX(PADDING5)
		       					                .startY(currentY-120)
		       					                .build()
		       					                .draw();
    							          
    						          }
    						          else
    						          {
    						        	   TableDrawer.builder()
       					                .contentStream(contentStream)
       					                .table(totalInfo)
       					                .startX(PADDING5)
       					                .startY(currentY-120)
       					                .build()
       					                .draw();
    						          }
    						       
    							          contentStream.close();
    								        
    								       // System.out.println(path);
    												
    								        
    								        document.save(path+"/cust-acc-stmt-report.pdf");
    								        document.close();
    								        
    								        response.setHeader("Content-disposition", "inline; filename=acc-stmt.pdf");
    										response.setContentType("application/pdf");
    										FileInputStream fileInputStream = new FileInputStream(path+"/cust-acc-stmt-report.pdf");
    										PrintWriter out = response.getWriter();  
    										int bytes;
    										while ((bytes = fileInputStream.read()) != -1) {
    											out.write(bytes);
    										}
    										fileInputStream.close();
    										out.flush();
    										out.close();
    										ttf1.close();
    						 
    						 
	    			
	    		}catch (SQLException e) {
	    			
	    			result = "error";
	    			e.printStackTrace();
	    			setReturnMessage(e.getErrorCode()+" || "+e.getMessage() +" || Something Went Wrong!");
	    		} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
    			finally {
	    			if(resultSet != null)
					{
						try {
							resultSet.close();
						} catch (SQLException e) {
							
						}
					}
	    			if(preparedStatement != null)
	    			{
	    				try {preparedStatement.close();} catch (SQLException e) {}
	    			}
	    			if(connection != null)
	    			{
	    				
	    				try {connection.close();}catch (SQLException e) {}
	    			}
	    			
	    		}
    		
	        }
}

public HttpServletRequest getRequest() {
	return request;
}

public void setRequest(HttpServletRequest request) {
	this.request = request;
}

public HttpServletResponse getResponse() {
	return response;
}

public void setResponse(HttpServletResponse response) {
	this.response = response;
}

public static long getSerialversionuid() {
	return serialVersionUID;
}

public HttpSession getSession() {
	return session;
}

public void setSession(HttpSession session) {
	this.session = session;
}

public String getReturnMessage() {
	return returnMessage;
}

public void setReturnMessage(String returnMessage) {
	this.returnMessage = returnMessage;
}

public String getCustName() {
	return custName;
}

public void setCustName(String custName) {
	this.custName = custName;
}

public String getCustMobile() {
	return custMobile;
}

public void setCustMobile(String custMobile) {
	this.custMobile = custMobile;
}

public String getFromDate() {
	return fromDate;
}

public void setFromDate(String fromDate) {
	this.fromDate = fromDate;
}

public String getToDate() {
	return toDate;
}

public void setToDate(String toDate) {
	this.toDate = toDate;
}

public String getTotalBillAmountBeforeDate() {
	return totalBillAmountBeforeDate;
}

public void setTotalBillAmountBeforeDate(String totalBillAmountBeforeDate) {
	this.totalBillAmountBeforeDate = totalBillAmountBeforeDate;
}

public String getTotalAmountPaidBeforeDate() {
	return totalAmountPaidBeforeDate;
}

public void setTotalAmountPaidBeforeDate(String totalAmountPaidBeforeDate) {
	this.totalAmountPaidBeforeDate = totalAmountPaidBeforeDate;
}

public String getTotalOutStandingAmountBeforeDate() {
	return totalOutStandingAmountBeforeDate;
}

public void setTotalOutStandingAmountBeforeDate(String totalOutStandingAmountBeforeDate) {
	this.totalOutStandingAmountBeforeDate = totalOutStandingAmountBeforeDate;
}

public String getTotalBillAmountAllTheTime() {
	return totalBillAmountAllTheTime;
}

public void setTotalBillAmountAllTheTime(String totalBillAmountAllTheTime) {
	this.totalBillAmountAllTheTime = totalBillAmountAllTheTime;
}

public String getTotalAmountPaidAllTheTime() {
	return totalAmountPaidAllTheTime;
}

public void setTotalAmountPaidAllTheTime(String totalAmountPaidAllTheTime) {
	this.totalAmountPaidAllTheTime = totalAmountPaidAllTheTime;
}

public String getTotalOutStandingAmountAllTheTime() {
	return totalOutStandingAmountAllTheTime;
}

public void setTotalOutStandingAmountAllTheTime(String totalOutStandingAmountAllTheTime) {
	this.totalOutStandingAmountAllTheTime = totalOutStandingAmountAllTheTime;
}

public String getSmsData() {
	return smsData;
}

public void setSmsData(String smsData) {
	this.smsData = smsData;
}

public List<CustomerAccountDetailsDAO> getCustomerAccountDetailsList() {
	return customerAccountDetailsList;
}

public void setCustomerAccountDetailsList(List<CustomerAccountDetailsDAO> customerAccountDetailsList) {
	this.customerAccountDetailsList = customerAccountDetailsList;
}

public List<CustomerAccountDetailsDAO> getCustomerAccountDetailsSoretdList() {
	return customerAccountDetailsSoretdList;
}

public void setCustomerAccountDetailsSoretdList(List<CustomerAccountDetailsDAO> customerAccountDetailsSoretdList) {
	this.customerAccountDetailsSoretdList = customerAccountDetailsSoretdList;
}

public Float getCustOpeningBalnce() {
	return custOpeningBalnce;
}

public void setCustOpeningBalnce(Float custOpeningBalnce) {
	this.custOpeningBalnce = custOpeningBalnce;
}

public String getOpeingBalancUpdatedBy() {
	return opeingBalancUpdatedBy;
}

public void setOpeingBalancUpdatedBy(String opeingBalancUpdatedBy) {
	this.opeingBalancUpdatedBy = opeingBalancUpdatedBy;
}

public String getOpeingBalanceUpdateDate() {
	return opeingBalanceUpdateDate;
}

public void setOpeingBalanceUpdateDate(String opeingBalanceUpdateDate) {
	this.opeingBalanceUpdateDate = opeingBalanceUpdateDate;
}

public String getKey() {
	return key;
}

public void setKey(String key) {
	this.key = key;
}

public String getCustAddress() {
	return custAddress;
}

public void setCustAddress(String custAddress) {
	this.custAddress = custAddress;
}





public SessionMap<String, Object> getSessionMap() {
	return sessionMap;
}

public void setSessionMap(SessionMap<String, Object> sessionMap) {
	this.sessionMap = sessionMap;
}


public void setSession(Map<String, Object> map) {  
    sessionMap=(SessionMap<String, Object>)map;  
}


}
