diff --git a/lib/data/models/payment_model.dart b/lib/data/models/payment_model.dart index 6a2735c4e..8608ff8ec 100644 --- a/lib/data/models/payment_model.dart +++ b/lib/data/models/payment_model.dart @@ -358,6 +358,21 @@ abstract class PaymentEntity extends Object return response; } + @override + bool matchesStatuses(BuiltList statuses) { + if (statuses.isEmpty) { + return true; + } + + for (final status in statuses) { + if (status.id == statusId || status.id == calculatedStatusId) { + return true; + } + } + + return false; + } + @override bool matchesFilter(String filter) { return matchesStrings( diff --git a/lib/redux/payment/payment_reducer.dart b/lib/redux/payment/payment_reducer.dart index d0e6b5b85..af6c8261a 100644 --- a/lib/redux/payment/payment_reducer.dart +++ b/lib/redux/payment/payment_reducer.dart @@ -55,6 +55,7 @@ Reducer selectedIdReducer = combineReducers([ TypedReducer((selectedId, action) => ''), TypedReducer((selectedId, action) => ''), TypedReducer((selectedId, action) => ''), + TypedReducer((selectedId, action) => ''), TypedReducer((selectedId, action) => ''), TypedReducer((selectedId, action) => ''), TypedReducer((selectedId, action) => ''), @@ -100,6 +101,7 @@ PaymentEntity _updateEditing(PaymentEntity payment, dynamic action) { final paymentListReducer = combineReducers([ TypedReducer(_sortPayments), TypedReducer(_filterPaymentsByState), + TypedReducer(_filterPaymentsByStatus), TypedReducer(_filterPayments), TypedReducer(_filterPaymentsByCustom1), TypedReducer(_filterPaymentsByCustom2), @@ -171,6 +173,16 @@ ListUIState _filterPaymentsByState( } } +ListUIState _filterPaymentsByStatus( + ListUIState paymentListState, FilterPaymentsByStatus action) { + if (paymentListState.statusFilters.contains(action.status)) { + return paymentListState + .rebuild((b) => b..statusFilters.remove(action.status)); + } else { + return paymentListState.rebuild((b) => b..statusFilters.add(action.status)); + } +} + ListUIState _filterPayments( ListUIState paymentListState, FilterPayments action) { return paymentListState.rebuild((b) => b diff --git a/lib/redux/payment/payment_selectors.dart b/lib/redux/payment/payment_selectors.dart index 31238ef68..dcfd59f93 100644 --- a/lib/redux/payment/payment_selectors.dart +++ b/lib/redux/payment/payment_selectors.dart @@ -110,6 +110,10 @@ List filteredPaymentsSelector( return false; } + if (!payment.matchesStatuses(paymentListState.statusFilters)) { + return false; + } + final client = clientMap[payment.clientId] ?? ClientEntity(id: payment.clientId); diff --git a/lib/ui/payment/payment_screen.dart b/lib/ui/payment/payment_screen.dart index 8fc83f7be..fba6a5ab5 100644 --- a/lib/ui/payment/payment_screen.dart +++ b/lib/ui/payment/payment_screen.dart @@ -38,13 +38,8 @@ class PaymentScreen extends StatelessWidget { final statuses = [ PaymentStatusEntity().rebuild( (b) => b - ..id = kPaymentStatusPartiallyUnapplied - ..name = localization.partiallyUnapplied, - ), - PaymentStatusEntity().rebuild( - (b) => b - ..id = kPaymentStatusUnapplied - ..name = localization.unapplied, + ..id = kPaymentStatusCompleted + ..name = localization.completed, ), PaymentStatusEntity().rebuild( (b) => b @@ -61,11 +56,6 @@ class PaymentScreen extends StatelessWidget { ..id = kPaymentStatusFailed ..name = localization.failed, ), - PaymentStatusEntity().rebuild( - (b) => b - ..id = kPaymentStatusCompleted - ..name = localization.completed, - ), PaymentStatusEntity().rebuild( (b) => b ..id = kPaymentStatusPartiallyRefunded @@ -76,6 +66,16 @@ class PaymentScreen extends StatelessWidget { ..id = kPaymentStatusRefunded ..name = localization.refunded, ), + PaymentStatusEntity().rebuild( + (b) => b + ..id = kPaymentStatusUnapplied + ..name = localization.unapplied, + ), + PaymentStatusEntity().rebuild( + (b) => b + ..id = kPaymentStatusPartiallyUnapplied + ..name = localization.partiallyUnapplied, + ), ]; return ListScaffold(