Payments
This commit is contained in:
parent
815c724b17
commit
f3370e521d
|
|
@ -45,9 +45,12 @@ class PaymentRepository {
|
||||||
}
|
}
|
||||||
response = await webClient.post(url, company.token, json.encode(data));
|
response = await webClient.post(url, company.token, json.encode(data));
|
||||||
} else {
|
} else {
|
||||||
var url = auth.url + '/payments/' + payment.id.toString();
|
var url = '${auth.url}/payments/${payment.id}?';
|
||||||
|
if (sendEmail) {
|
||||||
|
url += '&email_receipt=true';
|
||||||
|
}
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '&action=' + action.toString();
|
||||||
}
|
}
|
||||||
response = await webClient.put(url, company.token, json.encode(data));
|
response = await webClient.put(url, company.token, json.encode(data));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,14 @@ import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||||
|
|
||||||
class ViewPaymentList implements PersistUI {
|
class ViewPaymentList implements PersistUI {
|
||||||
final BuildContext context;
|
final BuildContext context;
|
||||||
|
|
||||||
ViewPaymentList(this.context);
|
ViewPaymentList(this.context);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ViewPayment implements PersistUI {
|
class ViewPayment implements PersistUI {
|
||||||
final int paymentId;
|
final int paymentId;
|
||||||
final BuildContext context;
|
final BuildContext context;
|
||||||
|
|
||||||
ViewPayment({this.paymentId, this.context});
|
ViewPayment({this.paymentId, this.context});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -20,11 +22,14 @@ class EditPayment implements PersistUI {
|
||||||
final BuildContext context;
|
final BuildContext context;
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool trackRoute;
|
final bool trackRoute;
|
||||||
EditPayment({this.payment, this.context, this.completer, this.trackRoute = true});
|
|
||||||
|
EditPayment(
|
||||||
|
{this.payment, this.context, this.completer, this.trackRoute = true});
|
||||||
}
|
}
|
||||||
|
|
||||||
class UpdatePayment implements PersistUI {
|
class UpdatePayment implements PersistUI {
|
||||||
final PaymentEntity payment;
|
final PaymentEntity payment;
|
||||||
|
|
||||||
UpdatePayment(this.payment);
|
UpdatePayment(this.payment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,6 +59,7 @@ class LoadPaymentRequest implements StartLoading {}
|
||||||
|
|
||||||
class LoadPaymentFailure implements StopLoading {
|
class LoadPaymentFailure implements StopLoading {
|
||||||
final dynamic error;
|
final dynamic error;
|
||||||
|
|
||||||
LoadPaymentFailure(this.error);
|
LoadPaymentFailure(this.error);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -64,6 +70,7 @@ class LoadPaymentFailure implements StopLoading {
|
||||||
|
|
||||||
class LoadPaymentSuccess implements StopLoading, PersistData {
|
class LoadPaymentSuccess implements StopLoading, PersistData {
|
||||||
final PaymentEntity payment;
|
final PaymentEntity payment;
|
||||||
|
|
||||||
LoadPaymentSuccess(this.payment);
|
LoadPaymentSuccess(this.payment);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -76,6 +83,7 @@ class LoadPaymentsRequest implements StartLoading {}
|
||||||
|
|
||||||
class LoadPaymentsFailure implements StopLoading {
|
class LoadPaymentsFailure implements StopLoading {
|
||||||
final dynamic error;
|
final dynamic error;
|
||||||
|
|
||||||
LoadPaymentsFailure(this.error);
|
LoadPaymentsFailure(this.error);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -86,6 +94,7 @@ class LoadPaymentsFailure implements StopLoading {
|
||||||
|
|
||||||
class LoadPaymentsSuccess implements StopLoading, PersistData {
|
class LoadPaymentsSuccess implements StopLoading, PersistData {
|
||||||
final BuiltList<PaymentEntity> payments;
|
final BuiltList<PaymentEntity> payments;
|
||||||
|
|
||||||
LoadPaymentsSuccess(this.payments);
|
LoadPaymentsSuccess(this.payments);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -94,11 +103,10 @@ class LoadPaymentsSuccess implements StopLoading, PersistData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SavePaymentRequest implements StartSaving {
|
class SavePaymentRequest implements StartSaving {
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final PaymentEntity payment;
|
final PaymentEntity payment;
|
||||||
|
|
||||||
SavePaymentRequest({this.completer, this.payment});
|
SavePaymentRequest({this.completer, this.payment});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,12 +118,14 @@ class SavePaymentSuccess implements StopSaving, PersistData, PersistUI {
|
||||||
|
|
||||||
class AddPaymentSuccess implements StopSaving, PersistData, PersistUI {
|
class AddPaymentSuccess implements StopSaving, PersistData, PersistUI {
|
||||||
final PaymentEntity payment;
|
final PaymentEntity payment;
|
||||||
|
|
||||||
AddPaymentSuccess(this.payment);
|
AddPaymentSuccess(this.payment);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SavePaymentFailure implements StopSaving {
|
class SavePaymentFailure implements StopSaving {
|
||||||
final Object error;
|
final Object error;
|
||||||
SavePaymentFailure (this.error);
|
|
||||||
|
SavePaymentFailure(this.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ArchivePaymentRequest implements StartSaving {
|
class ArchivePaymentRequest implements StartSaving {
|
||||||
|
|
@ -127,11 +137,13 @@ class ArchivePaymentRequest implements StartSaving {
|
||||||
|
|
||||||
class ArchivePaymentSuccess implements StopSaving, PersistData {
|
class ArchivePaymentSuccess implements StopSaving, PersistData {
|
||||||
final PaymentEntity payment;
|
final PaymentEntity payment;
|
||||||
|
|
||||||
ArchivePaymentSuccess(this.payment);
|
ArchivePaymentSuccess(this.payment);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ArchivePaymentFailure implements StopSaving {
|
class ArchivePaymentFailure implements StopSaving {
|
||||||
final PaymentEntity payment;
|
final PaymentEntity payment;
|
||||||
|
|
||||||
ArchivePaymentFailure(this.payment);
|
ArchivePaymentFailure(this.payment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -144,40 +156,59 @@ class DeletePaymentRequest implements StartSaving {
|
||||||
|
|
||||||
class DeletePaymentSuccess implements StopSaving, PersistData {
|
class DeletePaymentSuccess implements StopSaving, PersistData {
|
||||||
final PaymentEntity payment;
|
final PaymentEntity payment;
|
||||||
|
|
||||||
DeletePaymentSuccess(this.payment);
|
DeletePaymentSuccess(this.payment);
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeletePaymentFailure implements StopSaving {
|
class DeletePaymentFailure implements StopSaving {
|
||||||
final PaymentEntity payment;
|
final PaymentEntity payment;
|
||||||
|
|
||||||
DeletePaymentFailure(this.payment);
|
DeletePaymentFailure(this.payment);
|
||||||
}
|
}
|
||||||
|
|
||||||
class RestorePaymentRequest implements StartSaving {
|
class RestorePaymentRequest implements StartSaving {
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final int paymentId;
|
final int paymentId;
|
||||||
|
|
||||||
RestorePaymentRequest(this.completer, this.paymentId);
|
RestorePaymentRequest(this.completer, this.paymentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
class RestorePaymentSuccess implements StopSaving, PersistData {
|
class RestorePaymentSuccess implements StopSaving, PersistData {
|
||||||
final PaymentEntity payment;
|
final PaymentEntity payment;
|
||||||
|
|
||||||
RestorePaymentSuccess(this.payment);
|
RestorePaymentSuccess(this.payment);
|
||||||
}
|
}
|
||||||
|
|
||||||
class RestorePaymentFailure implements StopSaving {
|
class RestorePaymentFailure implements StopSaving {
|
||||||
final PaymentEntity payment;
|
final PaymentEntity payment;
|
||||||
|
|
||||||
RestorePaymentFailure(this.payment);
|
RestorePaymentFailure(this.payment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class EmailPaymentRequest implements StartSaving {
|
||||||
|
final Completer completer;
|
||||||
|
final PaymentEntity payment;
|
||||||
|
|
||||||
|
EmailPaymentRequest(this.completer, this.payment);
|
||||||
|
}
|
||||||
|
|
||||||
|
class EmailPaymentSuccess implements StopSaving, PersistData {}
|
||||||
|
|
||||||
|
class EmailPaymentFailure implements StopSaving {
|
||||||
|
final dynamic error;
|
||||||
|
|
||||||
|
EmailPaymentFailure(this.error);
|
||||||
|
}
|
||||||
|
|
||||||
class FilterPayments {
|
class FilterPayments {
|
||||||
final String filter;
|
final String filter;
|
||||||
|
|
||||||
FilterPayments(this.filter);
|
FilterPayments(this.filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SortPayments implements PersistUI {
|
class SortPayments implements PersistUI {
|
||||||
final String field;
|
final String field;
|
||||||
|
|
||||||
SortPayments(this.field);
|
SortPayments(this.field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -205,4 +236,3 @@ class FilterPaymentsByEntity implements PersistUI {
|
||||||
|
|
||||||
FilterPaymentsByEntity({this.entityId, this.entityType});
|
FilterPaymentsByEntity({this.entityId, this.entityType});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ List<Middleware<AppState>> createStorePaymentsMiddleware([
|
||||||
final archivePayment = _archivePayment(repository);
|
final archivePayment = _archivePayment(repository);
|
||||||
final deletePayment = _deletePayment(repository);
|
final deletePayment = _deletePayment(repository);
|
||||||
final restorePayment = _restorePayment(repository);
|
final restorePayment = _restorePayment(repository);
|
||||||
|
final emailPayment = _emailPayment(repository);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
TypedMiddleware<AppState, ViewPaymentList>(viewPaymentList),
|
TypedMiddleware<AppState, ViewPaymentList>(viewPaymentList),
|
||||||
|
|
@ -35,6 +36,7 @@ List<Middleware<AppState>> createStorePaymentsMiddleware([
|
||||||
TypedMiddleware<AppState, ArchivePaymentRequest>(archivePayment),
|
TypedMiddleware<AppState, ArchivePaymentRequest>(archivePayment),
|
||||||
TypedMiddleware<AppState, DeletePaymentRequest>(deletePayment),
|
TypedMiddleware<AppState, DeletePaymentRequest>(deletePayment),
|
||||||
TypedMiddleware<AppState, RestorePaymentRequest>(restorePayment),
|
TypedMiddleware<AppState, RestorePaymentRequest>(restorePayment),
|
||||||
|
TypedMiddleware<AppState, EmailPaymentRequest>(emailPayment),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -169,6 +171,25 @@ Middleware<AppState> _savePayment(PaymentRepository repository) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Middleware<AppState> _emailPayment(PaymentRepository repository) {
|
||||||
|
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||||
|
repository
|
||||||
|
.saveData(
|
||||||
|
store.state.selectedCompany, store.state.authState, action.payment, sendEmail: true)
|
||||||
|
.then((PaymentEntity payment) {
|
||||||
|
store.dispatch(SavePaymentSuccess(payment));
|
||||||
|
action.completer.complete(null);
|
||||||
|
}).catchError((Object error) {
|
||||||
|
print(error);
|
||||||
|
store.dispatch(SavePaymentFailure(error));
|
||||||
|
action.completer.completeError(error);
|
||||||
|
});
|
||||||
|
|
||||||
|
next(action);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Middleware<AppState> _loadPayment(PaymentRepository repository) {
|
Middleware<AppState> _loadPayment(PaymentRepository repository) {
|
||||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,11 @@ class PaymentListVM {
|
||||||
},
|
},
|
||||||
onEntityAction: (context, payment, action) {
|
onEntityAction: (context, payment, action) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
case EntityAction.email:
|
||||||
|
store.dispatch(EmailPaymentRequest(
|
||||||
|
popCompleter(context, AppLocalization.of(context).emailedPayment), payment
|
||||||
|
));
|
||||||
|
break;
|
||||||
case EntityAction.restore:
|
case EntityAction.restore:
|
||||||
store.dispatch(RestorePaymentRequest(
|
store.dispatch(RestorePaymentRequest(
|
||||||
popCompleter(
|
popCompleter(
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ class AppLocalization {
|
||||||
'deleted_invoice': 'Successfully deleted invoice',
|
'deleted_invoice': 'Successfully deleted invoice',
|
||||||
'restored_invoice': 'Successfully restored invoice',
|
'restored_invoice': 'Successfully restored invoice',
|
||||||
'emailed_invoice': 'Successfully emailed invoice',
|
'emailed_invoice': 'Successfully emailed invoice',
|
||||||
|
'emailed_payment': 'Successfully emailed payment',
|
||||||
'amount': 'Amount',
|
'amount': 'Amount',
|
||||||
'invoice_number': 'Invoice Number',
|
'invoice_number': 'Invoice Number',
|
||||||
'invoice_date': 'Invoice Date',
|
'invoice_date': 'Invoice Date',
|
||||||
|
|
@ -7353,6 +7354,9 @@ class AppLocalization {
|
||||||
String get emailedInvoice =>
|
String get emailedInvoice =>
|
||||||
_localizedValues[locale.languageCode]['emailed_invoice'];
|
_localizedValues[locale.languageCode]['emailed_invoice'];
|
||||||
|
|
||||||
|
String get emailedPayment =>
|
||||||
|
_localizedValues[locale.languageCode]['emailed_payment'];
|
||||||
|
|
||||||
String get amount => _localizedValues[locale.languageCode]['amount'];
|
String get amount => _localizedValues[locale.languageCode]['amount'];
|
||||||
|
|
||||||
String get invoiceNumber =>
|
String get invoiceNumber =>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue