|
|
|
@@ -372,29 +372,29 @@ public class TransactionController {
|
|
|
|
@RequestParam(required = false, defaultValue = "0") String months) {
|
|
|
|
@RequestParam(required = false, defaultValue = "0") String months) {
|
|
|
|
|
|
|
|
|
|
|
|
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
|
|
|
|
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
|
|
|
|
|
|
|
|
|
|
|
|
LocalDate today = LocalDate.now();
|
|
|
|
LocalDate today = LocalDate.now();
|
|
|
|
|
|
|
|
|
|
|
|
int year = (years.equals("0")) ? today.getYear() : Integer.parseInt(years);
|
|
|
|
int year = (years.equals("0")) ? today.getYear() : Integer.parseInt(years);
|
|
|
|
|
|
|
|
|
|
|
|
int month = (months.equals("0")) ? today.getMonthValue() : Integer.parseInt(months);
|
|
|
|
int month = (months.equals("0")) ? today.getMonthValue() : Integer.parseInt(months);
|
|
|
|
|
|
|
|
|
|
|
|
YearMonth yearMonth = YearMonth.of(year, month);
|
|
|
|
YearMonth yearMonth = YearMonth.of(year, month);
|
|
|
|
|
|
|
|
|
|
|
|
int lastDay = yearMonth.lengthOfMonth();
|
|
|
|
int lastDay = yearMonth.lengthOfMonth();
|
|
|
|
|
|
|
|
|
|
|
|
int firstDayOfWeek = yearMonth.atDay(1).getDayOfWeek().getValue() % 7;
|
|
|
|
int firstDayOfWeek = yearMonth.atDay(1).getDayOfWeek().getValue() % 7;
|
|
|
|
|
|
|
|
|
|
|
|
YearMonth previousYearMonth = yearMonth.minusMonths(1);
|
|
|
|
YearMonth previousYearMonth = yearMonth.minusMonths(1);
|
|
|
|
|
|
|
|
|
|
|
|
int previousYear = previousYearMonth.getYear();
|
|
|
|
int previousYear = previousYearMonth.getYear();
|
|
|
|
int previousMonth = previousYearMonth.getMonthValue();
|
|
|
|
int previousMonth = previousYearMonth.getMonthValue();
|
|
|
|
|
|
|
|
|
|
|
|
YearMonth nextYearMonth = yearMonth.plusMonths(1);
|
|
|
|
YearMonth nextYearMonth = yearMonth.plusMonths(1);
|
|
|
|
|
|
|
|
|
|
|
|
int nextYear = nextYearMonth.getYear();
|
|
|
|
int nextYear = nextYearMonth.getYear();
|
|
|
|
int nextMonth = nextYearMonth.getMonthValue();
|
|
|
|
int nextMonth = nextYearMonth.getMonthValue();
|
|
|
|
|
|
|
|
|
|
|
|
model.addAttribute(PageReturnAttributeKeyword.YEAR, year);
|
|
|
|
model.addAttribute(PageReturnAttributeKeyword.YEAR, year);
|
|
|
|
model.addAttribute(PageReturnAttributeKeyword.MONTH, month);
|
|
|
|
model.addAttribute(PageReturnAttributeKeyword.MONTH, month);
|
|
|
|
model.addAttribute(PageReturnAttributeKeyword.DAY, today.getDayOfMonth());
|
|
|
|
model.addAttribute(PageReturnAttributeKeyword.DAY, today.getDayOfMonth());
|
|
|
|
@@ -410,27 +410,26 @@ public class TransactionController {
|
|
|
|
|
|
|
|
|
|
|
|
LocalDate startDate = yearMonth.atDay(1);
|
|
|
|
LocalDate startDate = yearMonth.atDay(1);
|
|
|
|
LocalDate endDate = yearMonth.atEndOfMonth();
|
|
|
|
LocalDate endDate = yearMonth.atEndOfMonth();
|
|
|
|
|
|
|
|
|
|
|
|
List<Income> incomeList = transactionService.findTotalIncomeList(startDate, endDate, loginUser.getUserId());
|
|
|
|
List<Income> incomeList = transactionService.findTotalIncomeList(startDate, endDate, loginUser.getUserId());
|
|
|
|
|
|
|
|
|
|
|
|
List<Expense> expenseList = transactionService.findTotalExpenseList(startDate, endDate, loginUser.getUserId());
|
|
|
|
List<Expense> expenseList = transactionService.findTotalExpenseList(startDate, endDate, loginUser.getUserId());
|
|
|
|
|
|
|
|
|
|
|
|
model.addAttribute(PageReturnAttributeKeyword.INCOME_LIST, incomeList);
|
|
|
|
model.addAttribute(PageReturnAttributeKeyword.INCOME_LIST, incomeList);
|
|
|
|
model.addAttribute(PageReturnAttributeKeyword.EXPENSE_LIST, expenseList);
|
|
|
|
model.addAttribute(PageReturnAttributeKeyword.EXPENSE_LIST, expenseList);
|
|
|
|
|
|
|
|
|
|
|
|
int totalIncome = transactionService.findTotalIncome(startDate, endDate, loginUser.getUserId());
|
|
|
|
int totalIncome = transactionService.findTotalIncome(startDate, endDate, loginUser.getUserId());
|
|
|
|
|
|
|
|
|
|
|
|
int totalExpense = transactionService.findTotalExpense(startDate, endDate, loginUser.getUserId());
|
|
|
|
int totalExpense = transactionService.findTotalExpense(startDate, endDate, loginUser.getUserId());
|
|
|
|
|
|
|
|
|
|
|
|
model.addAttribute(PageReturnAttributeKeyword.TOTAL_INCOME, totalIncome);
|
|
|
|
model.addAttribute(PageReturnAttributeKeyword.TOTAL_INCOME, totalIncome);
|
|
|
|
model.addAttribute(PageReturnAttributeKeyword.TOTAL_EXPENSE, totalExpense);
|
|
|
|
model.addAttribute(PageReturnAttributeKeyword.TOTAL_EXPENSE, totalExpense);
|
|
|
|
|
|
|
|
|
|
|
|
List<GoalForm> goalForm = GoalForm.convertFrom(goalService.getGoalByUserId(loginUser.getUserId()));
|
|
|
|
List<GoalForm> goalForm = GoalForm.convertFrom(goalService.getGoalByUserId(loginUser.getUserId()));
|
|
|
|
|
|
|
|
|
|
|
|
UserForm userForm = UserForm.convertFrom(userService.findByUserId(loginUser.getUserId()));
|
|
|
|
UserForm userForm = UserForm.convertFrom(userService.findByUserId(loginUser.getUserId()));
|
|
|
|
|
|
|
|
|
|
|
|
List<GoalForm> resultList = goalForm.stream().filter(goal -> goal.getGoalComplete() == 0 && goal.getDeadline().isAfter(today) )
|
|
|
|
List<GoalForm> resultList = goalForm.stream().filter(goal -> goal.getGoalComplete() == 0 && goal.getDeadline().isAfter(today) )
|
|
|
|
|
|
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
if (!resultList.isEmpty()) {
|
|
|
|
if (!resultList.isEmpty()) {
|
|
|
|
|