public ArrayList subledger1(String type, String loanid, float amount)
    {        //get all details subledger needs
        arrayTemp= new ArrayList();
        String query = "select * from loan_dtl where loanid="+loanid+" and amordate between to_date('"+startDate.substring(0, 10)+"','yyyy-mm-dd') and to_date('"+endDate.substring(0, 10)+"','yyyy-mm-dd') ";
        System.out.println("sub1query"+query);
        ResultSet rs;
        this.connect();
        Statement stmt = null;
        String premium_prev, interest_prev, penalty_prev;
       float premium, interest, penalty ;
       
        try
        {
            stmt = conn.createStatement();
            rs = stmt.executeQuery(query);
            rs.next();
            //System.out.println("in sub1 while"+loanid+" "+rs.getString("mon_interest"));
                interest_prev=rs.getString("mon_interest");
                premium_prev=rs.getString("mon_premium");
                interest=rs.getFloat("mon_interest");
                premium=rs.getFloat("mon_premium");
                //penalty_prev=rs.getString("mon_penalty_prev");
                if(amount-rs.getFloat("mon_interest")-rs.getFloat("mon_premium")==0)
                {
                    //premium=0;
                    //interest=0;
                interest=rs.getFloat("mon_interest");
                premium=rs.getFloat("mon_premium");
                    System.out.println("pumasok dito sa zero");
                }
                else if(interest+premium>amount)
                {
                    //interest=-amount;
                    if(amount-interest==0){//equals intereset
                        premium=rs.getFloat("mon_premium");
                        interest=0;
                    }
                    else if (amount-interest<0)//less than interest
                    {
                        premium=rs.getFloat("mon_premium");;
                        interest-=amount;
                    }
                    else if (amount-interest>0)//greater than interest
                    {
                        interest=0;
                        if(amount-interest<premium)//less than premium
                            premium-=(amount-interest);
                    }
                
                
            }
                arrayTemp.add(type);
                //arrayTemp.add(ordtlid);
                arrayTemp.add(rs.getString("loanid"));
                arrayTemp.add(rs.getString("loandtlid"));
                arrayTemp.add(rs.getString("mon_premium"));
                arrayTemp.add(rs.getString("mon_interest"));
                //arrayTemp.add(rs.getString("mon_penalty"));
                arrayTemp.add(String.valueOf(premium));
                arrayTemp.add(String.valueOf(interest));
                //arrayTemp.add(String.valueOf(penalty));
                
	}
        
        catch (SQLException e)
        {
            e.printStackTrace();
	}   
        finally{
            this.disconnect();
        }
       
        return arrayTemp;
    }