Beispiel #1
0
		public OrderAccessResult AllowAccess(Order order, int? appraiserOrderId, Type controllerType)
		{
			if (!_securityContext.CurrentUser.Roles.Select(r => r.RoleType).Any(rt => OrderFulfillmentAccessUsers.ClientRoles.Contains(rt)))
			{
				return new OrderAccessResult { AllowAccess = true, Message = string.Empty };
			}

			if (order.OrderStatus == OrderStatus.CreationProcess || order.OrderStatus == OrderStatus.Draft)
			{
				return new OrderAccessResult
								{
									AllowAccess = false,
									Message = string.Format("Order in {0} status doesn't contain required data", order.OrderStatus)
								};
			}

			var currentClientUser = _securityContext.CurrentClientUser;
			var checkAccess = _clientDashboardService.HasClientUserAccessToOrder(currentClientUser).Compile();
			if (!checkAccess(order))
			{
				return new OrderAccessResult
								{
									AllowAccess = false,
									Message =
										string.Format("User cannot access order. User id: {0}, Order Id: {1} ",
																	currentClientUser.User.Id.ToString(CultureInfo.InvariantCulture), order.Id)
								};
			}

			return new OrderAccessResult { AllowAccess = true, Message = string.Empty };
		}
		public void AppraiserOrderDeliveryServiceTest_SendOrderInvitations()
		{
			//arrange
			var appraiser = new AppraiserUser
				{
					Status = AppraiserUserStatus.Active,
					User = new User { Id = 1, Email = "*****@*****.**", FirstName = "FName", LastName = "LName", Roles = new Collection<Role> { new Role { Id = (int)RoleType.Appraiser } } },
					ServiceArea = new AppraiserServiceArea { Latitude = 0, Longitude = 0 },
					Id = 1
				};

			var order = new Order
			{
				Id = 1,
				Latitude = 0,
				Longitude = 0,
				AcceptedAppraiserUser = appraiser,
				OrderPublicId = "AAA",
				AppraiserOrderDeliveryType = (int)AppraiserOrderDeliveryType.SMS
			};

			Target.SendOrderInvitations(order, new AppraiserUser[] { appraiser });
			_appraiserOrderRepository.Received(1).Add(Arg.Is<AppraiserOrder>(e => e.AppraiserUser.Id == appraiser.Id && e.Order.Id == order.Id));
			_backgroundService.Received(1).AddTask(TaskTypeEnum.SendAppraiserOrderInvitationSMS, Arg.Any<Dictionary<TaskParamsKey, string>>());
		}
Beispiel #3
0
		private void SetOrderInfo(DVSUserDashboardItemViewModel model, Order order)
		{
			if (order.GeneralInfo != null)
			{
				model.BorrowerFirstName = order.GeneralInfo.BorrowerFirstName;
				model.BorrowerLastName = order.GeneralInfo.BorrowerLastName;
				model.LoanNumber = order.GeneralInfo.LoanNumber;
				model.PropertyAddress = order.GeneralInfo.PropertyAddress;
			}

			model.Broker = order.CreatedByClientUser.Company.Profile.IsBroker ? order.CreatedByClientUser.Company.CompanyName : string.Empty;
			model.LastActionDate = GetLastActionDate(order.Id);

			if (order.CreatedByClientUser.Company.Profile.IsBroker)
			{
				if (order.ClientCompany != null)
				{
					model.LenderClient = order.ClientCompany.CompanyName;
				}
				if (order.ClientCompanyBranche != null)
				{
					model.LenderClientBranch = order.ClientCompanyBranche.Name;
				}
			}
			else
			{
				model.LenderClient = order.CreatedByClientUser.Company.CompanyName;
				model.LenderClientBranch = order.CreatedByClientUser.Branch.Name;
			}

			model.OrderNumber = order.OrderPublicId;
			model.Status = order.OrderStatus;
		}
		public void GetReadyForDisbursementOrders_should_return_order()
		{

			var appraiser = new AppraiserUser
									{
										BankingInfo = new AppraiserBanking
												{
													AccountNumber = "Account Number",
													AccountType = AccountType.Savings,
													RoutingNumber = "Routing Number",
													BankingInstitution = "test Banking Institution",
													BankAddress = new Address { City = "City", State = "State", ZIP = "Zip" }
												},

									};

			var order = new Order { CompletionDate = new DateTime(2012, 08, 20), AcceptedAppraiserUser = appraiser };
			var expected = new List<Order> { order };

			var date = new DateTime(2012, 08, 20);
			var status = OrderStatus.Completed.ToString();
			var needDate = date.AddDays(1).AddMinutes(-1);
			var where = PredicateBuilder.True<Order>();

			where = where.AndAlso(o => o.OrderStatusId == status)
				.AndAlso(o => o.CompletionDate < needDate);

			_orderRepository.Get(where).Returns(expected);


			var actual = _feeDisbursementManager.GetReadyForDisbursementOrders("08/20/2012");
			actual.Should().Equals(expected);

		}
		private void SheduleOrderPeriodicalNotificationsInternal(Order order, OrderPeriodicalNotificationType notificationType, IDictionary<TaskParamsKey, object> additionalParams)
		{
			var taskPeriod = GetTaskPeriodTypesAndStartPoint(order, notificationType);
			DateTime? minStartDate = CalculateNextRunTime(taskPeriod.InitialNotificationType.Value, taskPeriod.StartPoint.Value);

			_taskManager.SheduleOrderPeriodicalNotificationTask(order.Id, minStartDate, notificationType, additionalParams);
		}
Beispiel #6
0
		public ConfirmOrderViewModel(Order model, string state)
			: this()
		{
			this.GeneralInfo = new OrderGeneralInfoViewModel(model.GeneralInfo, state);
			this.AppraisalInfo = new OrderAppraisalInfoViewModel(model.AppraisalInfo);
			this.LoanAndContactViewModel = new OrderLoanAndContactInfoViewModel(model.LoanAndContactInfo);
		}
		public void GenerateAndSaveLOE_should_throw_SecurityException_if_order_status_Draft()
		{
			var order = new Order
			{
				OrderStatus = OrderStatus.Draft
			};
			_target.Invoking(x => x.GenerateAndSaveLOE(order, Arg.Any<int>())).ShouldThrow<SecurityException>().And.Message.Contains("Unable to generate LOE");
		}
Beispiel #8
0
		public ContactInfoViewModel(Order order, Func<Address, NotRequiredAddressViewModel> addressMapper)
		{
			if (order != null)
			{
				BorrowerFirstName = order.GeneralInfo.BorrowerFirstName;
				BorrowerLastName = order.GeneralInfo.BorrowerLastName;
				LoanNumber = order.GeneralInfo.LoanNumber;

				PointOfContact = new Orders.ContactInfoViewModel(order.LoanAndContactInfo.Contacts, order.Id);

				ToShowAppraiser = order.AcceptedAppraiserUser != null;
				if (order.AcceptedAppraiserUser != null)
				{
					AppraiserFirstName = order.AcceptedAppraiserUser.User.FirstName;
					AppraiserLastName = order.AcceptedAppraiserUser.User.LastName;

					if (order.AcceptedAppraiserUser.ContactInfo != null)
					{
						AppraiserAddress = addressMapper(order.AcceptedAppraiserUser.ContactInfo.PhysicalAddress);
						var appraiserPhone = order.AcceptedAppraiserUser.ContactInfo.Phones.FirstOrDefault();
						AppraiserPhone = appraiserPhone != null ? appraiserPhone.Number : string.Empty;
					}

				}

				ToShowBroker = order.ClientCompanyId.HasValue;
				if (order.ClientCompanyId.HasValue)
				{
					BrokerAddress = addressMapper(order.CreatedByClientUser.Branch.Address);
					BrokerCompany = order.CreatedByClientUser.Branch.Name;
					BrokerFirstName = order.CreatedByClientUser.User.FirstName;
					BrokerLastName = order.CreatedByClientUser.User.LastName;
					BrokerPhone = order.CreatedByClientUser.Branch.BranchPhone;

					LenderCompanyName = order.CreatedByClientUser.Company.CompanyName;

					if (order.ClientCompanyBrancheId.HasValue)
					{
						LenderAddress = addressMapper(order.ClientCompanyBranche.Address);
						LenderName = order.ClientCompanyBranche.Name;
						LenderPhone = order.ClientCompanyBranche.BranchPhone;

						LenderCompanyName = order.ClientCompany.CompanyName;
					}
				}
				else
				{
					LenderAddress = addressMapper(order.CreatedByClientUser.Branch.Address);
					LenderName = order.CreatedByClientUser.Branch.Name;
					LenderPhone = order.CreatedByClientUser.Branch.BranchPhone;
				}

				CompanyName = order.CreatedByClientUser.Company.CompanyName;
			}
		}
Beispiel #9
0
		public RequestDetailsViewModel(Order order, IReferenceManagement refManager, AppraiserOrder appraiserOrder, ISecurityContext securityContext)
		{
			if (order != null)
			{
				bool isAppraiserUser = new RoleType[] { RoleType.AppraisalCompanyAdmin, RoleType.Appraiser, RoleType.CompanyAdminAndAppraiser }
					.Contains(securityContext.CurrentUser.PrimaryRole.RoleType);
				bool isDVSUser = new RoleType[] { RoleType.DvsAdmin, RoleType.DvsDisbursementsProcessor, RoleType.DvsSuperAdmin }
					.Contains(securityContext.CurrentUser.PrimaryRole.RoleType);

				AcceptOrderData = new RequestDetailsAcceptOrderViewModel();
				if (appraiserOrder != null)
				{
					Distance = appraiserOrder.Distance;
					AppraiserOrderId = appraiserOrder.Id;
					AllowAcceptDeclineOrder = appraiserOrder.Order.OrderStatus == OrderStatus.PendingAssignment && (isDVSUser || (!appraiserOrder.IsDeclined && isAppraiserUser));
					AcceptOrderData.DefaultAppraiserId = appraiserOrder.AppraiserUser.Id;
					AcceptOrderData.DefaultAppraiserFirstName = appraiserOrder.AppraiserUser.User.FirstName;
					AcceptOrderData.DefaultAppraiserLastName = appraiserOrder.AppraiserUser.User.LastName;
					AcceptOrderData.DefaultAppraiserEmail = appraiserOrder.AppraiserUser.User.Email;
					AcceptOrderData.IsOtherAppraiser = false;
				}
				else
				{
					if (order.AcceptedAppraiserUser != null)
					{
						AcceptedInfo = String.Format("Accepted on {0} {1} by {2} ({3})", order.AcceptDate.Value.Date.ToString(Constants.DateTimeFormats.Date), order.AcceptDate.Value.ToString(Constants.DateTimeFormats.Time), order.AcceptedAppraiserUser.User.FullName, order.AcceptedAppraiserUser.User.Email);
					}
					else
					{
						AllowAcceptDeclineOrder = isDVSUser && order.OrderStatus == OrderStatus.PendingAssignment;
					}
					AcceptOrderData.IsOtherAppraiser = order.AcceptedAppraiserUser == null;
				}

				Address propertyAddress = order.GeneralInfo.PropertyAddress;
				if (!string.IsNullOrEmpty(order.GeocodingCounty))
					propertyAddress.County = order.GeocodingCounty;
				Address = new AddressWithCountyViewModel { City = propertyAddress.City, County = propertyAddress.County, State = propertyAddress.State, Street = propertyAddress.Street, Street2 = propertyAddress.Street2, ZIP = propertyAddress.ZIP };
				IsRush = order.AppraisalInfo.Rush;
				IsSecondAppraisalOrDuplicateAppraisal = order.AppraisalInfo.SecondDuplicateAppraisal;
				IsSupplementalREOAddendum = order.AppraisalInfo.SupplementalREOAddendum;
				DueDate = order.DueDate.Value;
				AppraisalFormType = order.AppraisalInfo.AppraisalForm.HasValue ? refManager.GetAppraisalForms().Single(e => e.Id == order.AppraisalInfo.AppraisalForm.Value).FormAbbreviation : null;
				ReviewFormType = order.AppraisalInfo.ReviewForm.HasValue ? refManager.GetAppraisalForms().Single(e => e.Id == order.AppraisalInfo.ReviewForm.Value).FormAbbreviation : null;
				AppraisalType = order.AppraisalInfo.AppraisalType.Value;
				LoanPurpose = refManager.GetReference(ReferenceType.LoanPurposeTypes)[order.LoanAndContactInfo.LoanPurposeTypeId.Value];
				Occupancy = refManager.GetReference(ReferenceType.OccupancyTypes)[order.AppraisalInfo.OccupancyTypeId.Value];
				PropertyType = refManager.GetReference(ReferenceType.PropertyTypes)[order.AppraisalInfo.PropertyTypeId.Value];
				LoanType = order.AppraisalInfo.LoanType.HasValue ? order.AppraisalInfo.LoanType.Value.ToString() : Constants.Text.EmptyField;
				if (order.LoanAndContactInfo.LoanPurpose == Model.Enums.OrderManagement.LoanPurpose.Purchase)
					PurchasePrice = order.LoanAndContactInfo.PurchasePrice.Value.ToString();
				TotalFee = order.AppraisersFee;
				Instructions = order.LoanAndContactInfo.Instructions != null ? order.LoanAndContactInfo.Instructions.ToList().Select(s => s.Id) : new List<int>();
			}
		}
		public OrderAccessResult AllowAccess(Order order, int? appraiserOrderId, Type controllerType)
		{
			var allRoles = OrderFulfillmentAccessUsers.ClientRoles.Concat(OrderFulfillmentAccessUsers.AppraiserRoles).Concat(new[] { RoleType.DvsAdmin, RoleType.DvsSuperAdmin });

			if (!_securityContext.CurrentUser.Roles.Select(r => r.RoleType).Any(allRoles.Contains))
			{
				return new OrderAccessResult { AllowAccess = false, Message = string.Format("User {0} with role don't know for access to order.", _securityContext.CurrentUser.Id) };
			}

			return new OrderAccessResult { AllowAccess = true, Message = string.Empty };
		}
		public OrderRequestConfirmationViewModel(Order model)
			: this()
		{
			if (model != null)
			{
				OrderId = model.Id;
				PublicOrderNumber = model.OrderPublicId;
				FeeConfirmation = FeeConfirmation ?? new OrderFeeConfirmationViewModel(model.FeeInfo);
				FeeDifference = model.FeeDifference;
			}
		}
		public ImportantDatesTabDataPluginResult(Order order)
		{
			if (order.RebuttalDetails != null)
			{
				ToShowRebuttalCreatedSubmitted = order.RebuttalDetails.RebuttalReasonId.HasValue;
				ToShowRebuttalAccepted = order.RebuttalDetails.ResponseEvaluation == ResponseEvaluation.Accepted;
				ToShowRebuttalRejected = order.RebuttalDetails.ResponseEvaluation == ResponseEvaluation.Rejected;
			}
			IsOrderCancelled = order.OrderStatus == OrderStatus.Cancelled;
			IsOrderCompletedOrPaid = order.OrderStatus == OrderStatus.Completed;
		}
Beispiel #13
0
		/// <summary>
		///A test for ValidateAciXml
		///</summary>

		private int CreateOrder(int formId)
		{
			base.InitDbContext();
			IOrderRepository orderRepository = new OrderRepository(this.DbFactory);
			ICommitProvider commitProvider = new CommitProvider(this.DbFactory);
			int rand = new Random().Next(0, 100000);
			var loanAndContactInfo = new OrderLoanAndContactInfo
			{
				Contacts = new List<OrderContact>() { new OrderContact { ContactRoleId = 2, Email = String.Format("mial{0}@mail.com", rand), Name = "Name" + rand, Phone = "123" + rand } },
				LoanPurposeTypeId = 4,
				GFEDate = DateTime.Now.AddDays(100),
				GFEAmount = 9999.99,
			};

			var generalInfo = new OrderGeneralInfo
			{
				BorrowerFirstName = "Test" + rand,
				BorrowerLastName = "Test" + rand,
				LoanNumber = "100" + rand,
				PropertyAddress = new Address { City = "New York", County = "Test", State = "NY", ZIP = "12345", Street = "Wallstreet" }
			};

			var appraisalInfo = new OrderAppraisalInfo
			{
				PropertyTypeId = 3,
				OccupancyTypeId = 1,
				AppraisalTypeId = 1,
				Rush = true,
				SecondDuplicateAppraisal = true,
				LoanType = LoanType.Conventional,
				NumberUnits = 7,
				AppraisalType = AppraisalType.Appraisal,
				AppraisalForm = formId,
				ReviewForm = 0
			};

			Order order = new Order
			{
				OrderPublicId = "000" + rand,
				AppraiserOrderDeliveryType = 3,
				CreationDate = DateTime.Now,
				LoanAndContactInfo = loanAndContactInfo,
				AppraisalInfo = appraisalInfo,
				CreatedByClientUserId = 1,
				OrderStatusId = OrderStatus.PendingAssignment.ToString(),
				DueDate = DateTime.Now.AddDays(10),
				Latitude = 43,
				Longitude = -73,
				GeneralInfo = generalInfo
			};
			orderRepository.Add(order);
			commitProvider.Commit();
			return order.Id;
		}
		public void SheduleOrderPeriodicalNotifications(Order order, OrderPeriodicalNotificationType notificationType)
		{
			if (new OrderPeriodicalNotificationType[]
				{ OrderPeriodicalNotificationType.UpdateRequestNotification, OrderPeriodicalNotificationType.UpdateRequestEscalation,
				OrderPeriodicalNotificationType.ConditionCreatedNotification, OrderPeriodicalNotificationType.ConditionResponseEscalation }
				.Contains(notificationType))
			{
				throw new NotSupportedException();
			}
			SheduleOrderPeriodicalNotificationsInternal(order, notificationType, null);
		}
Beispiel #15
0
		private string GetFormDisplayName(Order order)
		{
			if (order.AppraisalInfo.AppraisalType == AppraisalType.Appraisal && order.AppraisalInfo.AppraisalForm.HasValue)
			{
				return _formsService.GetFormTitle(order.AppraisalInfo.AppraisalForm.Value);
			}
			if (order.AppraisalInfo.AppraisalType == AppraisalType.Review && order.AppraisalInfo.ReviewForm.HasValue)
			{
				return _formsService.GetFormTitle(order.AppraisalInfo.ReviewForm.Value);
			}
			return string.Empty;
		}
Beispiel #16
0
		public void GenerateAndSaveLOE(Order order, int currentUserId)
		{
			if (order.OrderStatus == OrderStatus.CreationProcess || order.OrderStatus == OrderStatus.Draft)
			{
				throw new SecurityException(string.Format("Unable to generate LOE. Wrong status. (order id:{0})", order.Id));
			}
			var document = _reportManager.GetLOEReport(order.Id, ReportFormat.PDF);
			var documentInfo = new DocumentInfo()
			{
				AddedByUserId = currentUserId,
				DateAdded = DateTime.Now,
				DocumentType = "application/pdf",
				Name = "Order#" + order.OrderPublicId + "_LOE.pdf",
				Size = document.Length
			};
			var documentStorageId = _documentService.StoreDocument(documentInfo, document);
			order.LOEDocument = documentStorageId;
		}
		private string GetAddonsString(Order order)
		{

			var str = string.Empty;
			if (!order.AppraisalInfo.Rush && !order.AppraisalInfo.SupplementalREOAddendum)
			{
				return "-";
			}
			if (order.AppraisalInfo.Rush && order.AppraisalInfo.SupplementalREOAddendum)
			{
				str = ",";
			}
			return string.Format("{0}{1} {2}", order.AppraisalInfo.Rush ? "Rush" : string.Empty, str,
													 order.AppraisalInfo.SupplementalREOAddendum
														? "Supplemental REO Addendum"
														: string.Empty);

		}
Beispiel #18
0
		public void should_return_unique_orders_by_appraiserOrderStatus()
		{
			//arrange
			var order = new Order();
			var expectedCollection = GenerateCurrentAppraiserWithinOrder(TestData.UserWithRoles(RoleType.Appraiser), new AppraiserOrder { AppraiserOrderStatus = AppraiserOrderStatus.Pending, Order = order }).InitializeType(HotListType.NewAssignment).ToArray();

			IEnumerable<HotList> inputCollection;
			{
				inputCollection = GenerateCurrentAppraiserWithinOrder(CurrentUser.CurrentUser, new AppraiserOrder { AppraiserOrderStatus = AppraiserOrderStatus.PastDue, Order = order }).InitializeType(HotListType.NewAssignment).ToArray();

				inputCollection = inputCollection.Union(expectedCollection);
			}

			HotListManager.InputCollection = inputCollection;
			//act
			var actual = Target.GetHotListCollection(DefaultFilter);
			//assert
			Assert.IsTrue(expectedCollection.DefaultComparer(actual));
		}
Beispiel #19
0
		public Order CreateNewOrder(int userId, int? lenderCompanyId = null, int? lenderBranchId = null)
		{
			Order newOrder = new Order();
			newOrder.LoanAndContactInfo = new OrderLoanAndContactInfo();
			newOrder.OrderStatus = OrderStatus.CreationProcess;

			newOrder.OrderPublicId = GenerateOrderPublicIds();
			newOrder.CreationDate = DateTime.Now;

			newOrder.AppraiserOrderDeliveryType = (int)AppraiserOrderDeliveryType.SMS + (int)AppraiserOrderDeliveryType.Email;
			var clientUser = _clientUserRepository.GetByUserId(userId);

			newOrder.ClientCompanyId = lenderCompanyId;
			newOrder.ClientCompanyBrancheId = lenderBranchId;
			newOrder.CreatedByClientUserId = clientUser.Id;

			_orderRepository.Add(newOrder);

			return newOrder;
		}
Beispiel #20
0
		private NewOrdersListItemViewModel CreateNewOrdersListItem(Order order)
		{
			var result = new NewOrdersListItemViewModel
										{
											BorrowerFirstName = order.GeneralInfo.BorrowerFirstName,
											BorrowerLastName = order.GeneralInfo.BorrowerLastName,
											LoanNo = order.GeneralInfo.LoanNumber,
											ClientOrderId = order.Id,
											OrderNo = order.OrderPublicId,
											PropertyAddress = order.GeneralInfo.PropertyAddress,
											RequestDate = order.CreationDate,
											Status = order.OrderStatus
										};
			if (order.ClientCompany != null)
			{
				result.Lender = order.ClientCompany.CompanyName;
			}
			if (order.ClientCompanyBranche != null)
			{
				result.LenderBranch = order.ClientCompanyBranche.Name;
			}
			if (order.CreatedByClientUser.Company.Profile.IsBroker)
			{
				result.Broker = order.CreatedByClientUser.Company.CompanyName;
			}
			if (order.AppraisalInfo != null)
			{
				if (order.AppraisalInfo.Rush)
				{
					result.AddOns.Add(Constants.Text.addonRush);
				}
				if (order.AppraisalInfo.SecondDuplicateAppraisal)
				{
					result.AddOns.Add(order.ParentOrderId.HasValue ? Constants.Text.addonSecondOrder : Constants.Text.addonSeconDuplicateAppraisal);
				}
				result.Form = GetFormDisplayName(order);
				result.Fee = (double)order.AppraisersFee;
				result.IsDeclinedForInsufficientFee = _orderManager.IsOrderDeclinedForInsufficientFee(order.Id);
			}
			return result;
		}
		public void SendOrderInvitations(Order order, AppraiserUser[] appraisers)
		{
			List<AppraiserOrder> appraiserOrders = new List<AppraiserOrder>();

			foreach (var appraiser in appraisers)
			{
				var appraiserOrder = _appraiserOrderRepository.Get(e => e.AppraiserId == appraiser.Id && e.OrderId == order.Id).SingleOrDefault();
				if (appraiserOrder == null)
				{
					appraiserOrder = new AppraiserOrder()
					{
						AppraiserUser = appraiser,
						Distance = (float)GeographyManager.CalculateDistance((double)order.Longitude, (double)order.Latitude, (double)appraiser.ServiceArea.Longitude, (double)appraiser.ServiceArea.Latitude),
						Order = order,
						IsDeclined = false,
						CreatedDate = DateTime.Now
					};
					_appraiserOrderRepository.Add(appraiserOrder);
					appraiserOrders.Add(appraiserOrder);
				}
			}
			_taskManager.SendAppraiserOrderInvitations(appraiserOrders.ToArray(), (AppraiserOrderDeliveryType)order.AppraiserOrderDeliveryType);
		}
		public void GenerateAndSaveLOE_should_throw_generate_document()
		{
			var userId = 1;
			var order = new Order
			{
				Id = 1,
				OrderStatus = OrderStatus.OrderAccepted,
				OrderPublicId = "1234567890"
			};
			var documentGuid = Guid.NewGuid();
			var document = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
			_reportManager.GetLOEReport(order.Id, ReportFormat.PDF).Returns(document);
			var documentInfo = new DocumentInfo()
			{
				AddedByUserId = userId,
				DateAdded = DateTime.Now,
				DocumentType = "application/pdf",
				Name = "Order#" + order.OrderPublicId + "_LOE.pdf",
				Size = document.Length
			};
			_documentService.StoreDocument(documentInfo, document).Returns(documentGuid);
			_target.GenerateAndSaveLOE(order, userId);
		}
Beispiel #23
0
		public Order CreateOrderDuplicate(Order order)
		{
			Order newOrder = new Order();

			newOrder.AppraisalInfo = order.AppraisalInfo;
			newOrder.DueDate = order.DueDate;
			newOrder.LastCompletedStep = order.LastCompletedStep;
			newOrder.AppraiserOrderDeliveryType = order.AppraiserOrderDeliveryType;
			newOrder.ClientCompany = order.ClientCompany;
			newOrder.ClientCompanyId = order.ClientCompanyId;
			newOrder.ClientCompanyBranche = order.ClientCompanyBranche;
			newOrder.ClientCompanyBrancheId = order.ClientCompanyBrancheId;
			newOrder.CreatedByClientUser = order.CreatedByClientUser;
			newOrder.CreatedByClientUserId = order.CreatedByClientUserId;
			newOrder.CreationDate = order.CreationDate;
			newOrder.GeneralInfo = order.GeneralInfo;
			newOrder.LoanAndContactInfo = order.LoanAndContactInfo;
			newOrder.OrderStatus = OrderStatus.PendingAssignment;
			newOrder.OrderStatusId = OrderStatus.PendingAssignment.ToString();
			newOrder.Latitude = order.Latitude;
			newOrder.Longitude = order.Longitude;
			newOrder.OrderPublicId = GenerateOrderPublicIds();
			newOrder.ParentOrder = order;
			newOrder.ParentOrderId = order.Id;
			newOrder.FeeInfo = order.FeeInfo;
			newOrder.LOEDocument = order.LOEDocument;
			_orderRepository.Add(newOrder);

			var documents = _orderDocumentsRepository.GetDocumentsForOrder(order.Id);
			foreach (var item in documents)
			{
				item.Order = newOrder;
				_orderDocumentsRepository.Add(item);
			}

			return newOrder;
		}
		public string GetClientLender(Order order)
		{
			if (order.ClientCompanyBranche != null && order.ClientCompany != null)
			{
				return string.Format("{0}, {1}", order.ClientCompany.CompanyName,
														order.ClientCompanyBranche.Address.GetDisplayView());
			}
			return string.Format("{0}, {1}", order.CreatedByClientUser.Company.CompanyName,
													 order.CreatedByClientUser.Branch.Address.GetDisplayView());
		}
Beispiel #25
0
		private Order CreateTestOrderInternal(int appraiserUserId)
		{
			var isTestOrderAdded = _orderRepository.Get(o => o.IsTestOrder == true && o.AcceptedAppraiserUserId == appraiserUserId).Count() > 0;
			if (!isTestOrderAdded)
			{
				var order = new Order();
				var orderData = _referenceManagement.GetTestOrderData();

				#region Populate Fields
				order.AcceptedAppraiserUserId = appraiserUserId;
				order.IsTestOrder = true;
				order.LastCompletedStep = 5;
				order.AppraisalInfo = new OrderAppraisalInfo
				{
					AppraisalForm = int.Parse(orderData[OrderField.AppraisalForm]),
					AppraisalTypeId = int.Parse(orderData[OrderField.AppraisalTypeId]),
					LoanTypeId = int.Parse(orderData[OrderField.LoanTypeId]),
					OccupancyTypeId = int.Parse(orderData[OrderField.OccupancyTypeId]),
					PropertyTypeId = int.Parse(orderData[OrderField.PropertyTypeId]),
					Rush = false,
					SecondDuplicateAppraisal = false,
					SupplementalREOAddendum = false
				};
				order.AppraiserOrderDeliveryType = (int)AppraiserOrderDeliveryType.Email;
				order.ClientCompanyId = int.Parse(orderData[OrderField.ClientCompanyId]);
				order.ClientCompanyBrancheId = int.Parse(orderData[OrderField.ClientCompanyBrancheId]);
				order.CreatedByClientUserId = int.Parse(orderData[OrderField.CreatedByClientUserId]);
				order.CreationDate = DateTime.Now;
				order.DueDate = _businessDaysCalc.GetNextBusinessDay(DateTime.Now, 5);
				order.FeeInfo = new OrderFeeInfo
				{
					IsPlatformUtilizationFeeVisible = true,
					AppraisalFee = 100,
					RushFee = 100,
					SecondAppraisalFee = 100,
					PlatformUtilizationFee = 100,
					SupplementalREOAddendumFee = 100
				};
				order.GeneralInfo = new OrderGeneralInfo
				{
					BorrowerFirstName = orderData[OrderField.BorrowerFirstName],
					BorrowerLastName = orderData[OrderField.BorrowerLastName],
					LoanNumber = orderData[OrderField.LoanNumber],
					PropertyAddress = new Address { City = orderData[OrderField.PropertyCity], County = orderData[OrderField.PropertyCounty], State = orderData[OrderField.PropertyState], Street = orderData[OrderField.PropertyStreet], ZIP = orderData[OrderField.PropertyZip] }
				};
				order.LoanAndContactInfo = new OrderLoanAndContactInfo
				{
					PurchasePrice = double.Parse(orderData[OrderField.PurchasePrice]),
					GFEAmount = double.Parse(orderData[OrderField.GFEAmount]),
					GFEDate = DateTime.Now,
					LoanPurposeTypeId = int.Parse(orderData[OrderField.LoanPurposeTypeId]),
					Contacts = new List<OrderContact> { new OrderContact { ContactRoleId = int.Parse(orderData[OrderField.ContactRoleId]), Name = orderData[OrderField.ContactName], Phone = orderData[OrderField.ContactPhone] } }
				};
				order.GeocodingCounty = orderData[OrderField.PropertyCounty];
				order.Latitude = 1;
				order.Longitude = 1;
				order.OrderPublicId = orderData[OrderField.OrderPublicId];
				order.OrderStatus = OrderStatus.OrderAccepted;

				var appraiserOrder = new AppraiserOrder
				{
					AppraiserId = order.AcceptedAppraiserUserId.Value,
					CreatedDate = order.CreationDate,
					Distance = 1,
					IsDeclined = false,
					Order = order
				};


				if (_configurationHelper.Environment != DvsEnvironment.Local)
				{
					var fileName = orderData[OrderField.PurchaseContractFileName];
					var purchaseContract = _documentService.GetStaticContent(fileName);
					var documentInfo = new DocumentInfo();
					documentInfo.Name = fileName;
					documentInfo.DateAdded = DateTime.Now;
					documentInfo.AddedByUserId = _securityContext.CurrentUser.Id;
					documentInfo.Size = purchaseContract.Length;

					var documentStorageId = _documentService.StoreDocument(documentInfo, purchaseContract);
					order.LoanAndContactInfo.PurchaseContractFileGuid = documentStorageId;
					_orderDocumentsRepository.Add(new OrderDocumentInfo() { DocumentTypeId = (int)DocumentType.PurchaseContract, FileId = documentStorageId, UserType = DocumentUserType.Lender, OrderId = order.Id });
				}
				#endregion

				_appraiserOrderRepository.Add(appraiserOrder);
				return order;
			}
			else
			{
				return null;
			}
		}
		public AppraiserOrder CreateAppraiserOrder(Order order, AppraiserUser appraiser)
		{
			var appraiserOrder = new AppraiserOrder()
			{
				AppraiserUser = appraiser,
				AppraiserId = appraiser.Id,
				Distance = (float)GeographyManager.CalculateDistance((double)order.Longitude, (double)order.Latitude, (double)appraiser.ServiceArea.Longitude, (double)appraiser.ServiceArea.Latitude),
				Order = order,
				IsDeclined = false,
				CreatedDate = DateTime.Now
			};
			return appraiserOrder;
		}
		private void CheckInsufficientFeeReasons(Order order, string emailTo, string publicOrderId)
		{
			var declinedForFeeOrders = _appraiserOrderRepository.Get(e => e.OrderId == order.Id && e.DeclineAppraisalOrderReasonId != null && e.DeclineAppraisalOrderReasonId == (int)OrderDeclineReasonType.InsufficientFee);
			var notDeclinedOrders = _appraiserOrderRepository.Get(e => e.OrderId == order.Id && !e.IsDeclined);
			if (declinedForFeeOrders.Count() > 1 && !notDeclinedOrders.Any())
				_taskManager.ScheduleDeclineWithInsufficientFeeReason(emailTo, publicOrderId, order.GeneralInfo.PropertyAddress.ZIP, order.GeneralInfo.PropertyAddress.GetDisplayView(), order.Id.ToString());
		}
		private void AddNextTask(Order order, OrderPeriodicalNotificationType orderNotificationType, IDictionary<TaskParamsKey, object> additionalParams = null)
		{
			var nextRunTime = _orderPeriodicalManager.GetNextPeriodicalNotificationDate(order, orderNotificationType);
			if (nextRunTime.HasValue)
			{
				var parameters = new Dictionary<TaskParamsKey, string>();
				parameters.Add(TaskParamsKey.OrderId, order.Id.ToString());
				parameters.Add(TaskParamsKey.OrderPeriodicalNotificationTaskType, orderNotificationType.ToString());
				if (additionalParams != null)
				{
					foreach (var param in additionalParams)
					{
						parameters.Add(param.Key, param.Value.ToString());
					}
				}
				AddNew(TaskTypeEnum.OrderPeriodicalNotification, parameters, nextRunTime.Value, this.Task.Id);
			}
		}
		private void SendUpdateRequestNotification(Order order)
		{
			var dic = new Dictionary<string, string>();
			dic.Add(Constants.OrderPeriodicalNotificationKeyWords.OrderPublicId, order.OrderPublicId);
			dic.Add(Constants.OrderPeriodicalNotificationKeyWords.OrderLink, GetAppraiserOrderLink(order, Constants.WebSiteUrls.OrderFulfillmentTabs.Communication));
			_mailManager.SendPeriodicalNotification(EmailTemplateType.OrderPeriodicalNotification_UpdateRequestNotificationEmail, dic, new[] { order.AcceptedAppraiserUser.User.Email }, GetCCEmails(order));
		}
		private bool IsTaskAvaibleByOrder(Order order, OrderPeriodicalNotificationType notificationType)
		{
			var result = true;
			if (order.OrderStatus == OrderStatus.Cancelled ||
				order.OrderStatus == OrderStatus.CreationProcess ||
				order.OrderStatus == OrderStatus.Draft ||
				order.OrderStatus == OrderStatus.PendingAssignment ||
				order.OrderStatus == OrderStatus.Rejected)
			{
				result = false;
			}
			if (order.OrderStatus == OrderStatus.Completed)
			{
				if (
					notificationType == OrderPeriodicalNotificationType.UpdateRequestNotification ||
					notificationType == OrderPeriodicalNotificationType.ConditionCreatedNotification
					)
				{
					result = true;
				}
				else
				{
					result = false;
				}
			}
			return result;
		}