Refunds
This commit is contained in:
parent
617a48da75
commit
987708bd98
|
|
@ -37,6 +37,7 @@ abstract class PaymentItemResponse
|
||||||
|
|
||||||
class PaymentFields {
|
class PaymentFields {
|
||||||
static const String amount = 'amount';
|
static const String amount = 'amount';
|
||||||
|
static const String refunded = 'refunded';
|
||||||
static const String transactionReference = 'transactionReference';
|
static const String transactionReference = 'transactionReference';
|
||||||
static const String paymentDate = 'paymentDate';
|
static const String paymentDate = 'paymentDate';
|
||||||
static const String paymentTypeId = 'paymentTypeId';
|
static const String paymentTypeId = 'paymentTypeId';
|
||||||
|
|
|
||||||
|
|
@ -235,12 +235,12 @@ Middleware<AppState> _savePayment(PaymentRepository repository) {
|
||||||
Middleware<AppState> _refundPayment(PaymentRepository repository) {
|
Middleware<AppState> _refundPayment(PaymentRepository repository) {
|
||||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||||
final action = dynamicAction as RefundPaymentRequest;
|
final action = dynamicAction as RefundPaymentRequest;
|
||||||
final PaymentEntity payment = action.payment;
|
|
||||||
final bool sendEmail = store.state.prefState.emailPayment;
|
final bool sendEmail = store.state.prefState.emailPayment;
|
||||||
|
|
||||||
repository
|
repository
|
||||||
.refundPayment(store.state.credentials, action.payment, sendEmail: sendEmail)
|
.refundPayment(store.state.credentials, action.payment, sendEmail: sendEmail)
|
||||||
.then((PaymentEntity payment) {
|
.then((PaymentEntity payment) {
|
||||||
|
store.dispatch(SavePaymentSuccess(payment));
|
||||||
store.dispatch(RefundPaymentSuccess(payment));
|
store.dispatch(RefundPaymentSuccess(payment));
|
||||||
//store.dispatch(LoadInvoice(invoiceId: payment.invoiceId));
|
//store.dispatch(LoadInvoice(invoiceId: payment.invoiceId));
|
||||||
action.completer.complete(payment);
|
action.completer.complete(payment);
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,10 @@ class _PaymentViewState extends State<PaymentView> {
|
||||||
if (payment.transactionReference.isNotEmpty) {
|
if (payment.transactionReference.isNotEmpty) {
|
||||||
fields[PaymentFields.transactionReference] = payment.transactionReference;
|
fields[PaymentFields.transactionReference] = payment.transactionReference;
|
||||||
}
|
}
|
||||||
|
if (payment.refunded != 0) {
|
||||||
|
fields[PaymentFields.refunded] =
|
||||||
|
formatNumber(payment.refunded, context, clientId: client.id);
|
||||||
|
}
|
||||||
|
|
||||||
return ViewScaffold(
|
return ViewScaffold(
|
||||||
entity: payment,
|
entity: payment,
|
||||||
|
|
@ -61,27 +65,15 @@ class _PaymentViewState extends State<PaymentView> {
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return ListView(
|
return ListView(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
(payment.refunded ?? 0) > 0
|
EntityHeader(
|
||||||
? EntityHeader(
|
backgroundColor: PaymentStatusColors.colors[payment.statusId],
|
||||||
backgroundColor:
|
label: localization.amount,
|
||||||
PaymentStatusColors.colors[payment.statusId],
|
value:
|
||||||
label: localization.amount,
|
formatNumber(payment.amount, context, clientId: client.id),
|
||||||
value: formatNumber(payment.amount, context,
|
secondLabel: localization.applied,
|
||||||
clientId: client.id),
|
secondValue:
|
||||||
secondLabel: localization.refunded,
|
formatNumber(payment.applied, context, clientId: client.id),
|
||||||
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),
|
|
||||||
),
|
|
||||||
Material(
|
Material(
|
||||||
color: Theme.of(context).canvasColor,
|
color: Theme.of(context).canvasColor,
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue