/// <summary> /// Returns true if RentalAgreementRate instances are equal /// </summary> /// <param name="other">Instance of RentalAgreementRate to be compared</param> /// <returns>Boolean</returns> public bool Equals(RentalAgreementRate other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id.Equals(other.Id) ) && ( RentalAgreement == other.RentalAgreement || RentalAgreement != null && RentalAgreement.Equals(other.RentalAgreement) ) && ( ComponentName == other.ComponentName || ComponentName != null && ComponentName.Equals(other.ComponentName) ) && ( IsAttachment == other.IsAttachment || IsAttachment != null && IsAttachment.Equals(other.IsAttachment) ) && ( Rate == other.Rate || Rate != null && Rate.Equals(other.Rate) ) && ( PercentOfEquipmentRate == other.PercentOfEquipmentRate || PercentOfEquipmentRate != null && PercentOfEquipmentRate.Equals(other.PercentOfEquipmentRate) ) && ( RatePeriod == other.RatePeriod || RatePeriod != null && RatePeriod.Equals(other.RatePeriod) ) && ( Comment == other.Comment || Comment != null && Comment.Equals(other.Comment) ) && ( TimeRecords == other.TimeRecords || TimeRecords != null && TimeRecords.SequenceEqual(other.TimeRecords) )); }
/// <summary> /// Equivalências de taxas por período /// </summary> /// <param name="input">Taxa Informada</param> /// <param name="ratePeriodFrom">Define o tipo de entrada</param> /// <param name="ratePeriodTo">Define o tipo de saída</param> /// <returns></returns> public static float GetEquivalentRate(float input, RatePeriod ratePeriodFrom, RatePeriod ratePeriodTo) { Func <float, float> returnTo = delegate(float convertDay) { return(convertDay * (int)(ratePeriodTo)); }; return(returnTo(input / (int)ratePeriodFrom)); }
public static Videa.SharebuilderRateNS.Data.DataServices.RatePeriod ToEntity(this RatePeriod source) { return(new Videa.SharebuilderRateNS.Data.DataServices.RatePeriod { RatePeriodHashKey = source.RatePeriodHashKey.ToCharArray(), RatePeriodSqn = source.RatePeriodSqn, RatePeriodName = source.RatePeriodName, RatePeriodStartDate = source.RatePeriodStartDate.ToDateTime(), RatePeriodEndDate = source.RatePeriodEndDate.ToDateTime() }); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { int hash = 41; // Suitable nullity checks hash = hash * 59 + Id.GetHashCode(); if (RentalAgreement != null) { hash = hash * 59 + RentalAgreement.GetHashCode(); } hash = hash * 59 + IsIncludedInTotal.GetHashCode(); if (ComponentName != null) { hash = hash * 59 + ComponentName.GetHashCode(); } if (IsAttachment != null) { hash = hash * 59 + IsAttachment.GetHashCode(); } if (Rate != null) { hash = hash * 59 + Rate.GetHashCode(); } if (PercentOfEquipmentRate != null) { hash = hash * 59 + PercentOfEquipmentRate.GetHashCode(); } if (RatePeriod != null) { hash = hash * 59 + RatePeriod.GetHashCode(); } if (Comment != null) { hash = hash * 59 + Comment.GetHashCode(); } if (TimeRecords != null) { hash = hash * 59 + TimeRecords.GetHashCode(); } return(hash); } }
public void Ctor() { var startTime = DateTime.Parse("1:00PM"); var endTime = DateTime.Parse("8:00PM"); decimal rate = 10.00M; var ratePeriod = new RatePeriod(startTime, endTime, rate); Assert.AreEqual(startTime, ratePeriod.StartTime); Assert.AreEqual(endTime, ratePeriod.EndTime); Assert.AreEqual(rate, ratePeriod.Rate); }
public void PeriodCrossesMidnight() { var startTime = DateTime.Parse("12:00PM"); var endTime = DateTime.Parse("4:00AM"); decimal rate = 10.00M; var ratePeriod = new RatePeriod(startTime, endTime, rate); var jobStartTime = DateTime.Parse("1:00PM"); var jobEndTime = DateTime.Parse("1:00AM"); Assert.AreEqual(12, ratePeriod.HrsInRatePeriod(jobStartTime, jobEndTime)); Assert.AreEqual(120.00M, ratePeriod.CalculatePayment(jobStartTime, jobEndTime)); }
public void EndTimeAfterPeriodEnd() { var startTime = DateTime.Parse("12:00PM"); var endTime = DateTime.Parse("4:00PM"); decimal rate = 10.00M; var ratePeriod = new RatePeriod(startTime, endTime, rate); var jobStartTime = DateTime.Parse("1:00PM"); var jobEndTime = DateTime.Parse("8:00PM"); Assert.AreEqual(3, ratePeriod.HrsInRatePeriod(jobStartTime, jobEndTime)); Assert.AreEqual(30.00M, ratePeriod.CalculatePayment(jobStartTime, jobEndTime)); }
public void EndTimeBeforePeriodStart() { var startTime = DateTime.Parse("12:00PM"); var endTime = DateTime.Parse("4:00PM"); decimal rate = 10.00M; var ratePeriod = new RatePeriod(startTime, endTime, rate); var jobStartTime = DateTime.Parse("5:00AM"); var jobEndTime = DateTime.Parse("10:00AM"); Assert.AreEqual(0, ratePeriod.HrsInRatePeriod(jobStartTime, jobEndTime)); Assert.AreEqual(0M, ratePeriod.CalculatePayment(jobStartTime, jobEndTime)); }
public void JobsOnHalfHoursWork() { var periodStartTime = DateTime.Parse("10:00AM"); var periodEndTime = DateTime.Parse("4:00PM"); decimal periodRate = 10.00M; var ratePeriod = new RatePeriod(periodStartTime, periodEndTime, periodRate); var jobStartTime = DateTime.Parse("12:30 PM"); var jobEndTime = DateTime.Parse("3:30 PM"); Assert.AreEqual(3, ratePeriod.HrsInRatePeriod(jobStartTime, jobEndTime)); Assert.AreEqual(30.00M, ratePeriod.CalculatePayment(jobStartTime, jobEndTime)); }
public void EntireJobAfterMidnight() { var startTime = DateTime.Parse("1:00AM"); var endTime = DateTime.Parse("4:00AM"); decimal rate = 10.00M; var ratePeriod = new RatePeriod(startTime, endTime, rate); var jobStartTime = DateTime.Parse("12:30AM"); var jobEndTime = DateTime.Parse("3:00AM"); Assert.AreEqual(2.0M, ratePeriod.HrsInRatePeriod(jobStartTime, jobEndTime)); Assert.AreEqual(20.00M, ratePeriod.CalculatePayment(jobStartTime, jobEndTime)); }
/// <summary> /// Equivalências de taxas por período /// </summary> /// <param name="input">Taxa Informada</param> /// <param name="ratePeriodFrom">Define o tipo de entrada</param> /// <param name="ratePeriodTo">Define o tipo de saída</param> /// <returns></returns> public static float GetEquivalentRate(float input, RatePeriod ratePeriodFrom, RatePeriod ratePeriodTo) { double pow = Convert.ToDouble((int)ratePeriodTo > (int)ratePeriodFrom ? ((int)ratePeriodTo / (int)ratePeriodFrom) : ((int)ratePeriodFrom / (int)ratePeriodTo)); if ((int)ratePeriodTo > (int)ratePeriodFrom) { return(Convert.ToSingle(Math.Pow(1.0 + Convert.ToDouble(input), pow) - 1)); } else { return(Convert.ToSingle(Math.Pow(1.0 + Convert.ToDouble(input), 1 / pow) - 1)); } }
public void Ctor() { string name = "Test Family"; RatePeriod[] ratePeriods = new RatePeriod[] { new RatePeriod(DateTime.Parse("8:00PM"), DateTime.Parse("1:00AM"), 10.00M) }; var family = new Family(name, ratePeriods); Assert.AreEqual(name, family.Name); Assert.AreEqual(ratePeriods, family.RatePeriods); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { int hash = 41; // Suitable nullity checks hash = hash * 59 + Id.GetHashCode(); if (Number != null) { hash = hash * 59 + Number.GetHashCode(); } if (Status != null) { hash = hash * 59 + Status.GetHashCode(); } if (Equipment != null) { hash = hash * 59 + Equipment.GetHashCode(); } if (Project != null) { hash = hash * 59 + Project.GetHashCode(); } if (RentalAgreementRates != null) { hash = hash * 59 + RentalAgreementRates.GetHashCode(); } if (RentalAgreementConditions != null) { hash = hash * 59 + RentalAgreementConditions.GetHashCode(); } if (TimeRecords != null) { hash = hash * 59 + TimeRecords.GetHashCode(); } if (Note != null) { hash = hash * 59 + Note.GetHashCode(); } if (EstimateStartWork != null) { hash = hash * 59 + EstimateStartWork.GetHashCode(); } if (DatedOn != null) { hash = hash * 59 + DatedOn.GetHashCode(); } if (EstimateHours != null) { hash = hash * 59 + EstimateHours.GetHashCode(); } if (EquipmentRate != null) { hash = hash * 59 + EquipmentRate.GetHashCode(); } if (RatePeriod != null) { hash = hash * 59 + RatePeriod.GetHashCode(); } if (RateComment != null) { hash = hash * 59 + RateComment.GetHashCode(); } return(hash); } }
/// <summary> /// Returns true if RentalAgreement instances are equal /// </summary> /// <param name="other">Instance of RentalAgreement to be compared</param> /// <returns>Boolean</returns> public bool Equals(RentalAgreement other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id.Equals(other.Id) ) && ( Number == other.Number || Number != null && Number.Equals(other.Number) ) && ( Status == other.Status || Status != null && Status.Equals(other.Status) ) && ( Equipment == other.Equipment || Equipment != null && Equipment.Equals(other.Equipment) ) && ( Project == other.Project || Project != null && Project.Equals(other.Project) ) && ( RentalAgreementRates == other.RentalAgreementRates || RentalAgreementRates != null && RentalAgreementRates.SequenceEqual(other.RentalAgreementRates) ) && ( RentalAgreementConditions == other.RentalAgreementConditions || RentalAgreementConditions != null && RentalAgreementConditions.SequenceEqual(other.RentalAgreementConditions) ) && ( TimeRecords == other.TimeRecords || TimeRecords != null && TimeRecords.SequenceEqual(other.TimeRecords) ) && ( Note == other.Note || Note != null && Note.Equals(other.Note) ) && ( EstimateStartWork == other.EstimateStartWork || EstimateStartWork != null && EstimateStartWork.Equals(other.EstimateStartWork) ) && ( DatedOn == other.DatedOn || DatedOn != null && DatedOn.Equals(other.DatedOn) ) && ( EstimateHours == other.EstimateHours || EstimateHours != null && EstimateHours.Equals(other.EstimateHours) ) && ( EquipmentRate == other.EquipmentRate || EquipmentRate != null && EquipmentRate.Equals(other.EquipmentRate) ) && ( RatePeriod == other.RatePeriod || RatePeriod != null && RatePeriod.Equals(other.RatePeriod) ) && ( RateComment == other.RateComment || RateComment != null && RateComment.Equals(other.RateComment) )); }
public LimitRateAttribute(LimitType type, int limit, RatePeriod period = RatePeriod.PerMinute) : this(type, limit, (int)period) { }
public LimitRateAttribute(int limit, RatePeriod period = RatePeriod.PerMinute) : this(LimitType.PerRequest, limit, (int)period) { }