public OrderFeeConfirmationViewModel(OrderFeesCalculationResults results)
			: this()
		{
			if (results != null)
			{
				AppraisalFee = results.AppraisalFee;
				if (results.SecondAppraisalFee.HasValue)
					SecondAppraisalFee = results.SecondAppraisalFee;
				if (results.FHASurchargeFee.HasValue)
					FHASurchargeFee = results.FHASurchargeFee;
				if (results.SupplementalREOAddendumFee.HasValue)
					SupplementalREOAddendumFee = results.SupplementalREOAddendumFee;
				if (results.RushFee.HasValue)
					RushFee = results.RushFee;
				if (results.IsPlatformUtilizationFeeVisible)
					PlatformUtilizationFee = results.PlatformUtilizationFee;
			}
		}
Exemple #2
0
		public OrderFeesCalculationResults CalculateFee(Order order)
		{
			var orderCalculationResults = new OrderFeesCalculationResults();
			orderCalculationResults.OrderId = order.Id;
			double? platformUtilizationFee = null;

			ClientCompanyAdminSetting adminSettings;
			if (order.CreatedByClientUser.Company.Profile.IsBroker)
			{
				adminSettings = order.ClientCompany.AdminSetting;
			}
			else
			{
				adminSettings = order.CreatedByClientUser.Company.AdminSetting;
			}

			var county = string.IsNullOrEmpty(order.GeocodingCounty) ? order.GeneralInfo.PropertyAddress.County : order.GeocodingCounty;
			var state = order.GeneralInfo.PropertyAddress.State;

			var product1004 = Constants.OrderCalculations.ProductType1004.Trim().ToLowerInvariant();
			var product1004Id = GetAppraiserProductTypeIdByName(product1004);

			var productForForm = GetOrderAppraisalProductForForm(order);
			var medianAppraisalFeeByForm = GetMedianForProduct(county, state, productForForm.Value, product1004Id);

			decimal appraisalFee = (decimal)Math.Ceiling(medianAppraisalFeeByForm ?? 0);

			if (adminSettings != null)
			{
				var isPlatformUtilizationFeeVisible = adminSettings.SoftPlatformBillTo == (int)SoftwareBillTo.Borrower;
				if (adminSettings.SoftPlatformBillTo == (int)SoftwareBillTo.Appraisal)
				{
					appraisalFee += (decimal)(adminSettings.TotalFee ?? 0);
				}
				if (isPlatformUtilizationFeeVisible)
				{
					var adminTotal = (adminSettings.TotalFee.HasValue ? adminSettings.TotalFee.Value : 0);
					platformUtilizationFee = order.AppraisalInfo.SecondDuplicateAppraisal ? adminTotal * 2 : adminTotal;
				}
				orderCalculationResults.IsPlatformUtilizationFeeVisible = isPlatformUtilizationFeeVisible;
			}

			orderCalculationResults.AppraisalFee = appraisalFee;
			if (order.AppraisalInfo.SecondDuplicateAppraisal)
				orderCalculationResults.SecondAppraisalFee = appraisalFee;

			if (order.AppraisalInfo.Rush)
			{
				var rushFeeProductType = Constants.OrderCalculations.ProductTypeRush.Trim().ToLowerInvariant();
				var rushFeeId = GetAppraiserProductTypeIdByName(rushFeeProductType);
				var rushMedian = GetMedianForProduct(county, state, rushFeeId, null) ?? 0;
				var rushMedianRounded = Math.Ceiling(rushMedian);

				var rushFee = order.AppraisalInfo.SecondDuplicateAppraisal ? rushMedianRounded * 2 : rushMedianRounded;
				orderCalculationResults.RushFee = (decimal)rushFee;
			}

			if (order.AppraisalInfo.SupplementalREOAddendum)
			{
				var supplemnetaREOAddendum = Constants.OrderCalculations.ProductTypeSupplementalREOAddendum.Trim().ToLowerInvariant();
				var supplemnetaREOAddendumId = GetAppraiserProductTypeIdByName(supplemnetaREOAddendum);
				var supplemnetaREOAddendumMedian = GetMedianForProduct(county, state, supplemnetaREOAddendumId, null) ?? 0;
				var supplementalREOAddendumRounded = Math.Ceiling(supplemnetaREOAddendumMedian);

				var supplementalFee = order.AppraisalInfo.SecondDuplicateAppraisal ? supplementalREOAddendumRounded * 2 : supplementalREOAddendumRounded;
				orderCalculationResults.SupplementalREOAddendumFee = (decimal)supplementalFee;
			}

			var isFHA = order.AppraisalInfo.LoanType == LoanType.FHA;
			if (isFHA)
			{
				var fhaSurcharge = Constants.OrderCalculations.ProductTypeFHASurcharge.Trim().ToLowerInvariant();
				var fhaSurchargeId = GetAppraiserProductTypeIdByName(fhaSurcharge);
				var fhaSurchargeMedian = GetMedianForProduct(county, state, fhaSurchargeId, null) ?? 0;
				var fhaSurchargeRounded = Math.Ceiling(fhaSurchargeMedian);
				var fhaSurchargeFee = order.AppraisalInfo.SecondDuplicateAppraisal ? fhaSurchargeRounded * 2 : fhaSurchargeRounded;
				orderCalculationResults.FHASurchargeFee = (decimal)fhaSurchargeFee;
			}

			orderCalculationResults.PlatformUtilizationFee = (decimal?)platformUtilizationFee;

			return orderCalculationResults;
		}
Exemple #3
0
		public DeclinedOrderFeeConfirmationViewModel GetInsufficientFeeConfirmation(int orderId, OrderFeesCalculationResults calculationResults = null)
		{
			var order = _orderManager.GetOrderById(orderId);
			CheckOrderAccessForClients(order);
			var viewModel = new DeclinedOrderFeeConfirmationViewModel();
			viewModel.FeeConfirmation = calculationResults == null ? new OrderFeeConfirmationViewModel(order.FeeInfo) :
				new OrderFeeConfirmationViewModel(calculationResults);
			viewModel.InsufficientFeeConfirmation = calculationResults == null ? new OrderFeeConfirmationViewModel(order.FeeInfo) :
				new OrderFeeConfirmationViewModel(calculationResults);

			var insufficientFee = _orderManager.CalculateInsufficientFee(order);
			viewModel.InsufficientFeeConfirmation.AppraisalFee = insufficientFee != default(decimal) ? insufficientFee : viewModel.FeeConfirmation.AppraisalFee;
			viewModel.Difference = (double)(viewModel.InsufficientFeeConfirmation.AppraisalFee - viewModel.FeeConfirmation.AppraisalFee);
			viewModel.OrderNumber = GetOrderNumber(order);

			return viewModel;
		}
Exemple #4
0
		public OrderFeeConfirmationViewModel GetFeeConfirmation(int orderId, OrderFeesCalculationResults calculationResults = null)
		{
			var order = _orderManager.GetOrderById(orderId);
			CheckOrderAccessForClients(order);
			var viewModel = calculationResults == null ? new OrderFeeConfirmationViewModel(order.FeeInfo) : new OrderFeeConfirmationViewModel(calculationResults);
			viewModel.IsCancelPopupNeeded = !IsOrderDraft(order);
			viewModel.OrderNumber = GetOrderNumber(order);

			return viewModel;
		}
Exemple #5
0
		public void SaveFeeConfirmation(OrderFeesCalculationResults calculationResults)
		{
			var order = _orderManager.GetOrderById(calculationResults.OrderId);
			CheckOrderAccessForClients(order);
			order.FeeInfo = order.FeeInfo ?? new OrderFeeInfo();
			order.FeeInfo.AppraisalFee = (decimal)calculationResults.AppraisalFee;
			order.FeeInfo.RushFee = calculationResults.RushFee;
			order.FeeInfo.SecondAppraisalFee = calculationResults.SecondAppraisalFee;
			order.FeeInfo.FHASurchargeFee = calculationResults.FHASurchargeFee;
			order.FeeInfo.SupplementalREOAddendumFee = calculationResults.SupplementalREOAddendumFee;
			order.FeeInfo.PlatformUtilizationFee = calculationResults.PlatformUtilizationFee;
			order.FeeInfo.IsPlatformUtilizationFeeVisible = calculationResults.IsPlatformUtilizationFeeVisible;
		}