first commit
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
using System.Xml.Linq;
|
||||
using CRIF.ACTion.Configuration;
|
||||
using Landmark.OLA.Models.Assets;
|
||||
|
||||
namespace CRIF.ACTion.Loan.Assets
|
||||
{
|
||||
public class AppDetailMfgHomeAndLandSection : AppDetailHelocSection
|
||||
{
|
||||
//AppDetailMfgHomeAndLand is generally similar to AppDetailHeloc.
|
||||
public AppDetailMfgHomeAndLandSection(XNamespace sectionNamespace, CrifSettings settings)
|
||||
: base(sectionNamespace, settings, "appDetailMfgHousingAndLand", "Fixed", "Installment")
|
||||
{
|
||||
}
|
||||
|
||||
public override void AddPropertyDetails(RealEstateBase realEstateBase, bool? mfgHomeIncludesLand = null)
|
||||
{
|
||||
if (!mfgHomeIncludesLand.HasValue)
|
||||
throw new ArgumentException("Manufactured Home Loans must state if the land is included.");
|
||||
|
||||
base.AddPropertyDetails(realEstateBase, mfgHomeIncludesLand);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Xml.Linq;
|
||||
using CRIF.ACTion.Configuration;
|
||||
|
||||
namespace CRIF.ACTion.Loan.Assets
|
||||
{
|
||||
public class AppDetailRealEstateSection : AppDetailHelocSection
|
||||
{
|
||||
|
||||
//So far, AppDetailRealEstate is used exactly the same as AppDetailHeloc.
|
||||
//The only difference is the element name and term types.
|
||||
public AppDetailRealEstateSection(XNamespace sectionNamespace, CrifSettings settings)
|
||||
: base(sectionNamespace, settings, "appDetailRealEstate", "Fixed", "Installment")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
using System.Xml.Linq;
|
||||
using CRIF.ACTion.Common;
|
||||
using CRIF.ACTion.Configuration;
|
||||
using Landmark.OLA.Models.Assets;
|
||||
using Landmark.OLA.Models.Loan;
|
||||
|
||||
namespace CRIF.ACTion.Loan.Assets
|
||||
{
|
||||
public class AppDetailVehicleSection : AppDetailsSection
|
||||
{
|
||||
private readonly List<XObject> _content;
|
||||
private XElement _vehicleValuationsElement;
|
||||
|
||||
public AppDetailVehicleSection(XNamespace sectionNamespace, CrifSettings settings)
|
||||
: base(sectionNamespace, "appDetailVehicle", settings, "Fixed", "Installment")
|
||||
{
|
||||
_content = [];
|
||||
}
|
||||
|
||||
public void AddPropertyDetails(Vehicle vehicle)
|
||||
{
|
||||
//If there's no vehicle type, it's likely a preapproval and doesn't need the appDetailProperties element
|
||||
if (vehicle is null || vehicle.Type is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var appDetailPropertiesElement = new XElement(CrifNamespaces.App + "appDetailProperties");
|
||||
|
||||
var propertyValues = PropertyValues.GetPropertyValues(vehicle.Type.Value);
|
||||
|
||||
var isCollateralFL = true;
|
||||
var isTradeInFL = false;
|
||||
var statusID = "Active";
|
||||
var includeInLTVCalculations = true;
|
||||
|
||||
var appDetailPropertyElement = new XElement(CrifNamespaces.App + "appDetailProperty",
|
||||
new XAttribute(CrifNamespaces.Common + "idRef", vehicle.GetOrCreateGuid()),
|
||||
new XAttribute(CrifNamespaces.Common + "propertyType", propertyValues.PropertyType),
|
||||
new XAttribute(CrifNamespaces.Common + "propertySubType", propertyValues.PropertySubType),
|
||||
new XAttribute(CrifNamespaces.App + "isCollateralFL", isCollateralFL),
|
||||
new XAttribute(CrifNamespaces.App + "isTradeInFL", isTradeInFL),
|
||||
new XAttribute(CrifNamespaces.App + "statusID", statusID),
|
||||
new XAttribute(CrifNamespaces.App + "includeInLTVCalculations", includeInLTVCalculations),
|
||||
new XAttribute(CrifNamespaces.App + "collateralTypeID", propertyValues.CollateralId)
|
||||
);
|
||||
|
||||
appDetailPropertiesElement.Add(appDetailPropertyElement);
|
||||
|
||||
_vehicleValuationsElement = new XElement(CrifNamespaces.App + "vehicleValuations",
|
||||
new XElement(CrifNamespaces.App + "appDetailVehicleValuation",
|
||||
new XAttribute(CrifNamespaces.Common + "idRef", vehicle.ValuationId),
|
||||
new XAttribute(CrifNamespaces.App + "valueType", vehicle.ValuationType.Value.ToString())));
|
||||
//TODO: What does valuationType mean?
|
||||
|
||||
_content.Add(appDetailPropertiesElement);
|
||||
}
|
||||
|
||||
public void AddSalesPriceDetails(LoanApplication loanApplication)
|
||||
{
|
||||
_content.Add(new XAttribute(CrifNamespaces.App + "initialSalesPrice", loanApplication.RequestedAmount));
|
||||
}
|
||||
|
||||
public override void SetDetails(LoanApplication loanApplication, Guid channelRef, object[] additionalContent = null, XElement fieldsElement = null, XElement vehicleValuationsElement = null)
|
||||
{
|
||||
base.SetDetails(loanApplication, channelRef, [.. _content], vehicleValuationsElement: _vehicleValuationsElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace CRIF.ACTion.Loan.Assets
|
||||
{
|
||||
public interface IVehicleValuations
|
||||
{
|
||||
VehicleValuationsSection VehicleValuations { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using CRIF.ACTion.Common;
|
||||
using CRIF.ACTion.Configuration;
|
||||
|
||||
namespace CRIF.ACTion.Loan.Assets
|
||||
{
|
||||
public class MfgHousingAndLandAppBuilder : ILoanApplicationRequestBuilder
|
||||
{
|
||||
private readonly CrifSettings _settings;
|
||||
|
||||
public MfgHousingAndLandAppBuilder(CrifSettings settings)
|
||||
{
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
public void SetDetails(LoanApplicationRequestBuilder createApp)
|
||||
{
|
||||
createApp.AppDetails = new AppDetailMfgHomeAndLandSection(createApp.CrifRequestSectionNamespace, _settings);
|
||||
|
||||
|
||||
var includesLand = true;
|
||||
if (createApp.LoanApplication.ManufacturedHome?.Lot?.IsRented ?? false)
|
||||
{
|
||||
includesLand = false;
|
||||
}
|
||||
|
||||
|
||||
((AppDetailMfgHomeAndLandSection)createApp.AppDetails).AddPropertyDetails(createApp.LoanApplication.ManufacturedHome, includesLand);
|
||||
((AppDetailMfgHomeAndLandSection)createApp.AppDetails).AddHmdaDisclosed(createApp.LoanApplication.PrimaryBorrower.HmdaValues.HmdaNoticeDisclosed);
|
||||
createApp.Properties.AddProperty(new MfgHousingProperty(createApp.LoanApplication.ManufacturedHome, includesLand));
|
||||
createApp.Addresses.AddAddress(createApp.LoanApplication.ManufacturedHome.Lot, ContactMechanisms.CrifContactMechanism.RealEstateAddress);
|
||||
|
||||
createApp.AppDetails.SetDetails(createApp.LoanApplication,
|
||||
createApp._sourceChannel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using Landmark.OLA.Models.Assets;
|
||||
|
||||
namespace CRIF.ACTion.Loan.Assets
|
||||
{
|
||||
public class MfgHousingProperty : RealEstateProperty
|
||||
{
|
||||
public MfgHousingProperty(ManufacturedHome manufacturedHome, bool includesLand)
|
||||
: base(manufacturedHome, "propertyMfgHousing", "MfgHomeAndLand")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using Landmark.OLA.Models.Assets.Enums;
|
||||
|
||||
namespace CRIF.ACTion.Loan.Assets
|
||||
{
|
||||
public static class PropertyValues
|
||||
{
|
||||
public static (int CollateralId, string PropertyType, string PropertySubType, string elementName) GetPropertyValues(VehicleType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case VehicleType.Automobile:
|
||||
return (CrifConstants.CollateralIds[CrifConstants.Collateral.Vehicle], "Auto", "Automobile", "propertyAuto");
|
||||
case VehicleType.Motorcycle:
|
||||
return (CrifConstants.CollateralIds[CrifConstants.Collateral.Motorcycle], "Motorcycle", "NoneSelected", "propertyAuto");
|
||||
case VehicleType.Boat:
|
||||
return (CrifConstants.CollateralIds[CrifConstants.Collateral.Marine], "Marine", "NoneSelected", "propertyMarine");
|
||||
case VehicleType.ATV:
|
||||
return (CrifConstants.CollateralIds[CrifConstants.Collateral.ATV], "ATV", "NoneSelected", "propertyAuto");
|
||||
case VehicleType.PWC:
|
||||
return (CrifConstants.CollateralIds[CrifConstants.Collateral.Marine], "Marine", "NoneSelected", "propertyMarine");
|
||||
case VehicleType.RecreationalVehicle:
|
||||
return (CrifConstants.CollateralIds[CrifConstants.Collateral.RecreationalVehicle], "RV", "CampingTrailer", "propertyAuto"); //"CampingTrailer" is from CRIF example
|
||||
case VehicleType.Snowmobile:
|
||||
return (CrifConstants.CollateralIds[CrifConstants.Collateral.Snowmobile], "Snowmobile", "NoneSelected", "propertyAuto");
|
||||
case VehicleType.TrailerMotorHome:
|
||||
return (CrifConstants.CollateralIds[CrifConstants.Collateral.RecreationalVehicle], "RV", "Other", "propertyAuto"); //"Other" is from sprint requirements doc
|
||||
default:
|
||||
throw new NotImplementedException("This vehicle type is not implemented.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using CRIF.ACTion.Common;
|
||||
using CRIF.ACTion.Configuration;
|
||||
|
||||
namespace CRIF.ACTion.Loan.Assets
|
||||
{
|
||||
public class RealEstateEquityAppBuilder : ILoanApplicationRequestBuilder
|
||||
{
|
||||
private readonly CrifSettings _settings;
|
||||
|
||||
public RealEstateEquityAppBuilder(CrifSettings settings)
|
||||
{
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
public void SetDetails(LoanApplicationRequestBuilder createApp)
|
||||
{
|
||||
createApp.AppDetails = new AppDetailRealEstateSection(createApp.CrifRequestSectionNamespace, _settings);
|
||||
((AppDetailRealEstateSection)createApp.AppDetails).AddPropertyDetails(createApp.LoanApplication.RealEstate);
|
||||
((AppDetailRealEstateSection)createApp.AppDetails).AddHmdaDisclosed(createApp.LoanApplication.PrimaryBorrower.HmdaValues.HmdaNoticeDisclosed);
|
||||
createApp.Properties.AddProperty(new RealEstateProperty(createApp.LoanApplication.RealEstate));
|
||||
createApp.Addresses.AddAddress(createApp.LoanApplication.RealEstate.RealEstateAddress, ContactMechanisms.CrifContactMechanism.RealEstateAddress);
|
||||
|
||||
createApp.AppDetails.SetDetails(createApp.LoanApplication,
|
||||
createApp._sourceChannel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
using System.Xml.Linq;
|
||||
using CRIF.ACTion.Common;
|
||||
using Landmark.OLA.Models.Assets;
|
||||
using Landmark.OLA.Models.Assets.Enums;
|
||||
|
||||
using static CRIF.ACTion.Common.ContactMechanisms;
|
||||
|
||||
namespace CRIF.ACTion.Loan.Assets
|
||||
{
|
||||
public class RealEstateProperty : IProperty
|
||||
{
|
||||
private protected readonly RealEstateBase _realEstateBase;
|
||||
private protected readonly string _elementName;
|
||||
private protected readonly string _propertyType;
|
||||
|
||||
public RealEstateProperty(RealEstateBase realEstateBase, string elementName = "propertyRealEstate",
|
||||
string propertyType = "RealEstate")
|
||||
{
|
||||
_realEstateBase = realEstateBase;
|
||||
_elementName = elementName;
|
||||
_propertyType = propertyType;
|
||||
}
|
||||
|
||||
public XElement Build(params XElement[] content)
|
||||
{
|
||||
var classType = _realEstateBase.GetType();
|
||||
|
||||
if (classType.Equals(typeof(ManufacturedHome)) || classType.IsSubclassOf(typeof(ManufacturedHome)))
|
||||
{
|
||||
var realEstateElement = GetRealEstateElement((ManufacturedHome)_realEstateBase);
|
||||
realEstateElement.Add(
|
||||
new XAttribute(CrifNamespaces.Common + "lienPositionID", LienPositionType.First)
|
||||
);
|
||||
return realEstateElement;
|
||||
}
|
||||
else if (classType.Equals(typeof(RealEstate)) || classType.IsSubclassOf(typeof(RealEstate)))
|
||||
{
|
||||
var realEstateElement = GetRealEstateElement((RealEstate)_realEstateBase);
|
||||
realEstateElement.Add(
|
||||
new XAttribute(CrifNamespaces.Common + "lienPositionID", GetLienPosition(_realEstateBase.LienPosition))
|
||||
);
|
||||
return realEstateElement;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Unexpected object given to constructor for RealEstateProperty");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private XElement GetRealEstateElement(RealEstate realEstate)
|
||||
{
|
||||
return GetRealEstateElement(realEstate, realEstate.Type.Value.ToString());
|
||||
}
|
||||
|
||||
private XElement GetRealEstateElement(ManufacturedHome manufacturedHome)
|
||||
{
|
||||
var element = GetRealEstateElement(manufacturedHome, manufacturedHome.Type.Value.ToString(),
|
||||
manufacturedHome.EstimatedLandValuation, manufacturedHome.EstimatedHomeValuation);
|
||||
//The valuation fields above are suppose to go in totalValue and finalEstimatedValue as written.
|
||||
//It's a little strange but that's how CRIF stores that data.
|
||||
|
||||
// This has to be before propertyLot, otherwise CRIF will complain!
|
||||
if (manufacturedHome.Lot.AnnualPropertyTax.HasValue)
|
||||
{
|
||||
var propertyTaxesElement = new XElement(CrifNamespaces.Common + "propertyTaxes");
|
||||
var propertyTaxElement = new XElement(
|
||||
CrifNamespaces.Common + "propertyTax",
|
||||
new XAttribute(CrifNamespaces.Common + "taxEntity", "IRS"),
|
||||
new XAttribute(CrifNamespaces.Common + "amount", manufacturedHome.Lot.AnnualPropertyTax.Value.ToString()),
|
||||
new XAttribute(CrifNamespaces.Common + "paymentFrequency", "Annually")
|
||||
);
|
||||
propertyTaxesElement.Add(propertyTaxElement);
|
||||
element.Add(propertyTaxesElement);
|
||||
}
|
||||
|
||||
var propertyLotElement = new XElement(CrifNamespaces.Common + "propertyLot");
|
||||
|
||||
if (manufacturedHome.Lot.RentalAmt.HasValue)
|
||||
{
|
||||
propertyLotElement.Add(new XAttribute(CrifNamespaces.Common + "rentalAmt", manufacturedHome.Lot.RentalAmt.Value));
|
||||
}
|
||||
|
||||
element.Add(propertyLotElement);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
private XElement GetRealEstateElement(RealEstateBase realEstateBase, string subtype, decimal? finalEstimatedValue = null, decimal? totalValue = null)
|
||||
{
|
||||
var propertyRealEstateElement = new XElement(CrifNamespaces.Common + _elementName,
|
||||
new XAttribute(CrifNamespaces.Common + "id", realEstateBase.Id),
|
||||
new XAttribute(CrifNamespaces.Common + "propertySubType", subtype),
|
||||
// new XAttribute(CrifNamespaces.Common + "hasClearTitleFL", realEstate.HasClearTitle),
|
||||
new XAttribute(CrifNamespaces.Common + "initialEstimatedValue", realEstateBase.InitialEstimatedValue),
|
||||
new XAttribute(CrifNamespaces.Common + "propertyType", _propertyType),
|
||||
new XAttribute(CrifNamespaces.Common + "ownerOccupiedTypeID", realEstateBase.Use.Value));
|
||||
|
||||
if(finalEstimatedValue.HasValue)
|
||||
{
|
||||
propertyRealEstateElement.Add(new XAttribute(CrifNamespaces.Common + "finalEstimatedValue", finalEstimatedValue));
|
||||
}
|
||||
|
||||
if (totalValue.HasValue)
|
||||
{
|
||||
propertyRealEstateElement.Add(new XAttribute(CrifNamespaces.Common + "totalValue", totalValue));
|
||||
}
|
||||
|
||||
|
||||
var contactMechanismsElement = GetContactMechanisms(realEstateBase);
|
||||
|
||||
propertyRealEstateElement.Add(GetPropertyDetails(realEstateBase));
|
||||
|
||||
propertyRealEstateElement.Add(contactMechanismsElement);
|
||||
|
||||
return propertyRealEstateElement;
|
||||
}
|
||||
|
||||
private static XElement GetContactMechanisms(RealEstateBase realEstateBase)
|
||||
{
|
||||
var contactMechanismType = CrifContactMechanism.RealEstateAddress;
|
||||
var idRef = "";
|
||||
|
||||
var classType = realEstateBase.GetType();
|
||||
if (classType.Equals(typeof(ManufacturedHome)) || classType.IsSubclassOf(typeof(ManufacturedHome)))
|
||||
{
|
||||
contactMechanismType = CrifContactMechanism.ParkContactAddress;
|
||||
idRef = ((ManufacturedHome)realEstateBase).Lot.Id.ToString();
|
||||
}
|
||||
else if (classType.Equals(typeof(RealEstate)) || classType.IsSubclassOf(typeof(RealEstate)))
|
||||
{
|
||||
idRef = ((RealEstate)realEstateBase).RealEstateAddress.Id.ToString();
|
||||
}
|
||||
|
||||
var contactMechanismsElement = new XElement(CrifNamespaces.Common + "contactMechanisms",
|
||||
new XElement(CrifNamespaces.Common + "contactMechanism",
|
||||
new XAttribute(CrifNamespaces.Common + "contactMechanismType", contactMechanismType.ToString()),
|
||||
new XElement(CrifNamespaces.Common + "addressRef",
|
||||
new XAttribute(CrifNamespaces.Common + "idRef", idRef)),
|
||||
new XElement(CrifNamespaces.Common + "contactMechanismCategory",
|
||||
new XAttribute(CrifNamespaces.Common + "CD", (int)GetContactMechanismCategory(contactMechanismType)))
|
||||
));
|
||||
|
||||
return contactMechanismsElement;
|
||||
}
|
||||
|
||||
private static XAttribute[] GetPropertyDetails(RealEstateBase realEstateBase)
|
||||
{
|
||||
var attributeList = new List<XAttribute>();
|
||||
|
||||
if (realEstateBase.HasSpa.HasValue)
|
||||
{
|
||||
attributeList.Add(new XAttribute(CrifNamespaces.Common + "hasSpaFL", realEstateBase.HasSpa.Value));
|
||||
}
|
||||
if (realEstateBase.HasPool.HasValue)
|
||||
{
|
||||
attributeList.Add(new XAttribute(CrifNamespaces.Common + "hasPoolFL", realEstateBase.HasPool.Value));
|
||||
}
|
||||
if (realEstateBase.HasBasement.HasValue)
|
||||
{
|
||||
attributeList.Add(new XAttribute(CrifNamespaces.Common + "hasBasementFL", realEstateBase.HasBasement.Value));
|
||||
}
|
||||
if (realEstateBase.HasCentralAir.HasValue)
|
||||
{
|
||||
attributeList.Add(new XAttribute(CrifNamespaces.Common + "hasCentralAirFL", realEstateBase.HasCentralAir.Value));
|
||||
}
|
||||
if (realEstateBase.HasGarage.HasValue)
|
||||
{
|
||||
attributeList.Add(new XAttribute(CrifNamespaces.Common + "hasGarageFL", realEstateBase.HasGarage.Value));
|
||||
}
|
||||
if (realEstateBase.InFloodZone.HasValue)
|
||||
{
|
||||
attributeList.Add(new XAttribute(CrifNamespaces.Common + "inFloodZoneFL", realEstateBase.InFloodZone.Value));
|
||||
}
|
||||
if (realEstateBase.InEquity.HasValue)
|
||||
{
|
||||
attributeList.Add(new XAttribute(CrifNamespaces.Common + "inEquityFL", realEstateBase.InEquity.Value));
|
||||
}
|
||||
if (realEstateBase.IsPropertyHeldInTrust.HasValue)
|
||||
{
|
||||
attributeList.Add(new XAttribute(CrifNamespaces.Common + "isPropertyHeldInTrust", realEstateBase.IsPropertyHeldInTrust.Value));
|
||||
}
|
||||
|
||||
return [.. attributeList];
|
||||
}
|
||||
|
||||
public static LienPositionType GetLienPosition(LienPosition lienPositionData)
|
||||
{
|
||||
if (lienPositionData.HasFirstMortgage && lienPositionData.HasSecondMortgage)
|
||||
{
|
||||
if (lienPositionData.PayoffFirstMortgage && lienPositionData.PayoffSecondMortgage)
|
||||
{
|
||||
return LienPositionType.First;
|
||||
}
|
||||
else if (!lienPositionData.PayoffFirstMortgage && !lienPositionData.PayoffSecondMortgage)
|
||||
{
|
||||
return LienPositionType.Third;
|
||||
}
|
||||
else if (lienPositionData.PayoffFirstMortgage || lienPositionData.PayoffSecondMortgage)
|
||||
{
|
||||
return LienPositionType.Second;
|
||||
}
|
||||
|
||||
}
|
||||
else if (lienPositionData.HasFirstMortgage || lienPositionData.HasSecondMortgage)
|
||||
{
|
||||
if (lienPositionData.PayoffFirstMortgage || lienPositionData.PayoffSecondMortgage)
|
||||
{
|
||||
return LienPositionType.First;
|
||||
}
|
||||
else
|
||||
{
|
||||
return LienPositionType.Second;
|
||||
}
|
||||
}
|
||||
|
||||
return LienPositionType.First;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using CRIF.ACTion.Common;
|
||||
using CRIF.ACTion.Configuration;
|
||||
using Landmark.OLA.Models.Assets;
|
||||
using Landmark.OLA.Models.Loan.Enums;
|
||||
|
||||
namespace CRIF.ACTion.Loan.Assets
|
||||
{
|
||||
public class VehicleAppBuilder : ILoanApplicationRequestBuilder
|
||||
{
|
||||
private readonly CrifSettings _settings;
|
||||
|
||||
public VehicleAppBuilder(CrifSettings settings)
|
||||
{
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
public void SetDetails(LoanApplicationRequestBuilder createApp)
|
||||
{
|
||||
createApp.AppDetails = new AppDetailVehicleSection(createApp.CrifRequestSectionNamespace, _settings);
|
||||
|
||||
if (createApp.LoanApplication.LoanType.Value == LoanType.V_VehiclePreapproval
|
||||
&& createApp.LoanApplication.Vehicle is null)
|
||||
{
|
||||
createApp.LoanApplication.Vehicle = new Vehicle
|
||||
{
|
||||
InitialEstimatedValue = createApp.LoanApplication.RequestedAmount
|
||||
};
|
||||
}
|
||||
|
||||
((AppDetailVehicleSection)createApp.AppDetails).AddPropertyDetails(createApp.LoanApplication.Vehicle);
|
||||
((AppDetailVehicleSection)createApp.AppDetails).AddSalesPriceDetails(createApp.LoanApplication);
|
||||
createApp.Properties.AddProperty(new VehicleProperty(createApp.LoanApplication.Vehicle));
|
||||
createApp.VehicleValuations.AddVehicleValuation(createApp.LoanApplication.Vehicle);
|
||||
|
||||
if (createApp.LoanApplication.LoanType == LoanType.M_Boat &&
|
||||
!(createApp.LoanApplication.Vehicle.BoatAddress is null))
|
||||
{
|
||||
createApp.Addresses.AddAddress(createApp.LoanApplication.Vehicle.BoatAddress, ContactMechanisms.CrifContactMechanism.MarinaAddress);
|
||||
}
|
||||
|
||||
createApp.AppDetails.SetDetails(createApp.LoanApplication,
|
||||
createApp._sourceChannel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
using System.Xml.Linq;
|
||||
using CRIF.ACTion.Common;
|
||||
using CRIF.ACTion.Common.Builders;
|
||||
using Landmark.OLA.Models.Assets;
|
||||
using Landmark.OLA.Models.Loan.Enums;
|
||||
using static CRIF.ACTion.Common.ContactMechanisms;
|
||||
|
||||
namespace CRIF.ACTion.Loan.Assets
|
||||
{
|
||||
public class VehicleProperty : IProperty
|
||||
{
|
||||
private readonly Vehicle _vehicle;
|
||||
|
||||
public VehicleProperty(Vehicle vehicle)
|
||||
{
|
||||
_vehicle = vehicle;
|
||||
}
|
||||
|
||||
public XElement Build(params XElement[] content)
|
||||
{
|
||||
//If there's no vehicle type, it's likely a preapproval and doesn't need this element
|
||||
if (_vehicle is null || _vehicle.Type is null)
|
||||
return null;
|
||||
|
||||
var propertyValues = PropertyValues.GetPropertyValues(_vehicle.Type.Value);
|
||||
|
||||
var propertyElement = new XElement(CrifNamespaces.Common + propertyValues.elementName,
|
||||
new XAttribute(CrifNamespaces.Common + "id", _vehicle.GetOrCreateGuid()),
|
||||
new XAttribute(CrifNamespaces.Common + "propertySubType", propertyValues.PropertySubType),
|
||||
new XAttribute(CrifNamespaces.Common + "yearBuilt", _vehicle.Year.Value),
|
||||
new XAttribute(CrifNamespaces.Common + "initialEstimatedValue", _vehicle.InitialEstimatedValue.Value),
|
||||
new XAttribute(CrifNamespaces.Common + "propertyType", propertyValues.PropertyType));
|
||||
|
||||
if ( _vehicle.Type != Landmark.OLA.Models.Assets.Enums.VehicleType.Automobile ) {
|
||||
propertyElement.Add(new XAttribute(CrifNamespaces.Common + "totalValue",
|
||||
_vehicle.InitialEstimatedValue.Value));
|
||||
}
|
||||
|
||||
if (_vehicle.HasClearTitle.HasValue)
|
||||
{
|
||||
propertyElement.Add(new XAttribute(CrifNamespaces.Common + "hasClearTitleFL",
|
||||
_vehicle.HasClearTitle.Value));
|
||||
}
|
||||
|
||||
if (_vehicle.IsForBusinessUse.HasValue)
|
||||
{
|
||||
var usageType = _vehicle.IsForBusinessUse.Value ? "Business" : "Personal";
|
||||
propertyElement.Add(new XAttribute(CrifNamespaces.Common + "propertyUsageTypeID",
|
||||
usageType));
|
||||
}
|
||||
|
||||
if (_vehicle.IsOwnerOperator.HasValue)
|
||||
{
|
||||
propertyElement.Add(new XAttribute(CrifNamespaces.Common + "isOwnerOperatorFL",
|
||||
_vehicle.IsOwnerOperator.Value));
|
||||
}
|
||||
|
||||
if ((_vehicle.Type == Landmark.OLA.Models.Assets.Enums.VehicleType.PWC || _vehicle.Type == Landmark.OLA.Models.Assets.Enums.VehicleType.Boat)
|
||||
&& !string.IsNullOrWhiteSpace(_vehicle.VIN))
|
||||
{
|
||||
propertyElement.Add(new XAttribute(CrifNamespaces.Common + "hullNum",
|
||||
BuilderUtils.FormatCrifData(_vehicle.VIN)));
|
||||
}
|
||||
|
||||
if (_vehicle.Type == Landmark.OLA.Models.Assets.Enums.VehicleType.Boat && (_vehicle.BoatLength ?? 0) != 0)
|
||||
{
|
||||
propertyElement.Add(new XAttribute(CrifNamespaces.Common + "lengthDesc",
|
||||
_vehicle.BoatLength));
|
||||
}
|
||||
|
||||
// Order matters for elements
|
||||
|
||||
if (_vehicle.Type == Landmark.OLA.Models.Assets.Enums.VehicleType.Boat
|
||||
&& _vehicle.BoatAddress is not null)
|
||||
{
|
||||
var contactMechanisms = new XElement(CrifNamespaces.Common + "contactMechanisms");
|
||||
contactMechanisms.Add(GetAddressContactMechanismElement(_vehicle.BoatAddress.Id, CrifContactMechanism.MarinaAddress));
|
||||
propertyElement.Add(contactMechanisms);
|
||||
}
|
||||
|
||||
var valuationsLinkElement = new XElement(CrifNamespaces.Common + "propertyVehicleValuations",
|
||||
new XElement(CrifNamespaces.Common + "propertyVehicleValuation",
|
||||
new XAttribute(CrifNamespaces.Common + "idRef", _vehicle.ValuationId)));
|
||||
|
||||
propertyElement.Add(valuationsLinkElement);
|
||||
|
||||
if (_vehicle.Type == Landmark.OLA.Models.Assets.Enums.VehicleType.Boat)
|
||||
{
|
||||
propertyElement.Add(CreateMotorElement(_vehicle));
|
||||
propertyElement.Add(CreateTrailerElement(_vehicle));
|
||||
}
|
||||
|
||||
return propertyElement;
|
||||
}
|
||||
|
||||
public static XElement CreateMotorElement(Vehicle vehicle)
|
||||
{
|
||||
var motorElement = new XElement(CrifNamespaces.Common + "motors");
|
||||
|
||||
var propertyMotorElement = new XElement(CrifNamespaces.Common + "propertyMotor",
|
||||
new XAttribute(CrifNamespaces.Common + "motorNum", 1));
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(vehicle.MotorMake))
|
||||
{
|
||||
propertyMotorElement.Add(new XAttribute(CrifNamespaces.Common + "make", vehicle.MotorMake));
|
||||
}
|
||||
|
||||
if (vehicle.MotorYear is not null)
|
||||
{
|
||||
propertyMotorElement.Add(new XAttribute(CrifNamespaces.Common + "yearBuilt", vehicle.MotorYear.Value));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(vehicle.MotorModel))
|
||||
{
|
||||
propertyMotorElement.Add(new XAttribute(CrifNamespaces.Common + "model", vehicle.MotorModel));
|
||||
}
|
||||
|
||||
if (vehicle.MotorType is not null)
|
||||
{
|
||||
propertyMotorElement.Add(new XAttribute(CrifNamespaces.Common + "engineTypeID", vehicle.MotorType));
|
||||
}
|
||||
|
||||
motorElement.Add(propertyMotorElement);
|
||||
|
||||
return motorElement;
|
||||
}
|
||||
|
||||
public static XElement CreateTrailerElement(Vehicle vehicle)
|
||||
{
|
||||
var trailerElement = new XElement(CrifNamespaces.Common + "trailer",
|
||||
new XAttribute(CrifNamespaces.Common + "registrationState", "WI"));
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(vehicle.TrailerType))
|
||||
{
|
||||
trailerElement.Add(new XAttribute(CrifNamespaces.Common + "propertySubType", vehicle.TrailerType));
|
||||
}
|
||||
|
||||
if (vehicle.TrailerYear is not null)
|
||||
{
|
||||
trailerElement.Add(new XAttribute(CrifNamespaces.Common + "yearBuild", vehicle.TrailerYear.Value));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(vehicle.TrailerMake))
|
||||
{
|
||||
trailerElement.Add(new XAttribute(CrifNamespaces.Common + "make", vehicle.TrailerMake));
|
||||
}
|
||||
|
||||
return trailerElement;
|
||||
}
|
||||
|
||||
public static XElement GetAddressContactMechanismElement(Guid addressRef, CrifContactMechanism contactMechanismType)
|
||||
{
|
||||
|
||||
var contactMechanism = new XElement(CrifNamespaces.Common + "contactMechanism",
|
||||
new XAttribute(CrifNamespaces.Common + "contactMechanismType", contactMechanismType),
|
||||
new XElement(CrifNamespaces.Common + "addressRef",
|
||||
new XAttribute(CrifNamespaces.Common + "idRef", addressRef)
|
||||
),
|
||||
new XElement(CrifNamespaces.Common + "contactMechanismCategory",
|
||||
new XAttribute(CrifNamespaces.Common + "CD", 2)
|
||||
)
|
||||
);
|
||||
|
||||
return contactMechanism;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
using System.Xml.Linq;
|
||||
using CRIF.ACTion.Common;
|
||||
using CRIF.ACTion.Common.Builders;
|
||||
using CRIF.ACTion.Configuration;
|
||||
using Landmark.OLA.Models.Assets;
|
||||
|
||||
namespace CRIF.ACTion.Loan.Assets
|
||||
{
|
||||
public class VehicleValuationsSection : CrifRequestSection
|
||||
{
|
||||
public VehicleValuationsSection(XNamespace sectionNamespace, CrifSettings settings)
|
||||
: base(sectionNamespace, "vehicleValuations", settings)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void AddVehicleValuation(Vehicle vehicle)
|
||||
{
|
||||
//If there's no vehicle type, it's likely a preapproval and doesn't need this element
|
||||
if (vehicle is null || vehicle.Type is null)
|
||||
return;
|
||||
|
||||
var valuationElement = new XElement(CrifNamespaces.Common + "vehicleValuation",
|
||||
new XAttribute(CrifNamespaces.Common + "id", vehicle.ValuationId),
|
||||
new XAttribute(CrifNamespaces.Common + "valuationType", "Manual"),
|
||||
new XAttribute(CrifNamespaces.Common + "make", BuilderUtils.FormatCrifData(vehicle.Make)),
|
||||
new XAttribute(CrifNamespaces.Common + "model", BuilderUtils.FormatCrifData(vehicle.Model)),
|
||||
new XAttribute(CrifNamespaces.Common + "year", vehicle.Year.Value),
|
||||
new XAttribute(CrifNamespaces.Common + "newUsed", vehicle.Condition.Value.ToString()),
|
||||
new XAttribute(CrifNamespaces.Common + "estimatedValue", vehicle.InitialEstimatedValue));
|
||||
|
||||
var valuationValueTypesElement = new XElement(CrifNamespaces.Common + "vehicleValuationValueTypes");
|
||||
valuationValueTypesElement.Add(new XElement(CrifNamespaces.Common + "vehicleValuationValueType",
|
||||
new XAttribute(CrifNamespaces.Common + "valueType", "Manual"),
|
||||
new XAttribute(CrifNamespaces.Common + "baseValue", vehicle.InitialEstimatedValue)
|
||||
));
|
||||
|
||||
valuationElement.Add(valuationValueTypesElement);
|
||||
|
||||
if (vehicle.Mileage.HasValue)
|
||||
{
|
||||
valuationElement.Add(new XAttribute(CrifNamespaces.Common + "mileage", vehicle.Mileage.Value));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(vehicle.Color))
|
||||
{
|
||||
valuationElement.Add(new XAttribute(CrifNamespaces.Common + "color", BuilderUtils.FormatCrifData(vehicle.Color)));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(vehicle.Body))
|
||||
{
|
||||
valuationElement.Add(new XAttribute(CrifNamespaces.Common + "body", BuilderUtils.FormatCrifData(vehicle.Body)));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(vehicle.Series))
|
||||
{
|
||||
valuationElement.Add(new XAttribute(CrifNamespaces.Common + "series", BuilderUtils.FormatCrifData(vehicle.Series)));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(vehicle.Style))
|
||||
{
|
||||
valuationElement.Add(new XAttribute(CrifNamespaces.Common + "style", BuilderUtils.FormatCrifData(vehicle.Style)));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(vehicle.Trim))
|
||||
{
|
||||
valuationElement.Add(new XAttribute(CrifNamespaces.Common + "trim", BuilderUtils.FormatCrifData(vehicle.Trim)));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(vehicle.VIN))
|
||||
{
|
||||
if (vehicle.Type != Landmark.OLA.Models.Assets.Enums.VehicleType.PWC)
|
||||
{
|
||||
valuationElement.Add(new XAttribute(CrifNamespaces.Common + "vin", BuilderUtils.FormatCrifData(vehicle.VIN)));
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(vehicle.StateTitled))
|
||||
{
|
||||
valuationElement.Add(new XAttribute(CrifNamespaces.Common + "state", BuilderUtils.FormatCrifData(vehicle.StateTitled)));
|
||||
}
|
||||
|
||||
AddContent(valuationElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user