Bug fix for recurring transactions with HWT 'PREVIOUS_WORKDAY'
Fix the actual bug and add a test case (test case also contains a more detailed description)
This commit is contained in:
@@ -137,7 +137,8 @@ public class RecurringTransactionService {
|
||||
|
||||
|
||||
if (holiday || weekend) {
|
||||
defer = recurringTransaction.getHolidayWeekendType() == HolidayWeekendType.NEXT_WORKDAY;
|
||||
defer = recurringTransaction.getHolidayWeekendType() == HolidayWeekendType.NEXT_WORKDAY
|
||||
|| recurringTransaction.getHolidayWeekendType() == HolidayWeekendType.PREVIOUS_WORKDAY;
|
||||
}
|
||||
|
||||
return !defer && dueToday;
|
||||
|
||||
@@ -56,6 +56,34 @@ public class RecurringTransactionService_getAllDueToday_MONTHLY_PREVIOUS_WORKDAY
|
||||
Assert.assertEquals(1, IterableUtils.size(recurringDueToday));
|
||||
}
|
||||
|
||||
/**
|
||||
* Negative test case for the following: recurringTransaction firstOccurrence = saturday the 15th,
|
||||
* intervalType = monthly and holidayWeekendType = previous_workday => should not be due today if today is the 15th,
|
||||
* as it was actually due yesterday.
|
||||
*/
|
||||
@Test
|
||||
public void test_getAllDueToday_PreviousWorkday_weekend_notDue() {
|
||||
// Arrange
|
||||
final RecurringTransaction recurringTransaction = new RecurringTransaction();
|
||||
|
||||
recurringTransaction.setFirstOccurrence(LocalDate.of(2019, 6, 15));
|
||||
recurringTransaction.setHolidayWeekendType(HolidayWeekendType.PREVIOUS_WORKDAY);
|
||||
recurringTransaction.setIntervalType(IntervalType.MONTHLY);
|
||||
|
||||
Mockito.when(this.recurringTransactionRepository
|
||||
.findByDeletedFalseAndLastOccurrenceIsNullOrLastOccurrenceGreaterThanEqual(Mockito.any()))
|
||||
.thenReturn(Collections.singletonList(recurringTransaction));
|
||||
Mockito.when(this.ruleService.isHoliday(Mockito.any())).thenReturn(Boolean.FALSE);
|
||||
Mockito.when(this.ruleService.isWeekend(Mockito.any())).thenReturn(Boolean.TRUE, Boolean.FALSE);
|
||||
final LocalDate now = LocalDate.of(2019, 6, 15);
|
||||
|
||||
// Act
|
||||
final Iterable<RecurringTransaction> recurringDueToday = this.classUnderTest.getAllDueToday(now);
|
||||
|
||||
// Assert
|
||||
Assert.assertEquals(0, IterableUtils.size(recurringDueToday));
|
||||
}
|
||||
|
||||
private RecurringTransaction createRecurringTransaction(int days) {
|
||||
final RecurringTransaction recurringTransaction = new RecurringTransaction();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user