diff --git a/lib/data/models/payment_model.dart b/lib/data/models/payment_model.dart index 58d4da379..8bbdcb2a1 100644 --- a/lib/data/models/payment_model.dart +++ b/lib/data/models/payment_model.dart @@ -37,6 +37,7 @@ abstract class PaymentItemResponse class PaymentFields { static const String amount = 'amount'; + static const String refunded = 'refunded'; static const String transactionReference = 'transactionReference'; static const String paymentDate = 'paymentDate'; static const String paymentTypeId = 'paymentTypeId'; diff --git a/lib/redux/payment/payment_middleware.dart b/lib/redux/payment/payment_middleware.dart index 530821a93..6a902498a 100644 --- a/lib/redux/payment/payment_middleware.dart +++ b/lib/redux/payment/payment_middleware.dart @@ -235,12 +235,12 @@ Middleware _savePayment(PaymentRepository repository) { Middleware _refundPayment(PaymentRepository repository) { return (Store store, dynamic dynamicAction, NextDispatcher next) { final action = dynamicAction as RefundPaymentRequest; - final PaymentEntity payment = action.payment; final bool sendEmail = store.state.prefState.emailPayment; repository .refundPayment(store.state.credentials, action.payment, sendEmail: sendEmail) .then((PaymentEntity payment) { + store.dispatch(SavePaymentSuccess(payment)); store.dispatch(RefundPaymentSuccess(payment)); //store.dispatch(LoadInvoice(invoiceId: payment.invoiceId)); action.completer.complete(payment); diff --git a/lib/ui/payment/view/payment_view.dart b/lib/ui/payment/view/payment_view.dart index 55bdcfdb0..6c259fd8e 100644 --- a/lib/ui/payment/view/payment_view.dart +++ b/lib/ui/payment/view/payment_view.dart @@ -53,6 +53,10 @@ class _PaymentViewState extends State { if (payment.transactionReference.isNotEmpty) { fields[PaymentFields.transactionReference] = payment.transactionReference; } + if (payment.refunded != 0) { + fields[PaymentFields.refunded] = + formatNumber(payment.refunded, context, clientId: client.id); + } return ViewScaffold( entity: payment, @@ -61,27 +65,15 @@ class _PaymentViewState extends State { builder: (BuildContext context) { return ListView( children: [ - (payment.refunded ?? 0) > 0 - ? EntityHeader( - backgroundColor: - PaymentStatusColors.colors[payment.statusId], - label: localization.amount, - value: formatNumber(payment.amount, context, - clientId: client.id), - secondLabel: localization.refunded, - secondValue: formatNumber(payment.refunded, context, - clientId: client.id), - ) - : EntityHeader( - backgroundColor: - PaymentStatusColors.colors[payment.statusId], - label: localization.amount, - value: formatNumber(payment.amount, context, - clientId: client.id), - secondLabel: localization.applied, - secondValue: formatNumber(payment.applied, context, - clientId: client.id), - ), + EntityHeader( + backgroundColor: PaymentStatusColors.colors[payment.statusId], + label: localization.amount, + value: + formatNumber(payment.amount, context, clientId: client.id), + secondLabel: localization.applied, + secondValue: + formatNumber(payment.applied, context, clientId: client.id), + ), Material( color: Theme.of(context).canvasColor, child: ListTile(