Add end balance to account statistic
This commit is contained in:
@@ -21,6 +21,7 @@ public class AccountStatistic {
|
|||||||
private long transactionCountFrom;
|
private long transactionCountFrom;
|
||||||
private long spendingTotalTo;
|
private long spendingTotalTo;
|
||||||
private long transactionCountTo;
|
private long transactionCountTo;
|
||||||
|
private long endBalance;
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
@@ -73,4 +74,12 @@ public class AccountStatistic {
|
|||||||
public void setTransactionCountTo(long transactionCountTo) {
|
public void setTransactionCountTo(long transactionCountTo) {
|
||||||
this.transactionCountTo = transactionCountTo;
|
this.transactionCountTo = transactionCountTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getEndBalance() {
|
||||||
|
return endBalance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndBalance(long endBalance) {
|
||||||
|
this.endBalance = endBalance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<packaging.type>jar</packaging.type>
|
<packaging.type>jar</packaging.type>
|
||||||
<activeProfiles>postgres,dev</activeProfiles>
|
<activeProfiles>hsqldb,dev</activeProfiles>
|
||||||
<deploymentProfile>mk</deploymentProfile>
|
<deploymentProfile>mk</deploymentProfile>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|||||||
@@ -16,4 +16,7 @@ public interface AccountStatisticRepository extends CrudRepository<AccountStatis
|
|||||||
|
|
||||||
@Query("SELECT a FROM Account a WHERE a NOT IN (SELECT accStat.account FROM AccountStatistic accStat WHERE accStat.period = :period) AND a.status = :accountStatus")
|
@Query("SELECT a FROM Account a WHERE a NOT IN (SELECT accStat.account FROM AccountStatistic accStat WHERE accStat.period = :period) AND a.status = :accountStatus")
|
||||||
Iterable<Account> getAccountsWithoutStatisticInPeriod(Period period, AccountStatus accountStatus);
|
Iterable<Account> getAccountsWithoutStatisticInPeriod(Period period, AccountStatus accountStatus);
|
||||||
|
|
||||||
|
@Query("SELECT accStat FROM AccountStatistic accStat WHERE accStat.period = :period")
|
||||||
|
Iterable<AccountStatistic> getAllForPeriod(Period period);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ public class AccountStatisticService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method creates an {@link AccountStatistic}s entry with from and to spending <code>0</code>,
|
* This method creates an {@link AccountStatistic}s entry with from and to spending <code>0</code>, for every
|
||||||
* for every account not used in a booking in the given period.
|
* account not used in a booking in the given period.
|
||||||
*
|
*
|
||||||
* @param period to generate the null statistic entries for
|
* @param period to generate the null statistic entries for
|
||||||
*/
|
*/
|
||||||
@@ -111,4 +111,19 @@ public class AccountStatisticService {
|
|||||||
|
|
||||||
return accountStatistic;
|
return accountStatistic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(propagation = Propagation.REQUIRED)
|
||||||
|
public void takeOverEndBalances(Period period) {
|
||||||
|
final Iterable<AccountStatistic> allForPeriod = this.accountStatisticRepository.getAllForPeriod(period);
|
||||||
|
|
||||||
|
this.accountStatisticRepository.saveAll(IterableUtils.toList(allForPeriod)
|
||||||
|
.stream()
|
||||||
|
.map(as -> {
|
||||||
|
as.setEndBalance(as.getAccount().getCurrentBalance());
|
||||||
|
return as;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ public class PeriodService {
|
|||||||
|
|
||||||
this.accountStatisticService.generateNullStatisticsForUnusedAccounts(currentPeriod);
|
this.accountStatisticService.generateNullStatisticsForUnusedAccounts(currentPeriod);
|
||||||
|
|
||||||
|
this.accountStatisticService.takeOverEndBalances(currentPeriod);
|
||||||
|
|
||||||
response = ResponseReason.OK;
|
response = ResponseReason.OK;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Could not close current expense period!", e);
|
LOGGER.error("Could not close current expense period!", e);
|
||||||
@@ -90,6 +92,8 @@ public class PeriodService {
|
|||||||
|
|
||||||
this.periodRepository.save(expenseYearPeriod);
|
this.periodRepository.save(expenseYearPeriod);
|
||||||
this.periodRepository.save(nextExpenseYearPeriod);
|
this.periodRepository.save(nextExpenseYearPeriod);
|
||||||
|
|
||||||
|
this.accountStatisticService.takeOverEndBalances(expenseYearPeriod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE account_statistic
|
||||||
|
ADD COLUMN end_balance BIGINT;
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
|
v27 -> v28:
|
||||||
|
- Add account end balance to account statistics for closed expense periods. This is currently not visible in the UI
|
||||||
|
|
||||||
v26 -> v27:
|
v26 -> v27:
|
||||||
- Changed sort order of accounts in overview page. The accounts are now sorted by the account type first (BCILES), then
|
- Changed sort order of accounts in overview page. The accounts are now sorted by the account type first (BCILES), then
|
||||||
by the account group name and then by the account ID, leading to an overall more organic order of accounts
|
by the account group name and then by the account ID, leading to an overall more organic order of accounts
|
||||||
|
|||||||
Reference in New Issue
Block a user