1. Version Versendung

This commit is contained in:
concierge committed 2026-11-14 09:33:17 +01:00
1 parent d7113afa5f
commit 781aa20253
31 files changed
+4023 -10

No files matched your search

+133
View File
@@ -0,0 +1,133 @@
import Foundation
/// How a recipient receives the plan.
public enum DispatchChannel: String, Codable, CaseIterable, Identifiable, Sendable {
case email
case print
case none
public var id: String { rawValue }
public var title: String {
switch self {
case .email: "E-Mail"
case .print: "Ausdruck"
case .none: "Kein Versand"
}
}
public var symbolName: String {
switch self {
case .email: "envelope.fill"
case .print: "printer.fill"
case .none: "minus.circle"
}
}
}
/// Which list is attached to a dispatch.
public enum PlanListVariant: String, Codable, CaseIterable, Identifiable, Sendable {
case compact
case full
public var id: String { rawValue }
public var title: String {
switch self {
case .compact: "Kompaktansicht"
case .full: "Ausführlicher Plan"
}
}
public var shortTitle: String {
switch self {
case .compact: "Kompaktliste"
case .full: "Plan"
}
}
}
/// Stored dispatch preference for one person.
public struct DispatchPreference: Equatable, Sendable {
public var channel: DispatchChannel
public var variant: PlanListVariant
public var cover: Bool
public init(channel: DispatchChannel = .email, variant: PlanListVariant = .compact, cover: Bool = true) {
self.channel = channel
self.variant = variant
self.cover = cover
}
/// A selected e-mail channel without a stored address falls back to print,
/// mirroring the web version.
public func effectiveChannel(for person: Person) -> DispatchChannel {
if channel == .email && person.email.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
return .print
}
return channel
}
}
/// Outcome recorded in the dispatch log. The macOS app opens e-mails in the
/// default mail client instead of sending them over SMTP.
public enum DispatchStatus: String, Codable, CaseIterable, Sendable {
case mail
case pdf
case failed
public var title: String {
switch self {
case .mail: "Im Mailprogramm geöffnet"
case .pdf: "Druck-PDF erzeugt"
case .failed: "Fehlgeschlagen"
}
}
}
/// One log line of a dispatch batch.
public struct DispatchLogEntry: Identifiable, Equatable, Sendable {
public var id: String
public var batchID: String
public var rangeStart: Date
public var rangeEnd: Date
public var personID: String
public var personName: String
public var channel: DispatchChannel
public var variant: PlanListVariant
public var cover: Bool
public var email: String
public var status: DispatchStatus
public var detail: String
public var createdAt: Date
public init(
id: String = UUID().uuidString,
batchID: String,
rangeStart: Date,
rangeEnd: Date,
personID: String,
personName: String,
channel: DispatchChannel,
variant: PlanListVariant = .compact,
cover: Bool = false,
email: String = "",
status: DispatchStatus,
detail: String = "",
createdAt: Date = Date()
) {
self.id = id
self.batchID = batchID
self.rangeStart = rangeStart
self.rangeEnd = rangeEnd
self.personID = personID
self.personName = personName
self.channel = channel
self.variant = variant
self.cover = cover
self.email = email
self.status = status
self.detail = detail
self.createdAt = createdAt
}
}