Bank transactions

This commit is contained in:
Hillel Coren 2022-11-08 20:05:02 +02:00
parent 483d4a3055
commit a23799776b
5 changed files with 66 additions and 16 deletions

View File

@ -71,6 +71,7 @@ abstract class BankAccountEntity extends Object
balance: 0, balance: 0,
currency: '', currency: '',
disabledUpstream: false, disabledUpstream: false,
autoSync: false,
); );
} }
@ -92,6 +93,9 @@ abstract class BankAccountEntity extends Object
@BuiltValueField(wireName: 'provider_name') @BuiltValueField(wireName: 'provider_name')
String get provider; String get provider;
@BuiltValueField(wireName: 'auto_sync')
bool get autoSync;
@BuiltValueField(wireName: 'disabled_upstream') @BuiltValueField(wireName: 'disabled_upstream')
bool get disabledUpstream; bool get disabledUpstream;
@ -107,6 +111,8 @@ abstract class BankAccountEntity extends Object
return name; return name;
} }
bool get isConnected => type.isNotEmpty;
@override @override
List<EntityAction> getActions( List<EntityAction> getActions(
{UserCompanyEntity userCompany, {UserCompanyEntity userCompany,
@ -190,8 +196,9 @@ abstract class BankAccountEntity extends Object
FormatNumberType get listDisplayAmountType => FormatNumberType.money; FormatNumberType get listDisplayAmountType => FormatNumberType.money;
// ignore: unused_element // ignore: unused_element
static void _initializeBuilder(BankAccountEntityBuilder builder) => static void _initializeBuilder(BankAccountEntityBuilder builder) => builder
builder..disabledUpstream = false; ..disabledUpstream = false
..autoSync = false;
static Serializer<BankAccountEntity> get serializer => static Serializer<BankAccountEntity> get serializer =>
_$bankAccountEntitySerializer; _$bankAccountEntitySerializer;

View File

@ -130,6 +130,9 @@ class _$BankAccountEntitySerializer
'provider_name', 'provider_name',
serializers.serialize(object.provider, serializers.serialize(object.provider,
specifiedType: const FullType(String)), specifiedType: const FullType(String)),
'auto_sync',
serializers.serialize(object.autoSync,
specifiedType: const FullType(bool)),
'disabled_upstream', 'disabled_upstream',
serializers.serialize(object.disabledUpstream, serializers.serialize(object.disabledUpstream,
specifiedType: const FullType(bool)), specifiedType: const FullType(bool)),
@ -211,6 +214,10 @@ class _$BankAccountEntitySerializer
result.provider = serializers.deserialize(value, result.provider = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
break; break;
case 'auto_sync':
result.autoSync = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'disabled_upstream': case 'disabled_upstream':
result.disabledUpstream = serializers.deserialize(value, result.disabledUpstream = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool; specifiedType: const FullType(bool)) as bool;
@ -462,6 +469,8 @@ class _$BankAccountEntity extends BankAccountEntity {
@override @override
final String provider; final String provider;
@override @override
final bool autoSync;
@override
final bool disabledUpstream; final bool disabledUpstream;
@override @override
final double balance; final double balance;
@ -493,6 +502,7 @@ class _$BankAccountEntity extends BankAccountEntity {
this.status, this.status,
this.type, this.type,
this.provider, this.provider,
this.autoSync,
this.disabledUpstream, this.disabledUpstream,
this.balance, this.balance,
this.currency, this.currency,
@ -511,6 +521,8 @@ class _$BankAccountEntity extends BankAccountEntity {
BuiltValueNullFieldError.checkNotNull(type, 'BankAccountEntity', 'type'); BuiltValueNullFieldError.checkNotNull(type, 'BankAccountEntity', 'type');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
provider, 'BankAccountEntity', 'provider'); provider, 'BankAccountEntity', 'provider');
BuiltValueNullFieldError.checkNotNull(
autoSync, 'BankAccountEntity', 'autoSync');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
disabledUpstream, 'BankAccountEntity', 'disabledUpstream'); disabledUpstream, 'BankAccountEntity', 'disabledUpstream');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
@ -542,6 +554,7 @@ class _$BankAccountEntity extends BankAccountEntity {
status == other.status && status == other.status &&
type == other.type && type == other.type &&
provider == other.provider && provider == other.provider &&
autoSync == other.autoSync &&
disabledUpstream == other.disabledUpstream && disabledUpstream == other.disabledUpstream &&
balance == other.balance && balance == other.balance &&
currency == other.currency && currency == other.currency &&
@ -572,11 +585,16 @@ class _$BankAccountEntity extends BankAccountEntity {
$jc( $jc(
$jc( $jc(
$jc( $jc(
$jc(0, $jc(
name.hashCode), $jc(
status.hashCode), 0,
type.hashCode), name
provider.hashCode), .hashCode),
status
.hashCode),
type.hashCode),
provider.hashCode),
autoSync.hashCode),
disabledUpstream.hashCode), disabledUpstream.hashCode),
balance.hashCode), balance.hashCode),
currency.hashCode), currency.hashCode),
@ -597,6 +615,7 @@ class _$BankAccountEntity extends BankAccountEntity {
..add('status', status) ..add('status', status)
..add('type', type) ..add('type', type)
..add('provider', provider) ..add('provider', provider)
..add('autoSync', autoSync)
..add('disabledUpstream', disabledUpstream) ..add('disabledUpstream', disabledUpstream)
..add('balance', balance) ..add('balance', balance)
..add('currency', currency) ..add('currency', currency)
@ -632,6 +651,10 @@ class BankAccountEntityBuilder
String get provider => _$this._provider; String get provider => _$this._provider;
set provider(String provider) => _$this._provider = provider; set provider(String provider) => _$this._provider = provider;
bool _autoSync;
bool get autoSync => _$this._autoSync;
set autoSync(bool autoSync) => _$this._autoSync = autoSync;
bool _disabledUpstream; bool _disabledUpstream;
bool get disabledUpstream => _$this._disabledUpstream; bool get disabledUpstream => _$this._disabledUpstream;
set disabledUpstream(bool disabledUpstream) => set disabledUpstream(bool disabledUpstream) =>
@ -690,6 +713,7 @@ class BankAccountEntityBuilder
_status = $v.status; _status = $v.status;
_type = $v.type; _type = $v.type;
_provider = $v.provider; _provider = $v.provider;
_autoSync = $v.autoSync;
_disabledUpstream = $v.disabledUpstream; _disabledUpstream = $v.disabledUpstream;
_balance = $v.balance; _balance = $v.balance;
_currency = $v.currency; _currency = $v.currency;
@ -729,6 +753,8 @@ class BankAccountEntityBuilder
type, 'BankAccountEntity', 'type'), type, 'BankAccountEntity', 'type'),
provider: BuiltValueNullFieldError.checkNotNull( provider: BuiltValueNullFieldError.checkNotNull(
provider, 'BankAccountEntity', 'provider'), provider, 'BankAccountEntity', 'provider'),
autoSync: BuiltValueNullFieldError.checkNotNull(
autoSync, 'BankAccountEntity', 'autoSync'),
disabledUpstream: BuiltValueNullFieldError.checkNotNull( disabledUpstream: BuiltValueNullFieldError.checkNotNull(
disabledUpstream, 'BankAccountEntity', 'disabledUpstream'), disabledUpstream, 'BankAccountEntity', 'disabledUpstream'),
balance: BuiltValueNullFieldError.checkNotNull( balance: BuiltValueNullFieldError.checkNotNull(
@ -738,10 +764,9 @@ class BankAccountEntityBuilder
isChanged: isChanged, isChanged: isChanged,
createdAt: BuiltValueNullFieldError.checkNotNull( createdAt: BuiltValueNullFieldError.checkNotNull(
createdAt, 'BankAccountEntity', 'createdAt'), createdAt, 'BankAccountEntity', 'createdAt'),
updatedAt: BuiltValueNullFieldError.checkNotNull( updatedAt:
updatedAt, 'BankAccountEntity', 'updatedAt'), BuiltValueNullFieldError.checkNotNull(updatedAt, 'BankAccountEntity', 'updatedAt'),
archivedAt: archivedAt: BuiltValueNullFieldError.checkNotNull(archivedAt, 'BankAccountEntity', 'archivedAt'),
BuiltValueNullFieldError.checkNotNull(archivedAt, 'BankAccountEntity', 'archivedAt'),
isDeleted: isDeleted, isDeleted: isDeleted,
createdUserId: createdUserId, createdUserId: createdUserId,
assignedUserId: assignedUserId, assignedUserId: assignedUserId,

View File

@ -115,6 +115,14 @@ class _BankAccountEditState extends State<BankAccountEdit> {
onSavePressed: (_) => _onSavePressed(), onSavePressed: (_) => _onSavePressed(),
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
), ),
SizedBox(height: 16),
SwitchListTile(
activeColor: Theme.of(context).colorScheme.secondary,
title: Text(localization.autoSync),
value: bankAccount.autoSync,
onChanged: (value) => viewModel.onChanged(
bankAccount.rebuild((b) => b..autoSync = value)),
),
], ],
), ),
], ],

View File

@ -39,11 +39,12 @@ class _BankAccountViewState extends State<BankAccountView> {
entity: bankAccount, entity: bankAccount,
body: ScrollableListView( body: ScrollableListView(
children: <Widget>[ children: <Widget>[
EntityHeader( if (bankAccount.isConnected)
entity: bankAccount, EntityHeader(
label: localization.balance, entity: bankAccount,
value: formatNumber(bankAccount.balance, context), label: localization.balance,
), value: formatNumber(bankAccount.balance, context),
),
ListDivider(), ListDivider(),
EntitiesListTile( EntitiesListTile(
entity: bankAccount, entity: bankAccount,
@ -58,6 +59,10 @@ class _BankAccountViewState extends State<BankAccountView> {
localization.type: toTitleCase(bankAccount.type), localization.type: toTitleCase(bankAccount.type),
localization.status: toTitleCase(bankAccount.status), localization.status: toTitleCase(bankAccount.status),
localization.provider: toTitleCase(bankAccount.provider), localization.provider: toTitleCase(bankAccount.provider),
if (bankAccount.isConnected)
localization.autoSync: bankAccount.autoSync
? localization.enabled
: localization.disabled,
}), }),
], ],
), ),

View File

@ -16,6 +16,7 @@ mixin LocalizationsProvider on LocaleCodeAware {
static final Map<String, Map<String, String>> _localizedValues = { static final Map<String, Map<String, String>> _localizedValues = {
'en': { 'en': {
// STARTER: lang key - do not remove comment // STARTER: lang key - do not remove comment
'auto_sync': 'Auto Sync',
'refresh_accounts': 'Refresh Accounts', 'refresh_accounts': 'Refresh Accounts',
'upgrade_to_connect_bank_account': 'upgrade_to_connect_bank_account':
'Upgrade to Enterprise to connect your bank account', 'Upgrade to Enterprise to connect your bank account',
@ -90147,6 +90148,10 @@ mixin LocalizationsProvider on LocaleCodeAware {
_localizedValues[localeCode]['refresh_accounts'] ?? _localizedValues[localeCode]['refresh_accounts'] ??
_localizedValues['en']['refresh_accounts']; _localizedValues['en']['refresh_accounts'];
String get autoSync =>
_localizedValues[localeCode]['auto_sync'] ??
_localizedValues['en']['auto_sync'];
// STARTER: lang field - do not remove comment // STARTER: lang field - do not remove comment
String lookup(String key) { String lookup(String key) {