Skip to content

fly2189: Fix financial API bug on /reports/transactions#944

Open
AndresQuijano wants to merge 1 commit intov2.5.1from
fly2189_financial_api_bug
Open

fly2189: Fix financial API bug on /reports/transactions#944
AndresQuijano wants to merge 1 commit intov2.5.1from
fly2189_financial_api_bug

Conversation

@AndresQuijano
Copy link
Copy Markdown
Contributor

@AndresQuijano AndresQuijano commented Apr 3, 2026

What

The endpoint /reports/transactions was returning a completely broken response. This PR fixes that endpoint.

Why

Improve app quality

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change
  • Documentation update
  • Refactoring (no functional changes, no api changes)
  • Performance improvement
  • Test updates
  • Security fix
  • Deployment/Infrastructure changes

Affected part of the project

  • Management UI / API
  • PegIn flow
  • PegOut flow
  • Utility scripts
  • Configuration files
  • Metrics and alerting

Related Issues

Jira ticket

How to test

Since this probably won't be deployed in dev at the moment of testing I recommend this:

mongodump --uri='mongodb://root:root@flyover-01-dev.aws-us-east-1.flyover.rif.technology/?authSource=admin' --db=flyover --out=./dump
mongorestore --uri='mongodb://root:root@localhost:27017/?authSource=admin' ./dump

-Go to /management and authenticate using the dev credentials
-Run the test. Examples:
http://localhost:8080/reports/transactions?type=pegout&startDate=2025-01-01&endDate=2026-01-29&page=4&perPage=5
http://localhost:8080/reports/transactions?type=pegout&startDate=2025-01-01&endDate=2026-01-29&page=1&perPage=50
http://localhost:8080/reports/transactions?type=pegin&startDate=2025-01-01&endDate=2026-01-29&page=4&perPage=5

Pay special attention to pagination metadata

Reviewer Guidelines

The issue here was related with the way the repo object for pegin and pegout were managing the query. Most of the changes where made in the repo layer. Remember that this endpoint is supposed to take into account only the accepted quotes, so if a quote does not have a corresponding object in retainedQuote, in the DB, the endpoint must ignore it.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA ed66510.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

@AndresQuijano AndresQuijano marked this pull request as ready for review April 3, 2026 14:54
@AndresQuijano AndresQuijano requested a review from a team as a code owner April 3, 2026 14:54
Copy link
Copy Markdown
Collaborator

@Hakob23 Hakob23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ListQuotesByDateRange, countQuotesWithRetainedInDateRange, listQuotesByDateRangeDateMatch, listQuotesByDateRangeLookupStage, listQuotesByDateRangeHasRetainedMatch , and listQuotesByDateRangePipelinePrefix functions are the same both inside Pegin and Pegout
and
peginListQuotesByDateRangeAggRow and pegoutListQuotesByDateRangeAggRow have the same body inside Pegin_test and Pegout_test respectively.
Unless there is an explicit restriction to keep pegin and pegout flows separate, we could allow ourselves to have a general adapter for those(at least for pegin and pegout not for the tests).

This can be a little out of the scope of this PR, so we can resolve it in a separate one.

Other this, and this comment , I have run the tests, they pass. After your response for these comments we can approve the pr. LGTM

result := make([]quote.PeginQuoteWithRetained, 0)
logDbInteraction(Read, result)
return result, 0, nil
dataPipeline := append(repo.listQuotesByDateRangePipelinePrefix(dateMatch),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't we do the appending here and on line 403 together? I might be missing something, so just asking

result := make([]quote.PegoutQuoteWithRetained, 0)
logDbInteraction(Read, result)
return result, 0, nil
dataPipeline := append(repo.listQuotesByDateRangePipelinePrefix(dateMatch),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants