Skip to content

Commit f5a6990

Browse files
authored
Merge pull request #44 from Nexters/dev
#42
2 parents 20749d4 + 6dd6991 commit f5a6990

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/donmani/donmani_server/expense/service/ExpenseService.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import donmani.donmani_server.expense.entity.FlagType;
1313
import org.springframework.data.domain.Page;
1414
import org.springframework.data.domain.PageRequest;
15-
import org.springframework.data.domain.Pageable;
1615
import org.springframework.stereotype.Service;
1716
import org.springframework.transaction.annotation.Transactional;
1817

@@ -215,7 +214,13 @@ public CategoryStatisticsDTO getCategoryStatistics(String userKey, int year, int
215214
Map<CategoryType, Integer> categoryCounts = Arrays.stream(CategoryType.values())
216215
.collect(Collectors.toMap(category -> category, category -> 0));
217216

218-
expenses.forEach(expense -> categoryCounts.put(expense.getCategory(), categoryCounts.get(expense.getCategory()) + 1));
217+
expenses.forEach(expense -> {
218+
if (expense.getCategory() != null) {
219+
categoryCounts.put(
220+
expense.getCategory(), categoryCounts.get(expense.getCategory()) + 1);
221+
}
222+
});
223+
219224

220225
return CategoryStatisticsDTO.builder()
221226
.year(year)

0 commit comments

Comments
 (0)