Skip to content

feat: show post-settlement balance in usage logs - #533

Merged
chenyme merged 1 commit into
devfrom
usage
Jul 28, 2026
Merged

feat: show post-settlement balance in usage logs#533
chenyme merged 1 commit into
devfrom
usage

Conversation

@chenyme

@chenyme chenyme commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Add the account balance snapshot after each billing settlement to user and admin usage logs.

  • Store the post-settlement balance with new usage ledger records.
  • Recover historical charged records from existing balance transactions.
  • Keep unavailable historical balances nullable instead of treating them as zero.
  • Display the balance in user usage logs and admin usage logs/details.
  • Preserve negative balances and respect the configured USD/CNY display currency.
  • Use “结算后余额 / Balance after settlement” to clarify that the value is a historical settlement snapshot.

Closes #525

Change type

  • Bug fix
  • Feature
  • Documentation
  • Refactor
  • Configuration / deployment
  • Security hardening
  • Other

Affected areas

  • Frontend / UI
  • Backend / API
  • Authentication / authorization
  • Conversations / streaming
  • Files / RAG / extraction
  • Model routing / providers
  • MCP / tools
  • Billing / payments
  • Admin console
  • Deployment / Docker / configuration
  • Documentation

Verification

  • pnpm --filter @deeix/web lint
  • pnpm --filter @deeix/web typecheck
  • pnpm api:check
  • go test ./...
  • git diff --check
  • pnpm build; not rerun after the final frontend adjustments because the local escalation approval service failed before the command started.

Screenshots, API examples, or logs

No screenshots included.

Unknown historical balances are displayed as -. Negative balances remain visible as negative values.

Configuration, migration, and compatibility notes

  • Adds nullable balance_after_nanousd to billing_usage_ledgers.
  • Existing databases add the column through the standard schema migration process.
  • Historical charged usage records resolve their balance from existing balance transactions.
  • Historical free or subscription-covered records without an authoritative snapshot remain unavailable.
  • Adds nullable balanceAfterNanousd and balanceAfterUSD fields to user and admin usage-log responses.
  • Swagger documentation and generated frontend API contracts were updated.
  • The API change is additive and does not require configuration changes.

Documentation

  • Documentation is not needed for this change.
  • Documentation was updated.
  • Documentation still needs to be updated.

Security and privacy

  • No secrets, tokens, credentials, local config, or personal data are included.
  • User data access remains scoped by authenticated user context unless an admin-only path explicitly requires broader access.
  • Security-sensitive behavior was reviewed, including billing settlement, historical balance lookup, and admin access.

Checklist

  • I searched existing issues and pull requests.
  • Changes are focused and do not include unrelated refactors.
  • Tests or static verification were run where practical.
  • User-facing behavior, deployment steps, API contracts, or configuration changes are documented.
  • Generated artifacts are included only when this project explicitly requires them.
  • Caches, build output, .pyc files, .env files, and local storage data are not committed.

@chenyme chenyme self-assigned this Jul 28, 2026
@chenyme
chenyme merged commit cfe52e2 into dev Jul 28, 2026
11 checks passed
@chenyme
chenyme deleted the usage branch July 28, 2026 10:03
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.

[Feature]: 用户端和管理端调用日志增加剩余余额显示

1 participant