Conversation
What was broken PM-4623's wallet-admin engagement payment flow was already implemented in the current dev lineage, but tc-finance-api validation could not complete because winnings creation no longer satisfied Prisma's JSON input typing after the hours-worked attribute support was added. Root cause The winnings attribute helper used broad object/null typing, while the create path now needs Prisma-compatible JSON input values and a typed payroll attribute lookup. What was changed Updated the winnings attribute normalization helper to return Prisma-compatible JSON input, return undefined instead of null when no attributes are present, and narrowed the create-path attribute handling so the hours-worked and payroll lookups remain type-safe without changing runtime behavior. Any added/updated tests No test files were changed. Re-ran the existing platform-ui and tc-finance-api test suites, plus the required lint/build commands.
PM-4429 - use metadata for taas payments
PM-4623: validate wallet-admin engagement payment details flow
What was broken Wallet-admin payment details only enriched engagement payments when the winning could be resolved through the assignment context endpoint. Payments whose `external_id` stored an engagement id instead of an assignment id showed work-log data but missed the engagement details needed to build the Work Manager assignee link and assignment context section. Root cause The admin payment-details flow treated the stored identifier as an assignment id and stopped after the assignment-context lookup failed, even though some winnings only retained the parent engagement id. Numeric assignment ids in winning attributes also needed to be normalized before lookup. What was changed Added typed engagement API models and a direct engagement lookup helper in the Topcoder engagements client. Updated the admin payment-details service to normalize numeric assignment ids, try the assignment-context endpoint first, and then fall back to loading the engagement and matching the correct assignment by assignment id or winner id when needed. Any added/updated tests Extended the admin service spec with regressions for the engagement-id fallback path and for numeric assignment ids stored in winning attributes.
…tering PM-4657 - Role‑Based Access Control in Wallet Admin
PM-4623: fall back to engagement lookup for payment details
PM-4773 - topgear payments
…o PM-4789_payment-migrations
What was broken The wallet-admin payments CSV download still did not include the Payment Creator column after the earlier fix. QA could see the creator in payment details, but the exported report remained unchanged. Root cause The previous fix only populated payment creator data for the payment-details endpoint. The CSV export path in `admin.controller.ts` assembled its own columns and rows and never added the creator field or resolved creator handles for engagement payments. What was changed Updated the winnings export controller to collect engagement payment creator member IDs, resolve their handles, and emit a Payment Creator column before Billing Account. The export leaves that column blank for non-engagement payment types. Any added/updated tests Added `src/api/admin/admin.controller.spec.ts` to verify the CSV header includes Payment Creator and that only engagement payment rows populate it.
PM-4822: add Payment Creator to wallet export CSV
…ions PM-4789 payment migrations
There was a problem hiding this comment.
Pull request overview
This PR packages the April production release work across finance winnings, access control, and Topcoder engagement enrichment, including new winnings categories and supporting Prisma migrations/client regeneration.
Changes:
- Added TAAS/TOPGEAR winnings categories (DTO + Prisma schema) with backfill migrations, and mapped
payment_typechallenge metadata to these categories. - Introduced the
Wipro TaaS Adminrole and access-control provider, including controller role wiring and tests. - Added an admin “payment details” endpoint that enriches engagement payments with engagement/assignment context and exposes work-log + creator-handle info for wallet-admin UI.
Reviewed changes
Copilot reviewed 37 out of 48 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/shared/topcoder/topcoder.module.ts | Registers/exports the new engagements Topcoder client service. |
| src/shared/topcoder/engagements.service.ts | Adds Topcoder engagements API client for engagement + assignment context lookups. |
| src/shared/access-control/wipro-taas-admin.provider.ts | New role access provider that scopes/validates access to TAAS payments. |
| src/shared/access-control/wipro-taas-admin.provider.spec.ts | Unit tests for TAAS admin provider behavior. |
| src/shared/access-control/index.ts | Exports the new TAAS admin provider. |
| src/shared/access-control/access-control.service.ts | Extends “Payment Admin overrides scoped approvers” logic to include Wipro TaaS Admin. |
| src/shared/access-control/access-control.service.spec.ts | Tests for Wipro TaaS Admin filter application and override behavior. |
| src/shared/access-control/access-control.module.ts | Registers the new access provider in the module registrar. |
| src/dto/winning.dto.ts | Adds TAAS/TOPGEAR categories and createdBy field to winning DTO. |
| src/core/auth/auth.constants.ts | Introduces Role.WiproTaasAdmin. |
| src/api/winnings/winnings.service.ts | Tightens attribute typing/normalization and payroll flag extraction. |
| src/api/wallet/wallet.controller.ts | Adds Wipro TaaS Admin role access to wallet endpoint. |
| src/api/repository/winnings.repo.ts | Populates createdBy from payment creator when available. |
| src/api/challenges/challenges.service.ts | Maps payment_type metadata to TAAS/TOPGEAR categories when generating winnings. |
| src/api/challenges/challenges.service.spec.ts | Tests for TAAS/TOPGEAR metadata mapping. |
| src/api/admin/dto/payment-details.dto.ts | New DTOs for wallet-admin payment details payload. |
| src/api/admin/admin.service.ts | Adds getWinningPaymentDetails and engagement enrichment helpers. |
| src/api/admin/admin.service.spec.ts | Unit tests for new payment details enrichment behavior and fallbacks. |
| src/api/admin/admin.controller.ts | Adds payment-details endpoint + export CSV “Payment Creator” column + role updates. |
| src/api/admin/admin.controller.spec.ts | Tests for export CSV including Payment Creator column only for engagement payments. |
| prisma/schema.prisma | Adds TAAS/TOPGEAR winnings category enum values. |
| prisma/migrations/20260331120000_add_taas_payment_category/migration.sql | Adds TAAS_PAYMENT enum value. |
| prisma/migrations/20260407120000_add_topgear_payment_category/migration.sql | Adds TOPGEAR_PAYMENT enum value. |
| prisma/migrations/20260408120000_backfill_taas_category_from_metadata/migration.sql | Backfills TAAS category based on challenge metadata. |
| prisma/migrations/20260408130000_backfill_topgear_category_from_billing_account/migration.sql | Backfills TOPGEAR category based on billing accounts. |
| packages/finance-prisma-client/wasm.js | Regenerated Prisma client artifact reflecting schema/category updates. |
| packages/finance-prisma-client/wasm-worker-loader.mjs | Regenerated Prisma client artifact (adds biome ignore). |
| packages/finance-prisma-client/wasm-edge-light-loader.mjs | Regenerated Prisma client artifact (adds biome ignore). |
| packages/finance-prisma-client/schema.prisma | Regenerated packaged Prisma schema with new enum values/index. |
| packages/finance-prisma-client/runtime/library.js | Regenerated Prisma runtime artifact (adds biome ignore + version bump). |
| packages/finance-prisma-client/runtime/index-browser.js | Regenerated Prisma runtime artifact (adds biome ignore). |
| packages/finance-prisma-client/query_engine_bg.js | Regenerated Prisma engine JS glue artifact. |
| packages/finance-prisma-client/package.json | Prisma client package regen/version bump. |
| packages/finance-prisma-client/index.d.ts | Regenerated Prisma typings for new enum values/version. |
| packages/finance-prisma-client/index-browser.js | Regenerated Prisma browser entry artifact (adds biome ignore + enum update). |
| packages/finance-prisma-client/default.js | Regenerated Prisma entry artifact (adds biome ignore). |
| packages/finance-prisma-client/client.js | Regenerated Prisma entry artifact (adds biome ignore). |
| .circleci/config.yml | Updates CircleCI branch filter for the prod workflow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "previewFeatures": [], | ||
| "sourceFilePath": "/Users/hentrymartin/development/tc-finance-api/prisma/schema.prisma", | ||
| "sourceFilePath": "/home/vasea/work/topcoder/tc-finance-api/prisma/schema.prisma", | ||
| "isCustomOutput": true |
There was a problem hiding this comment.
This generated Prisma client file embeds an absolute local filesystem path in sourceFilePath. This causes noisy diffs between environments and can leak workstation paths into the repo. Consider making the generation output deterministic or stripping/sanitizing these fields post-generate if this package is committed.
| const paymentCreatorHandle = await this.getPaymentCreatorHandle( | ||
| winning.created_by, | ||
| ); |
There was a problem hiding this comment.
paymentCreatorHandle is derived from winning.created_by, but for payments the creator is typically stored on the related payment.created_by (and this PR already introduces createdBy derived from payment?.[0]?.created_by in WinningsRepository). As-is, the payment details endpoint can show the wrong creator when a payment record was created/updated by someone other than the winning row creator. Consider fetching the latest payment for the winning and prefer its created_by (falling back to winnings.created_by if no payment exists).
| } catch (error) { | ||
| this.logger.warn( | ||
| `Failed to enrich winning ${winningsId} with assignment context`, | ||
| error instanceof Error ? error.message : error, | ||
| ); | ||
| } |
There was a problem hiding this comment.
getAssignmentContextById failures are treated as warnings, but the method intentionally calls the assignment-context endpoint even when external_id may contain an engagement id (see the spec that expects this failure and fallback). This will generate warning-level log noise in normal operation. Consider either detecting engagement vs assignment ids (and skipping the context call when it’s clearly an engagement id), or downgrading expected 404/validation failures to debug while keeping unexpected errors as warn/error.
| "output": { | ||
| "value": "/Users/hentrymartin/development/tc-finance-api/packages/finance-prisma-client", | ||
| "value": "/home/vasea/work/topcoder/tc-finance-api/packages/finance-prisma-client", | ||
| "fromEnvVar": null |
There was a problem hiding this comment.
This generated Prisma client file embeds an absolute local filesystem path in the generator output.value. This causes noisy diffs between environments and can leak workstation paths into the repo. If the generated client must be committed, consider making the generation output deterministic or stripping/sanitizing these fields post-generate.
https://topcoder.atlassian.net/browse/PM-4429
https://topcoder.atlassian.net/browse/PM-4623
https://topcoder.atlassian.net/browse/PM-4657
https://topcoder.atlassian.net/browse/PM-4773
https://topcoder.atlassian.net/browse/PM-4822