public static void Tariff0001() { var tariff = new Tariff(Tariff_Id.Parse("12"), Currency.EUR, TariffElements: Enumeration.Create( new TariffElement( new PriceComponent(DimensionType.TIME, 2.00M, 300) ) ) ); var expected = new JObject(new JProperty("id", "12"), new JProperty("currency", "EUR"), new JProperty("elements", new JArray( new JObject( new JProperty("price_components", new JArray( new JObject( new JProperty("type", "TIME"), new JProperty("price", "2.00"), new JProperty("step_size", 300) ))) ) ))); Assert.AreEqual(expected.ToString(), tariff.ToJSON().ToString()); }
public Service( string name, string unit, Tariff tariff=null, string description = null ) { if (tariff != null) this.Tariffs.Add(tariff); this.Name = name; this.Unit = unit; if (description != null) this.Description = description; }
public async Task <IActionResult> Delete(int?id) { if (id != null) { Tariff tariff = await _db.Tariffs.FirstOrDefaultAsync(p => p.Id == id); if (tariff != null) { _db.Tariffs.Remove(tariff); await _db.SaveChangesAsync(); return(RedirectToAction(actionName: "index")); } } return(NotFound()); }
public bool AddnewTariff(Tariff tariff) { if (tariff != null) { _session.Transact(session => session.Save(tariff)); _helper.Log(LogEntryType.Audit, null, string.Format( "New Tarrif has been added to the system Tariff name {0} , Tarriff id {1}, by {2}", tariff.Name, tariff.Id, CurrentRequestData.CurrentUser.Id), "Tariff Added."); return(true); } else { return(false); } }
private void gridPriceList_LoadingRow(object sender, DataGridRowEventArgs e) { Tariff item = e.Row.Item as Tariff; if (item != null) { if (checkIsRelevant(item.DateStart, item.DateFinish) == true) { e.Row.Background = Brushes.LightGreen; } else { e.Row.Background = Brushes.White; } } }
public override void Calculate(Tariff tariff, double consumption) { tariff.Name = _tariffName; if (consumption <= _upTo) { tariff.AnnualCost = _upToCost; } else { var additionalConsumption = consumption - _upTo; var additionalCost = additionalConsumption * _consumptionCost; var total = additionalCost + _upToCost; tariff.AnnualCost = total; } }
public void BuildReport_WhenTaxmanSentMoneyToBanker_AddsToTotalSent() { var firstRateStart = new DateTimeOffset(2020, 06, 24, 0, 0, 0, TimeSpan.FromHours(1)); var now = firstRateStart.AddDays(14); var tariff = new Tariff { History = new [] { new TariffItem { Amount = CurrencyAmount.FromGold(40), BeginsOn = firstRateStart, RepeatInterval = TimeSpan.FromDays(7) } } }; var roster = new Roster() .Add(new Player("Neffer")); IReadOnlyList <Transaction> transactions = new [] { new Transaction( TransactionType.MoneyTransfer, CurrencyAmount.FromGold(40), "Neffer", "Frozengold", firstRateStart.AddDays(1)), new Transaction( TransactionType.MoneyTransfer, CurrencyAmount.FromGold(20), "Frozengold", "Frozbank", firstRateStart.AddDays(9)), }; A.CallTo(() => _dataSource.GetRoster()).Returns(roster); A.CallTo(() => _dataSource.GetTariff()).Returns(tariff); A.CallTo(() => _dataSource.NowServerTime).Returns(now); A.CallTo(() => _dataSource.GetTransactionHistory()).Returns(transactions); var sut = CreateSut(); sut.BuildReport(); sut.SentToBanker.Should().Be(CurrencyAmount.FromGold(20)); }
public void BuildReport_WhenPlayerNotInRosterSentGoldToTaxman_AddsToCollectionOfOddTransactions() { var firstRateStart = new DateTimeOffset(2020, 06, 24, 0, 0, 0, TimeSpan.FromHours(1)); var now = firstRateStart.AddDays(14); var tariff = new Tariff { History = new [] { new TariffItem { Amount = CurrencyAmount.FromGold(40), BeginsOn = firstRateStart, RepeatInterval = TimeSpan.FromDays(7) } } }; var roster = new Roster() .Add(new Player("Neffer")); Transaction oddTransaction = new Transaction( TransactionType.MoneyTransfer, CurrencyAmount.FromGold(40), "Jiwari", "Frozengold", firstRateStart.AddDays(1)); IReadOnlyList <Transaction> transactions = new [] { oddTransaction }; A.CallTo(() => _dataSource.GetRoster()).Returns(roster); A.CallTo(() => _dataSource.GetTariff()).Returns(tariff); A.CallTo(() => _dataSource.NowServerTime).Returns(now); A.CallTo(() => _dataSource.GetTransactionHistory()).Returns(transactions); var sut = CreateSut(); sut.BuildReport(); var neffer = sut.PlayerReports.Single(pr => pr.Player.Main.Name == "Neffer"); neffer.AmountPaid.Should().Be(CurrencyAmount.Zero); sut.OddTransactions.Count().Should().Be(1); sut.OddTransactions.Should().Contain(oddTransaction); }
public Charge CalculateSubsidy(Volume volumes, Tariff tariff) { Charge change = new Charge(); OnNotify?.Invoke(this, $"Start counting ({DateTime.Now})"); if (volumes.HouseId == tariff.HouseId) { if (volumes.ServiceId == tariff.ServiceId) { if (volumes.Month.Month <= tariff.PeriodEnd.Month && volumes.Month.Month >= tariff.PeriodBegin.Month) { if (tariff.Value > 0) { if (volumes.Value >= 0) { change.ServiceId = tariff.ServiceId; change.HouseId = tariff.HouseId; change.Value = tariff.Value * volumes.Value; change.Month = DateTime.Today; } else { ExceptionCall("incorrect volumes value"); } } else { ExceptionCall("incorrect tariss value"); } } else { ExceptionCall("incorrect period"); } } else { ExceptionCall("incorrect service ID"); } } else { ExceptionCall("incorrect house ID"); } OnNotify?.Invoke(this, $"End counting ({DateTime.Now})"); return(change); }
protected void Page_Load(object sender, EventArgs e) { Page .RegisterBodyScripts("~/UserControls/Management/TariffSettings/js/tariffusage.js", "~/js/asc/plugins/countries.js", "~/js/asc/plugins/phonecontroller.js") .RegisterStyle( "~/skins/default/phonecontroller.css", "~/UserControls/Management/TariffSettings/css/tariff.less", "~/UserControls/Management/TariffSettings/css/tariffusage.less") .RegisterClientScript(new CountriesResources()); CurrentRegion = RegionDefault; Regions.Add(CurrentRegion); UsersCount = TenantStatisticsProvider.GetUsersCount(); UsedSize = TenantStatisticsProvider.GetUsedSize(); CurrentTariff = TenantExtra.GetCurrentTariff(); CurrentQuota = TenantExtra.GetTenantQuota(); if (_quotaList == null || !_quotaList.Any()) { _quotaList = TenantExtra.GetTenantQuotas(); } else if (!CurrentQuota.Trial) { CurrentQuota = _quotaList.FirstOrDefault(q => q.Id == CurrentQuota.Id) ?? CurrentQuota; } _quotaList = _quotaList.OrderBy(r => r.ActiveUsers).ToList().Where(r => !r.Trial); QuotasYear = _quotaList.Where(r => r.Year).ToList(); MonthIsDisable = !CurrentQuota.Free && (CurrentQuota.Year || CurrentQuota.Year3) && CurrentTariff.State == TariffState.Paid; YearIsDisable = !CurrentQuota.Free && CurrentQuota.Year3 && CurrentTariff.State == TariffState.Paid; var minYearQuota = QuotasYear.FirstOrDefault(q => q.ActiveUsers >= UsersCount && q.MaxTotalSize >= UsedSize); MinActiveUser = minYearQuota != null ? minYearQuota.ActiveUsers : (QuotasYear.Count > 0 ? QuotasYear.Last().ActiveUsers : 0 + 1); HideBuyRecommendation = CurrentTariff.Autorenewal || TariffSettings.HideRecommendation; downgradeInfoContainer.Options.IsPopup = true; buyRecommendationContainer.Options.IsPopup = true; AjaxPro.Utility.RegisterTypeForAjax(GetType()); RegisterScript(); CurrencyCheck(); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Tariff tariff = _db.Tariffs.Find(id); if (tariff == null) { return(HttpNotFound()); } var tariffViewModel = TariffViewModel.FromTariff(tariff, _db); return(View(tariffViewModel)); }
public async Task CreateTariff(TariffDTO dto) { Guid id = Guid.NewGuid(); using (MUEContext db = new MUEContext()) { Tariff tariff = new Tariff { Value = dto.Value, TypeOfServiceId = dto.TypeOfServiceId, TariffId = id, FlatId = dto.FlatId }; db.Tariffs.Add(tariff); await db.SaveChangesAsync(); } }
private bool IsRecurringMatch(Tariff tariff, DateTime date) { if (tariff.Type == (int)TariffType.Recurring) { // Represents the candidate date day of the week value in the DayOfTheWeek enum var dayOfTheWeek = 1 << (int)date.DayOfWeek; var startTime = DateTime.MinValue.AddHours(tariff.StartTime.Hour).AddMinutes(tariff.StartTime.Minute); var endTime = DateTime.MinValue.AddHours(tariff.EndTime.Hour).AddMinutes(tariff.EndTime.Minute); var time = DateTime.MinValue.AddHours(date.Hour).AddMinutes(date.Minute); if (endTime <= startTime) { //The tariff spans across two days if (time < endTime) { //The candidate date is on the second day of the tariff time = time.AddDays(1); } endTime = endTime.AddDays(1); } // Determine if the candidate date is between start time and end time var isInRange = time >= startTime && time < endTime; if (isInRange) { // Now determine if the day of the week is correct if (startTime.Date == time.Date) { // The candidate date is the same day defined for the tariff return((tariff.DaysOfTheWeek & dayOfTheWeek) == dayOfTheWeek); } if (endTime.Date == time.Date) { // The candidate date is the next day defined for the tariff // We have to check if a tariff exist for the previous day var previousDayOfTheWeek = dayOfTheWeek == (int)DayOfTheWeek.Sunday ? (int)DayOfTheWeek.Saturday : dayOfTheWeek >> 1; return((tariff.DaysOfTheWeek & previousDayOfTheWeek) == previousDayOfTheWeek); } } } return(false); }
public object Post(Tariff request) { //Check if rate with same name already exists if (_dao.GetAll().Any(x => x.Name == request.Name)) { throw new HttpError(HttpStatusCode.Conflict, ErrorCode.Tariff_DuplicateName.ToString()); } var command = Mapper.Map <CreateTariff>(request); _commandBus.Send(command); return(new { Id = command.TariffId }); }
public ServiceResult Put(Tariff model) { var result = new ServiceResult { IsSuccess = false }; var tariff = GetById(model.Id); if (tariff != null) { tariff.Amount = model.Amount; tariff.EndHour = model.EndHour; tariff.StartHour = model.StartHour; context.SaveChanges(); result.IsSuccess = true; } return(result); }
void btnSave_Click(object sender, EventArgs e) { Page.Validate(); if (!Page.IsValid) { return; } if (Request["CurrencyId"] == null) { Tariff.AddCurrency(txtName.Text, txtSymbol.Text); } else { Tariff.UpdateCurrency(int.Parse(Request["CurrencyId"]), txtName.Text, txtSymbol.Text); } Response.Redirect("~/Pages/Currencies.aspx"); }
//перевод в статус "Выдан" public bool StatusToIssued(int id) { SysTransaction transaction = Database.TransactionsAC.Get(id); Country country = Mapper.Map <Country>(_countryService.Get(transaction.CountryId)); Tariff tariff = _commissionService.GetTariff(transaction, transaction.AgentFromId); decimal summ = _commissionService.GetCommissionWhenTransactionIssued(tariff.CommissionType, tariff.Value, transaction); transaction.TransactionStatus = (int)TransactionStatus.Issued; transaction.IssueDateLocal = DateTime.UtcNow.AddHours(country.Utc); // Дата в часовом поясе агента transaction.IssueDateUtc = DateTime.UtcNow; transaction.Sum = summ; Database.TransactionsAC.Update(transaction); Database.Save(); _commissionService.SendSmsToClientSender(transaction.ClientFromId); return(transaction.TransactionStatus == (int)TransactionStatus.Issued); }
public ActionResult Create(TariffViewModel tariffViewModel) { string fuel = tariffViewModel.fuel; int meterId = tariffViewModel.meterId; int propertyId = tariffViewModel.BelongsToProperty; try { if (ModelState.IsValid) { Tariff tariff = TariffConverter.createTariffFromViewModel(tariffViewModel); EMResponse response = JsonConvert.DeserializeObject <EMResponse>(emAPI.createTariff(tariff.SCValue, tariff.StartDate.ToString(), tariff.SCPeriod.Id, tariff.BandPeriod.Id, tariffViewModel.meterId)); if (response.status == EMResponse.OK) { int tariffId = JsonConvert.DeserializeObject <int>(response.data); foreach (TariffBand band in tariff.Bands) { EMResponse bandResponse = JsonConvert.DeserializeObject <EMResponse>(emAPI.createTariffBand(band.UpperkWhLimit, band.LowerkWhLimit, band.UnitRate, tariffId)); if (bandResponse.status != EMResponse.OK) { return(View("Error")); } } return(RedirectToAction("Home", "Meter", new { meterId = tariffViewModel.meterId, propertyId = tariffViewModel.BelongsToProperty, type = tariffViewModel.fuel })); } } else { return(View(tariffViewModel)); } return(View(tariffViewModel)); } catch { return(View("Error")); } }
public bool UpdateTariff(Tariff updateTariff) { var fullModel = GetDataFromFile(); var tariffToUpdate = fullModel.Tariffs.FirstOrDefault(tariff => tariff.Id == updateTariff.Id); if (tariffToUpdate == null) { return(false); } tariffToUpdate.Id = updateTariff.Id; tariffToUpdate.Name = updateTariff.Name; tariffToUpdate.Cost = updateTariff.Cost; SaveDataToFile(fullModel); return(true); }
public void Add( string Name, int Price, int InternetSpeed) { BillingSystemContext context = new BillingSystemContext(); Tariff tariff = new Tariff() { Name = Name, Price = Price, InternetSpeed = InternetSpeed }; TariffDao tariffDao = new TariffDao(); tariffDao.Insert(tariff); }
public ActionResult Delete(Tariff tariff) { if (tariff.Id > 0) { bool response = _tariffService.DeleteTariff(tariff); if (response) { _pageMessageSvc.SetSuccessMessage($"Tariff [{tariff.Name.ToUpper()}] was deleted successfully."); } else { _pageMessageSvc.SetErrormessage($"There was an error deleting tariff [{tariff.Name.ToUpper()}] "); } } return(_uniquePageService.RedirectTo <TariffPage>()); }
private void BindDG() { dgGroups.Columns[0].HeaderText = LocRM.GetString("TariffTypeName"); dgGroups.Columns[1].HeaderText = LocRM.GetString("TariffIsActive"); dgGroups.DataSource = Tariff.GetTariffType(0); dgGroups.DataBind(); foreach (DataGridItem dgi in dgGroups.Items) { ImageButton ibDelete = (ImageButton)dgi.FindControl("ibDelete"); if (ibDelete != null) { ibDelete.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("TariffTypeWarning") + "')"); } } }
protected void Page_Load(object sender, EventArgs e) { Page.RegisterBodyScripts("~/js/uploader/ajaxupload.js"); Page.RegisterBodyScripts("~/usercontrols/management/tariffsettings/js/tariffstandalone.js"); Page.RegisterStyle("~/usercontrols/management/tariffsettings/css/tariff.less"); Page.RegisterStyle("~/usercontrols/management/tariffsettings/css/tariffstandalone.less"); UsersCount = TenantStatisticsProvider.GetUsersCount(); CurrentTariff = TenantExtra.GetCurrentTariff(); CurrentQuota = TenantExtra.GetTenantQuota(); TenantCount = CoreContext.TenantManager.GetTenants().Count(t => t.Status == TenantStatus.Active); Settings = AdditionalWhiteLabelSettings.Instance; Settings.LicenseAgreementsUrl = CommonLinkUtility.GetRegionalUrl(Settings.LicenseAgreementsUrl, CultureInfo.CurrentCulture.TwoLetterISOLanguageName); AjaxPro.Utility.RegisterTypeForAjax(GetType()); }
public void Setup() { var tariff1 = new Tariff { Name = "Vehicle default tariff ending the next day", StartTime = new DateTime(1900, 1, 1, 20, 0, 0), EndTime = new DateTime(1900, 1, 2, 8, 0, 0), Type = (int)TariffType.VehicleDefault, VehicleTypeId = 10 }; _tariffProvider = new FakeTariffProvider(new[] { tariff1 }); _sut = new PriceCalculator(_tariffProvider, new Logger()); }
private bool IsDayMatch(Tariff tariff, DateTime date) { if (tariff.Type == (int)TariffType.Day) { var startTime = tariff.StartTime; var endTime = tariff.StartTime.Date.AddHours(tariff.EndTime.Hour).AddMinutes(tariff.EndTime.Minute); if (endTime < startTime) { //The tariff spans across two days endTime = endTime.AddDays(1); } return(date >= startTime && date < endTime); } return(false); }
void btnSave_Click(object sender, EventArgs e) { Page.Validate(); if (!Page.IsValid) { return; } if (Request["TypeId"] == null) { Tariff.AddTariffType(txtName.Text, cbIsActive.Checked); } else { Tariff.UpdateTariffType(int.Parse(Request["TypeId"]), txtName.Text, cbIsActive.Checked); } Response.Redirect("~/Pages/TariffGroups.aspx"); }
public async Task <Tariff> saveTariff([FromBody] Tariff postedTariff) { if (!ModelState.IsValid) { throw new ApiException("Model binding failed.", 500); } if (!TariffRepo.Validate(postedTariff)) { //throw new ApiException(TariffRepo.ErrorMessage, 500, TariffRepo.ValidationErrors); if (!await TariffRepo.SaveAsync(postedTariff)) { throw new ApiException(TariffRepo.ErrorMessage); } } return(postedTariff); }
public void Setup() { var tariff1 = new Tariff { Name = "Day tariff ending the next day", StartTime = new DateTime(2012, 12, 18, 20, 0, 0), EndTime = new DateTime(2012, 12, 19, 8, 0, 0), Type = (int)TariffType.Day, //Tuesday VehicleTypeId = 10 }; _tariffProvider = new FakeTariffProvider(new[] { tariff1 }); _sut = new PriceCalculator(_tariffProvider, new Logger()); }
public async Task GetAll_TariffsExist_ReturnsAll() { // arrange var one = new Tariff("one", 1.0M, 2.0M, 3.0M); var two = new Tariff("two", 4.0M, 5.0M, 6.0M); await _source.ReloadAsync(() => new [] { one, two }); // act var actual = _source.GetAll(); // assert actual.Should().BeEquivalentTo(new[] { one, two }); }
public void tariffСhange(string tariff) { while (true) { try { Tariff tarifff = (Tariff)Enum.Parse(typeof(Tariff), tariff !, true); switch (tarifff) { case Tariff.Supernetstart: accountAmount = accountAmount - 20; costPerMinute = 0.5; Console.WriteLine("Tariff SuperNet Start connected, every minute cost " + costPerMinute + " , your account amount = " + accountAmount); break; case Tariff.Supernetpro: accountAmount = accountAmount - 30; costPerMinute = 0.4; Console.WriteLine("Tariff SuperNet Pro connected, every minute cost " + costPerMinute + " , your account amount = " + accountAmount); break; case Tariff.Supernetunlim: accountAmount = accountAmount - 40; costPerMinute = 0.3; Console.WriteLine("Tariff SuperNet Unlim connected, every minute cost " + costPerMinute + " , your account amount = " + accountAmount); break; default: Console.WriteLine("There is no tariff like that...Try again"); break; } break; } catch (ArgumentException) { Console.WriteLine("Try again..."); tariff = Console.ReadLine(); } } }
protected void Page_Load(object sender, EventArgs e) { Page .RegisterBodyScripts("~/UserControls/Management/TariffSettings/js/tariffcustom.js", "~/js/asc/plugins/countries.js", "~/js/asc/plugins/phonecontroller.js") .RegisterStyle( "~/skins/default/phonecontroller.css", "~/UserControls/Management/TariffSettings/css/tariff.less", "~/UserControls/Management/TariffSettings/css/tariffusage.less", "~/UserControls/Management/TariffSettings/css/tariffcustom.less") .RegisterClientScript(new CountriesResources()); CurrentRegion = RegionDefault; UsersCount = TenantStatisticsProvider.GetUsersCount(); UsedSize = TenantStatisticsProvider.GetUsedSize(); CurrentTariff = TenantExtra.GetCurrentTariff(); CurrentQuota = TenantExtra.GetTenantQuota(); if (_quotaList == null || !_quotaList.Any()) { _quotaList = TenantExtra.GetTenantQuotas(); } else if (!CurrentQuota.Trial) { CurrentQuota = _quotaList.FirstOrDefault(q => q.Id == CurrentQuota.Id) ?? CurrentQuota; } _quotaList = _quotaList.OrderBy(r => r.ActiveUsers).ToList().Where(r => !r.Trial); QuotasYear = _quotaList.Where(r => r.Year).ToList(); MonthIsDisable = !CurrentQuota.Free && (CurrentQuota.Year || CurrentQuota.Year3) && CurrentTariff.State == TariffState.Paid; YearIsDisable = !CurrentQuota.Free && CurrentQuota.Year3 && CurrentTariff.State == TariffState.Paid; var minYearQuota = QuotasYear.FirstOrDefault(q => q.ActiveUsers >= UsersCount && q.MaxTotalSize >= UsedSize); MinActiveUser = minYearQuota != null ? minYearQuota.ActiveUsers : (QuotasYear.Count > 0 ? QuotasYear.Last().ActiveUsers : 0 + 1); MonthPrice = Convert.ToInt32(ConfigurationManager.AppSettings["core.custom-mode.month-price"] ?? "290"); YearPrice = Convert.ToInt32(ConfigurationManager.AppSettings["core.custom-mode.year-price"] ?? "175"); AjaxPro.Utility.RegisterTypeForAjax(GetType()); CurrencyCheck(); }
private Tariff CaculateLessTariff(IList <Tariff> tariffList) { Tariff lessTariff = null; foreach (var tariff in tariffList) { if (lessTariff == null || tariff.Price < lessTariff.Price) { lessTariff = tariff; } else if (tariff.Price.Equals(lessTariff.Price) && tariff.Hotel.Classification > lessTariff.Hotel.Classification) { lessTariff = tariff; } } return(lessTariff); }
public static void Tariff0002() { var tariff = new Tariff(Tariff_Id.Parse("12"), Currency.EUR, TariffText: I18NString.Create(Languages.eng, "2 euro p/hour"). Add(Languages.nld, "2 euro p/uur"), TariffElements: Enumeration.Create( new TariffElement( new PriceComponent(DimensionType.TIME, 2.00M, 300) ) ) ); var expected = new JObject(new JProperty("id", "12"), new JProperty("currency", "EUR"), new JProperty("tariff_alt_text", new JArray( new JObject(new JProperty("language", "en"), new JProperty("text", "2 euro p/hour")), new JObject(new JProperty("language", "nl"), new JProperty("text", "2 euro p/uur")) )), new JProperty("elements", new JArray( new JObject( new JProperty("price_components", new JArray( new JObject( new JProperty("type", "TIME"), new JProperty("price", "2.00"), new JProperty("step_size", 300) ))) ) ))); Assert.AreEqual(expected.ToString(), tariff.ToJSON().ToString()); }
public static void Tariff0003() { var tariff = new Tariff(Tariff_Id.Parse("12"), Currency.EUR, TariffUrl: new Uri("https://company.com/tariffs/12"), TariffElements: Enumeration.Create( new TariffElement( PriceComponent.ChargingTime(2.00M, TimeSpan.FromSeconds(300)) ) ) ); var expected = new JObject(new JProperty("id", "12"), new JProperty("currency", "EUR"), new JProperty("tariff_alt_url", "https://company.com/tariffs/12"), new JProperty("elements", new JArray( new JObject( new JProperty("price_components", new JArray( new JObject( new JProperty("type", "TIME"), new JProperty("price", "2.00"), new JProperty("step_size", 300) ))) ) ))); Assert.AreEqual(expected.ToString(), tariff.ToJSON().ToString()); }
public static void Tariff0004() { var tariff = new Tariff(Tariff_Id.Parse("11"), Currency.EUR, TariffUrl: new Uri("https://company.com/tariffs/11"), TariffElements: new List<TariffElement>() { // 2.50 euro start tariff new TariffElement( PriceComponent.FlatRate(2.50M) ), // 1.00 euro per hour charging tariff for less than 32A (paid per 15 minutes) new TariffElement( PriceComponent.ChargingTime(1.00M, TimeSpan.FromSeconds(900)), TariffRestriction.MaxPower(32M) ), // 2.00 euro per hour charging tariff for more than 32A on weekdays (paid per 10 minutes) new TariffElement( PriceComponent.ChargingTime(2.00M, TimeSpan.FromSeconds(600)), new TariffRestriction(Power: DecimalMinMax.FromMin(32M), DayOfWeek: Enumeration.Create( DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday )) ), // 1.25 euro per hour charging tariff for more then 32A during the weekend (paid per 10 minutes) new TariffElement( PriceComponent.ChargingTime(1.25M, TimeSpan.FromSeconds(600)), new TariffRestriction(Power: DecimalMinMax.FromMin(32M), DayOfWeek: Enumeration.Create( DayOfWeek.Saturday, DayOfWeek.Sunday )) ), // Parking on weekdays: between 09:00 and 18:00: 5 euro(paid per 5 minutes) new TariffElement( PriceComponent.ParkingTime(5M, TimeSpan.FromSeconds(300)), new TariffRestriction(Time: TimeRange.From(9).To(18), DayOfWeek: Enumeration.Create( DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday )) ), // Parking on saturday: between 10:00 and 17:00: 6 euro (paid per 5 minutes) new TariffElement( PriceComponent.ParkingTime(6M, TimeSpan.FromSeconds(300)), new TariffRestriction(Time: TimeRange.From(10).To(17), DayOfWeek: new DayOfWeek[] { DayOfWeek.Saturday }) ) } ); var expected = new JObject(new JProperty("id", "11"), new JProperty("currency", "EUR"), new JProperty("tariff_alt_url", "https://company.com/tariffs/11"), new JProperty("elements", new JArray( // 2.50 euro start tariff new JObject( new JProperty("price_components", new JArray( new JObject( new JProperty("type", "FLAT"), new JProperty("price", "2.50"), new JProperty("step_size", 1) ))) ), // 1.00 euro per hour charging tariff for less than 32A (paid per 15 minutes) new JObject( new JProperty("price_components", new JArray( new JObject( new JProperty("type", "TIME"), new JProperty("price", "1.00"), new JProperty("step_size", 900) ))), new JProperty("restrictions", new JArray( new JObject( new JProperty("max_power", "32.00") ) )) ), // 2.00 euro per hour charging tariff for more than 32A on weekdays (paid per 10 minutes) new JObject( new JProperty("price_components", new JArray( new JObject( new JProperty("type", "TIME"), new JProperty("price", "2.00"), new JProperty("step_size", 600) ))), new JProperty("restrictions", new JArray( new JObject( new JProperty("min_power", "32.00"), new JProperty("day_of_week", new JArray("MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY")) ) )) ), // 1.25 euro per hour charging tariff for more then 32A during the weekend (paid per 10 minutes) new JObject( new JProperty("price_components", new JArray( new JObject( new JProperty("type", "TIME"), new JProperty("price", "1.25"), new JProperty("step_size", 600) ))), new JProperty("restrictions", new JArray( new JObject( new JProperty("min_power", "32.00"), new JProperty("day_of_week", new JArray("SATURDAY", "SUNDAY")) ) )) ), // Parking on weekdays: between 09:00 and 18:00: 5 euro(paid per 5 minutes) new JObject( new JProperty("price_components", new JArray( new JObject( new JProperty("type", "PARKING_TIME"), new JProperty("price", "5.00"), new JProperty("step_size", 300) ))), new JProperty("restrictions", new JArray( new JObject( new JProperty("start_time", "09:00"), new JProperty("end_time", "18:00"), new JProperty("day_of_week", new JArray("MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY")) ) )) ), // Parking on saturday: between 10:00 and 17:00: 6 euro (paid per 5 minutes) new JObject( new JProperty("price_components", new JArray( new JObject( new JProperty("type", "PARKING_TIME"), new JProperty("price", "6.00"), new JProperty("step_size", 300) ))), new JProperty("restrictions", new JArray( new JObject( new JProperty("start_time", "10:00"), new JProperty("end_time", "17:00"), new JProperty("day_of_week", new JArray("SATURDAY")) ) )) ) ))); Assert.AreEqual(expected.ToString(), tariff.ToJSON().ToString()); }