Example #1
0
        private async Task <bool> HasAdjustmentAmountAsync(State state)
        {
            if (((Adjustment)state).AdjustmentAmount.HasValue)
            {
                var adjustmentDecision = state.Antecedent as AdjustmentDecision;
                var collateData        = adjustmentDecision.Antecedent as CollateData;

                if ((((Adjustment)state).AdjustmentAmount.Value
                     + collateData.RedressAmount.Value) > 100)
                {
                    if (Transition == null)
                    {
                        Transition = Transitions.FirstOrDefault();
                    }

                    await TaskRunner.DoAsyncStuff();

                    return(true);
                }

                var error = "The sum of the redress amount and the adjustment amount must be greater than 100.";
                state.Log.Add(new LogEntry(error));
                throw new StateException(state, error);
            }
            else
            {
                var error = String.Format("{0} requires an adjustment amount before it can be completed.", state.Name);
                state.WriteLogEntry(error);
                throw new StateException(state, error);
            }
        }
Example #2
0
        private async Task <bool> HasPaymentDateAsync(State state)
        {
            if (((Payment)state).PaymentDate.HasValue)
            {
                await TaskRunner.DoAsyncStuff();

                return(true);
            }

            var error = String.Format("{0} requires a payment date before it can be completed.", state.Name);

            state.WriteLogEntry(error);
            throw new StateException(state, error);
        }
Example #3
0
        private async Task <bool> HasResponseReceivedDateAsync(State state)
        {
            if (((ResponseReceived)state).ResponseReceivedDate.HasValue)
            {
                await TaskRunner.DoAsyncStuff();

                return(true);
            }

            var error = String.Format("{0} requires a response recieved date before it can be completed.", state.Name);

            state.WriteLogEntry(error);
            throw new StateException(state, error);
        }
Example #4
0
        private async Task <bool> HasRedressRateAsync(State state)
        {
            if (((CollateData)state).RedressAmount.HasValue)
            {
                if (Transition == null)
                {
                    Transition = Transitions.FirstOrDefault();
                }

                await TaskRunner.DoAsyncStuff();

                return(true);
            }

            var error = String.Format("{0} requires a redress amount before it can be completed.", state.Name);

            state.WriteLogEntry(error);
            throw new StateException(state, error);
        }
        internal async Task ConditionalTransitionDecisionAsync(State context)
        {
            var collateData = context.Antecedent as CollateData;

            if (collateData.RedressAmount == null ||
                collateData.RedressAmount.Value < 1000)
            {
                // If the calculated redress amount is less
                // than 100 transition to adjustment.
                context.Transition = context.Transitions[0];
                ((Adjustment)context.Transition).IsAdjustmentApplicable = true;
            }
            else
            {
                // If the calculated redress amount is greater
                // or equal to 100 transition to redress review.
                context.Transition = context.Transitions[1];
                ((Adjustment)context.Transitions[0]).IsAdjustmentApplicable = false;
            }

            await TaskRunner.DoAsyncStuff();
        }
Example #6
0
        internal async Task CalculateFinalRedressAmountAsync(State context)
        {
            var states           = context.Flatten();
            var collateData      = states.OfType <CollateData>().FirstOrDefault(s => s.Name.Equals("Collate Data"));
            var responseReceived = states.OfType <ResponseReceived>().FirstOrDefault(s => s.Name.Equals("Response Received"));
            var adjustment       = states.OfType <Adjustment>().FirstOrDefault(s => s.Name.Equals("Adjustment"));

            decimal?finalRedressAmount = 0;

            if (collateData != null &&
                collateData.RedressAmount.HasValue)
            {
                finalRedressAmount = collateData.RedressAmount;
            }

            if (adjustment != null &&
                adjustment.AdjustmentAmount.HasValue)
            {
                finalRedressAmount += adjustment.AdjustmentAmount;
            }

            if (responseReceived != null &&
                responseReceived.ConsequentialLossClaim.HasValue)
            {
                finalRedressAmount += responseReceived.ConsequentialLossClaim;
            }

            FinalRedressAmount = finalRedressAmount;

            if (Transition == null)
            {
                Transition = Transitions.FirstOrDefault(s => s.Name.Equals("Payment"));
            }

            await TaskRunner.DoAsyncStuff();
        }