Transaction rules

This commit is contained in:
Hillel Coren 2022-11-21 13:13:15 +02:00
parent 6e4406ba78
commit d468897c79
3 changed files with 148 additions and 6 deletions

View File

@ -64,6 +64,11 @@ abstract class TransactionRuleEntity extends Object
assignedUserId: '', assignedUserId: '',
archivedAt: 0, archivedAt: 0,
name: '', name: '',
matchesOnAll: true,
autoConvert: false,
appliesTo: TransactionEntity.TYPE_WITHDRAWL,
vendorId: '',
categoryId: '',
); );
} }
@ -73,9 +78,23 @@ abstract class TransactionRuleEntity extends Object
@memoized @memoized
int get hashCode; int get hashCode;
// STARTER: properties - do not remove comment
String get name; String get name;
@BuiltValueField(wireName: 'matches_on_all')
bool get matchesOnAll;
@BuiltValueField(wireName: 'auto_convert')
bool get autoConvert;
@BuiltValueField(wireName: 'applies_to')
String get appliesTo;
@BuiltValueField(wireName: 'vendor_id')
String get vendorId;
@BuiltValueField(wireName: 'category_id')
String get categoryId;
@override @override
EntityType get entityType => EntityType.transactionRule; EntityType get entityType => EntityType.transactionRule;

View File

@ -128,6 +128,21 @@ class _$TransactionRuleEntitySerializer
final result = <Object>[ final result = <Object>[
'name', 'name',
serializers.serialize(object.name, specifiedType: const FullType(String)), serializers.serialize(object.name, specifiedType: const FullType(String)),
'matches_on_all',
serializers.serialize(object.matchesOnAll,
specifiedType: const FullType(bool)),
'auto_convert',
serializers.serialize(object.autoConvert,
specifiedType: const FullType(bool)),
'applies_to',
serializers.serialize(object.appliesTo,
specifiedType: const FullType(String)),
'vendor_id',
serializers.serialize(object.vendorId,
specifiedType: const FullType(String)),
'category_id',
serializers.serialize(object.categoryId,
specifiedType: const FullType(String)),
'created_at', 'created_at',
serializers.serialize(object.createdAt, serializers.serialize(object.createdAt,
specifiedType: const FullType(int)), specifiedType: const FullType(int)),
@ -188,6 +203,26 @@ class _$TransactionRuleEntitySerializer
result.name = serializers.deserialize(value, result.name = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
break; break;
case 'matches_on_all':
result.matchesOnAll = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'auto_convert':
result.autoConvert = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'applies_to':
result.appliesTo = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'vendor_id':
result.vendorId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'category_id':
result.categoryId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'isChanged': case 'isChanged':
result.isChanged = serializers.deserialize(value, result.isChanged = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool; specifiedType: const FullType(bool)) as bool;
@ -423,6 +458,16 @@ class _$TransactionRuleEntity extends TransactionRuleEntity {
@override @override
final String name; final String name;
@override @override
final bool matchesOnAll;
@override
final bool autoConvert;
@override
final String appliesTo;
@override
final String vendorId;
@override
final String categoryId;
@override
final bool isChanged; final bool isChanged;
@override @override
final int createdAt; final int createdAt;
@ -445,6 +490,11 @@ class _$TransactionRuleEntity extends TransactionRuleEntity {
_$TransactionRuleEntity._( _$TransactionRuleEntity._(
{this.name, {this.name,
this.matchesOnAll,
this.autoConvert,
this.appliesTo,
this.vendorId,
this.categoryId,
this.isChanged, this.isChanged,
this.createdAt, this.createdAt,
this.updatedAt, this.updatedAt,
@ -456,6 +506,16 @@ class _$TransactionRuleEntity extends TransactionRuleEntity {
: super._() { : super._() {
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
name, 'TransactionRuleEntity', 'name'); name, 'TransactionRuleEntity', 'name');
BuiltValueNullFieldError.checkNotNull(
matchesOnAll, 'TransactionRuleEntity', 'matchesOnAll');
BuiltValueNullFieldError.checkNotNull(
autoConvert, 'TransactionRuleEntity', 'autoConvert');
BuiltValueNullFieldError.checkNotNull(
appliesTo, 'TransactionRuleEntity', 'appliesTo');
BuiltValueNullFieldError.checkNotNull(
vendorId, 'TransactionRuleEntity', 'vendorId');
BuiltValueNullFieldError.checkNotNull(
categoryId, 'TransactionRuleEntity', 'categoryId');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
createdAt, 'TransactionRuleEntity', 'createdAt'); createdAt, 'TransactionRuleEntity', 'createdAt');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
@ -479,6 +539,11 @@ class _$TransactionRuleEntity extends TransactionRuleEntity {
if (identical(other, this)) return true; if (identical(other, this)) return true;
return other is TransactionRuleEntity && return other is TransactionRuleEntity &&
name == other.name && name == other.name &&
matchesOnAll == other.matchesOnAll &&
autoConvert == other.autoConvert &&
appliesTo == other.appliesTo &&
vendorId == other.vendorId &&
categoryId == other.categoryId &&
isChanged == other.isChanged && isChanged == other.isChanged &&
createdAt == other.createdAt && createdAt == other.createdAt &&
updatedAt == other.updatedAt && updatedAt == other.updatedAt &&
@ -498,7 +563,19 @@ class _$TransactionRuleEntity extends TransactionRuleEntity {
$jc( $jc(
$jc( $jc(
$jc( $jc(
$jc($jc($jc(0, name.hashCode), isChanged.hashCode), $jc(
$jc(
$jc(
$jc(
$jc(
$jc(
$jc($jc(0, name.hashCode),
matchesOnAll.hashCode),
autoConvert.hashCode),
appliesTo.hashCode),
vendorId.hashCode),
categoryId.hashCode),
isChanged.hashCode),
createdAt.hashCode), createdAt.hashCode),
updatedAt.hashCode), updatedAt.hashCode),
archivedAt.hashCode), archivedAt.hashCode),
@ -512,6 +589,11 @@ class _$TransactionRuleEntity extends TransactionRuleEntity {
String toString() { String toString() {
return (newBuiltValueToStringHelper('TransactionRuleEntity') return (newBuiltValueToStringHelper('TransactionRuleEntity')
..add('name', name) ..add('name', name)
..add('matchesOnAll', matchesOnAll)
..add('autoConvert', autoConvert)
..add('appliesTo', appliesTo)
..add('vendorId', vendorId)
..add('categoryId', categoryId)
..add('isChanged', isChanged) ..add('isChanged', isChanged)
..add('createdAt', createdAt) ..add('createdAt', createdAt)
..add('updatedAt', updatedAt) ..add('updatedAt', updatedAt)
@ -532,6 +614,26 @@ class TransactionRuleEntityBuilder
String get name => _$this._name; String get name => _$this._name;
set name(String name) => _$this._name = name; set name(String name) => _$this._name = name;
bool _matchesOnAll;
bool get matchesOnAll => _$this._matchesOnAll;
set matchesOnAll(bool matchesOnAll) => _$this._matchesOnAll = matchesOnAll;
bool _autoConvert;
bool get autoConvert => _$this._autoConvert;
set autoConvert(bool autoConvert) => _$this._autoConvert = autoConvert;
String _appliesTo;
String get appliesTo => _$this._appliesTo;
set appliesTo(String appliesTo) => _$this._appliesTo = appliesTo;
String _vendorId;
String get vendorId => _$this._vendorId;
set vendorId(String vendorId) => _$this._vendorId = vendorId;
String _categoryId;
String get categoryId => _$this._categoryId;
set categoryId(String categoryId) => _$this._categoryId = categoryId;
bool _isChanged; bool _isChanged;
bool get isChanged => _$this._isChanged; bool get isChanged => _$this._isChanged;
set isChanged(bool isChanged) => _$this._isChanged = isChanged; set isChanged(bool isChanged) => _$this._isChanged = isChanged;
@ -572,6 +674,11 @@ class TransactionRuleEntityBuilder
final $v = _$v; final $v = _$v;
if ($v != null) { if ($v != null) {
_name = $v.name; _name = $v.name;
_matchesOnAll = $v.matchesOnAll;
_autoConvert = $v.autoConvert;
_appliesTo = $v.appliesTo;
_vendorId = $v.vendorId;
_categoryId = $v.categoryId;
_isChanged = $v.isChanged; _isChanged = $v.isChanged;
_createdAt = $v.createdAt; _createdAt = $v.createdAt;
_updatedAt = $v.updatedAt; _updatedAt = $v.updatedAt;
@ -602,18 +709,26 @@ class TransactionRuleEntityBuilder
new _$TransactionRuleEntity._( new _$TransactionRuleEntity._(
name: BuiltValueNullFieldError.checkNotNull( name: BuiltValueNullFieldError.checkNotNull(
name, 'TransactionRuleEntity', 'name'), name, 'TransactionRuleEntity', 'name'),
matchesOnAll: BuiltValueNullFieldError.checkNotNull(
matchesOnAll, 'TransactionRuleEntity', 'matchesOnAll'),
autoConvert: BuiltValueNullFieldError.checkNotNull(
autoConvert, 'TransactionRuleEntity', 'autoConvert'),
appliesTo: BuiltValueNullFieldError.checkNotNull(
appliesTo, 'TransactionRuleEntity', 'appliesTo'),
vendorId: BuiltValueNullFieldError.checkNotNull(
vendorId, 'TransactionRuleEntity', 'vendorId'),
categoryId: BuiltValueNullFieldError.checkNotNull(
categoryId, 'TransactionRuleEntity', 'categoryId'),
isChanged: isChanged, isChanged: isChanged,
createdAt: BuiltValueNullFieldError.checkNotNull( createdAt: BuiltValueNullFieldError.checkNotNull(
createdAt, 'TransactionRuleEntity', 'createdAt'), createdAt, 'TransactionRuleEntity', 'createdAt'),
updatedAt: BuiltValueNullFieldError.checkNotNull( updatedAt: BuiltValueNullFieldError.checkNotNull(
updatedAt, 'TransactionRuleEntity', 'updatedAt'), updatedAt, 'TransactionRuleEntity', 'updatedAt'),
archivedAt: BuiltValueNullFieldError.checkNotNull( archivedAt: BuiltValueNullFieldError.checkNotNull(archivedAt, 'TransactionRuleEntity', 'archivedAt'),
archivedAt, 'TransactionRuleEntity', 'archivedAt'),
isDeleted: isDeleted, isDeleted: isDeleted,
createdUserId: createdUserId, createdUserId: createdUserId,
assignedUserId: assignedUserId, assignedUserId: assignedUserId,
id: BuiltValueNullFieldError.checkNotNull( id: BuiltValueNullFieldError.checkNotNull(id, 'TransactionRuleEntity', 'id'));
id, 'TransactionRuleEntity', 'id'));
replace(_$result); replace(_$result);
return _$result; return _$result;
} }

View File

@ -1,5 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:invoiceninja_flutter/data/models/entities.dart';
import 'package:invoiceninja_flutter/ui/app/edit_scaffold.dart'; import 'package:invoiceninja_flutter/ui/app/edit_scaffold.dart';
import 'package:invoiceninja_flutter/ui/app/entity_dropdown.dart';
import 'package:invoiceninja_flutter/ui/app/form_card.dart'; import 'package:invoiceninja_flutter/ui/app/form_card.dart';
import 'package:invoiceninja_flutter/ui/app/forms/decorated_form_field.dart'; import 'package:invoiceninja_flutter/ui/app/forms/decorated_form_field.dart';
import 'package:invoiceninja_flutter/ui/transaction_rule/edit/transaction_rule_edit_vm.dart'; import 'package:invoiceninja_flutter/ui/transaction_rule/edit/transaction_rule_edit_vm.dart';
@ -99,6 +101,12 @@ class _TransactionRuleEditState extends State<TransactionRuleEdit> {
controller: _nameController, controller: _nameController,
onSavePressed: (context) => _onSubmitted(), onSavePressed: (context) => _onSubmitted(),
), ),
EntityDropdown(
entityType: EntityType.vendor,
labelText: localization.vendor,
onSelected: (vendor) {
//viewModel.onChanged(transactionRule.rebuild((b) => b..))
})
], ],
), ),
], ],