This commit is contained in:
Hillel Coren 2019-12-17 12:28:54 +02:00
parent 1cc5514126
commit 0060ea16d8
7 changed files with 121 additions and 100 deletions

View File

@ -61,8 +61,8 @@ abstract class PaymentEntity extends Object
isChanged: false, isChanged: false,
amount: 0.0, amount: 0.0,
transactionReference: '', transactionReference: '',
paymentDate: convertDateTimeToSqlDate(), date: convertDateTimeToSqlDate(),
paymentTypeId: state?.company != null && typeId: state?.company != null &&
(state.company.settings.defaultPaymentTypeId ?? '').isNotEmpty (state.company.settings.defaultPaymentTypeId ?? '').isNotEmpty
? state.company.settings.defaultPaymentTypeId ? state.company.settings.defaultPaymentTypeId
: '', : '',
@ -72,10 +72,11 @@ abstract class PaymentEntity extends Object
exchangeRate: 0.0, exchangeRate: 0.0,
exchangeCurrencyId: '', exchangeCurrencyId: '',
refunded: 0.0, refunded: 0.0,
paymentStatusId: '', statusId: '',
updatedAt: 0, updatedAt: 0,
archivedAt: 0, archivedAt: 0,
isDeleted: false, isDeleted: false,
isManual: true,
customValue1: '', customValue1: '',
customValue2: '', customValue2: '',
customValue3: '', customValue3: '',
@ -92,7 +93,6 @@ abstract class PaymentEntity extends Object
double get amount; double get amount;
@nullable
double get refunded; double get refunded;
@nullable @nullable
@ -104,17 +104,17 @@ abstract class PaymentEntity extends Object
String get clientId; String get clientId;
@nullable @nullable
@BuiltValueField(wireName: 'payment_status_id') @BuiltValueField(wireName: 'status_id')
String get paymentStatusId; String get statusId;
@BuiltValueField(wireName: 'transaction_reference') @BuiltValueField(wireName: 'transaction_reference')
String get transactionReference; String get transactionReference;
@BuiltValueField(wireName: 'payment_date') @BuiltValueField(wireName: 'date')
String get paymentDate; String get date;
@BuiltValueField(wireName: 'payment_type_id') @BuiltValueField(wireName: 'type_id')
String get paymentTypeId; String get typeId;
@nullable @nullable
@BuiltValueField(wireName: 'invoice_id') @BuiltValueField(wireName: 'invoice_id')
@ -148,6 +148,9 @@ abstract class PaymentEntity extends Object
@BuiltValueField(wireName: 'exchange_currency_id') @BuiltValueField(wireName: 'exchange_currency_id')
String get exchangeCurrencyId; String get exchangeCurrencyId;
@BuiltValueField(wireName: 'is_manual')
bool get isManual;
int compareTo(PaymentEntity credit, String sortField, bool sortAscending) { int compareTo(PaymentEntity credit, String sortField, bool sortAscending) {
int response = 0; int response = 0;
final PaymentEntity paymentA = sortAscending ? this : credit; final PaymentEntity paymentA = sortAscending ? this : credit;
@ -162,7 +165,7 @@ abstract class PaymentEntity extends Object
.compareTo(paymentB.transactionReference); .compareTo(paymentB.transactionReference);
break; break;
case PaymentFields.paymentDate: case PaymentFields.paymentDate:
response = paymentA.paymentDate.compareTo(paymentB.paymentDate); response = paymentA.date.compareTo(paymentB.date);
break; break;
case PaymentFields.updatedAt: case PaymentFields.updatedAt:
response = paymentA.updatedAt.compareTo(paymentB.updatedAt); response = paymentA.updatedAt.compareTo(paymentB.updatedAt);
@ -266,8 +269,8 @@ abstract class PaymentEntity extends Object
double get listDisplayAmount => amount; double get listDisplayAmount => amount;
bool isBetween(String startDate, String endDate) { bool isBetween(String startDate, String endDate) {
return startDate.compareTo(paymentDate) <= 0 && return startDate.compareTo(date) <= 0 &&
endDate.compareTo(paymentDate) >= 0; endDate.compareTo(date) >= 0;
} }
@override @override
@ -275,7 +278,7 @@ abstract class PaymentEntity extends Object
double get completedAmount { double get completedAmount {
if ([kPaymentStatusVoided, kPaymentStatusFailed] if ([kPaymentStatusVoided, kPaymentStatusFailed]
.contains(paymentStatusId)) { .contains(statusId)) {
return 0.0; return 0.0;
} }

View File

@ -121,22 +121,21 @@ class _$PaymentEntitySerializer implements StructuredSerializer<PaymentEntity> {
'amount', 'amount',
serializers.serialize(object.amount, serializers.serialize(object.amount,
specifiedType: const FullType(double)), specifiedType: const FullType(double)),
'refunded',
serializers.serialize(object.refunded,
specifiedType: const FullType(double)),
'transaction_reference', 'transaction_reference',
serializers.serialize(object.transactionReference, serializers.serialize(object.transactionReference,
specifiedType: const FullType(String)), specifiedType: const FullType(String)),
'payment_date', 'date',
serializers.serialize(object.paymentDate, serializers.serialize(object.date, specifiedType: const FullType(String)),
specifiedType: const FullType(String)), 'type_id',
'payment_type_id', serializers.serialize(object.typeId,
serializers.serialize(object.paymentTypeId,
specifiedType: const FullType(String)), specifiedType: const FullType(String)),
'is_manual',
serializers.serialize(object.isManual,
specifiedType: const FullType(bool)),
]; ];
if (object.refunded != null) {
result
..add('refunded')
..add(serializers.serialize(object.refunded,
specifiedType: const FullType(double)));
}
if (object.number != null) { if (object.number != null) {
result result
..add('number') ..add('number')
@ -149,10 +148,10 @@ class _$PaymentEntitySerializer implements StructuredSerializer<PaymentEntity> {
..add(serializers.serialize(object.clientId, ..add(serializers.serialize(object.clientId,
specifiedType: const FullType(String))); specifiedType: const FullType(String)));
} }
if (object.paymentStatusId != null) { if (object.statusId != null) {
result result
..add('payment_status_id') ..add('status_id')
..add(serializers.serialize(object.paymentStatusId, ..add(serializers.serialize(object.statusId,
specifiedType: const FullType(String))); specifiedType: const FullType(String)));
} }
if (object.invoiceId != null) { if (object.invoiceId != null) {
@ -282,20 +281,20 @@ class _$PaymentEntitySerializer implements StructuredSerializer<PaymentEntity> {
result.clientId = serializers.deserialize(value, result.clientId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
break; break;
case 'payment_status_id': case 'status_id':
result.paymentStatusId = serializers.deserialize(value, result.statusId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
break; break;
case 'transaction_reference': case 'transaction_reference':
result.transactionReference = serializers.deserialize(value, result.transactionReference = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
break; break;
case 'payment_date': case 'date':
result.paymentDate = serializers.deserialize(value, result.date = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
break; break;
case 'payment_type_id': case 'type_id':
result.paymentTypeId = serializers.deserialize(value, result.typeId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
break; break;
case 'invoice_id': case 'invoice_id':
@ -330,6 +329,10 @@ class _$PaymentEntitySerializer implements StructuredSerializer<PaymentEntity> {
result.exchangeCurrencyId = serializers.deserialize(value, result.exchangeCurrencyId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
break; break;
case 'is_manual':
result.isManual = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
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;
@ -568,13 +571,13 @@ class _$PaymentEntity extends PaymentEntity {
@override @override
final String clientId; final String clientId;
@override @override
final String paymentStatusId; final String statusId;
@override @override
final String transactionReference; final String transactionReference;
@override @override
final String paymentDate; final String date;
@override @override
final String paymentTypeId; final String typeId;
@override @override
final String invoiceId; final String invoiceId;
@override @override
@ -592,6 +595,8 @@ class _$PaymentEntity extends PaymentEntity {
@override @override
final String exchangeCurrencyId; final String exchangeCurrencyId;
@override @override
final bool isManual;
@override
final bool isChanged; final bool isChanged;
@override @override
final int createdAt; final int createdAt;
@ -616,10 +621,10 @@ class _$PaymentEntity extends PaymentEntity {
this.refunded, this.refunded,
this.number, this.number,
this.clientId, this.clientId,
this.paymentStatusId, this.statusId,
this.transactionReference, this.transactionReference,
this.paymentDate, this.date,
this.paymentTypeId, this.typeId,
this.invoiceId, this.invoiceId,
this.privateNotes, this.privateNotes,
this.customValue1, this.customValue1,
@ -628,6 +633,7 @@ class _$PaymentEntity extends PaymentEntity {
this.customValue4, this.customValue4,
this.exchangeRate, this.exchangeRate,
this.exchangeCurrencyId, this.exchangeCurrencyId,
this.isManual,
this.isChanged, this.isChanged,
this.createdAt, this.createdAt,
this.updatedAt, this.updatedAt,
@ -640,15 +646,21 @@ class _$PaymentEntity extends PaymentEntity {
if (amount == null) { if (amount == null) {
throw new BuiltValueNullFieldError('PaymentEntity', 'amount'); throw new BuiltValueNullFieldError('PaymentEntity', 'amount');
} }
if (refunded == null) {
throw new BuiltValueNullFieldError('PaymentEntity', 'refunded');
}
if (transactionReference == null) { if (transactionReference == null) {
throw new BuiltValueNullFieldError( throw new BuiltValueNullFieldError(
'PaymentEntity', 'transactionReference'); 'PaymentEntity', 'transactionReference');
} }
if (paymentDate == null) { if (date == null) {
throw new BuiltValueNullFieldError('PaymentEntity', 'paymentDate'); throw new BuiltValueNullFieldError('PaymentEntity', 'date');
} }
if (paymentTypeId == null) { if (typeId == null) {
throw new BuiltValueNullFieldError('PaymentEntity', 'paymentTypeId'); throw new BuiltValueNullFieldError('PaymentEntity', 'typeId');
}
if (isManual == null) {
throw new BuiltValueNullFieldError('PaymentEntity', 'isManual');
} }
} }
@ -667,10 +679,10 @@ class _$PaymentEntity extends PaymentEntity {
refunded == other.refunded && refunded == other.refunded &&
number == other.number && number == other.number &&
clientId == other.clientId && clientId == other.clientId &&
paymentStatusId == other.paymentStatusId && statusId == other.statusId &&
transactionReference == other.transactionReference && transactionReference == other.transactionReference &&
paymentDate == other.paymentDate && date == other.date &&
paymentTypeId == other.paymentTypeId && typeId == other.typeId &&
invoiceId == other.invoiceId && invoiceId == other.invoiceId &&
privateNotes == other.privateNotes && privateNotes == other.privateNotes &&
customValue1 == other.customValue1 && customValue1 == other.customValue1 &&
@ -679,6 +691,7 @@ class _$PaymentEntity extends PaymentEntity {
customValue4 == other.customValue4 && customValue4 == other.customValue4 &&
exchangeRate == other.exchangeRate && exchangeRate == other.exchangeRate &&
exchangeCurrencyId == other.exchangeCurrencyId && exchangeCurrencyId == other.exchangeCurrencyId &&
isManual == other.isManual &&
isChanged == other.isChanged && isChanged == other.isChanged &&
createdAt == other.createdAt && createdAt == other.createdAt &&
updatedAt == other.updatedAt && updatedAt == other.updatedAt &&
@ -709,18 +722,18 @@ class _$PaymentEntity extends PaymentEntity {
$jc( $jc(
$jc( $jc(
$jc( $jc(
$jc($jc($jc($jc($jc($jc(0, amount.hashCode), refunded.hashCode), number.hashCode), clientId.hashCode), paymentStatusId.hashCode), $jc($jc($jc($jc($jc($jc($jc(0, amount.hashCode), refunded.hashCode), number.hashCode), clientId.hashCode), statusId.hashCode), transactionReference.hashCode),
transactionReference.hashCode), date.hashCode),
paymentDate.hashCode), typeId.hashCode),
paymentTypeId.hashCode), invoiceId.hashCode),
invoiceId.hashCode), privateNotes.hashCode),
privateNotes.hashCode), customValue1.hashCode),
customValue1.hashCode), customValue2.hashCode),
customValue2.hashCode), customValue3.hashCode),
customValue3.hashCode), customValue4.hashCode),
customValue4.hashCode), exchangeRate.hashCode),
exchangeRate.hashCode), exchangeCurrencyId.hashCode),
exchangeCurrencyId.hashCode), isManual.hashCode),
isChanged.hashCode), isChanged.hashCode),
createdAt.hashCode), createdAt.hashCode),
updatedAt.hashCode), updatedAt.hashCode),
@ -738,10 +751,10 @@ class _$PaymentEntity extends PaymentEntity {
..add('refunded', refunded) ..add('refunded', refunded)
..add('number', number) ..add('number', number)
..add('clientId', clientId) ..add('clientId', clientId)
..add('paymentStatusId', paymentStatusId) ..add('statusId', statusId)
..add('transactionReference', transactionReference) ..add('transactionReference', transactionReference)
..add('paymentDate', paymentDate) ..add('date', date)
..add('paymentTypeId', paymentTypeId) ..add('typeId', typeId)
..add('invoiceId', invoiceId) ..add('invoiceId', invoiceId)
..add('privateNotes', privateNotes) ..add('privateNotes', privateNotes)
..add('customValue1', customValue1) ..add('customValue1', customValue1)
@ -750,6 +763,7 @@ class _$PaymentEntity extends PaymentEntity {
..add('customValue4', customValue4) ..add('customValue4', customValue4)
..add('exchangeRate', exchangeRate) ..add('exchangeRate', exchangeRate)
..add('exchangeCurrencyId', exchangeCurrencyId) ..add('exchangeCurrencyId', exchangeCurrencyId)
..add('isManual', isManual)
..add('isChanged', isChanged) ..add('isChanged', isChanged)
..add('createdAt', createdAt) ..add('createdAt', createdAt)
..add('updatedAt', updatedAt) ..add('updatedAt', updatedAt)
@ -782,24 +796,22 @@ class PaymentEntityBuilder
String get clientId => _$this._clientId; String get clientId => _$this._clientId;
set clientId(String clientId) => _$this._clientId = clientId; set clientId(String clientId) => _$this._clientId = clientId;
String _paymentStatusId; String _statusId;
String get paymentStatusId => _$this._paymentStatusId; String get statusId => _$this._statusId;
set paymentStatusId(String paymentStatusId) => set statusId(String statusId) => _$this._statusId = statusId;
_$this._paymentStatusId = paymentStatusId;
String _transactionReference; String _transactionReference;
String get transactionReference => _$this._transactionReference; String get transactionReference => _$this._transactionReference;
set transactionReference(String transactionReference) => set transactionReference(String transactionReference) =>
_$this._transactionReference = transactionReference; _$this._transactionReference = transactionReference;
String _paymentDate; String _date;
String get paymentDate => _$this._paymentDate; String get date => _$this._date;
set paymentDate(String paymentDate) => _$this._paymentDate = paymentDate; set date(String date) => _$this._date = date;
String _paymentTypeId; String _typeId;
String get paymentTypeId => _$this._paymentTypeId; String get typeId => _$this._typeId;
set paymentTypeId(String paymentTypeId) => set typeId(String typeId) => _$this._typeId = typeId;
_$this._paymentTypeId = paymentTypeId;
String _invoiceId; String _invoiceId;
String get invoiceId => _$this._invoiceId; String get invoiceId => _$this._invoiceId;
@ -834,6 +846,10 @@ class PaymentEntityBuilder
set exchangeCurrencyId(String exchangeCurrencyId) => set exchangeCurrencyId(String exchangeCurrencyId) =>
_$this._exchangeCurrencyId = exchangeCurrencyId; _$this._exchangeCurrencyId = exchangeCurrencyId;
bool _isManual;
bool get isManual => _$this._isManual;
set isManual(bool isManual) => _$this._isManual = isManual;
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;
@ -876,10 +892,10 @@ class PaymentEntityBuilder
_refunded = _$v.refunded; _refunded = _$v.refunded;
_number = _$v.number; _number = _$v.number;
_clientId = _$v.clientId; _clientId = _$v.clientId;
_paymentStatusId = _$v.paymentStatusId; _statusId = _$v.statusId;
_transactionReference = _$v.transactionReference; _transactionReference = _$v.transactionReference;
_paymentDate = _$v.paymentDate; _date = _$v.date;
_paymentTypeId = _$v.paymentTypeId; _typeId = _$v.typeId;
_invoiceId = _$v.invoiceId; _invoiceId = _$v.invoiceId;
_privateNotes = _$v.privateNotes; _privateNotes = _$v.privateNotes;
_customValue1 = _$v.customValue1; _customValue1 = _$v.customValue1;
@ -888,6 +904,7 @@ class PaymentEntityBuilder
_customValue4 = _$v.customValue4; _customValue4 = _$v.customValue4;
_exchangeRate = _$v.exchangeRate; _exchangeRate = _$v.exchangeRate;
_exchangeCurrencyId = _$v.exchangeCurrencyId; _exchangeCurrencyId = _$v.exchangeCurrencyId;
_isManual = _$v.isManual;
_isChanged = _$v.isChanged; _isChanged = _$v.isChanged;
_createdAt = _$v.createdAt; _createdAt = _$v.createdAt;
_updatedAt = _$v.updatedAt; _updatedAt = _$v.updatedAt;
@ -922,10 +939,10 @@ class PaymentEntityBuilder
refunded: refunded, refunded: refunded,
number: number, number: number,
clientId: clientId, clientId: clientId,
paymentStatusId: paymentStatusId, statusId: statusId,
transactionReference: transactionReference, transactionReference: transactionReference,
paymentDate: paymentDate, date: date,
paymentTypeId: paymentTypeId, typeId: typeId,
invoiceId: invoiceId, invoiceId: invoiceId,
privateNotes: privateNotes, privateNotes: privateNotes,
customValue1: customValue1, customValue1: customValue1,
@ -934,6 +951,7 @@ class PaymentEntityBuilder
customValue4: customValue4, customValue4: customValue4,
exchangeRate: exchangeRate, exchangeRate: exchangeRate,
exchangeCurrencyId: exchangeCurrencyId, exchangeCurrencyId: exchangeCurrencyId,
isManual: isManual,
isChanged: isChanged, isChanged: isChanged,
createdAt: createdAt, createdAt: createdAt,
updatedAt: updatedAt, updatedAt: updatedAt,

View File

@ -318,9 +318,9 @@ List<ChartDataGroup> chartPayments(
} else if (!settings.matchesCurrency(currencyId)) { } else if (!settings.matchesCurrency(currencyId)) {
// skip it // skip it
} else { } else {
if (totals[STATUS_ACTIVE][payment.paymentDate] == null) { if (totals[STATUS_ACTIVE][payment.date] == null) {
totals[STATUS_ACTIVE][payment.paymentDate] = 0.0; totals[STATUS_ACTIVE][payment.date] = 0.0;
totals[STATUS_REFUNDED][payment.paymentDate] = 0.0; totals[STATUS_REFUNDED][payment.date] = 0.0;
} }
double completedAmount = payment.completedAmount; double completedAmount = payment.completedAmount;
@ -335,8 +335,8 @@ List<ChartDataGroup> chartPayments(
fromCurrencyId: currencyId, toCurrencyId: company.currencyId); fromCurrencyId: currencyId, toCurrencyId: company.currencyId);
} }
totals[STATUS_ACTIVE][payment.paymentDate] += completedAmount; totals[STATUS_ACTIVE][payment.date] += completedAmount;
totals[STATUS_REFUNDED][payment.paymentDate] += refunded ?? 0; totals[STATUS_REFUNDED][payment.date] += refunded ?? 0;
counts[STATUS_ACTIVE]++; counts[STATUS_ACTIVE]++;
if ((payment.refunded ?? 0) > 0) { if ((payment.refunded ?? 0) > 0) {

View File

@ -112,7 +112,7 @@ class InvoiceOverview extends StatelessWidget {
subtitle: Text( subtitle: Text(
formatNumber(payment.amount, context, clientId: client.id) + formatNumber(payment.amount, context, clientId: client.id) +
'' + '' +
formatDate(payment.paymentDate, context)), formatDate(payment.date, context)),
leading: Icon(FontAwesomeIcons.creditCard, size: 18.0), leading: Icon(FontAwesomeIcons.creditCard, size: 18.0),
trailing: Icon(Icons.navigate_next), trailing: Icon(Icons.navigate_next),
onTap: () => viewModel.onPaymentPressed(context, payment), onTap: () => viewModel.onPaymentPressed(context, payment),

View File

@ -162,14 +162,14 @@ class _PaymentEditState extends State<PaymentEdit> {
), ),
], ],
EntityDropdown( EntityDropdown(
key: ValueKey('__payment_type_${payment.paymentTypeId}__'), key: ValueKey('__payment_type_${payment.typeId}__'),
entityType: EntityType.paymentType, entityType: EntityType.paymentType,
entityList: memoizedPaymentTypeList( entityList: memoizedPaymentTypeList(
viewModel.staticState.paymentTypeMap), viewModel.staticState.paymentTypeMap),
labelText: localization.paymentType, labelText: localization.paymentType,
entityId: payment.paymentTypeId, entityId: payment.typeId,
onSelected: (paymentType) => viewModel.onChanged(payment onSelected: (paymentType) => viewModel.onChanged(payment
.rebuild((b) => b..paymentTypeId = paymentType.id)), .rebuild((b) => b..typeId = paymentType.id)),
), ),
DatePicker( DatePicker(
validator: (String val) => val.trim().isEmpty validator: (String val) => val.trim().isEmpty
@ -177,10 +177,10 @@ class _PaymentEditState extends State<PaymentEdit> {
: null, : null,
autoValidate: autoValidate, autoValidate: autoValidate,
labelText: localization.paymentDate, labelText: localization.paymentDate,
selectedDate: payment.paymentDate, selectedDate: payment.date,
onSelected: (date) { onSelected: (date) {
viewModel.onChanged( viewModel.onChanged(
payment.rebuild((b) => b..paymentDate = date)); payment.rebuild((b) => b..date = date));
}, },
), ),
DecoratedFormField( DecoratedFormField(

View File

@ -48,7 +48,7 @@ class PaymentListItem extends StatelessWidget {
? payment.matchesFilterValue(filter) ? payment.matchesFilterValue(filter)
: null; : null;
final subtitle = filterMatch ?? final subtitle = filterMatch ??
(payment.number ?? '') + '' + formatDate(payment.paymentDate, context); (payment.number ?? '') + '' + formatDate(payment.date, context);
return DismissibleEntity( return DismissibleEntity(
isSelected: payment.id == isSelected: payment.id ==
@ -105,10 +105,10 @@ class PaymentListItem extends StatelessWidget {
), ),
Text( Text(
localization localization
.lookup('payment_status_${payment.paymentStatusId}'), .lookup('payment_status_${payment.statusId}'),
style: TextStyle( style: TextStyle(
color: color:
PaymentStatusColors.colors[payment.paymentStatusId], PaymentStatusColors.colors[payment.statusId],
)), )),
], ],
), ),

View File

@ -40,14 +40,14 @@ class _PaymentViewState extends State<PaymentView> {
final fields = <String, String>{}; final fields = <String, String>{};
fields[PaymentFields.paymentStatusId] = fields[PaymentFields.paymentStatusId] =
localization.lookup('payment_status_${payment.paymentStatusId}'); localization.lookup('payment_status_${payment.statusId}');
if (payment.paymentDate.isNotEmpty) { if (payment.date.isNotEmpty) {
fields[PaymentFields.paymentDate] = fields[PaymentFields.paymentDate] =
formatDate(payment.paymentDate, context); formatDate(payment.date, context);
} }
if ((payment.paymentTypeId ?? '').isNotEmpty) { if ((payment.typeId ?? '').isNotEmpty) {
final paymentType = final paymentType =
state.staticState.paymentTypeMap[payment.paymentTypeId]; state.staticState.paymentTypeMap[payment.typeId];
if (paymentType != null) { if (paymentType != null) {
fields[PaymentFields.paymentTypeId] = paymentType.name; fields[PaymentFields.paymentTypeId] = paymentType.name;
} }
@ -68,7 +68,7 @@ class _PaymentViewState extends State<PaymentView> {
(payment.refunded ?? 0) > 0 (payment.refunded ?? 0) > 0
? EntityHeader( ? EntityHeader(
backgroundColor: backgroundColor:
PaymentStatusColors.colors[payment.paymentStatusId], PaymentStatusColors.colors[payment.statusId],
label: localization.amount, label: localization.amount,
value: formatNumber(payment.amount, context, value: formatNumber(payment.amount, context,
clientId: client.id), clientId: client.id),
@ -78,7 +78,7 @@ class _PaymentViewState extends State<PaymentView> {
) )
: EntityHeader( : EntityHeader(
backgroundColor: backgroundColor:
PaymentStatusColors.colors[payment.paymentStatusId], PaymentStatusColors.colors[payment.statusId],
label: localization.amount, label: localization.amount,
value: formatNumber(payment.amount, context, value: formatNumber(payment.amount, context,
clientId: client.id), clientId: client.id),