This commit is contained in:
Hillel Coren 2019-11-16 22:47:24 +02:00
parent ae61539d21
commit 1acb53ff34
85 changed files with 144 additions and 147 deletions

View File

@ -321,8 +321,8 @@ Middleware<AppState> _createUserLoggedIn(
authRepository.saveAuthState(state.authState); authRepository.saveAuthState(state.authState);
uiRepository.saveUIState(state.uiState); uiRepository.saveUIState(state.uiState);
staticRepository.saveStaticState(state.staticState); staticRepository.saveStaticState(state.staticState);
for (var i = 0; i < state.companyStates.length; i++) { for (var i = 0; i < state.userCompanyStates.length; i++) {
companyRepositories[i].saveCompanyState(state.companyStates[i]); companyRepositories[i].saveCompanyState(state.userCompanyStates[i]);
} }
} }
}; };
@ -402,7 +402,7 @@ Middleware<AppState> _createPersistData(
final AppState state = store.state; final AppState state = store.state;
final index = state.uiState.selectedCompanyIndex; final index = state.uiState.selectedCompanyIndex;
companyRepositories[index].saveCompanyState(state.companyStates[index]); companyRepositories[index].saveCompanyState(state.userCompanyStates[index]);
}; };
} }

View File

@ -40,7 +40,7 @@ AppState appReducer(AppState state, dynamic action) {
..authState.replace(authReducer(state.authState, action)) ..authState.replace(authReducer(state.authState, action))
..staticState.replace(staticReducer(state.staticState, action)) ..staticState.replace(staticReducer(state.staticState, action))
..companyStates[state.uiState.selectedCompanyIndex] = companyReducer( ..companyStates[state.uiState.selectedCompanyIndex] = companyReducer(
state.companyStates[state.uiState.selectedCompanyIndex], action) state.userCompanyStates[state.uiState.selectedCompanyIndex], action)
..uiState.replace(uiReducer(state.uiState, action))); ..uiState.replace(uiReducer(state.uiState, action)));
} }

View File

@ -60,7 +60,7 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
lastError: '', lastError: '',
authState: AuthState(), authState: AuthState(),
staticState: StaticState(), staticState: StaticState(),
companyStates: List<int>.generate(10, (i) => i + 1) userCompanyStates: List<int>.generate(10, (i) => i + 1)
.map((index) => UserCompanyState()) .map((index) => UserCompanyState())
.toList(), .toList(),
uiState: uiState ?? UIState(), uiState: uiState ?? UIState(),
@ -83,13 +83,13 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
UIState get uiState; UIState get uiState;
List<UserCompanyState> get companyStates; List<UserCompanyState> get userCompanyStates;
//factory AppState([void updates(AppStateBuilder b)]) = _$AppState; //factory AppState([void updates(AppStateBuilder b)]) = _$AppState;
static Serializer<AppState> get serializer => _$appStateSerializer; static Serializer<AppState> get serializer => _$appStateSerializer;
UserCompanyState get selectedCompanyState => UserCompanyState get userCompanyState =>
companyStates[uiState.selectedCompanyIndex]; userCompanyStates[uiState.selectedCompanyIndex];
bool get isLoaded { bool get isLoaded {
return dashboardState.isLoaded && return dashboardState.isLoaded &&
@ -97,18 +97,18 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
clientState.isLoaded; 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; 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 get credentials =>
Credentials(token: selectedCompanyState.token.token, url: authState.url); Credentials(token: userCompanyState.token.token, url: authState.url);
BuiltMap<String, SelectableEntity> getEntityMap(EntityType type) { BuiltMap<String, SelectableEntity> getEntityMap(EntityType type) {
switch (type) { switch (type) {
@ -143,7 +143,7 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
return quoteState.map; return quoteState.map;
case EntityType.expenseCategory: case EntityType.expenseCategory:
// TODO move to expenseCategoryState.map // TODO move to expenseCategoryState.map
return selectedCompany.expenseCategoryMap; return company.expenseCategoryMap;
case EntityType.paymentType: case EntityType.paymentType:
return staticState.paymentTypeMap; return staticState.paymentTypeMap;
case EntityType.currency: case EntityType.currency:
@ -207,39 +207,39 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
return getUIState(type).listUIState; return getUIState(type).listUIState;
} }
ProductState get productState => selectedCompanyState.productState; ProductState get productState => userCompanyState.productState;
ProductUIState get productUIState => uiState.productUIState; ProductUIState get productUIState => uiState.productUIState;
ListUIState get productListState => uiState.productUIState.listUIState; ListUIState get productListState => uiState.productUIState.listUIState;
ClientState get clientState => selectedCompanyState.clientState; ClientState get clientState => userCompanyState.clientState;
ClientUIState get clientUIState => uiState.clientUIState; ClientUIState get clientUIState => uiState.clientUIState;
ListUIState get clientListState => uiState.clientUIState.listUIState; ListUIState get clientListState => uiState.clientUIState.listUIState;
InvoiceState get invoiceState => selectedCompanyState.invoiceState; InvoiceState get invoiceState => userCompanyState.invoiceState;
InvoiceUIState get invoiceUIState => uiState.invoiceUIState; InvoiceUIState get invoiceUIState => uiState.invoiceUIState;
ListUIState get invoiceListState => uiState.invoiceUIState.listUIState; ListUIState get invoiceListState => uiState.invoiceUIState.listUIState;
// STARTER: state getters - do not remove comment // STARTER: state getters - do not remove comment
UserState get userState => selectedCompanyState.userState; UserState get userState => userCompanyState.userState;
ListUIState get userListState => uiState.userUIState.listUIState; ListUIState get userListState => uiState.userUIState.listUIState;
UserUIState get userUIState => uiState.userUIState; UserUIState get userUIState => uiState.userUIState;
TaxRateState get taxRateState => selectedCompanyState.taxRateState; TaxRateState get taxRateState => userCompanyState.taxRateState;
ListUIState get taxRateListState => uiState.taxRateUIState.listUIState; ListUIState get taxRateListState => uiState.taxRateUIState.listUIState;
TaxRateUIState get taxRateUIState => uiState.taxRateUIState; TaxRateUIState get taxRateUIState => uiState.taxRateUIState;
CompanyGatewayState get companyGatewayState => CompanyGatewayState get companyGatewayState =>
selectedCompanyState.companyGatewayState; userCompanyState.companyGatewayState;
ListUIState get companyGatewayListState => ListUIState get companyGatewayListState =>
uiState.companyGatewayUIState.listUIState; uiState.companyGatewayUIState.listUIState;
@ -247,49 +247,49 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
CompanyGatewayUIState get companyGatewayUIState => CompanyGatewayUIState get companyGatewayUIState =>
uiState.companyGatewayUIState; uiState.companyGatewayUIState;
GroupState get groupState => selectedCompanyState.groupState; GroupState get groupState => userCompanyState.groupState;
ListUIState get groupListState => uiState.groupUIState.listUIState; ListUIState get groupListState => uiState.groupUIState.listUIState;
GroupUIState get groupUIState => uiState.groupUIState; GroupUIState get groupUIState => uiState.groupUIState;
DocumentState get documentState => selectedCompanyState.documentState; DocumentState get documentState => userCompanyState.documentState;
ListUIState get documentListState => uiState.documentUIState.listUIState; ListUIState get documentListState => uiState.documentUIState.listUIState;
DocumentUIState get documentUIState => uiState.documentUIState; DocumentUIState get documentUIState => uiState.documentUIState;
ExpenseState get expenseState => selectedCompanyState.expenseState; ExpenseState get expenseState => userCompanyState.expenseState;
ListUIState get expenseListState => uiState.expenseUIState.listUIState; ListUIState get expenseListState => uiState.expenseUIState.listUIState;
ExpenseUIState get expenseUIState => uiState.expenseUIState; ExpenseUIState get expenseUIState => uiState.expenseUIState;
VendorState get vendorState => selectedCompanyState.vendorState; VendorState get vendorState => userCompanyState.vendorState;
ListUIState get vendorListState => uiState.vendorUIState.listUIState; ListUIState get vendorListState => uiState.vendorUIState.listUIState;
VendorUIState get vendorUIState => uiState.vendorUIState; VendorUIState get vendorUIState => uiState.vendorUIState;
TaskState get taskState => selectedCompanyState.taskState; TaskState get taskState => userCompanyState.taskState;
ListUIState get taskListState => uiState.taskUIState.listUIState; ListUIState get taskListState => uiState.taskUIState.listUIState;
TaskUIState get taskUIState => uiState.taskUIState; TaskUIState get taskUIState => uiState.taskUIState;
ProjectState get projectState => selectedCompanyState.projectState; ProjectState get projectState => userCompanyState.projectState;
ListUIState get projectListState => uiState.projectUIState.listUIState; ListUIState get projectListState => uiState.projectUIState.listUIState;
ProjectUIState get projectUIState => uiState.projectUIState; ProjectUIState get projectUIState => uiState.projectUIState;
PaymentState get paymentState => selectedCompanyState.paymentState; PaymentState get paymentState => userCompanyState.paymentState;
ListUIState get paymentListState => uiState.paymentUIState.listUIState; ListUIState get paymentListState => uiState.paymentUIState.listUIState;
PaymentUIState get paymentUIState => uiState.paymentUIState; PaymentUIState get paymentUIState => uiState.paymentUIState;
QuoteState get quoteState => selectedCompanyState.quoteState; QuoteState get quoteState => userCompanyState.quoteState;
ListUIState get quoteListState => uiState.quoteUIState.listUIState; ListUIState get quoteListState => uiState.quoteUIState.listUIState;

View File

@ -40,7 +40,7 @@ class _$AppStateSerializer implements StructuredSerializer<AppState> {
serializers.serialize(object.uiState, serializers.serialize(object.uiState,
specifiedType: const FullType(UIState)), specifiedType: const FullType(UIState)),
'companyStates', 'companyStates',
serializers.serialize(object.companyStates, serializers.serialize(object.userCompanyStates,
specifiedType: specifiedType:
const FullType(List, const [const FullType(UserCompanyState)])), const FullType(List, const [const FullType(UserCompanyState)])),
]; ];
@ -116,7 +116,7 @@ class _$AppState extends AppState {
@override @override
final UIState uiState; final UIState uiState;
@override @override
final List<UserCompanyState> companyStates; final List<UserCompanyState> userCompanyStates;
factory _$AppState([void Function(AppStateBuilder) updates]) => factory _$AppState([void Function(AppStateBuilder) updates]) =>
(new AppStateBuilder()..update(updates)).build(); (new AppStateBuilder()..update(updates)).build();
@ -129,7 +129,7 @@ class _$AppState extends AppState {
this.authState, this.authState,
this.staticState, this.staticState,
this.uiState, this.uiState,
this.companyStates}) this.userCompanyStates})
: super._() { : super._() {
if (isLoading == null) { if (isLoading == null) {
throw new BuiltValueNullFieldError('AppState', 'isLoading'); throw new BuiltValueNullFieldError('AppState', 'isLoading');
@ -152,7 +152,7 @@ class _$AppState extends AppState {
if (uiState == null) { if (uiState == null) {
throw new BuiltValueNullFieldError('AppState', 'uiState'); throw new BuiltValueNullFieldError('AppState', 'uiState');
} }
if (companyStates == null) { if (userCompanyStates == null) {
throw new BuiltValueNullFieldError('AppState', 'companyStates'); throw new BuiltValueNullFieldError('AppState', 'companyStates');
} }
} }
@ -175,7 +175,7 @@ class _$AppState extends AppState {
authState == other.authState && authState == other.authState &&
staticState == other.staticState && staticState == other.staticState &&
uiState == other.uiState && uiState == other.uiState &&
companyStates == other.companyStates; userCompanyStates == other.userCompanyStates;
} }
@override @override
@ -191,7 +191,7 @@ class _$AppState extends AppState {
authState.hashCode), authState.hashCode),
staticState.hashCode), staticState.hashCode),
uiState.hashCode), uiState.hashCode),
companyStates.hashCode)); userCompanyStates.hashCode));
} }
} }
@ -246,7 +246,7 @@ class AppStateBuilder implements Builder<AppState, AppStateBuilder> {
_authState = _$v.authState?.toBuilder(); _authState = _$v.authState?.toBuilder();
_staticState = _$v.staticState?.toBuilder(); _staticState = _$v.staticState?.toBuilder();
_uiState = _$v.uiState?.toBuilder(); _uiState = _$v.uiState?.toBuilder();
_companyStates = _$v.companyStates; _companyStates = _$v.userCompanyStates;
_$v = null; _$v = null;
} }
return this; return this;
@ -278,7 +278,7 @@ class AppStateBuilder implements Builder<AppState, AppStateBuilder> {
authState: authState.build(), authState: authState.build(),
staticState: staticState.build(), staticState: staticState.build(),
uiState: uiState.build(), uiState: uiState.build(),
companyStates: companyStates); userCompanyStates: companyStates);
} catch (_) { } catch (_) {
String _$failedField; String _$failedField;
try { try {

View File

@ -286,7 +286,7 @@ void handleClientAction(
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
final state = store.state; final state = store.state;
final CompanyEntity company = state.selectedCompany; final CompanyEntity company = state.company;
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final clientIds = clients.map((client) => client.id).toList(); final clientIds = clients.map((client) => client.id).toList();
final client = clients[0]; final client = clients[0];

View File

@ -103,7 +103,7 @@ List<BaseEntity> filteredSelector(String filter, UserCompanyState state) {
List<CompanyEntity> companiesSelector(AppState state) { List<CompanyEntity> companiesSelector(AppState state) {
final List<CompanyEntity> list = []; final List<CompanyEntity> list = [];
for (var companyState in state.companyStates) { for (var companyState in state.userCompanyStates) {
if (companyState.company != null) { if (companyState.company != null) {
list.add(companyState.company); list.add(companyState.company);
} }
@ -116,7 +116,7 @@ List<CompanyEntity> companiesSelector(AppState state) {
String localeSelector(AppState state) { String localeSelector(AppState state) {
final locale = state.staticState final locale = state.staticState
?.languageMap[state.selectedCompany?.settings?.languageId]?.locale ?? ?.languageMap[state.company?.settings?.languageId]?.locale ??
'en'; 'en';
// https://github.com/flutter/flutter/issues/32090 // https://github.com/flutter/flutter/issues/32090

View File

@ -51,11 +51,8 @@ abstract class UserCompanyState
quoteState: QuoteState(), quoteState: QuoteState(),
// STARTER: constructor - do not remove comment // STARTER: constructor - do not remove comment
userState: UserState(), userState: UserState(),
taxRateState: TaxRateState(), taxRateState: TaxRateState(),
companyGatewayState: CompanyGatewayState(), companyGatewayState: CompanyGatewayState(),
groupState: GroupState(), groupState: GroupState(),
); );
} }

View File

@ -167,7 +167,7 @@ Middleware<AppState> _restoreDocument(DocumentRepository repository) {
Middleware<AppState> _saveDocument(DocumentRepository repository) { Middleware<AppState> _saveDocument(DocumentRepository repository) {
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as SaveDocumentRequest; final action = dynamicAction as SaveDocumentRequest;
if (store.state.selectedCompany.isEnterprisePlan) { if (store.state.company.isEnterprisePlan) {
repository repository
.saveData(store.state.credentials, action.document) .saveData(store.state.credentials, action.document)
.then((DocumentEntity document) { .then((DocumentEntity document) {

View File

@ -259,7 +259,7 @@ void handleExpenseAction(
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
final state = store.state; final state = store.state;
final CompanyEntity company = state.selectedCompany; final CompanyEntity company = state.company;
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final expense = expenses.first as ExpenseEntity; final expense = expenses.first as ExpenseEntity;
final expenseIds = expenses.map((expense) => expense.id).toList(); final expenseIds = expenses.map((expense) => expense.id).toList();

View File

@ -267,7 +267,7 @@ Middleware<AppState> _loadExpenses(ExpenseRepository repository) {
if (action.completer != null) { if (action.completer != null) {
action.completer.complete(null); action.completer.complete(null);
} }
if (state.selectedCompany.isEnterprisePlan) { if (state.company.isEnterprisePlan) {
if (state.documentState.isStale) { if (state.documentState.isStale) {
store.dispatch(LoadDocuments()); store.dispatch(LoadDocuments());
} }

View File

@ -356,7 +356,7 @@ void handleInvoiceAction(BuildContext context, List<BaseEntity> invoices,
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
final state = store.state; final state = store.state;
final CompanyEntity company = state.selectedCompany; final CompanyEntity company = state.company;
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final invoice = invoices.first as InvoiceEntity; final invoice = invoices.first as InvoiceEntity;
final invoiceIds = invoices.map((invoice) => invoice.id).toList(); final invoiceIds = invoices.map((invoice) => invoice.id).toList();

View File

@ -223,7 +223,7 @@ void handleProductAction(
convertProductToInvoiceItem(context: context, product: product); convertProductToInvoiceItem(context: context, product: product);
store.dispatch(EditInvoice( store.dispatch(EditInvoice(
context: context, context: context,
invoice: InvoiceEntity(company: state.selectedCompany) invoice: InvoiceEntity(company: state.company)
.rebuild((b) => b..lineItems.add(item)))); .rebuild((b) => b..lineItems.add(item))));
break; break;
case EntityAction.edit: case EntityAction.edit:

View File

@ -260,7 +260,7 @@ void handleProjectAction(
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
final state = store.state; final state = store.state;
final CompanyEntity company = state.selectedCompany; final CompanyEntity company = state.company;
final project = projects.first as ProjectEntity; final project = projects.first as ProjectEntity;
final projectIds = projects.map((project) => project.id).toList(); final projectIds = projects.map((project) => project.id).toList();

View File

@ -107,7 +107,7 @@ Middleware<AppState> _uploadLogo(SettingsRepository settingsRepository) {
final state = store.state; final state = store.state;
final settingsState = state.uiState.settingsUIState; final settingsState = state.uiState.settingsUIState;
final entityId = action.type == EntityType.company final entityId = action.type == EntityType.company
? state.selectedCompany.id ? state.company.id
: action.type == EntityType.group : action.type == EntityType.group
? settingsState.group.id ? settingsState.group.id
: settingsState.client.id; : settingsState.client.id;

View File

@ -294,7 +294,7 @@ void handleTaskAction(
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
final state = store.state; final state = store.state;
final CompanyEntity company = state.selectedCompany; final CompanyEntity company = state.company;
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final task = tasks.first as TaskEntity; final task = tasks.first as TaskEntity;
final taskIds = tasks.map((task) => task.id).toList(); final taskIds = tasks.map((task) => task.id).toList();

View File

@ -28,7 +28,7 @@ InvoiceItemEntity convertTaskToInvoiceItem(
..taskId = task.id ..taskId = task.id
..notes = notes ..notes = notes
..cost = taskRateSelector( ..cost = taskRateSelector(
company: state.selectedCompany, project: project, client: client) company: state.company, project: project, client: client)
..quantity = round(task.duration / 3600, 3)); ..quantity = round(task.duration / 3600, 3));
} }

View File

@ -284,7 +284,7 @@ void handleVendorAction(
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
final state = store.state; final state = store.state;
final CompanyEntity company = state.selectedCompany; final CompanyEntity company = state.company;
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final vendor = vendors.first as VendorEntity; final vendor = vendors.first as VendorEntity;
final vendorIds = vendors.map((vendor) => vendor.id).toList(); final vendorIds = vendors.map((vendor) => vendor.id).toList();

View File

@ -51,7 +51,7 @@ class AppBuilderState extends State<AppBuilder> {
void runCommand(BuildContext context) { void runCommand(BuildContext context) {
print('### RUN COMMAND: $_command ###'); print('### RUN COMMAND: $_command ###');
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
final company = store.state.selectedCompany; final company = store.state.company;
const force = true; const force = true;
dynamic action; dynamic action;

View File

@ -28,7 +28,7 @@ class DocumentGrid extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final state = StoreProvider.of<AppState>(context).state; final state = StoreProvider.of<AppState>(context).state;
final company = state.selectedCompany; final company = state.company;
return ListView( return ListView(
children: [ children: [

View File

@ -41,7 +41,7 @@ class AppDrawerVM {
isLoading: state.isLoading, isLoading: state.isLoading,
companies: companiesSelector(state), companies: companiesSelector(state),
user: state.user, user: state.user,
selectedCompany: state.selectedCompany, selectedCompany: state.company,
); );
} }
} }

View File

@ -33,7 +33,7 @@ class ActivityListTile extends StatelessWidget {
String title = localization.lookup('activity_${activity.activityTypeId}'); String title = localization.lookup('activity_${activity.activityTypeId}');
title = activity.getDescription( title = activity.getDescription(
title, title,
user: state.selectedCompany.userMap[activity.userId] ?? UserEntity(), user: state.company.userMap[activity.userId] ?? UserEntity(),
client: state.clientState.map[activity.clientId], client: state.clientState.map[activity.clientId],
invoice: state.invoiceState.map[activity.invoiceId], invoice: state.invoiceState.map[activity.invoiceId],
quote: state.quoteState.map[activity.invoiceId], quote: state.quoteState.map[activity.invoiceId],

View File

@ -47,7 +47,7 @@ class MenuDrawerVM {
isLoading: state.isLoading, isLoading: state.isLoading,
companies: companiesSelector(state), companies: companiesSelector(state),
user: state.user, user: state.user,
selectedCompany: state.selectedCompany, selectedCompany: state.company,
selectedCompanyIndex: state.uiState.selectedCompanyIndex.toString(), selectedCompanyIndex: state.uiState.selectedCompanyIndex.toString(),
onCompanyChanged: onCompanyChanged:
(BuildContext context, String companyIndex, CompanyEntity company) { (BuildContext context, String companyIndex, CompanyEntity company) {

View File

@ -152,7 +152,7 @@ class _UpgradeDialogState extends State<UpgradeDialog> {
void upgrade(BuildContext context, ProductDetails productDetails) { void upgrade(BuildContext context, ProductDetails productDetails) {
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
final company = store.state.selectedCompany; final company = store.state.company;
InAppPurchaseConnection.instance.buyNonConsumable( InAppPurchaseConnection.instance.buyNonConsumable(
purchaseParam: PurchaseParam( purchaseParam: PurchaseParam(

View File

@ -27,7 +27,7 @@ class ClientScreen extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
final state = store.state; final state = store.state;
final company = state.selectedCompany; final company = state.company;
final userCompany = state.userCompany; final userCompany = state.userCompany;
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final listUIState = state.uiState.clientUIState.listUIState; final listUIState = state.uiState.clientUIState.listUIState;

View File

@ -41,7 +41,7 @@ class ClientEditContactsVM {
final client = state.clientUIState.editing; final client = state.clientUIState.editing;
return ClientEditContactsVM( return ClientEditContactsVM(
company: state.selectedCompany, company: state.company,
client: client, client: client,
contact: state.clientUIState.editingContact, contact: state.clientUIState.editingContact,
onAddContactPressed: () { onAddContactPressed: () {

View File

@ -57,7 +57,7 @@ class ClientEditVM {
return ClientEditVM( return ClientEditVM(
state: state, state: state,
company: state.selectedCompany, company: state.company,
client: client, client: client,
origClient: state.clientState.map[client.id], origClient: state.clientState.map[client.id],
staticState: state.staticState, staticState: state.staticState,

View File

@ -79,7 +79,7 @@ class ClientViewVM {
isLoading: state.isLoading, isLoading: state.isLoading,
isDirty: client.isNew, isDirty: client.isNew,
client: client, client: client,
company: state.selectedCompany, company: state.company,
onEditPressed: (BuildContext context) { onEditPressed: (BuildContext context) {
final Completer<ClientEntity> completer = Completer<ClientEntity>(); final Completer<ClientEntity> completer = Completer<ClientEntity>();
store.dispatch( store.dispatch(
@ -98,7 +98,7 @@ class ClientViewVM {
if (longPress && client.isActive) { if (longPress && client.isActive) {
store.dispatch(EditInvoice( store.dispatch(EditInvoice(
context: context, context: context,
invoice: InvoiceEntity(company: state.selectedCompany))); invoice: InvoiceEntity(company: state.company)));
store.dispatch(UpdateInvoiceClient(client: client)); store.dispatch(UpdateInvoiceClient(client: client));
} else { } else {
store.dispatch(FilterInvoicesByEntity( store.dispatch(FilterInvoicesByEntity(
@ -111,7 +111,7 @@ class ClientViewVM {
store.dispatch(EditQuote( store.dispatch(EditQuote(
context: context, context: context,
quote: InvoiceEntity( quote: InvoiceEntity(
company: state.selectedCompany, isQuote: true))); company: state.company, isQuote: true)));
store.dispatch(UpdateQuoteClient(client: client)); store.dispatch(UpdateQuoteClient(client: client));
} else { } else {
store.dispatch(FilterQuotesByEntity( store.dispatch(FilterQuotesByEntity(
@ -123,7 +123,7 @@ class ClientViewVM {
if (longPress && client.isActive) { if (longPress && client.isActive) {
store.dispatch(EditPayment( store.dispatch(EditPayment(
context: context, context: context,
payment: PaymentEntity(company: state.selectedCompany) payment: PaymentEntity(company: state.company)
.rebuild((b) => b..clientId = client.id))); .rebuild((b) => b..clientId = client.id)));
} else { } else {
store.dispatch(FilterPaymentsByEntity( store.dispatch(FilterPaymentsByEntity(
@ -160,7 +160,7 @@ class ClientViewVM {
store.dispatch(EditExpense( store.dispatch(EditExpense(
context: context, context: context,
expense: ExpenseEntity( expense: ExpenseEntity(
company: state.selectedCompany, company: state.company,
client: client, client: client,
uiState: state.uiState))); uiState: state.uiState)));
} else { } else {

View File

@ -675,7 +675,7 @@ class _FeesEditorState extends State<FeesEditor> {
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final viewModel = widget.viewModel; final viewModel = widget.viewModel;
final companyGateway = viewModel.companyGateway; final companyGateway = viewModel.companyGateway;
final company = viewModel.state.selectedCompany; final company = viewModel.state.company;
final settings = final settings =
companyGateway.getSettingsForGatewayTypeId(widget.gatewayTypeId); companyGateway.getSettingsForGatewayTypeId(widget.gatewayTypeId);

View File

@ -59,7 +59,7 @@ class CompanyGatewayEditVM {
isSaving: state.isSaving, isSaving: state.isSaving,
origCompanyGateway: state.companyGatewayState.map[companyGateway.id], origCompanyGateway: state.companyGatewayState.map[companyGateway.id],
companyGateway: companyGateway, companyGateway: companyGateway,
company: state.selectedCompany, company: state.company,
onChanged: (CompanyGatewayEntity companyGateway) { onChanged: (CompanyGatewayEntity companyGateway) {
store.dispatch(UpdateCompanyGateway(companyGateway)); store.dispatch(UpdateCompanyGateway(companyGateway));
}, },

View File

@ -64,7 +64,7 @@ class CompanyGatewayViewVM {
return CompanyGatewayViewVM( return CompanyGatewayViewVM(
state: state, state: state,
company: state.selectedCompany, company: state.company,
isSaving: state.isSaving, isSaving: state.isSaving,
isLoading: state.isLoading, isLoading: state.isLoading,
isDirty: companyGateway.isNew, isDirty: companyGateway.isNew,

View File

@ -35,7 +35,7 @@ class DashboardPanels extends StatelessWidget {
Widget _header(BuildContext context) { Widget _header(BuildContext context) {
final uiState = viewModel.dashboardUIState; final uiState = viewModel.dashboardUIState;
final state = viewModel.state; final state = viewModel.state;
final company = state.selectedCompany; final company = state.company;
final clientMap = state.clientState.map; final clientMap = state.clientState.map;
// Add "All" if more than one currency // Add "All" if more than one currency
@ -176,7 +176,7 @@ class DashboardPanels extends StatelessWidget {
title: title, title: title,
currencyId: (settings.currencyId ?? '').isNotEmpty currencyId: (settings.currencyId ?? '').isNotEmpty
? settings.currencyId ? settings.currencyId
: state.selectedCompany.currencyId, : state.company.currencyId,
); );
} }
@ -186,7 +186,7 @@ class DashboardPanels extends StatelessWidget {
final state = viewModel.state; final state = viewModel.state;
final currentData = memoizedChartInvoices( final currentData = memoizedChartInvoices(
state.staticState.currencyMap, state.staticState.currencyMap,
state.selectedCompany, state.company,
settings, settings,
state.invoiceState.map, state.invoiceState.map,
state.clientState.map); state.clientState.map);
@ -195,7 +195,7 @@ class DashboardPanels extends StatelessWidget {
if (settings.enableComparison) { if (settings.enableComparison) {
previousData = memoizedChartInvoices( previousData = memoizedChartInvoices(
state.staticState.currencyMap, state.staticState.currencyMap,
state.selectedCompany, state.company,
settings.rebuild((b) => b..offset += 1), settings.rebuild((b) => b..offset += 1),
state.invoiceState.map, state.invoiceState.map,
state.clientState.map); state.clientState.map);
@ -215,7 +215,7 @@ class DashboardPanels extends StatelessWidget {
final state = viewModel.state; final state = viewModel.state;
final currentData = memoizedChartPayments( final currentData = memoizedChartPayments(
state.staticState.currencyMap, state.staticState.currencyMap,
state.selectedCompany, state.company,
settings, settings,
state.invoiceState.map, state.invoiceState.map,
state.clientState.map, state.clientState.map,
@ -225,7 +225,7 @@ class DashboardPanels extends StatelessWidget {
if (settings.enableComparison) { if (settings.enableComparison) {
previousData = memoizedChartPayments( previousData = memoizedChartPayments(
state.staticState.currencyMap, state.staticState.currencyMap,
state.selectedCompany, state.company,
settings.rebuild((b) => b..offset += 1), settings.rebuild((b) => b..offset += 1),
state.invoiceState.map, state.invoiceState.map,
state.clientState.map, state.clientState.map,
@ -246,7 +246,7 @@ class DashboardPanels extends StatelessWidget {
final isLoaded = state.quoteState.isLoaded; final isLoaded = state.quoteState.isLoaded;
final currentData = memoizedChartQuotes( final currentData = memoizedChartQuotes(
state.staticState.currencyMap, state.staticState.currencyMap,
state.selectedCompany, state.company,
settings, settings,
state.quoteState.map, state.quoteState.map,
state.clientState.map); state.clientState.map);
@ -255,7 +255,7 @@ class DashboardPanels extends StatelessWidget {
if (settings.enableComparison) { if (settings.enableComparison) {
previousData = memoizedChartQuotes( previousData = memoizedChartQuotes(
state.staticState.currencyMap, state.staticState.currencyMap,
state.selectedCompany, state.company,
settings.rebuild((b) => b..offset += 1), settings.rebuild((b) => b..offset += 1),
state.quoteState.map, state.quoteState.map,
state.clientState.map); state.clientState.map);
@ -276,7 +276,7 @@ class DashboardPanels extends StatelessWidget {
final currentData = memoizedChartTasks( final currentData = memoizedChartTasks(
state.staticState.currencyMap, state.staticState.currencyMap,
state.selectedCompany, state.company,
settings, settings,
state.taskState.map, state.taskState.map,
state.invoiceState.map, state.invoiceState.map,
@ -287,7 +287,7 @@ class DashboardPanels extends StatelessWidget {
if (settings.enableComparison) { if (settings.enableComparison) {
previousData = memoizedChartTasks( previousData = memoizedChartTasks(
state.staticState.currencyMap, state.staticState.currencyMap,
state.selectedCompany, state.company,
settings.rebuild((b) => b..offset += 1), settings.rebuild((b) => b..offset += 1),
state.taskState.map, state.taskState.map,
state.invoiceState.map, state.invoiceState.map,
@ -309,7 +309,7 @@ class DashboardPanels extends StatelessWidget {
final isLoaded = state.expenseState.isLoaded; final isLoaded = state.expenseState.isLoaded;
final currentData = memoizedChartExpenses( final currentData = memoizedChartExpenses(
state.staticState.currencyMap, state.staticState.currencyMap,
state.selectedCompany, state.company,
settings, settings,
state.invoiceState.map, state.invoiceState.map,
state.expenseState.map); state.expenseState.map);
@ -318,7 +318,7 @@ class DashboardPanels extends StatelessWidget {
if (settings.enableComparison) { if (settings.enableComparison) {
previousData = memoizedChartExpenses( previousData = memoizedChartExpenses(
state.staticState.currencyMap, state.staticState.currencyMap,
state.selectedCompany, state.company,
settings.rebuild((b) => b..offset += 1), settings.rebuild((b) => b..offset += 1),
state.invoiceState.map, state.invoiceState.map,
state.expenseState.map); state.expenseState.map);
@ -335,7 +335,7 @@ class DashboardPanels extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final state = viewModel.state; final state = viewModel.state;
final company = state.selectedCompany; final company = state.company;
if (!state.staticState.isLoaded) { if (!state.staticState.isLoaded) {
return LoadingIndicator(); return LoadingIndicator();

View File

@ -70,7 +70,7 @@ class DashboardVM {
currencyMap: state.staticState.currencyMap, currencyMap: state.staticState.currencyMap,
isLoading: state.isLoading, isLoading: state.isLoading,
isNextEnabled: isNextEnabled:
DateTime.parse(state.dashboardUIState.endDate(state.selectedCompany)) DateTime.parse(state.dashboardUIState.endDate(state.company))
.isBefore(DateTime.now()), .isBefore(DateTime.now()),
onRefreshed: (context) => _handleRefresh(context), onRefreshed: (context) => _handleRefresh(context),
onSettingsChanged: (DashboardSettings settings) => onSettingsChanged: (DashboardSettings settings) =>
@ -81,7 +81,7 @@ class DashboardVM {
store.dispatch(UpdateDashboardSettings(currencyId: currencyId)), store.dispatch(UpdateDashboardSettings(currencyId: currencyId)),
filter: filter, filter: filter,
filteredList: filteredList:
memoizedFilteredSelector(filter, state.selectedCompanyState), memoizedFilteredSelector(filter, state.userCompanyState),
); );
} }

View File

@ -56,7 +56,7 @@ class DocumentEditVM {
isSaving: state.isSaving, isSaving: state.isSaving,
origDocument: state.documentState.map[document.id], origDocument: state.documentState.map[document.id],
document: document, document: document,
company: state.selectedCompany, company: state.company,
onChanged: (DocumentEntity document) { onChanged: (DocumentEntity document) {
store.dispatch(UpdateDocument(document)); store.dispatch(UpdateDocument(document));
}, },

View File

@ -64,7 +64,7 @@ class DocumentViewVM {
return DocumentViewVM( return DocumentViewVM(
state: state, state: state,
company: state.selectedCompany, company: state.company,
isSaving: state.isSaving, isSaving: state.isSaving,
isLoading: state.isLoading, isLoading: state.isLoading,
isDirty: document.isNew, isDirty: document.isNew,

View File

@ -67,7 +67,7 @@ class ExpenseEditVM {
isSaving: state.isSaving, isSaving: state.isSaving,
origExpense: state.expenseState.map[expense.id], origExpense: state.expenseState.map[expense.id],
expense: expense, expense: expense,
company: state.selectedCompany, company: state.company,
onChanged: (ExpenseEntity expense) { onChanged: (ExpenseEntity expense) {
store.dispatch(UpdateExpense(expense)); store.dispatch(UpdateExpense(expense));
}, },

View File

@ -49,7 +49,7 @@ class ExpenseListItem extends StatelessWidget {
? expense.matchesFilterValue(filter) ? expense.matchesFilterValue(filter)
: null; : null;
final company = state.selectedCompany; final company = state.company;
final category = company.expenseCategoryMap[expense.categoryId]; final category = company.expenseCategoryMap[expense.categoryId];
String subtitle = ''; String subtitle = '';

View File

@ -28,7 +28,7 @@ class ExpenseScreen extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
final state = store.state; final state = store.state;
final company = state.selectedCompany; final company = state.company;
final userCompany = state.userCompany; final userCompany = state.userCompany;
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final listUIState = state.uiState.expenseUIState.listUIState; final listUIState = state.uiState.expenseUIState.listUIState;

View File

@ -44,7 +44,7 @@ class _ExpenseViewState extends State<ExpenseView>
Widget build(BuildContext context) { Widget build(BuildContext context) {
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final viewModel = widget.viewModel; final viewModel = widget.viewModel;
final company = viewModel.state.selectedCompany; final company = viewModel.state.company;
return WillPopScope( return WillPopScope(
onWillPop: () async { onWillPop: () async {

View File

@ -74,7 +74,7 @@ class ExpenseViewVM {
return ExpenseViewVM( return ExpenseViewVM(
state: state, state: state,
company: state.selectedCompany, company: state.company,
isSaving: state.isSaving, isSaving: state.isSaving,
isLoading: state.isLoading, isLoading: state.isLoading,
isDirty: expense.isNew, isDirty: expense.isNew,

View File

@ -59,7 +59,7 @@ class GroupEditVM {
isSaving: state.isSaving, isSaving: state.isSaving,
origGroup: state.groupState.map[group.id], origGroup: state.groupState.map[group.id],
group: group, group: group,
company: state.selectedCompany, company: state.company,
onChanged: (GroupEntity group) { onChanged: (GroupEntity group) {
store.dispatch(UpdateGroup(group)); store.dispatch(UpdateGroup(group));
}, },

View File

@ -29,7 +29,7 @@ class GroupSettingsScreen extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
final state = store.state; final state = store.state;
final company = state.selectedCompany; final company = state.company;
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final listUIState = state.uiState.groupUIState.listUIState; final listUIState = state.uiState.groupUIState.listUIState;
final isInMultiselect = listUIState.isInMultiselect(); final isInMultiselect = listUIState.isInMultiselect();

View File

@ -65,7 +65,7 @@ class GroupViewVM {
return GroupViewVM( return GroupViewVM(
state: state, state: state,
company: state.selectedCompany, company: state.company,
isSaving: state.isSaving, isSaving: state.isSaving,
isLoading: state.isLoading, isLoading: state.isLoading,
isDirty: group.isNew, isDirty: group.isNew,

View File

@ -61,7 +61,7 @@ class InvoiceEditContactsVM extends EntityEditContactsVM {
final invoice = state.invoiceUIState.editing; final invoice = state.invoiceUIState.editing;
return InvoiceEditContactsVM( return InvoiceEditContactsVM(
company: state.selectedCompany, company: state.company,
invoice: invoice, invoice: invoice,
client: state.clientState.map[invoice.clientId], client: state.clientState.map[invoice.clientId],
onAddContact: (ContactEntity contact) { onAddContact: (ContactEntity contact) {

View File

@ -80,7 +80,7 @@ class InvoiceEditDetailsVM extends EntityEditDetailsVM {
final invoice = state.invoiceUIState.editing; final invoice = state.invoiceUIState.editing;
return InvoiceEditDetailsVM( return InvoiceEditDetailsVM(
company: state.selectedCompany, company: state.company,
invoice: invoice, invoice: invoice,
onChanged: (InvoiceEntity invoice) => onChanged: (InvoiceEntity invoice) =>
store.dispatch(UpdateInvoice(invoice)), store.dispatch(UpdateInvoice(invoice)),

View File

@ -65,7 +65,7 @@ class InvoiceEditItemsVM extends EntityEditItemsVM {
final invoice = state.invoiceUIState.editing; final invoice = state.invoiceUIState.editing;
return InvoiceEditItemsVM( return InvoiceEditItemsVM(
company: state.selectedCompany, company: state.company,
invoice: invoice, invoice: invoice,
invoiceItemIndex: state.invoiceUIState.editingItemIndex, invoiceItemIndex: state.invoiceUIState.editingItemIndex,
onRemoveInvoiceItemPressed: (index) => onRemoveInvoiceItemPressed: (index) =>

View File

@ -53,7 +53,7 @@ class InvoiceEditNotesVM extends EntityEditNotesVM {
final invoice = state.invoiceUIState.editing; final invoice = state.invoiceUIState.editing;
return InvoiceEditNotesVM( return InvoiceEditNotesVM(
company: state.selectedCompany, company: state.company,
invoice: invoice, invoice: invoice,
onChanged: (InvoiceEntity invoice) => onChanged: (InvoiceEntity invoice) =>
store.dispatch(UpdateInvoice(invoice)), store.dispatch(UpdateInvoice(invoice)),

View File

@ -93,7 +93,7 @@ class InvoiceEditVM extends EntityEditVM {
return InvoiceEditVM( return InvoiceEditVM(
state: state, state: state,
company: state.selectedCompany, company: state.company,
isSaving: state.isSaving, isSaving: state.isSaving,
invoice: invoice, invoice: invoice,
invoiceItemIndex: state.invoiceUIState.editingItemIndex, invoiceItemIndex: state.invoiceUIState.editingItemIndex,

View File

@ -60,12 +60,12 @@ class _InvoiceItemSelectorState extends State<InvoiceItemSelector>
void _onItemsSelected(BuildContext context) { void _onItemsSelected(BuildContext context) {
final List<InvoiceItemEntity> items = []; final List<InvoiceItemEntity> items = [];
final state = StoreProvider.of<AppState>(context).state; final state = StoreProvider.of<AppState>(context).state;
final company = state.selectedCompany; final company = state.company;
_selected.forEach((entity) { _selected.forEach((entity) {
if (entity.entityType == EntityType.product) { if (entity.entityType == EntityType.product) {
final product = entity as ProductEntity; final product = entity as ProductEntity;
if (state.selectedCompany.fillProducts ?? true) { if (state.company.fillProducts ?? true) {
items.add( items.add(
convertProductToInvoiceItem(product: product, context: context)); convertProductToInvoiceItem(product: product, context: context));
} else { } else {
@ -119,7 +119,7 @@ class _InvoiceItemSelectorState extends State<InvoiceItemSelector>
Widget build(BuildContext context) { Widget build(BuildContext context) {
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final state = StoreProvider.of<AppState>(context).state; final state = StoreProvider.of<AppState>(context).state;
final company = state.selectedCompany; final company = state.company;
final showTabBar = company.isModuleEnabled(EntityType.task) || final showTabBar = company.isModuleEnabled(EntityType.task) ||
company.isModuleEnabled(EntityType.expense); company.isModuleEnabled(EntityType.expense);

View File

@ -83,7 +83,7 @@ class EmailInvoiceVM extends EmailEntityVM {
return EmailInvoiceVM( return EmailInvoiceVM(
isLoading: state.isLoading, isLoading: state.isLoading,
isSaving: state.isSaving, isSaving: state.isSaving,
company: state.selectedCompany, company: state.company,
invoice: invoice, invoice: invoice,
client: state.clientState.map[invoice.clientId] ?? client: state.clientState.map[invoice.clientId] ??
ClientEntity(id: invoice.clientId), ClientEntity(id: invoice.clientId),

View File

@ -28,7 +28,7 @@ class InvoiceScreen extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
final state = store.state; final state = store.state;
final company = state.selectedCompany; final company = state.company;
final userCompany = store.state.userCompany; final userCompany = store.state.userCompany;
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final listUIState = store.state.uiState.invoiceUIState.listUIState; final listUIState = store.state.uiState.invoiceUIState.listUIState;

View File

@ -128,7 +128,7 @@ class InvoiceViewVM extends EntityViewVM {
return InvoiceViewVM( return InvoiceViewVM(
state: state, state: state,
company: state.selectedCompany, company: state.company,
isSaving: state.isSaving, isSaving: state.isSaving,
isDirty: invoice.isNew, isDirty: invoice.isNew,
invoice: invoice, invoice: invoice,

View File

@ -24,7 +24,7 @@ class PaymentScreen extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
final state = store.state; final state = store.state;
final company = state.selectedCompany; final company = state.company;
final userCompany = state.userCompany; final userCompany = state.userCompany;
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final listUIState = state.uiState.paymentUIState.listUIState; final listUIState = state.uiState.paymentUIState.listUIState;

View File

@ -56,7 +56,7 @@ class PaymentViewVM {
return PaymentViewVM( return PaymentViewVM(
state: state, state: state,
company: state.selectedCompany, company: state.company,
isSaving: state.isSaving, isSaving: state.isSaving,
isDirty: payment.isNew, isDirty: payment.isNew,
isLoading: state.isLoading, isLoading: state.isLoading,

View File

@ -56,7 +56,7 @@ class ProductEditVM {
return ProductEditVM( return ProductEditVM(
state: state, state: state,
company: state.selectedCompany, company: state.company,
isSaving: state.isSaving, isSaving: state.isSaving,
isDirty: product.isNew, isDirty: product.isNew,
product: product, product: product,

View File

@ -26,7 +26,7 @@ class ProductScreen extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
final state = store.state; final state = store.state;
final company = state.selectedCompany; final company = state.company;
final userCompany = state.userCompany; final userCompany = state.userCompany;
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final listUIState = state.uiState.productUIState.listUIState; final listUIState = state.uiState.productUIState.listUIState;

View File

@ -71,7 +71,7 @@ class ProductViewVM {
isLoading: state.isLoading, isLoading: state.isLoading,
isDirty: product.isNew, isDirty: product.isNew,
product: product, product: product,
company: state.selectedCompany, company: state.company,
onEditPressed: (BuildContext context) { onEditPressed: (BuildContext context) {
final Completer<ProductEntity> completer = Completer<ProductEntity>(); final Completer<ProductEntity> completer = Completer<ProductEntity>();
store.dispatch(EditProduct( store.dispatch(EditProduct(

View File

@ -62,7 +62,7 @@ class ProjectEditVM {
return ProjectEditVM( return ProjectEditVM(
isLoading: state.isLoading, isLoading: state.isLoading,
isSaving: state.isSaving, isSaving: state.isSaving,
company: state.selectedCompany, company: state.company,
project: project, project: project,
state: state, state: state,
origProject: state.projectState.map[project.id], origProject: state.projectState.map[project.id],

View File

@ -26,7 +26,7 @@ class ProjectScreen extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
final state = store.state; final state = store.state;
final company = store.state.selectedCompany; final company = store.state.company;
final userCompany = store.state.userCompany; final userCompany = store.state.userCompany;
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final listUIState = state.uiState.projectUIState.listUIState; final listUIState = state.uiState.projectUIState.listUIState;

View File

@ -68,7 +68,7 @@ class ProjectViewVM {
return ProjectViewVM( return ProjectViewVM(
state: state, state: state,
company: state.selectedCompany, company: state.company,
isSaving: state.isSaving, isSaving: state.isSaving,
isLoading: state.isLoading, isLoading: state.isLoading,
isDirty: project.isNew, isDirty: project.isNew,

View File

@ -60,7 +60,7 @@ class QuoteEditDetailsVM extends EntityEditDetailsVM {
final quote = state.quoteUIState.editing; final quote = state.quoteUIState.editing;
return QuoteEditDetailsVM( return QuoteEditDetailsVM(
company: state.selectedCompany, company: state.company,
invoice: quote, invoice: quote,
onChanged: (InvoiceEntity quote) => store.dispatch(UpdateQuote(quote)), onChanged: (InvoiceEntity quote) => store.dispatch(UpdateQuote(quote)),
clientMap: state.clientState.map, clientMap: state.clientState.map,

View File

@ -48,7 +48,7 @@ class QuoteEditItemsVM extends EntityEditItemsVM {
final quote = state.quoteUIState.editing; final quote = state.quoteUIState.editing;
return QuoteEditItemsVM( return QuoteEditItemsVM(
company: state.selectedCompany, company: state.company,
invoice: quote, invoice: quote,
invoiceItemIndex: state.quoteUIState.editingItemIndex, invoiceItemIndex: state.quoteUIState.editingItemIndex,
onRemoveInvoiceItemPressed: (index) => onRemoveInvoiceItemPressed: (index) =>

View File

@ -42,7 +42,7 @@ class QuoteEditNotesVM extends EntityEditNotesVM {
final quote = state.quoteUIState.editing; final quote = state.quoteUIState.editing;
return QuoteEditNotesVM( return QuoteEditNotesVM(
company: state.selectedCompany, company: state.company,
invoice: quote, invoice: quote,
onChanged: (InvoiceEntity quote) => store.dispatch(UpdateQuote(quote)), onChanged: (InvoiceEntity quote) => store.dispatch(UpdateQuote(quote)),
); );

View File

@ -67,7 +67,7 @@ class QuoteEditVM extends EntityEditVM {
final quote = state.quoteUIState.editing; final quote = state.quoteUIState.editing;
return QuoteEditVM( return QuoteEditVM(
company: state.selectedCompany, company: state.company,
isSaving: state.isSaving, isSaving: state.isSaving,
invoice: quote, invoice: quote,
invoiceItemIndex: state.quoteUIState.editingItemIndex, invoiceItemIndex: state.quoteUIState.editingItemIndex,

View File

@ -65,7 +65,7 @@ class EmailQuoteVM extends EmailEntityVM {
return EmailQuoteVM( return EmailQuoteVM(
isLoading: state.isLoading, isLoading: state.isLoading,
isSaving: state.isSaving, isSaving: state.isSaving,
company: state.selectedCompany, company: state.company,
invoice: quote, invoice: quote,
client: state.clientState.map[quote.clientId], client: state.clientState.map[quote.clientId],
onSendPressed: (context, template, subject, body) => onSendPressed: (context, template, subject, body) =>

View File

@ -28,7 +28,7 @@ class QuoteScreen extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
final state = store.state; final state = store.state;
final company = store.state.selectedCompany; final company = store.state.company;
final userCompany = store.state.userCompany; final userCompany = store.state.userCompany;
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final listUIState = state.uiState.quoteUIState.listUIState; final listUIState = state.uiState.quoteUIState.listUIState;

View File

@ -93,7 +93,7 @@ class QuoteViewVM extends EntityViewVM {
return QuoteViewVM( return QuoteViewVM(
state: state, state: state,
company: state.selectedCompany, company: state.company,
isSaving: state.isSaving, isSaving: state.isSaving,
isDirty: quote.isNew, isDirty: quote.isNew,
invoice: quote, invoice: quote,

View File

@ -158,7 +158,7 @@ class _DeviceSettingsState extends State<DeviceSettings> {
} }
}, },
), ),
viewModel.state.selectedCompany viewModel.state.company
.isModuleEnabled(EntityType.task) .isModuleEnabled(EntityType.task)
? SwitchListTile( ? SwitchListTile(
title: title:

View File

@ -59,7 +59,7 @@ class TaskEditDetailsVM {
task: task, task: task,
taskTime: state.taskUIState.editingTime, taskTime: state.taskUIState.editingTime,
state: state, state: state,
company: state.selectedCompany, company: state.company,
onChanged: (TaskEntity task) { onChanged: (TaskEntity task) {
store.dispatch(UpdateTask(task)); store.dispatch(UpdateTask(task));
}, },

View File

@ -39,7 +39,7 @@ class TaskEditTimesVM {
final task = state.taskUIState.editing; final task = state.taskUIState.editing;
return TaskEditTimesVM( return TaskEditTimesVM(
company: state.selectedCompany, company: state.company,
task: task, task: task,
taskTime: state.taskUIState.editingTime, taskTime: state.taskUIState.editingTime,
onRemoveTaskTimePressed: (index) => store.dispatch(DeleteTaskTime(index)), onRemoveTaskTimePressed: (index) => store.dispatch(DeleteTaskTime(index)),

View File

@ -60,7 +60,7 @@ class TaskEditVM {
task: task, task: task,
taskTime: state.taskUIState.editingTime, taskTime: state.taskUIState.editingTime,
state: state, state: state,
company: state.selectedCompany, company: state.company,
onBackPressed: () { onBackPressed: () {
if (state.uiState.currentRoute.contains(TaskScreen.route)) { if (state.uiState.currentRoute.contains(TaskScreen.route)) {
store.dispatch(UpdateCurrentRoute(TaskScreen.route)); store.dispatch(UpdateCurrentRoute(TaskScreen.route));

View File

@ -42,7 +42,7 @@ class TaskListItem extends StatelessWidget {
final uiState = state.uiState; final uiState = state.uiState;
final taskUIState = uiState.taskUIState; final taskUIState = uiState.taskUIState;
final CompanyEntity company = state.selectedCompany; final CompanyEntity company = state.company;
final taskStatus = company.taskStatusMap[task.taskStatusId]; final taskStatus = company.taskStatusMap[task.taskStatusId];
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);

View File

@ -27,7 +27,7 @@ class TaskScreen extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
final state = store.state; final state = store.state;
final company = store.state.selectedCompany; final company = store.state.company;
final userCompany = store.state.userCompany; final userCompany = store.state.userCompany;
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final listUIState = state.uiState.taskUIState.listUIState; final listUIState = state.uiState.taskUIState.listUIState;

View File

@ -99,7 +99,7 @@ class TaskViewVM {
return TaskViewVM( return TaskViewVM(
state: state, state: state,
company: state.selectedCompany, company: state.company,
isSaving: state.isSaving, isSaving: state.isSaving,
isLoading: state.isLoading, isLoading: state.isLoading,
isDirty: task.isNew, isDirty: task.isNew,

View File

@ -59,7 +59,7 @@ class TaxRateEditVM {
isSaving: state.isSaving, isSaving: state.isSaving,
origTaxRate: state.taxRateState.map[taxRate.id], origTaxRate: state.taxRateState.map[taxRate.id],
taxRate: taxRate, taxRate: taxRate,
company: state.selectedCompany, company: state.company,
onChanged: (TaxRateEntity taxRate) { onChanged: (TaxRateEntity taxRate) {
store.dispatch(UpdateTaxRate(taxRate)); store.dispatch(UpdateTaxRate(taxRate));
}, },

View File

@ -62,7 +62,7 @@ class TaxRateViewVM {
return TaxRateViewVM( return TaxRateViewVM(
state: state, state: state,
company: state.selectedCompany, company: state.company,
isSaving: state.isSaving, isSaving: state.isSaving,
isLoading: state.isLoading, isLoading: state.isLoading,
isDirty: taxRate.isNew, isDirty: taxRate.isNew,

View File

@ -62,7 +62,7 @@ class UserEditVM {
origUser: state.userState.map[user.id], origUser: state.userState.map[user.id],
user: user, user: user,
userCompany: state.userCompany, userCompany: state.userCompany,
company: state.selectedCompany, company: state.company,
onUserChanged: (UserEntity user) { onUserChanged: (UserEntity user) {
store.dispatch(UpdateUser(user)); store.dispatch(UpdateUser(user));
}, },

View File

@ -31,7 +31,7 @@ class UserView extends StatelessWidget {
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final user = viewModel.user; final user = viewModel.user;
final state = StoreProvider.of<AppState>(context).state; final state = StoreProvider.of<AppState>(context).state;
final company = state.selectedCompany; final company = state.company;
final userCompany = state.userCompany; final userCompany = state.userCompany;
return Scaffold( return Scaffold(

View File

@ -69,7 +69,7 @@ class UserViewVM {
return UserViewVM( return UserViewVM(
state: state, state: state,
company: state.selectedCompany, company: state.company,
isSaving: state.isSaving, isSaving: state.isSaving,
isLoading: state.isLoading, isLoading: state.isLoading,
isDirty: user.isNew, isDirty: user.isNew,
@ -98,7 +98,7 @@ class UserViewVM {
if (longPress && user.isActive) { if (longPress && user.isActive) {
store.dispatch(EditInvoice( store.dispatch(EditInvoice(
context: context, context: context,
invoice: InvoiceEntity(company: state.selectedCompany))); invoice: InvoiceEntity(company: state.company)));
} else { } else {
store.dispatch(FilterInvoicesByEntity( store.dispatch(FilterInvoicesByEntity(
entityId: user.id, entityType: EntityType.user)); entityId: user.id, entityType: EntityType.user));
@ -110,7 +110,7 @@ class UserViewVM {
store.dispatch(EditQuote( store.dispatch(EditQuote(
context: context, context: context,
quote: InvoiceEntity( quote: InvoiceEntity(
company: state.selectedCompany, isQuote: true))); company: state.company, isQuote: true)));
} else { } else {
store.dispatch(FilterQuotesByEntity( store.dispatch(FilterQuotesByEntity(
entityId: user.id, entityType: EntityType.user)); entityId: user.id, entityType: EntityType.user));
@ -121,7 +121,7 @@ class UserViewVM {
if (longPress && user.isActive) { if (longPress && user.isActive) {
store.dispatch(EditPayment( store.dispatch(EditPayment(
context: context, context: context,
payment: PaymentEntity(company: state.selectedCompany))); payment: PaymentEntity(company: state.company)));
} else { } else {
store.dispatch(FilterPaymentsByEntity( store.dispatch(FilterPaymentsByEntity(
entityId: user.id, entityType: EntityType.user)); entityId: user.id, entityType: EntityType.user));
@ -154,7 +154,7 @@ class UserViewVM {
store.dispatch(EditExpense( store.dispatch(EditExpense(
context: context, context: context,
expense: ExpenseEntity( expense: ExpenseEntity(
company: state.selectedCompany, uiState: state.uiState))); company: state.company, uiState: state.uiState)));
} else { } else {
store.dispatch(FilterExpensesByEntity( store.dispatch(FilterExpensesByEntity(
entityId: user.id, entityType: EntityType.user)); entityId: user.id, entityType: EntityType.user));

View File

@ -41,7 +41,7 @@ class VendorEditContactsVM {
final vendor = state.vendorUIState.editing; final vendor = state.vendorUIState.editing;
return VendorEditContactsVM( return VendorEditContactsVM(
company: state.selectedCompany, company: state.company,
vendor: vendor, vendor: vendor,
contact: state.vendorUIState.editingContact, contact: state.vendorUIState.editingContact,
onAddContactPressed: () { onAddContactPressed: () {

View File

@ -59,7 +59,7 @@ class VendorEditVM {
isSaving: state.isSaving, isSaving: state.isSaving,
origVendor: state.vendorState.map[vendor.id], origVendor: state.vendorState.map[vendor.id],
vendor: vendor, vendor: vendor,
company: state.selectedCompany, company: state.company,
onChanged: (VendorEntity vendor) { onChanged: (VendorEntity vendor) {
store.dispatch(UpdateVendor(vendor)); store.dispatch(UpdateVendor(vendor));
}, },

View File

@ -26,7 +26,7 @@ class VendorScreen extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
final state = store.state; final state = store.state;
final company = state.selectedCompany; final company = state.company;
final userCompany = store.state.userCompany; final userCompany = store.state.userCompany;
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final listUIState = state.uiState.vendorUIState.listUIState; final listUIState = state.uiState.vendorUIState.listUIState;

View File

@ -53,7 +53,7 @@ class VendorViewVM {
factory VendorViewVM.fromStore(Store<AppState> store) { factory VendorViewVM.fromStore(Store<AppState> store) {
final state = store.state; final state = store.state;
final company = state.selectedCompany; final company = state.company;
final vendor = state.vendorState.map[state.vendorUIState.selectedId] ?? final vendor = state.vendorState.map[state.vendorUIState.selectedId] ??
VendorEntity(id: state.vendorUIState.selectedId); VendorEntity(id: state.vendorUIState.selectedId);
@ -66,7 +66,7 @@ class VendorViewVM {
return VendorViewVM( return VendorViewVM(
state: state, state: state,
company: state.selectedCompany, company: state.company,
isSaving: state.isSaving, isSaving: state.isSaving,
isLoading: state.isLoading, isLoading: state.isLoading,
isDirty: vendor.isNew, isDirty: vendor.isNew,
@ -96,7 +96,7 @@ class VendorViewVM {
store.dispatch(EditExpense( store.dispatch(EditExpense(
context: context, context: context,
expense: ExpenseEntity( expense: ExpenseEntity(
company: state.selectedCompany, vendor: vendor))); company: state.company, vendor: vendor)));
} else { } else {
store.dispatch(FilterExpensesByEntity( store.dispatch(FilterExpensesByEntity(
entityId: vendor.id, entityType: EntityType.vendor)); entityId: vendor.id, entityType: EntityType.vendor));

View File

@ -63,9 +63,9 @@ String formatNumber(
} }
final state = StoreProvider.of<AppState>(context).state; final state = StoreProvider.of<AppState>(context).state;
final CompanyEntity company = state.selectedCompany; final CompanyEntity company = state.company;
final ClientEntity client = final ClientEntity client =
state.selectedCompanyState.clientState.map[clientId]; state.userCompanyState.clientState.map[clientId];
String countryId; String countryId;
@ -239,7 +239,7 @@ String formatDate(String value, BuildContext context,
} }
final state = StoreProvider.of<AppState>(context).state; final state = StoreProvider.of<AppState>(context).state;
final CompanyEntity company = state.selectedCompany; final CompanyEntity company = state.company;
if (state.staticState.dateFormatMap.isEmpty) { if (state.staticState.dateFormatMap.isEmpty) {
return ''; return '';

View File

@ -52,7 +52,7 @@ bool isHosted(BuildContext context) =>
StoreProvider.of<AppState>(context).state.isHosted; StoreProvider.of<AppState>(context).state.isHosted;
bool isPaidAccount(BuildContext context) { bool isPaidAccount(BuildContext context) {
final company = StoreProvider.of<AppState>(context).state.selectedCompany; final company = StoreProvider.of<AppState>(context).state.company;
return isSelfHosted(context) || company.isProPlan || company.isEnterprisePlan; return isSelfHosted(context) || company.isProPlan || company.isEnterprisePlan;
} }

View File

@ -14,7 +14,7 @@ String processTemplate(
final state = StoreProvider.of<AppState>(context).state; final state = StoreProvider.of<AppState>(context).state;
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final company = state.selectedCompany; final company = state.company;
final client = state.clientState.map[invoice.clientId] ?? final client = state.clientState.map[invoice.clientId] ??
ClientEntity(id: invoice.clientId); ClientEntity(id: invoice.clientId);
final contact = client.contacts.first; final contact = client.contacts.first;