Correct sorty by payment type
This commit is contained in:
parent
4e044ef971
commit
c407206b4f
|
|
@ -231,13 +231,15 @@ abstract class PaymentEntity extends Object
|
||||||
return statusId;
|
return statusId;
|
||||||
}
|
}
|
||||||
|
|
||||||
int compareTo(
|
int compareTo({
|
||||||
{PaymentEntity payment,
|
PaymentEntity payment,
|
||||||
String sortField,
|
String sortField,
|
||||||
bool sortAscending,
|
bool sortAscending,
|
||||||
BuiltMap<String, InvoiceEntity> invoiceMap,
|
BuiltMap<String, InvoiceEntity> invoiceMap,
|
||||||
BuiltMap<String, ClientEntity> clientMap,
|
BuiltMap<String, ClientEntity> clientMap,
|
||||||
BuiltMap<String, UserEntity> userMap}) {
|
BuiltMap<String, UserEntity> userMap,
|
||||||
|
BuiltMap<String, PaymentTypeEntity> paymentTypeMap,
|
||||||
|
}) {
|
||||||
int response = 0;
|
int response = 0;
|
||||||
final PaymentEntity paymentA = sortAscending ? this : payment;
|
final PaymentEntity paymentA = sortAscending ? this : payment;
|
||||||
final PaymentEntity paymentB = sortAscending ? payment : this;
|
final PaymentEntity paymentB = sortAscending ? payment : this;
|
||||||
|
|
@ -315,6 +317,11 @@ abstract class PaymentEntity extends Object
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.compareTo(clientB.displayName.toLowerCase());
|
.compareTo(clientB.displayName.toLowerCase());
|
||||||
break;
|
break;
|
||||||
|
case PaymentFields.type:
|
||||||
|
final typeA = paymentTypeMap[paymentA.typeId] ?? PaymentTypeEntity();
|
||||||
|
final typeB = paymentTypeMap[paymentB.typeId] ?? PaymentTypeEntity();
|
||||||
|
return typeA.name.toLowerCase().compareTo(typeB.name.toLowerCase());
|
||||||
|
break;
|
||||||
case EntityFields.assignedTo:
|
case EntityFields.assignedTo:
|
||||||
final userA = userMap[paymentA.assignedUserId] ?? UserEntity();
|
final userA = userMap[paymentA.assignedUserId] ?? UserEntity();
|
||||||
final userB = userMap[paymentB.assignedUserId] ?? UserEntity();
|
final userB = userMap[paymentB.assignedUserId] ?? UserEntity();
|
||||||
|
|
|
||||||
|
|
@ -33,15 +33,16 @@ List<PaymentEntity> paymentsByCreditSelector(String creditId,
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
var memoizedDropdownPaymentList = memo5((
|
var memoizedDropdownPaymentList = memo6((
|
||||||
BuiltMap<String, PaymentEntity> paymentMap,
|
BuiltMap<String, PaymentEntity> paymentMap,
|
||||||
BuiltList<String> paymentList,
|
BuiltList<String> paymentList,
|
||||||
BuiltMap<String, InvoiceEntity> invoiceMap,
|
BuiltMap<String, InvoiceEntity> invoiceMap,
|
||||||
BuiltMap<String, ClientEntity> clientMap,
|
BuiltMap<String, ClientEntity> clientMap,
|
||||||
BuiltMap<String, UserEntity> userMap,
|
BuiltMap<String, UserEntity> userMap,
|
||||||
|
BuiltMap<String, PaymentTypeEntity> paymentTypeMap,
|
||||||
) =>
|
) =>
|
||||||
dropdownPaymentsSelector(
|
dropdownPaymentsSelector(paymentMap, paymentList, invoiceMap, clientMap,
|
||||||
paymentMap, paymentList, invoiceMap, clientMap, userMap));
|
userMap, paymentTypeMap));
|
||||||
|
|
||||||
List<String> dropdownPaymentsSelector(
|
List<String> dropdownPaymentsSelector(
|
||||||
BuiltMap<String, PaymentEntity> paymentMap,
|
BuiltMap<String, PaymentEntity> paymentMap,
|
||||||
|
|
@ -49,6 +50,7 @@ List<String> dropdownPaymentsSelector(
|
||||||
BuiltMap<String, InvoiceEntity> invoiceMap,
|
BuiltMap<String, InvoiceEntity> invoiceMap,
|
||||||
BuiltMap<String, ClientEntity> clientMap,
|
BuiltMap<String, ClientEntity> clientMap,
|
||||||
BuiltMap<String, UserEntity> userMap,
|
BuiltMap<String, UserEntity> userMap,
|
||||||
|
BuiltMap<String, PaymentTypeEntity> paymentTypeMap,
|
||||||
) {
|
) {
|
||||||
final list =
|
final list =
|
||||||
paymentList.where((paymentId) => paymentMap[paymentId].isActive).toList();
|
paymentList.where((paymentId) => paymentMap[paymentId].isActive).toList();
|
||||||
|
|
@ -58,26 +60,37 @@ List<String> dropdownPaymentsSelector(
|
||||||
final paymentB = paymentMap[paymentBId];
|
final paymentB = paymentMap[paymentBId];
|
||||||
|
|
||||||
return paymentA.compareTo(
|
return paymentA.compareTo(
|
||||||
payment: paymentB,
|
payment: paymentB,
|
||||||
sortAscending: true,
|
sortAscending: true,
|
||||||
sortField: PaymentFields.date,
|
sortField: PaymentFields.date,
|
||||||
invoiceMap: invoiceMap,
|
invoiceMap: invoiceMap,
|
||||||
clientMap: clientMap,
|
clientMap: clientMap,
|
||||||
userMap: userMap);
|
userMap: userMap,
|
||||||
|
paymentTypeMap: paymentTypeMap,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
var memoizedFilteredPaymentList = memo7((SelectionState selectionState,
|
var memoizedFilteredPaymentList = memo8((SelectionState selectionState,
|
||||||
BuiltMap<String, PaymentEntity> paymentMap,
|
BuiltMap<String, PaymentEntity> paymentMap,
|
||||||
BuiltList<String> paymentList,
|
BuiltList<String> paymentList,
|
||||||
BuiltMap<String, InvoiceEntity> invoiceMap,
|
BuiltMap<String, InvoiceEntity> invoiceMap,
|
||||||
BuiltMap<String, ClientEntity> clientMap,
|
BuiltMap<String, ClientEntity> clientMap,
|
||||||
BuiltMap<String, UserEntity> userMap,
|
BuiltMap<String, UserEntity> userMap,
|
||||||
|
BuiltMap<String, PaymentTypeEntity> paymentTypeMap,
|
||||||
ListUIState paymentListState) =>
|
ListUIState paymentListState) =>
|
||||||
filteredPaymentsSelector(selectionState, paymentMap, paymentList,
|
filteredPaymentsSelector(
|
||||||
invoiceMap, clientMap, userMap, paymentListState));
|
selectionState,
|
||||||
|
paymentMap,
|
||||||
|
paymentList,
|
||||||
|
invoiceMap,
|
||||||
|
clientMap,
|
||||||
|
userMap,
|
||||||
|
paymentTypeMap,
|
||||||
|
paymentListState,
|
||||||
|
));
|
||||||
|
|
||||||
List<String> filteredPaymentsSelector(
|
List<String> filteredPaymentsSelector(
|
||||||
SelectionState selectionState,
|
SelectionState selectionState,
|
||||||
|
|
@ -86,6 +99,7 @@ List<String> filteredPaymentsSelector(
|
||||||
BuiltMap<String, InvoiceEntity> invoiceMap,
|
BuiltMap<String, InvoiceEntity> invoiceMap,
|
||||||
BuiltMap<String, ClientEntity> clientMap,
|
BuiltMap<String, ClientEntity> clientMap,
|
||||||
BuiltMap<String, UserEntity> userMap,
|
BuiltMap<String, UserEntity> userMap,
|
||||||
|
BuiltMap<String, PaymentTypeEntity> paymentTypeMap,
|
||||||
ListUIState paymentListState) {
|
ListUIState paymentListState) {
|
||||||
final filterEntityId = selectionState.filterEntityId;
|
final filterEntityId = selectionState.filterEntityId;
|
||||||
final filterEntityType = selectionState.filterEntityType;
|
final filterEntityType = selectionState.filterEntityType;
|
||||||
|
|
@ -137,12 +151,14 @@ List<String> filteredPaymentsSelector(
|
||||||
final paymentA = paymentMap[paymentAId];
|
final paymentA = paymentMap[paymentAId];
|
||||||
final paymentB = paymentMap[paymentBId];
|
final paymentB = paymentMap[paymentBId];
|
||||||
return paymentA.compareTo(
|
return paymentA.compareTo(
|
||||||
payment: paymentB,
|
payment: paymentB,
|
||||||
sortAscending: paymentListState.sortAscending,
|
sortAscending: paymentListState.sortAscending,
|
||||||
sortField: paymentListState.sortField,
|
sortField: paymentListState.sortField,
|
||||||
invoiceMap: invoiceMap,
|
invoiceMap: invoiceMap,
|
||||||
clientMap: clientMap,
|
clientMap: clientMap,
|
||||||
userMap: userMap);
|
userMap: userMap,
|
||||||
|
paymentTypeMap: paymentTypeMap,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,7 @@ class PaymentListVM {
|
||||||
state.invoiceState.map,
|
state.invoiceState.map,
|
||||||
state.clientState.map,
|
state.clientState.map,
|
||||||
state.userState.map,
|
state.userState.map,
|
||||||
|
state.staticState.paymentTypeMap,
|
||||||
state.paymentListState),
|
state.paymentListState),
|
||||||
paymentMap: state.paymentState.map,
|
paymentMap: state.paymentState.map,
|
||||||
clientMap: state.clientState.map,
|
clientMap: state.clientState.map,
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ class PaymentScreenVM {
|
||||||
state.invoiceState.map,
|
state.invoiceState.map,
|
||||||
state.clientState.map,
|
state.clientState.map,
|
||||||
state.userState.map,
|
state.userState.map,
|
||||||
|
state.staticState.paymentTypeMap,
|
||||||
state.paymentListState),
|
state.paymentListState),
|
||||||
userCompany: state.userCompany,
|
userCompany: state.userCompany,
|
||||||
isInMultiselect: state.paymentListState.isInMultiselect(),
|
isInMultiselect: state.paymentListState.isInMultiselect(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue