|
|
|
|
@ -10,6 +10,7 @@ import SwiftUI |
|
|
|
|
struct CashierDetailView: View { |
|
|
|
|
var tournaments : [Tournament] |
|
|
|
|
@State private var earnings: Double? = nil |
|
|
|
|
@State private var remainingAmount: Double? = nil |
|
|
|
|
@State private var paidCompletion: Double? = nil |
|
|
|
|
|
|
|
|
|
init(tournaments: [Tournament]) { |
|
|
|
|
@ -24,6 +25,16 @@ struct CashierDetailView: View { |
|
|
|
|
List { |
|
|
|
|
if tournaments.count > 1 { |
|
|
|
|
Section { |
|
|
|
|
LabeledContent { |
|
|
|
|
if let remainingAmount { |
|
|
|
|
Text(remainingAmount.formatted(.currency(code: Locale.defaultCurrency()).precision(.fractionLength(0)))) |
|
|
|
|
} else { |
|
|
|
|
ProgressView() |
|
|
|
|
} |
|
|
|
|
} label: { |
|
|
|
|
Text("Reste à encaisser") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
LabeledContent { |
|
|
|
|
if let earnings { |
|
|
|
|
Text(earnings.formatted(.currency(code: Locale.defaultCurrency()).precision(.fractionLength(0)))) |
|
|
|
|
@ -57,10 +68,18 @@ struct CashierDetailView: View { |
|
|
|
|
if paidCompletion == nil { |
|
|
|
|
_getPaidCompletion() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if remainingAmount == nil { |
|
|
|
|
_getRemainingAmount() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _getRemainingAmount() { |
|
|
|
|
remainingAmount = tournaments.map { $0.remainingAmount() }.reduce(0,+) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _getEarnings() { |
|
|
|
|
earnings = tournaments.map { $0.earnings() }.reduce(0,+) |
|
|
|
|
} |
|
|
|
|
@ -88,11 +107,22 @@ struct CashierDetailView: View { |
|
|
|
|
let tournament: Tournament |
|
|
|
|
let showTournamentTitle: Bool |
|
|
|
|
@State private var earnings: Double? = nil |
|
|
|
|
@State private var remainingAmount: Double? = nil |
|
|
|
|
@State private var paidCompletion: Double? = nil |
|
|
|
|
@State private var presence: Double? = nil |
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
Section { |
|
|
|
|
LabeledContent { |
|
|
|
|
if let remainingAmount { |
|
|
|
|
Text(remainingAmount.formatted(.currency(code: Locale.defaultCurrency()).precision(.fractionLength(0)))) |
|
|
|
|
} else { |
|
|
|
|
ProgressView() |
|
|
|
|
} |
|
|
|
|
} label: { |
|
|
|
|
Text("Reste à encaisser") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
LabeledContent { |
|
|
|
|
if let earnings { |
|
|
|
|
Text(earnings.formatted(.currency(code: Locale.defaultCurrency()).precision(.fractionLength(0)))) |
|
|
|
|
@ -130,6 +160,10 @@ struct CashierDetailView: View { |
|
|
|
|
if presence == nil { |
|
|
|
|
presence = tournament.presenceStatus() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if remainingAmount == nil { |
|
|
|
|
remainingAmount = tournament.remainingAmount() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|