START bookings optimizations
This commit is contained in:
@@ -36,8 +36,13 @@ public class AccountStatisticService {
|
||||
public void calculateStatistics(Transaction transaction) {
|
||||
final Account fromAccount = transaction.getFromAccount();
|
||||
final Account toAccount = transaction.getToAccount();
|
||||
final long amount = transaction.getAmount();
|
||||
final List<AccountStatistic> resultList = new ArrayList<>();
|
||||
long amount = transaction.getAmount();
|
||||
|
||||
// Special case: START bookings should not increase 'spendings current period'
|
||||
if (AccountType.START.equals(fromAccount.getType())) {
|
||||
amount = 0;
|
||||
}
|
||||
|
||||
for (final Period period : transaction.getPeriods()) {
|
||||
resultList.add(calculateInternal(fromAccount, period, amount, true, 1));
|
||||
|
||||
@@ -98,6 +98,12 @@ public class TransactionService {
|
||||
.getMultiplierToAccount(toAccount) * amount));
|
||||
}
|
||||
|
||||
// Special case: START bookings should not be counted towards 'expenses current period'
|
||||
// as booking e.g. a mortgage of 250,000 looks kinda ugly then
|
||||
if (AccountType.START.equals(fromAccount.getType())) {
|
||||
transaction.setExpenseNeutral(true);
|
||||
}
|
||||
|
||||
this.transactionRepository.save(transaction);
|
||||
|
||||
this.accountStatisticService.calculateStatistics(transaction);
|
||||
|
||||
Reference in New Issue
Block a user