Client ledger
This commit is contained in:
parent
b46eabfb58
commit
f86ea1c29a
|
|
@ -122,6 +122,7 @@ abstract class ClientEntity extends Object
|
|||
<ContactEntity>[ContactEntity().rebuild((b) => b..isPrimary = true)],
|
||||
),
|
||||
activities: BuiltList<ActivityEntity>(),
|
||||
ledger: BuiltList<LedgerEntity>(),
|
||||
gatewayTokens: BuiltList<GatewayTokenEntity>(),
|
||||
lastUpdatedActivities: 0,
|
||||
updatedAt: 0,
|
||||
|
|
@ -253,6 +254,8 @@ abstract class ClientEntity extends Object
|
|||
|
||||
BuiltList<ActivityEntity> get activities;
|
||||
|
||||
BuiltList<LedgerEntity> get ledger;
|
||||
|
||||
@BuiltValueField(wireName: 'gateway_tokens')
|
||||
BuiltList<GatewayTokenEntity> get gatewayTokens;
|
||||
|
||||
|
|
|
|||
|
|
@ -211,6 +211,10 @@ class _$ClientEntitySerializer implements StructuredSerializer<ClientEntity> {
|
|||
serializers.serialize(object.activities,
|
||||
specifiedType: const FullType(
|
||||
BuiltList, const [const FullType(ActivityEntity)])),
|
||||
'ledger',
|
||||
serializers.serialize(object.ledger,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(LedgerEntity)])),
|
||||
'gateway_tokens',
|
||||
serializers.serialize(object.gatewayTokens,
|
||||
specifiedType: const FullType(
|
||||
|
|
@ -420,6 +424,12 @@ class _$ClientEntitySerializer implements StructuredSerializer<ClientEntity> {
|
|||
BuiltList, const [const FullType(ActivityEntity)]))
|
||||
as BuiltList<Object>);
|
||||
break;
|
||||
case 'ledger':
|
||||
result.ledger.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(
|
||||
BuiltList, const [const FullType(LedgerEntity)]))
|
||||
as BuiltList<Object>);
|
||||
break;
|
||||
case 'gateway_tokens':
|
||||
result.gatewayTokens.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(
|
||||
|
|
@ -929,6 +939,8 @@ class _$ClientEntity extends ClientEntity {
|
|||
@override
|
||||
final BuiltList<ActivityEntity> activities;
|
||||
@override
|
||||
final BuiltList<LedgerEntity> ledger;
|
||||
@override
|
||||
final BuiltList<GatewayTokenEntity> gatewayTokens;
|
||||
@override
|
||||
final bool isChanged;
|
||||
|
|
@ -985,6 +997,7 @@ class _$ClientEntity extends ClientEntity {
|
|||
this.customValue4,
|
||||
this.contacts,
|
||||
this.activities,
|
||||
this.ledger,
|
||||
this.gatewayTokens,
|
||||
this.isChanged,
|
||||
this.createdAt,
|
||||
|
|
@ -1094,6 +1107,9 @@ class _$ClientEntity extends ClientEntity {
|
|||
if (activities == null) {
|
||||
throw new BuiltValueNullFieldError('ClientEntity', 'activities');
|
||||
}
|
||||
if (ledger == null) {
|
||||
throw new BuiltValueNullFieldError('ClientEntity', 'ledger');
|
||||
}
|
||||
if (gatewayTokens == null) {
|
||||
throw new BuiltValueNullFieldError('ClientEntity', 'gatewayTokens');
|
||||
}
|
||||
|
|
@ -1147,6 +1163,7 @@ class _$ClientEntity extends ClientEntity {
|
|||
customValue4 == other.customValue4 &&
|
||||
contacts == other.contacts &&
|
||||
activities == other.activities &&
|
||||
ledger == other.ledger &&
|
||||
gatewayTokens == other.gatewayTokens &&
|
||||
isChanged == other.isChanged &&
|
||||
createdAt == other.createdAt &&
|
||||
|
|
@ -1179,17 +1196,17 @@ class _$ClientEntity extends ClientEntity {
|
|||
$jc(
|
||||
$jc(
|
||||
$jc(
|
||||
$jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc(0, groupId.hashCode), lastUpdatedActivities.hashCode), name.hashCode), displayName.hashCode), balance.hashCode), creditBalance.hashCode), paidToDate.hashCode), address1.hashCode), address2.hashCode), city.hashCode), state.hashCode), postalCode.hashCode), countryId.hashCode), phone.hashCode), privateNotes.hashCode), publicNotes.hashCode), website.hashCode), industryId.hashCode), sizeId.hashCode), vatNumber.hashCode), idNumber.hashCode), shippingAddress1.hashCode), shippingAddress2.hashCode), shippingCity.hashCode),
|
||||
shippingState.hashCode),
|
||||
shippingPostalCode.hashCode),
|
||||
shippingCountryId.hashCode),
|
||||
settings.hashCode),
|
||||
customValue1.hashCode),
|
||||
customValue2.hashCode),
|
||||
customValue3.hashCode),
|
||||
customValue4.hashCode),
|
||||
contacts.hashCode),
|
||||
activities.hashCode),
|
||||
$jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc(0, groupId.hashCode), lastUpdatedActivities.hashCode), name.hashCode), displayName.hashCode), balance.hashCode), creditBalance.hashCode), paidToDate.hashCode), address1.hashCode), address2.hashCode), city.hashCode), state.hashCode), postalCode.hashCode), countryId.hashCode), phone.hashCode), privateNotes.hashCode), publicNotes.hashCode), website.hashCode), industryId.hashCode), sizeId.hashCode), vatNumber.hashCode), idNumber.hashCode), shippingAddress1.hashCode), shippingAddress2.hashCode), shippingCity.hashCode), shippingState.hashCode),
|
||||
shippingPostalCode.hashCode),
|
||||
shippingCountryId.hashCode),
|
||||
settings.hashCode),
|
||||
customValue1.hashCode),
|
||||
customValue2.hashCode),
|
||||
customValue3.hashCode),
|
||||
customValue4.hashCode),
|
||||
contacts.hashCode),
|
||||
activities.hashCode),
|
||||
ledger.hashCode),
|
||||
gatewayTokens.hashCode),
|
||||
isChanged.hashCode),
|
||||
createdAt.hashCode),
|
||||
|
|
@ -1238,6 +1255,7 @@ class _$ClientEntity extends ClientEntity {
|
|||
..add('customValue4', customValue4)
|
||||
..add('contacts', contacts)
|
||||
..add('activities', activities)
|
||||
..add('ledger', ledger)
|
||||
..add('gatewayTokens', gatewayTokens)
|
||||
..add('isChanged', isChanged)
|
||||
..add('createdAt', createdAt)
|
||||
|
|
@ -1403,6 +1421,11 @@ class ClientEntityBuilder
|
|||
set activities(ListBuilder<ActivityEntity> activities) =>
|
||||
_$this._activities = activities;
|
||||
|
||||
ListBuilder<LedgerEntity> _ledger;
|
||||
ListBuilder<LedgerEntity> get ledger =>
|
||||
_$this._ledger ??= new ListBuilder<LedgerEntity>();
|
||||
set ledger(ListBuilder<LedgerEntity> ledger) => _$this._ledger = ledger;
|
||||
|
||||
ListBuilder<GatewayTokenEntity> _gatewayTokens;
|
||||
ListBuilder<GatewayTokenEntity> get gatewayTokens =>
|
||||
_$this._gatewayTokens ??= new ListBuilder<GatewayTokenEntity>();
|
||||
|
|
@ -1481,6 +1504,7 @@ class ClientEntityBuilder
|
|||
_customValue4 = _$v.customValue4;
|
||||
_contacts = _$v.contacts?.toBuilder();
|
||||
_activities = _$v.activities?.toBuilder();
|
||||
_ledger = _$v.ledger?.toBuilder();
|
||||
_gatewayTokens = _$v.gatewayTokens?.toBuilder();
|
||||
_isChanged = _$v.isChanged;
|
||||
_createdAt = _$v.createdAt;
|
||||
|
|
@ -1548,6 +1572,7 @@ class ClientEntityBuilder
|
|||
customValue4: customValue4,
|
||||
contacts: contacts.build(),
|
||||
activities: activities.build(),
|
||||
ledger: ledger.build(),
|
||||
gatewayTokens: gatewayTokens.build(),
|
||||
isChanged: isChanged,
|
||||
createdAt: createdAt,
|
||||
|
|
@ -1567,6 +1592,8 @@ class ClientEntityBuilder
|
|||
contacts.build();
|
||||
_$failedField = 'activities';
|
||||
activities.build();
|
||||
_$failedField = 'ledger';
|
||||
ledger.build();
|
||||
_$failedField = 'gatewayTokens';
|
||||
gatewayTokens.build();
|
||||
} catch (e) {
|
||||
|
|
|
|||
|
|
@ -588,3 +588,34 @@ abstract class ActivityEntity
|
|||
static Serializer<ActivityEntity> get serializer =>
|
||||
_$activityEntitySerializer;
|
||||
}
|
||||
|
||||
abstract class LedgerEntity
|
||||
implements Built<LedgerEntity, LedgerEntityBuilder> {
|
||||
factory LedgerEntity([void updates(LedgerEntityBuilder b)]) = _$LedgerEntity;
|
||||
|
||||
LedgerEntity._();
|
||||
|
||||
@override
|
||||
@memoized
|
||||
int get hashCode;
|
||||
|
||||
String get notes;
|
||||
|
||||
double get balance;
|
||||
|
||||
double get adjustment;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'invoice_id')
|
||||
String get invoiceId;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'credit_id')
|
||||
String get creditId;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'payment_id')
|
||||
String get paymentId;
|
||||
|
||||
static Serializer<LedgerEntity> get serializer => _$ledgerEntitySerializer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -296,6 +296,8 @@ Serializer<LoginResponse> _$loginResponseSerializer =
|
|||
new _$LoginResponseSerializer();
|
||||
Serializer<ActivityEntity> _$activityEntitySerializer =
|
||||
new _$ActivityEntitySerializer();
|
||||
Serializer<LedgerEntity> _$ledgerEntitySerializer =
|
||||
new _$LedgerEntitySerializer();
|
||||
|
||||
class _$EntityTypeSerializer implements PrimitiveSerializer<EntityType> {
|
||||
@override
|
||||
|
|
@ -626,6 +628,89 @@ class _$ActivityEntitySerializer
|
|||
}
|
||||
}
|
||||
|
||||
class _$LedgerEntitySerializer implements StructuredSerializer<LedgerEntity> {
|
||||
@override
|
||||
final Iterable<Type> types = const [LedgerEntity, _$LedgerEntity];
|
||||
@override
|
||||
final String wireName = 'LedgerEntity';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(Serializers serializers, LedgerEntity object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[
|
||||
'notes',
|
||||
serializers.serialize(object.notes,
|
||||
specifiedType: const FullType(String)),
|
||||
'balance',
|
||||
serializers.serialize(object.balance,
|
||||
specifiedType: const FullType(double)),
|
||||
'adjustment',
|
||||
serializers.serialize(object.adjustment,
|
||||
specifiedType: const FullType(double)),
|
||||
];
|
||||
if (object.invoiceId != null) {
|
||||
result
|
||||
..add('invoice_id')
|
||||
..add(serializers.serialize(object.invoiceId,
|
||||
specifiedType: const FullType(String)));
|
||||
}
|
||||
if (object.creditId != null) {
|
||||
result
|
||||
..add('credit_id')
|
||||
..add(serializers.serialize(object.creditId,
|
||||
specifiedType: const FullType(String)));
|
||||
}
|
||||
if (object.paymentId != null) {
|
||||
result
|
||||
..add('payment_id')
|
||||
..add(serializers.serialize(object.paymentId,
|
||||
specifiedType: const FullType(String)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
LedgerEntity deserialize(Serializers serializers, Iterable<Object> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = new LedgerEntityBuilder();
|
||||
|
||||
final iterator = serialized.iterator;
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final dynamic value = iterator.current;
|
||||
switch (key) {
|
||||
case 'notes':
|
||||
result.notes = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
case 'balance':
|
||||
result.balance = serializers.deserialize(value,
|
||||
specifiedType: const FullType(double)) as double;
|
||||
break;
|
||||
case 'adjustment':
|
||||
result.adjustment = serializers.deserialize(value,
|
||||
specifiedType: const FullType(double)) as double;
|
||||
break;
|
||||
case 'invoice_id':
|
||||
result.invoiceId = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
case 'credit_id':
|
||||
result.creditId = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
case 'payment_id':
|
||||
result.paymentId = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result.build();
|
||||
}
|
||||
}
|
||||
|
||||
class _$ErrorMessage extends ErrorMessage {
|
||||
@override
|
||||
final String message;
|
||||
|
|
@ -1100,4 +1185,156 @@ class ActivityEntityBuilder
|
|||
}
|
||||
}
|
||||
|
||||
class _$LedgerEntity extends LedgerEntity {
|
||||
@override
|
||||
final String notes;
|
||||
@override
|
||||
final double balance;
|
||||
@override
|
||||
final double adjustment;
|
||||
@override
|
||||
final String invoiceId;
|
||||
@override
|
||||
final String creditId;
|
||||
@override
|
||||
final String paymentId;
|
||||
|
||||
factory _$LedgerEntity([void Function(LedgerEntityBuilder) updates]) =>
|
||||
(new LedgerEntityBuilder()..update(updates)).build();
|
||||
|
||||
_$LedgerEntity._(
|
||||
{this.notes,
|
||||
this.balance,
|
||||
this.adjustment,
|
||||
this.invoiceId,
|
||||
this.creditId,
|
||||
this.paymentId})
|
||||
: super._() {
|
||||
if (notes == null) {
|
||||
throw new BuiltValueNullFieldError('LedgerEntity', 'notes');
|
||||
}
|
||||
if (balance == null) {
|
||||
throw new BuiltValueNullFieldError('LedgerEntity', 'balance');
|
||||
}
|
||||
if (adjustment == null) {
|
||||
throw new BuiltValueNullFieldError('LedgerEntity', 'adjustment');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
LedgerEntity rebuild(void Function(LedgerEntityBuilder) updates) =>
|
||||
(toBuilder()..update(updates)).build();
|
||||
|
||||
@override
|
||||
LedgerEntityBuilder toBuilder() => new LedgerEntityBuilder()..replace(this);
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(other, this)) return true;
|
||||
return other is LedgerEntity &&
|
||||
notes == other.notes &&
|
||||
balance == other.balance &&
|
||||
adjustment == other.adjustment &&
|
||||
invoiceId == other.invoiceId &&
|
||||
creditId == other.creditId &&
|
||||
paymentId == other.paymentId;
|
||||
}
|
||||
|
||||
int __hashCode;
|
||||
@override
|
||||
int get hashCode {
|
||||
return __hashCode ??= $jf($jc(
|
||||
$jc(
|
||||
$jc(
|
||||
$jc($jc($jc(0, notes.hashCode), balance.hashCode),
|
||||
adjustment.hashCode),
|
||||
invoiceId.hashCode),
|
||||
creditId.hashCode),
|
||||
paymentId.hashCode));
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (newBuiltValueToStringHelper('LedgerEntity')
|
||||
..add('notes', notes)
|
||||
..add('balance', balance)
|
||||
..add('adjustment', adjustment)
|
||||
..add('invoiceId', invoiceId)
|
||||
..add('creditId', creditId)
|
||||
..add('paymentId', paymentId))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class LedgerEntityBuilder
|
||||
implements Builder<LedgerEntity, LedgerEntityBuilder> {
|
||||
_$LedgerEntity _$v;
|
||||
|
||||
String _notes;
|
||||
String get notes => _$this._notes;
|
||||
set notes(String notes) => _$this._notes = notes;
|
||||
|
||||
double _balance;
|
||||
double get balance => _$this._balance;
|
||||
set balance(double balance) => _$this._balance = balance;
|
||||
|
||||
double _adjustment;
|
||||
double get adjustment => _$this._adjustment;
|
||||
set adjustment(double adjustment) => _$this._adjustment = adjustment;
|
||||
|
||||
String _invoiceId;
|
||||
String get invoiceId => _$this._invoiceId;
|
||||
set invoiceId(String invoiceId) => _$this._invoiceId = invoiceId;
|
||||
|
||||
String _creditId;
|
||||
String get creditId => _$this._creditId;
|
||||
set creditId(String creditId) => _$this._creditId = creditId;
|
||||
|
||||
String _paymentId;
|
||||
String get paymentId => _$this._paymentId;
|
||||
set paymentId(String paymentId) => _$this._paymentId = paymentId;
|
||||
|
||||
LedgerEntityBuilder();
|
||||
|
||||
LedgerEntityBuilder get _$this {
|
||||
if (_$v != null) {
|
||||
_notes = _$v.notes;
|
||||
_balance = _$v.balance;
|
||||
_adjustment = _$v.adjustment;
|
||||
_invoiceId = _$v.invoiceId;
|
||||
_creditId = _$v.creditId;
|
||||
_paymentId = _$v.paymentId;
|
||||
_$v = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@override
|
||||
void replace(LedgerEntity other) {
|
||||
if (other == null) {
|
||||
throw new ArgumentError.notNull('other');
|
||||
}
|
||||
_$v = other as _$LedgerEntity;
|
||||
}
|
||||
|
||||
@override
|
||||
void update(void Function(LedgerEntityBuilder) updates) {
|
||||
if (updates != null) updates(this);
|
||||
}
|
||||
|
||||
@override
|
||||
_$LedgerEntity build() {
|
||||
final _$result = _$v ??
|
||||
new _$LedgerEntity._(
|
||||
notes: notes,
|
||||
balance: balance,
|
||||
adjustment: adjustment,
|
||||
invoiceId: invoiceId,
|
||||
creditId: creditId,
|
||||
paymentId: paymentId);
|
||||
replace(_$result);
|
||||
return _$result;
|
||||
}
|
||||
}
|
||||
|
||||
// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,lines_longer_than_80_chars,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ Serializers _$serializers = (new Serializers().toBuilder()
|
|||
..add(LanguageEntity.serializer)
|
||||
..add(LanguageItemResponse.serializer)
|
||||
..add(LanguageListResponse.serializer)
|
||||
..add(LedgerEntity.serializer)
|
||||
..add(ListUIState.serializer)
|
||||
..add(LoginResponse.serializer)
|
||||
..add(ModuleLayout.serializer)
|
||||
|
|
@ -180,6 +181,9 @@ Serializers _$serializers = (new Serializers().toBuilder()
|
|||
..addBuilderFactory(
|
||||
const FullType(BuiltList, const [const FullType(ActivityEntity)]),
|
||||
() => new ListBuilder<ActivityEntity>())
|
||||
..addBuilderFactory(
|
||||
const FullType(BuiltList, const [const FullType(LedgerEntity)]),
|
||||
() => new ListBuilder<LedgerEntity>())
|
||||
..addBuilderFactory(
|
||||
const FullType(BuiltList, const [const FullType(GatewayTokenEntity)]),
|
||||
() => new ListBuilder<GatewayTokenEntity>())
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class ClientRepository {
|
|||
Future<ClientEntity> loadItem(
|
||||
Credentials credentials, String entityId) async {
|
||||
final String url =
|
||||
'${credentials.url}/clients/$entityId?include=gateway_tokens,activities';
|
||||
'${credentials.url}/clients/$entityId?include=gateway_tokens,activities,ledger';
|
||||
|
||||
final dynamic response = await webClient.get(url, credentials.token);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue