public PlayerReport(Player player, Tariff tariff) { _tariff = tariff ?? throw new ArgumentNullException(nameof(tariff)); _currentTariff = tariff.CurrentRate; Player = player ?? throw new ArgumentNullException(nameof(player)); AmountPaid = CurrencyAmount.Zero; AmountDueToDate = CurrencyAmount.Zero; }
private void CalculateDues(Dictionary <Player, PlayerReport> playerReports) { foreach (Player player in _roster.Players) { playerReports[player] = new PlayerReport(player, _tariff); int tariffIndex = 0; TariffItem currentRate = _tariff.History[tariffIndex]; var currentDate = currentRate.BeginsOn; while (currentDate < _dataSource.NowServerTime) { if (currentRate != _tariff.CurrentRate) { var nextRate = _tariff.History[tariffIndex + 1]; if (nextRate.BeginsOn <= currentDate) { currentRate = nextRate; tariffIndex++; } } var intervalEndDate = currentDate + currentRate.RepeatInterval; if (player.IsRetired && player.LeftOn < intervalEndDate) { break; } if (player.JoinedOn < intervalEndDate) { playerReports[player].AmountDueToDate += currentRate.Amount; } currentDate = intervalEndDate; } } }