Esempio n. 1
0
        }         // Execute

        private void Generate()
        {
            string timeString = DateTime.UtcNow.ToString("yyyy-MM-dd-HH-mm-ss");

            string dirPath  = caisPath + "\\" + timeString;
            string dirPath2 = caisPath2 + "\\" + timeString;

            Directory.CreateDirectory(dirPath);
            Directory.CreateDirectory(dirPath2);


            DB.ForEachRowSafe(ProcessOneLine, "GetCaisData", CommandSpecies.StoredProcedure);

            mailer.Send("Mandrill - CAIS report", new Dictionary <string, string> {
                { "CurrDate", DateTime.UtcNow.ToString(CultureInfo.InvariantCulture) },
                { "Path", dirPath }
            });

            var businessCaisFileData = CaisFileManager.GetBusinessCaisFileData();

            businessCaisFileData.WriteToFile(dirPath + "\\F1364.D.COMCAIS.ORMO.DI55CUST.INPUT");
            businessCaisFileData.WriteToFile(dirPath2 + "\\F1364.D.COMCAIS.ORMO.DI55CUST.INPUT");
            SaveCAISFile(
                businessCaisFileData.WriteToString(),
                "F1364.D.COMCAIS.ORMO.DI55CUST.INPUT",
                dirPath,
                2,
                businessCounter,
                businessGoodCounter,
                businessDefaultsCounter
                );
            CaisFileManager.RemoveBusinessCaisFileData();

            var consumerCaisFileData = CaisFileManager.GetCaisFileData();

            consumerCaisFileData.WriteToFile(dirPath + "\\F530.E.OMO.MSTEI49.XMIT");
            consumerCaisFileData.WriteToFile(dirPath2 + "\\F530.E.OMO.MSTEI49.XMIT");
            SaveCAISFile(
                consumerCaisFileData.WriteToString(),
                "F530.E.OMO.MSTEI49.XMIT",
                dirPath,
                1,
                consumerCounter,
                consumerGoodCounter,
                consumerDefaultsCounter
                );
            CaisFileManager.RemoveCaisFileData();
        }
Esempio n. 2
0
        private ActionResult ProcessOneLine(SafeReader sr, bool bRowsetStart)
        {
            int      loanId         = sr["loanID"];
            DateTime startDate      = sr["StartDate"];
            DateTime dateClose      = sr["DateClose"];
            decimal  currentBalance = sr["CurrentBalance"];
            string   gender         = sr["Gender"];
            string   firstName      = sr["FirstName"];
            string   middleInitial  = sr["MiddleInitial"];
            string   surname        = sr["Surname"];
            string   refNumber      = sr["RefNumber"];
            string   line1          = sr["Line1"];
            string   line2          = sr["Line2"];
            string   line3          = sr["Line3"];
            string   town           = sr["Town"];
            string   county         = sr["County"];
            string   postcode       = sr["Postcode"];
            DateTime dateOfBirth    = sr["DateOfBirth"];
            string   manualCaisFlag = sr["ManualCaisFlag"];

            DateTime?minLsDate = null;
            DateTime tmp       = sr["MinLSDate"];

            if (tmp != default(DateTime))
            {
                minLsDate = tmp;
            }
            decimal loanAmount          = sr["LoanAmount"];
            int     scheduledRepayments = sr["ScheduledRepayments"];
            string  companyType         = sr["CompanyType"];
            string  experianRefNum      = sr["ExperianRefNum"];
            string  experianCompanyName = sr["ExperianCompanyName"];
            string  customerState       = sr["CustomerState"];
            string  sortCode            = sr["SortCode"];
            bool    isDefaulted         = sr["IsDefaulted"];
            string  caisAccountStatus   = sr["CaisAccountStatus"];
            string  maritalStatus       = sr["MaritalStatus"];
            int     customerId          = sr["CustomerId"];
            string  genderPrefix;

            if (gender == "M")
            {
                genderPrefix = "Mr.";
            }
            else
            {
                genderPrefix = maritalStatus == "Married" ? "Mrs." : "Ms.";
            }

            if (!string.IsNullOrEmpty(caisAccountStatus) && caisAccountStatus != "Calculated value")
            {
                accountStatus = caisAccountStatus;
            }
            else
            {
                accountStatus = GetAccountStatus(minLsDate, dateClose, startDate, isDefaulted, currentBalance);

                if (accountStatus == "8")
                {
                    originalDefaultBalance = currentBalance;
                    dateClose = DateTime.UtcNow;
                }
                else
                {
                    originalDefaultBalance = 0;
                }
            }

            string line23   = string.Format("{0} {1}", line2, line3);
            string fullName = string.Format("{0} {1} {2} {3}", genderPrefix, firstName, middleInitial, surname);

            if (scheduledRepayments != 0)
            {
                monthlyPayment = loanAmount / scheduledRepayments;
            }
            else
            {
                monthlyPayment = 0;
            }

            if (accountStatus != "8" && dateClose > startDate)
            {
                currentBalance = 0;
            }

            string transferredToCollectionFlag = customerState == "Collection" ? "Y" : string.Empty;
            string accountNumber = refNumber + loanId;

            string caisFlag = null;

            if (!string.IsNullOrEmpty(manualCaisFlag) && manualCaisFlag != "Calculated value")
            {
                caisFlag = manualCaisFlag;
            }

            if (companyType == "Entrepreneur")
            {
                var file = CaisFileManager.GetCaisFileData();
                var h    = file.Header;
                h.SourceCodeNumber          = 402;
                h.DateCreation              = DateTime.UtcNow;
                h.CompanyPortfolioName      = "Orange Money";
                h.OverdraftReportingCutOff  = 0;
                h.IsCardsBehaviouralSharing = false;

                var account = CreateConsumerRecord(accountNumber, startDate, dateClose, scheduledRepayments, currentBalance, fullName, line1, line23, town, county, postcode, dateOfBirth, transferredToCollectionFlag, caisFlag);

                file.Accounts.Add(account);

                consumerCounter++;
                if (accountStatus == "0")
                {
                    consumerGoodCounter++;
                }
                else if (accountStatus == "8")
                {
                    consumerDefaultsCounter++;
                }
            }
            else
            {
                fullName = experianCompanyName;
                switch (companyType)
                {
                case "LLP":
                case "Limited": {
                    companyTypeCode = "L";
                    if (string.IsNullOrEmpty(experianCompanyName) && !string.IsNullOrEmpty(experianRefNum) && experianRefNum != "NotFound")
                    {
                        var res = service.GetLimitedBusinessData(experianRefNum, customerId, true, false);
                        if (res != null)
                        {
                            if (!string.IsNullOrEmpty(res.CompanyName))
                            {
                                fullName = res.CompanyName;
                            }

                            if (!string.IsNullOrEmpty(res.PostCode))
                            {
                                line1    = res.AddressLine1;
                                line23   = res.AddressLine2;
                                town     = res.AddressLine3;
                                county   = res.AddressLine4;
                                postcode = res.PostCode;
                            }
                        }
                    }
                }
                break;

                case "PShip":
                case "SoleTrader":
                case "PShip3P":
                    companyTypeCode = "N";
                    if (string.IsNullOrEmpty(experianCompanyName) && !string.IsNullOrEmpty(experianRefNum) && experianRefNum != "NotFound")
                    {
                        ExperianLib.Ebusiness.NonLimitedResults res = null;
                        try {
                            res = service.GetNotLimitedBusinessData(experianRefNum, customerId, true, false);
                        } catch (Exception e) {
                            Log.Warn("Exception during retrieval of non limited data. For customer:{0} experianRefNum:{1} Error:{2}", customerId, experianRefNum, e);
                        }

                        if (res != null)
                        {
                            if (!string.IsNullOrEmpty(res.CompanyName))
                            {
                                fullName = res.CompanyName;
                            }

                            if (!string.IsNullOrEmpty(res.PostCode))
                            {
                                line1    = res.AddressLine1;
                                line23   = res.AddressLine2 + res.AddressLine3 == null ? "" : " " + res.AddressLine3;
                                town     = res.AddressLine4;
                                county   = res.AddressLine5;
                                postcode = res.PostCode;
                            }
                        }
                    }
                    break;
                }

                var cais = CaisFileManager.GetBusinessCaisFileData();
                cais.Header.CompanyPortfolioName             = "Orange Money";
                cais.Header.CreditCardBehaviouralSharingFlag = "";
                cais.Header.DateOfCreation = DateTime.UtcNow;
                cais.Header.SourceCode     = 721;

                var record = CreateBusinessRecord(accountNumber, fullName, line1, line23, town, county, postcode, startDate, dateClose, scheduledRepayments, currentBalance, transferredToCollectionFlag, sortCode, experianRefNum);
                cais.Accounts.Add(record);

                businessCounter++;
                if (accountStatus == "0")
                {
                    businessGoodCounter++;
                }
                else if (accountStatus == "8")
                {
                    businessDefaultsCounter++;
                }
            }             // if

            DB.ExecuteNonQuery("UpdateLastReportedCAISstatus",
                               CommandSpecies.StoredProcedure,
                               new QueryParameter("LoanId", loanId),
                               new QueryParameter("CAISStatus", accountStatus)
                               );

            return(ActionResult.Continue);
        }