Merge branch 'main' into sync3

sync3
Laurent 5 months ago
commit 866d822ecd
  1. 4
      PadelClubData/Data/Event.swift
  2. 4
      PadelClubData/Data/GroupStage.swift
  3. 10
      PadelClubData/Data/Match.swift
  4. 3
      PadelClubData/Data/MatchScheduler.swift
  5. 13
      PadelClubData/Data/PlayerRegistration.swift
  6. 9
      PadelClubData/Data/Tournament.swift
  7. 2
      PadelClubData/ViewModel/PadelRule.swift
  8. 1
      PadelClubData/ViewModel/Screen.swift

@ -92,6 +92,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!)
}

@ -606,6 +606,10 @@ final public class GroupStage: BaseGroupStage, SideStorable {
guard hasEnded() else { return nil }
return teams(true).firstIndex(of: team)
}
public func computedStartDate() -> Date? {
return _matches().sorted(by: \.computedStartDateForSorting).first?.startDate
}
public override func deleteDependencies(store: Store, actionOption: ActionOption) {
store.deleteDependencies(type: Match.self, actionOption: actionOption) { $0.groupStage == self.id }

@ -525,6 +525,16 @@ defer {
updateFollowingMatchTeamScore()
}
public func teamPosition(for teamRegistration: TeamRegistration) -> TeamPosition? {
if self.team(.one)?.id == teamRegistration.id {
return .one
} else if self.team(.two)?.id == teamRegistration.id {
return .two
} else {
return nil
}
}
public func setWalkOut(_ teamPosition: TeamPosition) {
let teamScoreWalkout = teamScore(teamPosition) ?? TeamScore(match: id, team: team(teamPosition))
teamScoreWalkout.walkOut = 0

@ -131,6 +131,9 @@ final public class MatchScheduler: BaseMatchScheduler, SideStorable {
} catch {
Logger.error(error)
}
groupStages.forEach({ $0.startDate = $0.computedStartDate() })
self.tournamentStore?.groupStages.addOrUpdate(contentOfs: groupStages)
return lastDate
}

@ -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

@ -1251,6 +1251,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()

@ -1273,7 +1273,7 @@ public enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable {
self.init(rawValue: value)
}
func defaultWalkOutScore(_ asWalkOutTeam: Bool) -> [Int] {
public func defaultWalkOutScore(_ asWalkOutTeam: Bool) -> [Int] {
Array(repeating: asWalkOutTeam ? 0 : setFormat.scoreToWin, count: setsToWin)
}

@ -23,4 +23,5 @@ public enum Screen: String, Codable {
case share
case restingTime
case stateSettings
case statistics
}

Loading…
Cancel
Save