Exemple #1
0
        internal XmlElement ToXmlElement(XmlHelper helper)
        {
            var xmlElement = helper.CreateElement("AboutBenefit");

            xmlElement.AppendChild(helper.CreateElement(nameof(RequestedAmount), RequestedAmount.GetAmount().ToString()));
            xmlElement.AppendChild(helper.CreateElement(nameof(Diagnosis), Diagnosis));
            xmlElement.AppendChild(helper.CreateElement(nameof(PhysicianInfo), PhysicianInfo.ToXmlElement(helper)));
            return(xmlElement);
        }
Exemple #2
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var validations = new List <ValidationResult>();

            validations.AddRange(RequestedAmount.Validate(nameof(RequestedAmount), true));

            if (string.IsNullOrWhiteSpace(Diagnosis))
            {
                validations.Add(new ValidationResult(string.Empty, new[] { nameof(Diagnosis) }));
            }

            validations.AddRange(PhysicianInfo.Validate(nameof(PhysicianInfo), true));
            return(validations);
        }
Exemple #3
0
        }                                                 // IsValid

        public QuickOfferModel GetOffer(bool bSaveOfferToDB, AConnection oDB, ASafeLog oLog)
        {
            if (RequestedAmount < Cfg.MinOfferAmount)
            {
                oLog.Debug("Requested amount (£{0}) is less than minimal offer amount (£{1}), not offering.", RequestedAmount, Cfg.MinOfferAmount);
                return(null);
            }             // if

            oDB.ForEachRowSafe(
                (sr, bRowsetStart) => {
                minLoanAmount = sr["MinLoanAmount"];
                return(ActionResult.SkipAll);
            },
                "GetBankBasedApprovalConfigs",
                CommandSpecies.StoredProcedure
                );

            decimal?nOffer = Calculate();

            if (!nOffer.HasValue)
            {
                return(null);
            }

            int nOfferID = default(int);

            decimal nRequestedAmount = RequestedAmount.Min(Cfg.PotentialMaxAmount);

            var oOffer = new QuickOfferModel {
                ID                 = nOfferID,
                Amount             = nOffer.Value,
                Aml                = Aml,
                BusinessScore      = BusinessScore,
                IncorporationDate  = IncorporationDate.Value,
                TangibleEquity     = TangibleEquity,
                TotalCurrentAssets = TotalCurrentAssets,

                ImmediateTerm         = Cfg.ImmediateTermMonths,
                ImmediateInterestRate = Cfg.ImmediateInterestRate,
                ImmediateSetupFee     = Cfg.ImmediateSetupFee,

                PotentialAmount       = nRequestedAmount,
                PotentialTerm         = Cfg.PotentialTermMonths,
                PotentialInterestRate = Cfg.LoanPct(BusinessScore, nRequestedAmount),
                PotentialSetupFee     = Cfg.PotentialSetupFee,
            };

            if (bSaveOfferToDB && (Cfg.Enabled != QuickOfferEnabledStatus.Silent))
            {
                try {
                    var oID = new QueryParameter("@QuickOfferID")
                    {
                        Type      = DbType.Int32,
                        Direction = ParameterDirection.Output,
                    };

                    oDB.ExecuteNonQuery(
                        "QuickOfferSave",
                        CommandSpecies.StoredProcedure,
                        new QueryParameter("@Now", DateTime.UtcNow),
                        new QueryParameter("@CustomerID", CustomerID),
                        new QueryParameter("@Amount", oOffer.Amount),
                        new QueryParameter("@Aml", oOffer.Aml),
                        new QueryParameter("@BusinessScore", oOffer.BusinessScore),
                        new QueryParameter("@IncorporationDate", oOffer.IncorporationDate),
                        new QueryParameter("@TangibleEquity", oOffer.TangibleEquity),
                        new QueryParameter("@TotalCurrentAssets", oOffer.TotalCurrentAssets),

                        new QueryParameter("@ImmediateTerm", oOffer.ImmediateTerm),
                        new QueryParameter("@ImmediateInterestRate", oOffer.ImmediateInterestRate),
                        new QueryParameter("@ImmediateSetupFee", oOffer.ImmediateSetupFee),
                        new QueryParameter("@PotentialAmount", oOffer.PotentialAmount),
                        new QueryParameter("@PotentialTerm", oOffer.PotentialTerm),
                        new QueryParameter("@PotentialInterestRate", oOffer.PotentialInterestRate),
                        new QueryParameter("@PotentialSetupFee", oOffer.PotentialSetupFee),
                        oID
                        );

                    if (int.TryParse(oID.SafeReturnedValue, out nOfferID))
                    {
                        oLog.Msg("Quick offer id is {0}", nOfferID);
                        oOffer.ID = nOfferID;
                    }
                    else
                    {
                        oLog.Warn("Failed to parse quick offer id from {0}", oID.Value.ToString());
                    }
                }
                catch (Exception e) {
                    oLog.Alert(e, "Failed to save a quick offer to DB.");
                }         // try
            }             // if

            return(oOffer);
        }         // GetOffer