-
-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Mobile App] Refactore past and future payment calculation in payment page #1044
Conversation
…calculateFuturePayments" and "_calculatePastPayments" within the payment page
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
📝 WalkthroughWalkthroughThe changes refactor the payment calculation logic in the PaymentsPage. A new helper method, Changes
Sequence Diagram(s)sequenceDiagram
participant PP as _calculatePastPayments
participant Helper as _getAllPaidOrConfirmedPayments
participant Mapped as MappedPayments
PP ->> Helper: Call with full mappedPayments
Helper -->> PP: Return filteredPayments
PP ->> PP: Sum amounts from filteredPayments
PP -->> Caller: Return total amount with currency
sequenceDiagram
participant FP as _calculateFuturePayments
participant Helper as _getAllPaidOrConfirmedPayments
participant Mapped as MappedPayments
FP ->> Helper: Call with full mappedPayments
Helper -->> FP: Return filteredPayments
FP ->> FP: Count filteredPayments
FP -->> Caller: Return payment count
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
recipients_app/lib/view/pages/payments_page.dart (2)
150-151
: Extract currency conversion factor to a constant.The SLL to SLE conversion factor should be defined as a named constant for better maintainability.
+ static const _SLL_TO_SLE_CONVERSION_FACTOR = 1000; + String _calculatePastPayments(List<MappedPayment> mappedPayments) { var total = 0; final List<MappedPayment> paidOrConfirmedPayments = _getAllPaidOrConfirmedPayments(mappedPayments); for (final payment in paidOrConfirmedPayments) { - final factor = (payment.payment.currency == "SLL") ? 1000 : 1; + final factor = (payment.payment.currency == "SLL") ? _SLL_TO_SLE_CONVERSION_FACTOR : 1; total += (payment.payment.amount ?? 0) ~/ factor;
166-174
: Consider adding underscore prefix to private method.The helper method effectively encapsulates the payment filtering logic. Since it's a private implementation detail, consider prefixing it with an underscore.
- List<MappedPayment> _getAllPaidOrConfirmedPayments(List<MappedPayment> mappedPayments) { + List<MappedPayment> __getAllPaidOrConfirmedPayments(List<MappedPayment> mappedPayments) {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
recipients_app/lib/view/pages/payments_page.dart
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Test shared code
- GitHub Check: Prettify
- GitHub Check: Security checks (typescript)
🔇 Additional comments (2)
recipients_app/lib/view/pages/payments_page.dart (2)
157-164
: LGTM! Clear and efficient implementation.The refactored code effectively calculates future payments based on program duration and confirmed payment count.
146-174
: Great refactoring that improves code maintainability!The extraction of payment filtering logic into a helper method effectively reduces duplication while maintaining clear responsibilities.
Summary by CodeRabbit