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) {
|
||||
Debouncer.runOnComplete(() {
|
||||
final payment = store.state.paymentUIState.editing!;
|
||||
final localization = navigatorKey.localization;
|
||||
final localization = navigatorKey.localization!;
|
||||
final navigator = navigatorKey.currentState;
|
||||
double amount = 0;
|
||||
payment.invoices.forEach((invoice) => amount += invoice.amount);
|
||||
|
|
@ -89,17 +89,27 @@ class PaymentEditVM {
|
|||
showDialog<ErrorDialog>(
|
||||
context: navigatorKey.currentContext!,
|
||||
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;
|
||||
}
|
||||
|
||||
final Completer<PaymentEntity> completer = Completer<PaymentEntity>();
|
||||
store.dispatch(
|
||||
SavePaymentRequest(completer: completer, payment: payment));
|
||||
return completer.future.then((savedPayment) {
|
||||
showToast(payment.isNew
|
||||
? localization!.createdPayment
|
||||
: localization!.updatedPayment);
|
||||
? localization.createdPayment
|
||||
: localization.updatedPayment);
|
||||
if (state.prefState.isMobile) {
|
||||
store.dispatch(UpdateCurrentRoute(PaymentViewScreen.route));
|
||||
if (payment.isNew) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue