Skip to content

Commit

Permalink
[bugfix/#326] 회계내역 작성에 memberId 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
whitem4rk committed Jun 28, 2024
1 parent dd62793 commit 5b9efdf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class BudgetHistoryCreateForm {

@NotBlank private String details;

private Long memberIdReceived;

private String memberStudentIdReceived;

private String memberNameReceived;
Expand All @@ -54,6 +56,7 @@ public BudgetHistoryCreateForm(
LocalDateTime dateUsed,
String title,
String details,
Long memberIdReceived,
String memberStudentIdReceived,
String memberNameReceived,
Integer income,
Expand All @@ -62,6 +65,7 @@ public BudgetHistoryCreateForm(
this.dateUsed = dateUsed;
this.title = title;
this.details = details;
this.memberIdReceived = memberIdReceived;
this.memberStudentIdReceived = memberStudentIdReceived;
this.memberNameReceived = memberNameReceived;
this.income = income;
Expand All @@ -75,13 +79,15 @@ public BudgetHistoryCreateForm(
public boolean isIncome() {
return this.income > ZERO
&& this.outcome == 0
&& this.memberIdReceived == null
&& this.memberNameReceived == null
&& this.memberStudentIdReceived == null;
}

public boolean isOutcome() {
return this.outcome > ZERO
&& this.income == 0
&& this.memberIdReceived != null
&& this.memberNameReceived != null
&& this.memberStudentIdReceived != null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ public Long createHistory(BudgetHistoryCreateForm form, Long secretaryId) {
} else if (form.isOutcome()) {
memberReceived =
memberRepository
.findByStudentId_IdAndName_Value(
form.getMemberStudentIdReceived(), form.getMemberNameReceived())
.findByIdAndStudentId_IdAndName_Value(
form.getMemberIdReceived(),
form.getMemberStudentIdReceived(),
form.getMemberNameReceived())
.orElseThrow(MemberNotFoundException::new);
} else {
throw new InvalidInputException();
Expand Down Expand Up @@ -79,8 +81,10 @@ public void modifyHistory(Long historyId, BudgetHistoryCreateForm form, Long sec
} else if (form.isOutcome()) {
memberReceived =
memberRepository
.findByStudentId_IdAndName_Value(
form.getMemberStudentIdReceived(), form.getMemberNameReceived())
.findByIdAndStudentId_IdAndName_Value(
form.getMemberIdReceived(),
form.getMemberStudentIdReceived(),
form.getMemberNameReceived())
.orElseThrow(MemberNotFoundException::new);
} else {
throw new InvalidInputException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public void createOutcomeHistoryTest() {
.dateUsed(LocalDateTime.now())
.title("title")
.details("details")
.memberIdReceived(1L)
.memberStudentIdReceived("12171707")
.memberNameReceived("조승현")
.income(0)
Expand All @@ -125,7 +126,7 @@ public void createOutcomeHistoryTest() {
.build();

given(memberRepository.findById(any())).willReturn(Optional.of(secretary));
given(memberRepository.findByStudentId_IdAndName_Value(any(), any()))
given(memberRepository.findByIdAndStudentId_IdAndName_Value(any(), any(), any()))
.willReturn(Optional.of(memberReceived));
given(menuRepository.findById(anyInt())).willReturn(Optional.of(menu));
given(boardFileRepository.getAllByIdInAndUploader(anyList(), any())).willReturn(List.of(file));
Expand Down Expand Up @@ -153,6 +154,7 @@ public void modifyHistoryTest() {
LocalDateTime.now().minusDays(1L),
"title",
"details",
1L,
"12171234",
"유동현",
0,
Expand All @@ -173,7 +175,7 @@ public void modifyHistoryTest() {
.writtenBy(secretary, BudgetHistory.class);
ReflectionTestUtils.setField(budgetHistory, "id", 1L);
given(memberRepository.findById(any())).willReturn(Optional.of(secretary));
given(memberRepository.findByStudentId_IdAndName_Value(any(), any()))
given(memberRepository.findByIdAndStudentId_IdAndName_Value(any(), any(), any()))
.willReturn(Optional.of(memberReceived));
given(budgetHistoryRepository.findById(any())).willReturn(Optional.of(budgetHistory));
given(boardFileRepository.getAllByIdInAndUploader(anyList(), any())).willReturn(List.of(file));
Expand Down

0 comments on commit 5b9efdf

Please sign in to comment.