diff --git a/lib/redux/app/app_middleware.dart b/lib/redux/app/app_middleware.dart index 6a9659b4a..06d187f3e 100644 --- a/lib/redux/app/app_middleware.dart +++ b/lib/redux/app/app_middleware.dart @@ -321,8 +321,8 @@ Middleware _createUserLoggedIn( authRepository.saveAuthState(state.authState); uiRepository.saveUIState(state.uiState); staticRepository.saveStaticState(state.staticState); - for (var i = 0; i < state.companyStates.length; i++) { - companyRepositories[i].saveCompanyState(state.companyStates[i]); + for (var i = 0; i < state.userCompanyStates.length; i++) { + companyRepositories[i].saveCompanyState(state.userCompanyStates[i]); } } }; @@ -402,7 +402,7 @@ Middleware _createPersistData( final AppState state = store.state; final index = state.uiState.selectedCompanyIndex; - companyRepositories[index].saveCompanyState(state.companyStates[index]); + companyRepositories[index].saveCompanyState(state.userCompanyStates[index]); }; } diff --git a/lib/redux/app/app_reducer.dart b/lib/redux/app/app_reducer.dart index 6c516b13c..792539f8d 100644 --- a/lib/redux/app/app_reducer.dart +++ b/lib/redux/app/app_reducer.dart @@ -40,7 +40,7 @@ AppState appReducer(AppState state, dynamic action) { ..authState.replace(authReducer(state.authState, action)) ..staticState.replace(staticReducer(state.staticState, action)) ..companyStates[state.uiState.selectedCompanyIndex] = companyReducer( - state.companyStates[state.uiState.selectedCompanyIndex], action) + state.userCompanyStates[state.uiState.selectedCompanyIndex], action) ..uiState.replace(uiReducer(state.uiState, action))); } diff --git a/lib/redux/app/app_state.dart b/lib/redux/app/app_state.dart index 88a25eab7..482a1eb0f 100644 --- a/lib/redux/app/app_state.dart +++ b/lib/redux/app/app_state.dart @@ -60,7 +60,7 @@ abstract class AppState implements Built { lastError: '', authState: AuthState(), staticState: StaticState(), - companyStates: List.generate(10, (i) => i + 1) + userCompanyStates: List.generate(10, (i) => i + 1) .map((index) => UserCompanyState()) .toList(), uiState: uiState ?? UIState(), @@ -83,13 +83,13 @@ abstract class AppState implements Built { UIState get uiState; - List get companyStates; + List get userCompanyStates; //factory AppState([void updates(AppStateBuilder b)]) = _$AppState; static Serializer get serializer => _$appStateSerializer; - UserCompanyState get selectedCompanyState => - companyStates[uiState.selectedCompanyIndex]; + UserCompanyState get userCompanyState => + userCompanyStates[uiState.selectedCompanyIndex]; bool get isLoaded { return dashboardState.isLoaded && @@ -97,18 +97,18 @@ abstract class AppState implements Built { clientState.isLoaded; } - CompanyEntity get selectedCompany => selectedCompanyState.company; + CompanyEntity get company => userCompanyState.company; - DashboardState get dashboardState => selectedCompanyState.dashboardState; + DashboardState get dashboardState => userCompanyState.dashboardState; DashboardUIState get dashboardUIState => uiState.dashboardUIState; - UserEntity get user => selectedCompanyState.user; + UserEntity get user => userCompanyState.user; - UserCompanyEntity get userCompany => selectedCompanyState.userCompany; + UserCompanyEntity get userCompany => userCompanyState.userCompany; Credentials get credentials => - Credentials(token: selectedCompanyState.token.token, url: authState.url); + Credentials(token: userCompanyState.token.token, url: authState.url); BuiltMap getEntityMap(EntityType type) { switch (type) { @@ -143,7 +143,7 @@ abstract class AppState implements Built { return quoteState.map; case EntityType.expenseCategory: // TODO move to expenseCategoryState.map - return selectedCompany.expenseCategoryMap; + return company.expenseCategoryMap; case EntityType.paymentType: return staticState.paymentTypeMap; case EntityType.currency: @@ -207,39 +207,39 @@ abstract class AppState implements Built { return getUIState(type).listUIState; } - ProductState get productState => selectedCompanyState.productState; + ProductState get productState => userCompanyState.productState; ProductUIState get productUIState => uiState.productUIState; ListUIState get productListState => uiState.productUIState.listUIState; - ClientState get clientState => selectedCompanyState.clientState; + ClientState get clientState => userCompanyState.clientState; ClientUIState get clientUIState => uiState.clientUIState; ListUIState get clientListState => uiState.clientUIState.listUIState; - InvoiceState get invoiceState => selectedCompanyState.invoiceState; + InvoiceState get invoiceState => userCompanyState.invoiceState; InvoiceUIState get invoiceUIState => uiState.invoiceUIState; ListUIState get invoiceListState => uiState.invoiceUIState.listUIState; // STARTER: state getters - do not remove comment - UserState get userState => selectedCompanyState.userState; + UserState get userState => userCompanyState.userState; ListUIState get userListState => uiState.userUIState.listUIState; UserUIState get userUIState => uiState.userUIState; - TaxRateState get taxRateState => selectedCompanyState.taxRateState; + TaxRateState get taxRateState => userCompanyState.taxRateState; ListUIState get taxRateListState => uiState.taxRateUIState.listUIState; TaxRateUIState get taxRateUIState => uiState.taxRateUIState; CompanyGatewayState get companyGatewayState => - selectedCompanyState.companyGatewayState; + userCompanyState.companyGatewayState; ListUIState get companyGatewayListState => uiState.companyGatewayUIState.listUIState; @@ -247,49 +247,49 @@ abstract class AppState implements Built { CompanyGatewayUIState get companyGatewayUIState => uiState.companyGatewayUIState; - GroupState get groupState => selectedCompanyState.groupState; + GroupState get groupState => userCompanyState.groupState; ListUIState get groupListState => uiState.groupUIState.listUIState; GroupUIState get groupUIState => uiState.groupUIState; - DocumentState get documentState => selectedCompanyState.documentState; + DocumentState get documentState => userCompanyState.documentState; ListUIState get documentListState => uiState.documentUIState.listUIState; DocumentUIState get documentUIState => uiState.documentUIState; - ExpenseState get expenseState => selectedCompanyState.expenseState; + ExpenseState get expenseState => userCompanyState.expenseState; ListUIState get expenseListState => uiState.expenseUIState.listUIState; ExpenseUIState get expenseUIState => uiState.expenseUIState; - VendorState get vendorState => selectedCompanyState.vendorState; + VendorState get vendorState => userCompanyState.vendorState; ListUIState get vendorListState => uiState.vendorUIState.listUIState; VendorUIState get vendorUIState => uiState.vendorUIState; - TaskState get taskState => selectedCompanyState.taskState; + TaskState get taskState => userCompanyState.taskState; ListUIState get taskListState => uiState.taskUIState.listUIState; TaskUIState get taskUIState => uiState.taskUIState; - ProjectState get projectState => selectedCompanyState.projectState; + ProjectState get projectState => userCompanyState.projectState; ListUIState get projectListState => uiState.projectUIState.listUIState; ProjectUIState get projectUIState => uiState.projectUIState; - PaymentState get paymentState => selectedCompanyState.paymentState; + PaymentState get paymentState => userCompanyState.paymentState; ListUIState get paymentListState => uiState.paymentUIState.listUIState; PaymentUIState get paymentUIState => uiState.paymentUIState; - QuoteState get quoteState => selectedCompanyState.quoteState; + QuoteState get quoteState => userCompanyState.quoteState; ListUIState get quoteListState => uiState.quoteUIState.listUIState; diff --git a/lib/redux/app/app_state.g.dart b/lib/redux/app/app_state.g.dart index a045f44f1..85904fb37 100644 --- a/lib/redux/app/app_state.g.dart +++ b/lib/redux/app/app_state.g.dart @@ -40,7 +40,7 @@ class _$AppStateSerializer implements StructuredSerializer { serializers.serialize(object.uiState, specifiedType: const FullType(UIState)), 'companyStates', - serializers.serialize(object.companyStates, + serializers.serialize(object.userCompanyStates, specifiedType: const FullType(List, const [const FullType(UserCompanyState)])), ]; @@ -116,7 +116,7 @@ class _$AppState extends AppState { @override final UIState uiState; @override - final List companyStates; + final List userCompanyStates; factory _$AppState([void Function(AppStateBuilder) updates]) => (new AppStateBuilder()..update(updates)).build(); @@ -129,7 +129,7 @@ class _$AppState extends AppState { this.authState, this.staticState, this.uiState, - this.companyStates}) + this.userCompanyStates}) : super._() { if (isLoading == null) { throw new BuiltValueNullFieldError('AppState', 'isLoading'); @@ -152,7 +152,7 @@ class _$AppState extends AppState { if (uiState == null) { throw new BuiltValueNullFieldError('AppState', 'uiState'); } - if (companyStates == null) { + if (userCompanyStates == null) { throw new BuiltValueNullFieldError('AppState', 'companyStates'); } } @@ -175,7 +175,7 @@ class _$AppState extends AppState { authState == other.authState && staticState == other.staticState && uiState == other.uiState && - companyStates == other.companyStates; + userCompanyStates == other.userCompanyStates; } @override @@ -191,7 +191,7 @@ class _$AppState extends AppState { authState.hashCode), staticState.hashCode), uiState.hashCode), - companyStates.hashCode)); + userCompanyStates.hashCode)); } } @@ -246,7 +246,7 @@ class AppStateBuilder implements Builder { _authState = _$v.authState?.toBuilder(); _staticState = _$v.staticState?.toBuilder(); _uiState = _$v.uiState?.toBuilder(); - _companyStates = _$v.companyStates; + _companyStates = _$v.userCompanyStates; _$v = null; } return this; @@ -278,7 +278,7 @@ class AppStateBuilder implements Builder { authState: authState.build(), staticState: staticState.build(), uiState: uiState.build(), - companyStates: companyStates); + userCompanyStates: companyStates); } catch (_) { String _$failedField; try { diff --git a/lib/redux/client/client_actions.dart b/lib/redux/client/client_actions.dart index 919802341..0dc489a4a 100644 --- a/lib/redux/client/client_actions.dart +++ b/lib/redux/client/client_actions.dart @@ -286,7 +286,7 @@ void handleClientAction( final store = StoreProvider.of(context); final state = store.state; - final CompanyEntity company = state.selectedCompany; + final CompanyEntity company = state.company; final localization = AppLocalization.of(context); final clientIds = clients.map((client) => client.id).toList(); final client = clients[0]; diff --git a/lib/redux/company/company_selectors.dart b/lib/redux/company/company_selectors.dart index 8c3ca5f62..c60400460 100644 --- a/lib/redux/company/company_selectors.dart +++ b/lib/redux/company/company_selectors.dart @@ -103,7 +103,7 @@ List filteredSelector(String filter, UserCompanyState state) { List companiesSelector(AppState state) { final List list = []; - for (var companyState in state.companyStates) { + for (var companyState in state.userCompanyStates) { if (companyState.company != null) { list.add(companyState.company); } @@ -116,7 +116,7 @@ List companiesSelector(AppState state) { String localeSelector(AppState state) { final locale = state.staticState - ?.languageMap[state.selectedCompany?.settings?.languageId]?.locale ?? + ?.languageMap[state.company?.settings?.languageId]?.locale ?? 'en'; // https://github.com/flutter/flutter/issues/32090 diff --git a/lib/redux/company/company_state.dart b/lib/redux/company/company_state.dart index 74f31ce81..ed83859b5 100644 --- a/lib/redux/company/company_state.dart +++ b/lib/redux/company/company_state.dart @@ -51,11 +51,8 @@ abstract class UserCompanyState quoteState: QuoteState(), // STARTER: constructor - do not remove comment userState: UserState(), - taxRateState: TaxRateState(), - companyGatewayState: CompanyGatewayState(), - groupState: GroupState(), ); } diff --git a/lib/redux/document/document_middleware.dart b/lib/redux/document/document_middleware.dart index a2c8c340b..4a4330be0 100644 --- a/lib/redux/document/document_middleware.dart +++ b/lib/redux/document/document_middleware.dart @@ -167,7 +167,7 @@ Middleware _restoreDocument(DocumentRepository repository) { Middleware _saveDocument(DocumentRepository repository) { return (Store store, dynamic dynamicAction, NextDispatcher next) { final action = dynamicAction as SaveDocumentRequest; - if (store.state.selectedCompany.isEnterprisePlan) { + if (store.state.company.isEnterprisePlan) { repository .saveData(store.state.credentials, action.document) .then((DocumentEntity document) { diff --git a/lib/redux/expense/expense_actions.dart b/lib/redux/expense/expense_actions.dart index 5c0818ff2..0b47f104d 100644 --- a/lib/redux/expense/expense_actions.dart +++ b/lib/redux/expense/expense_actions.dart @@ -259,7 +259,7 @@ void handleExpenseAction( final store = StoreProvider.of(context); final state = store.state; - final CompanyEntity company = state.selectedCompany; + final CompanyEntity company = state.company; final localization = AppLocalization.of(context); final expense = expenses.first as ExpenseEntity; final expenseIds = expenses.map((expense) => expense.id).toList(); diff --git a/lib/redux/expense/expense_middleware.dart b/lib/redux/expense/expense_middleware.dart index 94a63d9d3..fba40f962 100644 --- a/lib/redux/expense/expense_middleware.dart +++ b/lib/redux/expense/expense_middleware.dart @@ -267,7 +267,7 @@ Middleware _loadExpenses(ExpenseRepository repository) { if (action.completer != null) { action.completer.complete(null); } - if (state.selectedCompany.isEnterprisePlan) { + if (state.company.isEnterprisePlan) { if (state.documentState.isStale) { store.dispatch(LoadDocuments()); } diff --git a/lib/redux/invoice/invoice_actions.dart b/lib/redux/invoice/invoice_actions.dart index f44b0acdc..20d1368d5 100644 --- a/lib/redux/invoice/invoice_actions.dart +++ b/lib/redux/invoice/invoice_actions.dart @@ -356,7 +356,7 @@ void handleInvoiceAction(BuildContext context, List invoices, final store = StoreProvider.of(context); final state = store.state; - final CompanyEntity company = state.selectedCompany; + final CompanyEntity company = state.company; final localization = AppLocalization.of(context); final invoice = invoices.first as InvoiceEntity; final invoiceIds = invoices.map((invoice) => invoice.id).toList(); diff --git a/lib/redux/product/product_actions.dart b/lib/redux/product/product_actions.dart index d23d3f9bf..564a612a4 100644 --- a/lib/redux/product/product_actions.dart +++ b/lib/redux/product/product_actions.dart @@ -223,7 +223,7 @@ void handleProductAction( convertProductToInvoiceItem(context: context, product: product); store.dispatch(EditInvoice( context: context, - invoice: InvoiceEntity(company: state.selectedCompany) + invoice: InvoiceEntity(company: state.company) .rebuild((b) => b..lineItems.add(item)))); break; case EntityAction.edit: diff --git a/lib/redux/project/project_actions.dart b/lib/redux/project/project_actions.dart index 7696d56b6..2645b138d 100644 --- a/lib/redux/project/project_actions.dart +++ b/lib/redux/project/project_actions.dart @@ -260,7 +260,7 @@ void handleProjectAction( final store = StoreProvider.of(context); final state = store.state; - final CompanyEntity company = state.selectedCompany; + final CompanyEntity company = state.company; final project = projects.first as ProjectEntity; final projectIds = projects.map((project) => project.id).toList(); diff --git a/lib/redux/settings/settings_middleware.dart b/lib/redux/settings/settings_middleware.dart index ecfec1085..d3b5ec382 100644 --- a/lib/redux/settings/settings_middleware.dart +++ b/lib/redux/settings/settings_middleware.dart @@ -107,7 +107,7 @@ Middleware _uploadLogo(SettingsRepository settingsRepository) { final state = store.state; final settingsState = state.uiState.settingsUIState; final entityId = action.type == EntityType.company - ? state.selectedCompany.id + ? state.company.id : action.type == EntityType.group ? settingsState.group.id : settingsState.client.id; diff --git a/lib/redux/task/task_actions.dart b/lib/redux/task/task_actions.dart index e9c093ee9..de01a26c0 100644 --- a/lib/redux/task/task_actions.dart +++ b/lib/redux/task/task_actions.dart @@ -294,7 +294,7 @@ void handleTaskAction( final store = StoreProvider.of(context); final state = store.state; - final CompanyEntity company = state.selectedCompany; + final CompanyEntity company = state.company; final localization = AppLocalization.of(context); final task = tasks.first as TaskEntity; final taskIds = tasks.map((task) => task.id).toList(); diff --git a/lib/redux/task/task_selectors.dart b/lib/redux/task/task_selectors.dart index 1eb832fbf..539859e43 100644 --- a/lib/redux/task/task_selectors.dart +++ b/lib/redux/task/task_selectors.dart @@ -28,7 +28,7 @@ InvoiceItemEntity convertTaskToInvoiceItem( ..taskId = task.id ..notes = notes ..cost = taskRateSelector( - company: state.selectedCompany, project: project, client: client) + company: state.company, project: project, client: client) ..quantity = round(task.duration / 3600, 3)); } diff --git a/lib/redux/vendor/vendor_actions.dart b/lib/redux/vendor/vendor_actions.dart index 31a3056a1..3e9824aaf 100644 --- a/lib/redux/vendor/vendor_actions.dart +++ b/lib/redux/vendor/vendor_actions.dart @@ -284,7 +284,7 @@ void handleVendorAction( final store = StoreProvider.of(context); final state = store.state; - final CompanyEntity company = state.selectedCompany; + final CompanyEntity company = state.company; final localization = AppLocalization.of(context); final vendor = vendors.first as VendorEntity; final vendorIds = vendors.map((vendor) => vendor.id).toList(); diff --git a/lib/ui/app/app_builder.dart b/lib/ui/app/app_builder.dart index 6ebc8e22f..2cb5dc442 100644 --- a/lib/ui/app/app_builder.dart +++ b/lib/ui/app/app_builder.dart @@ -51,7 +51,7 @@ class AppBuilderState extends State { void runCommand(BuildContext context) { print('### RUN COMMAND: $_command ###'); final store = StoreProvider.of(context); - final company = store.state.selectedCompany; + final company = store.state.company; const force = true; dynamic action; diff --git a/lib/ui/app/document_grid.dart b/lib/ui/app/document_grid.dart index cb8960f5d..eef8977db 100644 --- a/lib/ui/app/document_grid.dart +++ b/lib/ui/app/document_grid.dart @@ -28,7 +28,7 @@ class DocumentGrid extends StatelessWidget { Widget build(BuildContext context) { final localization = AppLocalization.of(context); final state = StoreProvider.of(context).state; - final company = state.selectedCompany; + final company = state.company; return ListView( children: [ diff --git a/lib/ui/app/history_drawer_vm.dart b/lib/ui/app/history_drawer_vm.dart index 1736957d9..3a6dce6cd 100644 --- a/lib/ui/app/history_drawer_vm.dart +++ b/lib/ui/app/history_drawer_vm.dart @@ -41,7 +41,7 @@ class AppDrawerVM { isLoading: state.isLoading, companies: companiesSelector(state), user: state.user, - selectedCompany: state.selectedCompany, + selectedCompany: state.company, ); } } diff --git a/lib/ui/app/lists/activity_list_tile.dart b/lib/ui/app/lists/activity_list_tile.dart index 3bf6ed205..11f42f12c 100644 --- a/lib/ui/app/lists/activity_list_tile.dart +++ b/lib/ui/app/lists/activity_list_tile.dart @@ -33,7 +33,7 @@ class ActivityListTile extends StatelessWidget { String title = localization.lookup('activity_${activity.activityTypeId}'); title = activity.getDescription( title, - user: state.selectedCompany.userMap[activity.userId] ?? UserEntity(), + user: state.company.userMap[activity.userId] ?? UserEntity(), client: state.clientState.map[activity.clientId], invoice: state.invoiceState.map[activity.invoiceId], quote: state.quoteState.map[activity.invoiceId], diff --git a/lib/ui/app/menu_drawer_vm.dart b/lib/ui/app/menu_drawer_vm.dart index 7b2466ee5..3e490ce93 100644 --- a/lib/ui/app/menu_drawer_vm.dart +++ b/lib/ui/app/menu_drawer_vm.dart @@ -47,7 +47,7 @@ class MenuDrawerVM { isLoading: state.isLoading, companies: companiesSelector(state), user: state.user, - selectedCompany: state.selectedCompany, + selectedCompany: state.company, selectedCompanyIndex: state.uiState.selectedCompanyIndex.toString(), onCompanyChanged: (BuildContext context, String companyIndex, CompanyEntity company) { diff --git a/lib/ui/app/upgrade_dialog.dart b/lib/ui/app/upgrade_dialog.dart index 78a5f2005..b84c36dab 100644 --- a/lib/ui/app/upgrade_dialog.dart +++ b/lib/ui/app/upgrade_dialog.dart @@ -152,7 +152,7 @@ class _UpgradeDialogState extends State { void upgrade(BuildContext context, ProductDetails productDetails) { final store = StoreProvider.of(context); - final company = store.state.selectedCompany; + final company = store.state.company; InAppPurchaseConnection.instance.buyNonConsumable( purchaseParam: PurchaseParam( diff --git a/lib/ui/client/client_screen.dart b/lib/ui/client/client_screen.dart index 141a59548..0f3dd9319 100644 --- a/lib/ui/client/client_screen.dart +++ b/lib/ui/client/client_screen.dart @@ -27,7 +27,7 @@ class ClientScreen extends StatelessWidget { Widget build(BuildContext context) { final store = StoreProvider.of(context); final state = store.state; - final company = state.selectedCompany; + final company = state.company; final userCompany = state.userCompany; final localization = AppLocalization.of(context); final listUIState = state.uiState.clientUIState.listUIState; diff --git a/lib/ui/client/edit/client_edit_contacts_vm.dart b/lib/ui/client/edit/client_edit_contacts_vm.dart index bf8316db4..7e1c5f63b 100644 --- a/lib/ui/client/edit/client_edit_contacts_vm.dart +++ b/lib/ui/client/edit/client_edit_contacts_vm.dart @@ -41,7 +41,7 @@ class ClientEditContactsVM { final client = state.clientUIState.editing; return ClientEditContactsVM( - company: state.selectedCompany, + company: state.company, client: client, contact: state.clientUIState.editingContact, onAddContactPressed: () { diff --git a/lib/ui/client/edit/client_edit_vm.dart b/lib/ui/client/edit/client_edit_vm.dart index 739321bca..4aa0552f8 100644 --- a/lib/ui/client/edit/client_edit_vm.dart +++ b/lib/ui/client/edit/client_edit_vm.dart @@ -57,7 +57,7 @@ class ClientEditVM { return ClientEditVM( state: state, - company: state.selectedCompany, + company: state.company, client: client, origClient: state.clientState.map[client.id], staticState: state.staticState, diff --git a/lib/ui/client/view/client_view_vm.dart b/lib/ui/client/view/client_view_vm.dart index 27b8a0b00..3b7b60ec0 100644 --- a/lib/ui/client/view/client_view_vm.dart +++ b/lib/ui/client/view/client_view_vm.dart @@ -79,7 +79,7 @@ class ClientViewVM { isLoading: state.isLoading, isDirty: client.isNew, client: client, - company: state.selectedCompany, + company: state.company, onEditPressed: (BuildContext context) { final Completer completer = Completer(); store.dispatch( @@ -98,7 +98,7 @@ class ClientViewVM { if (longPress && client.isActive) { store.dispatch(EditInvoice( context: context, - invoice: InvoiceEntity(company: state.selectedCompany))); + invoice: InvoiceEntity(company: state.company))); store.dispatch(UpdateInvoiceClient(client: client)); } else { store.dispatch(FilterInvoicesByEntity( @@ -111,7 +111,7 @@ class ClientViewVM { store.dispatch(EditQuote( context: context, quote: InvoiceEntity( - company: state.selectedCompany, isQuote: true))); + company: state.company, isQuote: true))); store.dispatch(UpdateQuoteClient(client: client)); } else { store.dispatch(FilterQuotesByEntity( @@ -123,7 +123,7 @@ class ClientViewVM { if (longPress && client.isActive) { store.dispatch(EditPayment( context: context, - payment: PaymentEntity(company: state.selectedCompany) + payment: PaymentEntity(company: state.company) .rebuild((b) => b..clientId = client.id))); } else { store.dispatch(FilterPaymentsByEntity( @@ -160,7 +160,7 @@ class ClientViewVM { store.dispatch(EditExpense( context: context, expense: ExpenseEntity( - company: state.selectedCompany, + company: state.company, client: client, uiState: state.uiState))); } else { diff --git a/lib/ui/company_gateway/edit/company_gateway_edit.dart b/lib/ui/company_gateway/edit/company_gateway_edit.dart index 507ca6772..224aafbbf 100644 --- a/lib/ui/company_gateway/edit/company_gateway_edit.dart +++ b/lib/ui/company_gateway/edit/company_gateway_edit.dart @@ -675,7 +675,7 @@ class _FeesEditorState extends State { final localization = AppLocalization.of(context); final viewModel = widget.viewModel; final companyGateway = viewModel.companyGateway; - final company = viewModel.state.selectedCompany; + final company = viewModel.state.company; final settings = companyGateway.getSettingsForGatewayTypeId(widget.gatewayTypeId); diff --git a/lib/ui/company_gateway/edit/company_gateway_edit_vm.dart b/lib/ui/company_gateway/edit/company_gateway_edit_vm.dart index 1e92b54ba..deb1f33fe 100644 --- a/lib/ui/company_gateway/edit/company_gateway_edit_vm.dart +++ b/lib/ui/company_gateway/edit/company_gateway_edit_vm.dart @@ -59,7 +59,7 @@ class CompanyGatewayEditVM { isSaving: state.isSaving, origCompanyGateway: state.companyGatewayState.map[companyGateway.id], companyGateway: companyGateway, - company: state.selectedCompany, + company: state.company, onChanged: (CompanyGatewayEntity companyGateway) { store.dispatch(UpdateCompanyGateway(companyGateway)); }, diff --git a/lib/ui/company_gateway/view/company_gateway_view_vm.dart b/lib/ui/company_gateway/view/company_gateway_view_vm.dart index 3a59da81b..8fb90c7da 100644 --- a/lib/ui/company_gateway/view/company_gateway_view_vm.dart +++ b/lib/ui/company_gateway/view/company_gateway_view_vm.dart @@ -64,7 +64,7 @@ class CompanyGatewayViewVM { return CompanyGatewayViewVM( state: state, - company: state.selectedCompany, + company: state.company, isSaving: state.isSaving, isLoading: state.isLoading, isDirty: companyGateway.isNew, diff --git a/lib/ui/dashboard/dashboard_panels.dart b/lib/ui/dashboard/dashboard_panels.dart index 871fe4e0f..db95ad87f 100644 --- a/lib/ui/dashboard/dashboard_panels.dart +++ b/lib/ui/dashboard/dashboard_panels.dart @@ -35,7 +35,7 @@ class DashboardPanels extends StatelessWidget { Widget _header(BuildContext context) { final uiState = viewModel.dashboardUIState; final state = viewModel.state; - final company = state.selectedCompany; + final company = state.company; final clientMap = state.clientState.map; // Add "All" if more than one currency @@ -176,7 +176,7 @@ class DashboardPanels extends StatelessWidget { title: title, currencyId: (settings.currencyId ?? '').isNotEmpty ? settings.currencyId - : state.selectedCompany.currencyId, + : state.company.currencyId, ); } @@ -186,7 +186,7 @@ class DashboardPanels extends StatelessWidget { final state = viewModel.state; final currentData = memoizedChartInvoices( state.staticState.currencyMap, - state.selectedCompany, + state.company, settings, state.invoiceState.map, state.clientState.map); @@ -195,7 +195,7 @@ class DashboardPanels extends StatelessWidget { if (settings.enableComparison) { previousData = memoizedChartInvoices( state.staticState.currencyMap, - state.selectedCompany, + state.company, settings.rebuild((b) => b..offset += 1), state.invoiceState.map, state.clientState.map); @@ -215,7 +215,7 @@ class DashboardPanels extends StatelessWidget { final state = viewModel.state; final currentData = memoizedChartPayments( state.staticState.currencyMap, - state.selectedCompany, + state.company, settings, state.invoiceState.map, state.clientState.map, @@ -225,7 +225,7 @@ class DashboardPanels extends StatelessWidget { if (settings.enableComparison) { previousData = memoizedChartPayments( state.staticState.currencyMap, - state.selectedCompany, + state.company, settings.rebuild((b) => b..offset += 1), state.invoiceState.map, state.clientState.map, @@ -246,7 +246,7 @@ class DashboardPanels extends StatelessWidget { final isLoaded = state.quoteState.isLoaded; final currentData = memoizedChartQuotes( state.staticState.currencyMap, - state.selectedCompany, + state.company, settings, state.quoteState.map, state.clientState.map); @@ -255,7 +255,7 @@ class DashboardPanels extends StatelessWidget { if (settings.enableComparison) { previousData = memoizedChartQuotes( state.staticState.currencyMap, - state.selectedCompany, + state.company, settings.rebuild((b) => b..offset += 1), state.quoteState.map, state.clientState.map); @@ -276,7 +276,7 @@ class DashboardPanels extends StatelessWidget { final currentData = memoizedChartTasks( state.staticState.currencyMap, - state.selectedCompany, + state.company, settings, state.taskState.map, state.invoiceState.map, @@ -287,7 +287,7 @@ class DashboardPanels extends StatelessWidget { if (settings.enableComparison) { previousData = memoizedChartTasks( state.staticState.currencyMap, - state.selectedCompany, + state.company, settings.rebuild((b) => b..offset += 1), state.taskState.map, state.invoiceState.map, @@ -309,7 +309,7 @@ class DashboardPanels extends StatelessWidget { final isLoaded = state.expenseState.isLoaded; final currentData = memoizedChartExpenses( state.staticState.currencyMap, - state.selectedCompany, + state.company, settings, state.invoiceState.map, state.expenseState.map); @@ -318,7 +318,7 @@ class DashboardPanels extends StatelessWidget { if (settings.enableComparison) { previousData = memoizedChartExpenses( state.staticState.currencyMap, - state.selectedCompany, + state.company, settings.rebuild((b) => b..offset += 1), state.invoiceState.map, state.expenseState.map); @@ -335,7 +335,7 @@ class DashboardPanels extends StatelessWidget { @override Widget build(BuildContext context) { final state = viewModel.state; - final company = state.selectedCompany; + final company = state.company; if (!state.staticState.isLoaded) { return LoadingIndicator(); diff --git a/lib/ui/dashboard/dashboard_screen_vm.dart b/lib/ui/dashboard/dashboard_screen_vm.dart index 37f4e9daf..082e54bab 100644 --- a/lib/ui/dashboard/dashboard_screen_vm.dart +++ b/lib/ui/dashboard/dashboard_screen_vm.dart @@ -70,7 +70,7 @@ class DashboardVM { currencyMap: state.staticState.currencyMap, isLoading: state.isLoading, isNextEnabled: - DateTime.parse(state.dashboardUIState.endDate(state.selectedCompany)) + DateTime.parse(state.dashboardUIState.endDate(state.company)) .isBefore(DateTime.now()), onRefreshed: (context) => _handleRefresh(context), onSettingsChanged: (DashboardSettings settings) => @@ -81,7 +81,7 @@ class DashboardVM { store.dispatch(UpdateDashboardSettings(currencyId: currencyId)), filter: filter, filteredList: - memoizedFilteredSelector(filter, state.selectedCompanyState), + memoizedFilteredSelector(filter, state.userCompanyState), ); } diff --git a/lib/ui/document/edit/document_edit_vm.dart b/lib/ui/document/edit/document_edit_vm.dart index 10dfa8ece..40f1b126e 100644 --- a/lib/ui/document/edit/document_edit_vm.dart +++ b/lib/ui/document/edit/document_edit_vm.dart @@ -56,7 +56,7 @@ class DocumentEditVM { isSaving: state.isSaving, origDocument: state.documentState.map[document.id], document: document, - company: state.selectedCompany, + company: state.company, onChanged: (DocumentEntity document) { store.dispatch(UpdateDocument(document)); }, diff --git a/lib/ui/document/view/document_view_vm.dart b/lib/ui/document/view/document_view_vm.dart index 40a850d32..af7f9c980 100644 --- a/lib/ui/document/view/document_view_vm.dart +++ b/lib/ui/document/view/document_view_vm.dart @@ -64,7 +64,7 @@ class DocumentViewVM { return DocumentViewVM( state: state, - company: state.selectedCompany, + company: state.company, isSaving: state.isSaving, isLoading: state.isLoading, isDirty: document.isNew, diff --git a/lib/ui/expense/edit/expense_edit_vm.dart b/lib/ui/expense/edit/expense_edit_vm.dart index 30b0c98ab..ad00166fd 100644 --- a/lib/ui/expense/edit/expense_edit_vm.dart +++ b/lib/ui/expense/edit/expense_edit_vm.dart @@ -67,7 +67,7 @@ class ExpenseEditVM { isSaving: state.isSaving, origExpense: state.expenseState.map[expense.id], expense: expense, - company: state.selectedCompany, + company: state.company, onChanged: (ExpenseEntity expense) { store.dispatch(UpdateExpense(expense)); }, diff --git a/lib/ui/expense/expense_list_item.dart b/lib/ui/expense/expense_list_item.dart index 5a67c9033..46dc66c3f 100644 --- a/lib/ui/expense/expense_list_item.dart +++ b/lib/ui/expense/expense_list_item.dart @@ -49,7 +49,7 @@ class ExpenseListItem extends StatelessWidget { ? expense.matchesFilterValue(filter) : null; - final company = state.selectedCompany; + final company = state.company; final category = company.expenseCategoryMap[expense.categoryId]; String subtitle = ''; diff --git a/lib/ui/expense/expense_screen.dart b/lib/ui/expense/expense_screen.dart index dfd15873a..eb86e5ab0 100644 --- a/lib/ui/expense/expense_screen.dart +++ b/lib/ui/expense/expense_screen.dart @@ -28,7 +28,7 @@ class ExpenseScreen extends StatelessWidget { Widget build(BuildContext context) { final store = StoreProvider.of(context); final state = store.state; - final company = state.selectedCompany; + final company = state.company; final userCompany = state.userCompany; final localization = AppLocalization.of(context); final listUIState = state.uiState.expenseUIState.listUIState; diff --git a/lib/ui/expense/view/expense_view.dart b/lib/ui/expense/view/expense_view.dart index 168481724..731ffb7d7 100644 --- a/lib/ui/expense/view/expense_view.dart +++ b/lib/ui/expense/view/expense_view.dart @@ -44,7 +44,7 @@ class _ExpenseViewState extends State Widget build(BuildContext context) { final localization = AppLocalization.of(context); final viewModel = widget.viewModel; - final company = viewModel.state.selectedCompany; + final company = viewModel.state.company; return WillPopScope( onWillPop: () async { diff --git a/lib/ui/expense/view/expense_view_vm.dart b/lib/ui/expense/view/expense_view_vm.dart index 93859eef0..141c2e892 100644 --- a/lib/ui/expense/view/expense_view_vm.dart +++ b/lib/ui/expense/view/expense_view_vm.dart @@ -74,7 +74,7 @@ class ExpenseViewVM { return ExpenseViewVM( state: state, - company: state.selectedCompany, + company: state.company, isSaving: state.isSaving, isLoading: state.isLoading, isDirty: expense.isNew, diff --git a/lib/ui/group/edit/group_edit_vm.dart b/lib/ui/group/edit/group_edit_vm.dart index 2bc9e0d85..e20e11cc0 100644 --- a/lib/ui/group/edit/group_edit_vm.dart +++ b/lib/ui/group/edit/group_edit_vm.dart @@ -59,7 +59,7 @@ class GroupEditVM { isSaving: state.isSaving, origGroup: state.groupState.map[group.id], group: group, - company: state.selectedCompany, + company: state.company, onChanged: (GroupEntity group) { store.dispatch(UpdateGroup(group)); }, diff --git a/lib/ui/group/group_screen.dart b/lib/ui/group/group_screen.dart index 8601d5132..b7cb02edf 100644 --- a/lib/ui/group/group_screen.dart +++ b/lib/ui/group/group_screen.dart @@ -29,7 +29,7 @@ class GroupSettingsScreen extends StatelessWidget { Widget build(BuildContext context) { final store = StoreProvider.of(context); final state = store.state; - final company = state.selectedCompany; + final company = state.company; final localization = AppLocalization.of(context); final listUIState = state.uiState.groupUIState.listUIState; final isInMultiselect = listUIState.isInMultiselect(); diff --git a/lib/ui/group/view/group_view_vm.dart b/lib/ui/group/view/group_view_vm.dart index c10a370e8..36fdd3230 100644 --- a/lib/ui/group/view/group_view_vm.dart +++ b/lib/ui/group/view/group_view_vm.dart @@ -65,7 +65,7 @@ class GroupViewVM { return GroupViewVM( state: state, - company: state.selectedCompany, + company: state.company, isSaving: state.isSaving, isLoading: state.isLoading, isDirty: group.isNew, diff --git a/lib/ui/invoice/edit/invoice_edit_contacts_vm.dart b/lib/ui/invoice/edit/invoice_edit_contacts_vm.dart index 3f678455a..21188010b 100644 --- a/lib/ui/invoice/edit/invoice_edit_contacts_vm.dart +++ b/lib/ui/invoice/edit/invoice_edit_contacts_vm.dart @@ -61,7 +61,7 @@ class InvoiceEditContactsVM extends EntityEditContactsVM { final invoice = state.invoiceUIState.editing; return InvoiceEditContactsVM( - company: state.selectedCompany, + company: state.company, invoice: invoice, client: state.clientState.map[invoice.clientId], onAddContact: (ContactEntity contact) { diff --git a/lib/ui/invoice/edit/invoice_edit_details_vm.dart b/lib/ui/invoice/edit/invoice_edit_details_vm.dart index fe6aa8b72..ac3c8447c 100644 --- a/lib/ui/invoice/edit/invoice_edit_details_vm.dart +++ b/lib/ui/invoice/edit/invoice_edit_details_vm.dart @@ -80,7 +80,7 @@ class InvoiceEditDetailsVM extends EntityEditDetailsVM { final invoice = state.invoiceUIState.editing; return InvoiceEditDetailsVM( - company: state.selectedCompany, + company: state.company, invoice: invoice, onChanged: (InvoiceEntity invoice) => store.dispatch(UpdateInvoice(invoice)), diff --git a/lib/ui/invoice/edit/invoice_edit_items_vm.dart b/lib/ui/invoice/edit/invoice_edit_items_vm.dart index b9754825d..245f42f8c 100644 --- a/lib/ui/invoice/edit/invoice_edit_items_vm.dart +++ b/lib/ui/invoice/edit/invoice_edit_items_vm.dart @@ -65,7 +65,7 @@ class InvoiceEditItemsVM extends EntityEditItemsVM { final invoice = state.invoiceUIState.editing; return InvoiceEditItemsVM( - company: state.selectedCompany, + company: state.company, invoice: invoice, invoiceItemIndex: state.invoiceUIState.editingItemIndex, onRemoveInvoiceItemPressed: (index) => diff --git a/lib/ui/invoice/edit/invoice_edit_notes_vm.dart b/lib/ui/invoice/edit/invoice_edit_notes_vm.dart index 9040ce7f7..3257cbdda 100644 --- a/lib/ui/invoice/edit/invoice_edit_notes_vm.dart +++ b/lib/ui/invoice/edit/invoice_edit_notes_vm.dart @@ -53,7 +53,7 @@ class InvoiceEditNotesVM extends EntityEditNotesVM { final invoice = state.invoiceUIState.editing; return InvoiceEditNotesVM( - company: state.selectedCompany, + company: state.company, invoice: invoice, onChanged: (InvoiceEntity invoice) => store.dispatch(UpdateInvoice(invoice)), diff --git a/lib/ui/invoice/edit/invoice_edit_vm.dart b/lib/ui/invoice/edit/invoice_edit_vm.dart index 96d3d74c0..82b38bd37 100644 --- a/lib/ui/invoice/edit/invoice_edit_vm.dart +++ b/lib/ui/invoice/edit/invoice_edit_vm.dart @@ -93,7 +93,7 @@ class InvoiceEditVM extends EntityEditVM { return InvoiceEditVM( state: state, - company: state.selectedCompany, + company: state.company, isSaving: state.isSaving, invoice: invoice, invoiceItemIndex: state.invoiceUIState.editingItemIndex, diff --git a/lib/ui/invoice/edit/invoice_item_selector.dart b/lib/ui/invoice/edit/invoice_item_selector.dart index 00133fc8a..057f173d8 100644 --- a/lib/ui/invoice/edit/invoice_item_selector.dart +++ b/lib/ui/invoice/edit/invoice_item_selector.dart @@ -60,12 +60,12 @@ class _InvoiceItemSelectorState extends State void _onItemsSelected(BuildContext context) { final List items = []; final state = StoreProvider.of(context).state; - final company = state.selectedCompany; + final company = state.company; _selected.forEach((entity) { if (entity.entityType == EntityType.product) { final product = entity as ProductEntity; - if (state.selectedCompany.fillProducts ?? true) { + if (state.company.fillProducts ?? true) { items.add( convertProductToInvoiceItem(product: product, context: context)); } else { @@ -119,7 +119,7 @@ class _InvoiceItemSelectorState extends State Widget build(BuildContext context) { final localization = AppLocalization.of(context); final state = StoreProvider.of(context).state; - final company = state.selectedCompany; + final company = state.company; final showTabBar = company.isModuleEnabled(EntityType.task) || company.isModuleEnabled(EntityType.expense); diff --git a/lib/ui/invoice/invoice_email_vm.dart b/lib/ui/invoice/invoice_email_vm.dart index d6e908ebc..3ddd9ec11 100644 --- a/lib/ui/invoice/invoice_email_vm.dart +++ b/lib/ui/invoice/invoice_email_vm.dart @@ -83,7 +83,7 @@ class EmailInvoiceVM extends EmailEntityVM { return EmailInvoiceVM( isLoading: state.isLoading, isSaving: state.isSaving, - company: state.selectedCompany, + company: state.company, invoice: invoice, client: state.clientState.map[invoice.clientId] ?? ClientEntity(id: invoice.clientId), diff --git a/lib/ui/invoice/invoice_screen.dart b/lib/ui/invoice/invoice_screen.dart index 114ddef65..a386fd3d9 100644 --- a/lib/ui/invoice/invoice_screen.dart +++ b/lib/ui/invoice/invoice_screen.dart @@ -28,7 +28,7 @@ class InvoiceScreen extends StatelessWidget { Widget build(BuildContext context) { final store = StoreProvider.of(context); final state = store.state; - final company = state.selectedCompany; + final company = state.company; final userCompany = store.state.userCompany; final localization = AppLocalization.of(context); final listUIState = store.state.uiState.invoiceUIState.listUIState; diff --git a/lib/ui/invoice/view/invoice_view_vm.dart b/lib/ui/invoice/view/invoice_view_vm.dart index 6c7793c75..143c5a00f 100644 --- a/lib/ui/invoice/view/invoice_view_vm.dart +++ b/lib/ui/invoice/view/invoice_view_vm.dart @@ -128,7 +128,7 @@ class InvoiceViewVM extends EntityViewVM { return InvoiceViewVM( state: state, - company: state.selectedCompany, + company: state.company, isSaving: state.isSaving, isDirty: invoice.isNew, invoice: invoice, diff --git a/lib/ui/payment/payment_screen.dart b/lib/ui/payment/payment_screen.dart index 9256b7a52..b490d3d05 100644 --- a/lib/ui/payment/payment_screen.dart +++ b/lib/ui/payment/payment_screen.dart @@ -24,7 +24,7 @@ class PaymentScreen extends StatelessWidget { Widget build(BuildContext context) { final store = StoreProvider.of(context); final state = store.state; - final company = state.selectedCompany; + final company = state.company; final userCompany = state.userCompany; final localization = AppLocalization.of(context); final listUIState = state.uiState.paymentUIState.listUIState; diff --git a/lib/ui/payment/view/payment_view_vm.dart b/lib/ui/payment/view/payment_view_vm.dart index 3ef97e238..eb2d1b10b 100644 --- a/lib/ui/payment/view/payment_view_vm.dart +++ b/lib/ui/payment/view/payment_view_vm.dart @@ -56,7 +56,7 @@ class PaymentViewVM { return PaymentViewVM( state: state, - company: state.selectedCompany, + company: state.company, isSaving: state.isSaving, isDirty: payment.isNew, isLoading: state.isLoading, diff --git a/lib/ui/product/edit/product_edit_vm.dart b/lib/ui/product/edit/product_edit_vm.dart index 1e57f10da..c644cd0c4 100644 --- a/lib/ui/product/edit/product_edit_vm.dart +++ b/lib/ui/product/edit/product_edit_vm.dart @@ -56,7 +56,7 @@ class ProductEditVM { return ProductEditVM( state: state, - company: state.selectedCompany, + company: state.company, isSaving: state.isSaving, isDirty: product.isNew, product: product, diff --git a/lib/ui/product/product_screen.dart b/lib/ui/product/product_screen.dart index 8bc766145..79b04d19f 100644 --- a/lib/ui/product/product_screen.dart +++ b/lib/ui/product/product_screen.dart @@ -26,7 +26,7 @@ class ProductScreen extends StatelessWidget { Widget build(BuildContext context) { final store = StoreProvider.of(context); final state = store.state; - final company = state.selectedCompany; + final company = state.company; final userCompany = state.userCompany; final localization = AppLocalization.of(context); final listUIState = state.uiState.productUIState.listUIState; diff --git a/lib/ui/product/view/product_view_vm.dart b/lib/ui/product/view/product_view_vm.dart index 7b85ace95..baf878a11 100644 --- a/lib/ui/product/view/product_view_vm.dart +++ b/lib/ui/product/view/product_view_vm.dart @@ -71,7 +71,7 @@ class ProductViewVM { isLoading: state.isLoading, isDirty: product.isNew, product: product, - company: state.selectedCompany, + company: state.company, onEditPressed: (BuildContext context) { final Completer completer = Completer(); store.dispatch(EditProduct( diff --git a/lib/ui/project/edit/project_edit_vm.dart b/lib/ui/project/edit/project_edit_vm.dart index 0d20a7d0d..f310b923d 100644 --- a/lib/ui/project/edit/project_edit_vm.dart +++ b/lib/ui/project/edit/project_edit_vm.dart @@ -62,7 +62,7 @@ class ProjectEditVM { return ProjectEditVM( isLoading: state.isLoading, isSaving: state.isSaving, - company: state.selectedCompany, + company: state.company, project: project, state: state, origProject: state.projectState.map[project.id], diff --git a/lib/ui/project/project_screen.dart b/lib/ui/project/project_screen.dart index f1fe68a18..cf172cc3c 100644 --- a/lib/ui/project/project_screen.dart +++ b/lib/ui/project/project_screen.dart @@ -26,7 +26,7 @@ class ProjectScreen extends StatelessWidget { Widget build(BuildContext context) { final store = StoreProvider.of(context); final state = store.state; - final company = store.state.selectedCompany; + final company = store.state.company; final userCompany = store.state.userCompany; final localization = AppLocalization.of(context); final listUIState = state.uiState.projectUIState.listUIState; diff --git a/lib/ui/project/view/project_view_vm.dart b/lib/ui/project/view/project_view_vm.dart index e0ffefada..304595287 100644 --- a/lib/ui/project/view/project_view_vm.dart +++ b/lib/ui/project/view/project_view_vm.dart @@ -68,7 +68,7 @@ class ProjectViewVM { return ProjectViewVM( state: state, - company: state.selectedCompany, + company: state.company, isSaving: state.isSaving, isLoading: state.isLoading, isDirty: project.isNew, diff --git a/lib/ui/quote/edit/quote_edit_details_vm.dart b/lib/ui/quote/edit/quote_edit_details_vm.dart index 6a17a8a4c..6b2c0c720 100644 --- a/lib/ui/quote/edit/quote_edit_details_vm.dart +++ b/lib/ui/quote/edit/quote_edit_details_vm.dart @@ -60,7 +60,7 @@ class QuoteEditDetailsVM extends EntityEditDetailsVM { final quote = state.quoteUIState.editing; return QuoteEditDetailsVM( - company: state.selectedCompany, + company: state.company, invoice: quote, onChanged: (InvoiceEntity quote) => store.dispatch(UpdateQuote(quote)), clientMap: state.clientState.map, diff --git a/lib/ui/quote/edit/quote_edit_items_vm.dart b/lib/ui/quote/edit/quote_edit_items_vm.dart index e7efe833b..ec6a4335d 100644 --- a/lib/ui/quote/edit/quote_edit_items_vm.dart +++ b/lib/ui/quote/edit/quote_edit_items_vm.dart @@ -48,7 +48,7 @@ class QuoteEditItemsVM extends EntityEditItemsVM { final quote = state.quoteUIState.editing; return QuoteEditItemsVM( - company: state.selectedCompany, + company: state.company, invoice: quote, invoiceItemIndex: state.quoteUIState.editingItemIndex, onRemoveInvoiceItemPressed: (index) => diff --git a/lib/ui/quote/edit/quote_edit_notes_vm.dart b/lib/ui/quote/edit/quote_edit_notes_vm.dart index 5f0315bc7..4c30cfa23 100644 --- a/lib/ui/quote/edit/quote_edit_notes_vm.dart +++ b/lib/ui/quote/edit/quote_edit_notes_vm.dart @@ -42,7 +42,7 @@ class QuoteEditNotesVM extends EntityEditNotesVM { final quote = state.quoteUIState.editing; return QuoteEditNotesVM( - company: state.selectedCompany, + company: state.company, invoice: quote, onChanged: (InvoiceEntity quote) => store.dispatch(UpdateQuote(quote)), ); diff --git a/lib/ui/quote/edit/quote_edit_vm.dart b/lib/ui/quote/edit/quote_edit_vm.dart index fb5e7f974..b1b238796 100644 --- a/lib/ui/quote/edit/quote_edit_vm.dart +++ b/lib/ui/quote/edit/quote_edit_vm.dart @@ -67,7 +67,7 @@ class QuoteEditVM extends EntityEditVM { final quote = state.quoteUIState.editing; return QuoteEditVM( - company: state.selectedCompany, + company: state.company, isSaving: state.isSaving, invoice: quote, invoiceItemIndex: state.quoteUIState.editingItemIndex, diff --git a/lib/ui/quote/quote_email_vm.dart b/lib/ui/quote/quote_email_vm.dart index 20f98cdfe..f5541408a 100644 --- a/lib/ui/quote/quote_email_vm.dart +++ b/lib/ui/quote/quote_email_vm.dart @@ -65,7 +65,7 @@ class EmailQuoteVM extends EmailEntityVM { return EmailQuoteVM( isLoading: state.isLoading, isSaving: state.isSaving, - company: state.selectedCompany, + company: state.company, invoice: quote, client: state.clientState.map[quote.clientId], onSendPressed: (context, template, subject, body) => diff --git a/lib/ui/quote/quote_screen.dart b/lib/ui/quote/quote_screen.dart index 6152331b4..0643fb2b3 100644 --- a/lib/ui/quote/quote_screen.dart +++ b/lib/ui/quote/quote_screen.dart @@ -28,7 +28,7 @@ class QuoteScreen extends StatelessWidget { Widget build(BuildContext context) { final store = StoreProvider.of(context); final state = store.state; - final company = store.state.selectedCompany; + final company = store.state.company; final userCompany = store.state.userCompany; final localization = AppLocalization.of(context); final listUIState = state.uiState.quoteUIState.listUIState; diff --git a/lib/ui/quote/view/quote_view_vm.dart b/lib/ui/quote/view/quote_view_vm.dart index a537924da..2de09fb32 100644 --- a/lib/ui/quote/view/quote_view_vm.dart +++ b/lib/ui/quote/view/quote_view_vm.dart @@ -93,7 +93,7 @@ class QuoteViewVM extends EntityViewVM { return QuoteViewVM( state: state, - company: state.selectedCompany, + company: state.company, isSaving: state.isSaving, isDirty: quote.isNew, invoice: quote, diff --git a/lib/ui/settings/device_settings_list.dart b/lib/ui/settings/device_settings_list.dart index 51741f289..1dba77266 100644 --- a/lib/ui/settings/device_settings_list.dart +++ b/lib/ui/settings/device_settings_list.dart @@ -158,7 +158,7 @@ class _DeviceSettingsState extends State { } }, ), - viewModel.state.selectedCompany + viewModel.state.company .isModuleEnabled(EntityType.task) ? SwitchListTile( title: diff --git a/lib/ui/task/edit/task_edit_details_vm.dart b/lib/ui/task/edit/task_edit_details_vm.dart index cfcea7832..af07098f6 100644 --- a/lib/ui/task/edit/task_edit_details_vm.dart +++ b/lib/ui/task/edit/task_edit_details_vm.dart @@ -59,7 +59,7 @@ class TaskEditDetailsVM { task: task, taskTime: state.taskUIState.editingTime, state: state, - company: state.selectedCompany, + company: state.company, onChanged: (TaskEntity task) { store.dispatch(UpdateTask(task)); }, diff --git a/lib/ui/task/edit/task_edit_times_vm.dart b/lib/ui/task/edit/task_edit_times_vm.dart index 0a192df05..81ef48073 100644 --- a/lib/ui/task/edit/task_edit_times_vm.dart +++ b/lib/ui/task/edit/task_edit_times_vm.dart @@ -39,7 +39,7 @@ class TaskEditTimesVM { final task = state.taskUIState.editing; return TaskEditTimesVM( - company: state.selectedCompany, + company: state.company, task: task, taskTime: state.taskUIState.editingTime, onRemoveTaskTimePressed: (index) => store.dispatch(DeleteTaskTime(index)), diff --git a/lib/ui/task/edit/task_edit_vm.dart b/lib/ui/task/edit/task_edit_vm.dart index 49a1ae7f2..71bc54662 100644 --- a/lib/ui/task/edit/task_edit_vm.dart +++ b/lib/ui/task/edit/task_edit_vm.dart @@ -60,7 +60,7 @@ class TaskEditVM { task: task, taskTime: state.taskUIState.editingTime, state: state, - company: state.selectedCompany, + company: state.company, onBackPressed: () { if (state.uiState.currentRoute.contains(TaskScreen.route)) { store.dispatch(UpdateCurrentRoute(TaskScreen.route)); diff --git a/lib/ui/task/task_list_item.dart b/lib/ui/task/task_list_item.dart index 16285ca7a..5b7077dbf 100644 --- a/lib/ui/task/task_list_item.dart +++ b/lib/ui/task/task_list_item.dart @@ -42,7 +42,7 @@ class TaskListItem extends StatelessWidget { final uiState = state.uiState; final taskUIState = uiState.taskUIState; - final CompanyEntity company = state.selectedCompany; + final CompanyEntity company = state.company; final taskStatus = company.taskStatusMap[task.taskStatusId]; final localization = AppLocalization.of(context); diff --git a/lib/ui/task/task_screen.dart b/lib/ui/task/task_screen.dart index af4b36cd0..53e941586 100644 --- a/lib/ui/task/task_screen.dart +++ b/lib/ui/task/task_screen.dart @@ -27,7 +27,7 @@ class TaskScreen extends StatelessWidget { Widget build(BuildContext context) { final store = StoreProvider.of(context); final state = store.state; - final company = store.state.selectedCompany; + final company = store.state.company; final userCompany = store.state.userCompany; final localization = AppLocalization.of(context); final listUIState = state.uiState.taskUIState.listUIState; diff --git a/lib/ui/task/view/task_view_vm.dart b/lib/ui/task/view/task_view_vm.dart index 5941ea4ab..2799214a8 100644 --- a/lib/ui/task/view/task_view_vm.dart +++ b/lib/ui/task/view/task_view_vm.dart @@ -99,7 +99,7 @@ class TaskViewVM { return TaskViewVM( state: state, - company: state.selectedCompany, + company: state.company, isSaving: state.isSaving, isLoading: state.isLoading, isDirty: task.isNew, diff --git a/lib/ui/tax_rate/edit/tax_rate_edit_vm.dart b/lib/ui/tax_rate/edit/tax_rate_edit_vm.dart index 3d8a2f154..833178902 100644 --- a/lib/ui/tax_rate/edit/tax_rate_edit_vm.dart +++ b/lib/ui/tax_rate/edit/tax_rate_edit_vm.dart @@ -59,7 +59,7 @@ class TaxRateEditVM { isSaving: state.isSaving, origTaxRate: state.taxRateState.map[taxRate.id], taxRate: taxRate, - company: state.selectedCompany, + company: state.company, onChanged: (TaxRateEntity taxRate) { store.dispatch(UpdateTaxRate(taxRate)); }, diff --git a/lib/ui/tax_rate/view/tax_rate_view_vm.dart b/lib/ui/tax_rate/view/tax_rate_view_vm.dart index f5fdc1596..fd5a59ff5 100644 --- a/lib/ui/tax_rate/view/tax_rate_view_vm.dart +++ b/lib/ui/tax_rate/view/tax_rate_view_vm.dart @@ -62,7 +62,7 @@ class TaxRateViewVM { return TaxRateViewVM( state: state, - company: state.selectedCompany, + company: state.company, isSaving: state.isSaving, isLoading: state.isLoading, isDirty: taxRate.isNew, diff --git a/lib/ui/user/edit/user_edit_vm.dart b/lib/ui/user/edit/user_edit_vm.dart index fa27e6355..37cfac237 100644 --- a/lib/ui/user/edit/user_edit_vm.dart +++ b/lib/ui/user/edit/user_edit_vm.dart @@ -62,7 +62,7 @@ class UserEditVM { origUser: state.userState.map[user.id], user: user, userCompany: state.userCompany, - company: state.selectedCompany, + company: state.company, onUserChanged: (UserEntity user) { store.dispatch(UpdateUser(user)); }, diff --git a/lib/ui/user/view/user_view.dart b/lib/ui/user/view/user_view.dart index fab4ac655..ed73ff677 100644 --- a/lib/ui/user/view/user_view.dart +++ b/lib/ui/user/view/user_view.dart @@ -31,7 +31,7 @@ class UserView extends StatelessWidget { final localization = AppLocalization.of(context); final user = viewModel.user; final state = StoreProvider.of(context).state; - final company = state.selectedCompany; + final company = state.company; final userCompany = state.userCompany; return Scaffold( diff --git a/lib/ui/user/view/user_view_vm.dart b/lib/ui/user/view/user_view_vm.dart index 99041b4b3..598db75c8 100644 --- a/lib/ui/user/view/user_view_vm.dart +++ b/lib/ui/user/view/user_view_vm.dart @@ -69,7 +69,7 @@ class UserViewVM { return UserViewVM( state: state, - company: state.selectedCompany, + company: state.company, isSaving: state.isSaving, isLoading: state.isLoading, isDirty: user.isNew, @@ -98,7 +98,7 @@ class UserViewVM { if (longPress && user.isActive) { store.dispatch(EditInvoice( context: context, - invoice: InvoiceEntity(company: state.selectedCompany))); + invoice: InvoiceEntity(company: state.company))); } else { store.dispatch(FilterInvoicesByEntity( entityId: user.id, entityType: EntityType.user)); @@ -110,7 +110,7 @@ class UserViewVM { store.dispatch(EditQuote( context: context, quote: InvoiceEntity( - company: state.selectedCompany, isQuote: true))); + company: state.company, isQuote: true))); } else { store.dispatch(FilterQuotesByEntity( entityId: user.id, entityType: EntityType.user)); @@ -121,7 +121,7 @@ class UserViewVM { if (longPress && user.isActive) { store.dispatch(EditPayment( context: context, - payment: PaymentEntity(company: state.selectedCompany))); + payment: PaymentEntity(company: state.company))); } else { store.dispatch(FilterPaymentsByEntity( entityId: user.id, entityType: EntityType.user)); @@ -154,7 +154,7 @@ class UserViewVM { store.dispatch(EditExpense( context: context, expense: ExpenseEntity( - company: state.selectedCompany, uiState: state.uiState))); + company: state.company, uiState: state.uiState))); } else { store.dispatch(FilterExpensesByEntity( entityId: user.id, entityType: EntityType.user)); diff --git a/lib/ui/vendor/edit/vendor_edit_contacts_vm.dart b/lib/ui/vendor/edit/vendor_edit_contacts_vm.dart index a562f7b82..843c9eeb8 100644 --- a/lib/ui/vendor/edit/vendor_edit_contacts_vm.dart +++ b/lib/ui/vendor/edit/vendor_edit_contacts_vm.dart @@ -41,7 +41,7 @@ class VendorEditContactsVM { final vendor = state.vendorUIState.editing; return VendorEditContactsVM( - company: state.selectedCompany, + company: state.company, vendor: vendor, contact: state.vendorUIState.editingContact, onAddContactPressed: () { diff --git a/lib/ui/vendor/edit/vendor_edit_vm.dart b/lib/ui/vendor/edit/vendor_edit_vm.dart index 372571ed1..917c62441 100644 --- a/lib/ui/vendor/edit/vendor_edit_vm.dart +++ b/lib/ui/vendor/edit/vendor_edit_vm.dart @@ -59,7 +59,7 @@ class VendorEditVM { isSaving: state.isSaving, origVendor: state.vendorState.map[vendor.id], vendor: vendor, - company: state.selectedCompany, + company: state.company, onChanged: (VendorEntity vendor) { store.dispatch(UpdateVendor(vendor)); }, diff --git a/lib/ui/vendor/vendor_screen.dart b/lib/ui/vendor/vendor_screen.dart index 43bc5d5d3..a06696121 100644 --- a/lib/ui/vendor/vendor_screen.dart +++ b/lib/ui/vendor/vendor_screen.dart @@ -26,7 +26,7 @@ class VendorScreen extends StatelessWidget { Widget build(BuildContext context) { final store = StoreProvider.of(context); final state = store.state; - final company = state.selectedCompany; + final company = state.company; final userCompany = store.state.userCompany; final localization = AppLocalization.of(context); final listUIState = state.uiState.vendorUIState.listUIState; diff --git a/lib/ui/vendor/view/vendor_view_vm.dart b/lib/ui/vendor/view/vendor_view_vm.dart index f6ef808eb..95c80d24e 100644 --- a/lib/ui/vendor/view/vendor_view_vm.dart +++ b/lib/ui/vendor/view/vendor_view_vm.dart @@ -53,7 +53,7 @@ class VendorViewVM { factory VendorViewVM.fromStore(Store store) { final state = store.state; - final company = state.selectedCompany; + final company = state.company; final vendor = state.vendorState.map[state.vendorUIState.selectedId] ?? VendorEntity(id: state.vendorUIState.selectedId); @@ -66,7 +66,7 @@ class VendorViewVM { return VendorViewVM( state: state, - company: state.selectedCompany, + company: state.company, isSaving: state.isSaving, isLoading: state.isLoading, isDirty: vendor.isNew, @@ -96,7 +96,7 @@ class VendorViewVM { store.dispatch(EditExpense( context: context, expense: ExpenseEntity( - company: state.selectedCompany, vendor: vendor))); + company: state.company, vendor: vendor))); } else { store.dispatch(FilterExpensesByEntity( entityId: vendor.id, entityType: EntityType.vendor)); diff --git a/lib/utils/formatting.dart b/lib/utils/formatting.dart index d3a3039de..830b415a4 100644 --- a/lib/utils/formatting.dart +++ b/lib/utils/formatting.dart @@ -63,9 +63,9 @@ String formatNumber( } final state = StoreProvider.of(context).state; - final CompanyEntity company = state.selectedCompany; + final CompanyEntity company = state.company; final ClientEntity client = - state.selectedCompanyState.clientState.map[clientId]; + state.userCompanyState.clientState.map[clientId]; String countryId; @@ -239,7 +239,7 @@ String formatDate(String value, BuildContext context, } final state = StoreProvider.of(context).state; - final CompanyEntity company = state.selectedCompany; + final CompanyEntity company = state.company; if (state.staticState.dateFormatMap.isEmpty) { return ''; diff --git a/lib/utils/platforms.dart b/lib/utils/platforms.dart index 3c53f2574..d46b8729d 100644 --- a/lib/utils/platforms.dart +++ b/lib/utils/platforms.dart @@ -52,7 +52,7 @@ bool isHosted(BuildContext context) => StoreProvider.of(context).state.isHosted; bool isPaidAccount(BuildContext context) { - final company = StoreProvider.of(context).state.selectedCompany; + final company = StoreProvider.of(context).state.company; return isSelfHosted(context) || company.isProPlan || company.isEnterprisePlan; } diff --git a/lib/utils/templates.dart b/lib/utils/templates.dart index b1d9587f1..7c4fdb3fe 100644 --- a/lib/utils/templates.dart +++ b/lib/utils/templates.dart @@ -14,7 +14,7 @@ String processTemplate( final state = StoreProvider.of(context).state; final localization = AppLocalization.of(context); - final company = state.selectedCompany; + final company = state.company; final client = state.clientState.map[invoice.clientId] ?? ClientEntity(id: invoice.clientId); final contact = client.contacts.first;