Ejemplo n.º 1
0
        /// <summary>
        /// Uses the rates data to calculate the totals and setup the required data for printing
        /// </summary>
        public void CalculateTotals()
        {
            // setup the rates lists -> records in the total and records not included
            RentalAgreementRatesWithTotal    = RentalAgreementRates.FindAll(x => x.IsIncludedInTotal);
            RentalAgreementRatesWithoutTotal = RentalAgreementRates.FindAll(x => !x.IsIncludedInTotal);

            // calculate the total
            float temp = 0.0F;

            foreach (RentalAgreementRate rentalRate in RentalAgreementRatesWithTotal)
            {
                if (rentalRate.PercentOfEquipmentRate != null &&
                    EquipmentRate != null &&
                    rentalRate.PercentOfEquipmentRate > 0)
                {
                    rentalRate.Rate = (float)rentalRate.PercentOfEquipmentRate * ((float)EquipmentRate / 100);
                    temp            = temp + (float)rentalRate.Rate;
                }
                else if (rentalRate.Rate != null)
                {
                    temp = temp + (float)rentalRate.Rate;
                }

                // format the rate / percent at the same time
                rentalRate.RateString = FormatRateString(rentalRate);
            }

            // add the base amount to the total too
            if (EquipmentRate != null)
            {
                temp = temp + (float)EquipmentRate;
            }

            AgreementTotal = temp;

            // format the base rate
            BaseRateString = string.Format("$ {0:0.00} / {1}", EquipmentRate, FormatRatePeriod(RatePeriod));

            // format the total
            AgreementTotalString = string.Format("$ {0:0.00} / {1}", AgreementTotal, FormatRatePeriod(RatePeriod));

            // format the rate / percent values
            foreach (RentalAgreementRate rentalRate in RentalAgreementRatesWithoutTotal)
            {
                if (rentalRate.PercentOfEquipmentRate != null &&
                    EquipmentRate != null &&
                    rentalRate.PercentOfEquipmentRate > 0)
                {
                    rentalRate.Rate = (float)rentalRate.PercentOfEquipmentRate * ((float)EquipmentRate / 100);
                }

                rentalRate.RateString = FormatRateString(rentalRate);
            }
        }
Ejemplo n.º 2
0
        /// <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);
            }
        }
Ejemplo n.º 3
0
        /// <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)
                 ));
        }