Exemple #1
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = ContractID;
         hashCode = (hashCode * 397) ^ (ContractName != null ? ContractName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ CustomerID;
         hashCode = (hashCode * 397) ^ (CustomerName != null ? CustomerName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ContractType != null ? ContractType.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Active.GetHashCode();
         hashCode = (hashCode * 397) ^ Default.GetHashCode();
         hashCode = (hashCode * 397) ^ Taxable.GetHashCode();
         hashCode = (hashCode * 397) ^ StartDate.GetHashCode();
         hashCode = (hashCode * 397) ^ EndDate.GetHashCode();
         hashCode = (hashCode * 397) ^ (RetainerFlatFeeContract != null ? RetainerFlatFeeContract.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (HourlyContract != null ? HourlyContract.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (BlockHoursContract != null ? BlockHoursContract.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (BlockMoneyContract != null ? BlockMoneyContract.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (RemoteMonitoringContract != null ? RemoteMonitoringContract.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (OnlineBackupContract != null ? OnlineBackupContract.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ProjectOneTimeFeeContract != null ? ProjectOneTimeFeeContract.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ProjectHourlyRateContract != null ? ProjectHourlyRateContract.GetHashCode() : 0);
         return(hashCode);
     }
 }
        /// <summary>
        /// Reads the tax selection from the console
        /// </summary>
        /// <param name="serviceProvider">the service provider</param>
        /// <returns></returns>
        private static Taxable ReadTaxSelection(ServiceProvider serviceProvider)
        {
            Console.WriteLine("Please pick an id from the following list:");

            WriteUserFriendlyTaxDescriptions(serviceProvider);
            string id = Console.ReadLine();

            Taxable taxable = Taxable.Undefined;

            while (taxable == Taxable.Undefined)
            {
                Console.WriteLine();
                bool parsedInteger = int.TryParse(id, out int idAsInt);
                if (!parsedInteger || parsedInteger && idAsInt != default && !Enum.IsDefined(typeof(Taxable), idAsInt))
                {
                    Console.WriteLine("Please enter a valid id from the list:");
                    id = Console.ReadLine();
                }
                else
                {
                    taxable = (Taxable)(idAsInt);
                }
            }
            return(taxable);
        }
Exemple #3
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is OrderReturnServiceCharge other &&
                   ((Uid == null && other.Uid == null) || (Uid?.Equals(other.Uid) == true)) &&
                   ((SourceServiceChargeUid == null && other.SourceServiceChargeUid == null) || (SourceServiceChargeUid?.Equals(other.SourceServiceChargeUid) == true)) &&
                   ((Name == null && other.Name == null) || (Name?.Equals(other.Name) == true)) &&
                   ((CatalogObjectId == null && other.CatalogObjectId == null) || (CatalogObjectId?.Equals(other.CatalogObjectId) == true)) &&
                   ((Percentage == null && other.Percentage == null) || (Percentage?.Equals(other.Percentage) == true)) &&
                   ((AmountMoney == null && other.AmountMoney == null) || (AmountMoney?.Equals(other.AmountMoney) == true)) &&
                   ((AppliedMoney == null && other.AppliedMoney == null) || (AppliedMoney?.Equals(other.AppliedMoney) == true)) &&
                   ((TotalMoney == null && other.TotalMoney == null) || (TotalMoney?.Equals(other.TotalMoney) == true)) &&
                   ((TotalTaxMoney == null && other.TotalTaxMoney == null) || (TotalTaxMoney?.Equals(other.TotalTaxMoney) == true)) &&
                   ((CalculationPhase == null && other.CalculationPhase == null) || (CalculationPhase?.Equals(other.CalculationPhase) == true)) &&
                   ((Taxable == null && other.Taxable == null) || (Taxable?.Equals(other.Taxable) == true)) &&
                   ((AppliedTaxes == null && other.AppliedTaxes == null) || (AppliedTaxes?.Equals(other.AppliedTaxes) == true)));
        }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = ChargeIntervalFrequency.GetHashCode();
         hashCode = (hashCode * 397) ^ CutoffDayOfMonth.GetHashCode();
         hashCode = (hashCode * 397) ^ CutoffDayOfWeek.GetHashCode();
         hashCode = (hashCode * 397) ^ ExpireAfterSpecificNumberOfCharges.GetHashCode();
         hashCode = (hashCode * 397) ^ (FulfillmentService != null ? FulfillmentService.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Grams.GetHashCode();
         hashCode = (hashCode * 397) ^ (LinePrice != null ? LinePrice.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ OrderDayOfMonth.GetHashCode();
         hashCode = (hashCode * 397) ^ OrderDayOfWeek.GetHashCode();
         hashCode = (hashCode * 397) ^ OrderIntervalFrequency.GetHashCode();
         hashCode = (hashCode * 397) ^ (OrderIntervalUnit != null ? OrderIntervalUnit.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Price != null ? Price.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ ProductId.GetHashCode();
         hashCode = (hashCode * 397) ^ Quantity.GetHashCode();
         hashCode = (hashCode * 397) ^ RequiresShipping.GetHashCode();
         hashCode = (hashCode * 397) ^ (Sku != null ? Sku.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Taxable.GetHashCode();
         hashCode = (hashCode * 397) ^ (Title != null ? Title.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ VariantId.GetHashCode();
         hashCode = (hashCode * 397) ^ (VariantTitle != null ? VariantTitle.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Vendor != null ? Vendor.GetHashCode() : 0);
         return(hashCode);
     }
 }
Exemple #5
0
 /// <summary>
 /// Constructor for an available tax type
 /// </summary>
 /// <param name="taxable">a taxable option</param>
 /// <param name="description">the enum description</param>
 /// <param name="id">the identifier</param>
 /// <parma name="taxPercentage"the tax percentage></param>
 public AvailableTaxType(Taxable taxable, string description, int id, string taxPercentage)
 {
     Taxable       = taxable;
     Description   = description;
     Id            = id;
     TaxPercentage = taxPercentage;
 }
Exemple #6
0
 //save() method for save button
 public String Save() //CSV
 {
     return(Name + "," + Salary.ToString()
            + "," + Investment.ToString()
            + "," + Taxable.ToString()
            + "," + (Rate * 100).ToString()
            + "," + (Taxable * Rate).ToString());
 }
 protected void ToString(List <string> toStringOutput)
 {
     toStringOutput.Add($"Name = {(Name == null ? "null" : Name == string.Empty ? "" : Name)}");
     toStringOutput.Add($"AppliedMoney = {(AppliedMoney == null ? "null" : AppliedMoney.ToString())}");
     toStringOutput.Add($"Rate = {(Rate == null ? "null" : Rate == string.Empty ? "" : Rate)}");
     toStringOutput.Add($"AmountMoney = {(AmountMoney == null ? "null" : AmountMoney.ToString())}");
     toStringOutput.Add($"Type = {(Type == null ? "null" : Type.ToString())}");
     toStringOutput.Add($"Taxable = {(Taxable == null ? "null" : Taxable.ToString())}");
     toStringOutput.Add($"Taxes = {(Taxes == null ? "null" : $"[{ string.Join(", ", Taxes)} ]")}");
     toStringOutput.Add($"SurchargeId = {(SurchargeId == null ? "null" : SurchargeId == string.Empty ? "" : SurchargeId)}");
 }
Exemple #8
0
 /// <summary>
 /// Constructor for a taxable item.
 /// </summary>
 /// <param name="taxable">an enumeration representing whether or not the item is taxable</param>
 /// <param name="priceWithoutTax">the price without tax</param>
 /// <param name="itemName">the item name</parma>
 /// <param name="taxCalculator">the tax calculator</param>
 public ShoppingItem(
     Taxable taxable,
     decimal priceWithoutTax,
     string itemName,
     ITaxCalculator taxCalculator
     )
 {
     Taxable            = taxable;
     PriceWithoutTax    = priceWithoutTax;
     ItemName           = itemName;
     TaxAmountAsPercent = taxCalculator.DetermineTaxPercentage(Taxable);
     FinalItemPrice     = taxCalculator.CalculatePriceWithTax(this);
 }
        /// <inehritdoc cref="ITaxCalculator.DetermineTaxPercentage(Taxable)">
        public decimal DetermineTaxPercentage(Taxable taxableItem)
        {
            decimal baseTaxPercentage   = .10M;
            decimal importTaxPercentage = .05M;

            if (taxableItem == Taxable.Undefined)
            {
                throw new InvalidEnumArgumentException($"To attempt to calculate tax percentage {nameof(taxableItem)} must be defined");
            }

            if (taxableItem == Taxable.TaxExempt)
            {
                return(default);
Exemple #10
0
        /// <summary>
        /// Runs the console application
        /// </summary>
        /// <param name="serviceProvider">the service provider</param>
        private static void RunApp(ServiceProvider serviceProvider)
        {
            ShoppingCart taxItemManager = new ShoppingCart();

            bool finishedEnteringInput = false;

            while (!finishedEnteringInput)
            {
                string name = ReadTaxItemName();

                Taxable taxSelection = ReadTaxSelection(serviceProvider);

                decimal priceWithoutTax = ReadPriceWithoutTax();

                ITaxCalculator taxCalculator = serviceProvider.GetService <ITaxCalculator> ();

                IShoppingItem existingItem = taxItemManager.CheckIfItemExistsInCart(name);
                if (existingItem != null)
                {
                    Console.WriteLine();
                    Console.WriteLine($"Item with name {existingItem.ItemName} already exists, using prexisiting item price {existingItem.PriceWithoutTax}");
                    priceWithoutTax = existingItem.PriceWithoutTax;
                    taxSelection    = existingItem.Taxable;
                }

                ShoppingItem taxableItem = new ShoppingItem(
                    taxSelection,
                    priceWithoutTax,
                    name,
                    taxCalculator
                    );

                taxItemManager.Add(taxableItem);

                Console.WriteLine();
                Console.Write("Add another item? y/n: ");

                ConsoleKeyInfo key = Console.ReadKey();
                if (key.KeyChar == 'n')
                {
                    finishedEnteringInput = true;
                }

                Console.WriteLine();
            }
            IReceiptPrinter receiptPrinter = serviceProvider.GetService <IReceiptPrinter> ();

            receiptPrinter.PrintReceipt(taxItemManager.TaxableItems);
        }
Exemple #11
0
 protected void ToString(List <string> toStringOutput)
 {
     toStringOutput.Add($"Uid = {(Uid == null ? "null" : Uid == string.Empty ? "" : Uid)}");
     toStringOutput.Add($"SourceServiceChargeUid = {(SourceServiceChargeUid == null ? "null" : SourceServiceChargeUid == string.Empty ? "" : SourceServiceChargeUid)}");
     toStringOutput.Add($"Name = {(Name == null ? "null" : Name == string.Empty ? "" : Name)}");
     toStringOutput.Add($"CatalogObjectId = {(CatalogObjectId == null ? "null" : CatalogObjectId == string.Empty ? "" : CatalogObjectId)}");
     toStringOutput.Add($"Percentage = {(Percentage == null ? "null" : Percentage == string.Empty ? "" : Percentage)}");
     toStringOutput.Add($"AmountMoney = {(AmountMoney == null ? "null" : AmountMoney.ToString())}");
     toStringOutput.Add($"AppliedMoney = {(AppliedMoney == null ? "null" : AppliedMoney.ToString())}");
     toStringOutput.Add($"TotalMoney = {(TotalMoney == null ? "null" : TotalMoney.ToString())}");
     toStringOutput.Add($"TotalTaxMoney = {(TotalTaxMoney == null ? "null" : TotalTaxMoney.ToString())}");
     toStringOutput.Add($"CalculationPhase = {(CalculationPhase == null ? "null" : CalculationPhase.ToString())}");
     toStringOutput.Add($"Taxable = {(Taxable == null ? "null" : Taxable.ToString())}");
     toStringOutput.Add($"AppliedTaxes = {(AppliedTaxes == null ? "null" : $"[{ string.Join(", ", AppliedTaxes)} ]")}");
 }
        public override int GetHashCode()
        {
            int hashCode = -446593569;

            if (Name != null)
            {
                hashCode += Name.GetHashCode();
            }

            if (AppliedMoney != null)
            {
                hashCode += AppliedMoney.GetHashCode();
            }

            if (Rate != null)
            {
                hashCode += Rate.GetHashCode();
            }

            if (AmountMoney != null)
            {
                hashCode += AmountMoney.GetHashCode();
            }

            if (Type != null)
            {
                hashCode += Type.GetHashCode();
            }

            if (Taxable != null)
            {
                hashCode += Taxable.GetHashCode();
            }

            if (Taxes != null)
            {
                hashCode += Taxes.GetHashCode();
            }

            if (SurchargeId != null)
            {
                hashCode += SurchargeId.GetHashCode();
            }

            return(hashCode);
        }
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is V1PaymentSurcharge other &&
                   ((Name == null && other.Name == null) || (Name?.Equals(other.Name) == true)) &&
                   ((AppliedMoney == null && other.AppliedMoney == null) || (AppliedMoney?.Equals(other.AppliedMoney) == true)) &&
                   ((Rate == null && other.Rate == null) || (Rate?.Equals(other.Rate) == true)) &&
                   ((AmountMoney == null && other.AmountMoney == null) || (AmountMoney?.Equals(other.AmountMoney) == true)) &&
                   ((Type == null && other.Type == null) || (Type?.Equals(other.Type) == true)) &&
                   ((Taxable == null && other.Taxable == null) || (Taxable?.Equals(other.Taxable) == true)) &&
                   ((Taxes == null && other.Taxes == null) || (Taxes?.Equals(other.Taxes) == true)) &&
                   ((SurchargeId == null && other.SurchargeId == null) || (SurchargeId?.Equals(other.SurchargeId) == true)));
        }
Exemple #14
0
        public override int GetHashCode()
        {
            int hashCode = -2013241171;

            if (Uid != null)
            {
                hashCode += Uid.GetHashCode();
            }

            if (SourceServiceChargeUid != null)
            {
                hashCode += SourceServiceChargeUid.GetHashCode();
            }

            if (Name != null)
            {
                hashCode += Name.GetHashCode();
            }

            if (CatalogObjectId != null)
            {
                hashCode += CatalogObjectId.GetHashCode();
            }

            if (Percentage != null)
            {
                hashCode += Percentage.GetHashCode();
            }

            if (AmountMoney != null)
            {
                hashCode += AmountMoney.GetHashCode();
            }

            if (AppliedMoney != null)
            {
                hashCode += AppliedMoney.GetHashCode();
            }

            if (TotalMoney != null)
            {
                hashCode += TotalMoney.GetHashCode();
            }

            if (TotalTaxMoney != null)
            {
                hashCode += TotalTaxMoney.GetHashCode();
            }

            if (CalculationPhase != null)
            {
                hashCode += CalculationPhase.GetHashCode();
            }

            if (Taxable != null)
            {
                hashCode += Taxable.GetHashCode();
            }

            if (AppliedTaxes != null)
            {
                hashCode += AppliedTaxes.GetHashCode();
            }

            return(hashCode);
        }
        public override int GetHashCode()
        {
            int hashCode = 1266271501;

            if (Uid != null)
            {
                hashCode += Uid.GetHashCode();
            }

            if (Name != null)
            {
                hashCode += Name.GetHashCode();
            }

            if (CatalogObjectId != null)
            {
                hashCode += CatalogObjectId.GetHashCode();
            }

            if (Percentage != null)
            {
                hashCode += Percentage.GetHashCode();
            }

            if (AmountMoney != null)
            {
                hashCode += AmountMoney.GetHashCode();
            }

            if (AppliedMoney != null)
            {
                hashCode += AppliedMoney.GetHashCode();
            }

            if (TotalMoney != null)
            {
                hashCode += TotalMoney.GetHashCode();
            }

            if (TotalTaxMoney != null)
            {
                hashCode += TotalTaxMoney.GetHashCode();
            }

            if (CalculationPhase != null)
            {
                hashCode += CalculationPhase.GetHashCode();
            }

            if (Taxable != null)
            {
                hashCode += Taxable.GetHashCode();
            }

            if (AppliedTaxes != null)
            {
                hashCode += AppliedTaxes.GetHashCode();
            }

            if (Metadata != null)
            {
                hashCode += Metadata.GetHashCode();
            }

            return(hashCode);
        }
Exemple #16
0
 public void SetUp()
 {
     playerId  = 0;
     banker    = new TraditionalBanker(new[] { playerId });
     incomeTax = new Taxable(4, "Income Tax", banker, TestTaxFunction);
 }