@SuppressWarnings("unchecked")
@Override
public List<Sales> selectByMonth(String month, String year) {
Sales sales = new Sales();
String year1,month1;
Sales salesFinal = new Sales();
int addFlag=0;
ArrayList<Sales> finalSalesList = new ArrayList<Sales>();
List<Sales> salesList =hibernateTemplate.find("from Sales where isActive=1");
for(int i=0;i<salesList.size();i++)
{
sales = salesList.get(i);
month1= sales.getBillId().getDate().substring(0, 2);
year1=sales.getBillId().getDate().substring(6, 10);
if(month1.equals(month) && year1.equals(year1))
{
addFlag=0;
for(int j=0;j<finalSalesList.size();j++)
{
salesFinal = finalSalesList.get(j);
if(salesFinal.getProductId().getId()== sales.getProductId().getId())
{
addFlag=1;
salesFinal.setQtySold(sales.getQtySold()+salesFinal.getQtySold());
salesFinal.setTotal(sales.getTotal()+salesFinal.getTotal());
}
}
if(addFlag==0)
finalSalesList.add(sales);
}