completionCheck function

CompletionCheck completionCheck({
  1. required KeckPaymentMethod paymentMethod,
  2. required int dueCents,
  3. required int? tenderedCents,
  4. required bool changeEnabled,
  5. required bool cartEmpty,
})

Darf abgeschlossen werden? Bar mit Rückgeld-Rechnung braucht genug Gegebenes.

Implementation

CompletionCheck completionCheck({
  required KeckPaymentMethod paymentMethod,
  required int dueCents,
  required int? tenderedCents,
  required bool changeEnabled,
  required bool cartEmpty,
}) {
  if (cartEmpty) {
    return const CompletionCheck(
      ready: false,
      reason: 'Noch nichts erfasst — bitte zuerst eine Position aufnehmen.',
    );
  }
  if (paymentMethod == KeckPaymentMethod.cash && changeEnabled && tenderedCents != null && tenderedCents < dueCents) {
    return const CompletionCheck(ready: false, reason: 'Gegeben ist weniger als der Betrag.');
  }
  return const CompletionCheck(ready: true);
}