Skip to content
Snippets Groups Projects
Commit a6c24056 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

Fixed #347 - account sum is wrong

parent b97b9ed5
No related branches found
No related tags found
No related merge requests found
Pipeline #304 passed
......@@ -46,7 +46,7 @@ public class HelpersService
private AccountService accountService;
@Autowired
private TransactionRepository transactionRepository;
private TransactionService transactionService;
public String getCurrencyString(int amount)
{
......@@ -234,9 +234,15 @@ public class HelpersService
return sum;
}
public DateTime getCurrentDate()
{
return DateTime.now();
}
public int getAccountBudget()
{
List<Transaction> transactions = transactionRepository.findAllByAccount(getCurrentAccount());
List<Transaction> transactions = transactionService.getTransactionsForAccountUntilDate(getCurrentAccount(), getCurrentDate());
int sum = 0;
for(Transaction transaction : transactions)
{
......
......@@ -76,6 +76,12 @@ public class TransactionService implements Resetable
return transactionRepository.findAllByAccountAndDateBetweenOrderByDateDesc(account, startDate, endDate);
}
public List<Transaction> getTransactionsForAccountUntilDate(Account account, DateTime date)
{
DateTime startDate = DateTime.now().withYear(1900).withMonthOfYear(1).withDayOfMonth(1);
return transactionRepository.findAllByAccountAndDateBetweenOrderByDateDesc(account, startDate, date);
}
private int getRest(Account account, DateTime endDate)
{
DateTime startDate = DateTime.now().withYear(2000).withMonthOfYear(1).withDayOfMonth(1);
......
......@@ -147,6 +147,7 @@ settings.database.delete.verification=Best
account.new.label.name=Name
account.default.name=Standardkonto
account.budget.asof=Stand
transaction.new.label.name=Name
transaction.new.label.amount=Betrag
......
......@@ -148,6 +148,7 @@ settings.database.delete.verification=Verification Code
account.new.label.name=Name
account.default.name=Default Account
account.budget.asof=as of
transaction.new.label.name=Name
transaction.new.label.amount=Amount
......
......@@ -422,6 +422,10 @@ input[type="radio"]:not(:checked) + label::before, [type="radio"]:not(:checked)
font-size: 20px !important;
}
.account-budget-date {
font-size: 12px !important;
}
.account-navbar {
padding: 5px 32px 12px 32px;
}
......
......@@ -364,6 +364,10 @@ input[type="radio"]:checked + label::after, [type="radio"].with-gap:checked + la
font-size: 20px !important;
}
.account-budget-date {
font-size: 12px !important;
}
.account-navbar {
padding: 5px 32px 12px 32px;
}
......
......@@ -63,6 +63,7 @@
<#else>
<div class="account-budget ${greenTextColor}">${helpers.getCurrencyString(accountBudget)}</div>
</#if>
<div class="account-budget-date text-color">(${locale.getString("account.budget.asof")}: ${helpers.getDateString(helpers.getCurrentDate())})</div>
</div>
</#macro>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment