diff --git a/lib/data/models/transaction_model.dart b/lib/data/models/transaction_model.dart index 5cd66a770..9a3898be8 100644 --- a/lib/data/models/transaction_model.dart +++ b/lib/data/models/transaction_model.dart @@ -139,6 +139,14 @@ abstract class TransactionEntity extends Object @BuiltValueField(wireName: 'transaction_id') int get transactionId; + @nullable + @BuiltValueField(serialize: false) + String get pendingVendorId; + + @nullable + @BuiltValueField(serialize: false) + String get pendingCategoryId; + @override EntityType get entityType => EntityType.transaction; diff --git a/lib/data/models/transaction_model.g.dart b/lib/data/models/transaction_model.g.dart index c197623e0..1aba0eff0 100644 --- a/lib/data/models/transaction_model.g.dart +++ b/lib/data/models/transaction_model.g.dart @@ -576,6 +576,10 @@ class _$TransactionEntity extends TransactionEntity { @override final int transactionId; @override + final String pendingVendorId; + @override + final String pendingCategoryId; + @override final bool isChanged; @override final int createdAt; @@ -610,6 +614,8 @@ class _$TransactionEntity extends TransactionEntity { this.expenseId, this.vendorId, this.transactionId, + this.pendingVendorId, + this.pendingCategoryId, this.isChanged, this.createdAt, this.updatedAt, @@ -678,6 +684,8 @@ class _$TransactionEntity extends TransactionEntity { expenseId == other.expenseId && vendorId == other.vendorId && transactionId == other.transactionId && + pendingVendorId == other.pendingVendorId && + pendingCategoryId == other.pendingCategoryId && isChanged == other.isChanged && createdAt == other.createdAt && updatedAt == other.updatedAt && @@ -709,18 +717,18 @@ class _$TransactionEntity extends TransactionEntity { $jc( $jc( $jc( - $jc($jc($jc(0, amount.hashCode), currencyId.hashCode), - category.hashCode), - baseType.hashCode), - date.hashCode), - bankAccountId.hashCode), - description.hashCode), - statusId.hashCode), - categoryId.hashCode), - invoiceIds.hashCode), - expenseId.hashCode), - vendorId.hashCode), - transactionId.hashCode), + $jc($jc($jc($jc($jc(0, amount.hashCode), currencyId.hashCode), category.hashCode), baseType.hashCode), + date.hashCode), + bankAccountId.hashCode), + description.hashCode), + statusId.hashCode), + categoryId.hashCode), + invoiceIds.hashCode), + expenseId.hashCode), + vendorId.hashCode), + transactionId.hashCode), + pendingVendorId.hashCode), + pendingCategoryId.hashCode), isChanged.hashCode), createdAt.hashCode), updatedAt.hashCode), @@ -747,6 +755,8 @@ class _$TransactionEntity extends TransactionEntity { ..add('expenseId', expenseId) ..add('vendorId', vendorId) ..add('transactionId', transactionId) + ..add('pendingVendorId', pendingVendorId) + ..add('pendingCategoryId', pendingCategoryId) ..add('isChanged', isChanged) ..add('createdAt', createdAt) ..add('updatedAt', updatedAt) @@ -816,6 +826,16 @@ class TransactionEntityBuilder int get transactionId => _$this._transactionId; set transactionId(int transactionId) => _$this._transactionId = transactionId; + String _pendingVendorId; + String get pendingVendorId => _$this._pendingVendorId; + set pendingVendorId(String pendingVendorId) => + _$this._pendingVendorId = pendingVendorId; + + String _pendingCategoryId; + String get pendingCategoryId => _$this._pendingCategoryId; + set pendingCategoryId(String pendingCategoryId) => + _$this._pendingCategoryId = pendingCategoryId; + bool _isChanged; bool get isChanged => _$this._isChanged; set isChanged(bool isChanged) => _$this._isChanged = isChanged; @@ -870,6 +890,8 @@ class TransactionEntityBuilder _expenseId = $v.expenseId; _vendorId = $v.vendorId; _transactionId = $v.transactionId; + _pendingVendorId = $v.pendingVendorId; + _pendingCategoryId = $v.pendingCategoryId; _isChanged = $v.isChanged; _createdAt = $v.createdAt; _updatedAt = $v.updatedAt; @@ -920,6 +942,8 @@ class TransactionEntityBuilder expenseId: BuiltValueNullFieldError.checkNotNull(expenseId, 'TransactionEntity', 'expenseId'), vendorId: BuiltValueNullFieldError.checkNotNull(vendorId, 'TransactionEntity', 'vendorId'), transactionId: BuiltValueNullFieldError.checkNotNull(transactionId, 'TransactionEntity', 'transactionId'), + pendingVendorId: pendingVendorId, + pendingCategoryId: pendingCategoryId, isChanged: isChanged, createdAt: BuiltValueNullFieldError.checkNotNull(createdAt, 'TransactionEntity', 'createdAt'), updatedAt: BuiltValueNullFieldError.checkNotNull(updatedAt, 'TransactionEntity', 'updatedAt'), diff --git a/lib/ui/transaction/view/transaction_view.dart b/lib/ui/transaction/view/transaction_view.dart index 7906a5829..6b8a52d32 100644 --- a/lib/ui/transaction/view/transaction_view.dart +++ b/lib/ui/transaction/view/transaction_view.dart @@ -484,11 +484,17 @@ class _MatchWithdrawalsState extends State<_MatchWithdrawals> { final state = widget.viewModel.state; if (transactions.isNotEmpty) { final transaction = transactions.first; - if ((transaction.categoryId ?? '').isNotEmpty) { + if ((transaction.pendingCategoryId ?? '').isNotEmpty) { + _selectedCategory = + state.expenseCategoryState.get(transaction.pendingCategoryId); + } else if ((transaction.categoryId ?? '').isNotEmpty) { _selectedCategory = state.expenseCategoryState.get(transaction.categoryId); } - if ((transaction.vendorId ?? '').isNotEmpty) { + + if ((transaction.pendingVendorId ?? '').isNotEmpty) { + _selectedVendor = state.vendorState.get(transaction.pendingVendorId); + } else if ((transaction.vendorId ?? '').isNotEmpty) { _selectedVendor = state.vendorState.get(transaction.vendorId); } } @@ -623,8 +629,8 @@ class _MatchWithdrawalsState extends State<_MatchWithdrawals> { UpdateCurrentRoute(TransactionScreen.route)); })); completer.future.then((SelectableEntity vendor) { - store.dispatch(SaveTransactionSuccess( - transaction.rebuild((b) => b..vendorId = vendor.id))); + store.dispatch(SaveTransactionSuccess(transaction + .rebuild((b) => b..pendingVendorId = vendor.id))); store.dispatch( UpdateCurrentRoute(TransactionScreen.route)); }); @@ -703,8 +709,9 @@ class _MatchWithdrawalsState extends State<_MatchWithdrawals> { UpdateCurrentRoute(TransactionScreen.route)); })); completer.future.then((SelectableEntity category) { - store.dispatch(SaveTransactionSuccess(transaction - .rebuild((b) => b..categoryId = category.id))); + store.dispatch(SaveTransactionSuccess( + transaction.rebuild( + (b) => b..pendingCategoryId = category.id))); store.dispatch( UpdateCurrentRoute(TransactionScreen.route)); });