This commit is contained in:
Hillel Coren 2020-02-05 20:12:46 +02:00
parent 617a48da75
commit 987708bd98
3 changed files with 15 additions and 22 deletions

View File

@ -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';

View File

@ -235,12 +235,12 @@ Middleware<AppState> _savePayment(PaymentRepository repository) {
Middleware<AppState> _refundPayment(PaymentRepository repository) {
return (Store<AppState> 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);

View File

@ -53,6 +53,10 @@ class _PaymentViewState extends State<PaymentView> {
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<PaymentView> {
builder: (BuildContext context) {
return ListView(
children: <Widget>[
(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(