In the following code it is suppose to fill the forecasted unites in the Account only if
-
the
Reportdate received from the cursor is within theForecaststartandenddates and, -
the
Itemid = to theItemid received from the cursor and -
the
Accountid = to theAccountid received from the cursor.if (cursor != null && cursor.getCount() > 0) { cursor.moveToFirst(); do { long reportDate = cursor.getLong(cursor.getColumnIndex(ForecastsItemAccountDetailsContract.Columns.Report_Date)); long itemId = cursor.getLong(cursor.getColumnIndex(ForecastsItemAccountDetailsContract.Columns.Item_ID)); long accountId = cursor.getLong(cursor.getColumnIndex(ForecastsItemAccountDetailsContract.Columns.Account_ID)); int forecastedUnits = cursor.getInt(cursor.getColumnIndex(ForecastsItemAccountDetailsContract.Columns.Forecasted_Units)); for (Forecast forecast : mForecasts) { if ((forecast.getForecast_From() < reportDate) && (forecast.getForecast_To() >= reportDate)) { for (Item item : forecast.getItems()) { if (item.getItem_ID() == itemId) { for (Account account : item.getAccounts()) { if (account.getAccount_ID() == accountId) { account.setForecastedUnits(forecastedUnits); } } } } } } } while (cursor.moveToNext()); }
But at the end i find all accounts within all items within all Forecasts having the same forecasted units.
All Are Equal...
What could be the mistake ?
Aucun commentaire:
Enregistrer un commentaire