Пример #1
0
        private CollectionMailModel GetMailModel(bool isLimited, int originId)
        {
            var model = new CollectionMailModel {
                IsLimited       = isLimited,
                OriginId        = originId,
                CustomerAddress = new Address {
                    Line1    = "6 Upperkirkgate",
                    Line2    = "cl2",
                    Line3    = "cl3",
                    Line4    = "Aberdeen",
                    Postcode = "AB10 1BA"
                },
                CompanyAddress = new Address {
                    Line1    = "6 Upperkirkgate",
                    Line2    = "bl2",
                    Line3    = "bl3",
                    Line4    = "Aberdeen",
                    Postcode = "AB10 1BA"
                },
                GuarantorAddress = new Address {
                    Line1    = "6 Upperkirkgate",
                    Line2    = "gl2",
                    Line3    = "gl3",
                    Line4    = "Aberdeen",
                    Postcode = "AB10 1BA"
                },
                CompanyName    = "compname",
                CustomerId     = 1,
                CustomerName   = "custname",
                Date           = DateTime.Today,
                GuarantorName  = "guarantorname",
                LoanAmount     = 20000,
                LoanDate       = DateTime.Today.AddDays(-14),
                LoanRef        = "loanref",
                MissedInterest = 1500,
                MissedPayment  = new MissedPaymentModel {
                    AmountDue    = 1000,
                    DateDue      = DateTime.Today.AddDays(-14),
                    Fees         = 40,
                    RepaidAmount = 0,
                    RepaidDate   = null
                },
                PreviousMissedPayment = new MissedPaymentModel {
                    AmountDue = 1000,
                    DateDue   = DateTime.Today.AddMonths(-1)
                                .AddDays(-14),
                    Fees         = 40,
                    RepaidAmount = 0,
                    RepaidDate   = null
                },
                OutstandingBalance   = 21000,
                OutstandingPrincipal = 20000,
            };

            return(model);
        }
Пример #2
0
        }        //SendCollectionEmail

        protected void SendCollectionImail(CollectionDataModel model, CollectionType type)
        {
            if (model.ImailSendingAllowed)
            {
                try {
                    CollectionMailModel mailModel = GetCollectionMailModel(model);
                    switch (type)
                    {
                    case CollectionType.CollectionDay7:
                        if (mailModel.IsLimited)
                        {
                            Log.Info("Sending imail {0} to customer {1}", model.CustomerID, type);
                            FileMetadata personal;
                            FileMetadata business;
                            this.collectionIMailer.SendDefaultTemplateComm7(mailModel, out personal, out business);

                            //int collection7LogID = AddCollectionLog(model.CustomerID, model.LoanID, type, CollectionMethod.Mail, model);

                            int collection7LogID = AddCollectionLog(new CollectionLog()
                            {
                                CustomerID    = model.CustomerID,
                                LoanID        = model.LoanID,
                                LoanHistoryID = model.LoanHistoryID,
                                Type          = type.ToString(),
                                Method        = CollectionMethod.Mail.ToString(),
                                Comments      = (model.NLLoanID > 0) ? "nlloan " + model.NLLoanID : null
                            });

                            SaveCollectionSnailMailMetadata(collection7LogID, personal);
                            SaveCollectionSnailMailMetadata(collection7LogID, business);
                        }
                        break;

                    case CollectionType.CollectionDay15:
                        FileMetadata day15Metadata;
                        if (mailModel.IsLimited)
                        {
                            Log.Info("Sending imail {0} to customer {1}", model.CustomerID, type);
                            day15Metadata = this.collectionIMailer.SendDefaultNoticeComm14Borrower(mailModel);
                            //TODO uncomment when guarantor is implemented:
                            //collectionIMailer.SendDefaultWarningComm7Guarantor(mailModel);
                        }
                        else
                        {
                            Log.Info("Sending imail {0} to customer {1}", model.CustomerID, type);
                            day15Metadata = this.collectionIMailer.SendDefaultTemplateConsumer14(mailModel);
                        }
                        //int collection15LogID = AddCollectionLog(model.CustomerID, model.LoanID, type, CollectionMethod.Mail, model);

                        int collection15LogID = AddCollectionLog(new CollectionLog()
                        {
                            CustomerID    = model.CustomerID,
                            LoanID        = model.LoanID,
                            LoanHistoryID = model.LoanHistoryID,
                            Type          = type.ToString(),
                            Method        = CollectionMethod.Mail.ToString(),
                            Comments      = (model.NLLoanID > 0) ? "nlloan " + model.NLLoanID : null
                        });

                        SaveCollectionSnailMailMetadata(collection15LogID, day15Metadata);
                        break;

                    case CollectionType.CollectionDay31:
                        if (!mailModel.IsLimited)
                        {
                            Log.Info("Sending imail {0} to customer {1}", model.CustomerID, type);
                            FileMetadata consumer = this.collectionIMailer.SendDefaultTemplateConsumer31(mailModel);
                            //int collection31LogID = AddCollectionLog(model.CustomerID, model.LoanID, type, CollectionMethod.Mail, model);

                            int collection31LogID = AddCollectionLog(new CollectionLog()
                            {
                                CustomerID    = model.CustomerID,
                                LoanID        = model.LoanID,
                                LoanHistoryID = model.LoanHistoryID,
                                Type          = type.ToString(),
                                Method        = CollectionMethod.Mail.ToString(),
                                Comments      = (model.NLLoanID > 0) ? "nlloan " + model.NLLoanID : null
                            });

                            SaveCollectionSnailMailMetadata(collection31LogID, consumer);
                        }
                        break;
                    }
                } catch (Exception ex) {
                    Log.Error(ex, "Sending Imail failed for customer {0}", model.CustomerID);
                }
            }
            else
            {
                Log.Info("Collection sending mail is not allowed, mail is not sent to customer {0}\n template {1}", model.CustomerID, type);
            }
        }        //SendCollectionImail
Пример #3
0
        }        //CollectionDay90

        private CollectionMailModel GetCollectionMailModel(CollectionDataModel model)
        {
            SafeReader          sr        = DB.GetFirst("GetDataForCollectionMail", CommandSpecies.StoredProcedure, new QueryParameter("CustomerID", model.CustomerID), new QueryParameter("LoanID", model.LoanID));
            CollectionMailModel mailModel = new CollectionMailModel {
                CustomerName    = model.FullName,
                CustomerAddress = new Address {
                    Line1    = sr["CAddress1"],
                    Line2    = sr["CAddress2"],
                    Line3    = sr["CAddress3"],
                    Line4    = sr["CAddress4"],
                    Postcode = sr["CPostcode"],
                },
                CompanyAddress = new Address {
                    Line1    = sr["BAddress1"],
                    Line2    = sr["BAddress2"],
                    Line3    = sr["BAddress3"],
                    Line4    = sr["BAddress4"],
                    Postcode = sr["BPostcode"],
                },
                GuarantorAddress = new Address {                 //TODO implement
                    Line1    = sr["GAddress1"],
                    Line2    = sr["GAddress2"],
                    Line3    = sr["GAddress3"],
                    Line4    = sr["GAddress4"],
                    Postcode = sr["GPostcode"],
                },
                GuarantorName = sr["GuarantorName"],                 //TODO implement
                IsLimited     = sr["IsLimited"],
                CompanyName   = sr["CompanyName"],
                Date          = this.now,

                LoanAmount = sr["LoanAmount"],
                LoanRef    = sr["LoanRef"],
                LoanDate   = sr["LoanDate"],
                //OutstandingBalance = sr["OutstandingBalance"],
                OutstandingPrincipal = sr["OutstandingPrincipal"],
                CustomerId           = model.CustomerID,
                OriginId             = model.OriginID,
                MissedPayment        = new MissedPaymentModel {
                    AmountDue    = sr["AmountDue"],
                    DateDue      = sr["SchedDate"],
                    Fees         = sr["Fees"],
                    RepaidAmount = sr["RepaidAmount"],
                    RepaidDate   = sr["RepaidDate"]
                },
                PreviousMissedPayment = new MissedPaymentModel {
                    AmountDue    = sr["PreviousAmountDue"],
                    DateDue      = sr["PreviousSchedDate"],
                    Fees         = sr["PreviousFees"],
                    RepaidAmount = sr["PreviousRepaidAmount"],
                    RepaidDate   = sr["PreviousRepaidDate"]
                },
            };
            var  loanRepository = ObjectFactory.GetInstance <LoanRepository>();
            Loan loan           = loanRepository.Get(model.LoanID);
            var  payEarlyCalc   = new LoanRepaymentScheduleCalculator(loan, this.now, CurrentValues.Instance.AmountToChargeFrom);
            var  balance        = payEarlyCalc.TotalEarlyPayment();

            mailModel.OutstandingBalance = balance;

            if (model.NLLoanID > 0)
            {
                GetLoanState nlState = new GetLoanState(model.CustomerID, model.NLLoanID, this.now, 1);
                nlState.Execute();

                mailModel.LoanRef = nlState.Result.Loan.Refnum;
                mailModel.OutstandingPrincipal = nlState.Result.Principal;
                mailModel.OutstandingBalance   = nlState.Result.TotalEarlyPayment;

                var firtHistory = nlState.Result.Loan.FirstHistory();
                if (firtHistory != null)
                {
                    mailModel.LoanAmount = (int)firtHistory.Amount;
                    mailModel.LoanDate   = firtHistory.EventTime;
                }

                // TODO handle MissedPayment, PreviousMissedPayment
            }

            return(mailModel);
        }        //GetCollectionMailModel