Skip to content

Commit

Permalink
BE-#94: Calculation and Tests work. Dto missing
Browse files Browse the repository at this point in the history
  • Loading branch information
Flugschnitzel committed May 20, 2024
1 parent de6b503 commit 7292149
Show file tree
Hide file tree
Showing 2 changed files with 265 additions and 220 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public List<Dept> calculateDeptsForUserId(String userId){
}
} else {
Optional<UserWithPercentage> userWithPercentage = expenseEntry.getInvolvedUsers().stream()
.findFirst().filter(user -> user.getUserId().equals(userId));
.filter(user -> user.getUserId().equals(userId)).findFirst();
if(userWithPercentage.isPresent()){
// Add the Dept of the user to the Dept List
// In this case the user for whom we calculate all depts is a involved user and not the payer
Expand All @@ -68,9 +68,8 @@ public List<Dept> calculateDeptsForUserId(String userId){

// This method extracts the logic if the deptor is already in the list or not
private List<Dept> addDept(List<Dept> depts, String debtorId, double deptAmount){
Optional<Dept> optionalDept = depts.stream().findFirst()
.filter(dept -> dept.getUserId().equals(debtorId));
// todo somehow in second entry with second user this optional is empty but should not be
Optional<Dept> optionalDept = depts.stream()
.filter(dept -> dept.getUserId().equals(debtorId)).findFirst();

if(optionalDept.isPresent()){
// Calculate new deptAmount if already exists
Expand Down
Loading

0 comments on commit 7292149

Please sign in to comment.