Skip to content

fix(revenue): persist issuer_id and reported_by in submitReport - #1354

Open
innocentharuna wants to merge 1 commit into
RevoraOrg:masterfrom
innocentharuna:fix/1257-revenue-report-issuer
Open

innocentharuna wants to merge 1 commit into
RevoraOrg:masterfrom
innocentharuna:fix/1257-revenue-report-issuer

Conversation

@innocentharuna

@innocentharuna innocentharuna commented Oct 26, 2026 •

Copy link
Copy Markdown

Closes #1257

Replaces #1306, which I closed because it included unrelated files that shouldn't have been there.

Changes

  • RevenueService.submitReport now sets issuer_id (from issuerId) and reported_by in the insert payload. A new optional reportedBy input defaults to issuerId.
  • RevenueHandler passes the authenticated user (req.user.id) as reportedBy on both submit routes.
  • The repository create call still gets the transaction client.

Separately, revenueService.ts used isPositiveDecimalAmount without importing it, so 12 revenue tests were already failing on master. I added the one-line import so CI can go green.

Tests

  • revenueService.test.ts:
    • asserts the repository receives issuer_id and reported_by
    • asserts a separate reportedBy is used when provided
    • a regression test with a mocked repo that rejects null issuer_id/reported_by
  • All three fail on master and pass here.
  • revenueHandler.test.ts: the expected service args now include reportedBy.

npx jest src/services/revenueService.test.ts src/handlers/revenueHandler.test.ts: 42/42 passing. tsc --noEmit and eslint report nothing for the changed files.

submitReport built the insert payload without issuer_id and reported_by,
both NOT NULL in migration 016, so every real submission failed with a
not-null violation. Populate both columns; the handler now threads the
authenticated user through as reportedBy.

Also add the missing isPositiveDecimalAmount import in revenueService.ts,
which was failing the existing revenue tests on master.

Closes RevoraOrg#1257

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@innocentharuna

Copy link
Copy Markdown
Author

@thlpkee20-wq please merge

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.

fix(revenue): submitReport never sets issuer_id/reported_by, so every revenue report insert violates NOT NULL

1 participant