feat: Adresszusatz (Ortsteil/Etage/Hinweis) anzeigen, Land nur im Ausland
- Address.addition aus dem Backend (ERP-Freitext, praktisch Ortsteil, Etage oder Hinweis); API-Client neu generiert. - Listen (Sortieren, Beladen, Liefer-Übersicht): Adresse mit Zusatz in Klammern, z. B. „… 41472 Neuss (Holzheim)". - Lieferdetails: „Zusatz: …" unter der Anschrift von Empfänger und Besteller; Land nur außerhalb Deutschlands. - Maps-Suche weiter ohne Zusatz (sonst stört „3 Etage" die Suche). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -12,17 +12,44 @@ class Address {
|
||||
required this.postalCode,
|
||||
required this.city,
|
||||
required this.country,
|
||||
this.addition,
|
||||
});
|
||||
|
||||
final String street;
|
||||
final String houseNumber;
|
||||
final String postalCode;
|
||||
final String city;
|
||||
/// Land laut ERP-Länderstamm (z. B. „Deutschland"), leer wenn unbekannt.
|
||||
final String country;
|
||||
|
||||
/// Einzeilige Darstellung für Listen/Header.
|
||||
String get oneLine =>
|
||||
'$street $houseNumber, $postalCode $city';
|
||||
/// Freier Adresszusatz aus dem ERP — praktisch Ortsteil, Etage oder
|
||||
/// Hinweis („Holzheim", „3 Etage", „Parterre"). `null`, wenn leer.
|
||||
final String? addition;
|
||||
|
||||
static const Set<String> _germany = {
|
||||
'd', 'de', 'deu', 'deutschland', 'germany', 'brd',
|
||||
};
|
||||
|
||||
/// Land für die Anzeige — nur außerhalb Deutschlands, sonst `null`.
|
||||
String? get foreignCountry {
|
||||
final c = country.trim();
|
||||
if (c.isEmpty || _germany.contains(c.toLowerCase())) return null;
|
||||
return c;
|
||||
}
|
||||
|
||||
/// Einzeilige Anschrift „Straße Nr, PLZ Ort" (+ Land, falls Ausland).
|
||||
/// Ohne Zusatz — so auch als Such-Query für Maps geeignet.
|
||||
String get oneLine => [
|
||||
'$street $houseNumber, $postalCode $city',
|
||||
if (foreignCountry case final c?) c,
|
||||
].join(', ');
|
||||
|
||||
/// Wie [oneLine], mit Adresszusatz in Klammern — für Listen, damit der
|
||||
/// Fahrer Ortsteil/Etage auf einen Blick sieht.
|
||||
String get oneLineWithAddition {
|
||||
final a = addition?.trim();
|
||||
return a == null || a.isEmpty ? oneLine : '$oneLine ($a)';
|
||||
}
|
||||
|
||||
Address copyWith({
|
||||
String? street,
|
||||
@ -30,6 +57,7 @@ class Address {
|
||||
String? postalCode,
|
||||
String? city,
|
||||
String? country,
|
||||
String? addition,
|
||||
}) {
|
||||
return Address(
|
||||
street: street ?? this.street,
|
||||
@ -37,6 +65,7 @@ class Address {
|
||||
postalCode: postalCode ?? this.postalCode,
|
||||
city: city ?? this.city,
|
||||
country: country ?? this.country,
|
||||
addition: addition ?? this.addition,
|
||||
);
|
||||
}
|
||||
|
||||
@ -48,8 +77,10 @@ class Address {
|
||||
other.houseNumber == houseNumber &&
|
||||
other.postalCode == postalCode &&
|
||||
other.city == city &&
|
||||
other.country == country;
|
||||
other.country == country &&
|
||||
other.addition == addition;
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(street, houseNumber, postalCode, city, country);
|
||||
int get hashCode =>
|
||||
Object.hash(street, houseNumber, postalCode, city, country, addition);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user