From 30f4110d92ac6f2ce7c62c74fb10d2e95156cdb8 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 15 Jan 2024 13:13:48 +0200 Subject: [PATCH 1/5] Filter transactions if account is not active --- lib/redux/transaction/transaction_selectors.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/redux/transaction/transaction_selectors.dart b/lib/redux/transaction/transaction_selectors.dart index 9fbd096b810..40491377f3d 100644 --- a/lib/redux/transaction/transaction_selectors.dart +++ b/lib/redux/transaction/transaction_selectors.dart @@ -99,6 +99,13 @@ List filteredTransactionsSelector( return true; } + final bankAccount = + bankAccountMap[transaction.bankAccountId] ?? BankAccountEntity(); + if (!bankAccount.isActive && + !bankAccount.matchesEntityFilter(filterEntityType, filterEntityId)) { + return false; + } + if (filterEntityType != null) { if (filterEntityType == EntityType.expenseCategory && transaction.categoryId != filterEntityId) { From 06f066390b0025d89081e49f8f19234e968fe318 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 15 Jan 2024 13:18:16 +0200 Subject: [PATCH 2/5] Adjust bank provider label --- lib/ui/bank_account/view/bank_account_view.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ui/bank_account/view/bank_account_view.dart b/lib/ui/bank_account/view/bank_account_view.dart index 1069338bc9e..d652cbe3f35 100644 --- a/lib/ui/bank_account/view/bank_account_view.dart +++ b/lib/ui/bank_account/view/bank_account_view.dart @@ -59,7 +59,7 @@ class _BankAccountViewState extends State { FieldGrid({ localization.type: toTitleCase(bankAccount.type), localization.status: toTitleCase(bankAccount.status), - localization.provider: toTitleCase(bankAccount.provider), + localization.provider: bankAccount.provider, if (bankAccount.isConnected) localization.autoSync: bankAccount.autoSync ? localization.enabled From 5e14167e555ad8a6e9545ed329f361c5d687a3fb Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 15 Jan 2024 13:32:56 +0200 Subject: [PATCH 3/5] Disable convert expense option if not configured --- lib/ui/transaction/view/transaction_view.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ui/transaction/view/transaction_view.dart b/lib/ui/transaction/view/transaction_view.dart index be9512c56fd..338bd1788d6 100644 --- a/lib/ui/transaction/view/transaction_view.dart +++ b/lib/ui/transaction/view/transaction_view.dart @@ -1277,7 +1277,8 @@ class _MatchWithdrawalsState extends State<_MatchWithdrawals> { ) : AppButton( label: localization.createExpense, - onPressed: viewModel.state.isSaving + onPressed: viewModel.state.isSaving || + (_selectedVendor == null && _selectedCategory == null) ? null : () { final viewModel = widget.viewModel; From 21e32df61e6021124132f6ee76ba7df4d3fc67c1 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 15 Jan 2024 13:44:22 +0200 Subject: [PATCH 4/5] Default to dashboard in the demo --- lib/redux/dashboard/dashboard_middleware.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/redux/dashboard/dashboard_middleware.dart b/lib/redux/dashboard/dashboard_middleware.dart index 76524ac6f35..02fbd74f24d 100644 --- a/lib/redux/dashboard/dashboard_middleware.dart +++ b/lib/redux/dashboard/dashboard_middleware.dart @@ -29,10 +29,11 @@ Middleware _createViewDashboard() { store: store, force: action.force, callback: () { - if (!store.state.userCompany.canViewDashboard) { + final state = store.state; + if (state.isLoaded && !state.userCompany.canViewDashboard) { store.dispatch(ViewClientList()); } else { - if (store.state.isStale) { + if (state.isStale) { store.dispatch(RefreshData()); } From c78972336073e82056356dfbfc86b5a751f38343 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 15 Jan 2024 13:51:48 +0200 Subject: [PATCH 5/5] Fix sorting payments by number --- lib/data/models/client_model.dart | 3 +-- lib/data/models/expense_model.dart | 3 +-- lib/data/models/invoice_model.dart | 3 +-- lib/data/models/payment_model.dart | 7 +++---- lib/data/models/project_model.dart | 3 ++- lib/data/models/task_model.dart | 3 +-- lib/data/models/vendor_model.dart | 3 +-- 7 files changed, 10 insertions(+), 15 deletions(-) diff --git a/lib/data/models/client_model.dart b/lib/data/models/client_model.dart index eb2b226dcfe..91d2025346b 100644 --- a/lib/data/models/client_model.dart +++ b/lib/data/models/client_model.dart @@ -432,8 +432,7 @@ abstract class ClientEntity extends Object response = clientA!.idNumber.compareTo(clientB!.idNumber); break; case ClientFields.number: - response = compareNatural( - clientA!.number.toLowerCase(), clientB!.number.toLowerCase()); + response = compareNatural(clientA!.number, clientB!.number); break; case ClientFields.website: response = clientA!.website diff --git a/lib/data/models/expense_model.dart b/lib/data/models/expense_model.dart index 64dcb8866eb..ef54f70806c 100644 --- a/lib/data/models/expense_model.dart +++ b/lib/data/models/expense_model.dart @@ -468,8 +468,7 @@ abstract class ExpenseEntity extends Object expenseA!.documents.length.compareTo(expenseB!.documents.length); break; case ExpenseFields.number: - response = compareNatural( - expenseA!.number.toLowerCase(), expenseB!.number.toLowerCase()); + response = compareNatural(expenseA!.number, expenseB!.number); break; case ExpenseFields.privateNotes: response = expenseA!.privateNotes.compareTo(expenseB!.privateNotes); diff --git a/lib/data/models/invoice_model.dart b/lib/data/models/invoice_model.dart index 3920dcb59d1..1670c56d622 100644 --- a/lib/data/models/invoice_model.dart +++ b/lib/data/models/invoice_model.dart @@ -728,8 +728,7 @@ abstract class InvoiceEntity extends Object invoiceBNumber.startsWith(recurringPrefix!) ? invoiceBNumber.replaceFirst(recurringPrefix, '') : invoiceBNumber; - response = compareNatural( - invoiceANumber.toLowerCase(), invoiceBNumber.toLowerCase()); + response = compareNatural(invoiceANumber, invoiceBNumber); break; case InvoiceFields.amount: response = invoiceA.amount.compareTo(invoiceB.amount); diff --git a/lib/data/models/payment_model.dart b/lib/data/models/payment_model.dart index cebaba49565..678d5c8c48c 100644 --- a/lib/data/models/payment_model.dart +++ b/lib/data/models/payment_model.dart @@ -4,7 +4,8 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; // Project imports: -import 'package:collection/collection.dart' show IterableExtension; +import 'package:collection/collection.dart' + show IterableExtension, compareNatural; import 'package:flutter_redux/flutter_redux.dart'; import 'package:invoiceninja_flutter/constants.dart'; import 'package:invoiceninja_flutter/data/models/models.dart'; @@ -267,9 +268,7 @@ abstract class PaymentEntity extends Object response = paymentA!.refunded.compareTo(paymentB!.refunded); break; case PaymentFields.number: - response = paymentA!.number - .toLowerCase() - .compareTo(paymentB!.number.toLowerCase()); + response = compareNatural(paymentA!.number, paymentB!.number); break; case PaymentFields.transactionReference: response = paymentA!.transactionReference diff --git a/lib/data/models/project_model.dart b/lib/data/models/project_model.dart index a3a3d795a2a..c7b1989e28f 100644 --- a/lib/data/models/project_model.dart +++ b/lib/data/models/project_model.dart @@ -2,6 +2,7 @@ import 'package:built_collection/built_collection.dart'; import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; +import 'package:collection/collection.dart'; import 'package:diacritic/diacritic.dart'; import 'package:flutter_redux/flutter_redux.dart'; @@ -307,7 +308,7 @@ abstract class ProjectEntity extends Object projectA.documents.length.compareTo(projectB.documents.length); break; case ProjectFields.number: - response = projectA.number.compareTo(projectB.number); + response = compareNatural(projectA.number, projectB.number); break; case ProjectFields.customValue1: response = projectA.customValue1.compareTo(projectB.customValue1); diff --git a/lib/data/models/task_model.dart b/lib/data/models/task_model.dart index fc26bac0578..2be989b25fa 100644 --- a/lib/data/models/task_model.dart +++ b/lib/data/models/task_model.dart @@ -790,8 +790,7 @@ abstract class TaskEntity extends Object response = taskA.documents.length.compareTo(taskB.documents.length); break; case TaskFields.number: - response = compareNatural( - taskA.number.toLowerCase(), taskB.number.toLowerCase()); + response = compareNatural(taskA.number, taskB.number); break; case TaskFields.createdBy: final userA = userMap[taskA.createdUserId] ?? UserEntity(); diff --git a/lib/data/models/vendor_model.dart b/lib/data/models/vendor_model.dart index 6a8942c12e5..87b14fa27e8 100644 --- a/lib/data/models/vendor_model.dart +++ b/lib/data/models/vendor_model.dart @@ -327,8 +327,7 @@ abstract class VendorEntity extends Object vendorA!.documents.length.compareTo(vendorB!.documents.length); break; case VendorFields.number: - response = compareNatural( - vendorA!.number.toLowerCase(), vendorB!.number.toLowerCase()); + response = compareNatural(vendorA!.number, vendorB!.number); break; case VendorFields.address1: response = vendorA!.address1.compareTo(vendorB!.address1);