package ibase.webitm.ejb.adm;

import java.util.*;

class Suppliers
{
	
    
   private String suppCode; 
   
   private String taxClass;
   private String taxChap;
   private String taxEnv;
   private String currCode;
   private String siteCode;
   private String bankCode;
   private String finEntity;
   private String acctCodeAp;
   private String cctrCodeAp;
   private double exchRate;
   private String prdCode ;
   private String effDate;
   private String  tranDate;
   private String crTerm;
   public void setCrTerm(String crTerm)
	{
		this.crTerm = crTerm.trim();
	}
	public String getCrTerm()
	{
		return this.crTerm;
	}

   //added for claim
    public void setEffDate(String  effDate)
	{
		this.effDate = effDate;
	}
	public String getEffDate()
	{
		return this.effDate;
	}
	public void setTranDate(String  tranDate)
	{
		this.tranDate = tranDate;
	}
	public String  getTranDate()
	{
		return this.tranDate;
	}
	//end
  	
   
    ArrayList CustomerList = new ArrayList();
   
    public void setSuppCode(String suppCode)
	{
		this.suppCode = suppCode.trim();
	}
	public String getSuppCode()
	{
		return this.suppCode;
	}
	 public void setPrdCode(String prdCode)
	{
		this.prdCode = prdCode.trim();
	}
	public String getPrdCode()
	{
		return this.prdCode;
	}
	
	
	public String getTaxClass()
	{
		return this.taxClass.trim();
	}
	
	public String getTaxChap()
	{
		return this.taxChap.trim();
	}
	public String getTaxEnv()
	{
		return this.taxEnv;
	}
	public String getCurrCode()
	{
		return this.currCode;
	}
	public double getExchRate()
	{
		return this.exchRate;
	}
	public String getSiteCode()
	{
		return this.siteCode;
	}
	public String getBankCode()
	{
		return this.bankCode;
	}
	public String getFinEntity()
	{
		return this.finEntity;
	}
	public String getAcctCodeAp()
	{
		return this.acctCodeAp;
	}
	public String getCctrCodeAp()
	{
		return this.cctrCodeAp;
	}
	
 

	public void setCustomerList(Customer customerObj) 
	{
			this.CustomerList.add(customerObj);
	}

	public ArrayList getCustomerList()  
	{ 
		return CustomerList;
	}
	
public void setGenInfo(java.sql.Connection conn)
{
	///select curr_code into :ls_curr from finent where fin_entity = :mfinentity;
	///select std_exrt into :lc_exch from currency where curr_code = :ls_curr;
	try
	{
		String sql="SELECT  SUPPLIER.SITE_CODE,SUPPLIER.TAX_CLASS,SUPPLIER.TAX_CHAP,SUPPLIER.TAX_ENV,SUPPLIER.CURR_CODE ,CURRENCY.STD_EXRT,SUPPLIER.ACCT_CODE__AP, SUPPLIER.CCTR_CODE__AP,SUPPLIER.CR_TERM    FROM SUPPLIER,CURRENCY WHERE"
		+" CURRENCY.CURR_CODE=SUPPLIER .CURR_CODE AND SUPP_CODE='"+this.suppCode+"'";
		System.out.println("SQL:::"+sql);
		java.sql.PreparedStatement pstmt=conn.prepareStatement(sql);
		java.sql.ResultSet rs = pstmt.executeQuery();
		if(rs.next())
		{
		this.siteCode = (rs.getString(1)==null?" ":rs.getString(1)); 
		this.taxClass = (rs.getString(2)==null?" ":rs.getString(2));
		this.taxChap = (rs.getString(3)==null?" ":rs.getString(3));
		this.taxEnv = (rs.getString(4)==null?" ":rs.getString(4));
		this.currCode = (rs.getString(5)==null?" ":rs.getString(5));
		this.exchRate = rs.getDouble(6);
		this.acctCodeAp= (rs.getString(7)==null?" ":rs.getString(7));
		this.cctrCodeAp=(rs.getString(8)==null?" ":rs.getString(8));
		this.crTerm=(rs.getString(9)==null?" ":rs.getString(9));
		}
		
		rs.close();
		//if not found on supplier then search on sitesupplier
		if(this.siteCode == null || this.siteCode.trim().length()==0)
		{
			sql = "SELECT SITE_CODE FROM SITE_SUPPLIER WHERE SUPP_CODE='"+this.suppCode+"'";
			System.out.println("SQL:::"+sql);
			pstmt=conn.prepareStatement(sql);
			rs = pstmt.executeQuery();
			if(rs.next())
			{
				this.siteCode = (rs.getString(1)==null?" ":rs.getString(1)); 

				
			}
			rs.close();
			
				
		}
		sql = "SELECT BANK_CODE,FIN_ENTITY FROM SITE WHERE SITE_CODE='"+this.siteCode+"'";
			System.out.println("SQL:::"+sql); 
		
		pstmt=conn.prepareStatement(sql);
		rs = pstmt.executeQuery();
		if(rs.next())
		{
			bankCode = (rs.getString(1)==null?" ":rs.getString(1));
			finEntity = (rs.getString(2)==null?" ":rs.getString(2));
		}
		rs.close();
		pstmt.close();
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}
	  
  
}
	
}//end of bean