Exemplo n.º 1
0
        /// <summary>
        /// Starts full calculation proccess.
        /// </summary>
        /// <param name="message">Delegate for UI message.</param>
        /// <returns>Returns the calculation decision made.</returns>
        public Warning BeginCalc(Message message)
        {
            decimal averagePercentage = 0;
            bool    paystubRatio      = true;
            bool    accuracyOutput    = true;

            Decision = CalculationDecision();

            // Maybe add a name to the paystub collection??
            message(Decision.ToString());

            if (Decision == CalcType.CalcGross)
            {
                averagePercentage = CalculatePercentage();
                SetPercentage(averagePercentage);
                paystubRatio = CheckCompletedPaystubRatio();
                Paystub.GrossFromPercentageList(Paystubs);
                accuracyOutput = CheckPercentageAccuracy();
                RunAverages();
            }
            else if (Decision == CalcType.CalcNet)
            {
                averagePercentage = CalculatePercentage();
                SetPercentage(averagePercentage);
                paystubRatio = CheckCompletedPaystubRatio();
                Paystub.NetFromPercentageList(Paystubs);
                accuracyOutput = CheckPercentageAccuracy();
                RunAverages();
            }

            return(CheckWarning(paystubRatio, accuracyOutput));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Starts full calculation proccess.
        /// </summary>
        /// <param name="message">String to be printed through the UI.</param>
        /// <param name="warning">Warning Enum to display to the user.</param>
        /// <param name="passCount">The desired number of completed paystubs.</param>
        public static Tuple <List <Paystub>, Tuple <decimal, decimal, decimal>, Tuple <decimal, decimal> > BeginCalc(Message message, WarningMessage warning, List <Paystub> paystubs, decimal accuracy, int passCount = 1)
        {
            int completePaystubs = 0;

            decimal averagePercentage = 0;
            decimal percentAccuracy   = 0;
            decimal outputRatio       = 0;
            bool    paystubRatio      = true;
            bool    accuracyOutput    = true;

            Decision = CalculationDecision(paystubs);

            // Maybe add a name to the paystub collection??
            message(Decision.ToString());

            Tuple <decimal, int> calcPercentageOutput = CalculatePercentage(paystubs);

            averagePercentage = calcPercentageOutput.Item1;
            completePaystubs  = calcPercentageOutput.Item2;

            SetPercentage(paystubs, averagePercentage);
            Tuple <bool, decimal> checkCompleteOutput = CheckCompletedPaystubRatio(paystubs, passCount, completePaystubs);

            paystubRatio = checkCompleteOutput.Item1;
            outputRatio  = checkCompleteOutput.Item2;

            if (Decision == CalcType.CalcGross)
            {
                Paystub.GrossFromPercentageList(paystubs);
            }
            else if (Decision == CalcType.CalcNet)
            {
                Paystub.NetFromPercentageList(paystubs);
            }

            Tuple <bool, decimal> checkPercentOutput = CheckPercentageAccuracy(paystubs, accuracy);

            accuracyOutput  = checkPercentOutput.Item1;
            percentAccuracy = checkPercentOutput.Item2;

            warning(CheckWarning(paystubRatio, accuracyOutput));

            Tuple <decimal, decimal> calcAccuracy = Tuple.Create(percentAccuracy, outputRatio);

            Tuple <decimal, decimal, decimal> averagesOut = RunAverages(paystubs);

            return(Tuple.Create(paystubs, averagesOut, calcAccuracy));
        }