Skip to content

Credit event dispute flow for incorrect partner reports #59

Description

@Cbiux

Summary

Implement credit event dispute flow so users/operators can flag incorrect partner reports and reverse score impact without manual DB edits.

Builds on admin dashboard (#43), recalc CLI (#50), and score history (#34).


Problem

Partner platforms (#17, #18) may report wrong wallet, amount, or duplicate events. Today there is no structured dispute — only npm run recalc:scores for batch fixes.


Proposed design

Schema

Add to CreditEvent:

disputed      Boolean  @default(false)
disputeReason String?
disputedAt    DateTime?
disputedBy    String?   // admin operator id or "user"

API

Endpoint Auth Action
POST /api/admin/events/{id}/dispute X-Admin-Key Mark disputed + reason
POST /api/admin/events/{id}/reinstate X-Admin-Key Clear dispute
POST /api/admin/users/{wallet}/recalculate X-Admin-Key Trigger recalc for one wallet

Disputed events excluded from score sum in score-recalc.service.ts.

Admin UI

Extend /admin — dispute button on recent events table, recalc trigger.


Acceptance criteria

  • Disputing an event excludes it from recalculateUserScore
  • User score updates after admin recalc
  • Audit fields stored on CreditEvent
  • Unit tests for recalc with disputed events
  • Swagger docs for admin dispute routes
  • Migration committed

How to verify

# Seed event, dispute it, recalc
npm run recalc:scores --prefix Server -- --wallet G... --dry-run
npm run recalc:scores --prefix Server -- --wallet G... --apply

Related

  • Server/scripts/recalculate-scores.ts
  • Server/src/services/score-recalc.service.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSPart of the GrantFox OSS programMaybe RewardedThis issue may receive a reward or bountyOfficial CampaignPart of an official ZCore campaignenhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions