Compare commits
10 Commits
7c362549ee
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| f12ad5d3c0 | |||
| 8b1b35b374 | |||
| 7e345bd71b | |||
| 4c6bef6897 | |||
| 6d2f496700 | |||
| 446cf73347 | |||
| 9ec3bba047 | |||
| 178edfdeed | |||
| 16648240cd | |||
| 3a937c317d |
@ -17,7 +17,7 @@
|
||||
<application
|
||||
android:label="Holzleitner Auslieferung"
|
||||
android:name="${applicationName}"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:icon="@mipmap/launcher_icon"
|
||||
android:networkSecurityConfig="@xml/network_security_config">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
|
||||
BIN
android/app/src/main/res/mipmap-hdpi/launcher_icon.png
Normal file
|
After Width: | Height: | Size: 7.1 KiB |
BIN
android/app/src/main/res/mipmap-mdpi/launcher_icon.png
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
android/app/src/main/res/mipmap-xhdpi/launcher_icon.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
android/app/src/main/res/mipmap-xxhdpi/launcher_icon.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
android/app/src/main/res/mipmap-xxxhdpi/launcher_icon.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
@ -540,7 +540,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
@ -597,7 +597,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
|
||||
@ -1,122 +1 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-20x20@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-20x20@3x.png",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-29x29@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-29x29@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-29x29@3x.png",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-40x40@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-40x40@3x.png",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "60x60",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-60x60@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "60x60",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-60x60@3x.png",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-20x20@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-20x20@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-29x29@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-29x29@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-40x40@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-40x40@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "76x76",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-76x76@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "76x76",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-76x76@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "83.5x83.5",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-83.5x83.5@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "1024x1024",
|
||||
"idiom" : "ios-marketing",
|
||||
"filename" : "Icon-App-1024x1024@1x.png",
|
||||
"scale" : "1x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
{"images":[{"size":"20x20","idiom":"iphone","filename":"Icon-App-20x20@2x.png","scale":"2x"},{"size":"20x20","idiom":"iphone","filename":"Icon-App-20x20@3x.png","scale":"3x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@1x.png","scale":"1x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@2x.png","scale":"2x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@3x.png","scale":"3x"},{"size":"40x40","idiom":"iphone","filename":"Icon-App-40x40@2x.png","scale":"2x"},{"size":"40x40","idiom":"iphone","filename":"Icon-App-40x40@3x.png","scale":"3x"},{"size":"57x57","idiom":"iphone","filename":"Icon-App-57x57@1x.png","scale":"1x"},{"size":"57x57","idiom":"iphone","filename":"Icon-App-57x57@2x.png","scale":"2x"},{"size":"60x60","idiom":"iphone","filename":"Icon-App-60x60@2x.png","scale":"2x"},{"size":"60x60","idiom":"iphone","filename":"Icon-App-60x60@3x.png","scale":"3x"},{"size":"20x20","idiom":"ipad","filename":"Icon-App-20x20@1x.png","scale":"1x"},{"size":"20x20","idiom":"ipad","filename":"Icon-App-20x20@2x.png","scale":"2x"},{"size":"29x29","idiom":"ipad","filename":"Icon-App-29x29@1x.png","scale":"1x"},{"size":"29x29","idiom":"ipad","filename":"Icon-App-29x29@2x.png","scale":"2x"},{"size":"40x40","idiom":"ipad","filename":"Icon-App-40x40@1x.png","scale":"1x"},{"size":"40x40","idiom":"ipad","filename":"Icon-App-40x40@2x.png","scale":"2x"},{"size":"50x50","idiom":"ipad","filename":"Icon-App-50x50@1x.png","scale":"1x"},{"size":"50x50","idiom":"ipad","filename":"Icon-App-50x50@2x.png","scale":"2x"},{"size":"72x72","idiom":"ipad","filename":"Icon-App-72x72@1x.png","scale":"1x"},{"size":"72x72","idiom":"ipad","filename":"Icon-App-72x72@2x.png","scale":"2x"},{"size":"76x76","idiom":"ipad","filename":"Icon-App-76x76@1x.png","scale":"1x"},{"size":"76x76","idiom":"ipad","filename":"Icon-App-76x76@2x.png","scale":"2x"},{"size":"83.5x83.5","idiom":"ipad","filename":"Icon-App-83.5x83.5@2x.png","scale":"2x"},{"size":"1024x1024","idiom":"ios-marketing","filename":"Icon-App-1024x1024@1x.png","scale":"1x"}],"info":{"version":1,"author":"xcode"}}
|
||||
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 133 KiB |
|
Before Width: | Height: | Size: 295 B After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 406 B After Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 450 B After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 282 B After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 462 B After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 704 B After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 406 B After Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 586 B After Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 862 B After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 8.6 KiB |
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 862 B After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 6.7 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 762 B After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 14 KiB |
@ -73,15 +73,59 @@ class DeliveryDetail extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class _DeliveryDetailScaffold extends StatelessWidget {
|
||||
class _DeliveryDetailScaffold extends StatefulWidget {
|
||||
const _DeliveryDetailScaffold({required this.deliveryId});
|
||||
|
||||
final String deliveryId;
|
||||
|
||||
@override
|
||||
State<_DeliveryDetailScaffold> createState() =>
|
||||
_DeliveryDetailScaffoldState();
|
||||
}
|
||||
|
||||
class _DeliveryDetailScaffoldState extends State<_DeliveryDetailScaffold> {
|
||||
/// „Gearmt" = die Lieferung war während dieser Page-Session aktiv. Nur dann
|
||||
/// poppen wir bei `completed` automatisch zurück zur Übersicht. Öffnet der
|
||||
/// Fahrer eine bereits abgeschlossene Lieferung, bleibt `_armed == false`
|
||||
/// und die Page bleibt offen (kein ungewolltes Zurückspringen).
|
||||
bool _armed = false;
|
||||
bool _popped = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final s = context.read<TourBloc>().state;
|
||||
if (s is TourLoaded && _findDelivery(s.details)?.state == DeliveryState.active) {
|
||||
_armed = true;
|
||||
}
|
||||
}
|
||||
|
||||
Delivery? _findDelivery(TourDetails details) {
|
||||
for (final d in details.deliveries) {
|
||||
if (d.id == widget.deliveryId) return d;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Nach erfolgreichem Abschluss (aktiv → completed) zurück zur Übersicht.
|
||||
void _onTourState(BuildContext context, TourState state) {
|
||||
if (_popped || state is! TourLoaded) return;
|
||||
final d = _findDelivery(state.details);
|
||||
if (d == null) return;
|
||||
if (d.state == DeliveryState.active) {
|
||||
_armed = true;
|
||||
} else if (_armed && d.state == DeliveryState.completed) {
|
||||
_popped = true;
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return BlocBuilder<TourBloc, TourState>(
|
||||
return BlocListener<TourBloc, TourState>(
|
||||
listener: _onTourState,
|
||||
child: BlocBuilder<TourBloc, TourState>(
|
||||
builder: (context, tourState) {
|
||||
if (tourState is! TourLoaded) {
|
||||
return const Scaffold(
|
||||
@ -94,7 +138,9 @@ class _DeliveryDetailScaffold extends StatelessWidget {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Lieferung')),
|
||||
body: Center(
|
||||
child: Text('Lieferung $deliveryId nicht in der Tour gefunden.'),
|
||||
child: Text(
|
||||
'Lieferung ${widget.deliveryId} nicht in der Tour gefunden.',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -118,15 +164,9 @@ class _DeliveryDetailScaffold extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Delivery? _findDelivery(TourDetails details) {
|
||||
for (final d in details.deliveries) {
|
||||
if (d.id == deliveryId) return d;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Step-Header (Pills) ────────────────────────────────────────────────
|
||||
|
||||
@ -49,6 +49,24 @@ class StepArticles extends StatelessWidget {
|
||||
return (a.komponentenArtikelNr ?? '')
|
||||
.compareTo(b.komponentenArtikelNr ?? '');
|
||||
});
|
||||
|
||||
// Komponenten je Oberartikel (Artikelnummer des Parents → Komponenten).
|
||||
// Grundlage für E: Komponenten sind einzeln NICHT entfernbar — nur der
|
||||
// Oberartikel kann (ganzes Set) entfernt werden, was auf die Komponenten
|
||||
// kaskadiert.
|
||||
final componentsByParentNr = <String, List<DeliveryItem>>{};
|
||||
for (final it in items) {
|
||||
final pNr = it.parentArtikelNr;
|
||||
if (it.isComponent && pNr != null) {
|
||||
componentsByParentNr.putIfAbsent(pNr, () => []).add(it);
|
||||
}
|
||||
}
|
||||
List<DeliveryItem> componentsOf(DeliveryItem it) {
|
||||
final nr = details.articleOf(it.articleId)?.articleNumber;
|
||||
if (nr == null) return const [];
|
||||
return componentsByParentNr[nr] ?? const [];
|
||||
}
|
||||
|
||||
return ListView(
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 24),
|
||||
children: [
|
||||
@ -73,6 +91,7 @@ class StepArticles extends StatelessWidget {
|
||||
details: details,
|
||||
deliveryId: delivery.id,
|
||||
deliveryActive: delivery.state == DeliveryState.active,
|
||||
components: componentsOf(items[i]),
|
||||
),
|
||||
if (i < items.length - 1)
|
||||
const Divider(height: 1, indent: 16, endIndent: 16),
|
||||
@ -149,6 +168,7 @@ class _ArticleManagementRow extends StatelessWidget {
|
||||
required this.details,
|
||||
required this.deliveryId,
|
||||
required this.deliveryActive,
|
||||
this.components = const [],
|
||||
});
|
||||
|
||||
final DeliveryItem item;
|
||||
@ -156,6 +176,10 @@ class _ArticleManagementRow extends StatelessWidget {
|
||||
final String deliveryId;
|
||||
final bool deliveryActive;
|
||||
|
||||
/// Komponenten dieses Items, falls es ein Set-Oberartikel ist (sonst leer).
|
||||
/// Entfernen/Wiederherstellen kaskadiert auf diese Komponenten.
|
||||
final List<DeliveryItem> components;
|
||||
|
||||
Future<void> _openCreditDialog(
|
||||
BuildContext context, {
|
||||
required int remaining,
|
||||
@ -193,6 +217,68 @@ class _ArticleManagementRow extends StatelessWidget {
|
||||
));
|
||||
}
|
||||
|
||||
/// Entfernt eine Anzahl Sets über den Oberartikel und kaskadiert auf seine
|
||||
/// Komponenten. Der Mengen-Stepper bleibt erhalten — ein Set kann mehrfach
|
||||
/// bestellt sein (Oberartikel-Menge = Set-Anzahl). Die Komponenten werden
|
||||
/// **proportional** mitreduziert (Stückzahl je Set × entfernte Sets),
|
||||
/// geklemmt auf die jeweilige Restmenge. Einzelne Komponenten bleiben
|
||||
/// nicht direkt entfernbar — nur dieser Weg über den Oberartikel.
|
||||
Future<void> _openSetRemoveDialog(
|
||||
BuildContext context, {
|
||||
required int remaining,
|
||||
}) async {
|
||||
final tourBloc = context.read<TourBloc>();
|
||||
final actorCarId = _actorCarId(context);
|
||||
final result = await showReasonPickerSheet(
|
||||
context: context,
|
||||
title: 'Grund für das Entfernen',
|
||||
presets: ReasonCatalog.itemRemove,
|
||||
confirmLabel: 'Entfernen',
|
||||
maxQuantity: remaining,
|
||||
);
|
||||
if (result == null) return;
|
||||
final n = result.quantity ?? remaining;
|
||||
final parentRequired = item.requiredQuantity;
|
||||
|
||||
// Oberartikel um n Sets reduzieren.
|
||||
tourBloc.add(RemoveItem(
|
||||
deliveryItemId: item.id,
|
||||
reason: result.reason,
|
||||
actorCarId: actorCarId,
|
||||
quantity: n,
|
||||
saveReasonAsNote: true,
|
||||
));
|
||||
// Komponenten proportional mitreduzieren.
|
||||
for (final c in components) {
|
||||
final cRemaining = c.requiredQuantity - c.scanProgress.creditedQuantity;
|
||||
if (cRemaining <= 0) continue;
|
||||
final proportional = parentRequired > 0
|
||||
? (c.requiredQuantity * n / parentRequired).round()
|
||||
: cRemaining;
|
||||
final removeQty = proportional.clamp(0, cRemaining);
|
||||
if (removeQty <= 0) continue;
|
||||
tourBloc.add(RemoveItem(
|
||||
deliveryItemId: c.id,
|
||||
reason: result.reason,
|
||||
actorCarId: actorCarId,
|
||||
quantity: removeQty,
|
||||
// Grund nur einmal (am Oberartikel) als Notiz festhalten.
|
||||
saveReasonAsNote: false,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// Stellt das ganze Set wieder her (Oberartikel + Komponenten).
|
||||
void _restoreSet(BuildContext context) {
|
||||
final tourBloc = context.read<TourBloc>();
|
||||
final actorCarId = _actorCarId(context);
|
||||
tourBloc.add(UnremoveItem(deliveryItemId: item.id, actorCarId: actorCarId));
|
||||
for (final c in components) {
|
||||
tourBloc
|
||||
.add(UnremoveItem(deliveryItemId: c.id, actorCarId: actorCarId));
|
||||
}
|
||||
}
|
||||
|
||||
/// Holt die aktuelle Auto-ID aus dem CarSelectBloc — gleiche Konvention
|
||||
/// wie der Loading-Flow: das aktiv gewählte Fahrzeug ist der „Akteur"
|
||||
/// des Audit-Events. Falls (defensiv) noch keine Auswahl getroffen ist,
|
||||
@ -216,11 +302,27 @@ class _ArticleManagementRow extends StatelessWidget {
|
||||
final fullyRemoved = item.isRemoved; // Status == removed (voll gutgeschr.)
|
||||
final partiallyCredited = credited > 0 && !fullyRemoved;
|
||||
|
||||
// E: Komponenten eines Sets sind einzeln NICHT entfernbar; nur der
|
||||
// Oberartikel kann (ganzes Set) entfernt werden.
|
||||
final isComponent = item.isComponent;
|
||||
final hasComponents = components.isNotEmpty;
|
||||
|
||||
// Gate: scannbare Position muss `done` sein, sonst keine Gutschrift.
|
||||
final scannable = article?.scannable ?? false;
|
||||
final isDone = item.scanProgress.status == ScanStatus.done;
|
||||
final blockedByScan = scannable && !isDone && !fullyRemoved;
|
||||
final canCredit = deliveryActive && !blockedByScan && remaining > 0;
|
||||
// Beim Set zusätzlich: jede scanbare Komponente muss erst verladen sein,
|
||||
// sonst würde das Backend deren Entfernen ablehnen.
|
||||
final componentsBlocked = components.any((c) {
|
||||
final cArticle = details.articleOf(c.articleId);
|
||||
final cScannable = cArticle?.scannable ?? false;
|
||||
final cDone = c.scanProgress.status == ScanStatus.done;
|
||||
return cScannable && !cDone && !c.isRemoved;
|
||||
});
|
||||
final canCredit = deliveryActive &&
|
||||
!blockedByScan &&
|
||||
!componentsBlocked &&
|
||||
remaining > 0;
|
||||
|
||||
final Color avatarColor;
|
||||
final String avatarText;
|
||||
@ -285,18 +387,40 @@ class _ArticleManagementRow extends StatelessWidget {
|
||||
text: 'Erst scannen/verladen — dann Gutschrift möglich',
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
// E: Komponenten-Hinweis — einzeln nicht entfernbar.
|
||||
if (isComponent && deliveryActive && !fullyRemoved)
|
||||
_StatusLine(
|
||||
text: 'Nur über den Oberartikel entfernbar',
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
// Set-Oberartikel: blockiert, solange eine Komponente noch nicht
|
||||
// verladen ist.
|
||||
if (hasComponents &&
|
||||
componentsBlocked &&
|
||||
deliveryActive &&
|
||||
!fullyRemoved)
|
||||
_StatusLine(
|
||||
text: 'Erst alle Set-Teile verladen — dann ganzes Set entfernbar',
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
],
|
||||
),
|
||||
trailing: Row(
|
||||
// E: Komponenten haben KEINE eigenen Aktionen — Entfernen/Wiederherstellen
|
||||
// läuft ausschließlich über den Oberartikel (kaskadiert auf das Set).
|
||||
trailing: isComponent
|
||||
? null
|
||||
: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (credited > 0)
|
||||
IconButton(
|
||||
// Wiederherstellen nur bei aktiver Lieferung — bei
|
||||
// abgeschlossener/abgebrochener Lieferung gesperrt (greift auch
|
||||
// backend-seitig, hier zusätzlich in der UI).
|
||||
// abgeschlossener/abgebrochener Lieferung gesperrt (greift
|
||||
// auch backend-seitig, hier zusätzlich in der UI).
|
||||
tooltip: deliveryActive
|
||||
? 'Gutschrift zurücknehmen'
|
||||
? (hasComponents
|
||||
? 'Set wiederherstellen'
|
||||
: 'Gutschrift zurücknehmen')
|
||||
: 'Nur bei aktiver Lieferung',
|
||||
icon: Icon(
|
||||
Icons.restore,
|
||||
@ -304,15 +428,21 @@ class _ArticleManagementRow extends StatelessWidget {
|
||||
? theme.colorScheme.primary
|
||||
: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
onPressed: deliveryActive ? () => _restoreAll(context) : null,
|
||||
onPressed: deliveryActive
|
||||
? () => hasComponents
|
||||
? _restoreSet(context)
|
||||
: _restoreAll(context)
|
||||
: null,
|
||||
),
|
||||
if (!fullyRemoved)
|
||||
IconButton.outlined(
|
||||
tooltip: blockedByScan
|
||||
tooltip: (blockedByScan || componentsBlocked)
|
||||
? 'Erst scannen/verladen'
|
||||
: (!deliveryActive
|
||||
? 'Nur bei aktiver Lieferung'
|
||||
: 'Gutschrift / entfernen'),
|
||||
: (hasComponents
|
||||
? 'Ganzes Set entfernen'
|
||||
: 'Gutschrift / entfernen')),
|
||||
style: ButtonStyle(
|
||||
backgroundColor: WidgetStatePropertyAll(
|
||||
canCredit
|
||||
@ -321,7 +451,9 @@ class _ArticleManagementRow extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
onPressed: canCredit
|
||||
? () => _openCreditDialog(context, remaining: remaining)
|
||||
? () => hasComponents
|
||||
? _openSetRemoveDialog(context, remaining: remaining)
|
||||
: _openCreditDialog(context, remaining: remaining)
|
||||
: null,
|
||||
icon: Icon(
|
||||
Icons.delete,
|
||||
|
||||
@ -9,6 +9,9 @@ import 'package:hl_lieferservice/domain/entity/delivery_item.dart';
|
||||
import 'package:hl_lieferservice/domain/entity/tour_details.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/bloc/tour_bloc.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/bloc/tour_event.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/bloc/workflow_bloc.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/bloc/workflow_event.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/bloc/workflow_state.dart';
|
||||
|
||||
/// Step 1 — Informationen zur Lieferung.
|
||||
///
|
||||
@ -716,7 +719,19 @@ class _ArticleList extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
return Card(
|
||||
// Hat sich bei mindestens einem Artikel die tatsächliche Menge geändert
|
||||
// (entfernt oder teilweise gutgeschrieben)? Dann ein Banner mit Verweis
|
||||
// auf Step 3 „Artikel", wo die Änderungen verwaltet werden.
|
||||
final anyChanged = items.any(_quantityChanged);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (anyChanged) ...[
|
||||
const _QuantityChangedBanner(),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
Card(
|
||||
margin: EdgeInsets.zero,
|
||||
child: Column(
|
||||
children: [
|
||||
@ -727,6 +742,55 @@ class _ArticleList extends StatelessWidget {
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// `true`, wenn die tatsächlich auszuliefernde Menge von der ursprünglich
|
||||
/// bestellten abweicht — also die Position ganz entfernt oder teilweise
|
||||
/// gutgeschrieben wurde.
|
||||
bool _quantityChanged(DeliveryItem item) =>
|
||||
item.isRemoved || item.scanProgress.creditedQuantity > 0;
|
||||
|
||||
/// Tappbares Banner über der Artikelliste: weist darauf hin, dass sich die
|
||||
/// Menge mindestens eines Artikels geändert hat, und springt zu Step 3
|
||||
/// („Artikel"), wo die Änderungen sichtbar/verwaltbar sind.
|
||||
class _QuantityChangedBanner extends StatelessWidget {
|
||||
const _QuantityChangedBanner();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final amber = Colors.amber.shade800;
|
||||
return InkWell(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
onTap: () => context
|
||||
.read<DeliveryWorkflowBloc>()
|
||||
.add(const WorkflowGoToStep(WorkflowStep.articles)),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: amber.withValues(alpha: 0.10),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: amber.withValues(alpha: 0.4)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.edit_note, color: amber),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Bei mindestens einem Artikel hat sich die Menge geändert. '
|
||||
'Details unter Schritt 3 „Artikel".',
|
||||
style: theme.textTheme.bodySmall?.copyWith(color: amber),
|
||||
),
|
||||
),
|
||||
Icon(Icons.chevron_right, color: amber, size: 20),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -744,6 +808,8 @@ class _ArticleRow extends StatelessWidget {
|
||||
final warehouse = details.warehouseOf(item.warehouseId);
|
||||
final isScannable = article?.scannable ?? false;
|
||||
final removed = item.isRemoved;
|
||||
// Menge tatsächlich verändert (entfernt oder teilweise gutgeschrieben)?
|
||||
final changed = _quantityChanged(item);
|
||||
|
||||
return ListTile(
|
||||
// Komponenten um eine Stufe eingerückt (gehören zum Oberartikel darüber).
|
||||
@ -756,6 +822,8 @@ class _ArticleRow extends StatelessWidget {
|
||||
foregroundColor: removed
|
||||
? theme.colorScheme.onSurfaceVariant
|
||||
: theme.colorScheme.onPrimary,
|
||||
// Bewusst die URSPRÜNGLICH bestellte Menge (requiredQuantity), nicht
|
||||
// die reduzierte — Änderungen werden separat als Hinweis ausgewiesen.
|
||||
child: Text(
|
||||
'${item.requiredQuantity}×',
|
||||
style: const TextStyle(fontSize: 12, fontWeight: FontWeight.bold),
|
||||
@ -769,7 +837,10 @@ class _ArticleRow extends StatelessWidget {
|
||||
color: removed ? theme.colorScheme.onSurfaceVariant : null,
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
[
|
||||
article?.articleNumber ?? item.articleId,
|
||||
if (warehouse != null) warehouse.name,
|
||||
@ -783,6 +854,31 @@ class _ArticleRow extends StatelessWidget {
|
||||
decoration: removed ? TextDecoration.lineThrough : null,
|
||||
),
|
||||
),
|
||||
if (changed)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 2),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.edit_note, size: 14, color: Colors.amber.shade800),
|
||||
const SizedBox(width: 4),
|
||||
Flexible(
|
||||
child: Text(
|
||||
removed
|
||||
? 'Menge geändert: entfernt (Ursprung ${item.requiredQuantity}×)'
|
||||
: 'Menge geändert: jetzt ${item.deliveredQuantity}× '
|
||||
'(Ursprung ${item.requiredQuantity}×)',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.amber.shade800,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
trailing: isScannable
|
||||
? Text(
|
||||
'${item.scanProgress.scannedQuantity} / ${item.requiredQuantity}',
|
||||
|
||||
@ -56,6 +56,7 @@ class StepSummary extends StatelessWidget {
|
||||
_PaymentMethodPicker(
|
||||
delivery: delivery,
|
||||
overrideId: wfState.paymentMethodOverrideId,
|
||||
credit: details.creditOf(delivery.id),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const _SignHint(),
|
||||
@ -213,6 +214,17 @@ class _DeliveredRow extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// Offener Betrag der Lieferung in Euro: Warenwert (Σ Stückpreis × gelieferte
|
||||
/// Menge) − Anzahlung − Gutschrift, nie negativ. Einzige Quelle dieser Formel —
|
||||
/// genutzt von der Zahlungs-Übersicht UND der Zahlungsmethoden-Auswahl.
|
||||
double _openAmount(Delivery delivery, DeliveryCredit? credit) {
|
||||
final creditEuros = (credit?.amountCents ?? 0) / 100.0;
|
||||
final warenwert =
|
||||
delivery.items.fold<double>(0, (acc, item) => acc + item.lineTotal);
|
||||
return (warenwert - delivery.prepaidAmount - creditEuros)
|
||||
.clamp(0.0, double.infinity);
|
||||
}
|
||||
|
||||
class _PaymentSummary extends StatelessWidget {
|
||||
const _PaymentSummary({required this.delivery, required this.credit});
|
||||
|
||||
@ -222,15 +234,13 @@ class _PaymentSummary extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
// Exakt aus Cent (nicht gerundet) — Gutschrift kann Cent-Beträge haben.
|
||||
final creditEuros = (credit?.amountCents ?? 0) / 100.0;
|
||||
// Warenwert = Σ Stückpreis × ausgelieferte Menge (entfernte/teil-entfernte
|
||||
// Positionen fallen automatisch raus).
|
||||
final warenwert = delivery.items
|
||||
.fold<double>(0, (acc, item) => acc + item.lineTotal);
|
||||
// Offener Betrag = Warenwert − Anzahlung − Gutschrift, nie negativ.
|
||||
final open = (warenwert - delivery.prepaidAmount - creditEuros)
|
||||
.clamp(0.0, double.infinity);
|
||||
// Offener Betrag über den gemeinsamen Helper (gleiche Formel wie die
|
||||
// Zahlungsmethoden-Auswahl).
|
||||
final open = _openAmount(delivery, credit);
|
||||
return Card(
|
||||
margin: EdgeInsets.zero,
|
||||
child: Padding(
|
||||
@ -349,10 +359,12 @@ class _PaymentMethodPicker extends StatelessWidget {
|
||||
const _PaymentMethodPicker({
|
||||
required this.delivery,
|
||||
required this.overrideId,
|
||||
required this.credit,
|
||||
});
|
||||
|
||||
final Delivery delivery;
|
||||
final String? overrideId;
|
||||
final DeliveryCredit? credit;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -407,6 +419,11 @@ class _PaymentMethodPicker extends StatelessWidget {
|
||||
// abgeschlossener/abgebrochener/pausierter Lieferung zeigt das
|
||||
// Dropdown den gewählten Stand, ist aber gesperrt.
|
||||
final active = delivery.state == DeliveryState.active;
|
||||
// Steht kein offener Betrag mehr aus (vollständig vorab bezahlt
|
||||
// oder per Gutschrift ausgeglichen), ist keine Zahlungsweise zu
|
||||
// wählen → Auswahl deaktivieren.
|
||||
final hasOpenAmount = _openAmount(delivery, credit) > 0;
|
||||
final editable = active && hasOpenAmount;
|
||||
return Card(
|
||||
margin: EdgeInsets.zero,
|
||||
child: Padding(
|
||||
@ -428,7 +445,7 @@ class _PaymentMethodPicker extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
// `null` deaktiviert das Dropdown (Flutter-Konvention).
|
||||
onChanged: active
|
||||
onChanged: editable
|
||||
? (newId) {
|
||||
if (newId == null) return;
|
||||
context.read<DeliveryWorkflowBloc>().add(
|
||||
@ -447,27 +464,15 @@ class _PaymentMethodPicker extends StatelessWidget {
|
||||
),
|
||||
if (!active) ...[
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.lock_outline,
|
||||
size: 16,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Lieferung abgeschlossen — Zahlungsmethode nicht '
|
||||
const _PickerHint(
|
||||
text: 'Lieferung abgeschlossen — Zahlungsmethode nicht '
|
||||
'mehr änderbar.',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall
|
||||
?.copyWith(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
] else if (!hasOpenAmount) ...[
|
||||
const SizedBox(height: 8),
|
||||
const _PickerHint(
|
||||
text: 'Keine Zahlung mehr offen (bereits bezahlt) — '
|
||||
'Auswahl der Zahlungsweise nicht erforderlich.',
|
||||
),
|
||||
],
|
||||
],
|
||||
@ -479,6 +484,31 @@ class _PaymentMethodPicker extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// Dezenter Sperr-/Info-Hinweis unter dem Zahlungsmethoden-Dropdown
|
||||
/// (Schloss-Icon + Text in gedämpfter Farbe).
|
||||
class _PickerHint extends StatelessWidget {
|
||||
const _PickerHint({required this.text});
|
||||
|
||||
final String text;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final muted = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
return Row(
|
||||
children: [
|
||||
Icon(Icons.lock_outline, size: 16, color: muted),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
text,
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(color: muted),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SignHint extends StatelessWidget {
|
||||
const _SignHint();
|
||||
|
||||
|
||||
@ -157,6 +157,15 @@ class _DeliverySortPageState extends State<DeliverySortPage> {
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
// Erneut die heutige Tour vom Backend laden. `LoadTour` zeigt
|
||||
// währenddessen den Lade-Branch (Spinner) und landet danach wieder
|
||||
// hier (TourEmpty) oder in der sortierbaren Lieferungsliste.
|
||||
FilledButton.tonalIcon(
|
||||
onPressed: () => context.read<TourBloc>().add(const LoadTour()),
|
||||
icon: const Icon(Icons.refresh),
|
||||
label: const Text('Neu laden'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@ -227,16 +236,34 @@ class _DeliverySortPageState extends State<DeliverySortPage> {
|
||||
// „Keine Tour heute"- oder Lade-Screen fest, ohne Zugriff auf
|
||||
// Einstellungen / Logout.
|
||||
if (state is TourEmpty) {
|
||||
// Auch im Leerzustand die Steps-AppBar (PhaseStepper, primary)
|
||||
// zeigen — nur die mittige Nachricht bleibt. So bleibt die Phasen-
|
||||
// Navigation sichtbar und die Optik konsistent zum geladenen Zustand.
|
||||
return Scaffold(
|
||||
drawer: const HomeAppDrawer(),
|
||||
appBar: AppBar(title: const Text('Sortieren')),
|
||||
appBar: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(140),
|
||||
child: PhaseStepper(
|
||||
currentPhase: DeliveryPhase.sortieren,
|
||||
carId: widget.selectedCarId,
|
||||
),
|
||||
),
|
||||
body: _emptyState(),
|
||||
);
|
||||
}
|
||||
if (state is! TourLoaded) {
|
||||
// Lade-Zwischenzustand (auch beim 'Neu laden') mit derselben
|
||||
// PhaseStepper-AppBar — sonst flackert die Leiste kurz auf die
|
||||
// schlichte AppBar zurück.
|
||||
return Scaffold(
|
||||
drawer: const HomeAppDrawer(),
|
||||
appBar: AppBar(title: const Text('Sortieren')),
|
||||
appBar: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(140),
|
||||
child: PhaseStepper(
|
||||
currentPhase: DeliveryPhase.sortieren,
|
||||
carId: widget.selectedCarId,
|
||||
),
|
||||
),
|
||||
body: const Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
}
|
||||
|
||||
@ -11,9 +11,12 @@ import 'package:hl_lieferservice/feature/car_selection/bloc/bloc.dart';
|
||||
import 'package:hl_lieferservice/feature/car_selection/bloc/state.dart';
|
||||
import 'package:hl_lieferservice/feature/cars/bloc/cars_bloc.dart';
|
||||
import 'package:hl_lieferservice/feature/cars/bloc/cars_state.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/bloc/phase_bloc.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/bloc/phase_event.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/bloc/tour_bloc.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/bloc/tour_event.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/bloc/tour_state.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/model/delivery_phase.dart';
|
||||
import 'package:hl_lieferservice/feature/loading/widget/reason_catalog.dart';
|
||||
import 'package:hl_lieferservice/feature/loading/widget/reason_picker_sheet.dart';
|
||||
import 'package:hl_lieferservice/widget/scanner/article_scanner_stripe.dart';
|
||||
@ -57,6 +60,10 @@ class _LoadingCustomerPageState extends State<LoadingCustomerPage> {
|
||||
/// vom (lebenslang einen) Scanner für die Barcode-Auflösung benutzt.
|
||||
int _currentIndex = 0;
|
||||
|
||||
/// Verhindert, dass der „Alles gescannt"-Abschluss-Dialog mehrfach erscheint.
|
||||
/// Wird zurückgesetzt, sobald wieder etwas zu beladen offen ist.
|
||||
bool _completionPromptShown = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -331,13 +338,78 @@ class _LoadingCustomerPageState extends State<LoadingCustomerPage> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Reagiert auf jedes TourBloc-Update: Sind ALLE eigenen, **aktiven**
|
||||
/// Lieferungen im Standardlager fertig beladen (dieselbe Bedingung wie der
|
||||
/// „Auslieferungs-Phase starten"-Gate der Beladen-Übersicht)? Genau beim
|
||||
/// Übergang „noch offen → alles fertig" (also nach dem letzten Pflicht-Scan)
|
||||
/// erscheint einmalig der Abschluss-Dialog.
|
||||
void _maybePromptLoadingComplete(
|
||||
BuildContext context,
|
||||
TourState state,
|
||||
String carId,
|
||||
) {
|
||||
if (state is! TourLoaded) return;
|
||||
final deliveries = _ownInLoadingOrder(context, state.details, carId);
|
||||
final active =
|
||||
deliveries.where((d) => d.state == DeliveryState.active).toList();
|
||||
final allDone = active.isNotEmpty &&
|
||||
active.every(state.details.standardWarehouseLoadingDone);
|
||||
|
||||
if (!allDone) {
|
||||
// Wieder etwas offen (Item entfernt/zurückgesetzt) → Dialog darf erneut.
|
||||
_completionPromptShown = false;
|
||||
return;
|
||||
}
|
||||
if (_completionPromptShown) return;
|
||||
_completionPromptShown = true;
|
||||
_showLoadingCompleteDialog(carId);
|
||||
}
|
||||
|
||||
/// Abschluss-Dialog der Beladung: weist darauf hin, dass alles gescannt ist,
|
||||
/// und fragt, ob die Auslieferung gestartet werden soll. Bei „Ja" wird die
|
||||
/// Phase auf `ausliefern` gesetzt (PhaseBloc, app-weit) und der Scanner
|
||||
/// geschlossen — der Phasen-Router (`home`) zeigt dann die Auslieferungs-
|
||||
/// Übersicht. „Später" schließt nur den Dialog (Start wie bisher über die
|
||||
/// Übersicht möglich).
|
||||
Future<void> _showLoadingCompleteDialog(String carId) async {
|
||||
final start = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
icon: const Icon(Icons.check_circle, color: Colors.green, size: 40),
|
||||
title: const Text('Alles gescannt'),
|
||||
content: const Text(
|
||||
'Alle zu beladenden Artikel sind gescannt. '
|
||||
'Möchten Sie die Auslieferung starten?',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(ctx).pop(false),
|
||||
child: const Text('Später'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.of(ctx).pop(true),
|
||||
child: const Text('Auslieferung starten'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (start != true || !mounted) return;
|
||||
context
|
||||
.read<PhaseBloc>()
|
||||
.add(PhaseSet(carId: carId, phase: DeliveryPhase.ausliefern));
|
||||
// Scanner schließen → zurück zum Phasen-Router, der nun 'ausliefern' zeigt.
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<CarSelectBloc, CarSelectState>(
|
||||
builder: (context, carState) {
|
||||
final carId =
|
||||
carState is CarSelectComplete ? carState.selectedCar.id : '';
|
||||
return BlocBuilder<TourBloc, TourState>(
|
||||
return BlocConsumer<TourBloc, TourState>(
|
||||
listener: (context, tourState) =>
|
||||
_maybePromptLoadingComplete(context, tourState, carId),
|
||||
builder: (context, tourState) {
|
||||
if (tourState is! TourLoaded) {
|
||||
return const Scaffold(
|
||||
@ -463,6 +535,65 @@ class _CustomerBody extends StatelessWidget {
|
||||
// erkennt. Liegen außerhalb von `groups` (die nur scanbare Items führen).
|
||||
final serviceItems = details.nonScannableItems(delivery).toList();
|
||||
|
||||
// ── Set-Köpfe (Parent-Komponenten) immer mit ihrem Set anzeigen ──────
|
||||
// Ein nicht-scanbarer Set-Kopf (Stücklisten-Oberartikel, z. B. als
|
||||
// Pauschale geführt) soll NICHT isoliert unter „Dienstleistungen"
|
||||
// erscheinen, sondern als Kopf über seinen (scanbaren) Komponenten in der
|
||||
// jeweiligen Lagergruppe. Ein Item ist Set-Kopf, wenn seine Artikelnummer
|
||||
// von einer Komponente als parentArtikelNr referenziert wird.
|
||||
String? artNrOf(DeliveryItem it) =>
|
||||
details.articleOf(it.articleId)?.articleNumber;
|
||||
// Alle Set-Köpfe (Parent-Artikel): ein Item, dessen Artikelnummer von einer
|
||||
// Komponente als parentArtikelNr referenziert wird. Für nicht-scanbare
|
||||
// Set-Köpfe wird der „kein Scanvorgang notwendig"-Hinweis unterdrückt.
|
||||
final componentParentNrs = delivery.items
|
||||
.where((it) => it.isComponent)
|
||||
.map((it) => it.parentArtikelNr)
|
||||
.whereType<String>()
|
||||
.toSet();
|
||||
final setParentIds = delivery.items
|
||||
.where((it) {
|
||||
final nr = artNrOf(it);
|
||||
return nr != null && componentParentNrs.contains(nr);
|
||||
})
|
||||
.map((it) => it.id)
|
||||
.toSet();
|
||||
// Set-Kopf „komplett": alle scanbaren, nicht entfernten Komponenten fertig.
|
||||
// Dann wird auch der (selbst nicht scanbare) Kopf grün dargestellt.
|
||||
bool setParentComplete(DeliveryItem parent) {
|
||||
final nr = artNrOf(parent);
|
||||
if (nr == null) return false;
|
||||
final comps = delivery.items.where((c) =>
|
||||
c.parentArtikelNr == nr &&
|
||||
!c.isRemoved &&
|
||||
(details.articleOf(c.articleId)?.scannable ?? false));
|
||||
return comps.isNotEmpty && comps.every((c) => c.isDone);
|
||||
}
|
||||
// Set-Köpfe je Lagergruppe (warehouseId → einzuhängende Köpfe) +
|
||||
// gesammelte IDs, um sie aus der Dienstleistungs-Sektion zu entfernen.
|
||||
final injectedParentsByWarehouseId = <String, List<DeliveryItem>>{};
|
||||
final injectedParentIds = <String>{};
|
||||
for (final group in groups) {
|
||||
final groupParentNrs = group.items
|
||||
.where((it) => it.isComponent)
|
||||
.map((it) => it.parentArtikelNr)
|
||||
.whereType<String>()
|
||||
.toSet();
|
||||
if (groupParentNrs.isEmpty) continue;
|
||||
final parents = serviceItems
|
||||
.where((s) => groupParentNrs.contains(artNrOf(s)))
|
||||
.toList();
|
||||
if (parents.isEmpty) continue;
|
||||
injectedParentsByWarehouseId[group.warehouse.id] = parents;
|
||||
injectedParentIds.addAll(parents.map((p) => p.id));
|
||||
}
|
||||
// Set-Köpfe, die in eine Gruppe eingehängt wurden, nicht doppelt unter
|
||||
// „Dienstleistungen" zeigen. Set-Köpfe ohne scanbare Komponenten (kommen
|
||||
// hier nicht vor) blieben weiterhin in der Liste.
|
||||
final serviceItemsView = serviceItems
|
||||
.where((s) => !injectedParentIds.contains(s.id))
|
||||
.toList();
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
// Header bekommt einen eigenen, leicht abgehobenen Hintergrund
|
||||
@ -555,26 +686,36 @@ class _CustomerBody extends StatelessWidget {
|
||||
warehouse: group.warehouse,
|
||||
items: group.items,
|
||||
),
|
||||
for (final item in _parentFirst(group.items))
|
||||
// Nicht-scanbare Set-Köpfe dieser Gruppe vor ihre Komponenten
|
||||
// einhängen; `_parentFirst` ordnet Kopf vor Komponenten.
|
||||
for (final item in _parentFirst([
|
||||
...?injectedParentsByWarehouseId[group.warehouse.id],
|
||||
...group.items,
|
||||
]))
|
||||
_ItemRow(
|
||||
item: item,
|
||||
details: details,
|
||||
onAction: (action) => onItemAction(item, action),
|
||||
suppressScanHint: setParentIds.contains(item.id),
|
||||
setParentComplete: setParentIds.contains(item.id) &&
|
||||
setParentComplete(item),
|
||||
),
|
||||
],
|
||||
// Gebuchte Dienstleistungen (nicht-scanbare Positionen): eigene
|
||||
// Zwischenüberschrift „Dienstleistungen" (optisch wie
|
||||
// Standardlager) und dieselbe Item-Card wie scanbare Artikel —
|
||||
// einziger Unterschied ist der Hinweis, dass kein Scanvorgang
|
||||
// nötig ist (`scanNotRequired`).
|
||||
if (serviceItems.isNotEmpty) ...[
|
||||
// Gebuchte Dienstleistungen (nicht-scanbare Positionen ohne
|
||||
// eigene Set-Komponenten): eigene Zwischenüberschrift
|
||||
// „Dienstleistungen" (optisch wie Standardlager) und dieselbe
|
||||
// Item-Card wie scanbare Artikel — einziger Unterschied ist der
|
||||
// Hinweis, dass kein Scanvorgang nötig ist.
|
||||
if (serviceItemsView.isNotEmpty) ...[
|
||||
const _ServiceSectionHeader(),
|
||||
for (final item in _parentFirst(serviceItems))
|
||||
for (final item in _parentFirst(serviceItemsView))
|
||||
_ItemRow(
|
||||
item: item,
|
||||
details: details,
|
||||
onAction: (action) => onItemAction(item, action),
|
||||
scanNotRequired: true,
|
||||
suppressScanHint: setParentIds.contains(item.id),
|
||||
setParentComplete: setParentIds.contains(item.id) &&
|
||||
setParentComplete(item),
|
||||
),
|
||||
],
|
||||
],
|
||||
@ -681,6 +822,44 @@ class _ScanNotRequiredHint extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// Grünes „Komplett geladen" für einen Set-Kopf (Parent-Artikel), dessen
|
||||
/// (scanbare) Komponenten alle geladen sind. Ersetzt an dieser Stelle den
|
||||
/// „Kein Scanvorgang notwendig"-Hinweis.
|
||||
class _SetCompleteHint extends StatelessWidget {
|
||||
const _SetCompleteHint();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final color = Colors.green.shade700;
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.green.withValues(alpha: 0.10),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.check_circle, size: 16, color: color),
|
||||
const SizedBox(width: 6),
|
||||
Flexible(
|
||||
child: Text(
|
||||
'Komplett geladen',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: color,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Sektions-Kopf vor den Items eines Lagers. Visuell klar getrennt
|
||||
/// (Standardlager vs. Filiale): Standardlager ist der primäre
|
||||
/// Arbeitsplatz und damit neutral koloriert; Filial-Sections
|
||||
@ -1039,24 +1218,37 @@ class _ItemRow extends StatelessWidget {
|
||||
required this.item,
|
||||
required this.details,
|
||||
required this.onAction,
|
||||
this.scanNotRequired = false,
|
||||
this.suppressScanHint = false,
|
||||
this.setParentComplete = false,
|
||||
});
|
||||
|
||||
final DeliveryItem item;
|
||||
final TourDetails details;
|
||||
final void Function(_ItemAction action) onAction;
|
||||
|
||||
/// `true` für gebuchte Dienstleistungen (nicht-scanbare Positionen): die
|
||||
/// Card wird GENAU SO wie ein Standardlager-Artikel gerendert, bekommt aber
|
||||
/// unten den Hinweis „Kein Scanvorgang notwendig". Der Manuell-Button
|
||||
/// entfällt bei nicht-scanbaren Positionen ohnehin (`canManualConfirm`).
|
||||
final bool scanNotRequired;
|
||||
/// Unterdrückt den „Kein Scanvorgang notwendig"-Hinweis. Für nicht-scanbare
|
||||
/// **Set-Köpfe** (Parent-Artikel): dort ist der Hinweis irreführend, weil die
|
||||
/// (scanbaren) Komponenten darunter sehr wohl gescannt werden.
|
||||
final bool suppressScanHint;
|
||||
|
||||
/// `true`, wenn dies ein Set-Kopf ist, dessen Komponenten alle fertig
|
||||
/// geladen sind. Dann wird der (selbst nicht scanbare) Kopf grün dargestellt.
|
||||
final bool setParentComplete;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final article = details.articleOf(item.articleId);
|
||||
final warehouse = details.warehouseOf(item.warehouseId);
|
||||
// `true` für nicht-scanbare Positionen (Dienstleistungen / Pauschalen /
|
||||
// Set-Köpfe): die Card wird GENAU SO wie ein scanbarer Artikel gerendert,
|
||||
// bekommt aber unten den Hinweis „Kein Scanvorgang notwendig" und keinen
|
||||
// Mengen-Zähler. Aus dem Artikel abgeleitet, damit ein in eine Lagergruppe
|
||||
// eingehängter nicht-scanbarer Set-Kopf automatisch korrekt rendert.
|
||||
final scanNotRequired = !(article?.scannable ?? false);
|
||||
// Effektiv „fertig": eigener Scan-Status ODER (Set-Kopf, dessen Komponenten
|
||||
// alle geladen sind) → der Kopf wird dann ebenfalls grün.
|
||||
final effectiveDone = item.isDone || setParentComplete;
|
||||
final isExternalWarehouse = warehouse != null && !warehouse.isStandard;
|
||||
// Manueller Fallback-Button: nur für scanbare, noch offene Positionen
|
||||
// (nicht done/entfernt/pausiert) — analog dazu, was ein Barcode-Scan
|
||||
@ -1093,7 +1285,7 @@ class _ItemRow extends StatelessWidget {
|
||||
leadingIcon = Icons.pause_circle_outline;
|
||||
leadingIconColor = Colors.orange.shade800;
|
||||
statusBadgeLabel = 'Pausiert';
|
||||
} else if (item.isDone) {
|
||||
} else if (effectiveDone) {
|
||||
cardColor = Colors.green.withValues(alpha: 0.07);
|
||||
borderColor = Colors.green.withValues(alpha: 0.35);
|
||||
titleColor = Colors.green.shade700;
|
||||
@ -1282,9 +1474,14 @@ class _ItemRow extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
],
|
||||
// Dienstleistung (nicht-scanbar): Hinweis statt Scan/Manuell-
|
||||
// Aktion. Steht an derselben Stelle wie der Manuell-Button.
|
||||
if (scanNotRequired) ...[
|
||||
// Set-Kopf, dessen Komponenten alle geladen sind → grünes
|
||||
// „Komplett geladen". Sonst (nicht-scanbare Position, KEIN
|
||||
// Set-Kopf) der normale „Kein Scanvorgang notwendig"-Hinweis;
|
||||
// bei Set-Köpfen ist der unterdrückt (irreführend).
|
||||
if (scanNotRequired && setParentComplete) ...[
|
||||
const SizedBox(height: 8),
|
||||
const _SetCompleteHint(),
|
||||
] else if (scanNotRequired && !suppressScanHint) ...[
|
||||
const SizedBox(height: 8),
|
||||
const _ScanNotRequiredHint(),
|
||||
],
|
||||
|
||||
@ -90,6 +90,8 @@ dev_dependencies:
|
||||
flutter_launcher_icons:
|
||||
android: "launcher_icon"
|
||||
ios: true
|
||||
# iOS-Icons dürfen keinen Alpha-Kanal haben (sonst App-Store-Ablehnung).
|
||||
remove_alpha_ios: true
|
||||
image_path: "assets/launch_icon.png"
|
||||
min_sdk_android: 21
|
||||
|
||||
|
||||