package com.reallinkbilling.add;

import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.dispatcher.SessionMap;
import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
import com.reallinkbilling.DAO.PurchaseInvoiceInformationDAO;
import com.reallinkbilling.DAO.PurchaseProductInfoDAO;
import com.reallinkbilling.resource.CheckAlreadyAvailable;
import com.reallinkbilling.resource.CheckInputCorrection;
import com.reallinkbilling.resource.GetListResource;
import com.reallinkbilling.utils.GetAccountListForDrCr;

public class AddProductToPurchaseInvoice extends ActionSupport implements SessionAware,Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -5375687134990140583L;
	private SessionMap<String,Object> sessionMap;  
	private HttpSession session;
	private String paymentType;
	private String purchaseDateTime;
	private String productName;
	private Float amount;
	private Float quantity;
	private String purchaseUnit;
	private Float purchaseRate;
	private Float discount;
	private String rateType;
	private String taxId;
	private Float frightCharges;
	private Float otherExpense;
	private String purchaseId;
	private String supplierName;
	private String invoiceNumber;
	private String comments;
	private File invoiceImage;
	private Float amountPaid;
	private String invoiceImageContentType;
	private boolean addToStock;
	private Map<String,String> taxList = new LinkedHashMap<String,String>();
	private Map<String,String> unitList = new LinkedHashMap<String,String>();
	private String serialBatchNo;
	private PurchaseInvoiceInformationDAO purchaseInvoiceInformationDAO = null;
	private Map<String,String> paymentTypeList = new  LinkedHashMap<String,String>();
	private String paymentDefaultValue;
	private List<PurchaseProductInfoDAO> purchaseProductInfoList = null;
	private String purchaseBy;	
	
	private String viewPurchaseInvoice;
	
	private Float totalPurchaseAmount;
	
	private Float totalNettAmount;
	private Float totalCGST;
	private Float totalSGST;
	private Float totalIGST;
	private Float totalQuantity;
	private DecimalFormat df;
	
	private Map<String,String> rateTypeList = new  LinkedHashMap<String,String>();
	private String rateTyprDefaultValue;
	
	private Float tcsPercentage;
	private Float tcsAmount;
	
	private Float directDiscountAmount;
	
	private String accountId;
	private Map<String,String> accountList = new LinkedHashMap<String,String>();
	private List<String> paymentTypeList2 = new ArrayList<String>();
	
	@SuppressWarnings("unchecked")
	public String execute() {
		 
		String result = "login";
		session=ServletActionContext.getRequest().getSession(false); 
		
	        if(session==null || session.getAttribute("login")==null){ 
	        	addActionMessage("Please Logout and Login again !");
	        	result = "error";
	        }  
	        else{
	        	this.setTotalQuantity(0.0F);
	        	
	    		
	        		
	        	if(this.getSerialBatchNo() == null || this.getSerialBatchNo().equals(""))
	        	{
	        		this.setSerialBatchNo("NA");
	        	}
	        	purchaseInvoiceInformationDAO = (PurchaseInvoiceInformationDAO) this.getSessionMap().get("purchaseInformation");
	        	purchaseProductInfoList = (List<PurchaseProductInfoDAO>) this.getSessionMap().get("purchaseProductList");
	        	
	        	if(purchaseInvoiceInformationDAO == null)
	        	{
	        		purchaseInvoiceInformationDAO = new PurchaseInvoiceInformationDAO();
	        	}
	        	
	        	if(this.getPurchaseProductInfoList() == null)
	        	{
	        		purchaseProductInfoList = new ArrayList<PurchaseProductInfoDAO>();
	        	}
	        	
	        	
	        	if(this.getPurchaseInvoiceInformationDAO().getTcsPercentage() == null )
	        	{
	        		this.setTcsPercentage(0.0F);
	        		this.getPurchaseInvoiceInformationDAO().setTcsPercentage(0.0F);
	        	}
	        	else
	        	{
	        		this.setTcsPercentage(this.getPurchaseInvoiceInformationDAO().getTcsPercentage() );
	        	}
	        	
	        	if(this.getPurchaseInvoiceInformationDAO().getOtherExpense() == null)
	        	{
	        		this.setOtherExpense(0.0F);
	        	}
	        	else
	        	{
	        		this.setOtherExpense(this.getPurchaseInvoiceInformationDAO().getOtherExpense());
	        	}
	        	
	        	if(this.getPurchaseInvoiceInformationDAO().getFrightCharges() == null)
	        	{
	        		this.setFrightCharges(0.0F);
	        	}
	        	else
	        	{
	        		this.setFrightCharges(this.getPurchaseInvoiceInformationDAO().getFrightCharges());
	        	}
	        	
	        	PurchaseProductInfoDAO purchaseProductInfoDAO = new PurchaseProductInfoDAO();
	        	
	        	purchaseProductInfoDAO.setPurchaseId(this.getPurchaseId());
	        	purchaseProductInfoDAO.setProductId(this.getProductName().split("-")[0]);
	        	purchaseProductInfoDAO.setProductName(this.getProductName().split("-")[1]);
	        	purchaseProductInfoDAO.setPurchaseRate(this.getPurchaseRate());
	        	purchaseProductInfoDAO.setPurchaseUnit(this.getPurchaseUnit());
	        	purchaseProductInfoDAO.setQuantity(this.getQuantity());
	        	purchaseProductInfoDAO.setDiscount(this.getDiscount());
	        	purchaseProductInfoDAO.setDiscountType("PERCENTAGE");
	        	purchaseProductInfoDAO.setAmount(this.getAmount());
	        	purchaseProductInfoDAO.setTaxId(this.getTaxId());
	        	purchaseProductInfoDAO.setSerialBatchNo(this.getSerialBatchNo());
	        	purchaseProductInfoDAO.setAddedToDB(false);
	        	
	        	if(this.getSerialBatchNo() == null)
	        	{
	        		purchaseProductInfoDAO.setSerialBatchNo("NA");
	        	}
	        	
	        	float sgst = 0.0F;
	        	float cgst = 0.0F;
	        	float igst = 0.0F;
	        	
	        	 float floatTotalPurchaseAmount = 0.0F;
	        	 float floatTotalCGST = 0.0F;
	        	 float floatTotalSGST = 0.0F;
	        	 float floatTotalIGST = 0.0F;
	        	 float floatTotalNettAmount = 0.0F;
	        	 
	        	
	        	Map<String,String> taxInfo = GetListResource.GetTaxNamePercentage(this.getTaxId(),this.getSessionMap());
	      		String taxName = taxInfo.get("TAX-NAME");
				String taxPercentage = taxInfo.get("TAX-PERCENTAGE");
	        	
				purchaseProductInfoDAO.setTaxName(taxName);
				purchaseProductInfoDAO.setTaxPercentage(Float.parseFloat(taxPercentage));
				
				  df = new DecimalFormat("#.##");
	        	
				if(this.getRateType().equals("INCLUDINGGST"))
				{
						
							float floatProductAmount =0.0F;
							
							try
							{
								float totalAmt = this.getPurchaseRate() * this.getQuantity();
								float totalAmtAfterDis = totalAmt - (totalAmt * (this.getDiscount()/100.F));
								floatProductAmount = totalAmtAfterDis;
							}
							catch(NumberFormatException nfe)
							{}
			
							float floatTaxRate = Float.parseFloat(taxPercentage);	
							
							float basicTax = floatTaxRate+100.0F;
				        	
				        	float nettAmount = (floatProductAmount / basicTax) * 100.0F;
				        	
				        	float totalTax = floatProductAmount - nettAmount;
							
							if(taxName.toUpperCase().contains("IGST"))
							{
								igst = totalTax;
							}
							else
							{
								sgst = totalTax/2.0F;
					        	cgst = totalTax/2.0F;
							}    
				        	
				        	
				        	
				        	 purchaseProductInfoDAO.setNettAmount((float) (Math.round(nettAmount * 10) / 10.0));
				        	 purchaseProductInfoDAO.setSgst((float) (Math.round(sgst * 10) / 10.0));
				        	 purchaseProductInfoDAO.setCgst((float) (Math.round(cgst * 10) / 10.0));
				        	 purchaseProductInfoDAO.setIgst((float) (Math.round(igst * 10) / 10.0));
				        	 
				        	 purchaseProductInfoDAO.setGrossAmount(floatProductAmount);
				        	 
				        	 this.getPurchaseProductInfoList().add(purchaseProductInfoDAO);
				        	 
				        
				        	 
				        	
				}
				
				if(this.getRateType().equals("EXCLUDINGGST"))
				{

					float floatProductAmount = 0.0F;
					float totalAmt = this.getPurchaseRate() * this.getQuantity();
					float totalAmtAfterDis = totalAmt - (totalAmt * (this.getDiscount()/100.F));
					floatProductAmount = totalAmtAfterDis;
	
					float floatTaxRate = Float.parseFloat(taxPercentage);	
					
		        	
		        	float totalTax = floatProductAmount * (floatTaxRate / 100.0F);
					
					if(taxName.toUpperCase().contains("IGST"))
					{
						igst = totalTax;
					}
					else
					{
						sgst = totalTax/2.0F;
			        	cgst = totalTax/2.0F;
					}    
		        	 
		        	
		        	 purchaseProductInfoDAO.setNettAmount((float) (Math.round(floatProductAmount * 10) / 10.0));
		        	 purchaseProductInfoDAO.setSgst((float) (Math.round(sgst * 10) / 10.0));
		        	 purchaseProductInfoDAO.setCgst((float) (Math.round(cgst * 10) / 10.0));
		        	 purchaseProductInfoDAO.setIgst((float) (Math.round(igst * 10) / 10.0));
		        	 
		        	 purchaseProductInfoDAO.setGrossAmount(purchaseProductInfoDAO.getNettAmount()
		        			 +purchaseProductInfoDAO.getSgst()
		        			 +purchaseProductInfoDAO.getCgst()
		        			 +purchaseProductInfoDAO.getIgst());
		        	 
		        	 this.getPurchaseProductInfoList().add(purchaseProductInfoDAO);
		        	 
		        	 
		       
		        	
				}
				
			
				 
	        	 for (PurchaseProductInfoDAO pProductInfoDAO : this.getPurchaseProductInfoList())
	        	 {
	        		
	        			
	        		 this.setTotalQuantity(pProductInfoDAO.getQuantity()+this.getTotalQuantity());
	        		 floatTotalPurchaseAmount = floatTotalPurchaseAmount + pProductInfoDAO.getGrossAmount();
	        		 floatTotalCGST = floatTotalCGST + pProductInfoDAO.getCgst();
	        		 floatTotalSGST = floatTotalSGST + pProductInfoDAO.getSgst();
	        		 floatTotalIGST = floatTotalIGST + pProductInfoDAO.getIgst();
	        		 floatTotalNettAmount = floatTotalNettAmount + pProductInfoDAO.getNettAmount();
	        	 }
	        	 
	        	 this.setTotalPurchaseAmount(floatTotalPurchaseAmount);
	        	 this.setTotalNettAmount(floatTotalNettAmount);
	        	 this.setTotalCGST(floatTotalCGST);
	        	 this.setTotalSGST(floatTotalSGST);
	        	 this.setTotalIGST(floatTotalIGST);
	        	 
	        	 if(this.getFrightCharges() != null)
	        	 {
		        	 if(this.getFrightCharges().equals(""))
		        	 {
		        		 setFrightCharges(0.0F);
		        	 }
	        	 }
	        	 if(this.getOtherExpense() != null)
	        	 {
		        	 if(getOtherExpense().equals(""))
		        	 {
		        		 this.setOtherExpense(0.0F);
		        	 }
	        	 }
	        	 
	        	 String [] supplierInfo = new String [5] ;
	        
	        	 try
	        	 {
	        		 supplierInfo = this.getSupplierName().split("-") ;
	        		 
	        		 
	        	 }catch(Exception e){}
	        	 
	        	 
//	        	 for(int i =0 ;i<supplierInfo.length ; i++) {
//	        		 System.out.println("supplier : "+ supplierInfo[i] );
//	        		 
//	        	 }
	        	 
	        	
	        	 this.getPurchaseInvoiceInformationDAO().setPurchaseId(this.getPurchaseId());
	        	// System.out.println("supplier at 0th index : "+ supplierInfo[0] );
	        	 this.getPurchaseInvoiceInformationDAO().setSupplierId(supplierInfo[0]);
	        	// System.out.println("supplier at 1st index : "+ supplierInfo[1] );
	        	 this.getPurchaseInvoiceInformationDAO().setSupplierName(supplierInfo[1]);
	        	 this.getPurchaseInvoiceInformationDAO().setSupplierDetails(this.getSupplierName());
	        	 this.getPurchaseInvoiceInformationDAO().setInvoiceNumber(this.getInvoiceNumber());
	        	 this.getPurchaseInvoiceInformationDAO().setOtherExpense(this.getOtherExpense());
	        	 this.getPurchaseInvoiceInformationDAO().setFrightCharges(this.getFrightCharges());
	        	 this.getPurchaseInvoiceInformationDAO().setPurchaseTotalAmount(this.getTotalPurchaseAmount()+this.getFrightCharges()+this.getOtherExpense());
	        	 this.getPurchaseInvoiceInformationDAO().setInvoiceImage(this.getInvoiceImage());
	        	 this.getPurchaseInvoiceInformationDAO().setPurchaseDate(this.getPurchaseDateTime());
	        	 this.getPurchaseInvoiceInformationDAO().setTotalCGST((float) (Math.round(floatTotalCGST * 100) / 100.0));
	        	 this.getPurchaseInvoiceInformationDAO().setTotalSGST((float) (Math.round(floatTotalSGST * 100) / 100.0));
	        	 this.getPurchaseInvoiceInformationDAO().setTotalIGST((float) (Math.round(floatTotalIGST * 100) / 100.0));
	        	 this.getPurchaseInvoiceInformationDAO().setTotalNettAmount((float) (Math.round(floatTotalNettAmount * 100) / 100.0));
	        	 this.getPurchaseInvoiceInformationDAO().setPaymentType(this.getPaymentType());
	        	 this.getPurchaseInvoiceInformationDAO().setPurchaseSaved(false);	        	
	        	 this.getPurchaseInvoiceInformationDAO().setAddToStock(this.isAddToStock());
	        	 this.getPurchaseInvoiceInformationDAO().setPurchaseBy(this.getPurchaseBy());
	        	 this.getPurchaseInvoiceInformationDAO().setRateType(this.getRateType());
	        	 
	        	 float tcsAmtCal = this.getTotalPurchaseAmount() * (this.getTcsPercentage()/100F);
	        	 
	        	 
	        	 this.getPurchaseInvoiceInformationDAO().setTcsAmount((float) (Math.round(tcsAmtCal * 100) / 100.0));
	        	 this.setTcsAmount((float) (Math.round(tcsAmtCal * 100f) / 100.0));
	        	 
	        	 this.setTotalPurchaseAmount((float) Math.round(this.getTotalPurchaseAmount()+tcsAmtCal));
	        	 this.getPurchaseInvoiceInformationDAO().setPurchaseTotalAmount((float) Math.round(this.getTotalPurchaseAmount()+tcsAmtCal));
	        	 
	        		this.setUnitList(GetListResource.GetUnitList());
	        		 this.setAccountList(GetAccountListForDrCr.getAccountList(this.getSessionMap()));
	 		       	
	        		this.setProductName("");
	        		this.setQuantity(0.0F);
	        		this.setPurchaseRate(0.0F);
	        		this.setAmount(0.0F);
	        		this.setSerialBatchNo("NA");
	        	 
		        	result = SUCCESS;
	        	
	        }
	        this.getSessionMap().put("purchaseInformation", this.getPurchaseInvoiceInformationDAO());
	        this.getSessionMap().put("purchaseProductList", this.getPurchaseProductInfoList());
        	
	        return result;
	}
	
	@Override
	public void validate() {
		
		

		try
		{
			String s = this.getProductName().split("-")[1];
		}catch (Exception e) {
			addActionError("Please provide correct product name!");
		}
		
		paymentTypeList.put("CASH","CASH");
    	paymentTypeList.put("CREDIT","CREDIT");    	
    	this.setPaymentDefaultValue(this.getPaymentType());
    	
    	this.setAccountList(GetAccountListForDrCr.getAccountList(this.getSessionMap()));
    	
    	paymentTypeList2.add("CASH");
    	paymentTypeList2.add("UPI");
    	paymentTypeList2.add("RTGS");
    	paymentTypeList2.add("NEFT");
    	
		 df = new DecimalFormat("0.00");
		session=ServletActionContext.getRequest().getSession(false); 
		@SuppressWarnings("unchecked")
		List<PurchaseProductInfoDAO> purchaseProductInfoListTest = (List<PurchaseProductInfoDAO>) sessionMap.get("purchaseProductList");
		purchaseInvoiceInformationDAO = (PurchaseInvoiceInformationDAO) sessionMap.get("purchaseInformation");
		
			taxList = GetListResource.GetTaxList(this.getSessionMap());
			
		
    	
    	unitList = GetListResource.GetUnitList();
		
		if(this.getSupplierName() == null || this.getSupplierName().equals(""))
		{
			addActionError("Please provide correct supplier name !");
		}
		if(!hasActionErrors())
		{
			if(getSupplierName().equals("Supplier_Not_Found"))
			{
				addActionError("Please provide correct supplier name !");
			}
		}
		
		if(this.getSupplierName() !=null || !getSupplierName().equals(""))
		{
			try
			{
				getSupplierName().split("-");
			}catch(NumberFormatException nfe)
			{
				addActionError("Please provide correct supplier name !");
			}
		}
		if(!hasActionErrors())
		{
			if(this.getProductName().equals(""))
			{
				addActionError("Please provide product name!");
			}
		}
		if(!hasActionErrors())
		{
			if(this.getInvoiceNumber().equals(""))
			{
				addActionError("Please provide correct invoice number !");
			}
		}
		if(!hasActionErrors())
		{
			if(this.getPurchaseUnit() == null ||  this.getPurchaseUnit().equals(""))
			{
				addActionError("Please provide correct purchase unit !");
			}
		}
		
		if(!hasActionErrors())
		{
			if(this.getPurchaseRate() == null || this.getPurchaseRate().equals(""))
			{
			addActionError("Please provide purchase rate !");
			}
		}
		if(!hasActionErrors())
		{
			if(this.getTaxId() == null || this.getTaxId().equals(""))
			{
				addActionError("Please provide Tax !");
			}
		}
		
		if(!hasActionErrors())
		{
			if(getSessionMap().get("batchbased") == "1")
			{
				if(this.getSerialBatchNo() == null || this.getSerialBatchNo().equals(""))
				{
					addActionError("Please provide correct Serial Number or Batch Id!");
				}
			}
		}
		if(!hasActionErrors())
		{
			if(this.getQuantity() ==null || this.getQuantity().equals(""))
			{
				addActionError("Please provide quantity !");
			}
		}
		if(!hasActionErrors())
		{ 
				if(this.getAmount() == null || this.getAmount().equals(""))
				{
					addActionError("Amount cannot be blank !");
				}
		}
		if(!hasActionErrors())
		{
			boolean isSpecialCharsAddedtoInvoiceNumber = false;
			isSpecialCharsAddedtoInvoiceNumber = CheckInputCorrection.checkSpecialCharactersAdded(getInvoiceNumber());
			if(isSpecialCharsAddedtoInvoiceNumber)
			{
				addActionError("Invoice Number cannot have special characters !");
			}
		}
		if(!hasActionErrors())
		{
			if(this.getQuantity()!=null || !this.getQuantity().equals(""))
			{
				try
				{
					
					
					if(this.getQuantity()<0)
					{
						addActionError("Quantity can not be less than '0' !");
					}
				}
				catch(NumberFormatException nfe)
				{
					addActionError("Please provide correct quantity !");
				}
			}
		}
		
		
		if(!hasActionErrors())
		{
			if(!this.getPurchaseRate().equals(""))
			{
				float purchaserate  = 0.0F;
				
				try
				{
					purchaserate = this.getPurchaseRate();
					
					if(purchaserate<0)
					{
						addActionError("Purchase rate can not be less than '0' !");
					}
				}
				catch(NumberFormatException nfe)
				{
					addActionError("Please provide correct purchase rate !");
				}
			}
		}
		
		
		if(!hasActionErrors())
		{
			if(this.getDiscount() == null || this.getDiscount().equals(""))
			{
				addActionError("Please provide correct discount figure!");
			}
		}
		
		if(!hasActionErrors())
			
		{
			if(this.getInvoiceImage() != null)
			{
			
				if(!getInvoiceImageContentType().equals("image/jpeg"))
				{
					addActionError("Please provide only jpeg file to upload image !");
				}
			}
		}
		
		
		if(!hasActionErrors())
		{
			String isInvoiceDuplicate = "false";
			
			String [] result = new String[2];
			String condition  = "NA";
			result = new CheckAlreadyAvailable().checkAvaibility("productpurchaseinfo", "invoicenumber", condition, getInvoiceNumber(), this.getSessionMap());
			
			isInvoiceDuplicate = result[0];
			
			//System.out.println("isInvoiceDuplicate");
			
			/*if(isInvoiceDuplicate.equals("true"))
			{
				addActionError("Invoice number duplication constraint !");
			}		*/		
			
		}
		
		
		if(purchaseProductInfoListTest !=null)
		{
			if(!purchaseProductInfoListTest.isEmpty())
			{
				for(PurchaseProductInfoDAO infoDAO:purchaseProductInfoListTest)
				{
					
					if(this.getSessionMap().get("batchbased").equals("1"))
					{
						if(infoDAO.getSerialBatchNo().equals(this.getSerialBatchNo()))
						{
							addActionError("Product is alredy added to list with same serial No !");
							purchaseProductInfoList = purchaseProductInfoListTest;
						}
					}
					else if(infoDAO.getProductName().equals(this.productName))
					{
						addActionError("Product is alredy added to list !");
						purchaseProductInfoList = purchaseProductInfoListTest;
					}
					
				}
				
				
			}
			else
			{
				this.purchaseProductInfoList = purchaseProductInfoListTest;
			}
		}
		this.purchaseProductInfoList = purchaseProductInfoListTest;
		if(!hasActionErrors())
		{
		if(purchaseProductInfoList != null && purchaseProductInfoList.size()>0)
		{
		
		 float floatTotalPurchaseAmount = 0.0F;
    	 float floatTotalCGST = 0.0F;
    	 float floatTotalSGST = 0.0F;
    	 float floatTotalIGST = 0.0F;
    	 float floatTotalNettAmount = 0.0F;
    	 
    	 for (PurchaseProductInfoDAO pProductInfoDAO : purchaseProductInfoList)
    	 {
    		 floatTotalPurchaseAmount = floatTotalPurchaseAmount + pProductInfoDAO.getAmount();
    		 floatTotalCGST = floatTotalCGST + pProductInfoDAO.getCgst();
    		 floatTotalSGST = floatTotalSGST + pProductInfoDAO.getSgst();
    		 floatTotalIGST = floatTotalIGST + pProductInfoDAO.getIgst();
    		 floatTotalNettAmount = floatTotalNettAmount + pProductInfoDAO.getNettAmount();
    	 }
    	 if(this.getPaymentType().equals("CREDIT")){
    		 this.setAmountPaid(0.0F);
    	 }
    	this.setTotalPurchaseAmount(floatTotalPurchaseAmount);
    	this.setTotalNettAmount(floatTotalNettAmount);
    	this.setTotalCGST(floatTotalCGST);
    	this.setTotalSGST(floatTotalSGST);
    	this.setTotalIGST(floatTotalIGST);
		
    	
    	 
    	this.setPurchaseId(purchaseInvoiceInformationDAO.getPurchaseId());
    	this.setInvoiceNumber(purchaseInvoiceInformationDAO.getInvoiceNumber());
    	purchaseInvoiceInformationDAO.setPurchaseSaved(false);
    	this.setAddToStock(purchaseInvoiceInformationDAO.isAddToStock());
    	 
		sessionMap.put("purchaseInformation", purchaseInvoiceInformationDAO);
    	sessionMap.put("purchaseProductList", purchaseProductInfoList);
	

	
			taxList = GetListResource.GetTaxList(this.getSessionMap());
			
		
    	
    	unitList = GetListResource.GetUnitList();
		}
		}
		else
		{
			addActionError("Please provide all details!");
		}
		this.setDirectDiscountAmount(0.0F);
		this.getRateTypeList().put("INCLUDINGGST", "Including GST");
    	this.getRateTypeList().put("EXCLUDINGGST", "Excluding GST");
    	this.setRateTyprDefaultValue(this.getRateType());
		
	}
	
	public HttpSession getSession() {
		return session;
	}

	public void setSession(HttpSession session) {
		this.session = session;
	}

	public Map<String, String> getTaxList() {
		return taxList;
	}

	public void setTaxList(Map<String, String> taxList) {
		this.taxList = taxList;
	}

	public Map<String, String> getUnitList() {
		return unitList;
	}

	public void setUnitList(Map<String, String> unitList) {
		this.unitList = unitList;
	}

	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}


	public String getPurchaseUnit() {
		return purchaseUnit;
	}

	public void setPurchaseUnit(String purchaseUnit) {
		this.purchaseUnit = purchaseUnit;
	}

	

	public Float getAmount() {
		return amount;
	}

	public void setAmount(Float amount) {
		this.amount = amount;
	}

	public Float getQuantity() {
		return quantity;
	}

	public void setQuantity(Float quantity) {
		this.quantity = quantity;
	}

	public Float getPurchaseRate() {
		return purchaseRate;
	}

	public void setPurchaseRate(Float purchaseRate) {
		this.purchaseRate = purchaseRate;
	}

	public Float getFrightCharges() {
		return frightCharges;
	}

	public void setFrightCharges(Float frightCharges) {
		this.frightCharges = frightCharges;
	}

	public Float getOtherExpense() {
		return otherExpense;
	}

	public void setOtherExpense(Float otherExpense) {
		this.otherExpense = otherExpense;
	}

	public String getTaxId() {
		return taxId;
	}


	public void setTaxId(String taxId) {
		this.taxId = taxId;
	}


	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;  
	}


	public PurchaseInvoiceInformationDAO getPurchaseInvoiceInformationDAO() {
		return purchaseInvoiceInformationDAO;
	}


	public void setPurchaseInvoiceInformationDAO(PurchaseInvoiceInformationDAO purchaseInvoiceInformationDAO) {
		this.purchaseInvoiceInformationDAO = purchaseInvoiceInformationDAO;
	}


	public List<PurchaseProductInfoDAO> getPurchaseProductInfoList() {
		return purchaseProductInfoList;
	}


	public void setPurchaseProductInfoList(List<PurchaseProductInfoDAO> purchaseProductInfoList) {
		this.purchaseProductInfoList = purchaseProductInfoList;
	}


	public String getViewPurchaseInvoice() {
		return viewPurchaseInvoice;
	}


	public void setViewPurchaseInvoice(String viewPurchaseInvoice) {
		this.viewPurchaseInvoice = viewPurchaseInvoice;
	}



	
	public String getPurchaseId() {
		return purchaseId;
	}


	public void setPurchaseId(String purchaseId) {
		this.purchaseId = purchaseId;
	}


	public String getSupplierName() {
		return supplierName;
	}


	public void setSupplierName(String supplierName) {
		this.supplierName = supplierName;
	}


	public String getInvoiceNumber() {
		return invoiceNumber;
	}


	public void setInvoiceNumber(String invoiceNumber) {
		this.invoiceNumber = invoiceNumber;
	}


	public String getComments() {
		return comments;
	}


	public void setComments(String comments) {
		this.comments = comments;
	}


	public File getInvoiceImage() {
		return invoiceImage;
	}


	public void setInvoiceImage(File invoiceImage) {
		this.invoiceImage = invoiceImage;
	}

	public String getInvoiceImageContentType() {
		return invoiceImageContentType;
	}

	public void setInvoiceImageContentType(String invoiceImageContentType) {
		this.invoiceImageContentType = invoiceImageContentType;
	}


	public Float getTotalPurchaseAmount() {
		return totalPurchaseAmount;
	}

	public void setTotalPurchaseAmount(Float totalPurchaseAmount) {
		this.totalPurchaseAmount = totalPurchaseAmount;
	}

	public Float getTotalNettAmount() {
		return totalNettAmount;
	}

	public void setTotalNettAmount(Float totalNettAmount) {
		this.totalNettAmount = totalNettAmount;
	}

	public Float getTotalCGST() {
		return totalCGST;
	}

	public void setTotalCGST(Float totalCGST) {
		this.totalCGST = totalCGST;
	}

	public Float getTotalSGST() {
		return totalSGST;
	}

	public void setTotalSGST(Float totalSGST) {
		this.totalSGST = totalSGST;
	}

	public Float getTotalIGST() {
		return totalIGST;
	}

	public void setTotalIGST(Float totalIGST) {
		this.totalIGST = totalIGST;
	}

	public boolean isAddToStock() {
		return addToStock;
	}

	public void setAddToStock(boolean addToStock) {
		this.addToStock = addToStock;
	}

	public String getPurchaseDateTime() {
		return purchaseDateTime;
	}

	public void setPurchaseDateTime(String purchaseDateTime) {
		this.purchaseDateTime = purchaseDateTime;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public Map<String, String> getPaymentTypeList() {
		return paymentTypeList;
	}

	public void setPaymentTypeList(Map<String, String> paymentTypeList) {
		this.paymentTypeList = paymentTypeList;
	}

	
	public String getPaymentDefaultValue() {
		return paymentDefaultValue;
	}

	public void setPaymentDefaultValue(String paymentDefaultValue) {
		this.paymentDefaultValue = paymentDefaultValue;
	}

	public DecimalFormat getDf() {
		return df;
	}

	public void setDf(DecimalFormat df) {
		this.df = df;
	}

	public String getPaymentType() {
		return paymentType;
	}

	public void setPaymentType(String paymentType) {
		this.paymentType = paymentType;
	}

	public Float getAmountPaid() {
		return amountPaid;
	}

	public void setAmountPaid(Float amountPaid) {
		this.amountPaid = amountPaid;
	}

	public String getPurchaseBy() {
		return purchaseBy;
	}

	public void setPurchaseBy(String purchaseBy) {
		this.purchaseBy = purchaseBy;
	}

	public Float getTotalQuantity() {
		return totalQuantity;
	}

	public void setTotalQuantity(Float totalQuantity) {
		this.totalQuantity = totalQuantity;
	}

	public Float getDiscount() {
		return discount;
	}

	public void setDiscount(Float discount) {
		this.discount = discount;
	}

	public String getRateType() {
		return rateType;
	}

	public void setRateType(String rateType) {
		this.rateType = rateType;
	}

	public Map<String, String> getRateTypeList() {
		return rateTypeList;
	}

	public void setRateTypeList(Map<String, String> rateTypeList) {
		this.rateTypeList = rateTypeList;
	}

	public String getRateTyprDefaultValue() {
		return rateTyprDefaultValue;
	}

	public void setRateTyprDefaultValue(String rateTyprDefaultValue) {
		this.rateTyprDefaultValue = rateTyprDefaultValue;
	}

	public String getSerialBatchNo() {
		return serialBatchNo;
	}

	public void setSerialBatchNo(String serialBatchNo) {
		this.serialBatchNo = serialBatchNo;
	}

	public Float getTcsPercentage() {
		return tcsPercentage;
	}

	public void setTcsPercentage(Float tcsPercentage) {
		this.tcsPercentage = tcsPercentage;
	}

	public Float getTcsAmount() {
		return tcsAmount;
	}

	public void setTcsAmount(Float tcsAmount) {
		this.tcsAmount = tcsAmount;
	}

	public Float getDirectDiscountAmount() {
		return directDiscountAmount;
	}

	public void setDirectDiscountAmount(Float directDiscountAmount) {
		this.directDiscountAmount = directDiscountAmount;
	}

	public String getAccountId() {
		return accountId;
	}

	public void setAccountId(String accountId) {
		this.accountId = accountId;
	}

	public Map<String, String> getAccountList() {
		return accountList;
	}

	public void setAccountList(Map<String, String> accountList) {
		this.accountList = accountList;
	}

	public List<String> getPaymentTypeList2() {
		return paymentTypeList2;
	}

	public void setPaymentTypeList2(List<String> paymentTypeList2) {
		this.paymentTypeList2 = paymentTypeList2;
	}

	

}
