From 905e9b7c228d858532cd1674cc97b57664d32225 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 13 Sep 2022 16:43:16 +0300 Subject: [PATCH] Transactions --- lib/data/models/company_model.dart | 7 ++++- lib/data/models/company_model.g.dart | 29 ++++++++++++++++- lib/data/models/entities.dart | 2 ++ lib/data/models/entities.g.dart | 4 +++ lib/data/models/models.dart | 1 + lib/data/models/serializers.dart | 8 +++-- lib/data/models/serializers.g.dart | 20 ++++++++++++ lib/main.dart | 3 ++ lib/main_app.dart | 12 +++++++ lib/redux/app/app_actions.dart | 37 ++++++++++++++++++++++ lib/redux/app/app_reducer.dart | 6 ++++ lib/redux/app/app_state.dart | 22 +++++++++++++ lib/redux/company/company_reducer.dart | 4 +++ lib/redux/company/company_state.dart | 6 ++++ lib/redux/company/company_state.g.dart | 33 ++++++++++++++++--- lib/redux/ui/pref_reducer.dart | 13 ++++++++ lib/redux/ui/ui_reducer.dart | 4 +++ lib/redux/ui/ui_state.dart | 7 +++++ lib/redux/ui/ui_state.g.dart | 27 +++++++++++++++- lib/ui/app/menu_drawer.dart | 7 +++++ lib/utils/i18n.dart | 42 +++++++++++++++++++++++++ starter.sh | 29 +++++++---------- stubs/data/models/stub_model | 10 ++---- stubs/data/repositories/stub_repository | 1 - stubs/redux/stub/stub_middleware | 2 -- stubs/redux/stub/stub_reducer | 1 - stubs/redux/stub/stub_selectors | 3 +- stubs/redux/stub/stub_state | 1 - stubs/ui/stub/edit/stub_edit | 1 - stubs/ui/stub/edit/stub_edit_vm | 3 -- stubs/ui/stub/stub_list_item | 2 -- stubs/ui/stub/stub_list_vm | 9 +++--- stubs/ui/stub/stub_screen | 1 - stubs/ui/stub/stub_screen_vm | 1 - stubs/ui/stub/view/stub_view | 1 - stubs/ui/stub/view/stub_view_vm | 2 -- 36 files changed, 304 insertions(+), 57 deletions(-) diff --git a/lib/data/models/company_model.dart b/lib/data/models/company_model.dart index c45111ee4..72aea3ea3 100644 --- a/lib/data/models/company_model.dart +++ b/lib/data/models/company_model.dart @@ -145,6 +145,7 @@ abstract class CompanyEntity extends Object clientRegistrationFields: BuiltList(), purchaseOrders: BuiltList(), bankAccounts: BuiltList(), + transactions: BuiltList(), ); } @@ -328,6 +329,8 @@ abstract class CompanyEntity extends Object @BuiltValueField(wireName: 'bank_integrations') BuiltList get bankAccounts; + BuiltList get transactions; + BuiltList get tasks; BuiltList get projects; @@ -596,6 +599,7 @@ abstract class CompanyEntity extends Object ..quotes.clear() ..purchaseOrders.clear() ..bankAccounts.clear() + ..transactions.clear() ..credits.clear() ..tasks.clear() ..projects.clear() @@ -678,7 +682,8 @@ abstract class CompanyEntity extends Object ..recurringExpenses.replace(BuiltList()) ..clientRegistrationFields.replace(BuiltList()) ..purchaseOrders.replace(BuiltList()) - ..bankAccounts.replace(BuiltList()); + ..bankAccounts.replace(BuiltList()) + ..transactions.replace(BuiltList()); static Serializer get serializer => _$companyEntitySerializer; } diff --git a/lib/data/models/company_model.g.dart b/lib/data/models/company_model.g.dart index c1e4dea3a..cb9bc8990 100644 --- a/lib/data/models/company_model.g.dart +++ b/lib/data/models/company_model.g.dart @@ -235,6 +235,10 @@ class _$CompanyEntitySerializer implements StructuredSerializer { serializers.serialize(object.bankAccounts, specifiedType: const FullType( BuiltList, const [const FullType(BankAccountEntity)])), + 'transactions', + serializers.serialize(object.transactions, + specifiedType: const FullType( + BuiltList, const [const FullType(TransactionEntity)])), 'tasks', serializers.serialize(object.tasks, specifiedType: @@ -675,6 +679,12 @@ class _$CompanyEntitySerializer implements StructuredSerializer { BuiltList, const [const FullType(BankAccountEntity)])) as BuiltList); break; + case 'transactions': + result.transactions.replace(serializers.deserialize(value, + specifiedType: const FullType( + BuiltList, const [const FullType(TransactionEntity)])) + as BuiltList); + break; case 'tasks': result.tasks.replace(serializers.deserialize(value, specifiedType: const FullType( @@ -1632,6 +1642,8 @@ class _$CompanyEntity extends CompanyEntity { @override final BuiltList bankAccounts; @override + final BuiltList transactions; + @override final BuiltList tasks; @override final BuiltList projects; @@ -1772,6 +1784,7 @@ class _$CompanyEntity extends CompanyEntity { this.credits, this.purchaseOrders, this.bankAccounts, + this.transactions, this.tasks, this.projects, this.expenses, @@ -1924,6 +1937,8 @@ class _$CompanyEntity extends CompanyEntity { purchaseOrders, 'CompanyEntity', 'purchaseOrders'); BuiltValueNullFieldError.checkNotNull( bankAccounts, 'CompanyEntity', 'bankAccounts'); + BuiltValueNullFieldError.checkNotNull( + transactions, 'CompanyEntity', 'transactions'); BuiltValueNullFieldError.checkNotNull(tasks, 'CompanyEntity', 'tasks'); BuiltValueNullFieldError.checkNotNull( projects, 'CompanyEntity', 'projects'); @@ -2058,6 +2073,7 @@ class _$CompanyEntity extends CompanyEntity { credits == other.credits && purchaseOrders == other.purchaseOrders && bankAccounts == other.bankAccounts && + transactions == other.transactions && tasks == other.tasks && projects == other.projects && expenses == other.expenses && @@ -2119,7 +2135,7 @@ class _$CompanyEntity extends CompanyEntity { $jc( $jc( $jc( - $jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc(0, enableCustomSurchargeTaxes1.hashCode), enableCustomSurchargeTaxes2.hashCode), enableCustomSurchargeTaxes3.hashCode), enableCustomSurchargeTaxes4.hashCode), sizeId.hashCode), industryId.hashCode), subdomain.hashCode), portalMode.hashCode), portalDomain.hashCode), updateProducts.hashCode), convertProductExchangeRate.hashCode), convertRateToClient.hashCode), fillProducts.hashCode), enableProductCost.hashCode), enableProductQuantity.hashCode), enableProductDiscount.hashCode), defaultTaskIsDateBased.hashCode), defaultQuantity.hashCode), showProductDetails.hashCode), clientCanRegister.hashCode), isLarge.hashCode), isDisabled.hashCode), enableShopApi.hashCode), companyKey.hashCode), firstDayOfWeek.hashCode), firstMonthOfYear.hashCode), numberOfInvoiceTaxRates.hashCode), numberOfItemTaxRates.hashCode), numberOfExpenseTaxRates.hashCode), expenseInclusiveTaxes.hashCode), sessionTimeout.hashCode), passwordTimeout.hashCode), oauthPasswordRequired.hashCode), markdownEnabled.hashCode), markdownEmailEnabled.hashCode), useCommaAsDecimalPlace.hashCode), reportIncludeDrafts.hashCode), useQuoteTermsOnConversion.hashCode), enableApplyingPayments.hashCode), trackInventory.hashCode), stockNotificationThreshold.hashCode), stockNotification.hashCode), groups.hashCode), activities.hashCode), taxRates.hashCode), taskStatuses.hashCode), taskStatusMap.hashCode), companyGateways.hashCode), expenseCategories.hashCode), users.hashCode), clients.hashCode), products.hashCode), invoices.hashCode), recurringInvoices.hashCode), recurringExpenses.hashCode), payments.hashCode), quotes.hashCode), credits.hashCode), purchaseOrders.hashCode), bankAccounts.hashCode), tasks.hashCode), projects.hashCode), expenses.hashCode), vendors.hashCode), designs.hashCode), documents.hashCode), tokens.hashCode), webhooks.hashCode), subscriptions.hashCode), paymentTerms.hashCode), systemLogs.hashCode), clientRegistrationFields.hashCode), customFields.hashCode), slackWebhookUrl.hashCode), googleAnalyticsKey.hashCode), markExpensesInvoiceable.hashCode), markExpensesPaid.hashCode), invoiceExpenseDocuments.hashCode), invoiceTaskDocuments.hashCode), + $jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc(0, enableCustomSurchargeTaxes1.hashCode), enableCustomSurchargeTaxes2.hashCode), enableCustomSurchargeTaxes3.hashCode), enableCustomSurchargeTaxes4.hashCode), sizeId.hashCode), industryId.hashCode), subdomain.hashCode), portalMode.hashCode), portalDomain.hashCode), updateProducts.hashCode), convertProductExchangeRate.hashCode), convertRateToClient.hashCode), fillProducts.hashCode), enableProductCost.hashCode), enableProductQuantity.hashCode), enableProductDiscount.hashCode), defaultTaskIsDateBased.hashCode), defaultQuantity.hashCode), showProductDetails.hashCode), clientCanRegister.hashCode), isLarge.hashCode), isDisabled.hashCode), enableShopApi.hashCode), companyKey.hashCode), firstDayOfWeek.hashCode), firstMonthOfYear.hashCode), numberOfInvoiceTaxRates.hashCode), numberOfItemTaxRates.hashCode), numberOfExpenseTaxRates.hashCode), expenseInclusiveTaxes.hashCode), sessionTimeout.hashCode), passwordTimeout.hashCode), oauthPasswordRequired.hashCode), markdownEnabled.hashCode), markdownEmailEnabled.hashCode), useCommaAsDecimalPlace.hashCode), reportIncludeDrafts.hashCode), useQuoteTermsOnConversion.hashCode), enableApplyingPayments.hashCode), trackInventory.hashCode), stockNotificationThreshold.hashCode), stockNotification.hashCode), groups.hashCode), activities.hashCode), taxRates.hashCode), taskStatuses.hashCode), taskStatusMap.hashCode), companyGateways.hashCode), expenseCategories.hashCode), users.hashCode), clients.hashCode), products.hashCode), invoices.hashCode), recurringInvoices.hashCode), recurringExpenses.hashCode), payments.hashCode), quotes.hashCode), credits.hashCode), purchaseOrders.hashCode), bankAccounts.hashCode), transactions.hashCode), tasks.hashCode), projects.hashCode), expenses.hashCode), vendors.hashCode), designs.hashCode), documents.hashCode), tokens.hashCode), webhooks.hashCode), subscriptions.hashCode), paymentTerms.hashCode), systemLogs.hashCode), clientRegistrationFields.hashCode), customFields.hashCode), slackWebhookUrl.hashCode), googleAnalyticsKey.hashCode), markExpensesInvoiceable.hashCode), markExpensesPaid.hashCode), invoiceExpenseDocuments.hashCode), invoiceTaskDocuments.hashCode), invoiceTaskTimelog.hashCode), invoiceTaskDatelog.hashCode), invoiceTaskProject.hashCode), @@ -2204,6 +2220,7 @@ class _$CompanyEntity extends CompanyEntity { ..add('credits', credits) ..add('purchaseOrders', purchaseOrders) ..add('bankAccounts', bankAccounts) + ..add('transactions', transactions) ..add('tasks', tasks) ..add('projects', projects) ..add('expenses', expenses) @@ -2554,6 +2571,12 @@ class CompanyEntityBuilder set bankAccounts(ListBuilder bankAccounts) => _$this._bankAccounts = bankAccounts; + ListBuilder _transactions; + ListBuilder get transactions => + _$this._transactions ??= new ListBuilder(); + set transactions(ListBuilder transactions) => + _$this._transactions = transactions; + ListBuilder _tasks; ListBuilder get tasks => _$this._tasks ??= new ListBuilder(); @@ -2815,6 +2838,7 @@ class CompanyEntityBuilder _credits = $v.credits.toBuilder(); _purchaseOrders = $v.purchaseOrders.toBuilder(); _bankAccounts = $v.bankAccounts.toBuilder(); + _transactions = $v.transactions.toBuilder(); _tasks = $v.tasks.toBuilder(); _projects = $v.projects.toBuilder(); _expenses = $v.expenses.toBuilder(); @@ -2949,6 +2973,7 @@ class CompanyEntityBuilder credits: credits.build(), purchaseOrders: purchaseOrders.build(), bankAccounts: bankAccounts.build(), + transactions: transactions.build(), tasks: tasks.build(), projects: projects.build(), expenses: expenses.build(), @@ -3026,6 +3051,8 @@ class CompanyEntityBuilder purchaseOrders.build(); _$failedField = 'bankAccounts'; bankAccounts.build(); + _$failedField = 'transactions'; + transactions.build(); _$failedField = 'tasks'; tasks.build(); _$failedField = 'projects'; diff --git a/lib/data/models/entities.dart b/lib/data/models/entities.dart index f8be43f70..6662df388 100644 --- a/lib/data/models/entities.dart +++ b/lib/data/models/entities.dart @@ -42,6 +42,8 @@ class EntityType extends EnumClass { static const EntityType invoiceItem = _$invoiceItem; static const EntityType design = _$design; // STARTER: entity type - do not remove comment + static const EntityType transaction = _$transaction; + static const EntityType bankAccount = _$bankAccount; static const EntityType recurringExpense = _$recurringExpense; diff --git a/lib/data/models/entities.g.dart b/lib/data/models/entities.g.dart index d8c57f70d..1a8c50bc5 100644 --- a/lib/data/models/entities.g.dart +++ b/lib/data/models/entities.g.dart @@ -30,6 +30,7 @@ const EntityType _$gateway = const EntityType._('gateway'); const EntityType _$gatewayToken = const EntityType._('gatewayToken'); const EntityType _$invoiceItem = const EntityType._('invoiceItem'); const EntityType _$design = const EntityType._('design'); +const EntityType _$transaction = const EntityType._('transaction'); const EntityType _$bankAccount = const EntityType._('bankAccount'); const EntityType _$recurringExpense = const EntityType._('recurringExpense'); const EntityType _$recurringQuote = const EntityType._('recurringQuote'); @@ -102,6 +103,8 @@ EntityType _$typeValueOf(String name) { return _$invoiceItem; case 'design': return _$design; + case 'transaction': + return _$transaction; case 'bankAccount': return _$bankAccount; case 'recurringExpense': @@ -175,6 +178,7 @@ final BuiltSet _$typeValues = _$gatewayToken, _$invoiceItem, _$design, + _$transaction, _$bankAccount, _$recurringExpense, _$recurringQuote, diff --git a/lib/data/models/models.dart b/lib/data/models/models.dart index 63640b717..6997f98df 100644 --- a/lib/data/models/models.dart +++ b/lib/data/models/models.dart @@ -40,6 +40,7 @@ export 'package:invoiceninja_flutter/data/models/task_status_model.dart'; export 'package:invoiceninja_flutter/data/models/user_model.dart'; export 'package:invoiceninja_flutter/data/models/vendor_model.dart'; export 'package:invoiceninja_flutter/data/models/bank_account_model.dart'; +export 'package:invoiceninja_flutter/data/models/transaction_model.dart'; // STARTER: export - do not remove comment part 'models.g.dart'; diff --git a/lib/data/models/serializers.dart b/lib/data/models/serializers.dart index b842a6838..4f6e3f0ed 100644 --- a/lib/data/models/serializers.dart +++ b/lib/data/models/serializers.dart @@ -48,9 +48,9 @@ import 'package:invoiceninja_flutter/redux/ui/ui_state.dart'; import 'package:invoiceninja_flutter/redux/user/user_state.dart'; import 'package:invoiceninja_flutter/redux/vendor/vendor_state.dart'; import 'package:invoiceninja_flutter/redux/webhook/webhook_state.dart'; - -// STARTER: import - do not remove comment +import 'package:invoiceninja_flutter/redux/transaction/transaction_state.dart'; import 'package:invoiceninja_flutter/redux/bank_account/bank_account_state.dart'; +// STARTER: import - do not remove comment part 'serializers.g.dart'; @@ -115,6 +115,10 @@ part 'serializers.g.dart'; TaxRateItemResponse, TaxRateListResponse, // STARTER: serializers - do not remove comment + TransactionEntity, + TransactionListResponse, + TransactionItemResponse, + BankAccountEntity, BankAccountListResponse, BankAccountItemResponse, diff --git a/lib/data/models/serializers.g.dart b/lib/data/models/serializers.g.dart index a50f2d187..97f920f59 100644 --- a/lib/data/models/serializers.g.dart +++ b/lib/data/models/serializers.g.dart @@ -193,6 +193,11 @@ Serializers _$serializers = (new Serializers().toBuilder() ..add(TokenListResponse.serializer) ..add(TokenState.serializer) ..add(TokenUIState.serializer) + ..add(TransactionEntity.serializer) + ..add(TransactionItemResponse.serializer) + ..add(TransactionListResponse.serializer) + ..add(TransactionState.serializer) + ..add(TransactionUIState.serializer) ..add(UIState.serializer) ..add(UserCompanyEntity.serializer) ..add(UserCompanyItemResponse.serializer) @@ -420,6 +425,9 @@ Serializers _$serializers = (new Serializers().toBuilder() ..addBuilderFactory( const FullType(BuiltList, const [const FullType(BankAccountEntity)]), () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [const FullType(TransactionEntity)]), + () => new ListBuilder()) ..addBuilderFactory( const FullType(BuiltList, const [const FullType(TaskEntity)]), () => new ListBuilder()) @@ -551,6 +559,9 @@ Serializers _$serializers = (new Serializers().toBuilder() ..addBuilderFactory( const FullType(BuiltList, const [const FullType(TokenEntity)]), () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [const FullType(TransactionEntity)]), + () => new ListBuilder()) ..addBuilderFactory( const FullType(BuiltList, const [const FullType(UserCompanyEntity)]), () => new ListBuilder()) @@ -891,6 +902,15 @@ Serializers _$serializers = (new Serializers().toBuilder() ..addBuilderFactory( const FullType(BuiltList, const [const FullType(String)]), () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltMap, const [ + const FullType(String), + const FullType(TransactionEntity) + ]), + () => new MapBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [const FullType(String)]), + () => new ListBuilder()) ..addBuilderFactory( const FullType(BuiltMap, const [const FullType(String), const FullType(UserEntity)]), diff --git a/lib/main.dart b/lib/main.dart index deca72cde..d7cfcced5 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -57,6 +57,8 @@ import 'package:invoiceninja_flutter/utils/web_stub.dart' if (dart.library.html) 'package:invoiceninja_flutter/utils/web.dart'; // STARTER: import - do not remove comment +import 'package:invoiceninja_flutter/redux/transaction/transaction_middleware.dart'; + import 'package:invoiceninja_flutter/redux/bank_account/bank_account_middleware.dart'; import 'package:invoiceninja_flutter/redux/purchase_order/purchase_order_middleware.dart'; @@ -100,6 +102,7 @@ void main({bool isTesting = false}) async { ..addAll(createStoreSettingsMiddleware()) ..addAll(createStoreReportsMiddleware()) // STARTER: middleware - do not remove comment + ..addAll(createStoreTransactionsMiddleware()) ..addAll(createStoreBankAccountsMiddleware()) ..addAll(createStorePurchaseOrdersMiddleware()) ..addAll(createStoreRecurringExpensesMiddleware()) diff --git a/lib/main_app.dart b/lib/main_app.dart index 401c20924..ecd7ac93a 100644 --- a/lib/main_app.dart +++ b/lib/main_app.dart @@ -95,6 +95,11 @@ import 'package:invoiceninja_flutter/utils/localization.dart'; import 'package:invoiceninja_flutter/utils/platforms.dart'; // STARTER: import - do not remove comment +import 'package:invoiceninja_flutter/ui/transaction/transaction_screen.dart'; +import 'package:invoiceninja_flutter/ui/transaction/edit/transaction_edit_vm.dart'; +import 'package:invoiceninja_flutter/ui/transaction/view/transaction_view_vm.dart'; +import 'package:invoiceninja_flutter/ui/transaction/transaction_screen_vm.dart'; + import 'package:invoiceninja_flutter/ui/bank_account/bank_account_screen.dart'; import 'package:invoiceninja_flutter/ui/bank_account/view/bank_account_view_vm.dart'; import 'package:invoiceninja_flutter/ui/bank_account/bank_account_screen_vm.dart'; @@ -507,6 +512,13 @@ class InvoiceNinjaAppState extends State { QuoteEmailScreen.route: (context) => QuoteEmailScreen(), QuotePdfScreen.route: (context) => QuotePdfScreen(), // STARTER: routes - do not remove comment + TransactionScreen.route: (context) => + TransactionScreenBuilder(), + TransactionViewScreen.route: (context) => + TransactionViewScreen(), + TransactionEditScreen.route: (context) => + TransactionEditScreen(), + BankAccountScreen.route: (context) => BankAccountScreenBuilder(), BankAccountViewScreen.route: (context) => diff --git a/lib/redux/app/app_actions.dart b/lib/redux/app/app_actions.dart index 7d5d883e7..50fcc1c44 100644 --- a/lib/redux/app/app_actions.dart +++ b/lib/redux/app/app_actions.dart @@ -65,6 +65,8 @@ import 'package:invoiceninja_flutter/utils/localization.dart'; import 'package:invoiceninja_flutter/utils/platforms.dart'; // STARTER: import - do not remove comment +import 'package:invoiceninja_flutter/redux/transaction/transaction_actions.dart'; + import 'package:invoiceninja_flutter/redux/bank_account/bank_account_actions.dart'; import 'package:invoiceninja_flutter/redux/purchase_order/purchase_order_actions.dart'; @@ -388,6 +390,10 @@ void viewEntitiesByType({ action = ViewGroupList(); break; // STARTER: view list - do not remove comment + case EntityType.transaction: + action = ViewTransactionList(); + break; + case EntityType.bankAccount: action = ViewBankAccountList(); break; @@ -606,6 +612,13 @@ void viewEntityById({ )); break; // STARTER: view - do not remove comment + case EntityType.transaction: + store.dispatch(ViewTransaction( + transactionId: entityId, + force: force, + )); + break; + case EntityType.bankAccount: store.dispatch(ViewBankAccount( bankAccountId: entityId, @@ -845,6 +858,13 @@ void createEntityByType({ )); break; // STARTER: create type - do not remove comment + case EntityType.transaction: + store.dispatch(EditTransaction( + force: force, + transaction: TransactionEntity(state: state), + )); + break; + case EntityType.purchaseOrder: store.dispatch(EditPurchaseOrder( force: force, @@ -1060,6 +1080,14 @@ void createEntity({ )); break; // STARTER: create - do not remove comment + case EntityType.transaction: + store.dispatch(EditTransaction( + transaction: entity, + force: force, + completer: completer, + )); + break; + case EntityType.purchaseOrder: store.dispatch(EditPurchaseOrder( purchaseOrder: entity, @@ -1253,6 +1281,11 @@ void editEntity({ )); break; // STARTER: edit - do not remove comment + case EntityType.transaction: + store.dispatch( + EditTransaction(transaction: entity, completer: completer)); + break; + case EntityType.purchaseOrder: store.dispatch( EditPurchaseOrder(purchaseOrder: entity, completer: completer)); @@ -1428,6 +1461,10 @@ void handleEntitiesActions(List entities, EntityAction action, handleDocumentAction(context, entities, action); break; // STARTER: actions - do not remove comment + case EntityType.transaction: + handleTransactionAction(context, entities, action); + break; + case EntityType.bankAccount: handleBankAccountAction(context, entities, action); break; diff --git a/lib/redux/app/app_reducer.dart b/lib/redux/app/app_reducer.dart index 75cb7560e..f4e8d1ef5 100644 --- a/lib/redux/app/app_reducer.dart +++ b/lib/redux/app/app_reducer.dart @@ -32,6 +32,8 @@ import 'package:invoiceninja_flutter/redux/vendor/vendor_actions.dart'; import 'package:invoiceninja_flutter/redux/webhook/webhook_actions.dart'; // STARTER: import - do not remove comment +import 'package:invoiceninja_flutter/redux/transaction/transaction_actions.dart'; + import 'package:invoiceninja_flutter/redux/bank_account/bank_account_actions.dart'; import 'package:invoiceninja_flutter/redux/purchase_order/purchase_order_actions.dart'; @@ -104,6 +106,10 @@ final lastErrorReducer = combineReducers([ return '${action.error}'; }), // STARTER: errors - do not remove comment + TypedReducer((state, action) { + return '${action.error}'; + }), + TypedReducer((state, action) { return '${action.error}'; }), diff --git a/lib/redux/app/app_state.dart b/lib/redux/app/app_state.dart index 86313edce..9ff36d703 100644 --- a/lib/redux/app/app_state.dart +++ b/lib/redux/app/app_state.dart @@ -88,6 +88,10 @@ import 'package:invoiceninja_flutter/utils/colors.dart'; import 'package:invoiceninja_flutter/utils/formatting.dart'; import 'package:invoiceninja_flutter/utils/platforms.dart'; // STARTER: import - do not remove comment +import 'package:invoiceninja_flutter/redux/transaction/transaction_state.dart'; +import 'package:invoiceninja_flutter/ui/transaction/edit/transaction_edit_vm.dart'; +import 'package:invoiceninja_flutter/redux/transaction/transaction_selectors.dart'; + import 'package:invoiceninja_flutter/redux/bank_account/bank_account_state.dart'; import 'package:invoiceninja_flutter/redux/purchase_order/purchase_order_state.dart'; import 'package:invoiceninja_flutter/ui/purchase_order/edit/purchase_order_edit_vm.dart'; @@ -293,6 +297,9 @@ abstract class AppState implements Built { case EntityType.invoice: return invoiceState.map; // STARTER: states switch map - do not remove comment + case EntityType.transaction: + return transactionState.map; + case EntityType.bankAccount: return bankAccountState.map; @@ -379,6 +386,9 @@ abstract class AppState implements Built { case EntityType.invoice: return invoiceState.list; // STARTER: states switch list - do not remove comment + case EntityType.transaction: + return transactionState.list; + case EntityType.bankAccount: return bankAccountState.list; @@ -454,6 +464,9 @@ abstract class AppState implements Built { case EntityType.invoice: return invoiceUIState; // STARTER: states switch - do not remove comment + case EntityType.transaction: + return transactionUIState; + case EntityType.bankAccount: return bankAccountUIState; @@ -530,6 +543,11 @@ abstract class AppState implements Built { ListUIState get invoiceListState => uiState.invoiceUIState.listUIState; // STARTER: state getters - do not remove comment + TransactionState get transactionState => userCompanyState.transactionState; + ListUIState get transactionListState => + uiState.transactionUIState.listUIState; + TransactionUIState get transactionUIState => uiState.transactionUIState; + BankAccountState get bankAccountState => userCompanyState.bankAccountState; ListUIState get bankAccountListState => uiState.bankAccountUIState.listUIState; @@ -711,6 +729,10 @@ abstract class AppState implements Built { case CreditEditScreen.route: return hasCreditChanges(creditUIState.editing, creditState.map); // STARTER: has changes - do not remove comment + case TransactionEditScreen.route: + return hasTransactionChanges( + transactionUIState.editing, transactionState.map); + case PurchaseOrderEditScreen.route: return hasPurchaseOrderChanges( purchaseOrderUIState.editing, purchaseOrderState.map); diff --git a/lib/redux/company/company_reducer.dart b/lib/redux/company/company_reducer.dart index a178eea8e..283a5f7bd 100644 --- a/lib/redux/company/company_reducer.dart +++ b/lib/redux/company/company_reducer.dart @@ -36,6 +36,8 @@ import 'package:invoiceninja_flutter/redux/vendor/vendor_reducer.dart'; import 'package:invoiceninja_flutter/redux/webhook/webhook_reducer.dart'; // STARTER: import - do not remove comment +import 'package:invoiceninja_flutter/redux/transaction/transaction_reducer.dart'; + import 'package:invoiceninja_flutter/redux/bank_account/bank_account_reducer.dart'; import 'package:invoiceninja_flutter/redux/purchase_order/purchase_order_reducer.dart'; @@ -56,6 +58,8 @@ UserCompanyState companyReducer(UserCompanyState state, dynamic action) { ..vendorState.replace(vendorsReducer(state.vendorState, action)) ..taskState.replace(tasksReducer(state.taskState, action)) // STARTER: reducer - do not remove comment + ..transactionState + .replace(transactionsReducer(state.transactionState, action)) ..bankAccountState .replace(bankAccountsReducer(state.bankAccountState, action)) ..purchaseOrderState diff --git a/lib/redux/company/company_state.dart b/lib/redux/company/company_state.dart index 4d342554a..c8bfac95e 100644 --- a/lib/redux/company/company_state.dart +++ b/lib/redux/company/company_state.dart @@ -32,6 +32,8 @@ import 'package:invoiceninja_flutter/redux/vendor/vendor_state.dart'; import 'package:invoiceninja_flutter/redux/webhook/webhook_state.dart'; // STARTER: import - do not remove comment +import 'package:invoiceninja_flutter/redux/transaction/transaction_state.dart'; + import 'package:invoiceninja_flutter/redux/bank_account/bank_account_state.dart'; import 'package:invoiceninja_flutter/redux/purchase_order/purchase_order_state.dart'; @@ -55,6 +57,8 @@ abstract class UserCompanyState paymentState: PaymentState(), quoteState: QuoteState(), // STARTER: constructor - do not remove comment + transactionState: TransactionState(), + bankAccountState: BankAccountState(), purchaseOrderState: PurchaseOrderState(), @@ -108,6 +112,8 @@ abstract class UserCompanyState QuoteState get quoteState; // STARTER: fields - do not remove comment + TransactionState get transactionState; + BankAccountState get bankAccountState; PurchaseOrderState get purchaseOrderState; diff --git a/lib/redux/company/company_state.g.dart b/lib/redux/company/company_state.g.dart index febae2280..ee5d768ac 100644 --- a/lib/redux/company/company_state.g.dart +++ b/lib/redux/company/company_state.g.dart @@ -55,6 +55,9 @@ class _$UserCompanyStateSerializer 'quoteState', serializers.serialize(object.quoteState, specifiedType: const FullType(QuoteState)), + 'transactionState', + serializers.serialize(object.transactionState, + specifiedType: const FullType(TransactionState)), 'bankAccountState', serializers.serialize(object.bankAccountState, specifiedType: const FullType(BankAccountState)), @@ -176,6 +179,11 @@ class _$UserCompanyStateSerializer result.quoteState.replace(serializers.deserialize(value, specifiedType: const FullType(QuoteState)) as QuoteState); break; + case 'transactionState': + result.transactionState.replace(serializers.deserialize(value, + specifiedType: const FullType(TransactionState)) + as TransactionState); + break; case 'bankAccountState': result.bankAccountState.replace(serializers.deserialize(value, specifiedType: const FullType(BankAccountState)) @@ -433,6 +441,8 @@ class _$UserCompanyState extends UserCompanyState { @override final QuoteState quoteState; @override + final TransactionState transactionState; + @override final BankAccountState bankAccountState; @override final PurchaseOrderState purchaseOrderState; @@ -482,6 +492,7 @@ class _$UserCompanyState extends UserCompanyState { this.projectState, this.paymentState, this.quoteState, + this.transactionState, this.bankAccountState, this.purchaseOrderState, this.recurringExpenseState, @@ -521,6 +532,8 @@ class _$UserCompanyState extends UserCompanyState { paymentState, 'UserCompanyState', 'paymentState'); BuiltValueNullFieldError.checkNotNull( quoteState, 'UserCompanyState', 'quoteState'); + BuiltValueNullFieldError.checkNotNull( + transactionState, 'UserCompanyState', 'transactionState'); BuiltValueNullFieldError.checkNotNull( bankAccountState, 'UserCompanyState', 'bankAccountState'); BuiltValueNullFieldError.checkNotNull( @@ -579,6 +592,7 @@ class _$UserCompanyState extends UserCompanyState { projectState == other.projectState && paymentState == other.paymentState && quoteState == other.quoteState && + transactionState == other.transactionState && bankAccountState == other.bankAccountState && purchaseOrderState == other.purchaseOrderState && recurringExpenseState == other.recurringExpenseState && @@ -618,10 +632,10 @@ class _$UserCompanyState extends UserCompanyState { $jc( $jc( $jc( - $jc($jc($jc($jc($jc($jc($jc($jc($jc($jc(0, lastUpdated.hashCode), userCompany.hashCode), documentState.hashCode), productState.hashCode), clientState.hashCode), invoiceState.hashCode), expenseState.hashCode), vendorState.hashCode), taskState.hashCode), - projectState.hashCode), - paymentState.hashCode), - quoteState.hashCode), + $jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc(0, lastUpdated.hashCode), userCompany.hashCode), documentState.hashCode), productState.hashCode), clientState.hashCode), invoiceState.hashCode), expenseState.hashCode), vendorState.hashCode), taskState.hashCode), projectState.hashCode), + paymentState.hashCode), + quoteState.hashCode), + transactionState.hashCode), bankAccountState.hashCode), purchaseOrderState.hashCode), recurringExpenseState.hashCode), @@ -655,6 +669,7 @@ class _$UserCompanyState extends UserCompanyState { ..add('projectState', projectState) ..add('paymentState', paymentState) ..add('quoteState', quoteState) + ..add('transactionState', transactionState) ..add('bankAccountState', bankAccountState) ..add('purchaseOrderState', purchaseOrderState) ..add('recurringExpenseState', recurringExpenseState) @@ -748,6 +763,12 @@ class UserCompanyStateBuilder set quoteState(QuoteStateBuilder quoteState) => _$this._quoteState = quoteState; + TransactionStateBuilder _transactionState; + TransactionStateBuilder get transactionState => + _$this._transactionState ??= new TransactionStateBuilder(); + set transactionState(TransactionStateBuilder transactionState) => + _$this._transactionState = transactionState; + BankAccountStateBuilder _bankAccountState; BankAccountStateBuilder get bankAccountState => _$this._bankAccountState ??= new BankAccountStateBuilder(); @@ -862,6 +883,7 @@ class UserCompanyStateBuilder _projectState = $v.projectState.toBuilder(); _paymentState = $v.paymentState.toBuilder(); _quoteState = $v.quoteState.toBuilder(); + _transactionState = $v.transactionState.toBuilder(); _bankAccountState = $v.bankAccountState.toBuilder(); _purchaseOrderState = $v.purchaseOrderState.toBuilder(); _recurringExpenseState = $v.recurringExpenseState.toBuilder(); @@ -913,6 +935,7 @@ class UserCompanyStateBuilder projectState: projectState.build(), paymentState: paymentState.build(), quoteState: quoteState.build(), + transactionState: transactionState.build(), bankAccountState: bankAccountState.build(), purchaseOrderState: purchaseOrderState.build(), recurringExpenseState: recurringExpenseState.build(), @@ -954,6 +977,8 @@ class UserCompanyStateBuilder paymentState.build(); _$failedField = 'quoteState'; quoteState.build(); + _$failedField = 'transactionState'; + transactionState.build(); _$failedField = 'bankAccountState'; bankAccountState.build(); _$failedField = 'purchaseOrderState'; diff --git a/lib/redux/ui/pref_reducer.dart b/lib/redux/ui/pref_reducer.dart index 2641f4691..e95d0c3d7 100644 --- a/lib/redux/ui/pref_reducer.dart +++ b/lib/redux/ui/pref_reducer.dart @@ -40,6 +40,8 @@ import 'package:invoiceninja_flutter/redux/vendor/vendor_actions.dart'; import 'package:invoiceninja_flutter/redux/webhook/webhook_actions.dart'; // STARTER: import - do not remove comment +import 'package:invoiceninja_flutter/redux/transaction/transaction_actions.dart'; + import 'package:invoiceninja_flutter/redux/bank_account/bank_account_actions.dart'; import 'package:invoiceninja_flutter/redux/purchase_order/purchase_order_actions.dart'; @@ -551,6 +553,17 @@ Reducer> historyReducer = combineReducers([ _addToHistory(historyList, HistoryRecord(id: action.group.id, entityType: EntityType.group))), // STARTER: history - do not remove comment + TypedReducer, ViewTransaction>( + (historyList, action) => _addToHistory( + historyList, + HistoryRecord( + id: action.transactionId, entityType: EntityType.transaction))), + TypedReducer, EditTransaction>( + (historyList, action) => _addToHistory( + historyList, + HistoryRecord( + id: action.transaction.id, entityType: EntityType.transaction))), + TypedReducer, ViewBankAccount>( (historyList, action) => _addToHistory( historyList, diff --git a/lib/redux/ui/ui_reducer.dart b/lib/redux/ui/ui_reducer.dart index ec6630633..ada34193b 100644 --- a/lib/redux/ui/ui_reducer.dart +++ b/lib/redux/ui/ui_reducer.dart @@ -51,6 +51,8 @@ import 'package:invoiceninja_flutter/redux/vendor/vendor_reducer.dart'; import 'package:invoiceninja_flutter/redux/webhook/webhook_reducer.dart'; // STARTER: import - do not remove comment +import 'package:invoiceninja_flutter/redux/transaction/transaction_reducer.dart'; + import 'package:invoiceninja_flutter/redux/bank_account/bank_account_reducer.dart'; import 'package:invoiceninja_flutter/redux/purchase_order/purchase_order_reducer.dart'; @@ -80,6 +82,8 @@ UIState uiReducer(UIState state, dynamic action) { .replace(dashboardUIReducer(state.dashboardUIState, action)) ..reportsUIState.replace(reportsUIReducer(state.reportsUIState, action)) // STARTER: reducer - do not remove comment + ..transactionUIState + .replace(transactionUIReducer(state.transactionUIState, action)) ..bankAccountUIState .replace(bankAccountUIReducer(state.bankAccountUIState, action)) ..purchaseOrderUIState diff --git a/lib/redux/ui/ui_state.dart b/lib/redux/ui/ui_state.dart index 3c405533b..33b84dbfc 100644 --- a/lib/redux/ui/ui_state.dart +++ b/lib/redux/ui/ui_state.dart @@ -38,6 +38,8 @@ import 'package:invoiceninja_flutter/ui/auth/login_vm.dart'; import 'package:invoiceninja_flutter/utils/strings.dart'; // STARTER: import - do not remove comment +import 'package:invoiceninja_flutter/redux/transaction/transaction_state.dart'; + import 'package:invoiceninja_flutter/redux/bank_account/bank_account_state.dart'; import 'package:invoiceninja_flutter/redux/purchase_order/purchase_order_state.dart'; @@ -89,6 +91,9 @@ abstract class UIState implements Built { paymentUIState: PaymentUIState(sortFields[EntityType.payment]), quoteUIState: QuoteUIState(sortFields[EntityType.quote]), // STARTER: constructor - do not remove comment + transactionUIState: + TransactionUIState(sortFields[EntityType.transaction]), + bankAccountUIState: BankAccountUIState(sortFields[EntityType.bankAccount]), @@ -142,6 +147,8 @@ abstract class UIState implements Built { InvoiceUIState get invoiceUIState; // STARTER: properties - do not remove comment + TransactionUIState get transactionUIState; + BankAccountUIState get bankAccountUIState; PurchaseOrderUIState get purchaseOrderUIState; diff --git a/lib/redux/ui/ui_state.g.dart b/lib/redux/ui/ui_state.g.dart index 08e313772..9a652b7da 100644 --- a/lib/redux/ui/ui_state.g.dart +++ b/lib/redux/ui/ui_state.g.dart @@ -53,6 +53,9 @@ class _$UIStateSerializer implements StructuredSerializer { 'invoiceUIState', serializers.serialize(object.invoiceUIState, specifiedType: const FullType(InvoiceUIState)), + 'transactionUIState', + serializers.serialize(object.transactionUIState, + specifiedType: const FullType(TransactionUIState)), 'bankAccountUIState', serializers.serialize(object.bankAccountUIState, specifiedType: const FullType(BankAccountUIState)), @@ -215,6 +218,11 @@ class _$UIStateSerializer implements StructuredSerializer { result.invoiceUIState.replace(serializers.deserialize(value, specifiedType: const FullType(InvoiceUIState)) as InvoiceUIState); break; + case 'transactionUIState': + result.transactionUIState.replace(serializers.deserialize(value, + specifiedType: const FullType(TransactionUIState)) + as TransactionUIState); + break; case 'bankAccountUIState': result.bankAccountUIState.replace(serializers.deserialize(value, specifiedType: const FullType(BankAccountUIState)) @@ -361,6 +369,8 @@ class _$UIState extends UIState { @override final InvoiceUIState invoiceUIState; @override + final TransactionUIState transactionUIState; + @override final BankAccountUIState bankAccountUIState; @override final PurchaseOrderUIState purchaseOrderUIState; @@ -428,6 +438,7 @@ class _$UIState extends UIState { this.productUIState, this.clientUIState, this.invoiceUIState, + this.transactionUIState, this.bankAccountUIState, this.purchaseOrderUIState, this.recurringExpenseUIState, @@ -476,6 +487,8 @@ class _$UIState extends UIState { clientUIState, 'UIState', 'clientUIState'); BuiltValueNullFieldError.checkNotNull( invoiceUIState, 'UIState', 'invoiceUIState'); + BuiltValueNullFieldError.checkNotNull( + transactionUIState, 'UIState', 'transactionUIState'); BuiltValueNullFieldError.checkNotNull( bankAccountUIState, 'UIState', 'bankAccountUIState'); BuiltValueNullFieldError.checkNotNull( @@ -552,6 +565,7 @@ class _$UIState extends UIState { productUIState == other.productUIState && clientUIState == other.clientUIState && invoiceUIState == other.invoiceUIState && + transactionUIState == other.transactionUIState && bankAccountUIState == other.bankAccountUIState && purchaseOrderUIState == other.purchaseOrderUIState && recurringExpenseUIState == other.recurringExpenseUIState && @@ -600,7 +614,7 @@ class _$UIState extends UIState { $jc( $jc( $jc( - $jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc(0, selectedCompanyIndex.hashCode), currentRoute.hashCode), previousRoute.hashCode), loadingEntityType.hashCode), previewStack.hashCode), filterStack.hashCode), filter.hashCode), filterClearedAt.hashCode), lastActivityAt.hashCode), dashboardUIState.hashCode), productUIState.hashCode), clientUIState.hashCode), invoiceUIState.hashCode), bankAccountUIState.hashCode), purchaseOrderUIState.hashCode), recurringExpenseUIState.hashCode), subscriptionUIState.hashCode), taskStatusUIState.hashCode), expenseCategoryUIState.hashCode), + $jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc(0, selectedCompanyIndex.hashCode), currentRoute.hashCode), previousRoute.hashCode), loadingEntityType.hashCode), previewStack.hashCode), filterStack.hashCode), filter.hashCode), filterClearedAt.hashCode), lastActivityAt.hashCode), dashboardUIState.hashCode), productUIState.hashCode), clientUIState.hashCode), invoiceUIState.hashCode), transactionUIState.hashCode), bankAccountUIState.hashCode), purchaseOrderUIState.hashCode), recurringExpenseUIState.hashCode), subscriptionUIState.hashCode), taskStatusUIState.hashCode), expenseCategoryUIState.hashCode), recurringInvoiceUIState.hashCode), webhookUIState.hashCode), tokenUIState.hashCode), @@ -638,6 +652,7 @@ class _$UIState extends UIState { ..add('productUIState', productUIState) ..add('clientUIState', clientUIState) ..add('invoiceUIState', invoiceUIState) + ..add('transactionUIState', transactionUIState) ..add('bankAccountUIState', bankAccountUIState) ..add('purchaseOrderUIState', purchaseOrderUIState) ..add('recurringExpenseUIState', recurringExpenseUIState) @@ -739,6 +754,12 @@ class UIStateBuilder implements Builder { set invoiceUIState(InvoiceUIStateBuilder invoiceUIState) => _$this._invoiceUIState = invoiceUIState; + TransactionUIStateBuilder _transactionUIState; + TransactionUIStateBuilder get transactionUIState => + _$this._transactionUIState ??= new TransactionUIStateBuilder(); + set transactionUIState(TransactionUIStateBuilder transactionUIState) => + _$this._transactionUIState = transactionUIState; + BankAccountUIStateBuilder _bankAccountUIState; BankAccountUIStateBuilder get bankAccountUIState => _$this._bankAccountUIState ??= new BankAccountUIStateBuilder(); @@ -913,6 +934,7 @@ class UIStateBuilder implements Builder { _productUIState = $v.productUIState.toBuilder(); _clientUIState = $v.clientUIState.toBuilder(); _invoiceUIState = $v.invoiceUIState.toBuilder(); + _transactionUIState = $v.transactionUIState.toBuilder(); _bankAccountUIState = $v.bankAccountUIState.toBuilder(); _purchaseOrderUIState = $v.purchaseOrderUIState.toBuilder(); _recurringExpenseUIState = $v.recurringExpenseUIState.toBuilder(); @@ -978,6 +1000,7 @@ class UIStateBuilder implements Builder { productUIState: productUIState.build(), clientUIState: clientUIState.build(), invoiceUIState: invoiceUIState.build(), + transactionUIState: transactionUIState.build(), bankAccountUIState: bankAccountUIState.build(), purchaseOrderUIState: purchaseOrderUIState.build(), recurringExpenseUIState: recurringExpenseUIState.build(), @@ -1019,6 +1042,8 @@ class UIStateBuilder implements Builder { clientUIState.build(); _$failedField = 'invoiceUIState'; invoiceUIState.build(); + _$failedField = 'transactionUIState'; + transactionUIState.build(); _$failedField = 'bankAccountUIState'; bankAccountUIState.build(); _$failedField = 'purchaseOrderUIState'; diff --git a/lib/ui/app/menu_drawer.dart b/lib/ui/app/menu_drawer.dart index 70b377d46..721c29547 100644 --- a/lib/ui/app/menu_drawer.dart +++ b/lib/ui/app/menu_drawer.dart @@ -613,6 +613,13 @@ class _MenuDrawerState extends State { iconTooltip: localization.newExpense, ), // STARTER: menu - do not remove comment + DrawerTile( + company: company, + entityType: EntityType.transaction, + icon: getEntityIcon(EntityType.transaction), + title: localization.transactions, + ), + DrawerTile( company: company, entityType: EntityType.recurringExpense, diff --git a/lib/utils/i18n.dart b/lib/utils/i18n.dart index e175c0b4c..0b8d51150 100644 --- a/lib/utils/i18n.dart +++ b/lib/utils/i18n.dart @@ -16,6 +16,18 @@ mixin LocalizationsProvider on LocaleCodeAware { static final Map> _localizedValues = { 'en': { // STARTER: lang key - do not remove comment + 'transaction': 'Transaction', + 'transactions': 'Transactions', + 'new_transaction': 'New Transaction', + 'edit_transaction': 'Edit Transaction', + 'created_transaction': 'Successfully created transaction', + 'updated_transaction': 'Successfully updated transaction', + 'archived_transaction': 'Successfully archived transaction', + 'deleted_transaction': 'Successfully deleted transaction', + 'removed_transaction': 'Successfully removed transaction', + 'restored_transaction': 'Successfully restored transaction', + 'search_transaction': 'Search Transaction', + 'bank_account': 'Bank Account', 'bank_accounts': 'Bank Accounts', 'archived_bank_account': 'Successfully archived bank account', @@ -87232,6 +87244,36 @@ mixin LocalizationsProvider on LocaleCodeAware { _localizedValues['en']['search_bank_account']; // STARTER: lang field - do not remove comment + String get transaction => + _localizedValues[localeCode]['transaction'] ?? + _localizedValues['en']['transaction']; + String get transactions => + _localizedValues[localeCode]['transactions'] ?? + _localizedValues['en']['transactions']; + String get newTransaction => + _localizedValues[localeCode]['new_transaction'] ?? + _localizedValues['en']['new_transaction']; + String get createdTransaction => + _localizedValues[localeCode]['created_transaction'] ?? + _localizedValues['en']['created_transaction']; + String get updatedTransaction => + _localizedValues[localeCode]['updated_transaction'] ?? + _localizedValues['en']['updated_transaction']; + String get archivedTransaction => + _localizedValues[localeCode]['archived_transaction'] ?? + _localizedValues['en']['archived_transaction']; + String get deletedTransaction => + _localizedValues[localeCode]['deleted_transaction'] ?? + _localizedValues['en']['deleted_transaction']; + String get restoredTransaction => + _localizedValues[localeCode]['restored_transaction'] ?? + _localizedValues['en']['restored_transaction']; + String get editTransaction => + _localizedValues[localeCode]['edit_transaction'] ?? + _localizedValues['en']['edit_transaction']; + String get searchTransaction => + _localizedValues[localeCode]['search_transaction'] ?? + _localizedValues['en']['search_transaction']; String lookup(String key) { final lookupKey = toSnakeCase(key); diff --git a/starter.sh b/starter.sh index fbdd2fecd..50c3add5f 100644 --- a/starter.sh +++ b/starter.sh @@ -188,7 +188,7 @@ else echo "app_state: import" comment="STARTER: import - do not remove comment" code="import 'package:${package}\/redux\/${module_snake}\/${module_snake}_state.dart';import 'package:${package}\/ui\/${module_snake}\/edit\/${module_snake}_edit_vm.dart';import 'package:${package}\/redux\/${module_snake}\/${module_snake}_selectors.dart';${lineBreak}" - sed -i -e "s/$comment/$comment${lineBreak}$code/g" ./lib/redux/app/app_state.dart + sed -i -e "s/$comment/$code${lineBreak}$comment/g" ./lib/redux/app/app_state.dart echo "app_state: list" comment="STARTER: states switch list - do not remove comment" @@ -295,10 +295,6 @@ else comment="STARTER: sort default - do not remove comment" code="return ${module_camel}A.${element}.compareTo(${module_camel}B.${element});${lineBreak}" sed -i -e "s/$comment/$comment${lineBreak}$code/g" "./lib/data/models/${module_snake}_model.dart" - - comment="STARTER: display name - do not remove comment" - code="return ${element};${lineBreak}" - sed -i -e "s/$comment/$comment${lineBreak}$code/g" "./lib/data/models/${module_snake}_model.dart" fi if [ "$idx" -eq 1 ]; then @@ -312,7 +308,7 @@ else echo "main: import" comment="STARTER: import - do not remove comment" code="import 'package:${package}\/redux\/${module_snake}\/${module_snake}_middleware.dart';${lineBreak}" - sed -i -e "s/$comment/$comment${lineBreak}$code/g" ./lib/main.dart + sed -i -e "s/$code/$code${lineBreak}$comment/g" ./lib/main.dart comment="STARTER: middleware - do not remove comment" code="..addAll(createStore${Modules}Middleware())${lineBreak}" @@ -323,7 +319,7 @@ else code="${code}import 'package:${package}\/ui\/${module_snake}\/edit\/${module_snake}_edit_vm.dart';${lineBreak}" code="${code}import 'package:${package}\/ui\/${module_snake}\/view\/${module_snake}_view_vm.dart';${lineBreak}" code="${code}import 'package:${package}\/ui\/${module_snake}\/${module_snake}_screen_vm.dart';${lineBreak}" - sed -i -e "s/$comment/$comment${lineBreak}$code/g" ./lib/main_app.dart + sed -i -e "s/$comment/$code${lineBreak}$comment/g" ./lib/main_app.dart comment="STARTER: routes - do not remove comment" code="${Module}Screen.route: (context) => ${Module}ScreenBuilder(),${lineBreak}" @@ -336,9 +332,8 @@ else sed -i -e "s/$comment/$comment${lineBreak}$code/g" ./lib/data/models/models.dart comment="STARTER: import - do not remove comment" - code="import 'package:${package}\/data\/models\/${module_snake}_model.dart';${lineBreak}" - code="${code}import 'package:${package}\/redux\/${module_snake}\/${module_snake}_state.dart';${lineBreak}" - sed -i -e "s/$comment/$comment${lineBreak}$code/g" ./lib/data/models/serializers.dart + code="import 'package:${package}\/redux\/${module_snake}\/${module_snake}_state.dart';${lineBreak}" + sed -i -e "s/$comment/$code${lineBreak}$comment/g" ./lib/data/models/serializers.dart comment="STARTER: serializers - do not remove comment" code="${Module}Entity,${lineBreak}${Module}ListResponse,${lineBreak}${Module}ItemResponse,${lineBreak}" @@ -346,7 +341,7 @@ else comment="STARTER: import - do not remove comment" code="import 'package:${package}\/redux\/${module_snake}\/${module_snake}_state.dart';${lineBreak}" - sed -i -e "s/$comment/$comment${lineBreak}$code/g" ./lib/redux/company/company_state.dart + sed -i -e "s/$comment/$code${lineBreak}$comment/g" ./lib/redux/company/company_state.dart comment="STARTER: fields - do not remove comment" code="${Module}State get ${module_camel}State;${lineBreak}" @@ -358,7 +353,7 @@ else comment="STARTER: import - do not remove comment" code="import 'package:${package}\/redux\/${module_snake}\/${module_snake}_reducer.dart';${lineBreak}" - sed -i -e "s/$comment/$comment${lineBreak}$code/g" ./lib/redux/company/company_reducer.dart + sed -i -e "s/$comment/$code${lineBreak}$comment/g" ./lib/redux/company/company_reducer.dart comment="STARTER: reducer - do not remove comment" code="..${module_camel}State.replace(${modules_camel}Reducer(state.${module_camel}State, action))${lineBreak}" @@ -375,7 +370,7 @@ else comment="STARTER: import - do not remove comment" code="import 'package:${package}\/redux\/${module_snake}\/${module_snake}_state.dart';${lineBreak}" - sed -i -e "s/$comment/$comment${lineBreak}$code/g" ./lib/redux/ui/ui_state.dart + sed -i -e "s/$comment/$code${lineBreak}$comment/g" ./lib/redux/ui/ui_state.dart comment="STARTER: properties - do not remove comment" code="${Module}UIState get ${module_camel}UIState;${lineBreak}" @@ -387,7 +382,7 @@ else comment="STARTER: import - do not remove comment" code="import 'package:${package}\/redux\/${module_snake}\/${module_snake}_reducer.dart';${lineBreak}" - sed -i -e "s/$comment/$comment${lineBreak}$code/g" ./lib/redux/ui/ui_reducer.dart + sed -i -e "s/$comment/$code${lineBreak}$comment/g" ./lib/redux/ui/ui_reducer.dart comment="STARTER: reducer - do not remove comment" code="..${module_camel}UIState.replace(${module_camel}UIReducer(state.${module_camel}UIState, action))${lineBreak}" @@ -395,7 +390,7 @@ else comment="STARTER: import - do not remove comment" code="import 'package:${package}\/redux\/${module_snake}\/${module_snake}_actions.dart';${lineBreak}" - sed -i -e "s/$comment/$comment${lineBreak}$code/g" ./lib/redux/app/app_reducer.dart + sed -i -e "s/$comment/$code${lineBreak}$comment/g" ./lib/redux/app/app_reducer.dart comment="STARTER: errors - do not remove comment" code="TypedReducer((state, action) { return '\${action.error}'; }),${lineBreak}" @@ -407,11 +402,11 @@ else comment="STARTER: import - do not remove comment" code="import 'package:${package}\/redux\/${module_snake}\/${module_snake}_actions.dart';${lineBreak}" - sed -i -e "s/$comment/$comment${lineBreak}$code/g" ./lib/redux/ui/pref_reducer.dart + sed -i -e "s/$comment/$code${lineBreak}$comment/g" ./lib/redux/ui/pref_reducer.dart comment="STARTER: import - do not remove comment" code="import 'package:${package}\/redux\/${module_snake}\/${module_snake}_actions.dart';${lineBreak}" - sed -i -e "s/$comment/$comment${lineBreak}$code/g" ./lib/redux/app/app_actions.dart + sed -i -e "s/$comment/$code${lineBreak}$comment/g" ./lib/redux/app/app_actions.dart comment="STARTER: view list - do not remove comment" code="case EntityType.${module_camel}: action = View${Module}List(); break;${lineBreak}" diff --git a/stubs/data/models/stub_model b/stubs/data/models/stub_model index 926829eef..37432ce81 100644 --- a/stubs/data/models/stub_model +++ b/stubs/data/models/stub_model @@ -73,10 +73,6 @@ abstract class StubEntity extends Object with BaseEntity implements Built EntityType.stub; - String get displayName { - // STARTER: display name - do not remove comment - } - @override List getActions( @@ -121,8 +117,7 @@ abstract class StubEntity extends Object with BaseEntity implements Built b diff --git a/stubs/redux/stub/stub_selectors b/stubs/redux/stub/stub_selectors index a1487b1e9..97181bf4d 100644 --- a/stubs/redux/stub/stub_selectors +++ b/stubs/redux/stub/stub_selectors @@ -1,4 +1,3 @@ -import 'package:invoiceninja_flutter/data/models/stub_model.dart'; import 'package:invoiceninja_flutter/redux/static/static_state.dart'; import 'package:invoiceninja_flutter/redux/app/app_state.dart'; import 'package:memoize/memoize.dart'; @@ -84,7 +83,7 @@ List filteredStubsSelector( list.sort((stubAId, stubBId) { final stubA = stubMap[stubAId]; final stubB = stubMap[stubBId]; - return stubAA.compareTo(stubB, stubListState.sortField, + return stubA.compareTo(stubB, stubListState.sortField, stubListState.sortAscending); }); diff --git a/stubs/redux/stub/stub_state b/stubs/redux/stub/stub_state index 8d6d6553a..c58bb2f59 100644 --- a/stubs/redux/stub/stub_state +++ b/stubs/redux/stub/stub_state @@ -2,7 +2,6 @@ import 'dart:async'; import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; import 'package:built_collection/built_collection.dart'; -import 'package:invoiceninja_flutter/data/models/stub_model.dart'; import 'package:invoiceninja_flutter/redux/ui/entity_ui_state.dart'; import 'package:invoiceninja_flutter/redux/ui/list_ui_state.dart'; import 'package:invoiceninja_flutter/data/models/models.dart'; diff --git a/stubs/ui/stub/edit/stub_edit b/stubs/ui/stub/edit/stub_edit index fd7d2745b..797befb53 100644 --- a/stubs/ui/stub/edit/stub_edit +++ b/stubs/ui/stub/edit/stub_edit @@ -1,4 +1,3 @@ -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:invoiceninja_flutter/ui/app/edit_scaffold.dart'; import 'package:invoiceninja_flutter/ui/app/form_card.dart'; diff --git a/stubs/ui/stub/edit/stub_edit_vm b/stubs/ui/stub/edit/stub_edit_vm index 45d6f421e..af1835c19 100644 --- a/stubs/ui/stub/edit/stub_edit_vm +++ b/stubs/ui/stub/edit/stub_edit_vm @@ -1,17 +1,14 @@ import 'dart:async'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_redux/flutter_redux.dart'; import 'package:invoiceninja_flutter/redux/app/app_actions.dart'; import 'package:invoiceninja_flutter/redux/ui/ui_actions.dart'; -import 'package:invoiceninja_flutter/utils/platforms.dart'; import 'package:redux/redux.dart'; import 'package:invoiceninja_flutter/utils/completers.dart'; import 'package:invoiceninja_flutter/data/models/models.dart'; import 'package:invoiceninja_flutter/ui/app/dialogs/error_dialog.dart'; import 'package:invoiceninja_flutter/ui/stub/view/stub_view_vm.dart'; import 'package:invoiceninja_flutter/redux/stub/stub_actions.dart'; -import 'package:invoiceninja_flutter/data/models/stub_model.dart'; import 'package:invoiceninja_flutter/ui/stub/edit/stub_edit.dart'; import 'package:invoiceninja_flutter/redux/app/app_state.dart'; import 'package:flutter_styled_toast/flutter_styled_toast.dart'; diff --git a/stubs/ui/stub/stub_list_item b/stubs/ui/stub/stub_list_item index 1ebd13ea8..b92d19bbe 100644 --- a/stubs/ui/stub/stub_list_item +++ b/stubs/ui/stub/stub_list_item @@ -1,10 +1,8 @@ import 'package:flutter_redux/flutter_redux.dart'; import 'package:invoiceninja_flutter/redux/app/app_actions.dart'; -import 'package:invoiceninja_flutter/data/models/stub_model.dart'; import 'package:invoiceninja_flutter/redux/app/app_state.dart'; import 'package:invoiceninja_flutter/ui/app/entity_state_label.dart'; import 'package:invoiceninja_flutter/utils/formatting.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:invoiceninja_flutter/data/models/models.dart'; import 'package:invoiceninja_flutter/ui/app/dismissible_entity.dart'; diff --git a/stubs/ui/stub/stub_list_vm b/stubs/ui/stub/stub_list_vm index c24a44583..d345b25b1 100644 --- a/stubs/ui/stub/stub_list_vm +++ b/stubs/ui/stub/stub_list_vm @@ -1,13 +1,10 @@ import 'dart:async'; -import 'package:invoiceninja_flutter/data/models/stub_model.dart'; -import 'package:invoiceninja_flutter/ui/app/entities/entity_actions_dialog.dart'; import 'package:invoiceninja_flutter/ui/app/tables/entity_list.dart'; import 'package:invoiceninja_flutter/ui/stub/stub_list_item.dart'; import 'package:invoiceninja_flutter/ui/stub/stub_presenter.dart'; import 'package:redux/redux.dart'; import 'package:invoiceninja_flutter/redux/app/app_actions.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_redux/flutter_redux.dart'; import 'package:built_collection/built_collection.dart'; @@ -88,8 +85,10 @@ class StubListVM { state: state, userCompany: state.userCompany, listState: state.stubListState, - stubList: memoizedFilteredStubList(state.stubState.map, - state.stubState.list, state.stubListState), + stubList: memoizedFilteredStubList(state.getUISelection(EntityType.stub), + state.stubState.map, + state.stubState.list, + state.stubListState), stubMap: state.stubState.map, isLoading: state.isLoading, filter: state.stubUIState.listUIState.filter, diff --git a/stubs/ui/stub/stub_screen b/stubs/ui/stub/stub_screen index 1629b2236..5cb1f7af0 100644 --- a/stubs/ui/stub/stub_screen +++ b/stubs/ui/stub/stub_screen @@ -27,7 +27,6 @@ class StubScreen extends StatelessWidget { Widget build(BuildContext context) { final store = StoreProvider.of(context); final state = store.state; - final company = state.company; final userCompany = state.userCompany; final localization = AppLocalization.of(context); diff --git a/stubs/ui/stub/stub_screen_vm b/stubs/ui/stub/stub_screen_vm index 0a83b6573..c35b73133 100644 --- a/stubs/ui/stub/stub_screen_vm +++ b/stubs/ui/stub/stub_screen_vm @@ -1,5 +1,4 @@ import 'package:built_collection/built_collection.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_redux/flutter_redux.dart'; diff --git a/stubs/ui/stub/view/stub_view b/stubs/ui/stub/view/stub_view index cd213c122..0e0bc4fd8 100644 --- a/stubs/ui/stub/view/stub_view +++ b/stubs/ui/stub/view/stub_view @@ -1,4 +1,3 @@ -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:invoiceninja_flutter/ui/app/scrollable_listview.dart'; import 'package:invoiceninja_flutter/ui/stub/view/stub_view_vm.dart'; diff --git a/stubs/ui/stub/view/stub_view_vm b/stubs/ui/stub/view/stub_view_vm index 5dc9e2794..760b6fde1 100644 --- a/stubs/ui/stub/view/stub_view_vm +++ b/stubs/ui/stub/view/stub_view_vm @@ -1,13 +1,11 @@ import 'dart:async'; import 'package:invoiceninja_flutter/redux/app/app_actions.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:invoiceninja_flutter/utils/completers.dart'; import 'package:invoiceninja_flutter/utils/localization.dart'; import 'package:redux/redux.dart'; import 'package:flutter_redux/flutter_redux.dart'; import 'package:invoiceninja_flutter/redux/stub/stub_actions.dart'; -import 'package:invoiceninja_flutter/data/models/stub_model.dart'; import 'package:invoiceninja_flutter/data/models/models.dart'; import 'package:invoiceninja_flutter/ui/stub/view/stub_view.dart'; import 'package:invoiceninja_flutter/redux/app/app_state.dart';