Skip to content

Commit

Permalink
Merge pull request #177 from afk11/fix-postgres-balances-journal
Browse files Browse the repository at this point in the history
Fix: getBalances query should always join transacc table so journal restriction is applied
  • Loading branch information
ar authored Sep 17, 2020
2 parents 689917b + e94d98e commit 13757c8
Showing 1 changed file with 5 additions and 5 deletions.
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

0 comments on commit 13757c8

Please sign in to comment.