Exemple #1
0
        /// <summary>
        /// Returns true if BankingProductLendingRate instances are equal
        /// </summary>
        /// <param name="other">Instance of BankingProductLendingRate to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(BankingProductLendingRate other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     LendingRateType == other.LendingRateType ||
                     LendingRateType != null &&
                     LendingRateType.Equals(other.LendingRateType)
                     ) &&
                 (
                     Rate == other.Rate ||
                     Rate != null &&
                     Rate.Equals(other.Rate)
                 ) &&
                 (
                     CalculationFrequency == other.CalculationFrequency ||
                     CalculationFrequency != null &&
                     CalculationFrequency.Equals(other.CalculationFrequency)
                 ) &&
                 (
                     ApplicationFrequency == other.ApplicationFrequency ||
                     ApplicationFrequency != null &&
                     ApplicationFrequency.Equals(other.ApplicationFrequency)
                 ) &&
                 (
                     PaymentStructureType == other.PaymentStructureType ||
                     PaymentStructureType != null &&
                     PaymentStructureType.Equals(other.PaymentStructureType)
                 ) &&
                 (
                     Tier == other.Tier ||
                     Tier != null &&
                     Tier.Equals(other.Tier)
                 ) &&
                 (
                     AdditionalValue == other.AdditionalValue ||
                     AdditionalValue != null &&
                     AdditionalValue.Equals(other.AdditionalValue)
                 ) &&
                 (
                     AdditionalInfo == other.AdditionalInfo ||
                     AdditionalInfo != null &&
                     AdditionalInfo.Equals(other.AdditionalInfo)
                 ) &&
                 (
                     AdditionalInfoUri == other.AdditionalInfoUri ||
                     AdditionalInfoUri != null &&
                     AdditionalInfoUri.Equals(other.AdditionalInfoUri)
                 ));
        }
        public int CalculateIncomeTax(int annualSalary, CalculationFrequency calculationFrequency)
        {
            TaxBracketConfigSection settings = TaxBracketConfigSection.LoadSettings();
            var taxInfo = settings.TaxBrackets
                          .Find(taxBracket => (taxBracket.MinSalary == 0 || annualSalary > taxBracket.MinSalary) &&
                                (taxBracket.MaxSalary == -1 || annualSalary <= taxBracket.MaxSalary));

            int   taxableDollars = annualSalary - taxInfo.MinSalary;
            int   baseTax        = taxInfo.BaseTax;
            float centsPerDollar = taxInfo.TaxInCentsPerDollar;

            var tax = (baseTax + (taxableDollars * (centsPerDollar / 100))) / (int)calculationFrequency;

            return(((decimal)tax).RoundToNearestInt());
        }
        /// <summary>
        /// Returns true if BankingAccountDepositRate instances are equal
        /// </summary>
        /// <param name="other">Instance of BankingAccountDepositRate to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(BankingAccountDepositRate other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     DepositRateType == other.DepositRateType ||
                     DepositRateType != null &&
                     DepositRateType.Equals(other.DepositRateType)
                     ) &&
                 (
                     Rate == other.Rate ||
                     Rate != null &&
                     Rate.Equals(other.Rate)
                 ) &&
                 (
                     CalculationFrequency == other.CalculationFrequency ||
                     CalculationFrequency != null &&
                     CalculationFrequency.Equals(other.CalculationFrequency)
                 ) &&
                 (
                     ApplicationFrequency == other.ApplicationFrequency ||
                     ApplicationFrequency != null &&
                     ApplicationFrequency.Equals(other.ApplicationFrequency)
                 ) &&
                 (
                     AdditionalValue == other.AdditionalValue ||
                     AdditionalValue != null &&
                     AdditionalValue.Equals(other.AdditionalValue)
                 ) &&
                 (
                     AdditionalInfo == other.AdditionalInfo ||
                     AdditionalInfo != null &&
                     AdditionalInfo.Equals(other.AdditionalInfo)
                 ) &&
                 (
                     AdditionalInfoUri == other.AdditionalInfoUri ||
                     AdditionalInfoUri != null &&
                     AdditionalInfoUri.Equals(other.AdditionalInfoUri)
                 ));
        }
Exemple #4
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (LendingRateType != null)
         {
             hashCode = hashCode * 59 + LendingRateType.GetHashCode();
         }
         if (Rate != null)
         {
             hashCode = hashCode * 59 + Rate.GetHashCode();
         }
         if (CalculationFrequency != null)
         {
             hashCode = hashCode * 59 + CalculationFrequency.GetHashCode();
         }
         if (ApplicationFrequency != null)
         {
             hashCode = hashCode * 59 + ApplicationFrequency.GetHashCode();
         }
         if (PaymentStructureType != null)
         {
             hashCode = hashCode * 59 + PaymentStructureType.GetHashCode();
         }
         if (Tier != null)
         {
             hashCode = hashCode * 59 + Tier.GetHashCode();
         }
         if (AdditionalValue != null)
         {
             hashCode = hashCode * 59 + AdditionalValue.GetHashCode();
         }
         if (AdditionalInfo != null)
         {
             hashCode = hashCode * 59 + AdditionalInfo.GetHashCode();
         }
         if (AdditionalInfoUri != null)
         {
             hashCode = hashCode * 59 + AdditionalInfoUri.GetHashCode();
         }
         return(hashCode);
     }
 }