-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#460 - new page to show still active recurring transactions
- Loading branch information
1 parent
a11e227
commit 4ae5fb1
Showing
9 changed files
with
304 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
BudgetMasterServer/src/main/resources/templates/transactions/recurringOverview.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<html> | ||
<head> | ||
<#import "../helpers/header.ftl" as header> | ||
<@header.globals/> | ||
<@header.header "BudgetMaster - ${locale.getString('transactions.recurring.headline')}"/> | ||
<@header.style "transactions"/> | ||
<@header.style "search"/> | ||
<#import "/spring.ftl" as s> | ||
</head> | ||
<@header.body> | ||
<#import "../helpers/navbar.ftl" as navbar> | ||
<@navbar.navbar "recurring" settings/> | ||
|
||
<#import "../search/searchMacros.ftl" as searchMacros> | ||
|
||
<main> | ||
<div class="card main-card background-color"> | ||
<div class="container"> | ||
<div class="section center-align"> | ||
<div class="headline">${locale.getString("transactions.recurring.headline")}</div> | ||
</div> | ||
</div> | ||
|
||
<@header.content> | ||
<#if transactions?has_content> | ||
<@searchMacros.renderTransactions transactions=transactions openLinksInNewTab=false/> | ||
<#else> | ||
<#-- show placeholde text if there are no active recurring transactions --> | ||
<br> | ||
<div class="row"> | ||
<div class="col s12"> | ||
<div class="headline-small center-align">${locale.getString("transactions.recurring.placeholder")}</div> | ||
</div> | ||
</div> | ||
</#if> | ||
</@header.content> | ||
</div> | ||
</main> | ||
|
||
<!-- Scripts--> | ||
<#import "../helpers/scripts.ftl" as scripts> | ||
<@scripts.scripts/> | ||
</@header.body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
...test/java/de/deadlocker8/budgetmaster/unit/repeating/RepeatingTransactionUpdaterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
package de.deadlocker8.budgetmaster.unit.repeating; | ||
|
||
import de.deadlocker8.budgetmaster.accounts.Account; | ||
import de.deadlocker8.budgetmaster.accounts.AccountType; | ||
import de.deadlocker8.budgetmaster.repeating.RepeatingOption; | ||
import de.deadlocker8.budgetmaster.repeating.RepeatingOptionRepository; | ||
import de.deadlocker8.budgetmaster.repeating.RepeatingTransactionUpdater; | ||
import de.deadlocker8.budgetmaster.repeating.endoption.RepeatingEndAfterXTimes; | ||
import de.deadlocker8.budgetmaster.repeating.endoption.RepeatingEndDate; | ||
import de.deadlocker8.budgetmaster.repeating.endoption.RepeatingEndNever; | ||
import de.deadlocker8.budgetmaster.repeating.modifier.RepeatingModifierDays; | ||
import de.deadlocker8.budgetmaster.repeating.modifier.RepeatingModifierMonths; | ||
import de.deadlocker8.budgetmaster.repeating.modifier.RepeatingModifierYears; | ||
import de.deadlocker8.budgetmaster.transactions.Transaction; | ||
import de.deadlocker8.budgetmaster.transactions.TransactionRepository; | ||
import de.deadlocker8.budgetmaster.transactions.TransactionService; | ||
import de.deadlocker8.budgetmaster.unit.helpers.LocalizedTest; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
import org.springframework.test.context.junit.jupiter.SpringExtension; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
|
||
@ExtendWith(SpringExtension.class) | ||
@LocalizedTest | ||
class RepeatingTransactionUpdaterTest | ||
{ | ||
@Mock | ||
private TransactionService transactionService; | ||
|
||
@Mock | ||
private TransactionRepository transactionRepository; | ||
|
||
@Mock | ||
private RepeatingOptionRepository repeatingOptionRepository; | ||
|
||
private Transaction TRANSACTION_1; | ||
private Transaction TRANSACTION_2; | ||
private Transaction TRANSACTION_3; | ||
private Transaction TRANSACTION_4; | ||
|
||
private RepeatingTransactionUpdater repeatingTransactionUpdater; | ||
|
||
@BeforeEach | ||
void beforeEach() | ||
{ | ||
final RepeatingOption REPEATING_OPTION_END_NEVER = new RepeatingOption(LocalDate.of(2022, 12, 1), | ||
new RepeatingModifierDays(3), | ||
new RepeatingEndNever()); | ||
|
||
final RepeatingOption REPEATING_OPTION_END_DATE = new RepeatingOption(LocalDate.of(2022, 10, 24), | ||
new RepeatingModifierMonths(1), | ||
new RepeatingEndDate(LocalDate.of(2023, 2, 15))); | ||
|
||
final RepeatingOption REPEATING_OPTION_END_AFTER_X_TIMES = new RepeatingOption(LocalDate.of(2018, 4, 30), | ||
new RepeatingModifierYears(1), | ||
new RepeatingEndAfterXTimes(2)); | ||
|
||
final Account account = new Account("Account", AccountType.CUSTOM); | ||
|
||
TRANSACTION_1 = new Transaction(); | ||
TRANSACTION_1.setName("abc"); | ||
TRANSACTION_1.setAmount(700); | ||
TRANSACTION_1.setAccount(account); | ||
TRANSACTION_1.setIsExpenditure(true); | ||
TRANSACTION_1.setRepeatingOption(REPEATING_OPTION_END_NEVER); | ||
Mockito.when(transactionRepository.findAllByRepeatingOption(REPEATING_OPTION_END_NEVER)).thenReturn(List.of(TRANSACTION_1)); | ||
|
||
TRANSACTION_2 = new Transaction(); | ||
TRANSACTION_2.setName("Lorem"); | ||
TRANSACTION_2.setAmount(200); | ||
TRANSACTION_2.setAccount(account); | ||
TRANSACTION_2.setIsExpenditure(true); | ||
TRANSACTION_2.setRepeatingOption(REPEATING_OPTION_END_DATE); | ||
|
||
TRANSACTION_3 = new Transaction(); | ||
TRANSACTION_3.setName("Ipsum"); | ||
TRANSACTION_3.setAmount(75); | ||
TRANSACTION_3.setAccount(account); | ||
TRANSACTION_3.setIsExpenditure(true); | ||
TRANSACTION_3.setRepeatingOption(REPEATING_OPTION_END_AFTER_X_TIMES); | ||
Mockito.when(transactionRepository.findAllByRepeatingOption(REPEATING_OPTION_END_DATE)).thenReturn(List.of(TRANSACTION_2, TRANSACTION_3)); | ||
|
||
TRANSACTION_4 = new Transaction(); | ||
TRANSACTION_4.setName("dolor"); | ||
TRANSACTION_4.setAmount(50); | ||
TRANSACTION_4.setAccount(account); | ||
TRANSACTION_4.setIsExpenditure(true); | ||
TRANSACTION_4.setRepeatingOption(REPEATING_OPTION_END_AFTER_X_TIMES); | ||
Mockito.when(transactionRepository.findAllByRepeatingOption(REPEATING_OPTION_END_AFTER_X_TIMES)).thenReturn(List.of(TRANSACTION_4)); | ||
|
||
Mockito.when(transactionService.getRepository()).thenReturn(transactionRepository); | ||
Mockito.when(repeatingOptionRepository.findAllByOrderByStartDateAsc()).thenReturn(List.of(REPEATING_OPTION_END_NEVER, REPEATING_OPTION_END_DATE, REPEATING_OPTION_END_AFTER_X_TIMES)); | ||
repeatingTransactionUpdater = new RepeatingTransactionUpdater(transactionService, repeatingOptionRepository); | ||
} | ||
|
||
@Test | ||
void test_getActiveRepeatingTransactionsAfter() | ||
{ | ||
assertThat(repeatingTransactionUpdater.getActiveRepeatingTransactionsAfter(LocalDate.of(2023, 1, 20))) | ||
.containsExactly(TRANSACTION_1, TRANSACTION_2); | ||
} | ||
|
||
@Test | ||
void test_getActiveRepeatingTransactionsAfter_2() | ||
{ | ||
assertThat(repeatingTransactionUpdater.getActiveRepeatingTransactionsAfter(LocalDate.of(2017, 1, 20))) | ||
.containsExactly(TRANSACTION_1, TRANSACTION_2, TRANSACTION_4); | ||
} | ||
|
||
@Test | ||
void test_getActiveRepeatingTransactionsAfter_3() | ||
{ | ||
assertThat(repeatingTransactionUpdater.getActiveRepeatingTransactionsAfter(LocalDate.of(2023, 10, 1))) | ||
.containsExactly(TRANSACTION_1); | ||
} | ||
} |