Add vendor contact id to activities

This commit is contained in:
Hillel Coren 2022-10-18 16:04:03 +03:00
parent 77088182c3
commit a15c929529
2 changed files with 72 additions and 22 deletions

View File

@ -719,6 +719,10 @@ abstract class ActivityEntity
@BuiltValueField(wireName: 'vendor_id') @BuiltValueField(wireName: 'vendor_id')
String get vendorId; String get vendorId;
@nullable
@BuiltValueField(wireName: 'vendor_contact_id')
String get vendorContactId;
@nullable @nullable
@BuiltValueField(wireName: 'token_id') @BuiltValueField(wireName: 'token_id')
String get tokenId; String get tokenId;
@ -875,9 +879,11 @@ abstract class ActivityEntity
ExpenseEntity recurringExpense, ExpenseEntity recurringExpense,
InvoiceEntity purchaseOrder, InvoiceEntity purchaseOrder,
}) { }) {
ClientContactEntity contact; ClientContactEntity clientContact;
VendorContactEntity vendorContact;
if (client != null && contactId != null && contactId.isNotEmpty) { if (client != null && contactId != null && contactId.isNotEmpty) {
contact = client.getContact(contactId); vendorContact = vendor.getContact(vendorContactId);
clientContact = client.getContact(contactId);
} }
activity = activity =
@ -889,8 +895,26 @@ abstract class ActivityEntity
activity = activity.replaceFirst( activity = activity.replaceFirst(
':recurring_expense', recurringExpense?.number ?? ''); ':recurring_expense', recurringExpense?.number ?? '');
activity = activity.replaceFirst(':quote', quote?.number ?? ''); activity = activity.replaceFirst(':quote', quote?.number ?? '');
activity = activity.replaceFirst(':contact', if ([
contact?.fullName ?? client?.displayName ?? user?.fullName ?? ''); kActivityViewPurchaseOrder,
kActivityAcceptPurchaseOrder,
].contains(activityTypeId)) {
activity = activity.replaceFirst(
':contact',
(vendorContact?.fullName ?? '').isNotEmpty
? vendorContact.fullName
: (vendor?.name ?? '').isNotEmpty
? vendor.name
: user?.fullName ?? '');
} else {
activity = activity.replaceFirst(
':contact',
(clientContact?.fullName ?? '').isNotEmpty
? clientContact.fullName
: (client?.displayName ?? '').isNotEmpty
? client.displayName
: user?.fullName ?? '');
}
activity = activity.replaceFirst( activity = activity.replaceFirst(
':payment', payment?.transactionReferenceOrNumber ?? ''); ':payment', payment?.transactionReferenceOrNumber ?? '');
activity = activity.replaceFirst(':credit', credit?.number ?? ''); activity = activity.replaceFirst(':credit', credit?.number ?? '');
@ -903,6 +927,9 @@ abstract class ActivityEntity
':recurring_expense', vendor?.name ?? ''); // TODO implement ':recurring_expense', vendor?.name ?? ''); // TODO implement
activity = activity.replaceAll(' ', ' '); activity = activity.replaceAll(' ', ' ');
print('## Activityy: IS $activity');
print('##');
return activity; return activity;
} }

View File

@ -628,6 +628,13 @@ class _$ActivityEntitySerializer
..add(serializers.serialize(value, ..add(serializers.serialize(value,
specifiedType: const FullType(String))); specifiedType: const FullType(String)));
} }
value = object.vendorContactId;
if (value != null) {
result
..add('vendor_contact_id')
..add(serializers.serialize(value,
specifiedType: const FullType(String)));
}
value = object.tokenId; value = object.tokenId;
if (value != null) { if (value != null) {
result result
@ -737,6 +744,10 @@ class _$ActivityEntitySerializer
result.vendorId = serializers.deserialize(value, result.vendorId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
break; break;
case 'vendor_contact_id':
result.vendorContactId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'token_id': case 'token_id':
result.tokenId = serializers.deserialize(value, result.tokenId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
@ -1077,6 +1088,8 @@ class _$ActivityEntity extends ActivityEntity {
@override @override
final String vendorId; final String vendorId;
@override @override
final String vendorContactId;
@override
final String tokenId; final String tokenId;
@override @override
final InvoiceHistoryEntity history; final InvoiceHistoryEntity history;
@ -1105,6 +1118,7 @@ class _$ActivityEntity extends ActivityEntity {
this.taskId, this.taskId,
this.projectId, this.projectId,
this.vendorId, this.vendorId,
this.vendorContactId,
this.tokenId, this.tokenId,
this.history}) this.history})
: super._() { : super._() {
@ -1149,6 +1163,7 @@ class _$ActivityEntity extends ActivityEntity {
taskId == other.taskId && taskId == other.taskId &&
projectId == other.projectId && projectId == other.projectId &&
vendorId == other.vendorId && vendorId == other.vendorId &&
vendorContactId == other.vendorContactId &&
tokenId == other.tokenId && tokenId == other.tokenId &&
history == other.history; history == other.history;
} }
@ -1174,24 +1189,24 @@ class _$ActivityEntity extends ActivityEntity {
$jc( $jc(
$jc( $jc(
$jc( $jc(
$jc($jc($jc($jc(0, notes.hashCode), key.hashCode), activityTypeId.hashCode), $jc($jc($jc($jc($jc(0, notes.hashCode), key.hashCode), activityTypeId.hashCode), clientId.hashCode),
clientId.hashCode), userId.hashCode),
userId.hashCode), invoiceId.hashCode),
invoiceId.hashCode), recurringInvoiceId.hashCode),
recurringInvoiceId.hashCode), recurringExpenseId.hashCode),
recurringExpenseId.hashCode), purchaseOrderId.hashCode),
purchaseOrderId.hashCode), quoteId.hashCode),
quoteId.hashCode), paymentId.hashCode),
paymentId.hashCode), creditId.hashCode),
creditId.hashCode), updatedAt.hashCode),
updatedAt.hashCode), expenseId.hashCode),
expenseId.hashCode), isSystem.hashCode),
isSystem.hashCode), ip.hashCode),
ip.hashCode), contactId.hashCode),
contactId.hashCode), taskId.hashCode),
taskId.hashCode), projectId.hashCode),
projectId.hashCode), vendorId.hashCode),
vendorId.hashCode), vendorContactId.hashCode),
tokenId.hashCode), tokenId.hashCode),
history.hashCode)); history.hashCode));
} }
@ -1219,6 +1234,7 @@ class _$ActivityEntity extends ActivityEntity {
..add('taskId', taskId) ..add('taskId', taskId)
..add('projectId', projectId) ..add('projectId', projectId)
..add('vendorId', vendorId) ..add('vendorId', vendorId)
..add('vendorContactId', vendorContactId)
..add('tokenId', tokenId) ..add('tokenId', tokenId)
..add('history', history)) ..add('history', history))
.toString(); .toString();
@ -1313,6 +1329,11 @@ class ActivityEntityBuilder
String get vendorId => _$this._vendorId; String get vendorId => _$this._vendorId;
set vendorId(String vendorId) => _$this._vendorId = vendorId; set vendorId(String vendorId) => _$this._vendorId = vendorId;
String _vendorContactId;
String get vendorContactId => _$this._vendorContactId;
set vendorContactId(String vendorContactId) =>
_$this._vendorContactId = vendorContactId;
String _tokenId; String _tokenId;
String get tokenId => _$this._tokenId; String get tokenId => _$this._tokenId;
set tokenId(String tokenId) => _$this._tokenId = tokenId; set tokenId(String tokenId) => _$this._tokenId = tokenId;
@ -1347,6 +1368,7 @@ class ActivityEntityBuilder
_taskId = $v.taskId; _taskId = $v.taskId;
_projectId = $v.projectId; _projectId = $v.projectId;
_vendorId = $v.vendorId; _vendorId = $v.vendorId;
_vendorContactId = $v.vendorContactId;
_tokenId = $v.tokenId; _tokenId = $v.tokenId;
_history = $v.history?.toBuilder(); _history = $v.history?.toBuilder();
_$v = null; _$v = null;
@ -1396,6 +1418,7 @@ class ActivityEntityBuilder
taskId: taskId, taskId: taskId,
projectId: projectId, projectId: projectId,
vendorId: vendorId, vendorId: vendorId,
vendorContactId: vendorContactId,
tokenId: tokenId, tokenId: tokenId,
history: _history?.build()); history: _history?.build());
} catch (_) { } catch (_) {