feat(abschluss): interne Notiz nach den Unterschriften abfragen
- Nach "Abschliessen" oeffnet sich ein Blatt "Interne Notiz" (optional, max. 2000 Zeichen). Ohne Eingabe genuegt ein Tipp auf "Ohne Notiz abschliessen"; "Zurueck zur Unterschrift" bricht nur das Abschliessen ab - Die Notiz reist im Abschluss-Aufruf mit (internalNote) und landet im Lieferbericht, nicht in den Kunden-Notizen - API-Client aus aktueller Backend-Spec neu generiert - Widget-Tests fuer das Blatt Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -1102,6 +1102,7 @@ class TourBloc extends Bloc<TourEvent, TourState> {
|
||||
paymentMethodId: event.paymentMethodId,
|
||||
actorCarId: event.actorCarId,
|
||||
paymentCollected: event.paymentCollected,
|
||||
internalNote: event.internalNote,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -225,6 +225,7 @@ class CompleteDelivery extends TourEvent {
|
||||
this.paymentMethodId,
|
||||
this.actorCarId,
|
||||
this.paymentCollected = false,
|
||||
this.internalNote,
|
||||
});
|
||||
|
||||
final String deliveryId;
|
||||
@ -242,6 +243,10 @@ class CompleteDelivery extends TourEvent {
|
||||
/// Fahrer hat das Vor-Ort-Inkasso (Bar/EC) des offenen Betrags bestätigt.
|
||||
/// `false`, wenn kein Inkasso anfiel (offen == 0 oder „Auf Rechnung").
|
||||
final bool paymentCollected;
|
||||
|
||||
/// Optionale interne Notiz des Fahrers (nach den Unterschriften erfasst,
|
||||
/// nur für den Lieferbericht). `null` = keine.
|
||||
final String? internalNote;
|
||||
}
|
||||
|
||||
/// Legt eine neue (Text- oder Bild-)Notiz an einer Lieferung an. Aktuell
|
||||
|
||||
@ -422,6 +422,7 @@ class _BottomNav extends StatelessWidget {
|
||||
acknowledgedNoteIds: result.acknowledgedNoteIds,
|
||||
paymentMethodId: payment?.paymentMethodId,
|
||||
paymentCollected: payment?.isCollectedOnSite ?? false,
|
||||
internalNote: result.internalNote,
|
||||
),
|
||||
);
|
||||
Navigator.of(routeContext).pop();
|
||||
|
||||
@ -7,6 +7,7 @@ import 'package:signature/signature.dart';
|
||||
import 'package:hl_lieferservice/domain/entity/delivery.dart';
|
||||
import 'package:hl_lieferservice/domain/entity/delivery_note.dart';
|
||||
import 'package:hl_lieferservice/domain/entity/tour_details.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/presentation/widget/internal_note_sheet.dart';
|
||||
|
||||
/// Daten, die der Abschluss-Flow an den Aufrufer zurückgibt: beide
|
||||
/// Unterschriften als PNG plus die dokumentierten Bestätigungen des Kunden.
|
||||
@ -17,6 +18,7 @@ class SignatureResult {
|
||||
required this.receiptConfirmed,
|
||||
required this.notesAcknowledged,
|
||||
required this.acknowledgedNoteIds,
|
||||
this.internalNote,
|
||||
});
|
||||
|
||||
final Uint8List customerSignaturePng;
|
||||
@ -24,6 +26,10 @@ class SignatureResult {
|
||||
final bool receiptConfirmed;
|
||||
final bool notesAcknowledged;
|
||||
final List<String> acknowledgedNoteIds;
|
||||
|
||||
/// Optionale interne Notiz des Fahrers, abgefragt nach beiden
|
||||
/// Unterschriften. `null` = keine.
|
||||
final String? internalNote;
|
||||
}
|
||||
|
||||
/// Mehrstufiger Unterschrift-Flow zum Abschließen einer Lieferung.
|
||||
@ -34,7 +40,8 @@ class SignatureResult {
|
||||
/// Stufe 1 (Kunde): sieht die Anmerkungen zur Lieferung, hakt zwei
|
||||
/// Bestätigungen ab (Anmerkungen-Kenntnisnahme — nur Pflicht, wenn Notizen
|
||||
/// vorhanden; Empfangsbestätigung — immer Pflicht) und unterschreibt.
|
||||
/// Stufe 2 (Fahrer): unterschreibt.
|
||||
/// Stufe 2 (Fahrer): unterschreibt. Danach fragt ein Blatt optional eine
|
||||
/// interne Notiz ab (nur für den Lieferbericht, nicht für den Kunden).
|
||||
///
|
||||
/// Erst nach beiden Unterschriften ruft die View [onSigned] mit dem
|
||||
/// vollständigen [SignatureResult] auf — der Aufrufer triggert dann den
|
||||
@ -133,6 +140,11 @@ class _SignatureViewState extends State<SignatureView> {
|
||||
final customerPng = await _customerController.toPngBytes();
|
||||
final driverPng = await _driverController.toPngBytes();
|
||||
if (customerPng == null || driverPng == null) return;
|
||||
if (!mounted) return;
|
||||
// Nach beiden Unterschriften: optional interne Notiz. „Zurück" im
|
||||
// Blatt bricht nur das Abschließen ab, die Unterschriften bleiben.
|
||||
final decision = await showInternalNoteSheet(context);
|
||||
if (decision == null || !mounted) return;
|
||||
widget.onSigned(
|
||||
SignatureResult(
|
||||
customerSignaturePng: customerPng,
|
||||
@ -141,6 +153,7 @@ class _SignatureViewState extends State<SignatureView> {
|
||||
notesAcknowledged: _notesEmpty ? false : _notesAccepted,
|
||||
acknowledgedNoteIds:
|
||||
_notesEmpty ? const [] : _notes.map((n) => n.id).toList(),
|
||||
internalNote: decision.note,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -0,0 +1,145 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Entscheidung im Blatt „Interne Notiz". `null` als Ergebnis von
|
||||
/// [showInternalNoteSheet] heißt: zurück zur Unterschrift, nichts abschließen.
|
||||
class InternalNoteDecision {
|
||||
const InternalNoteDecision(this.note);
|
||||
|
||||
/// Getrimmter Text oder `null` = ohne Notiz abschließen.
|
||||
final String? note;
|
||||
}
|
||||
|
||||
/// Maximale Länge — deckungsgleich mit dem Backend (2000 Zeichen).
|
||||
const int internalNoteMaxLength = 2000;
|
||||
|
||||
/// Fragt nach beiden Unterschriften optional eine interne Notiz ab.
|
||||
///
|
||||
/// Ohne Eingabe ist der große Button „Ohne Notiz abschließen" — der Fahrer
|
||||
/// braucht also nur einen Tipp, wenn er nichts notieren will. Die Notiz ist
|
||||
/// nur für interne Zwecke (Lieferbericht) und nicht Teil der Bestätigung
|
||||
/// durch den Kunden.
|
||||
Future<InternalNoteDecision?> showInternalNoteSheet(BuildContext context) {
|
||||
return showModalBottomSheet<InternalNoteDecision>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
useSafeArea: true,
|
||||
isDismissible: false,
|
||||
enableDrag: false,
|
||||
builder: (_) => const _InternalNoteSheet(),
|
||||
);
|
||||
}
|
||||
|
||||
class _InternalNoteSheet extends StatefulWidget {
|
||||
const _InternalNoteSheet();
|
||||
|
||||
@override
|
||||
State<_InternalNoteSheet> createState() => _InternalNoteSheetState();
|
||||
}
|
||||
|
||||
class _InternalNoteSheetState extends State<_InternalNoteSheet> {
|
||||
final TextEditingController _controller = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Button-Label hängt vom Text ab („Ohne" vs. „Mit Notiz").
|
||||
_controller.addListener(() => setState(() {}));
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
String? get _note {
|
||||
final text = _controller.text.trim();
|
||||
return text.isEmpty ? null : text;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final hasNote = _note != null;
|
||||
return Padding(
|
||||
// Tastatur schiebt das Blatt hoch, statt die Buttons zu verdecken.
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(context).viewInsets.bottom,
|
||||
),
|
||||
// Unten Abstand zur System-Navigationsleiste, sonst liegt
|
||||
// „Zurück zur Unterschrift" darunter.
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.fromLTRB(20, 20, 20, 12),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.sticky_note_2_outlined,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
'Interne Notiz',
|
||||
style: theme.textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
'Optional. Nur für interne Zwecke, der Kunde sieht sie nicht. '
|
||||
'Die Notiz erscheint im Lieferbericht.',
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: _controller,
|
||||
minLines: 3,
|
||||
maxLines: 6,
|
||||
maxLength: internalNoteMaxLength,
|
||||
textCapitalization: TextCapitalization.sentences,
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'z. B. Kunde wünscht Rückruf wegen Montage',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
FilledButton.icon(
|
||||
style: FilledButton.styleFrom(
|
||||
minimumSize: const Size.fromHeight(56),
|
||||
textStyle: const TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
onPressed:
|
||||
() =>
|
||||
Navigator.of(context).pop(InternalNoteDecision(_note)),
|
||||
icon: const Icon(Icons.check),
|
||||
label: Text(
|
||||
hasNote ? 'Mit Notiz abschließen' : 'Ohne Notiz abschließen',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
minimumSize: const Size.fromHeight(44),
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('Zurück zur Unterschrift'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user