fix txs by account pagination bug

This commit is contained in:
Patrick Nagurny
2021-01-28 12:47:49 -07:00
parent 2f07dd4cda
commit df6901ef8a

View File

@@ -2,11 +2,12 @@ package db
import ( import (
"database/sql" "database/sql"
"github.com/openaccounting/oa-server/core/model/types"
"github.com/openaccounting/oa-server/core/util"
"strconv" "strconv"
"strings" "strings"
"time" "time"
"github.com/openaccounting/oa-server/core/model/types"
"github.com/openaccounting/oa-server/core/util"
) )
const txFields = "LOWER(HEX(id)),LOWER(HEX(orgId)),LOWER(HEX(userId)),date,inserted,updated,description,data,deleted" const txFields = "LOWER(HEX(id)),LOWER(HEX(orgId)),LOWER(HEX(userId)),date,inserted,updated,description,data,deleted"
@@ -106,7 +107,7 @@ func (db *DB) GetTransactionById(id string) (*types.Transaction, error) {
} }
func (db *DB) GetTransactionsByAccount(accountId string, options *types.QueryOptions) ([]*types.Transaction, error) { func (db *DB) GetTransactionsByAccount(accountId string, options *types.QueryOptions) ([]*types.Transaction, error) {
query := "SELECT LOWER(HEX(s.transactionId)) FROM split s" query := "SELECT DISTINCT LOWER(HEX(s.transactionId)),s.date,s.inserted,s.updated FROM split s"
if options.DescriptionStartsWith != "" { if options.DescriptionStartsWith != "" {
query = query + " JOIN transaction t ON t.id = s.transactionId" query = query + " JOIN transaction t ON t.id = s.transactionId"
@@ -128,7 +129,10 @@ func (db *DB) GetTransactionsByAccount(accountId string, options *types.QueryOpt
for rows.Next() { for rows.Next() {
var id string var id string
err = rows.Scan(&id) var date int64
var inserted int64
var updated int64
err = rows.Scan(&id, &date, &inserted, &updated)
if err != nil { if err != nil {
return nil, err return nil, err
} }