Don’t allow creating an empty payment if client initiated payments is disabled
This commit is contained in:
parent
41c3d54339
commit
6a6b0fb665
|
|
@ -80,7 +80,7 @@ class PaymentEditVM {
|
||||||
onSavePressed: (BuildContext context) {
|
onSavePressed: (BuildContext context) {
|
||||||
Debouncer.runOnComplete(() {
|
Debouncer.runOnComplete(() {
|
||||||
final payment = store.state.paymentUIState.editing!;
|
final payment = store.state.paymentUIState.editing!;
|
||||||
final localization = navigatorKey.localization;
|
final localization = navigatorKey.localization!;
|
||||||
final navigator = navigatorKey.currentState;
|
final navigator = navigatorKey.currentState;
|
||||||
double amount = 0;
|
double amount = 0;
|
||||||
payment.invoices.forEach((invoice) => amount += invoice.amount);
|
payment.invoices.forEach((invoice) => amount += invoice.amount);
|
||||||
|
|
@ -89,17 +89,27 @@ class PaymentEditVM {
|
||||||
showDialog<ErrorDialog>(
|
showDialog<ErrorDialog>(
|
||||||
context: navigatorKey.currentContext!,
|
context: navigatorKey.currentContext!,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return ErrorDialog(localization!.creditPaymentError);
|
return ErrorDialog(localization.creditPaymentError);
|
||||||
|
});
|
||||||
|
return null;
|
||||||
|
} else if (!state.company.enableApplyingPayments &&
|
||||||
|
payment.invoices.isEmpty &&
|
||||||
|
payment.credits.isEmpty) {
|
||||||
|
showDialog<ErrorDialog>(
|
||||||
|
context: navigatorKey.currentContext!,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return ErrorDialog(localization.pleaseSelectAnInvoice);
|
||||||
});
|
});
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Completer<PaymentEntity> completer = Completer<PaymentEntity>();
|
final Completer<PaymentEntity> completer = Completer<PaymentEntity>();
|
||||||
store.dispatch(
|
store.dispatch(
|
||||||
SavePaymentRequest(completer: completer, payment: payment));
|
SavePaymentRequest(completer: completer, payment: payment));
|
||||||
return completer.future.then((savedPayment) {
|
return completer.future.then((savedPayment) {
|
||||||
showToast(payment.isNew
|
showToast(payment.isNew
|
||||||
? localization!.createdPayment
|
? localization.createdPayment
|
||||||
: localization!.updatedPayment);
|
: localization.updatedPayment);
|
||||||
if (state.prefState.isMobile) {
|
if (state.prefState.isMobile) {
|
||||||
store.dispatch(UpdateCurrentRoute(PaymentViewScreen.route));
|
store.dispatch(UpdateCurrentRoute(PaymentViewScreen.route));
|
||||||
if (payment.isNew) {
|
if (payment.isNew) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue