示例#1
0
        public void Excemptions()
        {
            Console.WriteLine("Excemptions : - \n" +
                              "1. Section 1 - Hostel fees \n" +
                              "2. Section 2 - Transportation fees");
            Constants.ExcemptionType option = (Constants.ExcemptionType) this.UtilityService.GetIntegerInput("Please select the excemption type : - \n ");
            int  excemptionAmount           = this.UtilityService.GetIntegerInput("Enter excemption amount : - ");
            bool isApplied = false;

            switch (option)
            {
            case Constants.ExcemptionType.Hostel:
                if (excemptionAmount > Constants.ExcemptionsList[0].Amount || excemptionAmount < 1)
                {
                    Console.WriteLine("Invalid excemption amount");
                    break;
                }
                isApplied = this.CalculateService.TaxAfterExcemption(Constants.ExcemptionType.Hostel, excemptionAmount);

                break;

            case Constants.ExcemptionType.Transport:
                if (excemptionAmount > Constants.ExcemptionsList[1].Amount || excemptionAmount < 1)
                {
                    Console.WriteLine("Invalid excemption amount");
                    break;
                }
                isApplied = this.CalculateService.TaxAfterExcemption(Constants.ExcemptionType.Transport, excemptionAmount);

                break;

            default:
                Console.WriteLine("Enter a valid input : -");
                Excemptions();

                break;
            }
            if (isApplied)
            {
                ExcemptionsMenu();
            }
            else
            {
                Console.WriteLine("Excemption not applied");
                ShowTaxes();
            }
        }
示例#2
0
        public bool TaxAfterExcemption(Constants.ExcemptionType type, int excemptionAmount)
        {
            Excemption excemption = Tax.Excemptions.Find(ex => ex.Type == type);

            if (excemption != null)
            {
                return(false);
            }

            this.Tax.Amount    -= excemptionAmount;
            this.Tax.Percentage = decimal.Round(decimal.Divide(Tax.Amount * 100, Tax.TotalIncome), 2);
            this.Tax.Excemptions.Add(new Excemption()
            {
                Amount = excemptionAmount,
                Type   = type
            });

            return(true);
        }