feat: implement subscription revenue recognition accounting#308
Merged
Smartdevs17 merged 3 commits intoSmartdevs17:mainfrom Apr 25, 2026
Merged
Conversation
- 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.
|
@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! 🚀 |
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #199