Correct expense sorting

This commit is contained in:
Hillel Coren 2021-10-08 10:20:02 +03:00
parent e55be98772
commit 41df407b99
1 changed files with 22 additions and 12 deletions

View File

@ -474,24 +474,34 @@ abstract class ExpenseEntity extends Object
break; break;
case ExpenseFields.currencyId: case ExpenseFields.currencyId:
final currencyMap = staticState.currencyMap; final currencyMap = staticState.currencyMap;
response = currencyMap[expenseA.currencyId] final currencyA = currencyMap[expenseA.currencyId] ?? CurrencyEntity();
.name final currencyB = currencyMap[expenseB.currencyId] ?? CurrencyEntity();
.compareTo(currencyMap[expenseB.currencyId].name); response = currencyA.name
.toLowerCase()
.compareTo(currencyB.name.toLowerCase());
break; break;
case ExpenseFields.categoryId: case ExpenseFields.categoryId:
case ExpenseFields.category: case ExpenseFields.category:
response = expenseCategoryMap[expenseA.categoryId] final categoryA =
.name expenseCategoryMap[expenseA.categoryId] ?? ExpenseCategoryEntity();
.compareTo(expenseCategoryMap[expenseB.categoryId].name); final categoryB =
expenseCategoryMap[expenseB.categoryId] ?? ExpenseCategoryEntity();
response = categoryA.name
.toLowerCase()
.compareTo(categoryB.name.toLowerCase());
break; break;
case ExpenseFields.exchangeRate: case ExpenseFields.exchangeRate:
response = expenseA.exchangeRate.compareTo(expenseB.exchangeRate); response = expenseA.exchangeRate.compareTo(expenseB.exchangeRate);
break; break;
case ExpenseFields.invoiceCurrencyId: case ExpenseFields.invoiceCurrencyId:
final currencyMap = staticState.currencyMap; final currencyMap = staticState.currencyMap;
response = currencyMap[expenseA.invoiceCurrencyId] final currencyA =
.name currencyMap[expenseA.invoiceCurrencyId] ?? CurrencyEntity();
.compareTo(currencyMap[expenseB.invoiceCurrencyId].name); final currencyB =
currencyMap[expenseB.invoiceCurrencyId] ?? CurrencyEntity();
response = currencyA.name
.toLowerCase()
.compareTo(currencyB.name.toLowerCase());
break; break;
case ExpenseFields.taxName1: case ExpenseFields.taxName1:
response = expenseA.taxName1.compareTo(expenseB.taxName1); response = expenseA.taxName1.compareTo(expenseB.taxName1);
@ -506,9 +516,9 @@ abstract class ExpenseEntity extends Object
response = expenseA.taxRate2.compareTo(expenseB.taxRate2); response = expenseA.taxRate2.compareTo(expenseB.taxRate2);
break; break;
case ExpenseFields.invoiceId: case ExpenseFields.invoiceId:
response = invoiceMap[expenseA.invoiceId] final invoiceA = invoiceMap[expenseA.invoiceId] ?? InvoiceEntity();
.listDisplayName final invoiceB = invoiceMap[expenseB.invoiceId] ?? InvoiceEntity();
.compareTo(invoiceMap[expenseB.invoiceId].listDisplayName); response = invoiceA.listDisplayName.compareTo(invoiceB.listDisplayName);
break; break;
case ExpenseFields.customValue1: case ExpenseFields.customValue1:
response = expenseA.customValue1.compareTo(expenseB.customValue1); response = expenseA.customValue1.compareTo(expenseB.customValue1);