Skip to content

feat: implement subscription revenue recognition accounting#308

Merged
Smartdevs17 merged 3 commits intoSmartdevs17:mainfrom
od-hunter:feat/revenue-recognition-accounting
Apr 25, 2026
Merged

feat: implement subscription revenue recognition accounting#308
Smartdevs17 merged 3 commits intoSmartdevs17:mainfrom
od-hunter:feat/revenue-recognition-accounting

Conversation

@od-hunter
Copy link
Copy Markdown
Contributor

Closes #199

- Add contracts/src/revenue.rs with full revenue recognition module:
  - RevenueRecognitionRule (method + recognition_period)
  - Straight-line and usage-based recognition methods
  - RevenueSchedule / RevenueScheduleEntry types
  - Recognition snapshot and PeriodRevenue analytics types
  - generate_revenue_schedule, recognize_revenue, get_deferred_revenue,
    get_revenue_schedule, get_revenue_analytics_by_period
  - Deduplicating track_merchant_subscription
  - 21 Rust tests covering all paths, edge cases, and multi-element arrangements

- Update contracts/src/lib.rs:
  - Hook revenue schedule generation into charge_subscription
  - Add set_revenue_rule, recognize_revenue, get_deferred_revenue,
    get_revenue_schedule public contract APIs

- Add src/store/accountingStore.ts (Zustand + AsyncStorage):
  - setRecognitionRule / removeRecognitionRule
  - generateRevenueSchedule with straight-line and usage-based support
  - recognizeRevenue with pro-rated partial recognition
  - getDeferredRevenue per merchant
  - getRevenueAnalyticsByPeriod with configurable bucket size

- Add src/screens/RevenueReportScreen.tsx:
  - Recognised / deferred revenue summary cards
  - SVG bar chart by period (month / quarter / year)
  - Per-subscription recognition table
  - Revenue configuration panel (method toggle, simulate charge, reset)

- Add src/store/__tests__/accountingStore.test.ts:
  - 30 Jest tests covering pure helpers and all store actions
  - Edge cases: cancellation mid-period, rule updates, multi-element arrangements

- Wire RevenueReportScreen into bottom tab navigator (Revenue tab)
- Export useAccountingStore from store index
Conflicts resolved:
- contracts/src/lib.rs: kept our version (revenue module depends on it;
  upstream restructured contracts into a workspace but our standalone
  crate remains valid alongside the new structure)
- src/navigation/AppNavigator.tsx: merged upstream's new screens
  (Community, Profile, Segments, Gamification, Settings stack, GDPR,
  Language, Session, Admin, Error dashboards) with our RevenueReportScreen
- src/navigation/types.ts: merged upstream's new route types with our
  RevenueReport and RevenueTab additions
- src/store/index.ts: merged upstream's new store exports
  (useNetworkStore, useCommunityStore) with our useAccountingStore

Note: pre-existing lint errors in upstream files (unresolved module paths
for @shopify/flash-list, i18next, react-i18next) are not introduced by
this branch and exist on upstream/main.
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 24, 2026

@od-hunter Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

- Fix contracts/Cargo.toml: remove duplicate [package] section,
  make it a proper workspace root only
- Move revenue module from contracts/src/ to contracts/subscription/src/
  adapted for the new storage-contract delegation pattern
- Add revenue StorageKey variants to contracts/types/src/lib.rs:
  RevenueRecognitionRule, RevenueSchedule, RevenueDeferredBalance,
  RevenueRecognisedBalance, RevenueMerchantSubscriptions
- Hook revenue schedule generation into charge_subscription in
  contracts/subscription/src/lib.rs
- Add revenue public API to SubTrackrSubscription:
  set_revenue_rule, recognize_revenue, get_deferred_revenue,
  get_revenue_schedule
- Fix clippy::manual_div_ceil in revenue.rs (use .div_ceil())
- Add #[allow(clippy::too_many_arguments)] to subscription and proxy
  crates (pre-existing upstream issue with Soroban contractimpl macro)
- Remove obsolete contracts/src/ directory
- All workspace tests pass, cargo fmt --check clean, clippy -D warnings clean
@Smartdevs17 Smartdevs17 merged commit de0682d into Smartdevs17:main Apr 25, 2026
8 of 17 checks passed
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.

Implement subscription revenue recognition accounting

2 participants