-
Notifications
You must be signed in to change notification settings - Fork 19
Description
Bug
getAdminTransactions in RealUnitService returns only 3 of 32 actual REALU transactions on dev because it queries via transaction_request join.
Root Cause
TransactionService.getByAssetId() (src/subdomains/supporting/payment/services/transaction.service.ts:259) joins transaction → transaction_request and filters by request.targetId / request.sourceId:
.leftJoinAndSelect('transaction.request', 'request')
.where('transaction.type IS NOT NULL')
.andWhere(
new Brackets((qb) =>
qb
.where('request.type = :buyType AND request.targetId = :assetId', { buyType: 'Buy', assetId })
.orWhere('request.type = :sellType AND request.sourceId = :assetId', { sellType: 'Sell', assetId }),
),
)However, most BuyCrypto transactions have requestId = NULL in the transaction table (21 of 22 on dev). These transactions are linked to REALU only via buy_crypto.transactionId → buy.assetId, a path the current query doesn't follow.
Dev DB Analysis
| Total | Found by current query | |
|---|---|---|
| BuyCrypto (Buy) | 22 | 1 |
| BuyFiat (Sell) | 10 | 2 |
| Total | 32 | 3 |
Expected Behavior
All completed REALU transactions should appear in the admin "Received Transactions" view, regardless of whether they have a transaction_request linked.
Suggested Fix
Extend getByAssetId() to also find transactions via buy_crypto.transactionId / buy_fiat.transactionId when requestId is NULL, e.g.:
-- Current path (works for 3)
transaction → transaction_request (targetId/sourceId = assetId)
-- Missing path (needed for the other 29)
transaction ← buy_crypto.transactionId → buy.assetId = assetId
transaction ← buy_fiat.transactionId → crypto_input.assetId = assetId