Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: getBalances query should always join transacc table so journal restriction is applied #177

Merged
merged 1 commit into from
Sep 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions modules/minigl/src/main/java/org/jpos/gl/GLSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -1151,10 +1151,9 @@ else if (acct.isFinalAccount()) {
checkPermission (GLPermission.READ, journal);
BigDecimal balance[] = { ZERO, Z };
BalanceCache bcache = null;
if (date != null) {
select.append(", transacc as txn\n");
}
else if (!ignoreBalanceCache) {
select.append(", transacc as txn\n");

if (!ignoreBalanceCache) {
short[] layersCopy = Arrays.copyOf(layers,layers.length);
bcache = getBalanceCache(journal, acct, layersCopy);
if (maxId > 0 && bcache != null && bcache.getRef() > maxId)
Expand All @@ -1180,8 +1179,8 @@ else if (acct.isChart()) {
where(qs, "entry.account = acct.id");
where(qs, "acct.code like :code");
}
where(qs, "(entry.transaction = txn.id and txn.journal = :journal)\n");
if (date != null) {
where(qs, "entry.transaction = txn.id\n");
where(qs, "txn.postDate < :date");
}
where(qs, "entry.layer in");
Expand All @@ -1197,6 +1196,7 @@ else if (acct.isChart()) {
else {
q.setParameter("code", acct.getCode() + "%");
}
q.setParameter("journal", journal.getId());
if (date != null) {
q.setParameter("date", inclusive ? Util.tomorrow(date) : date);
}
Expand Down