import 'address.dart';

/// Kunden-Stammdatensatz. Ein Kunde kann mehrere `CustomerContact`s haben
/// (Ehepartner, Hausverwalter, …); diese werden separat in der
/// `TourDetails.contacts`-Map geführt.
class Customer {
  const Customer({
    required this.id,
    required this.name,
    required this.erpCustomerId,
    required this.address,
  });

  final String id;
  final String name;

  /// ERP-Kundennummer (Legacy). Wird in der App nur informativ in der
  /// Detail-Ansicht angezeigt.
  final int erpCustomerId;
  final Address address;

  Customer copyWith({
    String? id,
    String? name,
    int? erpCustomerId,
    Address? address,
  }) {
    return Customer(
      id: id ?? this.id,
      name: name ?? this.name,
      erpCustomerId: erpCustomerId ?? this.erpCustomerId,
      address: address ?? this.address,
    );
  }
}

/// Ansprechpartner zu einem Kunden. Optional, daher als eigene Liste in
/// `TourDetails` — eine Lieferung referenziert n Kontakte per Id.
class CustomerContact {
  const CustomerContact({
    required this.id,
    required this.customerId,
    required this.name,
    this.phone,
    this.email,
  });

  final String id;
  final String customerId;
  final String name;
  final String? phone;
  final String? email;
}
