public void addCarryForward(Date smsDate) { Date firstDateOfMonth = AppUtil.getFirstDateOfMonth(smsDate); this.setFirstDateOfMonth(firstDateOfMonth); ExpenseData data = new ExpenseData(); data.setNumber("Carry Forward"); data.setCategory(AppConstants.CATEGORY.CARRY_FORWARD.toString()); data.setDate(AppUtil.convertDateToString(firstDateOfMonth)); data.setAmount(this.getCarryForwardAmount().toString()); data.setAccountingType(AppConstants.ACCOUNTING_TYPE_CREDIT); this.add(data); }
public List<WeeklyExpenseData> getWeeklyExpenseData() { List<WeeklyExpenseData> weeklySmsList = new ArrayList<WeeklyExpenseData>(); for (ExpenseData data : this.smsList) { // Getting week number for date Date date = AppUtil.getDateFromString(data.getDate(), "MM/dd/yy HH:mm"); Calendar cal = Calendar.getInstance(); cal.setTime(date); int weekNbr = cal.get(Calendar.WEEK_OF_MONTH); WeeklyExpenseData weekData = this.getWeeklyDataFromList(weekNbr, weeklySmsList); if (weekData != null) { if (AppConstants.ACCOUNTING_TYPE_DEBIT.equalsIgnoreCase(data.getAccountingType())) weekData.setDebitAmount(weekData.getDebitAmount() + Double.valueOf(data.getAmount())); if (AppConstants.ACCOUNTING_TYPE_CREDIT.equalsIgnoreCase(data.getAccountingType())) weekData.setCreditAmount(weekData.getCreditAmount() + Double.valueOf(data.getAmount())); weekData.add(data); } else { weekData = new WeeklyExpenseData(); weekData.setWeek("W" + weekNbr); if (AppConstants.ACCOUNTING_TYPE_DEBIT.equalsIgnoreCase(data.getAccountingType())) { weekData.setDebitAmount(Double.valueOf(data.getAmount())); weekData.setCreditAmount(0D); } if (AppConstants.ACCOUNTING_TYPE_CREDIT.equalsIgnoreCase(data.getAccountingType())) { weekData.setCreditAmount(Double.valueOf(data.getAmount())); weekData.setDebitAmount(0D); } weekData.add(data); weeklySmsList.add(weekData); } } return weeklySmsList; }