Skip to content
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] Resolve incorrect payment calculations for past and future payments (#869) #1040

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions recipients_app/lib/view/pages/payments_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ class _PaymentsPageState extends State<PaymentsPage> {
var total = 0;

for (final mappedPayment in mappedPayments) {
final paymentStatus = mappedPayment.payment.status;
if (paymentStatus != PaymentStatus.paid && paymentStatus != PaymentStatus.confirmed) continue;

// some of the users still have SLL from begining of the program,
// we will change it to SLE
final factor = (mappedPayment.payment.currency == "SLL") ? 1000 : 1;
Expand All @@ -154,10 +157,17 @@ class _PaymentsPageState extends State<PaymentsPage> {
}

String _calculateFuturePayments(List<MappedPayment> mappedPayments) {
KarinBerg marked this conversation as resolved.
Show resolved Hide resolved
final paidOrConfirmedPayments = mappedPayments.where(
(payment) {
final paymentStatus = payment.payment.status;
return paymentStatus == PaymentStatus.paid || paymentStatus == PaymentStatus.confirmed;
},
).toList();
KarinBerg marked this conversation as resolved.
Show resolved Hide resolved

// due to problem that payment amount can change we need to calculate
// the future payments without calculation of previous payments
final futurePayments = (kProgramDurationMonths - mappedPayments.length) * kCurrentPaymentAmount;
final futurePayments = (kProgramDurationMonths - paidOrConfirmedPayments.length) * kCurrentPaymentAmount;
floodoo marked this conversation as resolved.
Show resolved Hide resolved

return "${mappedPayments.firstOrNull?.payment.currency ?? "SLE"} $futurePayments";
return "${paidOrConfirmedPayments.firstOrNull?.payment.currency ?? "SLE"} $futurePayments";
}
}
Loading