diff --git a/PadelClubData/Data/Event.swift b/PadelClubData/Data/Event.swift index 15eb2ab..29f3fc6 100644 --- a/PadelClubData/Data/Event.swift +++ b/PadelClubData/Data/Event.swift @@ -100,6 +100,10 @@ final public class Event: BaseEvent { tournaments.filter({ $0.isFree() == false && $0.isCanceled == false && $0.isDeleted == false }) } + public func confirmedTournaments() -> [Tournament] { + tournaments.filter({ $0.isCanceled == false && $0.isDeleted == false }) + } + public func shareURL() -> URL? { return URL(string: URLs.main.url.appending(path: "event/\(id)").absoluteString.removingPercentEncoding!) } diff --git a/PadelClubData/Data/PlayerRegistration.swift b/PadelClubData/Data/PlayerRegistration.swift index 773934b..afc6c4d 100644 --- a/PadelClubData/Data/PlayerRegistration.swift +++ b/PadelClubData/Data/PlayerRegistration.swift @@ -230,7 +230,18 @@ final public class PlayerRegistration: BasePlayerRegistration, SideStorable { return 0.0 } } - + + public func totalIncome(_ tournament: Tournament) -> Double { + if let entryFee = tournament.entryFee { + if clubMember, let clubMemberFeeDeduction = tournament.clubMemberFeeDeduction { + return entryFee - clubMemberFeeDeduction + } else { + return entryFee + } + } else { + return 0.0 + } + } public enum PlayerDataSource: Int, Codable { case frenchFederation = 0 diff --git a/PadelClubData/Data/Tournament.swift b/PadelClubData/Data/Tournament.swift index 6304f72..045bf79 100644 --- a/PadelClubData/Data/Tournament.swift +++ b/PadelClubData/Data/Tournament.swift @@ -1235,6 +1235,15 @@ defer { public func remainingAmount() -> Double { return selectedPlayers().compactMap { $0.remainingAmount(self) }.reduce(0.0, +) } + + public func totalIncome() -> Double { + if let entryFee { + return Double(teamCount) * entryFee * 2.0 + } else { + return 0.0 + } + } + public func paidCompletion() -> Double { let selectedPlayers = selectedPlayers() diff --git a/PadelClubData/ViewModel/Screen.swift b/PadelClubData/ViewModel/Screen.swift index 251ac6b..bb53ac7 100644 --- a/PadelClubData/ViewModel/Screen.swift +++ b/PadelClubData/ViewModel/Screen.swift @@ -23,4 +23,5 @@ public enum Screen: String, Codable { case share case restingTime case stateSettings + case statistics }