diff --git a/lib/data/models/client_model.g.dart b/lib/data/models/client_model.g.dart index a2bdc4ea2..7f6b7d9f0 100644 --- a/lib/data/models/client_model.g.dart +++ b/lib/data/models/client_model.g.dart @@ -268,7 +268,7 @@ class _$ClientEntitySerializer implements StructuredSerializer { result ..add('entity_type') ..add(serializers.serialize(object.subEntityType, - specifiedType: const FullType(String))); + specifiedType: const FullType(EntityType))); } if (object.id != null) { result @@ -466,7 +466,7 @@ class _$ClientEntitySerializer implements StructuredSerializer { break; case 'entity_type': result.subEntityType = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; + specifiedType: const FullType(EntityType)) as EntityType; break; case 'id': result.id = serializers.deserialize(value, @@ -578,7 +578,7 @@ class _$ContactEntitySerializer implements StructuredSerializer { result ..add('entity_type') ..add(serializers.serialize(object.subEntityType, - specifiedType: const FullType(String))); + specifiedType: const FullType(EntityType))); } if (object.id != null) { result @@ -683,7 +683,7 @@ class _$ContactEntitySerializer implements StructuredSerializer { break; case 'entity_type': result.subEntityType = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; + specifiedType: const FullType(EntityType)) as EntityType; break; case 'id': result.id = serializers.deserialize(value, @@ -971,7 +971,7 @@ class _$ClientEntity extends ClientEntity { @override final String assignedUserId; @override - final String subEntityType; + final EntityType subEntityType; @override final String id; @@ -1466,9 +1466,9 @@ class ClientEntityBuilder set assignedUserId(String assignedUserId) => _$this._assignedUserId = assignedUserId; - String _subEntityType; - String get subEntityType => _$this._subEntityType; - set subEntityType(String subEntityType) => + EntityType _subEntityType; + EntityType get subEntityType => _$this._subEntityType; + set subEntityType(EntityType subEntityType) => _$this._subEntityType = subEntityType; String _id; @@ -1656,7 +1656,7 @@ class _$ContactEntity extends ContactEntity { @override final String assignedUserId; @override - final String subEntityType; + final EntityType subEntityType; @override final String id; @@ -1917,9 +1917,9 @@ class ContactEntityBuilder set assignedUserId(String assignedUserId) => _$this._assignedUserId = assignedUserId; - String _subEntityType; - String get subEntityType => _$this._subEntityType; - set subEntityType(String subEntityType) => + EntityType _subEntityType; + EntityType get subEntityType => _$this._subEntityType; + set subEntityType(EntityType subEntityType) => _$this._subEntityType = subEntityType; String _id; diff --git a/lib/data/models/company_gateway_model.g.dart b/lib/data/models/company_gateway_model.g.dart index 07b77abbb..914534651 100644 --- a/lib/data/models/company_gateway_model.g.dart +++ b/lib/data/models/company_gateway_model.g.dart @@ -212,7 +212,7 @@ class _$CompanyGatewayEntitySerializer result ..add('entity_type') ..add(serializers.serialize(object.subEntityType, - specifiedType: const FullType(String))); + specifiedType: const FullType(EntityType))); } if (object.id != null) { result @@ -316,7 +316,7 @@ class _$CompanyGatewayEntitySerializer break; case 'entity_type': result.subEntityType = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; + specifiedType: const FullType(EntityType)) as EntityType; break; case 'id': result.id = serializers.deserialize(value, @@ -684,7 +684,7 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity { @override final String assignedUserId; @override - final String subEntityType; + final EntityType subEntityType; @override final String id; @@ -959,9 +959,9 @@ class CompanyGatewayEntityBuilder set assignedUserId(String assignedUserId) => _$this._assignedUserId = assignedUserId; - String _subEntityType; - String get subEntityType => _$this._subEntityType; - set subEntityType(String subEntityType) => + EntityType _subEntityType; + EntityType get subEntityType => _$this._subEntityType; + set subEntityType(EntityType subEntityType) => _$this._subEntityType = subEntityType; String _id; diff --git a/lib/data/models/company_model.g.dart b/lib/data/models/company_model.g.dart index e1c0c8110..187e82c8f 100644 --- a/lib/data/models/company_model.g.dart +++ b/lib/data/models/company_model.g.dart @@ -253,7 +253,7 @@ class _$CompanyEntitySerializer implements StructuredSerializer { result ..add('entity_type') ..add(serializers.serialize(object.subEntityType, - specifiedType: const FullType(String))); + specifiedType: const FullType(EntityType))); } if (object.id != null) { result @@ -532,7 +532,7 @@ class _$CompanyEntitySerializer implements StructuredSerializer { break; case 'entity_type': result.subEntityType = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; + specifiedType: const FullType(EntityType)) as EntityType; break; case 'id': result.id = serializers.deserialize(value, @@ -2721,7 +2721,7 @@ class _$CompanyEntity extends CompanyEntity { @override final String assignedUserId; @override - final String subEntityType; + final EntityType subEntityType; @override final String id; @@ -3365,9 +3365,9 @@ class CompanyEntityBuilder set assignedUserId(String assignedUserId) => _$this._assignedUserId = assignedUserId; - String _subEntityType; - String get subEntityType => _$this._subEntityType; - set subEntityType(String subEntityType) => + EntityType _subEntityType; + EntityType get subEntityType => _$this._subEntityType; + set subEntityType(EntityType subEntityType) => _$this._subEntityType = subEntityType; String _id; diff --git a/lib/data/models/document_model.g.dart b/lib/data/models/document_model.g.dart index ee1d26529..9637818cb 100644 --- a/lib/data/models/document_model.g.dart +++ b/lib/data/models/document_model.g.dart @@ -232,7 +232,7 @@ class _$DocumentEntitySerializer result ..add('entity_type') ..add(serializers.serialize(object.subEntityType, - specifiedType: const FullType(String))); + specifiedType: const FullType(EntityType))); } if (object.id != null) { result @@ -349,7 +349,7 @@ class _$DocumentEntitySerializer break; case 'entity_type': result.subEntityType = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; + specifiedType: const FullType(EntityType)) as EntityType; break; case 'id': result.id = serializers.deserialize(value, @@ -600,7 +600,7 @@ class _$DocumentEntity extends DocumentEntity { @override final String assignedUserId; @override - final String subEntityType; + final EntityType subEntityType; @override final String id; @@ -871,9 +871,9 @@ class DocumentEntityBuilder set assignedUserId(String assignedUserId) => _$this._assignedUserId = assignedUserId; - String _subEntityType; - String get subEntityType => _$this._subEntityType; - set subEntityType(String subEntityType) => + EntityType _subEntityType; + EntityType get subEntityType => _$this._subEntityType; + set subEntityType(EntityType subEntityType) => _$this._subEntityType = subEntityType; String _id; diff --git a/lib/data/models/entities.dart b/lib/data/models/entities.dart index aec8c1fee..e732003ca 100644 --- a/lib/data/models/entities.dart +++ b/lib/data/models/entities.dart @@ -199,7 +199,7 @@ abstract class BaseEntity implements SelectableEntity { @nullable @BuiltValueField(wireName: 'entity_type') - String get subEntityType; + EntityType get subEntityType; String get entityKey => '__${entityType}__${id}__'; diff --git a/lib/data/models/expense_model.g.dart b/lib/data/models/expense_model.g.dart index 23c8938bb..0b19f5f87 100644 --- a/lib/data/models/expense_model.g.dart +++ b/lib/data/models/expense_model.g.dart @@ -271,7 +271,7 @@ class _$ExpenseEntitySerializer implements StructuredSerializer { result ..add('entity_type') ..add(serializers.serialize(object.subEntityType, - specifiedType: const FullType(String))); + specifiedType: const FullType(EntityType))); } if (object.id != null) { result @@ -436,7 +436,7 @@ class _$ExpenseEntitySerializer implements StructuredSerializer { break; case 'entity_type': result.subEntityType = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; + specifiedType: const FullType(EntityType)) as EntityType; break; case 'id': result.id = serializers.deserialize(value, @@ -513,7 +513,7 @@ class _$ExpenseCategoryEntitySerializer result ..add('entity_type') ..add(serializers.serialize(object.subEntityType, - specifiedType: const FullType(String))); + specifiedType: const FullType(EntityType))); } if (object.id != null) { result @@ -570,7 +570,7 @@ class _$ExpenseCategoryEntitySerializer break; case 'entity_type': result.subEntityType = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; + specifiedType: const FullType(EntityType)) as EntityType; break; case 'id': result.id = serializers.deserialize(value, @@ -895,7 +895,7 @@ class _$ExpenseEntity extends ExpenseEntity { @override final String assignedUserId; @override - final String subEntityType; + final EntityType subEntityType; @override final String id; @@ -1299,9 +1299,9 @@ class ExpenseEntityBuilder set assignedUserId(String assignedUserId) => _$this._assignedUserId = assignedUserId; - String _subEntityType; - String get subEntityType => _$this._subEntityType; - set subEntityType(String subEntityType) => + EntityType _subEntityType; + EntityType get subEntityType => _$this._subEntityType; + set subEntityType(EntityType subEntityType) => _$this._subEntityType = subEntityType; String _id; @@ -1431,7 +1431,7 @@ class _$ExpenseCategoryEntity extends ExpenseCategoryEntity { @override final String assignedUserId; @override - final String subEntityType; + final EntityType subEntityType; @override final String id; @@ -1558,9 +1558,9 @@ class ExpenseCategoryEntityBuilder set assignedUserId(String assignedUserId) => _$this._assignedUserId = assignedUserId; - String _subEntityType; - String get subEntityType => _$this._subEntityType; - set subEntityType(String subEntityType) => + EntityType _subEntityType; + EntityType get subEntityType => _$this._subEntityType; + set subEntityType(EntityType subEntityType) => _$this._subEntityType = subEntityType; String _id; diff --git a/lib/data/models/gateway_token_model.g.dart b/lib/data/models/gateway_token_model.g.dart index c71073e12..35594f719 100644 --- a/lib/data/models/gateway_token_model.g.dart +++ b/lib/data/models/gateway_token_model.g.dart @@ -179,7 +179,7 @@ class _$GatewayTokenEntitySerializer result ..add('entity_type') ..add(serializers.serialize(object.subEntityType, - specifiedType: const FullType(String))); + specifiedType: const FullType(EntityType))); } if (object.id != null) { result @@ -248,7 +248,7 @@ class _$GatewayTokenEntitySerializer break; case 'entity_type': result.subEntityType = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; + specifiedType: const FullType(EntityType)) as EntityType; break; case 'id': result.id = serializers.deserialize(value, @@ -477,7 +477,7 @@ class _$GatewayTokenEntity extends GatewayTokenEntity { @override final String assignedUserId; @override - final String subEntityType; + final EntityType subEntityType; @override final String id; @@ -643,9 +643,9 @@ class GatewayTokenEntityBuilder set assignedUserId(String assignedUserId) => _$this._assignedUserId = assignedUserId; - String _subEntityType; - String get subEntityType => _$this._subEntityType; - set subEntityType(String subEntityType) => + EntityType _subEntityType; + EntityType get subEntityType => _$this._subEntityType; + set subEntityType(EntityType subEntityType) => _$this._subEntityType = subEntityType; String _id; diff --git a/lib/data/models/group_model.g.dart b/lib/data/models/group_model.g.dart index 863dc10ca..18d877b95 100644 --- a/lib/data/models/group_model.g.dart +++ b/lib/data/models/group_model.g.dart @@ -161,7 +161,7 @@ class _$GroupEntitySerializer implements StructuredSerializer { result ..add('entity_type') ..add(serializers.serialize(object.subEntityType, - specifiedType: const FullType(String))); + specifiedType: const FullType(EntityType))); } if (object.id != null) { result @@ -221,7 +221,7 @@ class _$GroupEntitySerializer implements StructuredSerializer { break; case 'entity_type': result.subEntityType = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; + specifiedType: const FullType(EntityType)) as EntityType; break; case 'id': result.id = serializers.deserialize(value, @@ -439,7 +439,7 @@ class _$GroupEntity extends GroupEntity { @override final String assignedUserId; @override - final String subEntityType; + final EntityType subEntityType; @override final String id; @@ -575,9 +575,9 @@ class GroupEntityBuilder implements Builder { set assignedUserId(String assignedUserId) => _$this._assignedUserId = assignedUserId; - String _subEntityType; - String get subEntityType => _$this._subEntityType; - set subEntityType(String subEntityType) => + EntityType _subEntityType; + EntityType get subEntityType => _$this._subEntityType; + set subEntityType(EntityType subEntityType) => _$this._subEntityType = subEntityType; String _id; diff --git a/lib/data/models/invoice_model.dart b/lib/data/models/invoice_model.dart index 5e2e5251c..4cf95c2d1 100644 --- a/lib/data/models/invoice_model.dart +++ b/lib/data/models/invoice_model.dart @@ -74,11 +74,16 @@ class InvoiceFields { abstract class InvoiceEntity extends Object with BaseEntity, SelectableEntity, CalculateInvoiceTotal, BelongsToClient implements Built { - factory InvoiceEntity( - {String id, bool isQuote = false, AppState state, ClientEntity client}) { + factory InvoiceEntity({ + String id, + AppState state, + ClientEntity client, + EntityType entityType, + }) { final company = state?.company; return _$InvoiceEntity._( id: id ?? BaseEntity.nextId, + subEntityType: entityType ?? EntityType.invoice, isChanged: false, amount: 0.0, balance: 0.0, @@ -153,8 +158,8 @@ abstract class InvoiceEntity extends Object @override EntityType get entityType { - if ((subEntityType ?? '').isNotEmpty) { - return EntityType.valueOf(subEntityType); + if (subEntityType != null) { + return subEntityType; } else { return EntityType.invoice; } diff --git a/lib/data/models/invoice_model.g.dart b/lib/data/models/invoice_model.g.dart index 36478765c..4d1871e73 100644 --- a/lib/data/models/invoice_model.g.dart +++ b/lib/data/models/invoice_model.g.dart @@ -329,7 +329,7 @@ class _$InvoiceEntitySerializer implements StructuredSerializer { result ..add('entity_type') ..add(serializers.serialize(object.subEntityType, - specifiedType: const FullType(String))); + specifiedType: const FullType(EntityType))); } if (object.id != null) { result @@ -558,7 +558,7 @@ class _$InvoiceEntitySerializer implements StructuredSerializer { break; case 'entity_type': result.subEntityType = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; + specifiedType: const FullType(EntityType)) as EntityType; break; case 'id': result.id = serializers.deserialize(value, @@ -823,7 +823,7 @@ class _$InvitationEntitySerializer result ..add('entity_type') ..add(serializers.serialize(object.subEntityType, - specifiedType: const FullType(String))); + specifiedType: const FullType(EntityType))); } if (object.id != null) { result @@ -896,7 +896,7 @@ class _$InvitationEntitySerializer break; case 'entity_type': result.subEntityType = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; + specifiedType: const FullType(EntityType)) as EntityType; break; case 'id': result.id = serializers.deserialize(value, @@ -1200,7 +1200,7 @@ class _$InvoiceEntity extends InvoiceEntity { @override final String assignedUserId; @override - final String subEntityType; + final EntityType subEntityType; @override final String id; @@ -1746,9 +1746,9 @@ class InvoiceEntityBuilder set assignedUserId(String assignedUserId) => _$this._assignedUserId = assignedUserId; - String _subEntityType; - String get subEntityType => _$this._subEntityType; - set subEntityType(String subEntityType) => + EntityType _subEntityType; + EntityType get subEntityType => _$this._subEntityType; + set subEntityType(EntityType subEntityType) => _$this._subEntityType = subEntityType; String _id; @@ -2297,7 +2297,7 @@ class _$InvitationEntity extends InvitationEntity { @override final String assignedUserId; @override - final String subEntityType; + final EntityType subEntityType; @override final String id; @@ -2471,9 +2471,9 @@ class InvitationEntityBuilder set assignedUserId(String assignedUserId) => _$this._assignedUserId = assignedUserId; - String _subEntityType; - String get subEntityType => _$this._subEntityType; - set subEntityType(String subEntityType) => + EntityType _subEntityType; + EntityType get subEntityType => _$this._subEntityType; + set subEntityType(EntityType subEntityType) => _$this._subEntityType = subEntityType; String _id; diff --git a/lib/data/models/models.dart b/lib/data/models/models.dart index c82500925..1a45a1c55 100644 --- a/lib/data/models/models.dart +++ b/lib/data/models/models.dart @@ -54,6 +54,7 @@ class EntityAction extends EnumClass { static const EntityAction newClient = _$newClient; static const EntityAction newInvoice = _$newInvoice; static const EntityAction newQuote = _$newQuote; + static const EntityAction newCredit = _$newCredit; static const EntityAction newExpense = _$newExpense; static const EntityAction newProject = _$newProject; static const EntityAction newTask = _$newTask; diff --git a/lib/data/models/models.g.dart b/lib/data/models/models.g.dart index 6cc296c60..cadfbafac 100644 --- a/lib/data/models/models.g.dart +++ b/lib/data/models/models.g.dart @@ -23,6 +23,7 @@ const EntityAction _$markPaid = const EntityAction._('markPaid'); const EntityAction _$newClient = const EntityAction._('newClient'); const EntityAction _$newInvoice = const EntityAction._('newInvoice'); const EntityAction _$newQuote = const EntityAction._('newQuote'); +const EntityAction _$newCredit = const EntityAction._('newCredit'); const EntityAction _$newExpense = const EntityAction._('newExpense'); const EntityAction _$newProject = const EntityAction._('newProject'); const EntityAction _$newTask = const EntityAction._('newTask'); @@ -76,6 +77,8 @@ EntityAction _$valueOf(String name) { return _$newInvoice; case 'newQuote': return _$newQuote; + case 'newCredit': + return _$newCredit; case 'newExpense': return _$newExpense; case 'newProject': @@ -130,6 +133,7 @@ final BuiltSet _$values = _$newClient, _$newInvoice, _$newQuote, + _$newCredit, _$newExpense, _$newProject, _$newTask, diff --git a/lib/data/models/payment_model.g.dart b/lib/data/models/payment_model.g.dart index 4620264cf..e083b0254 100644 --- a/lib/data/models/payment_model.g.dart +++ b/lib/data/models/payment_model.g.dart @@ -271,7 +271,7 @@ class _$PaymentEntitySerializer implements StructuredSerializer { result ..add('entity_type') ..add(serializers.serialize(object.subEntityType, - specifiedType: const FullType(String))); + specifiedType: const FullType(EntityType))); } if (object.id != null) { result @@ -418,7 +418,7 @@ class _$PaymentEntitySerializer implements StructuredSerializer { break; case 'entity_type': result.subEntityType = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; + specifiedType: const FullType(EntityType)) as EntityType; break; case 'id': result.id = serializers.deserialize(value, @@ -771,7 +771,7 @@ class _$PaymentEntity extends PaymentEntity { @override final String assignedUserId; @override - final String subEntityType; + final EntityType subEntityType; @override final String id; @@ -1098,9 +1098,9 @@ class PaymentEntityBuilder set assignedUserId(String assignedUserId) => _$this._assignedUserId = assignedUserId; - String _subEntityType; - String get subEntityType => _$this._subEntityType; - set subEntityType(String subEntityType) => + EntityType _subEntityType; + EntityType get subEntityType => _$this._subEntityType; + set subEntityType(EntityType subEntityType) => _$this._subEntityType = subEntityType; String _id; diff --git a/lib/data/models/product_model.g.dart b/lib/data/models/product_model.g.dart index b3deed442..3ca29e146 100644 --- a/lib/data/models/product_model.g.dart +++ b/lib/data/models/product_model.g.dart @@ -227,7 +227,7 @@ class _$ProductEntitySerializer implements StructuredSerializer { result ..add('entity_type') ..add(serializers.serialize(object.subEntityType, - specifiedType: const FullType(String))); + specifiedType: const FullType(EntityType))); } if (object.id != null) { result @@ -348,7 +348,7 @@ class _$ProductEntitySerializer implements StructuredSerializer { break; case 'entity_type': result.subEntityType = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; + specifiedType: const FullType(EntityType)) as EntityType; break; case 'id': result.id = serializers.deserialize(value, @@ -600,7 +600,7 @@ class _$ProductEntity extends ProductEntity { @override final String assignedUserId; @override - final String subEntityType; + final EntityType subEntityType; @override final String id; @@ -892,9 +892,9 @@ class ProductEntityBuilder set assignedUserId(String assignedUserId) => _$this._assignedUserId = assignedUserId; - String _subEntityType; - String get subEntityType => _$this._subEntityType; - set subEntityType(String subEntityType) => + EntityType _subEntityType; + EntityType get subEntityType => _$this._subEntityType; + set subEntityType(EntityType subEntityType) => _$this._subEntityType = subEntityType; String _id; diff --git a/lib/data/models/project_model.g.dart b/lib/data/models/project_model.g.dart index ebc62d06f..ef3ac361c 100644 --- a/lib/data/models/project_model.g.dart +++ b/lib/data/models/project_model.g.dart @@ -194,7 +194,7 @@ class _$ProjectEntitySerializer implements StructuredSerializer { result ..add('entity_type') ..add(serializers.serialize(object.subEntityType, - specifiedType: const FullType(String))); + specifiedType: const FullType(EntityType))); } if (object.id != null) { result @@ -287,7 +287,7 @@ class _$ProjectEntitySerializer implements StructuredSerializer { break; case 'entity_type': result.subEntityType = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; + specifiedType: const FullType(EntityType)) as EntityType; break; case 'id': result.id = serializers.deserialize(value, @@ -525,7 +525,7 @@ class _$ProjectEntity extends ProjectEntity { @override final String assignedUserId; @override - final String subEntityType; + final EntityType subEntityType; @override final String id; @@ -767,9 +767,9 @@ class ProjectEntityBuilder set assignedUserId(String assignedUserId) => _$this._assignedUserId = assignedUserId; - String _subEntityType; - String get subEntityType => _$this._subEntityType; - set subEntityType(String subEntityType) => + EntityType _subEntityType; + EntityType get subEntityType => _$this._subEntityType; + set subEntityType(EntityType subEntityType) => _$this._subEntityType = subEntityType; String _id; diff --git a/lib/data/models/quote_model.g.dart b/lib/data/models/quote_model.g.dart index 425b822e5..3ddac356d 100644 --- a/lib/data/models/quote_model.g.dart +++ b/lib/data/models/quote_model.g.dart @@ -304,7 +304,7 @@ class _$QuoteEntitySerializer implements StructuredSerializer { result ..add('entity_type') ..add(serializers.serialize(object.subEntityType, - specifiedType: const FullType(String))); + specifiedType: const FullType(EntityType))); } if (object.id != null) { result @@ -536,7 +536,7 @@ class _$QuoteEntitySerializer implements StructuredSerializer { break; case 'entity_type': result.subEntityType = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; + specifiedType: const FullType(EntityType)) as EntityType; break; case 'id': result.id = serializers.deserialize(value, @@ -620,7 +620,7 @@ class _$InvitationEntitySerializer result ..add('entity_type') ..add(serializers.serialize(object.subEntityType, - specifiedType: const FullType(String))); + specifiedType: const FullType(EntityType))); } if (object.id != null) { result @@ -693,7 +693,7 @@ class _$InvitationEntitySerializer break; case 'entity_type': result.subEntityType = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; + specifiedType: const FullType(EntityType)) as EntityType; break; case 'id': result.id = serializers.deserialize(value, @@ -995,7 +995,7 @@ class _$QuoteEntity extends QuoteEntity { @override final String assignedUserId; @override - final String subEntityType; + final EntityType subEntityType; @override final String id; @@ -1568,9 +1568,9 @@ class QuoteEntityBuilder implements Builder { set assignedUserId(String assignedUserId) => _$this._assignedUserId = assignedUserId; - String _subEntityType; - String get subEntityType => _$this._subEntityType; - set subEntityType(String subEntityType) => + EntityType _subEntityType; + EntityType get subEntityType => _$this._subEntityType; + set subEntityType(EntityType subEntityType) => _$this._subEntityType = subEntityType; String _id; @@ -1755,7 +1755,7 @@ class _$InvitationEntity extends InvitationEntity { @override final String assignedUserId; @override - final String subEntityType; + final EntityType subEntityType; @override final String id; @@ -1929,9 +1929,9 @@ class InvitationEntityBuilder set assignedUserId(String assignedUserId) => _$this._assignedUserId = assignedUserId; - String _subEntityType; - String get subEntityType => _$this._subEntityType; - set subEntityType(String subEntityType) => + EntityType _subEntityType; + EntityType get subEntityType => _$this._subEntityType; + set subEntityType(EntityType subEntityType) => _$this._subEntityType = subEntityType; String _id; diff --git a/lib/data/models/task_model.g.dart b/lib/data/models/task_model.g.dart index 35d651ed7..cdac87d6c 100644 --- a/lib/data/models/task_model.g.dart +++ b/lib/data/models/task_model.g.dart @@ -274,7 +274,7 @@ class _$TaskEntitySerializer implements StructuredSerializer { result ..add('entity_type') ..add(serializers.serialize(object.subEntityType, - specifiedType: const FullType(String))); + specifiedType: const FullType(EntityType))); } if (object.id != null) { result @@ -382,7 +382,7 @@ class _$TaskEntitySerializer implements StructuredSerializer { break; case 'entity_type': result.subEntityType = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; + specifiedType: const FullType(EntityType)) as EntityType; break; case 'id': result.id = serializers.deserialize(value, @@ -766,7 +766,7 @@ class _$TaskEntity extends TaskEntity { @override final String assignedUserId; @override - final String subEntityType; + final EntityType subEntityType; @override final String id; @@ -1016,9 +1016,9 @@ class TaskEntityBuilder implements Builder { set assignedUserId(String assignedUserId) => _$this._assignedUserId = assignedUserId; - String _subEntityType; - String get subEntityType => _$this._subEntityType; - set subEntityType(String subEntityType) => + EntityType _subEntityType; + EntityType get subEntityType => _$this._subEntityType; + set subEntityType(EntityType subEntityType) => _$this._subEntityType = subEntityType; String _id; diff --git a/lib/data/models/tax_rate_model.g.dart b/lib/data/models/tax_rate_model.g.dart index a7eb6e317..b546634da 100644 --- a/lib/data/models/tax_rate_model.g.dart +++ b/lib/data/models/tax_rate_model.g.dart @@ -169,7 +169,7 @@ class _$TaxRateEntitySerializer implements StructuredSerializer { result ..add('entity_type') ..add(serializers.serialize(object.subEntityType, - specifiedType: const FullType(String))); + specifiedType: const FullType(EntityType))); } if (object.id != null) { result @@ -230,7 +230,7 @@ class _$TaxRateEntitySerializer implements StructuredSerializer { break; case 'entity_type': result.subEntityType = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; + specifiedType: const FullType(EntityType)) as EntityType; break; case 'id': result.id = serializers.deserialize(value, @@ -452,7 +452,7 @@ class _$TaxRateEntity extends TaxRateEntity { @override final String assignedUserId; @override - final String subEntityType; + final EntityType subEntityType; @override final String id; @@ -588,9 +588,9 @@ class TaxRateEntityBuilder set assignedUserId(String assignedUserId) => _$this._assignedUserId = assignedUserId; - String _subEntityType; - String get subEntityType => _$this._subEntityType; - set subEntityType(String subEntityType) => + EntityType _subEntityType; + EntityType get subEntityType => _$this._subEntityType; + set subEntityType(EntityType subEntityType) => _$this._subEntityType = subEntityType; String _id; diff --git a/lib/data/models/user_model.g.dart b/lib/data/models/user_model.g.dart index 53399f8ed..7c3fed719 100644 --- a/lib/data/models/user_model.g.dart +++ b/lib/data/models/user_model.g.dart @@ -247,7 +247,7 @@ class _$UserEntitySerializer implements StructuredSerializer { result ..add('entity_type') ..add(serializers.serialize(object.subEntityType, - specifiedType: const FullType(String))); + specifiedType: const FullType(EntityType))); } if (object.id != null) { result @@ -336,7 +336,7 @@ class _$UserEntitySerializer implements StructuredSerializer { break; case 'entity_type': result.subEntityType = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; + specifiedType: const FullType(EntityType)) as EntityType; break; case 'id': result.id = serializers.deserialize(value, @@ -664,7 +664,7 @@ class _$UserEntity extends UserEntity { @override final String assignedUserId; @override - final String subEntityType; + final EntityType subEntityType; @override final String id; @@ -877,9 +877,9 @@ class UserEntityBuilder implements Builder { set assignedUserId(String assignedUserId) => _$this._assignedUserId = assignedUserId; - String _subEntityType; - String get subEntityType => _$this._subEntityType; - set subEntityType(String subEntityType) => + EntityType _subEntityType; + EntityType get subEntityType => _$this._subEntityType; + set subEntityType(EntityType subEntityType) => _$this._subEntityType = subEntityType; String _id; diff --git a/lib/data/models/vendor_model.g.dart b/lib/data/models/vendor_model.g.dart index 6497b3121..0973cf990 100644 --- a/lib/data/models/vendor_model.g.dart +++ b/lib/data/models/vendor_model.g.dart @@ -215,7 +215,7 @@ class _$VendorEntitySerializer implements StructuredSerializer { result ..add('entity_type') ..add(serializers.serialize(object.subEntityType, - specifiedType: const FullType(String))); + specifiedType: const FullType(EntityType))); } if (object.id != null) { result @@ -341,7 +341,7 @@ class _$VendorEntitySerializer implements StructuredSerializer { break; case 'entity_type': result.subEntityType = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; + specifiedType: const FullType(EntityType)) as EntityType; break; case 'id': result.id = serializers.deserialize(value, @@ -431,7 +431,7 @@ class _$VendorContactEntitySerializer result ..add('entity_type') ..add(serializers.serialize(object.subEntityType, - specifiedType: const FullType(String))); + specifiedType: const FullType(EntityType))); } if (object.id != null) { result @@ -504,7 +504,7 @@ class _$VendorContactEntitySerializer break; case 'entity_type': result.subEntityType = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; + specifiedType: const FullType(EntityType)) as EntityType; break; case 'id': result.id = serializers.deserialize(value, @@ -758,7 +758,7 @@ class _$VendorEntity extends VendorEntity { @override final String assignedUserId; @override - final String subEntityType; + final EntityType subEntityType; @override final String id; @@ -1071,9 +1071,9 @@ class VendorEntityBuilder set assignedUserId(String assignedUserId) => _$this._assignedUserId = assignedUserId; - String _subEntityType; - String get subEntityType => _$this._subEntityType; - set subEntityType(String subEntityType) => + EntityType _subEntityType; + EntityType get subEntityType => _$this._subEntityType; + set subEntityType(EntityType subEntityType) => _$this._subEntityType = subEntityType; String _id; @@ -1204,7 +1204,7 @@ class _$VendorContactEntity extends VendorContactEntity { @override final String assignedUserId; @override - final String subEntityType; + final EntityType subEntityType; @override final String id; @@ -1381,9 +1381,9 @@ class VendorContactEntityBuilder set assignedUserId(String assignedUserId) => _$this._assignedUserId = assignedUserId; - String _subEntityType; - String get subEntityType => _$this._subEntityType; - set subEntityType(String subEntityType) => + EntityType _subEntityType; + EntityType get subEntityType => _$this._subEntityType; + set subEntityType(EntityType subEntityType) => _$this._subEntityType = subEntityType; String _id; diff --git a/lib/redux/app/app_actions.dart b/lib/redux/app/app_actions.dart index 939769bb3..e19967324 100644 --- a/lib/redux/app/app_actions.dart +++ b/lib/redux/app/app_actions.dart @@ -25,6 +25,7 @@ import 'package:invoiceninja_flutter/redux/vendor/vendor_actions.dart'; import 'package:invoiceninja_flutter/utils/completers.dart'; import 'package:invoiceninja_flutter/utils/dialogs.dart'; import 'package:invoiceninja_flutter/utils/localization.dart'; + // STARTER: import - do not remove comment import 'package:invoiceninja_flutter/redux/credit/credit_actions.dart'; @@ -506,7 +507,7 @@ void createEntityByType( force: force, quote: InvoiceEntity( state: state, - isQuote: true, + entityType: EntityType.quote, ))); break; case EntityType.vendor: @@ -558,7 +559,10 @@ void createEntityByType( store.dispatch(EditCredit( navigator: navigator, force: force, - credit: InvoiceEntity(state: state), + credit: InvoiceEntity( + state: state, + entityType: EntityType.credit, + ), )); break; } diff --git a/lib/redux/client/client_actions.dart b/lib/redux/client/client_actions.dart index 7701cf1d5..791bb106b 100644 --- a/lib/redux/client/client_actions.dart +++ b/lib/redux/client/client_actions.dart @@ -324,7 +324,26 @@ void handleClientAction( } createEntity( context: context, - entity: InvoiceEntity(state: state, client: client, isQuote: true)); + entity: InvoiceEntity( + state: state, + client: client, + entityType: EntityType.quote, + )); + break; + case EntityAction.newCredit: + if (isNotMobile(context)) { + filterEntitiesByType( + context: context, + entityType: EntityType.credit, + filterEntity: client); + } + createEntity( + context: context, + entity: InvoiceEntity( + state: state, + client: client, + entityType: EntityType.credit, + )); break; case EntityAction.newExpense: if (isNotMobile(context)) { diff --git a/lib/ui/user/view/user_view_vm.dart b/lib/ui/user/view/user_view_vm.dart index 0f2159367..ef16e6b45 100644 --- a/lib/ui/user/view/user_view_vm.dart +++ b/lib/ui/user/view/user_view_vm.dart @@ -91,7 +91,8 @@ class UserViewVM { if (longPress && user.isActive) { createEntity( context: context, - entity: InvoiceEntity(state: state, isQuote: true)); + entity: InvoiceEntity( + state: state, entityType: EntityType.quote)); } else { viewEntitiesByType( context: context, @@ -99,6 +100,19 @@ class UserViewVM { filterEntity: user); } break; + case EntityType.credit: + if (longPress && user.isActive) { + createEntity( + context: context, + entity: InvoiceEntity( + state: state, entityType: EntityType.credit)); + } else { + viewEntitiesByType( + context: context, + entityType: EntityType.credit, + filterEntity: user); + } + break; case EntityType.payment: if (longPress && user.isActive) { createEntity(