This commit is contained in:
Zeeshaun
2026-03-31 14:32:23 -05:00
parent f4646dc97f
commit 9be174da46
485 changed files with 37290 additions and 0 deletions
@@ -0,0 +1,40 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace LCU.Library.Internal.CoreApiWrapperLib.Configuration
{
public class CoreApiConfiguration
{
public string HostUrl { get; set; }
public string HostPort { get; set; }
public string GrantType { get; set; }
public string Scope { get; set; }
public string SeviceAccountId { get; set; }
public string DeviceName { get; set; }
public string RelyingPassword { get; set; }
public string ServiceApiChannelId { get; set; }
public int ReTryLimit { get; set; }
[Obsolete("User connection only, 09/08/2021, will be removed in future release")]
public string CoreEnvironment { get; set; }
[Obsolete("User connection only, 09/08/2021, will be removed in future release")]
public string UserId { get; set; }
[Obsolete("User connection only, 09/08/2021, will be removed in future release")]
public string Password { get; set; }
[Obsolete("User connection only, 09/08/2021, will be removed in future release")]
public string ApiChannelId { get; set; }
[Obsolete("User connection only, 09/08/2021, will be removed in future release")]
public string BusinessTaskId { get; set; }
[Obsolete("User connection only, 09/08/2021, will be removed in future release")]
public string ApplId { get; set; }
public CoreEndPointConfiguration CoreEndPointConfiguration { get; set; }
[NotMapped]
public string HostName
{
get
{
return $"{HostUrl}:{HostPort}";
}
}
}
}
@@ -0,0 +1,9 @@
namespace LCU.Library.Internal.CoreApiWrapperLib.Configuration
{
public class CoreConfiguration
{
public CoreApiConfiguration CoreApiConfiguration { get; set; }
public CoreSoapApiConfiguration CoreSoapApiConfiguration { get; set; }
public CoreDbConfiguration CoreDbConfiguration { get; set; }
}
}
@@ -0,0 +1,12 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace LCU.Library.Internal.CoreApiWrapperLib.Configuration
{
public class CoreDbConfiguration
{
public string ConnectionString { get; set; }
public int CommandTimeout { get; set; }
}
}
@@ -0,0 +1,55 @@
namespace LCU.Library.Internal.CoreApiWrapperLib.Configuration
{
public class CoreEndPointConfiguration
{
public string ServiceToken { get; set; }
public string StsToken { get; set; }
public string Prelogin { get; set; }
public string DnaToken { get; set; }
//Persons
public string PersonsQueryName { get; set; }
public string PersonsQuerySearch { get; set; }
public string PersonsQueryMemberAgreementNbr { get; set; }
public string PutPersonUserField { get; set; }
public string PersonUserFields { get; set; }
//Accounts
public string AccountsQueryMemberAgreement { get; set; }
public string AccountsQueryAccountDetail { get; set; }
public string AccountsTransactionHistoryQueryAccountNumber { get; set; }
public string AccountsCollateral { get; set; }
public string PutAccountUserField { get; set; }
public string AccountUserFields { get; set; }
//Addresses
public string PersonPostalAddress { get; set; }
public string PersonPostalAddresses { get; set; }
public string PersonAddressLine { get; set; }
//AccessChannelPersons
public string AccessChannelPersonsByPerson { get; set; }
public string AccessChannelPersonsAccessChannelPersonId { get; set; }
//AccessType
public string AccessChannelPersonsAccessTypes { get; set; }
//Branches
public string Branches { get; set; }
//Properties
public string PropertyById { get; set; }
public string PropertyUserFields { get; set; }
public string PutPropertyUserField { get; set; }
//Tax
public string GetPersonsDataByTaxId { get; set; }
public string GetOrganizationsDataByTaxId { get; set; }
//Organizations
public string OrganizationsQueryMemberAgreementNbr { get; set; }
public string OrganizationQuerySearch { get; set; }
}
}
@@ -0,0 +1,8 @@
namespace LCU.Library.Internal.CoreApiWrapperLib.Configuration
{
public class CoreSoapApiConfiguration
{
public string CoreSoapApiWrapperHost { get; set; }
public CoreSoapEndpointConfiguration CoreSoapEndpointConfiguration { get; set; }
}
}
@@ -0,0 +1,23 @@
namespace LCU.Library.Internal.CoreApiWrapperLib.Configuration
{
public class CoreSoapEndpointConfiguration
{
public string GetAccountByAccountNumber { get; set; }
public string PutAccountMaintenanceRequest { get; set; }
public string PutAccountBranchUpdateRequest { get; set; }
public string PutAccountLtvUpdateRequest { get; set; }
public string PutAccountAnalysisGroupMaintenanceRequest { get; set; }
public string PostMonetaryTransactions { get; set; }
public string PutDealerOriginalBalance { get; set; }
public string PutPersonAgreementsDetailTypes { get; set; }
public string PostFundsToAccount { get; set; }
public string PostPersonAccount { get; set; }
public string PostOrganizationAccount { get; set; }
public string PutOrganizationMaintenanceRequest { get; set; }
public string PutAccountNickNameUpdateRequest { get; set; }
public string PutAccountContractDateUpdateRequest { get; set; }
public string PutAccountCreditReportTypeUpdateRequest { get; set; }
public string PutPropertyUserField { get; set; }
public string PostPropertyUserField { get; set; }
}
}
@@ -0,0 +1,11 @@
namespace LCU.Library.Internal.CoreApiWrapperLib.ConnectionModels
{
public class CoreApiConnection
{
public string EffectiveDate { get; set; }
public string PostingDate { get; set; }
public string CashBoxNumber { get; set; }
public string StsToken { get; set; }
public string DnaToken { get; set; }
}
}
@@ -0,0 +1,11 @@
namespace LCU.Library.Internal.CoreApiWrapperLib.ConnectionModels
{
public class CoreApiUserConnection
{
public string EffectiveDate { get; set; }
public string PostingDate { get; set; }
public string CashBoxNumber { get; set; }
public string StsToken { get; set; }
public string DnaToken { get; set; }
}
}
@@ -0,0 +1,48 @@
namespace LCU.Library.Internal.CoreApiWrapperLib.ConnectionModels
{
public class DnaTokenConnection
{
private const string DefaultCashBoxNumber = "0";
public class DnaTokenRequest
{
public DnaTokenRequest(CoreApiUserConnection coreApiConnection)
{
MessageBody = new MessageBodyRequest(coreApiConnection);
}
public MessageBodyRequest MessageBody { get; set; }
public class MessageBodyRequest
{
public MessageBodyRequest(CoreApiUserConnection coreApiConnection)
{
EffectiveDate = coreApiConnection.EffectiveDate;
PostingDate = coreApiConnection.PostingDate;
CashBoxNumber = coreApiConnection.CashBoxNumber;
}
public string EffectiveDate { get; set; }
public string PostingDate { get; set; }
public string CashBoxNumber { get; set; }
}
}
public class DnaTokenResponse
{
public MessageHeaderResponse MessageHeader { get; set; }
public MessageBodyResponse MessageBody {get; set;}
public class MessageHeaderResponse
{
public string UpdateKey { get; set; }
public string MessageId { get; set; }
}
public class MessageBodyResponse
{
public string Dnatoken { get; set; }
}
}
}
}
@@ -0,0 +1,40 @@
namespace LCU.Library.Internal.CoreApiWrapperLib.ConnectionModels
{
public class PreloginConnection
{
public class PreloginResponse
{
public MessageHeader MessageHeader { get; set; }
public MessageBody MessageBody { get; set; }
}
public class MessageHeader
{
public string UpdateKey { get; set; }
public string MessageId { get; set; }
}
public class MessageBody
{
public string PostingDate { get; set; }
public string CarryoverDate { get; set; }
public CashBox[] CashBoxes { get; set; }
}
public class CashBox
{
public string Id { get; set; }
public int CashboxNumber { get; set; }
public string Description { get; set; }
public LocationOrganization LocationOrganization { get; set; }
public string TypeCode { get; set; }
public string Url { get; set; }
}
public class LocationOrganization
{
public string BranchNumber { get; set; }
public string BranchName { get; set; }
}
}
}
@@ -0,0 +1,10 @@
namespace LCU.Library.Internal.CoreApiWrapperLib.ConnectionModels
{
public class ServiceAccessRequest
{
public string Grant_Type { get; set; }
public string Scope { get; set; }
public string Service_Account_Id { get; set; }
public string Device_Name { get; set; }
}
}
@@ -0,0 +1,14 @@
namespace LCU.Library.Internal.CoreApiWrapperLib.ConnectionModels
{
public class ServiceAccessResponse
{
public string Access_Token { get; set; }
public string Token_Type { get; set; }
public string Expires_In { get; set; }
public string Refresh_Token { get; set; }
public string Password_Expiration { get; set; }
public string Roaming_Id { get; set; }
public string ResponseStatus { get; set; }
public string ErrorMessage { get; set; }
}
}
@@ -0,0 +1,20 @@
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
namespace LCU.Library.Internal.CoreApiWrapperModel.ConnectionModels
{
public class StsTokenConnection
{
public StsTokenConnection(CoreApiConfiguration coreApiConfiguration)
{
device_name = coreApiConfiguration.DeviceName;
environment = coreApiConfiguration.CoreEnvironment;
user_id = coreApiConfiguration.UserId;
password = coreApiConfiguration.Password;
}
public string device_name { get; set; }
public string environment { get; set; }
public string user_id { get; set; }
public string password { get; set; }
}
}
@@ -0,0 +1,141 @@
using System;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;
using Newtonsoft.Json;
using LCU.Library.Internal.CoreApiWrapperLib.Exceptions;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
namespace LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities
{
public class CoreRequest : ICoreRequest
{
private const int DefaultAttempts = 0;
private readonly IHttpClientFactory _clientFactory;
private readonly ICoreServiceConnection _coreServiceConnection;
private readonly CoreConfiguration _coreConfiguration;
private readonly CoreApiConfiguration _coreApiConfiguration;
public CoreRequest(IHttpClientFactory clientFactory,
ICoreServiceConnection coreServiceConnection,
CoreConfiguration coreConfiguration)
{
_clientFactory = clientFactory;
_coreServiceConnection = coreServiceConnection;
_coreConfiguration = coreConfiguration;
_coreApiConfiguration = _coreConfiguration.CoreApiConfiguration;
}
public async Task<T> GetRequestObject<T>(string endpoint, Dictionary<string, string> endpointParameters, string jsonBody = null)
{
return await RequestObject<T>(endpoint, endpointParameters, HttpMethod.Get, jsonBody);
}
public async Task<T> PostRequestObject<T>(string endpoint, Dictionary<string, string> endpointParameters, string jsonBody)
{
return await RequestObject<T>(endpoint, endpointParameters, HttpMethod.Post, jsonBody);
}
public async Task<T> PutRequestObject<T>(string endpoint, Dictionary<string, string> endpointParameters, string jsonBody)
{
return await RequestObject<T>(endpoint, endpointParameters, HttpMethod.Put, jsonBody);
}
public async Task<T> DeleteRequestObject<T>(string endpoint, Dictionary<string, string> endpointParameters, string jsonBody)
{
return await RequestObject<T>(endpoint, endpointParameters, HttpMethod.Delete, jsonBody);
}
private async Task<T> RequestObject<T>(string endpoint, Dictionary<string, string> endpointParameters, HttpMethod httpMethod, string jsonBody)
{
var finalEndpoint = HttpUtilities.BuildEndPointWithParams(endpoint, endpointParameters);
var result = await RequestCoreJsonResponse(finalEndpoint, httpMethod, jsonBody);
if (string.IsNullOrEmpty(result))
{
return default(T);
}
return JsonConvert.DeserializeObject<T>(result);
}
public async Task<string> RequestCoreJsonResponse(string endpoint, HttpMethod httpMethod, string body = null)
{
var attempts = DefaultAttempts;
Exception exception = new Exception();
while (attempts < _coreApiConfiguration.ReTryLimit)
{
try
{
return await SendHttpRequest(endpoint, httpMethod, body);
}
catch (UnauthorizedRequestException uex)
{
await Task.Delay(TimeSpan.FromSeconds(1));
_coreServiceConnection.RefreshAccessCache();
attempts++;
exception = uex;
}
catch (Exception ex)
{
attempts = _coreApiConfiguration.ReTryLimit;
exception = ex;
}
}
throw new Exception($"Failure to perform HTTP request. Exception: {exception.Message}");
}
public async Task<string> SendHttpRequest(string endpoint, HttpMethod httpMethod, string body = null)
{
HttpRequestMessage request = CreateHttpRequestMessage(endpoint, httpMethod, body);
var client = HttpUtilities.GetClient(request.RequestUri);
var response = await client.SendAsync(request);
if (!response.IsSuccessStatusCode)
{
if (response.StatusCode == HttpStatusCode.Unauthorized)
{
throw new UnauthorizedRequestException($"Unauthorized Request.");
}
throw new Exception($"Unable to successfully send the HTTP request. " +
$"StatusCode:{response.StatusCode}, ReasonPhrase:{response.ReasonPhrase}");
}
return await response.Content.ReadAsStringAsync();
}
public HttpRequestMessage CreateHttpRequestMessage(string endpoint, HttpMethod httpMethod, string body = null)
{
var accessToken = _coreServiceConnection.GetAccessToken();
if (string.IsNullOrWhiteSpace(accessToken))
{
throw new UnauthorizedRequestException($"Unauthorized Request.");
}
var uri = HttpUtilities.BuildHttpsUri(_coreApiConfiguration.HostName, endpoint);
HttpRequestMessage request = new HttpRequestMessage
{
Method = httpMethod,
RequestUri = uri,
Headers = {
{ HttpRequestHeader.Authorization.ToString(), accessToken },
{ "X-ApiChannelId", _coreApiConfiguration.ServiceApiChannelId },
{ "X-MessageId", Guid.NewGuid().ToString() },
{ HttpRequestHeader.ContentType.ToString(), "application/json" }
}
};
if (!string.IsNullOrEmpty(body))
{
var content = new StringContent(body, Encoding.UTF8, "application/json");
request.Content = content;
}
return request;
}
}
}
@@ -0,0 +1,108 @@
using System;
using System.Net;
using System.Net.Http;
using System.Text;
using Microsoft.Extensions.Caching.Memory;
using Newtonsoft.Json;
using Serilog;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
using LCU.Library.Internal.CoreApiWrapperLib.ConnectionModels;
using System.Net.Http.Headers;
namespace LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities
{
public class CoreServiceConnection : ICoreServiceConnection
{
private readonly IHttpClientFactory _clientFactory;
private readonly CoreConfiguration _coreConfiguration;
private readonly CoreApiConfiguration _coreApiConfiguration;
private IMemoryCache _cache;
private string _accessToken;
public CoreServiceConnection(IHttpClientFactory clientFactory,
CoreConfiguration coreConfiguration,
IMemoryCache cache)
{
_clientFactory = clientFactory;
_coreConfiguration = coreConfiguration;
_coreApiConfiguration = _coreConfiguration.CoreApiConfiguration;
_accessToken = "";
_cache = cache;
}
public string GetAccessToken()
{
if (_cache.TryGetValue("accesstoken", out _accessToken))
{
return _accessToken;
}
RefreshAccessCache();
return _accessToken;
}
public void RefreshAccessCache()
{
if (_cache.TryGetValue("accesstoken", out _accessToken))
{
_cache.Remove("accesstoken");
}
SetAccessToken();
if (!string.IsNullOrWhiteSpace(_accessToken))
{
_cache.Set("accesstoken", _accessToken);
}
}
private void SetAccessToken()
{
try
{
_accessToken = "";
var body = new ServiceAccessRequest()
{
Grant_Type = _coreApiConfiguration.GrantType,
Scope = _coreApiConfiguration.Scope,
Service_Account_Id = _coreApiConfiguration.SeviceAccountId,
Device_Name = _coreApiConfiguration.DeviceName
};
var encoded = JsonConvert.SerializeObject(body);
var content = new StringContent(encoded, Encoding.UTF8, "application/json");
var uri = HttpUtilities.BuildHttpsUri(_coreApiConfiguration.HostName, _coreApiConfiguration.CoreEndPointConfiguration.ServiceToken);
var client = HttpUtilities.GetClient(uri);
var authenticationString = $"{_coreApiConfiguration.SeviceAccountId}:{_coreApiConfiguration.RelyingPassword}";
var base64EncodedAuthenticationString = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(authenticationString));
var basicAthentication = new AuthenticationHeaderValue("Basic", base64EncodedAuthenticationString);
HttpRequestMessage request = new HttpRequestMessage()
{
Method = HttpMethod.Post,
RequestUri = uri,
Content = content,
Headers = {
{ HttpRequestHeader.Authorization.ToString(), basicAthentication.ToString() },
{ HttpRequestHeader.ContentType.ToString(), "application/json" },
{ HttpRequestHeader.Accept.ToString(), "application/json;version=2" }
}
};
var response = client.SendAsync(request).Result;
if (!response.IsSuccessStatusCode)
{
Log.Error("Unsuccessful response status code, unable to set the access token.");
return;
}
var result = response.Content.ReadAsStringAsync().Result;
var accessResponse = JsonConvert.DeserializeObject<ServiceAccessResponse>(result);
_accessToken = $"Bearer {accessResponse.Access_Token}";
}
catch (Exception ex)
{
Log.Fatal(ex, "Failure to set access token");
}
}
}
}
@@ -0,0 +1,181 @@
using System;
using System.Net;
using System.Net.Http;
using System.Text;
using Microsoft.Extensions.Caching.Memory;
using Newtonsoft.Json;
using Serilog;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
using LCU.Library.Internal.CoreApiWrapperModel.ConnectionModels;
using LCU.Library.Internal.CoreApiWrapperLib.ConnectionModels;
namespace LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities
{
[Obsolete("User connection only, 09/08/2021, will be removed in future release")]
public class CoreUserConnection : ICoreUserConnection
{
private readonly IHttpClientFactory _clientFactory;
private readonly CoreConfiguration _coreConfiguration;
private readonly CoreApiConfiguration _coreApiConfiguration;
private IMemoryCache _cache;
private CoreApiUserConnection _coreApiUserConnection;
public CoreUserConnection(IHttpClientFactory clientFactory,
CoreConfiguration coreConfiguration,
IMemoryCache cache)
{
_clientFactory = clientFactory;
_coreConfiguration = coreConfiguration;
_coreApiConfiguration = _coreConfiguration.CoreApiConfiguration;
_coreApiUserConnection = new CoreApiUserConnection();
_cache = cache;
}
public CoreApiUserConnection GetCoreApiConnection()
{
var coreApiConnection = new CoreApiUserConnection();
if (_cache.TryGetValue("coreapiuserconnection", out coreApiConnection))
{
return coreApiConnection;
}
RefreshConnectionCache();
return _coreApiUserConnection;
}
public void RefreshConnectionCache()
{
var coreApiConnection = new CoreApiUserConnection();
if (_cache.TryGetValue("coreapiuserconnection", out coreApiConnection))
{
_cache.Remove("coreapiuserconnection");
}
SetStsToken();
SetPreLoginDetails();
SetDnaToken();
_cache.Set("coreapiuserconnection", _coreApiUserConnection);
}
private void SetStsToken()
{
try
{
var body = new StsTokenConnection(_coreApiConfiguration);
var encoded = JsonConvert.SerializeObject(body);
var content = new StringContent(encoded, Encoding.UTF8, "application/json");
var uri = HttpUtilities.BuildHttpsUri(_coreApiConfiguration.HostName, _coreApiConfiguration.CoreEndPointConfiguration.StsToken);
var client = HttpUtilities.GetClient(uri);
var response = client.PostAsync(uri, content).Result;
if (!response.IsSuccessStatusCode)
{
Log.Error("Unable to set the STS Token.");
throw new Exception($"Unable to set the STS Token. StatusCode:{response.StatusCode}, ReasonPhrase:{response.ReasonPhrase}");
}
var stsToken = response.Content.ReadAsStringAsync().Result;
_coreApiUserConnection.StsToken = $"Bearer {stsToken.Replace("\"", "")}";
}
catch (Exception ex)
{
throw new Exception($"Failure to SetStsToken. Exception: {ex.InnerException}");
}
}
private void SetPreLoginDetails()
{
try
{
var uri = HttpUtilities.BuildHttpsUri(_coreApiConfiguration.HostName, _coreApiConfiguration.CoreEndPointConfiguration.Prelogin);
var client = HttpUtilities.GetClient(uri);
HttpRequestMessage request = new HttpRequestMessage()
{
Method = HttpMethod.Post,
RequestUri = uri,
Headers = {
{ HttpRequestHeader.Authorization.ToString(), _coreApiUserConnection.StsToken },
{ HttpRequestHeader.ContentType.ToString(), "application/json" },
{ "X-ApiChannelId", _coreApiConfiguration.ApiChannelId },
{ "X-MessageId", Guid.NewGuid().ToString() }
}
};
var response = client.SendAsync(request).Result;
if (!response.IsSuccessStatusCode)
{
Log.Error("Unable to set the Pre Login Details");
throw new Exception($"Unable to set the Pre Login Details. StatusCode:{response.StatusCode}, ReasonPhrase:{response.ReasonPhrase}");
}
var result = response.Content.ReadAsStringAsync().Result;
var preloginConnection = JsonConvert.DeserializeObject<PreloginConnection.PreloginResponse>(result);
AddPrelogin(preloginConnection);
}
catch (Exception ex)
{
throw new Exception($"Failure to SetPreLoginDetails. Exception: {ex.InnerException}");
}
}
public void AddPrelogin(PreloginConnection.PreloginResponse preloginResponse)
{
_coreApiUserConnection.EffectiveDate = preloginResponse.MessageBody.PostingDate;
_coreApiUserConnection.PostingDate = preloginResponse.MessageBody.PostingDate;
if (preloginResponse.MessageBody.CashBoxes.Length <= 0 ||
preloginResponse.MessageBody.CashBoxes[0] == null)
{
Log.Error("Core API user does not have a cashbox.");
throw new Exception("Core API user does not have a cashbox.");
}
_coreApiUserConnection.CashBoxNumber = preloginResponse.MessageBody.CashBoxes[0].CashboxNumber.ToString();
}
private void SetDnaToken()
{
try
{
var body = new DnaTokenConnection.DnaTokenRequest(_coreApiUserConnection);
var encoded = JsonConvert.SerializeObject(body);
var content = new StringContent(encoded, Encoding.UTF8, "application/json");
var uri = HttpUtilities.BuildHttpsUri(_coreApiConfiguration.HostName, _coreApiConfiguration.CoreEndPointConfiguration.DnaToken);
var client = HttpUtilities.GetClient(uri);
HttpRequestMessage request = new HttpRequestMessage()
{
Method = HttpMethod.Post,
RequestUri = uri,
Content = content,
Headers = {
{ HttpRequestHeader.Authorization.ToString(), _coreApiUserConnection.StsToken },
{ "X-ApiChannelId", _coreApiConfiguration.ApiChannelId },
{ "X-MessageId", Guid.NewGuid().ToString() },
{ HttpRequestHeader.ContentType.ToString(), "application/json" },
{ "X-BusinessTaskId", _coreApiConfiguration.BusinessTaskId }
}
};
var response = client.SendAsync(request).Result;
if (!response.IsSuccessStatusCode)
{
Log.Error("Unable to set the DNA Token");
throw new Exception($"Unable to set the DNA Token. StatusCode:{response.StatusCode}, ReasonPhrase:{response.ReasonPhrase}");
}
var result = response.Content.ReadAsStringAsync().Result;
var dnaTokenResponse = JsonConvert.DeserializeObject<DnaTokenConnection.DnaTokenResponse>(result);
_coreApiUserConnection.DnaToken = $"Bearer {dnaTokenResponse.MessageBody.Dnatoken}";
}
catch (Exception ex)
{
throw new Exception($"Failure to SetDnaToken. Exception: {ex.InnerException}");
}
}
}
}
@@ -0,0 +1,10 @@
using LCU.Library.Internal.CoreApiWrapperLib.ConnectionModels;
namespace LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities
{
public interface ICoreConnection
{
CoreApiConnection GetCoreApiConnection();
void RefreshConnectionCache();
}
}
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
namespace LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities
{
public interface ICoreRequest
{
Task<T> GetRequestObject<T>(string endpoint, Dictionary<string, string> endpointParameters, string jsonBody = null);
Task<T> PostRequestObject<T>(string endpoint, Dictionary<string, string> endpointParameters, string jsonBody);
Task<T> PutRequestObject<T>(string endpoint, Dictionary<string, string> endpointParameters, string jsonBody);
Task<T> DeleteRequestObject<T>(string endpoint, Dictionary<string, string> endpointParameters, string jsonBody);
Task<string> RequestCoreJsonResponse(string body, HttpMethod httpMethod, string endpoint);
}
}
@@ -0,0 +1,10 @@
using LCU.Library.Internal.CoreApiWrapperLib.ConnectionModels;
namespace LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities
{
public interface ICoreServiceConnection
{
string GetAccessToken();
void RefreshAccessCache();
}
}
@@ -0,0 +1,10 @@
using LCU.Library.Internal.CoreApiWrapperLib.ConnectionModels;
namespace LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities
{
public interface ICoreUserConnection
{
CoreApiUserConnection GetCoreApiConnection();
void RefreshConnectionCache();
}
}
@@ -0,0 +1,39 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Data;
using Dapper;
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
namespace LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities
{
public class CoreDbExecution : ICoreDbExecution
{
private readonly IDbConnection _dbConnection;
private readonly CoreConfiguration _coreConfiguration;
private readonly CoreDbConfiguration _coreDbConfiguration;
public CoreDbExecution(IDbConnection dbConnection,
CoreConfiguration coreConfiguration)
{
_coreConfiguration = coreConfiguration;
_coreDbConfiguration = _coreConfiguration.CoreDbConfiguration;
_dbConnection = dbConnection;
}
public async Task<IEnumerable<T>> ExecuteQuery<T>(string query)
{
_dbConnection.Open();
var result = await _dbConnection.QueryAsync<T>(query);
_dbConnection.Close();
return result;
}
public async Task<IEnumerable<T>> ExecuteQuery<T, P>(string query, P parameters)
{
_dbConnection.Open();
var result = await _dbConnection.QueryAsync<T>(query, parameters);
_dbConnection.Close();
return result;
}
}
}
@@ -0,0 +1,11 @@
using System.Collections.Generic;
using System.Threading.Tasks;
namespace LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities
{
public interface ICoreDbExecution
{
Task<IEnumerable<T>> ExecuteQuery<T>(string query);
Task<IEnumerable<T>> ExecuteQuery<T, P>(string query, P parameters);
}
}
@@ -0,0 +1,59 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Newtonsoft.Json;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
using LCU.Library.Internal.CoreApiWrapperModel.Constants;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.AccessChannelPersons;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public class AccessChannelPersonsDao : BaseCoreDao, IAccessChannelPersonsDao
{
private readonly CoreConfiguration _coreConfiguration;
private readonly CoreApiConfiguration _coreApiConfiguration;
public AccessChannelPersonsDao(ICoreRequest coreRequest,
CoreConfiguration coreConfiguration) : base(coreRequest)
{
_coreConfiguration = coreConfiguration;
_coreApiConfiguration = _coreConfiguration.CoreApiConfiguration;
}
/// <summary>
/// Calls Core API to update Access Channel Person.
/// </summary>
/// <param name="request"></param>
/// <returns>AccessChannelPerson</returns>
public async Task<AccessChannelPerson> UpdateAccessChannelPerson(CoreApiMessage<AccessChannelPerson> request)
{
var endpoint = HttpUtilities.ReplaceRootParameter(_coreApiConfiguration.CoreEndPointConfiguration.AccessChannelPersonsAccessChannelPersonId,
RequestRootParameters.AccessChannelPersonId,
request.MessageBody.Id);
var jsonBody = JsonConvert.SerializeObject(request);
var result = await _coreRequest.PutRequestObject<CoreApiMessage<AccessChannelPerson>>(endpoint, null, jsonBody);
return result?.MessageBody;
}
/// <summary>
/// Calls Core API to search for AccessChannelPersons based By Person.
/// Default Included: Graph
/// </summary>
/// <param name="coreRequestParameters"></param>
/// <param name="request"></param>
/// <returns>IEnumerable<AccessChannelPerson></returns>
public async Task<CoreApiMessage<IEnumerable<AccessChannelPerson>>> FindAccessChannelPersonsByPerson(CoreRequestParameters coreRequestParameters,
AccessChannelPersonsByPersonRequest request)
{
var endpointParameters = HttpUtilities.BuildDictionaryOfNonNullValues(coreRequestParameters);
var jsonBody = JsonConvert.SerializeObject(request);
return await _coreRequest.PostRequestObject<CoreApiMessage<IEnumerable<AccessChannelPerson>>>(
_coreApiConfiguration.CoreEndPointConfiguration.AccessChannelPersonsByPerson,
endpointParameters,
jsonBody);
}
}
}
@@ -0,0 +1,42 @@
using System.Threading.Tasks;
using Newtonsoft.Json;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
using LCU.Library.Internal.CoreApiWrapperModel.Constants;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.AccessTypes;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public class AccessTypeDao : BaseCoreDao, IAccessTypeDao
{
private readonly CoreConfiguration _coreConfiguration;
private readonly CoreApiConfiguration _coreApiConfiguration;
public AccessTypeDao(ICoreRequest coreRequest,
CoreConfiguration coreConfiguration) : base(coreRequest)
{
_coreConfiguration = coreConfiguration;
_coreApiConfiguration = _coreConfiguration.CoreApiConfiguration;
}
/// <summary>
/// Calls Core API to update Access Type.
/// </summary>
/// <param name="request"></param>
/// <returns>AccessType</returns>
public async Task<AccessType> UpdateAccessType(CoreApiMessage<AccessType> request, string accessChannelPersonId)
{
var endpoint = HttpUtilities.ReplaceRootParameter(_coreApiConfiguration.CoreEndPointConfiguration.AccessChannelPersonsAccessTypes,
RequestRootParameters.AccessChannelPersonId,
accessChannelPersonId);
var finalEndpoint = HttpUtilities.ReplaceRootParameter(endpoint,
RequestRootParameters.AccessTypeId,
request.MessageBody.Id);
var jsonBody = JsonConvert.SerializeObject(request);
var result = await _coreRequest.PutRequestObject<CoreApiMessage<AccessType>>(finalEndpoint, null, jsonBody);
return result?.MessageBody;
}
}
}
@@ -0,0 +1,313 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using LCU.Library.Internal.ApiSecurity.Enums;
using LCU.Library.Internal.ApiSecurity.Models;
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
using LCU.Library.Internal.CoreApiWrapperLib.Exceptions;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperModel.Constants;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Accounts;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Collaterals;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreResponses;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreSoapRequests;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreSoapResponses;
using LCU.Library.Internal.LcuHttpClient.HttpRequest;
using AccountMaintenanceRequest = LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests.AccountMaintenanceRequest;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public class AccountDao : BaseCoreDao, IAccountDao
{
private readonly ICoreDbExecution _coreDbExecution;
private readonly CoreConfiguration _coreConfiguration;
private readonly CoreApiConfiguration _coreApiConfiguration;
private readonly CoreSoapApiConfiguration _coreSoapApiConfiguration;
private readonly ApiSecurityConfiguration _apiSecurityConfiguration;
private readonly IPostRequest _postRequest;
private readonly IPutRequest _putRequest;
private const string SoapClientKeyValue = "CoreSoapApiWrapper";
private const string GetAccountAdminBranchUpdateQuery = "AccountBranch/GetAccountAdminBranchUpdateQuery";
private const string GetVipSavingsToFundQuery = "Account/GetVipSavingsToFundQuery";
private const string GetAccountOwnersByAccountNumber = "Account/GetAccountOwnersByAccountNumber";
private const string GetAccountOwnersByOrganizationName = "Account/GetAccountOwnersByOrganizationName";
private const string GetAccountOwnersByPersonName = "Account/GetAccountOwnersByPersonName";
private const string GetAccountsToUpdateGroupAnalysisQuery = "Account/GetAccountsToUpdateGroupAnalysis";
private const string GetAccountsByMajorMinorBranchAndStatusQuery = "Account/GetAccountsByMajorMinorBranchCodeAndStatus";
private const string GetAccountsByRecentTransactionsQuery = "Account/GetAccountsByRecentTransactions";
private const string DnaTimeFormat = "yyyy-MM-dd HH:mm:ss";
public AccountDao(ICoreRequest coreRequest,
CoreConfiguration coreConfiguration,
ApiSecurityConfiguration apiSecurityConfiguration,
ICoreDbExecution coreDbExecution,
IPostRequest postRequest,
IPutRequest putRequest) : base(coreRequest)
{
_coreConfiguration = coreConfiguration;
_apiSecurityConfiguration = apiSecurityConfiguration;
_coreApiConfiguration = _coreConfiguration.CoreApiConfiguration;
_coreSoapApiConfiguration = _coreConfiguration.CoreSoapApiConfiguration;
_coreDbExecution = coreDbExecution;
_postRequest = postRequest;
_putRequest = putRequest;
}
/// <summary>
/// Calls Core API to search based the memberagreenbr in the MemberAgreeNbrRequest model.
/// Default Included: Graph
/// </summary>
/// <param name="coreRequestParameters"></param>
/// <param name="request"></param>
/// <returns>IEnumerable<Account></returns>
public async Task<IEnumerable<Account>> FindByMemberAgreeNbr(CoreRequestParameters coreRequestParameters, MemberAgreeNbrRequest request)
{
var endpointParameters = HttpUtilities.BuildDictionaryOfNonNullValues(coreRequestParameters);
var jsonBody = HttpUtilities.BuildJsonOfNonNullProperties(request);
var result = await _coreRequest.PostRequestObject<CoreApiMessage<IEnumerable<Account>>>(
_coreApiConfiguration.CoreEndPointConfiguration.AccountsQueryMemberAgreement,
endpointParameters,
jsonBody);
return result?.MessageBody;
}
/// <summary>
/// Calls Core API to search based the AcctNbr in the AcctNbrRequest model.
/// Default Included: Standard, Graph
/// </summary>
/// <param name="coreRequestParameters"></param>
/// <param name="request"></param>
/// <returns>Account</returns>
public async Task<Account> FindByAcctNbr(CoreRequestParameters coreRequestParameters, AcctNbrRequest request)
{
var endpointParameters = HttpUtilities.BuildDictionaryOfNonNullValues(coreRequestParameters);
var jsonBody = HttpUtilities.BuildJsonOfNonNullProperties(request);
var result = await _coreRequest.PostRequestObject<CoreApiMessage<Account>>(
_coreApiConfiguration.CoreEndPointConfiguration.AccountsQueryAccountDetail,
endpointParameters,
jsonBody);
return result?.MessageBody;
}
/// <summary>
/// Calls Core API to search based the filled out AccountId.
/// Default Included: Graph
/// </summary>
/// <param name="coreRequestParameters"></param>
/// <param name="accountId"></param>
/// <returns>IEnumerable<Collateral></returns>
public async Task<IEnumerable<Collateral>> FindCollateralById(CoreRequestParameters coreRequestParameters, string accountId)
{
var endpointParameters = HttpUtilities.BuildDictionaryOfNonNullValues(coreRequestParameters);
var endpoint = HttpUtilities.ReplaceRootParameter(_coreApiConfiguration.CoreEndPointConfiguration.AccountsCollateral,
RequestRootParameters.AccountId,
accountId);
var result = await _coreRequest.GetRequestObject<CoreApiMessage<IEnumerable<Collateral>>>(endpoint, endpointParameters);
return result?.MessageBody;
}
/// <summary>
/// Calls Core Soap API and provides an AccountMaintenanceRequest to update an account.
/// </summary>
/// <param name="accountMaintenanceRequest"></param>
public async Task PutAccountMaintenanceRequest(IEnumerable<AccountMaintenanceRequest> accountMaintenanceRequests)
{
var endpoint = HttpUtilities.BuildHttpsUri(_coreSoapApiConfiguration.CoreSoapApiWrapperHost, _coreSoapApiConfiguration.CoreSoapEndpointConfiguration.PutAccountMaintenanceRequest);
var headers = LcuHttpClient.Utilities.HttpUtilities.GetApiKeyHeaders(SoapClientKeyValue, _apiSecurityConfiguration.ExtractApiKey(SoapClientKeyValue, ApiKeySetName.InternalKeySet));
var accounts = accountMaintenanceRequests.Select(account => new MaintenanceAccount { AccountNumber = account.AccountNumber, DeliveryMethodCode = account.DeliveryMethod, IsAccountMaintenance = true }).ToArray();
var accountMaintenanceSoapRequest = new CoreApiWrapperModel.CoreModels.CoreSoapRequests.AccountMaintenanceRequest
{
Accounts = accounts
};
var response = await _putRequest.Async<CoreApiWrapperModel.CoreModels.CoreSoapRequests.AccountMaintenanceRequest, HttpResponseMessage> (endpoint, accountMaintenanceSoapRequest, headers, 0);
if (!response.IsSuccessStatusCode)
{
throw new AccountMaintenanceRequestException($"Request to update accounts with AccountMaintenanceRequest: {accountMaintenanceSoapRequest} failed with the following bad status code: {response.StatusCode}");
}
}
public async Task<IEnumerable<string>> FindAdminBranchCodeChangeAccountNumbers()
{
var query = QueryUtilities.GetQuery(GetAccountAdminBranchUpdateQuery);
return await _coreDbExecution.ExecuteQuery<string>(query);
}
public async Task<IEnumerable<string>> FindVipSavingsToFund()
{
var query = QueryUtilities.GetQuery(GetVipSavingsToFundQuery);
return await _coreDbExecution.ExecuteQuery<string>(query);
}
public async Task<IEnumerable<string>> FindAccountsToUpdateAccountAnalysis()
{
var query = QueryUtilities.GetQuery(GetAccountsToUpdateGroupAnalysisQuery);
return await _coreDbExecution.ExecuteQuery<string>(query);
}
public async Task<BasicResponse> UpdateAccountAnalysis(AccountAnalysisGroupMaintenanceRequest accountAnalysisGroupMaintenanceRequest)
{
var endpoint = HttpUtilities.BuildHttpsUri(_coreSoapApiConfiguration.CoreSoapApiWrapperHost, _coreSoapApiConfiguration.CoreSoapEndpointConfiguration.PutAccountAnalysisGroupMaintenanceRequest);
var headers = LcuHttpClient.Utilities.HttpUtilities.GetApiKeyHeaders(SoapClientKeyValue, _apiSecurityConfiguration.ExtractApiKey(SoapClientKeyValue, ApiKeySetName.InternalKeySet));
return await _putRequest.Async<AccountAnalysisGroupMaintenanceRequest, BasicResponse>(endpoint, accountAnalysisGroupMaintenanceRequest, headers, 0);
}
public async Task<BasicResponse> UpdateAccountBranch(AccountBranchUpdateRequest accountBranchUpdateRequest)
{
var endpoint = HttpUtilities.BuildHttpsUri(_coreSoapApiConfiguration.CoreSoapApiWrapperHost, _coreSoapApiConfiguration.CoreSoapEndpointConfiguration.PutAccountBranchUpdateRequest);
var headers = LcuHttpClient.Utilities.HttpUtilities.GetApiKeyHeaders(SoapClientKeyValue, _apiSecurityConfiguration.ExtractApiKey(SoapClientKeyValue, ApiKeySetName.InternalKeySet));
return await _putRequest.Async<AccountBranchUpdateRequest, BasicResponse>(endpoint, accountBranchUpdateRequest, headers, 0);
}
public async Task<BasicResponse> UpdateAccountLoanToValue(AccountLtvUpdateRequest accountLtvUpdateRequest)
{
var endpoint = HttpUtilities.BuildHttpsUri(_coreSoapApiConfiguration.CoreSoapApiWrapperHost, _coreSoapApiConfiguration.CoreSoapEndpointConfiguration.PutAccountLtvUpdateRequest);
var headers = LcuHttpClient.Utilities.HttpUtilities.GetApiKeyHeaders(SoapClientKeyValue, _apiSecurityConfiguration.ExtractApiKey(SoapClientKeyValue, ApiKeySetName.InternalKeySet));
return await _putRequest.Async<AccountLtvUpdateRequest, BasicResponse>(endpoint, accountLtvUpdateRequest, headers, 0);
}
public async Task<BasicResponse> UpdateAccountNickName(AccountNickNameUpdateRequest accountNickNameUpdateRequest)
{
var endpoint = HttpUtilities.BuildHttpsUri(_coreSoapApiConfiguration.CoreSoapApiWrapperHost, _coreSoapApiConfiguration.CoreSoapEndpointConfiguration.PutAccountNickNameUpdateRequest);
var headers = LcuHttpClient.Utilities.HttpUtilities.GetApiKeyHeaders(SoapClientKeyValue, _apiSecurityConfiguration.ExtractApiKey(SoapClientKeyValue, ApiKeySetName.InternalKeySet));
return await _putRequest.Async<AccountNickNameUpdateRequest, BasicResponse>(endpoint, accountNickNameUpdateRequest, headers, 0);
}
public async Task<BasicResponse> UpdateAccountContractDate(AccountContractDateUpdateRequest accountContractDateUpdateRequest)
{
var endpoint = HttpUtilities.BuildHttpsUri(_coreSoapApiConfiguration.CoreSoapApiWrapperHost, _coreSoapApiConfiguration.CoreSoapEndpointConfiguration.PutAccountContractDateUpdateRequest);
var headers = LcuHttpClient.Utilities.HttpUtilities.GetApiKeyHeaders(SoapClientKeyValue, _apiSecurityConfiguration.ExtractApiKey(SoapClientKeyValue, ApiKeySetName.InternalKeySet));
return await _putRequest.Async<AccountContractDateUpdateRequest, BasicResponse>(endpoint, accountContractDateUpdateRequest, headers, 0);
}
public async Task<List<ActivityAccountDetails>> GetActivityAccountDetailsByAccountNumbers(List<string> accountNumbers)
{
var query = QueryUtilities.GetQuery("ActivityAccountDetailsByAccountNbr");
var accountActivityParams = new
{
accountNumbers = accountNumbers.ToArray()
};
var results =
await _coreDbExecution.ExecuteQuery<ActivityAccountDetails, object>(query, accountActivityParams);
return results.ToList();
}
public async Task<IEnumerable<AccountOwnership>> FindOwnersByAccountNumber(long accountNumber, DateTime creationDate)
{
var query = QueryUtilities.GetQuery(GetAccountOwnersByAccountNumber);
var accountNumberParams = new
{
accountNumber = accountNumber.ToString(),
createdDate = creationDate.Date.ToString(DnaTimeFormat)
};
return await _coreDbExecution.ExecuteQuery<AccountOwnership, object>(query, accountNumberParams);
}
public async Task<IEnumerable<AccountOwnership>> FindPrimaryOwnersByOrganizationName(string organizationName)
{
var query = QueryUtilities.GetQuery(GetAccountOwnersByOrganizationName);
var organizationNameParams = new
{
organizationName = organizationName
};
return await _coreDbExecution.ExecuteQuery<AccountOwnership, object>(query, organizationNameParams);
}
public async Task<IEnumerable<AccountOwnership>> FindPrimaryOwnersByPersonName(string personName)
{
var query = QueryUtilities.GetQuery(GetAccountOwnersByPersonName);
var personNameParams = new
{
personName = personName
};
return await _coreDbExecution.ExecuteQuery<AccountOwnership, object>(query, personNameParams);
}
/// <summary>
/// Calls Core Soap API post to create a new person account.
/// </summary>
/// <param name="CreateAccountRequest"></param>
public async Task<CreatedAccountResponse> AddPersonAccount(CreatePersonAccountRequest createPersonAccountRequest)
{
var endpoint = HttpUtilities.BuildHttpsUri(_coreSoapApiConfiguration.CoreSoapApiWrapperHost, _coreSoapApiConfiguration.CoreSoapEndpointConfiguration.PostPersonAccount);
var headers = LcuHttpClient.Utilities.HttpUtilities.GetApiKeyHeaders(SoapClientKeyValue, _apiSecurityConfiguration.ExtractApiKey(SoapClientKeyValue, ApiKeySetName.InternalKeySet));
return await _postRequest.Async<CreatePersonAccountRequest, CreatedAccountResponse>(endpoint, createPersonAccountRequest, headers, 0);
}
/// <summary>
/// Calls Core Soap API post to create a new organization account.
/// </summary>
/// <param name="CreateAccountRequest"></param>
public async Task<CreatedAccountResponse> AddOrganizationAccount(CreateOrganizationAccountRequest createOrganizationAccountRequest)
{
var endpoint = HttpUtilities.BuildHttpsUri(_coreSoapApiConfiguration.CoreSoapApiWrapperHost, _coreSoapApiConfiguration.CoreSoapEndpointConfiguration.PostOrganizationAccount);
var headers = LcuHttpClient.Utilities.HttpUtilities.GetApiKeyHeaders(SoapClientKeyValue, _apiSecurityConfiguration.ExtractApiKey(SoapClientKeyValue, ApiKeySetName.InternalKeySet));
return await _postRequest.Async<CreateOrganizationAccountRequest, CreatedAccountResponse>(endpoint, createOrganizationAccountRequest, headers, 0);
}
/// <summary>
/// Calls Core Soap API and provides an OrganizationMaintenanceRequest to update an account.
/// </summary>
/// <param name="organizationMaintenanceRequest"></param>
public async Task<BasicResponse> PutOrganizationMaintenanceRequest(OrganizationMaintenanceRequest organizationMaintenanceRequest)
{
var endpoint = HttpUtilities.BuildHttpsUri(_coreSoapApiConfiguration.CoreSoapApiWrapperHost, _coreSoapApiConfiguration.CoreSoapEndpointConfiguration.PutOrganizationMaintenanceRequest);
var headers = LcuHttpClient.Utilities.HttpUtilities.GetApiKeyHeaders(SoapClientKeyValue, _apiSecurityConfiguration.ExtractApiKey(SoapClientKeyValue, ApiKeySetName.InternalKeySet));
return await _putRequest.Async<OrganizationMaintenanceRequest, BasicResponse>(endpoint, organizationMaintenanceRequest, headers, 0);
}
/// <summary>
/// Calls Core Soap API and provides an AccountCreditReportTypeUpdateRequest to update an account.
/// </summary>
/// <param name="accountCreditReportTypeUpdateRequest"></param>
public async Task<BasicResponse> UpdateAccountCreditReportType(AccountCreditReportTypeUpdateRequest accountCreditReportTypeUpdateRequest)
{
var endpoint = HttpUtilities.BuildHttpsUri(_coreSoapApiConfiguration.CoreSoapApiWrapperHost, _coreSoapApiConfiguration.CoreSoapEndpointConfiguration.PutAccountCreditReportTypeUpdateRequest);
var headers = LcuHttpClient.Utilities.HttpUtilities.GetApiKeyHeaders(SoapClientKeyValue, _apiSecurityConfiguration.ExtractApiKey(SoapClientKeyValue, ApiKeySetName.InternalKeySet));
return await _putRequest.Async<AccountCreditReportTypeUpdateRequest, BasicResponse>(endpoint, accountCreditReportTypeUpdateRequest, headers, 0);
}
public async Task<IEnumerable<AccountsByMajorMinorBranchAndStatusResponse>> GetAccountsByMajorMinorBranchAndStatus(AccountsByMajorMinorBranchAndStatusRequest request)
{
var query = QueryUtilities.GetQuery(GetAccountsByMajorMinorBranchAndStatusQuery);
var queryParams = new
{
majorAccountTypes = request.MajorTypes.ToArray(),
minorAccountTypes = request.MinorTypes.ToArray(),
accountStatusCodes = request.AccountStatuses.ToArray(),
branchOrgCodes = request.BranchCodes.ToArray()
};
return await _coreDbExecution.ExecuteQuery<AccountsByMajorMinorBranchAndStatusResponse, object>(query, queryParams);
}
public async Task<IEnumerable<AccountsByRecentTransactionsResponse>> GetAccountsByRecentTransactions(AccountsByRecentTransactionsRequest request)
{
var query = QueryUtilities.GetQuery(GetAccountsByRecentTransactionsQuery);
var queryParams = new
{
startDate = request.StartDate,
endDate = request.EndDate
};
return await _coreDbExecution.ExecuteQuery<AccountsByRecentTransactionsResponse, object>(query, queryParams);
}
}
}
@@ -0,0 +1,32 @@
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Accounts;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public class AccountHistoryDao : IAccountHistoryDao
{
private readonly ICoreDbExecution _coreDbExecution;
private const string GetChargeOffDateTimes = "AccountHistory/GetChargeOffDateTimes";
public AccountHistoryDao(ICoreDbExecution coreDbExecution)
{
_coreDbExecution = coreDbExecution;
}
public async Task<IEnumerable<DateTime>> GetChargeoffDateTimesByAccountNumber(string accountNumber)
{
var query = QueryUtilities.GetQuery(GetChargeOffDateTimes);
var queryParams = new
{
accountNumber
};
return await _coreDbExecution.ExecuteQuery<DateTime, object>(query, queryParams);
}
}
}
@@ -0,0 +1,81 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Newtonsoft.Json;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
using LCU.Library.Internal.CoreApiWrapperModel.Constants;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Accounts;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public class AccountUserFieldDao : BaseCoreDao, IAccountUserFieldDao
{
private readonly CoreConfiguration _coreConfiguration;
private readonly CoreApiConfiguration _coreApiConfiguration;
public AccountUserFieldDao(ICoreRequest coreRequest, CoreConfiguration coreConfiguration) : base(coreRequest)
{
_coreConfiguration = coreConfiguration;
_coreApiConfiguration = _coreConfiguration.CoreApiConfiguration;
}
/// <summary>
/// Calls Core API to update Accounts UserField.
/// Default Included: Graph
/// </summary>
/// <param name="accountUserFieldUpdateRequest"></param>
/// <param name="accountId"></param>
/// <param name="userFieldId"></param>
/// <returns>AccountUserField</returns>
public async Task<AccountUserField> UpdateAccountUserField(CoreApiMessage<AccountUserFieldRequest> accountUserFieldUpdateRequest,
string accountId,
string userFieldId)
{
var endpoint = HttpUtilities.ReplaceRootParameter(_coreApiConfiguration.CoreEndPointConfiguration.PutAccountUserField,
RequestRootParameters.AccountId,
accountId);
endpoint = HttpUtilities.ReplaceRootParameter(endpoint, RequestRootParameters.UserFieldId, userFieldId);
var jsonBody = JsonConvert.SerializeObject(accountUserFieldUpdateRequest);
var result = await _coreRequest.PutRequestObject<CoreApiMessage<AccountUserField>>(endpoint, null, jsonBody);
return result?.MessageBody;
}
/// <summary>
/// Calls Core API to insert Accounts UserField.
/// Default Included: Graph
/// </summary>
/// <param name="accountUserFieldRequest"></param>
/// <param name="accountId"></param>
/// <param name="userFieldId"></param>
/// <returns>AccountUserField</returns>
public async Task<AccountUserField> InsertAccountUserField(CoreApiMessage<AccountUserFieldRequest> accountUserFieldRequest,
string accountId)
{
var endpoint = HttpUtilities.ReplaceRootParameter(_coreApiConfiguration.CoreEndPointConfiguration.AccountUserFields,
RequestRootParameters.AccountId,
accountId);
var jsonBody = JsonConvert.SerializeObject(accountUserFieldRequest);
var result = await _coreRequest.PostRequestObject<CoreApiMessage<AccountUserField>>(endpoint, null, jsonBody);
return result?.MessageBody;
}
/// <summary>
/// Calls Core API to search for UserFields based AccountId.
/// Default Included: Graph
/// </summary>
/// <param name="coreRequestParameters"></param>
/// <param name="accountId"></param>
/// <returns>IEnumerable<AccountUserField></returns>
public async Task<CoreApiMessage<IEnumerable<AccountUserField>>> FindAccountUserFieldCoreApiResponseByAccountId(CoreRequestParameters coreRequestParameters, string accountId)
{
var endpointParameters = HttpUtilities.BuildDictionaryOfNonNullValues(coreRequestParameters);
var endpoint = HttpUtilities.ReplaceRootParameter(_coreApiConfiguration.CoreEndPointConfiguration.AccountUserFields,
RequestRootParameters.AccountId,
accountId);
return await _coreRequest.GetRequestObject<CoreApiMessage<IEnumerable<AccountUserField>>>(endpoint, endpointParameters);
}
}
}
@@ -0,0 +1,318 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Activity;
using LCU.Library.Internal.CoreApiWrapperModel.LcuModels.Activity;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public class ActivityDao : IActivityDao
{
private readonly ICoreDbExecution _coreDbExecution;
private const string NewCheckingAccountSalesDigitalBanking = "Activity/NewCheckingAccountSalesDigitalBanking";
private const string NewCheckingAccountSalesQuery = "Activity/NewCheckingAccountSales";
private const string NewAtmCheckCardQuery = "Activity/NewAtmCheckCardSales";
private const string NewMortgageSalesQuery = "Activity/NewMortgageAccountSales";
private const string NewVehicleSalesQuery = "Activity/NewVehicleAccountSales";
private const string NewDebtProtectedLoanQuery = "Activity/NewDebtProtectedLoanSales";
private const string EStatementDeliveryQuery = "Activity/QueryEStatementDeliveryMethod";
private const string NewActivityManagerIncentiveReferralQuery = "Activity/NewActivityManagerIncentiveReferralQuery";
private const string ActivityManagerReferralById = "Activity/QueryActivityManagerActivityDetail";
private const string GetPersonActivityByPhoneNumberQuery = "Activity/GetPersonActivityByPhoneNumberQuery";
private const string GetPersonActivityByPersonNumberQuery = "Activity/GetPersonActivityByPersonNumberQuery";
private const string DnaTimeFormat = "yyyy-MM-dd HH:mm:ss";
public ActivityDao(ICoreDbExecution coreDbExecution)
{
_coreDbExecution = coreDbExecution;
}
//Some of this could be DRYer, opting for this for better Type Safety and Messaging in Services.
public async Task<IReadOnlyCollection<NewCheckingAccountActivity>> GetNewCheckingActivitiesNewerThanDate(
DateTime newerThanDateTime,
int limitAmount
)
{
var query = QueryUtilities.GetQuery(NewCheckingAccountSalesQuery);
//Define Anonymous Object to Pass in Parameter "newerThanDateTime: "datetimestring" to query
//See: https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/types/anonymous-types
var accountActivityParams = new
{
newerThanDateTime = newerThanDateTime.ToString(DnaTimeFormat),
afterActivityNbr = (string)null,
limitAmount = limitAmount.ToString()
};
var results =
await _coreDbExecution.ExecuteQuery<NewCheckingAccountActivity, object>(query, accountActivityParams);
return results.ToList();
}
public async Task<IReadOnlyCollection<NewCheckingAccountActivity>> GetNewCheckingActivitiesAfterActivityNbr(
long afterActivityNumber,
int limitAmount
)
{
var query = QueryUtilities.GetQuery(NewCheckingAccountSalesQuery);
var accountActivityParams = new
{
afterActivityNbr = afterActivityNumber.ToString(),
newerThanDateTime = (string)null,
limitAmount = limitAmount.ToString()
};
var results =
await _coreDbExecution.ExecuteQuery<NewCheckingAccountActivity, object>(query, accountActivityParams);
return results.ToList();
}
public async Task<IReadOnlyCollection<NewCheckingAccountActivity>> GetNewCheckingActivities(
DateTime newerThanDateTime,
long afterActivityNumber,
int limitAmount
)
{
var query = QueryUtilities.GetQuery(NewCheckingAccountSalesQuery);
var accountActivityParams = new
{
afterActivityNbr = afterActivityNumber.ToString(),
newerThanDateTime = newerThanDateTime.ToString(DnaTimeFormat),
limitAmount = limitAmount.ToString()
};
var results =
await _coreDbExecution.ExecuteQuery<NewCheckingAccountActivity, object>(query, accountActivityParams);
return results.ToList();
}
public async Task<IReadOnlyCollection<NewCheckingAccountActivity>> GetNewDigitalBankingCheckingActivitiesNewerThanDate(
DateTime newerThanDateTime,
int limitAmount
)
{
var query = QueryUtilities.GetQuery(NewCheckingAccountSalesDigitalBanking);
var accountActivityParams = new
{
newerThanDateTime = newerThanDateTime.ToString(DnaTimeFormat),
afterActivityNbr = (string)null,
limitAmount = limitAmount.ToString()
};
var results =
await _coreDbExecution.ExecuteQuery<NewCheckingAccountActivity, object>(query, accountActivityParams);
return results.ToList();
}
public async Task<IReadOnlyCollection<NewCheckingAccountActivity>> GetNewDigitalBankingCheckingActivitiesAfterActivityNbr(
long afterActivityNumber,
int limitAmount
)
{
var query = QueryUtilities.GetQuery(NewCheckingAccountSalesDigitalBanking);
var accountActivityParams = new
{
afterActivityNbr = afterActivityNumber.ToString(),
newerThanDateTime = (string)null,
limitAmount = limitAmount.ToString()
};
var results =
await _coreDbExecution.ExecuteQuery<NewCheckingAccountActivity, object>(query, accountActivityParams);
return results.ToList();
}
public async Task<IReadOnlyCollection<NewCheckingAccountActivity>> GetNewDigitalBankingCheckingActivities(
DateTime newerThanDateTime,
long afterActivityNumber,
int limitAmount
)
{
var query = QueryUtilities.GetQuery(NewCheckingAccountSalesDigitalBanking);
var accountActivityParams = new
{
afterActivityNbr = afterActivityNumber.ToString(),
newerThanDateTime = newerThanDateTime.ToString(DnaTimeFormat),
limitAmount = limitAmount.ToString()
};
var results =
await _coreDbExecution.ExecuteQuery<NewCheckingAccountActivity, object>(query, accountActivityParams);
return results.ToList();
}
public async Task<IReadOnlyCollection<NewAtmCheckCardActivity>> GetNewAtmCheckCardActivitiesNewerThanDate(
DateTime newerThanDateTime,
int limitAmount
)
{
var query = QueryUtilities.GetQuery(NewAtmCheckCardQuery);
var accountActivityParams = new
{
newerThanDateTime = newerThanDateTime.ToString(DnaTimeFormat),
afterActivityNbr = (string)null,
limitAmount = limitAmount.ToString()
};
var results =
await _coreDbExecution.ExecuteQuery<NewAtmCheckCardActivity, object>(query, accountActivityParams);
return results.ToList();
}
public async Task<IReadOnlyCollection<NewAtmCheckCardActivity>> GetNewAtmCheckCardActivitiesAfterActivityNbr(
long afterActivityNumber,
int limitAmount
)
{
var query = QueryUtilities.GetQuery(NewAtmCheckCardQuery);
var accountActivityParams = new
{
afterActivityNbr = afterActivityNumber.ToString(),
newerThanDateTime = (string)null,
limitAmount = limitAmount.ToString()
};
var results =
await _coreDbExecution.ExecuteQuery<NewAtmCheckCardActivity, object>(query, accountActivityParams);
return results.ToList();
}
public async Task<IReadOnlyCollection<NewAtmCheckCardActivity>> GetNewAtmCheckCardActivities(
DateTime newerThanDateTime,
long afterActivityNumber,
int limitAmount
)
{
var query = QueryUtilities.GetQuery(NewAtmCheckCardQuery);
var accountActivityParams = new
{
afterActivityNbr = afterActivityNumber.ToString(),
newerThanDateTime = newerThanDateTime.ToString(DnaTimeFormat),
limitAmount = limitAmount.ToString()
};
var results =
await _coreDbExecution.ExecuteQuery<NewAtmCheckCardActivity, object>(query, accountActivityParams);
return results.ToList();
}
public async Task<IReadOnlyCollection<NewActivityManagerIncentiveReferral>> GetNewActivityManagerReferralsNewerThan(
DateTime newerThanOriginationDateTime)
{
var query = QueryUtilities.GetQuery(NewActivityManagerIncentiveReferralQuery);
var accountActivityParams = new
{
newerThanOriginationDate = newerThanOriginationDateTime.ToString(DnaTimeFormat),
afterActivityId = (string)null
};
var results =
await _coreDbExecution.ExecuteQuery<NewActivityManagerIncentiveReferral, object>(query, accountActivityParams);
return results.ToList();
}
public async Task<IReadOnlyCollection<NewActivityManagerIncentiveReferral>> GetNewActivityManagerReferralsAfterActivityId(long afterActivityId)
{
var query = QueryUtilities.GetQuery(NewActivityManagerIncentiveReferralQuery);
var accountActivityParams = new
{
afterActivityId = afterActivityId.ToString(),
newerThanOriginationDate = (string)null
};
var results =
await _coreDbExecution.ExecuteQuery<NewActivityManagerIncentiveReferral, object>(query, accountActivityParams);
return results.ToList();
}
public async Task<IReadOnlyCollection<NewActivityManagerIncentiveReferral>> GetNewActivityManagerReferrals(DateTime newerThanOriginationDateTime,
long afterActivityId)
{
var query = QueryUtilities.GetQuery(NewActivityManagerIncentiveReferralQuery);
var accountActivityParams = new
{
afterActivityId = afterActivityId.ToString(),
newerThanOriginationDate = newerThanOriginationDateTime.ToString(DnaTimeFormat),
};
var results =
await _coreDbExecution.ExecuteQuery<NewActivityManagerIncentiveReferral, object>(query, accountActivityParams);
return results.ToList();
}
public async Task<IReadOnlyCollection<NewLoanSaleActivity>> GetNewMortgageSaleActivities(
DateTime? newerThanDateTime, long? afterActivityNumber)
{
var query = QueryUtilities.GetQuery(NewMortgageSalesQuery);
var accountActivityParams = new
{
afterActivityNbr = afterActivityNumber?.ToString(),
newerThanDateTime = newerThanDateTime?.ToString(DnaTimeFormat)
};
var results =
await _coreDbExecution.ExecuteQuery<NewLoanSaleActivity, object>(query, accountActivityParams);
return results.ToList();
}
public async Task<IReadOnlyCollection<NewLoanSaleActivity>> GetNewVehicleSaleActivities(
DateTime? newerThanDateTime, long? afterActivityNumber)
{
var query = QueryUtilities.GetQuery(NewVehicleSalesQuery);
var accountActivityParams = new
{
afterActivityNbr = afterActivityNumber?.ToString(),
newerThanDateTime = newerThanDateTime?.ToString(DnaTimeFormat)
};
var results =
await _coreDbExecution.ExecuteQuery<NewLoanSaleActivity, object>(query, accountActivityParams);
return results.ToList();
}
public async Task<IReadOnlyCollection<NewLoanSaleActivity>> GetNewDebtProtectedLoanSaleActivities(
DateTime? newerThanDateTime, long? afterActivityNumber)
{
var query = QueryUtilities.GetQuery(NewDebtProtectedLoanQuery);
var accountActivityParams = new
{
afterActivityNbr = afterActivityNumber?.ToString(),
newerThanDateTime = newerThanDateTime?.ToString(DnaTimeFormat)
};
var results =
await _coreDbExecution.ExecuteQuery<NewLoanSaleActivity, object>(query, accountActivityParams);
return results.ToList();
}
public async Task<IReadOnlyCollection<NewActivityManagerIncentiveReferral>> QueryActivityManagerActivity(ActivityQueryRequest request)
{
var query = QueryUtilities.GetQuery(ActivityManagerReferralById);
var accountActivityParams = new
{
activityIds = request.ActivityIds.Select(x => x.ToString()).ToArray()
};
var results =
await _coreDbExecution.ExecuteQuery<NewActivityManagerIncentiveReferral, object>(query, accountActivityParams);
return results.ToList();
}
public async Task<IReadOnlyCollection<EStatementDeliveryMethod>> GetEStatementDeliveryActivity(DateTime? newerThanDateTime)
{
var query = QueryUtilities.GetQuery(EStatementDeliveryQuery);
var accountActivityParams = new
{
newerThanDateTime = newerThanDateTime?.ToString(DnaTimeFormat)
};
var results =
await _coreDbExecution.ExecuteQuery<EStatementDeliveryMethod, object>(query, accountActivityParams);
return results.ToList();
}
public async Task<IReadOnlyCollection<PersonRecentActivity>> GetPersonActivityByPhoneNumber(string phoneNumber)
{
var query = QueryUtilities.GetQuery(GetPersonActivityByPhoneNumberQuery);
var personRecentActivityParams = new
{
phoneNumber = phoneNumber
};
return (await _coreDbExecution.ExecuteQuery<PersonRecentActivity, dynamic>(query, personRecentActivityParams)).ToList();
}
public async Task<PersonRecentActivity> GetPersonActivityByPersonNumber(string personNumber)
{
var query = QueryUtilities.GetQuery(GetPersonActivityByPersonNumberQuery);
var personRecentActivityParams = new {
personNumber = personNumber
};
return (await _coreDbExecution.ExecuteQuery<PersonRecentActivity, dynamic>(query, personRecentActivityParams)).FirstOrDefault();
}
}
}
@@ -0,0 +1,132 @@
using System.Threading.Tasks;
using Newtonsoft.Json;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
using LCU.Library.Internal.CoreApiWrapperModel.Constants;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.PostalAddresses;
using System.Collections.Generic;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public class AddressDao : BaseCoreDao, IAddressDao
{
private readonly CoreConfiguration _coreConfiguration;
private readonly CoreApiConfiguration _coreApiConfiguration;
public AddressDao(ICoreRequest coreRequest,
CoreConfiguration coreConfiguration)
: base(coreRequest)
{
_coreConfiguration = coreConfiguration;
_coreApiConfiguration = _coreConfiguration.CoreApiConfiguration;
}
/// <summary>
/// Calls Core API to search based on personNumber and postalAddressNumber.
/// Default Included: Standard
/// </summary>
/// <param name="coreRequestParameters"></param>
/// <param name="personNumber"></param>
/// <param name="postalAddressId"></param>
/// <returns>CoreApiMessage<PersonPostalAddress></returns>
public async Task<CoreApiMessage<PersonPostalAddress>> FindByPersonNumberAddressNumber(CoreRequestParameters coreRequestParameters,
string personNumber,
string postalAddressId)
{
var endpointParameters = HttpUtilities.BuildDictionaryOfNonNullValues(coreRequestParameters);
var endpoint = ReplaceEndpointsPersonIdAndPostalAddressId(personNumber, postalAddressId);
return await _coreRequest.GetRequestObject<CoreApiMessage<PersonPostalAddress>>(endpoint, endpointParameters, null);
}
/// <summary>
/// Calls Core API to search based on personNumber.
/// Default Included: Standard
/// </summary>
/// <param name="coreRequestParameters"></param>
/// <param name="personNumber"></param>
/// <param name="postalAddressNumber"></param>
/// <returns>CoreApiMessage<PersonPostalAddress></returns>
public async Task<CoreApiMessage<IReadOnlyCollection<PersonPostalAddress>>> FindByPersonNumber(CoreRequestParameters coreRequestParameters,
string personNumber)
{
var endpointParameters = HttpUtilities.BuildDictionaryOfNonNullValues(coreRequestParameters);
var endpoint = HttpUtilities.ReplaceRootParameter(_coreApiConfiguration.CoreEndPointConfiguration.PersonPostalAddresses,
RequestRootParameters.PersonId,
personNumber);
var result = await _coreRequest.GetRequestObject<CoreApiMessage<IReadOnlyCollection<PersonPostalAddress>>>(endpoint, endpointParameters, null);
return result;
}
// <summary>
/// Calls Core API to Post Address.
/// Default Included: Standard
/// </summary>
/// <param name="coreUpdateRequestAddress"></param>
/// <returns>boole</returns>
public async Task<PersonPostalAddress> InsertPersonPostalAddress(PersonPostalAddress request)
{
var endpoint = HttpUtilities.ReplaceRootParameter(_coreApiConfiguration.CoreEndPointConfiguration.PersonPostalAddresses,
RequestRootParameters.PersonId,
request.PersonNumber.ToString());
var message = new
{
messageBody = request
};
var jsonBody = JsonConvert.SerializeObject(message);
var result = await _coreRequest.PostRequestObject<CoreApiMessage<PersonPostalAddress>>(endpoint, null, jsonBody);
return result?.MessageBody;
}
/// <summary>
/// Calls Core API to Delete Address.
/// Default Included: Standard
/// </summary>
/// <param name="request"></param>
/// <returns>boole</returns>
public async Task<string> RemovePersonPostalAddress(CoreApiMessage<PersonPostalAddress> request)
{
var endpoint = ReplaceEndpointsPersonIdAndPostalAddressId(request.MessageBody.PersonNumber.ToString(),
request.MessageBody.Id.ToString());
var jsonBody = JsonConvert.SerializeObject(request);
var result = await _coreRequest.DeleteRequestObject<object>(endpoint, null, jsonBody);
var stringResult = "";
//If not null DNA sent back a error object back. We want to serialize and use in error log message.
if (result != null)
{
stringResult = JsonConvert.SerializeObject(result);
}
return stringResult;
}
public async Task<PersonAddrLine> UpdatePersonAddrLine(CoreApiMessage<PersonAddrLine> request)
{
var endpoint = ReplaceEndpointsPersonIdAndAdressUseCode(request.MessageBody.PersonNumber.ToString(), request.MessageBody.AddressUseCode);
var jsonBody = JsonConvert.SerializeObject(request);
var result = await _coreRequest.PutRequestObject<CoreApiMessage<PersonAddrLine>>(endpoint, null, jsonBody);
return result?.MessageBody;
}
private string ReplaceEndpointsPersonIdAndPostalAddressId(string personId, string postalAddressId)
{
var endpoint = ReplaceEndpointsPersonId(_coreApiConfiguration.CoreEndPointConfiguration.PersonPostalAddress, personId);
return HttpUtilities.ReplaceRootParameter(endpoint, RequestRootParameters.PostalAddressId, postalAddressId);
}
private string ReplaceEndpointsPersonIdAndAdressUseCode(string personId, string addressUseCode)
{
var endpoint = ReplaceEndpointsPersonId(_coreApiConfiguration.CoreEndPointConfiguration.PersonAddressLine, personId);
return HttpUtilities.ReplaceRootParameter(endpoint, RequestRootParameters.AddressUseCode, addressUseCode);
}
private string ReplaceEndpointsPersonId(string endpoint, string personId)
{
return HttpUtilities.ReplaceRootParameter(endpoint, RequestRootParameters.PersonId, personId);
}
}
}
@@ -0,0 +1,153 @@
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Agreements;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.MemberAgreements;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public class AgreeDao: IAgreeDao
{
private readonly ICoreDbExecution _coreDbExecution;
private const string AgreeUserByAccountsQuery = "AgreeUserByAccountsQuery";
private const string AgreeUserByPersonNumberQuery = "AgreeUserByPersonNumberQuery";
private const string AgreeUserByOrganizationNumberQuery = "AgreeUserByOrganizationNumberQuery";
private const string AgreementByUserIdQuery = "Agreement/AgreementByUserIdQuery";
private const string AgreementByAgreementIdQuery = "Agreement/AgreementByAgreementIdQuery";
private const string AgreementsByAccountIdQuery = "Agreement/AgreementsByAccountIdQuery";
private const string AccountByAccountIdQuery = "Agreement/AccountByAccountIdQuery";
private const string AccountsByAgreementUserIdQuery = "Agreement/AccountsByAgreementUserIdQuery";
private const string AccountsByOrganizationIdQuery = "Agreement/AccountsByOrganizationIdQuery";
private const string AgreementOwnerByAccountsQuery = "Agreement/AgreementOwnerByAccountsQuery";
private const string AuditActiveSubActiveForAccountChangesQuery = "Agreement/Audit/AuditActiveSubActiveForAccountChangesQuery";
private const string AuditActiveSubActiveForAgreementChangesQuery = "Agreement/Audit/AuditActiveSubActiveForAgreementChangesQuery";
private const string AuditActiveSubActiveForOrganizationChangesQuery = "Agreement/Audit/AuditActiveSubActiveForOrganizationChangesQuery";
private const string AccountNumbersHolder = "{AccountNumbersHolder}";
private const string DnaTimeFormat = "yyyy-MM-dd HH:mm:ss";
public AgreeDao(ICoreDbExecution coreDbExecution)
{
_coreDbExecution = coreDbExecution;
}
public async Task<IEnumerable<AgreeUserAccount>> FindAgreeUsersByAccountNumbers(List<string> accountNumbers)
{
var query = QueryUtilities.GetQuery(AgreeUserByAccountsQuery);
var accountNumbersStringList = QueryUtilities.BuildParameterListString(accountNumbers);
var alteredQuery = query.Replace(AccountNumbersHolder, accountNumbersStringList);
var parameterDictionary = QueryUtilities.BuildDictionaryParameter(accountNumbers);
var result = await _coreDbExecution.ExecuteQuery<AgreeUserAccount, Dictionary<string, object>>(alteredQuery, parameterDictionary);
return result;
}
public async Task<IEnumerable<string>> FindAgreeUserByPersonNumber(long personNumber)
{
var query = QueryUtilities.GetQuery(AgreeUserByPersonNumberQuery);
var personNumberParam = new { personNumber };
var agreementUser = await _coreDbExecution.ExecuteQuery<string, object>(query, personNumberParam);
return agreementUser;
}
public async Task<string> FindAgreeUserByOrganizationNumber(long organizationNumber)
{
var query = QueryUtilities.GetQuery(AgreeUserByOrganizationNumberQuery);
var organizationNumberParam = new { organizationNumber };
var agreementUser = await _coreDbExecution.ExecuteQuery<string, object>(query, organizationNumberParam);
return agreementUser.FirstOrDefault();
}
public async Task<Agreement> FindAgreementByUserId(string userId)
{
var query = QueryUtilities.GetQuery(AgreementByUserIdQuery);
var userIdParam = new { userId };
var agreement = await _coreDbExecution.ExecuteQuery<Agreement, object>(query, userIdParam);
return agreement.FirstOrDefault();
}
public async Task<Agreement> FindAgreementByAgreementId(long agreementId)
{
var query = QueryUtilities.GetQuery(AgreementByAgreementIdQuery);
var agreementIdParam = new { agreementId };
var agreement = await _coreDbExecution.ExecuteQuery<Agreement, object>(query, agreementIdParam);
return agreement.FirstOrDefault();
}
public async Task<IEnumerable<Agreement>> FindAgreementsByAccountId(long accountNumber)
{
var query = QueryUtilities.GetQuery(AgreementsByAccountIdQuery);
var accountNumberParams = new { accountNumber };
return await _coreDbExecution.ExecuteQuery<Agreement, object>(query, accountNumberParams);
}
public async Task<IEnumerable<AgreementAccount>> FindAgreementAccountsByUserId(string userId)
{
var query = QueryUtilities.GetQuery(AccountsByAgreementUserIdQuery);
var userIdParams = new { userId };
return await _coreDbExecution.ExecuteQuery<AgreementAccount, object>(query, userIdParams);
}
public async Task<IEnumerable<AgreementAccount>> FindAgreementAccountsByOrganizationId(long organizationId)
{
var query = QueryUtilities.GetQuery(AccountsByOrganizationIdQuery);
var organizationIdParams = new { organizationId };
return await _coreDbExecution.ExecuteQuery<AgreementAccount, object>(query, organizationIdParams);
}
public async Task<AgreementAccount> FindAgreementAccountByAccountId(long accountNumber)
{
var query = QueryUtilities.GetQuery(AccountByAccountIdQuery);
var accountNumberParams = new { accountNumber };
var account = await _coreDbExecution.ExecuteQuery<AgreementAccount, object>(query, accountNumberParams);
return account.FirstOrDefault();
}
public async Task<IEnumerable<AgreementAccountOwner>> FindAgreementOwnerByAccountNumbers(IEnumerable<long> accountNumbers)
{
var query = QueryUtilities.GetQuery(AgreementOwnerByAccountsQuery);
var accountNumbersStringList = string.Join(",", accountNumbers);
var alteredQuery = query.Replace(AccountNumbersHolder, accountNumbersStringList);
return await _coreDbExecution.ExecuteQuery<AgreementAccountOwner, object>(alteredQuery, null);
}
public async Task<AgreementAccountOwner> FindAgreementOwnerByAccountNumber(long accountNumber)
{
var query = QueryUtilities.GetQuery(AgreementOwnerByAccountsQuery);
var alteredQuery = query.Replace(AccountNumbersHolder, accountNumber.ToString());
var accountOwner = await _coreDbExecution.ExecuteQuery<AgreementAccountOwner, object>(alteredQuery, null);
return accountOwner.FirstOrDefault();
}
public async Task<IEnumerable<long>> AuditAccountDeliveryMethodAndOwnerChangesByDateLastMaintained(DateTime maintenanceDate)
{
var query = QueryUtilities.GetQuery(AuditActiveSubActiveForAccountChangesQuery);
var dateLastMaintained = maintenanceDate.ToString(DnaTimeFormat);
var maintenanceDateParam = new { dateLastMaintained };
return await _coreDbExecution.ExecuteQuery<long, object>(query, maintenanceDateParam);
}
public async Task<IEnumerable<long>> AuditAccountAgreementChangesByDateLastMaintained(DateTime maintenanceDate)
{
var query = QueryUtilities.GetQuery(AuditActiveSubActiveForAgreementChangesQuery);
var dateLastMaintained = maintenanceDate.ToString(DnaTimeFormat);
var maintenanceDateParam = new { dateLastMaintained };
return await _coreDbExecution.ExecuteQuery<long, object>(query, maintenanceDateParam);
}
public async Task<IEnumerable<long>> AuditAccountOrganizationChangesByDateLastMaintained(DateTime maintenanceDate)
{
var query = QueryUtilities.GetQuery(AuditActiveSubActiveForOrganizationChangesQuery);
var dateLastMaintained = maintenanceDate.ToString(DnaTimeFormat);
var maintenanceDateParam = new { dateLastMaintained };
return await _coreDbExecution.ExecuteQuery<long, object>(query, maintenanceDateParam);
}
}
}
@@ -0,0 +1,88 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Library.Internal.ApiSecurity.Enums;
using LCU.Library.Internal.ApiSecurity.Models;
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreResponses;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreSoapRequests;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.MemberAgreements;
using LCU.Library.Internal.LcuHttpClient.HttpRequest;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public class AgreePersonDao : IAgreePersonDao
{
private readonly ICoreDbExecution _coreDbExecution;
private readonly CoreSoapApiConfiguration _coreSoapApiConfiguration;
private readonly ApiSecurityConfiguration _apiSecurityConfiguration;
private readonly IPutRequest _putRequest;
private const string SoapClientKeyValue = "CoreSoapApiWrapper";
private const string AgreePersonByUserIdQuery = "AgreePerson/AgreePersonByUserIdQuery";
private const string GetAgreePersonsQuery = "AgreePerson/GetAgreePersonsQuery";
private const string AgreePersonsWithHyphenatedUserIdQuery = "AgreePerson/AgreePersonsWithHyphenatedUserIdQuery";
private const string GetActiveCustodialAgreePersonNumbers = "AgreePerson/GetActiveCustodialAgreePersonNumbers";
private const string GetActiveCustodialVruCardAgreementAgreePersons = "AgreePerson/GetActiveCustodialVruCardAgreementAgreePersons";
public AgreePersonDao(ICoreDbExecution coreDbExecution,
CoreConfiguration coreConfiguration,
ApiSecurityConfiguration apiSecurityConfiguration,
IPutRequest putRequest)
{
_coreDbExecution = coreDbExecution;
_coreSoapApiConfiguration = coreConfiguration.CoreSoapApiConfiguration;
_apiSecurityConfiguration = apiSecurityConfiguration;
_putRequest = putRequest;
}
public async Task<AgreePerson> FindByUserId(string userId)
{
var query = QueryUtilities.GetQuery(AgreePersonByUserIdQuery);
var userIdParams = new { userId = userId };
var result = await _coreDbExecution.ExecuteQuery<AgreePerson, object>(query, userIdParams);
return result.FirstOrDefault();
}
public async Task<IEnumerable<AgreePerson>> FindAgreePersons(int fetchAmount)
{
var query = QueryUtilities.GetQuery(GetAgreePersonsQuery);
var fectAmountParam = new { fetchAmount = fetchAmount };
var result = await _coreDbExecution.ExecuteQuery<AgreePerson, object>(query, fectAmountParam);
return result;
}
public async Task<IEnumerable<AgreePerson>> FindAgreePersonsWithHyphenatedUserId()
{
var query = QueryUtilities.GetQuery(AgreePersonsWithHyphenatedUserIdQuery);
var result = await _coreDbExecution.ExecuteQuery<AgreePerson>(query);
return result;
}
public async Task<IEnumerable<string>> FindActiveCustodialAgreePersonNumbers()
{
var query = QueryUtilities.GetQuery(GetActiveCustodialAgreePersonNumbers);
var result = await _coreDbExecution.ExecuteQuery<string>(query);
return result;
}
public async Task<IEnumerable<AgreePerson>> FindActiveCustodialVruCardAgreementAgreePersons()
{
var query = QueryUtilities.GetQuery(GetActiveCustodialVruCardAgreementAgreePersons);
var result = await _coreDbExecution.ExecuteQuery<AgreePerson>(query);
return result;
}
public async Task<BasicResponse> UpdatePersonAgreementDetailTypes(PersonAgreementDetailTypeRequest personAgreementDetailTypeRequest)
{
var endpoint = HttpUtilities.BuildHttpsUri(_coreSoapApiConfiguration.CoreSoapApiWrapperHost, _coreSoapApiConfiguration.CoreSoapEndpointConfiguration.PutPersonAgreementsDetailTypes);
var headers = LcuHttpClient.Utilities.HttpUtilities.GetApiKeyHeaders(SoapClientKeyValue, _apiSecurityConfiguration.ExtractApiKey(SoapClientKeyValue, ApiKeySetName.InternalKeySet));
return await _putRequest.Async<PersonAgreementDetailTypeRequest, BasicResponse>(endpoint, personAgreementDetailTypeRequest, headers, 0);
}
}
}
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.ApplicationHistories;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public class ApplicationHistoryDao : IApplicationHistoryDao
{
private readonly ICoreDbExecution _coreDbExecution;
private const string ApplHistoryQuery = "ApplHistoryQuery";
private const string QueApplParamQuery = "QueApplParamQuery";
private const string DnaTimeFormat = "yyyy-MM-dd HH:mm:ss";
private const string ApplicationNumbersHolder = "{ApplicationNumbersHolder}";
public ApplicationHistoryDao(ICoreDbExecution coreDbExecution)
{
_coreDbExecution = coreDbExecution;
}
public async Task<IEnumerable<ApplicationHistory>> FindApplicationHistory(List<string> applicationNumbers,
DateTime effectiveDate)
{
var query = QueryUtilities.GetQuery(ApplHistoryQuery);
var applicationNumberStringList = QueryUtilities.BuildParameterListString(applicationNumbers);
var alteredQuery = query.Replace(ApplicationNumbersHolder, applicationNumberStringList);
var parameterDictionary = QueryUtilities.BuildDictionaryParameter(applicationNumbers);
parameterDictionary.Add(nameof(effectiveDate), effectiveDate.ToString(DnaTimeFormat));
var results = await _coreDbExecution.ExecuteQuery<ApplicationHistory, Dictionary<string, object>>(alteredQuery, parameterDictionary);
return results;
}
public async Task<IEnumerable<QueueApplicationParameter>> FindApplicationHistoryParameters(List<string> applicationNumbers,
DateTime effectiveDate)
{
var query = QueryUtilities.GetQuery(QueApplParamQuery);
var applicationNumberStringList = QueryUtilities.BuildParameterListString(applicationNumbers);
var alteredQuery = query.Replace(ApplicationNumbersHolder, applicationNumberStringList);
var parameterDictionary = QueryUtilities.BuildDictionaryParameter(applicationNumbers);
parameterDictionary.Add(nameof(effectiveDate), effectiveDate.ToString(DnaTimeFormat));
var results = await _coreDbExecution.ExecuteQuery<QueueApplicationParameter, Dictionary<string, object>>(alteredQuery, parameterDictionary);
return results;
}
}
}
@@ -0,0 +1,35 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Associate;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public class AssociateDao : BaseCoreDao, IAssociateDao
{
private const string GetAssociateDetailsBySsnQuery = "Associate/GetAssociateDetailsBySsnQuery";
private readonly ICoreDbExecution _coreDbExecution;
public AssociateDao(ICoreRequest coreRequest,
ICoreDbExecution coreDbExecution)
: base(coreRequest)
{
_coreDbExecution = coreDbExecution;
}
public async Task<AssociateDetails> GetAssociateDetailsBySsn(string taxId)
{
var query = QueryUtilities.GetQuery(GetAssociateDetailsBySsnQuery);
var queryParameters = new
{
taxId = taxId
};
return (await _coreDbExecution.ExecuteQuery<AssociateDetails, dynamic>(query, queryParameters)).FirstOrDefault();
}
}
}
@@ -0,0 +1,14 @@
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public abstract class BaseCoreDao
{
protected readonly ICoreRequest _coreRequest;
public BaseCoreDao(ICoreRequest coreRequest)
{
_coreRequest = coreRequest;
}
}
}
@@ -0,0 +1,38 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Branches;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public class BranchDao : BaseCoreDao, IBranchDao
{
private readonly CoreConfiguration _coreConfiguration;
private readonly CoreApiConfiguration _coreApiConfiguration;
public BranchDao(ICoreRequest coreRequest,
CoreConfiguration coreConfiguration)
: base(coreRequest)
{
_coreConfiguration = coreConfiguration;
_coreApiConfiguration = _coreConfiguration.CoreApiConfiguration;
}
/// <summary>
/// Calls Core API to get all branches.
/// Default Included: Graph
/// </summary>
/// <returns>IEnumerable<Branch></returns>
public async Task<IEnumerable<Branch>> FindBranches(CoreRequestParameters coreRequestParameters)
{
var endpointParameters = HttpUtilities.BuildDictionaryOfNonNullValues(coreRequestParameters);
var result = await _coreRequest.GetRequestObject<CoreApiMessage<IEnumerable<Branch>>>(
_coreApiConfiguration.CoreEndPointConfiguration.Branches,
endpointParameters);
return result?.MessageBody;
}
}
}
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.AccessChannelPersons;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public interface IAccessChannelPersonsDao
{
Task<AccessChannelPerson> UpdateAccessChannelPerson(CoreApiMessage<AccessChannelPerson> request);
Task<CoreApiMessage<IEnumerable<AccessChannelPerson>>> FindAccessChannelPersonsByPerson(CoreRequestParameters coreRequestParameters,
AccessChannelPersonsByPersonRequest request);
}
}
@@ -0,0 +1,12 @@
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.AccessChannelPersons;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.AccessTypes;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public interface IAccessTypeDao
{
Task<AccessType> UpdateAccessType(CoreApiMessage<AccessType> request, string accessChannelPersonId);
}
}
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using CoreRequest = LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Accounts;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Collaterals;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreResponses;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreSoapResponses;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public interface IAccountDao
{
Task<IEnumerable<Account>> FindByMemberAgreeNbr(CoreRequestParameters coreRequestParameters, MemberAgreeNbrRequest request);
Task<Account> FindByAcctNbr(CoreRequestParameters coreRequestParameters, AcctNbrRequest request);
Task<IEnumerable<Collateral>> FindCollateralById(CoreRequestParameters coreRequestParameters, string accountId);
Task PutAccountMaintenanceRequest(IEnumerable<CoreRequest.AccountMaintenanceRequest> accountMaintenanceRequests);
Task<List<ActivityAccountDetails>> GetActivityAccountDetailsByAccountNumbers(List<string> accountNumbers);
Task<IEnumerable<string>> FindAdminBranchCodeChangeAccountNumbers();
Task<IEnumerable<string>> FindVipSavingsToFund();
Task<IEnumerable<string>> FindAccountsToUpdateAccountAnalysis();
Task<BasicResponse> UpdateAccountAnalysis(AccountAnalysisGroupMaintenanceRequest accountAnalysisGroupMaintenanceRequest);
Task<BasicResponse> UpdateAccountBranch(AccountBranchUpdateRequest accountBranchUpdateRequest);
Task<BasicResponse> UpdateAccountLoanToValue(AccountLtvUpdateRequest accountLtvUpdateRequest);
Task<BasicResponse> UpdateAccountNickName(AccountNickNameUpdateRequest accountNickNameUpdateRequest);
Task<BasicResponse> UpdateAccountContractDate(AccountContractDateUpdateRequest accountContractDateUpdateRequest);
Task<IEnumerable<AccountOwnership>> FindOwnersByAccountNumber(long accountNumber, DateTime createdDate);
Task<IEnumerable<AccountOwnership>> FindPrimaryOwnersByOrganizationName(string organizationName);
Task<IEnumerable<AccountOwnership>> FindPrimaryOwnersByPersonName(string personName);
Task<CreatedAccountResponse> AddPersonAccount(CreatePersonAccountRequest createPersonAccountRequest);
Task<CreatedAccountResponse> AddOrganizationAccount(CreateOrganizationAccountRequest createOrganizationAccountRequest);
Task<BasicResponse> PutOrganizationMaintenanceRequest(OrganizationMaintenanceRequest organziationMaintenanceRequest);
Task<BasicResponse> UpdateAccountCreditReportType(AccountCreditReportTypeUpdateRequest accountCreditReportTypeUpdateRequest);
Task<IEnumerable<AccountsByMajorMinorBranchAndStatusResponse>> GetAccountsByMajorMinorBranchAndStatus(AccountsByMajorMinorBranchAndStatusRequest request);
Task<IEnumerable<AccountsByRecentTransactionsResponse>> GetAccountsByRecentTransactions(AccountsByRecentTransactionsRequest request);
}
}
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public interface IAccountHistoryDao
{
Task<IEnumerable<DateTime>> GetChargeoffDateTimesByAccountNumber(string accountNumber);
}
}
@@ -0,0 +1,18 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Accounts;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public interface IAccountUserFieldDao
{
Task<AccountUserField> UpdateAccountUserField(CoreApiMessage<AccountUserFieldRequest> accountUserFieldUpdateRequest,
string accountId,
string userFieldId);
Task<AccountUserField> InsertAccountUserField(CoreApiMessage<AccountUserFieldRequest> accountUserFieldUpdateRequest,
string accountId);
Task<CoreApiMessage<IEnumerable<AccountUserField>>> FindAccountUserFieldCoreApiResponseByAccountId(CoreRequestParameters coreRequestParameters, string accountId);
}
}
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Activity;
using LCU.Library.Internal.CoreApiWrapperModel.LcuModels.Activity;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public interface IActivityDao
{
Task<IReadOnlyCollection<NewCheckingAccountActivity>> GetNewCheckingActivitiesNewerThanDate(DateTime newerThanDateTime, int limitAmount);
Task<IReadOnlyCollection<NewCheckingAccountActivity>> GetNewCheckingActivitiesAfterActivityNbr(long afterActivityNumber, int limitAmount);
Task<IReadOnlyCollection<NewCheckingAccountActivity>> GetNewCheckingActivities(DateTime newerThanDateTime, long afterActivityNumber, int limitAmount);
Task<IReadOnlyCollection<NewCheckingAccountActivity>> GetNewDigitalBankingCheckingActivitiesNewerThanDate(DateTime newerThanDateTime, int limitAmount);
Task<IReadOnlyCollection<NewCheckingAccountActivity>> GetNewDigitalBankingCheckingActivitiesAfterActivityNbr(long afterActivityNumber, int limitAmount);
Task<IReadOnlyCollection<NewCheckingAccountActivity>> GetNewDigitalBankingCheckingActivities(DateTime newerThanDateTime, long afterActivityNumber, int limitAmount);
Task<IReadOnlyCollection<NewAtmCheckCardActivity>> GetNewAtmCheckCardActivitiesNewerThanDate(DateTime newerThanDateTime, int limitAmount);
Task<IReadOnlyCollection<NewAtmCheckCardActivity>> GetNewAtmCheckCardActivitiesAfterActivityNbr(long afterActivityNumber, int limitAmount);
Task<IReadOnlyCollection<NewAtmCheckCardActivity>> GetNewAtmCheckCardActivities(DateTime newerThanDateTime, long afterActivityNumber, int limitAmount);
Task<IReadOnlyCollection<NewActivityManagerIncentiveReferral>> GetNewActivityManagerReferralsNewerThan(DateTime newerThanOriginationDateTime);
Task<IReadOnlyCollection<NewActivityManagerIncentiveReferral>> GetNewActivityManagerReferralsAfterActivityId(long afterActivityId);
Task<IReadOnlyCollection<NewActivityManagerIncentiveReferral>> GetNewActivityManagerReferrals(DateTime newerThanOriginationDateTime, long afterActivityId);
Task<IReadOnlyCollection<NewLoanSaleActivity>> GetNewMortgageSaleActivities(DateTime? newerThanDateTime, long? afterActivityNumber);
Task<IReadOnlyCollection<NewLoanSaleActivity>> GetNewVehicleSaleActivities(DateTime? newerThanDateTime, long? afterActivityNumber);
Task<IReadOnlyCollection<NewLoanSaleActivity>> GetNewDebtProtectedLoanSaleActivities(DateTime? newerThanDateTime, long? afterActivityNumber);
Task<IReadOnlyCollection<NewActivityManagerIncentiveReferral>> QueryActivityManagerActivity(ActivityQueryRequest request);
Task<IReadOnlyCollection<EStatementDeliveryMethod>> GetEStatementDeliveryActivity(DateTime? newerThanDateTime);
Task<IReadOnlyCollection<PersonRecentActivity>> GetPersonActivityByPhoneNumber(string phoneNumber);
Task<PersonRecentActivity> GetPersonActivityByPersonNumber(string personNumber);
}
}
@@ -0,0 +1,19 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.PostalAddresses;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public interface IAddressDao
{
Task<CoreApiMessage<PersonPostalAddress>> FindByPersonNumberAddressNumber(CoreRequestParameters coreRequestParameters,
string personId,
string postalAddressId);
Task<CoreApiMessage<IReadOnlyCollection<PersonPostalAddress>>> FindByPersonNumber(CoreRequestParameters coreRequestParameters,
string personNumber);
Task<PersonPostalAddress> InsertPersonPostalAddress(PersonPostalAddress request);
Task<string> RemovePersonPostalAddress(CoreApiMessage<PersonPostalAddress> request);
Task<PersonAddrLine> UpdatePersonAddrLine(CoreApiMessage<PersonAddrLine> request);
}
}
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Agreements;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.MemberAgreements;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public interface IAgreeDao
{
Task<IEnumerable<AgreeUserAccount>> FindAgreeUsersByAccountNumbers(List<string> accountNumbers);
Task<IEnumerable<string>> FindAgreeUserByPersonNumber(long personNumber);
Task<string> FindAgreeUserByOrganizationNumber(long organizationNumber);
Task<Agreement> FindAgreementByUserId(string userId);
Task<Agreement> FindAgreementByAgreementId(long agreementId);
Task<IEnumerable<Agreement>> FindAgreementsByAccountId(long accountNumber);
Task<IEnumerable<AgreementAccount>> FindAgreementAccountsByUserId(string userId);
Task<IEnumerable<AgreementAccount>> FindAgreementAccountsByOrganizationId(long organizationId);
Task<AgreementAccount> FindAgreementAccountByAccountId(long accountId);
Task<IEnumerable<AgreementAccountOwner>> FindAgreementOwnerByAccountNumbers(IEnumerable<long> accountNumber);
Task<AgreementAccountOwner> FindAgreementOwnerByAccountNumber(long accountNumber);
Task<IEnumerable<long>> AuditAccountDeliveryMethodAndOwnerChangesByDateLastMaintained(DateTime maintenanceDate);
Task<IEnumerable<long>> AuditAccountAgreementChangesByDateLastMaintained(DateTime maintenanceDate);
Task<IEnumerable<long>> AuditAccountOrganizationChangesByDateLastMaintained(DateTime maintenanceDate);
}
}
@@ -0,0 +1,18 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreSoapRequests;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreResponses;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.MemberAgreements;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public interface IAgreePersonDao
{
Task<AgreePerson> FindByUserId(string userId);
Task<IEnumerable<AgreePerson>> FindAgreePersons(int fetchAmount);
Task<IEnumerable<AgreePerson>> FindAgreePersonsWithHyphenatedUserId();
Task<IEnumerable<string>> FindActiveCustodialAgreePersonNumbers();
Task<IEnumerable<AgreePerson>> FindActiveCustodialVruCardAgreementAgreePersons();
Task<BasicResponse> UpdatePersonAgreementDetailTypes(PersonAgreementDetailTypeRequest personAgreeementDetailTypeRequest);
}
}
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.ApplicationHistories;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public interface IApplicationHistoryDao
{
Task<IEnumerable<ApplicationHistory>> FindApplicationHistory(List<string> applicationNumbers,
DateTime effectiveDate);
Task<IEnumerable<QueueApplicationParameter>> FindApplicationHistoryParameters(List<string> applicationNumbers,
DateTime effectiveDate);
}
}
@@ -0,0 +1,11 @@
using System;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Associate;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public interface IAssociateDao
{
Task<AssociateDetails> GetAssociateDetailsBySsn(string taxId);
}
}
@@ -0,0 +1,12 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Branches;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public interface IBranchDao
{
Task<IEnumerable<Branch>> FindBranches(CoreRequestParameters coreRequestParameters);
}
}
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.IndirectLoan;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public interface IIndirectLoanDao
{
Task<IEnumerable<IndirectLoanDetail>> FindByAccountNumber(long accountNumber);
Task<IEnumerable<IndirectLoanDetail>> FindByPostedDate(DateTime newerThanDateTime);
Task<IEnumerable<ClosedIndirectLoan>> FindClosedByPostedDate(DateTime newerThanDateTime);
Task<IEnumerable<IndirectLoanDetail>> FindClosedWithDetailByPostedDate(DateTime newerThanDateTime);
Task<IEnumerable<UpdateDealerOriginalBalanceResponse>> UpdateDealerOriginalBalance(string accountNumber);
}
}
@@ -0,0 +1,17 @@
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Organizations;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public interface IOrganizationDao
{
Task<Organization> FindOrganizationByMemberAgreeNbr(CoreRequestParameters coreRequestParameters, MemberNbrRequest organizationRequest);
Task<IEnumerable<Organization>> FindByOrganizationsSearch(CoreRequestParameters coreRequestParameters, OrganizationSearchRequest searchRequest);
Task<long> CountOrganizationNumbersByName(string name);
Task<IEnumerable<long>> FindOrganizationNumbersByNameSearch(string name, int limit);
}
}
@@ -0,0 +1,17 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Persons;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public interface IPersonDao
{
Task<IEnumerable<Person>> FindByPersonsName(CoreRequestParameters coreRequestParameters, PersonNameRequest personRequest);
Task<IEnumerable<Person>> FindByPersonsSearch(CoreRequestParameters coreRequestParameters, PersonSearchRequest personRequest);
Task<Person> FindByPersonMemberAgreementNbr(CoreRequestParameters coreRequestParameters, MemberNbrRequest personRequest);
Task<IEnumerable<long>> GetPersonNumbersByNameLike(string firstName, string middleName, string lastName, int limit);
Task<long> CountPersonsByNameLike(string firstName, string middleName, string lastName);
}
}
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Persons;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public interface IPersonUserFieldDao
{
Task<PersonUserField> InsertPersonUserField(CoreApiMessage<PersonUserFieldRequest> personUserFieldRequest,
int personId);
Task<PersonUserField> UpdatePersonUserField(CoreApiMessage<PersonUserFieldRequest> personUserFieldUpdateRequest,
int personId,
string userFieldId);
Task<CoreApiMessage<IEnumerable<PersonUserField>>> FindPersonUserFieldCoreApiResponseByPersonId(CoreRequestParameters coreRequestParameters, int personId);
Task<IEnumerable<PersonCheckHoldsUserField>> FindPersonsForAtmCheckHolds(DateTime? resetStartDate, DateTime? resetEndDate);
}
}
@@ -0,0 +1,10 @@
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Properties;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public interface IPropertyDao
{
Task<Property> FindProperty(long propertynumber);
}
}
@@ -0,0 +1,16 @@
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Properties;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreResponses;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public interface IPropertyUserFieldDao
{
Task<BasicResponse> InsertPropertyUserField(UserFieldRequest request);
Task<BasicResponse> UpdatePropertyUserField(UserFieldRequest request);
Task<CoreApiMessage<IEnumerable<PropertyUserField>>> FindPropertyUserFieldCoreApiResponseByPersonId(CoreRequestParameters coreRequestParameters, int propertyId);
}
}
@@ -0,0 +1,12 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Saf;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public interface ISafDao
{
public Task<IEnumerable<SafUser>> GetAllSafUsersCoreInfo();
}
}
@@ -0,0 +1,24 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Tax;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public interface ITaxDao
{
/// <summary>
/// Calls Core API and provides a peron's taxId to get taxIdData against.
/// </summary>
/// <param name="coreRequestParameters"></param>
/// <param name="taxId"></param>
Task<IEnumerable<PersonTaxIdDataResponse>> GetPersonTaxIdData(CoreRequestParameters coreRequestParameters, string taxId);
/// <summary>
/// Calls Core API and provides an organization's taxId to get taxIdData against.
/// </summary>
/// <param name="coreRequestParameters"></param>
/// <param name="taxId"></param>
Task<IEnumerable<OrganizationTaxIdDataResponse>> GetOrganizationTaxIdData(CoreRequestParameters coreRequestParameters, string taxId);
}
}
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreResponses;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Transaction;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public interface ITransactionDao
{
Task<IEnumerable<TransactionHistory>> FindTransactionHistoryById(CoreRequestParameters coreRequestParameters,
TransactionHistoryRequest request,
string accountId);
Task<List<MonetaryTransactionResponse>> AddMonetaryTransactions(List<GroupedMonetaryTransactionRequest> requests);
Task<IEnumerable<ExternalDescription>> FindExternalDescriptionsWithSsn();
void UpdateExternalDescription(ExternalDescription externalTransactionDescription);
Task<List<BasicResponse>> PostFundsToAccount(List<FundsToAccountRequest> requests);
Task<IEnumerable<TransactionAlertInfo>> GetTransactionsByDateSpan(DateTime startDateRange, DateTime endDateRange, string rtxnTypCdToExcludeParams, string rtxnTypCdToExcludeVerify);
}
}
@@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Library.Internal.ApiSecurity.Enums;
using LCU.Library.Internal.ApiSecurity.Models;
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.IndirectLoan;
using LCU.Library.Internal.LcuHttpClient.HttpRequest;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public class IndirectLoanDao : IIndirectLoanDao
{
private readonly ICoreDbExecution _coreDbExecution;
private readonly CoreSoapApiConfiguration _coreSoapApiConfiguration;
private readonly ApiSecurityConfiguration _apiSecurityConfiguration;
private readonly IPutRequest _putRequest;
private const string SoapClientKeyValue = "CoreSoapApiWrapper";
private const string indirectLoanByAcctNbrQuery = "IndirectLoan/IndirectLoan_ByAcctNbr_Query";
private const string indirectLoanByPostedDateQuery = "IndirectLoan/IndirectLoan_ByPostedDate_Query";
private const string closedIndirectLoanByPostedDateQuery = "IndirectLoan/ClosedIndirectLoan_ByPostedDate_Query";
private const string closedIndirectLoanWithDetailByPostedDateQuery = "IndirectLoan/ClosedIndirectLoanWithDetail_ByPostedDate_Query";
private const string DnaTimeFormat = "yyyy-MM-dd HH:mm:ss";
public IndirectLoanDao(ICoreDbExecution coreDbExecution,
CoreConfiguration coreConfiguration,
ApiSecurityConfiguration apiSecurityConfiguration,
IPutRequest putRequest)
{
_coreSoapApiConfiguration = coreConfiguration.CoreSoapApiConfiguration;
_coreDbExecution = coreDbExecution;
_apiSecurityConfiguration = apiSecurityConfiguration;
_putRequest = putRequest;
}
/// <summary>
/// Searches for indirect loans based on account number using SQL query.
/// Default Included: Graph
/// </summary>
/// <param name="accountNumber"></param>
/// <returns>IEnumerable<IndirectLoanDetail></returns>
public async Task<IEnumerable<IndirectLoanDetail>> FindByAccountNumber(long accountNumber)
{
var query = QueryUtilities.GetQuery(indirectLoanByAcctNbrQuery);
var accountNumberParam = new { AcctNbr = accountNumber };
var results = await _coreDbExecution.ExecuteQuery<IndirectLoanDetail, object>(query, accountNumberParam);
return results;
}
/// <summary>
/// Searches for indirect loans with posted date greater than the parameter using SQL query.
/// Default Included: Graph
/// </summary>
/// <param name="newerThanDateTime"></param>
/// <returns>IEnumerable<IndirectLoanDetail></returns>
public async Task<IEnumerable<IndirectLoanDetail>> FindByPostedDate(DateTime newerThanDateTime)
{
var query = QueryUtilities.GetQuery(indirectLoanByPostedDateQuery);
var newerThanDateTimeParam = new { newerThanDateTime = newerThanDateTime.ToString(DnaTimeFormat) };
var results = await _coreDbExecution.ExecuteQuery<IndirectLoanDetail, object>(query, newerThanDateTimeParam);
return results;
}
/// <summary>
/// Searches for closed indirect loans with closed date greater than the parameter using SQL query.
/// Default Included: Graph
/// </summary>
/// <param name="newerThanDateTime"></param>
/// <returns>IEnumerable<IndirectLoanDetail></returns>
public async Task<IEnumerable<ClosedIndirectLoan>> FindClosedByPostedDate(DateTime newerThanDateTime)
{
var query = QueryUtilities.GetQuery(closedIndirectLoanByPostedDateQuery);
var newerThanDateTimeParam = new { newerThanDateTime = newerThanDateTime.ToString(DnaTimeFormat) };
var results = await _coreDbExecution.ExecuteQuery<ClosedIndirectLoan, object>(query, newerThanDateTimeParam);
return results;
}
/// <summary>
/// Searches for closed indirect loans with detail with closed date greater than the parameter using SQL query.
/// Default Included: Graph
/// </summary>
/// <param name="newerThanDateTime"></param>
/// <returns>IEnumerable<IndirectLoanDetail></returns>
public async Task<IEnumerable<IndirectLoanDetail>> FindClosedWithDetailByPostedDate(DateTime newerThanDateTime)
{
var query = QueryUtilities.GetQuery(closedIndirectLoanWithDetailByPostedDateQuery);
var newerThanDateTimeParam = new { newerThanDateTime = newerThanDateTime.ToString(DnaTimeFormat) };
var results = await _coreDbExecution.ExecuteQuery<IndirectLoanDetail, object>(query, newerThanDateTimeParam);
return results;
}
public async Task<IEnumerable<UpdateDealerOriginalBalanceResponse>> UpdateDealerOriginalBalance(string accountNumber)
{
var endpoint = HttpUtilities.BuildHttpsUri(_coreSoapApiConfiguration.CoreSoapApiWrapperHost, _coreSoapApiConfiguration.CoreSoapEndpointConfiguration.PutDealerOriginalBalance + $"?accountNumber={accountNumber}");
var headers = LcuHttpClient.Utilities.HttpUtilities.GetApiKeyHeaders(SoapClientKeyValue, _apiSecurityConfiguration.ExtractApiKey(SoapClientKeyValue, ApiKeySetName.InternalKeySet));
return await _putRequest.Async<string, List<UpdateDealerOriginalBalanceResponse>>(endpoint, null, headers, 0);
}
}
}
@@ -0,0 +1,12 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperModel.LcuModels.LoanPayoff;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public interface ILoanPayoffDao
{
Task<List<LoanPayoff>> GetLoanPayoffByAccountNumber(long accountNumber, string dateRange);
Task<List<LoanPayoff>> GetLoanPayoffByVIN(string VIN, string dateRange);
}
}
@@ -0,0 +1,48 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
using LCU.Library.Internal.CoreApiWrapperModel.LcuModels.LoanPayoff;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public class LoanPayoffDao : BaseCoreDao, ILoanPayoffDao
{
private readonly ICoreDbExecution _coreDbExecution;
public LoanPayoffDao(ICoreRequest coreRequest, CoreConfiguration coreConfiguration, ICoreDbExecution coreDbExecution) : base(coreRequest)
{
_coreDbExecution = coreDbExecution;
}
public async Task<List<LoanPayoff>> GetLoanPayoffByAccountNumber(long accountNumber, string dateRange)
{
var query = QueryUtilities.GetQuery("LoanPayoff/LoanPayoffByAccountNumberQuery");
var accountActivityParams = new
{
dateRange = dateRange,
accountNumber = accountNumber
};
var results =
await _coreDbExecution.ExecuteQuery<LoanPayoff, object>(query, accountActivityParams);
return results.ToList();
}
public async Task<List<LoanPayoff>> GetLoanPayoffByVIN(string VIN, string dateRange)
{
var query = QueryUtilities.GetQuery("LoanPayoff/LoanPayoffByVINQuery");
var accountActivityParams = new
{
dateRange = dateRange,
VIN = VIN
};
var results =
await _coreDbExecution.ExecuteQuery<LoanPayoff, object>(query, accountActivityParams);
return results.ToList();
}
}
}
@@ -0,0 +1,90 @@
using System.Collections.Generic;
using System.Linq;
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Organizations;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public class OrganizationDao : BaseCoreDao, IOrganizationDao
{
private const string OrganizationByNameLikeCount = "Organization/OrganizationByNameLikeCount";
private const string OrganizationNumberByNameLikeQuery = "Organization/OrganizationNumberByNameLikeQuery";
private readonly CoreApiConfiguration _coreApiConfiguration;
private readonly ICoreDbExecution _coreDb;
public OrganizationDao
(
ICoreRequest coreRequest,
CoreConfiguration coreConfiguration,
ICoreDbExecution coreDbExecution
)
: base(coreRequest)
{
_coreApiConfiguration = coreConfiguration.CoreApiConfiguration;
_coreDb = coreDbExecution;
}
/// <summary>
/// Calls Core API to search based on any field in the OrganizationSearchRequest properties.
/// </summary>
/// <param name="coreRequestParameters"></param>
/// <param name="searchRequest"></param>
/// <returns>IEnumerable<Organization></returns>
public async Task<IEnumerable<Organization>> FindByOrganizationsSearch(CoreRequestParameters coreRequestParameters, OrganizationSearchRequest searchRequest)
{
var endpointParameters = HttpUtilities.BuildDictionaryOfNonNullValues(coreRequestParameters);
var jsonBody = HttpUtilities.BuildJsonOfNonNullProperties(searchRequest);
var result = await _coreRequest.PostRequestObject<CoreApiMessage<IEnumerable<Organization>>>(_coreApiConfiguration.CoreEndPointConfiguration.OrganizationQuerySearch,
endpointParameters,
jsonBody);
return result?.MessageBody;
}
/// <summary>
/// Calls Core API to search based on MemberAgreementNbrRequest property.
/// Default Included: Graph
/// </summary>
/// <param name="coreRequestParameters"></param>
/// <param name="memberAgreeNbrRequest"></param>
/// <returns>Organization</returns>
public async Task<Organization> FindOrganizationByMemberAgreeNbr(CoreRequestParameters coreRequestParameters, MemberNbrRequest organizationRequest)
{
var endpointParameters = HttpUtilities.BuildDictionaryOfNonNullValues(coreRequestParameters);
var jsonBody = HttpUtilities.BuildJsonOfNonNullProperties(organizationRequest);
var result = await _coreRequest.PostRequestObject<CoreApiMessage<Organization>>(
_coreApiConfiguration.CoreEndPointConfiguration.OrganizationsQueryMemberAgreementNbr,
endpointParameters,
jsonBody);
return result?.MessageBody;
}
public async Task<long> CountOrganizationNumbersByName(string name)
{
var query = QueryUtilities.GetQuery(OrganizationByNameLikeCount);
var queryParameters = new {
organizationName = name.ToLowerInvariant()
};
return (await _coreDb.ExecuteQuery<long, dynamic>(query, queryParameters)).Single();
}
public async Task<IEnumerable<long>> FindOrganizationNumbersByNameSearch(string name, int limit)
{
var query = QueryUtilities.GetQuery(OrganizationNumberByNameLikeQuery);
var queryParameters = new {
organizationName = name.ToLowerInvariant(),
limit
};
return await _coreDb.ExecuteQuery<long, dynamic>(query, queryParameters);
}
}
}
@@ -0,0 +1,111 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Persons;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public class PersonDao : BaseCoreDao, IPersonDao
{
private const string PersonByNameLikeCount = "Person/PersonByNameLikeCount";
private const string PersonNumberByNameLikeQuery = "Person/PersonNumberByNameLikeQuery";
private readonly ICoreDbExecution _coreDbExecution;
private readonly CoreConfiguration _coreConfiguration;
private readonly CoreApiConfiguration _coreApiConfiguration;
public PersonDao(ICoreRequest coreRequest,
ICoreDbExecution coreDbExecution,
CoreConfiguration coreConfiguration)
: base(coreRequest)
{
_coreConfiguration = coreConfiguration;
_coreApiConfiguration = _coreConfiguration.CoreApiConfiguration;
_coreDbExecution = coreDbExecution;
}
/// <summary>
/// Calls Core API to search based on any or any number of the PersonNameRequest properties.
/// Default Included: Graph
/// </summary>
/// <param name="coreRequestParameters"></param>
/// <param name="personRequest"></param>
/// <returns>IEnumerable<Person></returns>
public async Task<IEnumerable<Person>> FindByPersonsName(CoreRequestParameters coreRequestParameters, PersonNameRequest personRequest)
{
var endpointParameters = HttpUtilities.BuildDictionaryOfNonNullValues(coreRequestParameters);
var jsonBody = HttpUtilities.BuildJsonOfNonNullProperties(personRequest);
var result = await _coreRequest.PostRequestObject<CoreApiMessage<IEnumerable<Person>>>(
_coreApiConfiguration.CoreEndPointConfiguration.PersonsQueryName,
endpointParameters,
jsonBody);
return result?.MessageBody;
}
/// <summary>
/// Calls Core API to search based on any or any number of the PersonSearchRequest properties.
/// Default Included: EmailAddresses, OrgRelationships, PersonInfo, PersonPhonesCard, PostalAddresses
/// </summary>
/// <param name="coreRequestParameters"></param>
/// <param name="personRequest"></param>
/// <returns>IEnumerable<Person></returns>
public async Task<IEnumerable<Person>> FindByPersonsSearch(CoreRequestParameters coreRequestParameters, PersonSearchRequest personRequest)
{
var endpointParameters = HttpUtilities.BuildDictionaryOfNonNullValues(coreRequestParameters);
var jsonBody = HttpUtilities.BuildJsonOfNonNullProperties(personRequest);
var result = await _coreRequest.PostRequestObject<CoreApiMessage<IEnumerable<Person>>>(_coreApiConfiguration.CoreEndPointConfiguration.PersonsQuerySearch,
endpointParameters,
jsonBody);
return result?.MessageBody;
}
/// <summary>
/// Calls Core API to search based on MemberAgreementNbrRequest property.
/// Default Included: Graph
/// </summary>
/// <param name="coreRequestParameters"></param>
/// <param name="personRequest"></param>
/// <returns>Person</returns>
public async Task<Person> FindByPersonMemberAgreementNbr(CoreRequestParameters coreRequestParameters, MemberNbrRequest personRequest)
{
var endpointParameters = HttpUtilities.BuildDictionaryOfNonNullValues(coreRequestParameters);
var jsonBody = HttpUtilities.BuildJsonOfNonNullProperties(personRequest);
var result = await _coreRequest.PostRequestObject<CoreApiMessage<Person>>(
_coreApiConfiguration.CoreEndPointConfiguration.PersonsQueryMemberAgreementNbr,
endpointParameters,
jsonBody);
return result?.MessageBody;
}
public async Task<IEnumerable<long>> GetPersonNumbersByNameLike(string firstName, string middleName, string lastName, int limit)
{
var query = QueryUtilities.GetQuery(PersonNumberByNameLikeQuery);
var queryParameters = new {
firstName = firstName?.ToLowerInvariant(),
middleName = middleName?.ToLowerInvariant(),
lastName = lastName?.ToLowerInvariant(),
limit
};
return await _coreDbExecution.ExecuteQuery<long, dynamic>(query, queryParameters);
}
public async Task<long> CountPersonsByNameLike(string firstName, string middleName, string lastName)
{
var query = QueryUtilities.GetQuery(PersonByNameLikeCount);
var queryParameters = new {
firstName = firstName?.ToLowerInvariant(),
middleName = middleName?.ToLowerInvariant(),
lastName = lastName?.ToLowerInvariant()
};
return (await _coreDbExecution.ExecuteQuery<long, dynamic>(query, queryParameters)).Single();
}
}
}
@@ -0,0 +1,78 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using System;
using Newtonsoft.Json;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
using LCU.Library.Internal.CoreApiWrapperModel.Constants;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Persons;
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public class PersonUserFieldDao : BaseCoreDao, IPersonUserFieldDao
{
private readonly ICoreDbExecution _coreDbExecution;
private readonly CoreConfiguration _coreConfiguration;
private readonly CoreApiConfiguration _coreApiConfiguration;
private const string GetPersonsForCheckHoldsUpdate = "Person/GetPersonsForCheckHoldsUpdate";
private const string DnaTimeFormat = "MM-dd-yyyy HH:mm:ss";
public PersonUserFieldDao(ICoreRequest coreRequest, CoreConfiguration coreConfiguration, ICoreDbExecution coreDbExecution) : base(coreRequest)
{
_coreConfiguration = coreConfiguration;
_coreApiConfiguration = _coreConfiguration.CoreApiConfiguration;
_coreDbExecution = coreDbExecution;
}
public async Task<PersonUserField> UpdatePersonUserField(CoreApiMessage<PersonUserFieldRequest> personUserFieldUpdateRequest,
int personId,
string userFieldId)
{
var strPersonId = JsonConvert.ToString(personId);
var endpoint = HttpUtilities.ReplaceRootParameter(_coreApiConfiguration.CoreEndPointConfiguration.PutPersonUserField,
RequestRootParameters.PersonId,
strPersonId);
endpoint = HttpUtilities.ReplaceRootParameter(endpoint, RequestRootParameters.UserFieldId, userFieldId);
var jsonBody = JsonConvert.SerializeObject(personUserFieldUpdateRequest);
var result = await _coreRequest.PutRequestObject<CoreApiMessage<PersonUserField>>(endpoint, null, jsonBody);
return result?.MessageBody;
}
public async Task<PersonUserField> InsertPersonUserField(CoreApiMessage<PersonUserFieldRequest> personUserFieldRequest,
int personId)
{
var strPersonId = JsonConvert.ToString(personId);
var endpoint = HttpUtilities.ReplaceRootParameter(_coreApiConfiguration.CoreEndPointConfiguration.PersonUserFields,
RequestRootParameters.PersonId,
strPersonId);
var jsonBody = JsonConvert.SerializeObject(personUserFieldRequest);
var result = await _coreRequest.PostRequestObject<CoreApiMessage<PersonUserField>>(endpoint, null, jsonBody);
return result?.MessageBody;
}
public async Task<CoreApiMessage<IEnumerable<PersonUserField>>> FindPersonUserFieldCoreApiResponseByPersonId(CoreRequestParameters coreRequestParameters, int personId)
{
var endpointParameters = HttpUtilities.BuildDictionaryOfNonNullValues(coreRequestParameters);
var endpoint = HttpUtilities.ReplaceRootParameter(_coreApiConfiguration.CoreEndPointConfiguration.PersonUserFields,
RequestRootParameters.PersonId,
JsonConvert.ToString(personId));
return await _coreRequest.GetRequestObject<CoreApiMessage<IEnumerable<PersonUserField>>>(endpoint, endpointParameters);
}
public async Task<IEnumerable<PersonCheckHoldsUserField>> FindPersonsForAtmCheckHolds(DateTime? resetStartDate, DateTime? resetEndDate)
{
var query = QueryUtilities.GetQuery(GetPersonsForCheckHoldsUpdate);
var personUserFieldDateParams = new
{
ResetStartDate = resetStartDate?.ToString(DnaTimeFormat), //to indicate the start and end date to reset user field values
ResetEndDate = resetEndDate?.ToString(DnaTimeFormat)
};
return await _coreDbExecution.ExecuteQuery<PersonCheckHoldsUserField, object>(query, personUserFieldDateParams);
}
}
}
@@ -0,0 +1,38 @@
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
using LCU.Library.Internal.CoreApiWrapperModel.Constants;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Properties;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public class PropertyDao : BaseCoreDao, IPropertyDao
{
private readonly CoreConfiguration _coreConfiguration;
private readonly CoreApiConfiguration _coreApiConfiguration;
public PropertyDao(ICoreRequest coreRequest,
CoreConfiguration coreConfiguration)
: base(coreRequest)
{
_coreConfiguration = coreConfiguration;
_coreApiConfiguration = _coreConfiguration.CoreApiConfiguration;
}
/// <summary>
/// Calls Core API to get all property by propertynumber.
/// Default Included: Graph, Standard
/// </summary>
/// <returns>Property</returns>
public async Task<Property> FindProperty(long propertynumber)
{
var endpoint = HttpUtilities.ReplaceRootParameter(_coreApiConfiguration.CoreEndPointConfiguration.PropertyById,
RequestRootParameters.PropertyNumber,
propertynumber.ToString());
var result = await _coreRequest.GetRequestObject<CoreApiMessage<Property>>(endpoint, null);
return result?.MessageBody;
}
}
}
@@ -0,0 +1,72 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Library.Internal.ApiSecurity.Enums;
using LCU.Library.Internal.ApiSecurity.Models;
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperModel.Constants;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreResponses;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Properties;
using LCU.Library.Internal.LcuHttpClient.HttpRequest;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public class PropertyUserFieldDao : BaseCoreDao, IPropertyUserFieldDao
{
private readonly CoreConfiguration _coreConfiguration;
private readonly CoreApiConfiguration _coreApiConfiguration;
private readonly CoreSoapApiConfiguration _coreSoapApiConfiguration;
private readonly ApiSecurityConfiguration _apiSecurityConfiguration;
private readonly IPostRequest _postRequest;
private readonly IPutRequest _putRequest;
private const string SoapClientKeyValue = "CoreSoapApiWrapper";
public PropertyUserFieldDao(ICoreRequest coreRequest,
CoreConfiguration coreConfiguration,
ApiSecurityConfiguration apiSecurityConfiguration,
IPostRequest postRequest,
IPutRequest putRequest) : base(coreRequest)
{
_coreConfiguration = coreConfiguration;
_apiSecurityConfiguration = apiSecurityConfiguration;
_coreApiConfiguration = _coreConfiguration.CoreApiConfiguration;
_coreSoapApiConfiguration = _coreConfiguration.CoreSoapApiConfiguration;
_postRequest = postRequest;
_putRequest = putRequest;
}
public async Task<CoreApiMessage<IEnumerable<PropertyUserField>>> FindPropertyUserFieldCoreApiResponseByPersonId(CoreRequestParameters coreRequestParameters, int propertyId)
{
var endpointParameters = HttpUtilities.BuildDictionaryOfNonNullValues(coreRequestParameters);
var endpoint = HttpUtilities.ReplaceRootParameter(_coreApiConfiguration.CoreEndPointConfiguration.PropertyUserFields,
RequestRootParameters.PropertyNumber,
JsonConvert.ToString(propertyId));
return await _coreRequest.GetRequestObject<CoreApiMessage<IEnumerable<PropertyUserField>>>(endpoint, endpointParameters);
}
/// <summary>
/// Calls Core Soap API post to create a new user field.
/// </summary>
/// <param name="UserFieldRequest"></param>
public async Task<BasicResponse> InsertPropertyUserField(UserFieldRequest userFieldRequest)
{
var endpoint = HttpUtilities.BuildHttpsUri(_coreSoapApiConfiguration.CoreSoapApiWrapperHost, _coreSoapApiConfiguration.CoreSoapEndpointConfiguration.PostPropertyUserField);
var headers = LcuHttpClient.Utilities.HttpUtilities.GetApiKeyHeaders(SoapClientKeyValue, _apiSecurityConfiguration.ExtractApiKey(SoapClientKeyValue, ApiKeySetName.InternalKeySet));
return await _postRequest.Async<UserFieldRequest, BasicResponse>(endpoint, userFieldRequest, headers, 0);
}
public async Task<BasicResponse> UpdatePropertyUserField(UserFieldRequest request)
{
var endpoint = HttpUtilities.BuildHttpsUri(_coreSoapApiConfiguration.CoreSoapApiWrapperHost, _coreSoapApiConfiguration.CoreSoapEndpointConfiguration.PutPropertyUserField);
var headers = LcuHttpClient.Utilities.HttpUtilities.GetApiKeyHeaders(SoapClientKeyValue, _apiSecurityConfiguration.ExtractApiKey(SoapClientKeyValue, ApiKeySetName.InternalKeySet));
return await _putRequest.Async<UserFieldRequest, BasicResponse>(endpoint, request, headers, 0);
}
}
}
@@ -0,0 +1,25 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Saf;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public class SafDao : ISafDao
{
private readonly ICoreDbExecution _coreDbExecution;
private const string GetAllSafUserInfoQuery = "Saf/GetAllSafUserInfo";
public SafDao(ICoreDbExecution coreDbExecution)
{
_coreDbExecution = coreDbExecution;
}
public async Task<IEnumerable<SafUser>> GetAllSafUsersCoreInfo()
{
var query = QueryUtilities.GetQuery(GetAllSafUserInfoQuery);
return await _coreDbExecution.ExecuteQuery<SafUser>(query);
}
}
}
@@ -0,0 +1,42 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Tax;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public class TaxDao : BaseCoreDao, ITaxDao
{
private readonly CoreApiConfiguration _coreApiConfiguration;
public TaxDao(ICoreRequest coreRequest, CoreConfiguration coreConfiguration) : base(coreRequest)
{
_coreApiConfiguration = coreConfiguration.CoreApiConfiguration;
}
public async Task<IEnumerable<PersonTaxIdDataResponse>> GetPersonTaxIdData(CoreRequestParameters coreRequestParameters, string taxId)
{
var endpointParameters = HttpUtilities.BuildDictionaryOfNonNullValues(coreRequestParameters);
var endpoint = _coreApiConfiguration.CoreEndPointConfiguration.GetPersonsDataByTaxId;
var request = HttpUtilities.BuildJsonOfNonNullProperties(new TaxIdRequest { TaxId = taxId });
var response = await _coreRequest.PostRequestObject<CoreApiMessage<IEnumerable<PersonTaxIdDataResponse>>>(endpoint, endpointParameters, request);
return response?.MessageBody;
}
public async Task<IEnumerable<OrganizationTaxIdDataResponse>> GetOrganizationTaxIdData(CoreRequestParameters coreRequestParameters, string taxId)
{
var endpointParameters = HttpUtilities.BuildDictionaryOfNonNullValues(coreRequestParameters);
var endpoint = _coreApiConfiguration.CoreEndPointConfiguration.GetOrganizationsDataByTaxId;
var request = HttpUtilities.BuildJsonOfNonNullProperties(new TaxIdRequest { TaxId = taxId });
var response = await _coreRequest.PostRequestObject<CoreApiMessage<IEnumerable<OrganizationTaxIdDataResponse>>>(endpoint, endpointParameters, request);
return response?.MessageBody;
}
}
}
@@ -0,0 +1,125 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Library.Internal.ApiSecurity.Enums;
using LCU.Library.Internal.ApiSecurity.Models;
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
using LCU.Library.Internal.CoreApiWrapperModel.Constants;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreResponses;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Transaction;
using LCU.Library.Internal.LcuHttpClient.HttpRequest;
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
{
public class TransactionDao : BaseCoreDao, ITransactionDao
{
private readonly CoreApiConfiguration _coreApiConfiguration;
private readonly CoreSoapApiConfiguration _coreSoapApiConfiguration;
private readonly ApiSecurityConfiguration _apiSecurityConfiguration;
private readonly ICoreDbExecution _coreDbExecution;
private readonly IPostRequest _postRequest;
private const string SoapClientKeyValue = "CoreSoapApiWrapper";
private const string GetExternalDescriptionsWithSSNQuery = "Transaction/GetExternalDescriptionsWithSSNQuery";
private const string UpdateExternalDescriptionQuery = "Transaction/UpdateExternalDescriptionQuery";
private const string GetTransactionsByDateSpanQuery = "Transaction/GetTransactionsByDateSpanQuery";
private const string RtxnTypCdQueryVerifyHolder = "{RtxnTypCdQueryVerifyHolder}";
private const string RtxnTypCdQueryParamHolder = "{RtxnTypCdQueryParamHolder}";
public TransactionDao(ICoreRequest coreRequest,
CoreConfiguration coreConfiguration,
ApiSecurityConfiguration apiSecurityConfiguration,
ICoreDbExecution coreDbExecution,
IPostRequest postRequest) : base(coreRequest)
{
_coreApiConfiguration = coreConfiguration.CoreApiConfiguration;
_coreSoapApiConfiguration = coreConfiguration.CoreSoapApiConfiguration;
_apiSecurityConfiguration = apiSecurityConfiguration;
_coreDbExecution = coreDbExecution;
_postRequest = postRequest;
}
/// <summary>
/// Calls Core API to search based the AccountId and filled out TransactionHistoryRequest model.
/// Default Included: Standard, Graph
/// </summary>
/// <param name="coreRequestParameters"></param>
/// <param name="request"></param>
/// <param name="accountId"></param>
/// <returns>IEnumerable<TransactionHistory></returns>
public async Task<IEnumerable<TransactionHistory>> FindTransactionHistoryById(CoreRequestParameters coreRequestParameters,
TransactionHistoryRequest request,
string accountId)
{
var endpointParameters = HttpUtilities.BuildDictionaryOfNonNullValues(coreRequestParameters);
var endpoint = HttpUtilities.ReplaceRootParameter(_coreApiConfiguration.CoreEndPointConfiguration.AccountsTransactionHistoryQueryAccountNumber,
RequestRootParameters.AccountId,
accountId);
var jsonBody = HttpUtilities.BuildJsonOfNonNullProperties(request);
var result = await _coreRequest.PostRequestObject<CoreApiMessage<IEnumerable<TransactionHistory>>>(
endpoint, endpointParameters, jsonBody);
return result?.MessageBody;
}
public async Task<List<MonetaryTransactionResponse>> AddMonetaryTransactions(List<GroupedMonetaryTransactionRequest> monetaryTransactionRequests)
{
var endpoint = HttpUtilities.BuildHttpsUri(_coreSoapApiConfiguration.CoreSoapApiWrapperHost, _coreSoapApiConfiguration.CoreSoapEndpointConfiguration.PostMonetaryTransactions);
var headers = LcuHttpClient.Utilities.HttpUtilities.GetApiKeyHeaders(SoapClientKeyValue, _apiSecurityConfiguration.ExtractApiKey(SoapClientKeyValue, ApiKeySetName.InternalKeySet));
return await _postRequest.Async<List<GroupedMonetaryTransactionRequest>, List<MonetaryTransactionResponse>>(endpoint, monetaryTransactionRequests, headers, 0);
}
public async Task<IEnumerable<ExternalDescription>> FindExternalDescriptionsWithSsn()
{
var query = QueryUtilities.GetQuery(GetExternalDescriptionsWithSSNQuery);
return await _coreDbExecution.ExecuteQuery<ExternalDescription>(query);
}
public async Task<List<BasicResponse>> PostFundsToAccount(List<FundsToAccountRequest> fundsToAccount)
{
var endpoint = HttpUtilities.BuildHttpsUri(_coreSoapApiConfiguration.CoreSoapApiWrapperHost, _coreSoapApiConfiguration.CoreSoapEndpointConfiguration.PostFundsToAccount);
var headers = LcuHttpClient.Utilities.HttpUtilities.GetApiKeyHeaders(SoapClientKeyValue, _apiSecurityConfiguration.ExtractApiKey(SoapClientKeyValue, ApiKeySetName.InternalKeySet));
return await _postRequest.Async<List<FundsToAccountRequest>, List<BasicResponse>>(endpoint, fundsToAccount, headers, 0);
}
/// <summary>
/// Note: ExecuteQuery does not return anything when running an Update statement.
/// </summary>
/// <param name="externalTransactionDescription"></param>
public void UpdateExternalDescription(ExternalDescription externalTransactionDescription)
{
var query = QueryUtilities.GetQuery(UpdateExternalDescriptionQuery);
var param = new
{
externaldescriptionnumber = externalTransactionDescription.ExternalDescriptionNumber,
externaldescriptiontext = externalTransactionDescription.ExternalDescriptionText
};
var result = _coreDbExecution.ExecuteQuery<string, object>(query, param).Result;
}
public async Task<IEnumerable<TransactionAlertInfo>> GetTransactionsByDateSpan(DateTime startDateRange,
DateTime endDateRange,
string rtxnTypCdToExcludeParams,
string rtxnTypCdToExcludeVerify)
{
var query = QueryUtilities.GetQuery(GetTransactionsByDateSpanQuery);
var alteredQuery = query.Replace(RtxnTypCdQueryVerifyHolder, rtxnTypCdToExcludeVerify)//;
.Replace(RtxnTypCdQueryParamHolder, rtxnTypCdToExcludeParams);
var param = new
{
startDateTime = startDateRange.ToString("yyyy-MM-dd HH:mm:ss"),
endDateTime = endDateRange.ToString("yyyy-MM-dd HH:mm:ss")
};
return await _coreDbExecution.ExecuteQuery<TransactionAlertInfo, object>(alteredQuery, param);
}
}
}
@@ -0,0 +1,11 @@
using System;
namespace LCU.Library.Internal.CoreApiWrapperLib.Exceptions
{
public class AccountMaintenanceRequestException : Exception
{
public AccountMaintenanceRequestException(string message) : base(message)
{
}
}
}
@@ -0,0 +1,11 @@
using System;
namespace LCU.Library.Internal.CoreApiWrapperLib.Exceptions
{
public class FailedToParseException : Exception
{
public FailedToParseException(string message) : base(message)
{
}
}
}
@@ -0,0 +1,11 @@
using System;
namespace LCU.Library.Internal.CoreApiWrapperLib.Exceptions
{
public class UnauthorizedRequestException : Exception
{
public UnauthorizedRequestException(string message) : base(message)
{
}
}
}
@@ -0,0 +1,359 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Version>4.1.9</Version>
<Description>
1.0.0 - Initial Setup
1.1.0 - Added Configurations models and ConnectionModels related to core rather than being pulled from CoreApiWrapperModels prj.
1.1.1 - Added Indirect loan controller methods for exporting information
1.1.2 - Added IndirectLoanController method for getting closed loans
1.1.3 - Creation of the ApplicationHistoryDao, ApplHhistoryQuery, and addition of QueryUtitilies to help add generic list of params to query.
1.1.4 - Update to IndirectLoanDetail model
1.1.5 - Update to InidrectLoanDetail model
1.1.6 - Add SafUser Model
1.1.7 - Added method to FindApplicationHistoryParameters by application numbers and date range.
1.1.8 - Added AgreeDao and AgreeuserByAccountsQuery
1.1.9 - Update Activity Queries, Add Activity Manager Query
1.1.10 - Update Checking Activity Query
1.2.0 - Added AccountUserField get and update methods
1.2.1 - Added AgreementByUserId to controller and subsequent service,dao, and query
1.3.0 - Add New Mortgage Actvity query
1.4.0 - Creation of CoreSoapConfiguration models and CoreSoapApiRequest class.
1.5.0 - Add New Vehicle Activity Query, Update Mortgage Query
2.0.0 - Refactor model namespaces
2.0.1 - Moved transaction dao methods from AccountDao to TransactionDao class.
2.0.2 - Update Referral Activity Query and Model. Add Account Info, fix PersNbr parsing.
2.1.0 - ApplciationHistory and ApplicationHistoryRequest change to use effectivedate.
2.1.1 - Update Checking Query. Filter on Minor Account Type, Rely on Sub Activity Data Less.
2.1.2 - Add Minor Account Type to results
2.1.3 - Update Mortgage Referral Types for Activity Manager Query
2.1.4 - Update Loan Queries to Contain Debt Protection Information
2.1.5 - Add new Endpoint for DP Elligible loans. Update Loan Queries to Contain DP Eligibility Information.
2.1.6 - Update Loan Originating Person Field Name
2.1.7 - Adding query to search accounts by orgNbr, audit activity for agreement and organization changes, and determine agreements by agreementId
2.1.8 - Update AgreeuserByAccountsQuery to fix how to get UserIds by account.
2.1.9 - Updating query to search accounts by orgNbr and removing types that don't have delivery method codes
2.2.0 - Add new Endpoint to get Updated Activity Account Details
2.2.1 - Update Activity Query include Org Role Requirements and Add Basic LIC Referral
2.2.2 - Updating account and agree audit endpoints to get account fields when removed from agreement. Adding additional active='y' check to owner query
2.3.0 - Add OrgNbr to Card Activity Query, Make persnbr and orgnbr strings
2.3.1 - Update DPELoan Activity Query Minor Account Types
2.4.0 - Update Email Type for Activities
2.5.0 - Add Member Name and Balance to Activity Query and Models
2.6.0 - Removal of AccountUserFields in Account methods and Added AccountUserField classes
2.7.0 - Update Agreement Queries and Endpoints - breaking change (not backwards compatible)
3.0.0 - Allow Null/Unkown Originators in Loan Activity Queries
3.1.0 - Changes to Address methods to handle per person.
3.1.1 - Update Activity Manager Query to Return Email Correctly
3.2.0 - New AccessChannel classes, added AgreePerson folder and query, and New AgreePersonDao method
3.3.0 - New AgreePerson query and new Dao for AccessType
3.4.0 - New AgreePerson query, FindActiveCustodialVruCardAgreementAgreePersons, and UpdatePersonAgreementDetailTypes
3.4.1 - Update Activity queries/models to include contact info metadata
3.5.0 - Add OrganizationByMemberAgreeNbr endpoint and OrganizationDao
3.5.1 - Creating AgreeUserByOrganizationNumberQuery and AgreeUserByPersonNumberQuery
3.6.0 - Update ActivityAccountDetail query to include Debt Protection info
3.7.0 - Add new Transaction methods/queries to get Transaction's Exterenal Descriptions with SSN and to update Transaction's External Descriptions
3.8.0 - Return card activities in batches with default of 100
3.9.0 - Add new Account Branch queries to get Admin/MembSvc branch accounts, update to Digital Banking branch code
3.9.1 - Add new Vip Savings query to get approved new accounts, add Funds to Account
3.9.2 - Add query to grab all owners by accountNumber
3.9.3 - Add queries to grab all owners by organizationName or personName
3.9.4 - Add endpoint to soap configuration for AccountLtvUpdateRequest
3.9.5 - Update queries for grabbing accounts by account number, person name, or organization name
3.9.6 - Update query for grabbing accounts by account number to include role (this creates multiple records per person/organization)
3.9.7 - Update Org and Pers name queries to handle '/', as well as change endpoint names to reflect grabbing only primary owners
3.9.8 - Update Org and Pers name queries regex_replace to better handle diacritics
3.9.9 - Update Org and Pers name queries collation for ligatures
4.0.0 - Add new Account Analysis Group query to get accounts without a group, update account with Analysis Group
4.0.1 - Update AgreeUserByOrganizationNumberQuery to use FetchLimit 1 instead of RowNum
4.0.2 - Add Person User Field queries for data cleanup
4.0.3 - Update AgreeUserByPersonNumberQuery to not use RowNum
4.0.4 - Update AgreeUserByPersonNumberQuery to return list of UserIDs
4.0.5 - Add Person/Org accounts and OrgMaintenance
4.0.6 - Add endpoint to soap configuration for AccountNickNameUpdate request
4.1.0 - Add Update AddressLine logic
4.1.1 - Add query for New Checking Activities for Digital Banking
4.1.2 - Add endpoint to soap configuration for AccountCreditReportTypeUpdateRequest
4.1.3 - Add query to get AssociateDetails by TaxId
4.1.4 - Add queries for LoanPayoff
4.1.5 - Add queries for PersonRecentActivity by PhoneNumber or TaxId
4.1.6 - Add queries and Dao for GetAccountsByRecentTransactions
4.1.7 - Add queries and Dao for GetTransactionsByDateSpan
4.1.8 - Add query and Dao for GetChargeoffDateTimes
4.1.9 - Update GetTransactionsByDateSpan query to all for exclusion of RtxnTypCd
4.2.0 - Updating target framework to net8.0
</Description>
<PackageReleaseNotes>
1.0.0 - Initial Setup
1.1.0 Added Configurations models and ConnectionModels related to core rather than being pulled from CoreApiWrapperModels prj.
1.1.1 Added Indirect loan controller methods for exporting information
1.1.2 Added IndirectLoanController method for getting closed loans
1.1.3 - Creation of the ApplicationHistoryDao, ApplHhistoryQuery, and addition of QueryUtitilies to help add generic list of params to query.
1.1.4 - Update to InidrectLoanDetail model
1.1.5 - Update to InidrectLoanDetail model
1.1.6 - Add SafUser Model
1.1.7 - Added method to FindApplicationHistoryParameters by application numbers and date range.
1.1.8 - Added AgreeDao and AgreeuserByAccountsQuery
1.1.9 - Update Activity Queries, Add Activity Manager Query
1.1.10 - Update Checking Activity Query
1.2.0 - Added AccountUserField get and update methods
1.2.1 - Added AgreementByUserId to controller and subsequent service,dao, and query
1.3.0 - Add New Mortgage Actvity query
1.4.0 - Creation of CoreSoapConfiguration models and CoreSoapApiRequest class.
1.5.0 - Add New Vehicle Activity Query, Update Mortgage Query
2.0.0 - Refactor model namespaces
2.0.1 - Moved transaction dao methods from AccountDao to TransactionDao class.
2.0.2 - Update Referral Activity Query and Model. Add Account Info, fix PersNbr parsing.
2.1.0 - ApplciationHistory and ApplicationHistoryRequest change to use effectivedate.
2.1.1 - Update Checking Query. Filter on Minor Account Type, Rely on Sub Activity Data Less.
2.1.2 - Add Minor Account Type to results
2.1.3 - Update Mortgage Referral Types for Activity Manager Query
2.1.4 - Update Loan Queries to Contain Debt Protection Information
2.1.5 - Add new Endpoint for DP Elligible loans. Update Loan Queries to Contain DP Eligibility Information.
2.1.6 - Update Loan Originating Person Field Name
2.1.7 - Adding query to search accounts by orgNbr, audit activity for agreement and organization changes, and determine agreements by agreementId
2.1.8 - Update AgreeuserByAccountsQuery to fix how to get UserIds by account.
2.1.9 - Updating query to search accounts by orgNbr and removing types that don't have delivery method codes
2.2.0 - Add new Endpoint to get Updated Activity Account Details
2.2.1 - Update Activity Query include Org Role Requirements and Add Basic LIC Referral
2.2.2 - Updating account and agree audit endpoints to get account fields when removed from agreement. Adding additional active='y' check to owner query
2.3.0 - Add OrgNbr to Card Activity Query, Make persnbr and orgnbr strings
2.3.1 - Update DPELoanActivity Query Minor Account Types
2.3.2 - Update Email Type for Activities
2.4.0 - Add Acitivty Manager Incentive Activity Query and Endpoint
2.5.0 - Add Member Name and Balance to Activity Query and Models
2.6.0 - Removal of AccountUserFields methods in Account classes and Added AccountUserField classes
2.7.0 - Update Agreement Queries and Endpoints - breaking change (not backwards compatible)
3.0.0 - Allow Null/Unkown Originators in Loan Activity Queries
3.1.0 - Changes to Address methods to handle per person.
3.1.1 - Update Activity Manager Query to Return Email Correctly
3.2.0 - New AccessChannel classes, added AgreePerson folder and query, and New AgreePersonDao method
3.3.0 - New AgreePerson query and new Dao for AccessType
3.4.0 - New AgreePerson query, FindActiveCustodialVruCardAgreementAgreePersons, and UpdatePersonAgreementDetailTypes
3.4.1 - Update Activity queries/models to include contact info metadata
3.5.0 - Add OrganizationByMemberAgreeNbr endpoint and OrganizationDao
3.5.1 - Creating AgreeUserByOrganizationNumberQuery and AgreeUserByPersonNumberQuery
3.6.0 - Update ActivityAccountDetail query to include Debt Protection info
3.7.0 - Add new Transaction methods/queries to get Transaction's Exterenal Descriptions with SSN and to update Transaction's External Descriptions
3.8.0 - Return card activities in batches with default of 100
3.9.1 - Add new Vip Savings query to get approved new accounts, add Funds to Account
3.9.2 - Add query to grab all owners by accountNumber
3.9.3 - Add queries to grab all owners by organizationName or personName
3.9.4 - Add endpoint to soap configuration for AccountLtvUpdateRequest
3.9.5 - Update queries for grabbing accounts by account number, person name, or organization name
3.9.6 - Update query for grabbing accounts by account number to include role (this creates multiple records per person/organization)
3.9.7 - Update Org and Pers name queries to handle '/', as well as change endpoint names to reflect grabbing only primary owners
3.9.8 - Update Org and Pers name queries regex_replace to better handle diacritics
3.9.9 - Update Org and Pers name queries collation for ligatures
4.0.0 - Add new Account Analysis Group query to get accounts without a group, update account with Analysis Group
4.0.1 - Update AgreeUserByOrganizationNumberQuery to use FetchLimit 1 instead of RowNum
4.0.2 - Add Person User Field queries for data cleanup
4.0.3 - Update AgreeUserByPersonNumberQuery to not use RowNum
4.0.4 - Update AgreeUserByPersonNumberQuery to return list of UserIDs
4.0.5 - Add Person/Org accounts and OrgMaintenance
4.0.6 - Add endpoint to soap configuration for AccountNickNameUpdate request
4.1.0 - Add Update AddressLine logic
4.1.1 - Add query for New Checking Activities for Digital Banking
4.1.2 - Add endpoint to soap configuration for AccountCreditReportTypeUpdateRequest
4.1.3 - Add query to get AssociateDetails by TaxId
4.1.4 - Add queries for LoanPayoff
4.1.5 - Add queries for PersonRecentActivity by PhoneNumber or TaxId
4.1.6 - Add queries and Dao for GetAccountsByRecentTransactions
4.1.7 - Add queries and Dao for GetTransactionsByDateSpan
4.1.8 - Add query and Dao for GetChargeoffDateTimes
4.1.9 - Update GetTransactionsByDateSpan query to all for exclusion of RtxnTypCd
4.2.0 - Updating target framework to net8.0
</PackageReleaseNotes>
<PackageVersion>4.1.6</PackageVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\LCU.Library.Internal.CoreApiWrapperModel\LCU.Library.Internal.CoreApiWrapperModel.csproj" />
<PackageReference Include="Dapper" Version="2.0.151" />
<PackageReference Include="Dapper.Contrib" Version="2.0.78" />
<PackageReference Include="LCU.Library.Internal.ApiSecurity" Version="2.0.0" />
<PackageReference Include="LCU.Library.Internal.LcuHttpClient" Version="2.0.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="Oracle.EntityFrameworkCore" Version="5.21.90" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.110" />
<PackageReference Include="Serilog" Version="3.0.1" />
</ItemGroup>
<ItemGroup>
<None Update="Queries\AccountHistory\GetChargeOffDateTimes.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Account\GetAccountOwnersByOrganizationName.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Account\GetAccountOwnersByPersonName.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Account\GetAccountsByMajorMinorBranchCodeAndStatus.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Account\GetAccountsByRecentTransactions.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Account\GetAccountsToUpdateGroupAnalysis.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Activity\NewCheckingAccountSalesDigitalBanking.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Activity\QueryEStatementDeliveryMethod.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\AgreePerson\GetActiveCustodialVruCardAgreementAgreePersons.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\AgreePerson\GetActiveCustodialAgreePersonNumbers.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\AgreePerson\AgreePersonsWithHyphenatedUserIdQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\LoanPayoff\LoanPayoffByAccountNumberQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\LoanPayoff\LoanPayoffByVINQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Person\GetPersonsForCheckHoldsUpdate.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Transaction\UpdateExternalDescriptionQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Transaction\GetExternalDescriptionsWithSSNQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\AgreeUserByAccountsQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\QueApplParamQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\IndirectLoan\ClosedIndirectLoanWithDetail_ByPostedDate_Query.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\IndirectLoan\ClosedIndirectLoan_ByPostedDate_Query.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\ApplHistoryQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\AgreePerson\GetAgreePersonsQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\AgreePerson\AgreePersonByUserIdQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\IndirectLoan\IndirectLoan_ByPostedDate_Query.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\IndirectLoan\IndirectLoan_ByAcctNbr_Query.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Activity\NewCheckingAccountSales.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Activity\NewAtmCheckCardSales.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Saf\GetAllSafUserInfo.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Agreement\AgreementsByAccountIdQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Agreement\AccountsByAgreementUserIdQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Agreement\AgreementOwnerByAccountsQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Agreement\Audit\AuditActiveSubActiveForAccountChangesQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Agreement\Audit\AuditActiveSubActiveForAgreementChangesQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Agreement\Audit\AuditActiveSubActiveForOrganizationChangesQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Activity\NewActivityManagerIncentiveReferralQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Agreement\AgreementByUserIdQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Activity\NewMortgageAccountSales.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Activity\NewVehicleAccountSales.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Activity\NewDebtProtectedLoanSales.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Agreement\AccountByAccountIdQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Agreement\AccountsByOrganizationIdQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\ActivityAccountDetailsByAccountNbr.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Activity\QueryActivityManagerActivityDetail.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Agreement\AgreementByAgreementIdQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\AgreeUserByPersonNumberQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\AgreeUserByOrganizationNumberQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\AccountBranch\GetAccountAdminBranchUpdateQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Account\GetVipSavingsToFundQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Account\GetAccountOwnersByAccountNumber.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Organization\OrganizationNumberByNameLikeQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Organization\OrganizationByNameLikeCount.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Person\PersonByNameLikeCount.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Person\PersonNumberByNameLikeQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Associate\GetAssociateDetailsBySsnQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Activity\GetPersonActivityByPhoneNumberQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Activity\GetPersonActivityByPersonNumberQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Queries\Transaction\GetTransactionsByDateSpanQuery.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Queries\AccountHistory\" />
</ItemGroup>
</Project>
@@ -0,0 +1,31 @@
SELECT DISTINCT
a.TAXRPTFORPERSNBR AS PersonNumber,
a.TAXRPTFORORGNBR AS ByOrgNbr,
a.TAXRPTFORPERSNBR AS TaxReportForPersonNumber,
a.TAXRPTFORORGNBR AS TaxReportForOrgNumber,
o.ORGNAME AS OrganizationName,
p.FIRSTNAME,
p.MDLINIT AS MiddleInitial,
p.MDLNAME AS MiddleName,
p.LASTNAME,
p.SUFFIX,
'' AS Role,
CASE WHEN (p.PERSNBR = a.TAXRPTFORPERSNBR OR o.ORGNBR = a.TAXRPTFORORGNBR) THEN (1) ELSE (0) END AS IsPrimaryOwner
FROM osibank.ACCT a
LEFT OUTER JOIN OSIBANK.PERS p ON a.TAXRPTFORPERSNBR = p.PERSNBR
LEFT OUTER JOIN OSIBANK.ORG o ON a.TAXRPTFORORGNBR = o.ORGNBR
WHERE a.ACCTNBR = :accountNumber
UNION
(SELECT DISTINCT a2.PERSNBR, NULL, NULL, NULL, NULL, p.FIRSTNAME, p.MDLINIT, p.MDLNAME, p.LASTNAME, p.SUFFIX, a2.ACCTROLECD, 0
FROM OSIBANK.ACCTACCTROLEPERS a2
LEFT OUTER JOIN OSIBANK.PERS p ON a2.PERSNBR = p.PERSNBR
WHERE a2.ACCTROLECD IN ( 'SIGN', 'OWN', 'CUST', 'GUAD', 'PREP', 'REPP', 'VAFI', 'TRUT', 'TRUS')
AND a2.ACCTNBR = :accountNumber
AND a2.EFFDATE <= TO_DATE(:createdDate, 'YYYY-MM-DD HH24:MI:SS') AND a2.EFFDATE IS NOT NULL)
UNION
(SELECT DISTINCT NULL, a3.ORGNBR, NULL, NULL, o.ORGNAME, NULL, NULL, NULL, NULL, NULL, a3.ACCTROLECD, 0
FROM OSIBANK.ACCTACCTROLEORG a3
LEFT OUTER JOIN OSIBANK.ORG o ON a3.ORGNBR = o.ORGNBR
WHERE a3.ACCTROLECD IN ( 'SIGN', 'OWN', 'CUST', 'GUAD', 'PREP', 'REPP', 'VAFI', 'TRUT', 'TRUS')
AND a3.ACCTNBR = :accountNumber
AND a3.EFFDATE <= TO_DATE(:createdDate, 'YYYY-MM-DD HH24:MI:SS') AND a3.EFFDATE IS NOT NULL)
@@ -0,0 +1,19 @@
SELECT DISTINCT
a.TAXRPTFORPERSNBR AS PersonNumber,
a.TAXRPTFORORGNBR AS ByOrgNbr,
a.TAXRPTFORPERSNBR AS TaxReportForPersonNumber,
a.TAXRPTFORORGNBR AS TaxReportForOrgNumber,
o.ORGNAME AS OrganizationName,
p.FIRSTNAME,
p.MDLINIT AS MiddleInitial,
p.MDLNAME AS MiddleName,
p.LASTNAME,
p.SUFFIX,
CASE WHEN (p.PERSNBR = a.TAXRPTFORPERSNBR OR o.ORGNBR = a.TAXRPTFORORGNBR) THEN (1) ELSE (0) END AS IsPrimaryOwner
FROM osibank.ACCT a
LEFT OUTER JOIN OSIBANK.PERS p ON a.TAXRPTFORPERSNBR = p.PERSNBR
LEFT OUTER JOIN OSIBANK.ORG o ON a.TAXRPTFORORGNBR = o.ORGNBR
WHERE NLSSORT(TRIM(REPLACE(REPLACE(REPLACE(REGEXP_REPLACE(REPLACE(o.ORGNAME, '%2F', '/'), '[^[:alnum:] ]', ''), ' ', '<>'), '><', ''), '<>', ' ')), 'NLS_SORT = UCA0700_DUCET_AI')
LIKE NLSSORT(TRIM(REPLACE(REPLACE(REPLACE(REGEXP_REPLACE(REPLACE(:organizationName, '%2F', '/'), '[^[:alnum:] ]', ''), ' ', '<>'), '><', ''), '<>', ' ')), 'NLS_SORT = UCA0700_DUCET_AI')
OFFSET 0 ROWS
FETCH FIRST 5 ROWS ONLY
@@ -0,0 +1,19 @@
SELECT DISTINCT
a.TAXRPTFORPERSNBR AS PersonNumber,
a.TAXRPTFORORGNBR AS ByOrgNbr,
a.TAXRPTFORPERSNBR AS TaxReportForPersonNumber,
a.TAXRPTFORORGNBR AS TaxReportForOrgNumber,
o.ORGNAME AS OrganizationName,
p.FIRSTNAME,
p.MDLINIT AS MiddleInitial,
p.MDLNAME AS MiddleName,
p.LASTNAME,
p.SUFFIX,
CASE WHEN (p.PERSNBR = a.TAXRPTFORPERSNBR OR o.ORGNBR = a.TAXRPTFORORGNBR) THEN (1) ELSE (0) END AS IsPrimaryOwner
FROM osibank.ACCT a
LEFT OUTER JOIN OSIBANK.PERS p ON a.TAXRPTFORPERSNBR = p.PERSNBR
LEFT OUTER JOIN OSIBANK.ORG o ON a.TAXRPTFORORGNBR = o.ORGNBR
WHERE NLSSORT(TRIM(REPLACE(REPLACE(REPLACE(REGEXP_REPLACE(REPLACE(NVL(p.FIRSTNAME,'') || NVL(' ' || p.MDLINIT,'') || NVL(' ' || p.LASTNAME,'') || NVL(' ' || p.SUFFIX,''), '%2F', '/'), '[^[:alnum:] ]', ''), ' ', '<>'), '><', ''), '<>', ' ')), 'NLS_SORT = UCA0700_DUCET_AI')
LIKE NLSSORT(TRIM(REPLACE(REPLACE(REPLACE(REGEXP_REPLACE(REPLACE(:personName, '%2F', '/'), '[^[:alnum:] ]', ''), ' ', '<>'), '><', ''), '<>', ' ')), 'NLS_SORT = UCA0700_DUCET_AI')
OFFSET 0 ROWS
FETCH FIRST 5 ROWS ONLY
@@ -0,0 +1,14 @@
select
ac.branchorgnbr as branchcode,
ac.acctnbr as accountnumber,
CASE
when (ac.taxrptforpersnbr is not null) then (concat(concat(pe.FirstNameUpper, ' '), pe.LastNameUpper))
else (og.orgname)
end as Name
from acct ac
left join pers pe on ac.taxrptforpersnbr = pe.persnbr
left join org og on og.orgnbr = ac.taxrptfororgnbr
Where AC.MJACCTTYPCD IN :majorAccountTypes
and AC.CURRMIACCTTYPCD IN :minorAccountTypes
and AC.CURRACCTSTATCD IN :accountStatusCodes
and AC.Branchorgnbr IN :branchOrgCodes
@@ -0,0 +1,5 @@
SELECT
ACCTNBR, DATELASTMAINT
FROM Acct
WHERE DATELASTMAINT >= TO_TIMESTAMP(:startDate, 'yyyy-mm-dd HH24:mi:ss')
AND DATELASTMAINT < TO_TIMESTAMP(:endDate, 'yyyy-mm-dd HH24:mi:ss')
@@ -0,0 +1,9 @@
Select AC.ACCTNBR as AccountNumber
FROM ACCT AC
LEFT JOIN ACCTGRPACCT AGA ON AGA.ACCTNBR= AC.ACCTNBR
LEFT JOIN ACCTGRP AG ON AG.ACCTGRPNBR = AGA.ACCTGRPNBR
Where
AC.MJACCTTYPCD = 'CK'
And AC.CURRMIACCTTYPCD IN ('BC01','BC10','BC11','BC20','MMC1','MMC5','MMC9','BMM1','MMM1')
And AC.CURRACCTSTATCD = 'ACT'
And AG.ACCTGRPNBR is null
@@ -0,0 +1,9 @@
Select AC.ACCTNBR as AccountNumber from OSIBANK.ACCT AC
INNER JOIN PERS PE ON PE.PersNbr = AC.TAXRPTFORPERSNBR
INNER JOIN MEMBERAGREEMENT MA ON MA.PRIMARYPERSNBR = PE.PERSNBR
Where AC.MJACCTTYPCD = 'SAV'
and AC.CURRMIACCTTYPCD = 'SV01'
and AC.CURRACCTSTATCD = 'APPR'
and AC.Branchorgnbr = 1210
and MA.SHAREACCTNBR = AC.ACCTNBR
and NOT EXISTS (select null FROM ACCTACCTROLEPERS AR WHERE AR.ACCTNBR = AC.ACCTNBR And AR.ACCTROLECD = 'OEMP')
@@ -0,0 +1,17 @@
SELECT
AC.ACCTNBR
FROM
OSIBANK.ACCT AC
INNER JOIN OSIBANK.MJMIACCTTYP MI ON MI.MIACCTTYPCD = AC.CURRMIACCTTYPCD
INNER JOIN OSIBANK.PERS PE ON PE.PERSNBR = AC.TAXRPTFORPERSNBR
INNER JOIN OSIBANK.MEMBERAGREEMENT MA ON MA.PRIMARYPERSNBR = PE.PERSNBR
WHERE
(AC.BRANCHORGNBR = 1500 OR AC.BRANCHORGNBR = 1200)
AND AC.CURRACCTSTATCD IN ('ACT', 'DORM', 'IACT', 'NPFM')
AND AC.MJACCTTYPCD IN ('CK','SAV','TD','CML','CNS','MTG')
AND AC.ACCTNBR NOT IN('99993001','99994001','99997001','27507971401','99998001')
AND AC.CURRMIACCTTYPCD NOT IN ('GL','CK20','APCK','BAT','CASH','FLML','HSA','IRA',
'IRTH','ITRD','MO','PREC','CDFN','CDFC','CDFI','INVR','DLR','CHSA','CITA','CRTA',
'CLRA','CANZ','DEF1','LETR','DEF2','DEF3','SDFP','SDFS','SDFI','SVWV','PASS',
'SVRT','TDFR','TDFN','CDNR')
@@ -0,0 +1 @@
SELECT EFFDATETIME FROM OSIBANK.ACCTACCTSTATHIST WHERE ACCTNBR = :accountNumber and ACCTSTATCD = 'CO' ORDER BY EFFDATETIME desc
@@ -0,0 +1,110 @@
WITH PersonLookup AS
(
SELECT DISTINCT
MAX(n.PERSNBR) AS PERSNBR,
MAX(n.SHAREACCTNBR) AS SHAREACCTNBR,
MAX(n.MEMBERAGREENBR) AS MEMBERAGREENBR,
MAX(n.PRIORITY) AS PRIORITY
FROM (
SELECT a.TAXRPTFORPERSNBR AS PERSNBR, a.ACCTNBR AS SHAREACCTNBR, m.MEMBERAGREENBR, 0 AS PRIORITY
FROM ACCT a
LEFT OUTER JOIN MEMBERAGREEMENT m ON m.PRIMARYPERSNBR = a.TAXRPTFORPERSNBR
LEFT OUTER JOIN OSIBANK.ACCTACCTROLEPERS a1 ON a1.ACCTNBR = a.ACCTNBR AND a.TAXRPTFORPERSNBR <> a1.PERSNBR AND a1.ACCTROLECD = 'CUST'
WHERE a1.ACCTROLECD IS NULL
UNION
SELECT DISTINCT a.PERSNBR, a3.ACCTNBR AS SHAREACCTNBR, NULL AS MEMBERAGREENBR, 1 AS PRIORITY
FROM OSIBANK.ACCTACCTROLEPERS a
INNER JOIN OSIBANK.ACCTROLE a2 ON a.ACCTROLECD = a2.ACCTROLECD AND a2.TRANSACTYN = 'Y'
INNER JOIN ACCT a3 ON a.ACCTNBR IN (a3.ACCTNBR, a3.STMTACCTNBR)
LEFT OUTER JOIN MEMBERAGREEMENT e ON e.SHAREACCTNBR = a3.STMTACCTNBR
WHERE a.EFFDATE <= CURRENT_DATE
AND a.EFFDATE IS NOT NULL
) n
WHERE n.PERSNBR = :personNumber
GROUP BY (n.PERSNBR, n.SHAREACCTNBR, n.MEMBERAGREENBR)
ORDER BY (MAX(n.PRIORITY))
)
,Person AS
(
SELECT DISTINCT e.FIRSTNAME||COALESCE(nullif(' '||e.MDLINIT,' '), '')||' '||e.LASTNAME AS PERSONNAME, l.PERSNBR, l.MEMBERAGREENBR, l.SHAREACCTNBR
FROM OSIBANK.PERS e
INNER JOIN PersonLookup l ON l.PERSNBR=e.PERSNBR
)
,Phone_list AS
(
SELECT DISTINCT p.PERSNBR, p.AREACD||p.EXCHANGE||p.PHONENBR AS phone_number, p.PHONEUSECD AS phone_type, p.PHONESEQ,
ROW_NUMBER () OVER(PARTITION BY p.PERSNBR, p.PHONEUSECD ORDER BY PREFERREDYN DESC, p.PHONESEQ DESC) AS rn
FROM OSIBANK.PERSPHONE p
INNER JOIN PersonLookup l ON l.PERSNBR=p.PERSNBR
WHERE p.PHONEUSECD IN ('PER', 'CELL', 'BUS')
)
,phone_part AS
(
SELECT * FROM
(
SELECT PERSNBR, phone_type, phone_number
FROM Phone_list
WHERE rn=1
)
PIVOT
(
MAX(phone_number) FOR phone_type IN ('PER' AS Home_Phone, 'CELL' AS Cell_Phone, 'BUS' AS Business_Phone)
)
)
,SharedAcctTran AS
(
SELECT t.ACCTNBR, a.PERSNBR, t.RTXNTYPCD, t.ORIGPOSTDATE, t.TRANAMT, a.SHAREACCTNBR,
CASE WHEN t.RTXNTYPCD = 'WTH' THEN 'WTH'
WHEN t.RTXNTYPCD IN ('DEP', 'XDEP') THEN 'DEP' END AS TransType
FROM PersonLookup a
INNER JOIN OSIBANK.RTXN t ON t.ACCTNBR=a.SHAREACCTNBR AND t.RTXNTYPCD IN ('WTH','DEP','XDEP')
ORDER BY t.ORIGPOSTDATE DESC
FETCH FIRST 1000 ROWS ONLY
)
,SharedAcctTranOrder AS
(
SELECT ACCTNBR, PERSNBR, ORIGPOSTDATE, TRANAMT, RTXNTYPCD, TransType, SHAREACCTNBR,
ROW_NUMBER() OVER(PARTITION BY ACCTNBR, TransType ORDER BY ORIGPOSTDATE DESC) AS rn
FROM SharedAcctTran
)
,SharedAcctTran_Part AS
(
SELECT ACCTNBR, PERSNBR, TransType, SHAREACCTNBR,
CASE WHEN TransType='WTH' THEN ORIGPOSTDATE END AS Last_ShareAcct_Withdrawal_DateTime,
CASE WHEN TransType='DEP' THEN ORIGPOSTDATE END AS Last_Share_Deposit_Date,
CASE WHEN TransType='DEP' THEN TRANAMT END AS Last_Share_Deposit_Amount
FROM SharedAcctTranOrder
WHERE rn=1
)
,Autoloan_Part AS
(
SELECT DISTINCT MAX(l.PERSNBR) AS PERSNBR, MAX(pr.PROPDESC) AS PROPDESC
FROM OSIBANK.ACCT a
INNER JOIN PersonLookup l ON a.ACCTNBR = l.SHAREACCTNBR OR a.TAXRPTFORPERSNBR = l.PERSNBR
INNER JOIN OSIBANK.ACCTPROP AP ON AP.ACCTNBR=a.ACCTNBR
INNER JOIN OSIBANK.prop pr ON pr.propnbr=ap.PROPNBR
WHERE a.MJACCTTYPCD='CNS'
AND a.CURRMIACCTTYPCD IN ('DL01','DL02','DL03','DL04','DV01','DV02','DV03','DV04')
GROUP BY (l.PERSNBR)
ORDER BY a.CONTRACTDATE DESC
)
SELECT DISTINCT
MAX(p.PERSNBR) AS PersonNumber,
MAX(e.PERSONNAME) AS PERSONNAME,
MAX(e.MEMBERAGREENBR) AS MemberNumber,
MAX(p.Home_Phone) AS HomePhone,
MAX(p.Cell_Phone) AS CellPhone,
MAX(p.Business_Phone) AS BusinessPhone,
MAX(w.Last_ShareAcct_Withdrawal_DateTime) AS LastShareAcctWithdrawalTime,
MAX(d.Last_Share_Deposit_Date) AS LastShareDepositDate,
MAX(d.Last_Share_Deposit_Amount) AS LastShareDepositAmount,
MAX(l.PROPDESC) AS VehicleYearMakeModelVin,
MAX(puf.VALUE) AS PassPhrase
FROM phone_part p
LEFT JOIN Person e ON p.PERSNBR=e.PERSNBR
LEFT JOIN PERSUSERFIELD puf on p.PERSNBR=puf.PERSNBR AND puf.userfieldcd='PASS'
LEFT JOIN SharedAcctTran_Part w ON e.SHAREACCTNBR=w.SHAREACCTNBR AND w.TransType='WTH'
LEFT JOIN SharedAcctTran_Part d ON e.SHAREACCTNBR=d.SHAREACCTNBR AND d.TransType='DEP'
LEFT JOIN Autoloan_Part l ON p.PERSNBR=l.PERSNBR
GROUP BY (p.PERSNBR)
FETCH FIRST 2 ROWS ONLY
@@ -0,0 +1,115 @@
WITH PersonLookup AS
(
SELECT DISTINCT
MAX(n.PERSNBR) AS PERSNBR,
MAX(n.SHAREACCTNBR) AS SHAREACCTNBR,
MAX(n.MEMBERAGREENBR) AS MEMBERAGREENBR,
MAX(n.PRIORITY) AS PRIORITY
FROM (
SELECT a.TAXRPTFORPERSNBR AS PERSNBR, a.ACCTNBR AS SHAREACCTNBR, m.MEMBERAGREENBR, 0 AS PRIORITY
FROM ACCT a
LEFT OUTER JOIN MEMBERAGREEMENT m ON m.PRIMARYPERSNBR = a.TAXRPTFORPERSNBR
LEFT OUTER JOIN OSIBANK.ACCTACCTROLEPERS a1 ON a1.ACCTNBR = a.ACCTNBR AND a.TAXRPTFORPERSNBR <> a1.PERSNBR AND a1.ACCTROLECD = 'CUST'
WHERE a1.ACCTROLECD IS NULL
UNION
SELECT DISTINCT a.PERSNBR, a3.ACCTNBR AS SHAREACCTNBR, NULL AS MEMBERAGREENBR, 1 AS PRIORITY
FROM OSIBANK.ACCTACCTROLEPERS a
INNER JOIN OSIBANK.ACCTROLE a2 ON a.ACCTROLECD = a2.ACCTROLECD AND a2.TRANSACTYN = 'Y'
INNER JOIN ACCT a3 ON a.ACCTNBR IN (a3.ACCTNBR, a3.STMTACCTNBR)
LEFT OUTER JOIN MEMBERAGREEMENT e ON e.SHAREACCTNBR = a3.STMTACCTNBR
WHERE a.EFFDATE <= CURRENT_DATE
AND a.EFFDATE IS NOT NULL
) n
INNER JOIN (
SELECT DISTINCT p2.PERSNBR
FROM PERSPHONE p2
WHERE p2.AREACD||p2.EXCHANGE||p2.PHONENBR = :phoneNumber
FETCH FIRST 50 ROWS ONLY
) l ON l.PERSNBR = n.PERSNBR
GROUP BY (n.PERSNBR, n.SHAREACCTNBR)
ORDER BY (MAX(n.PRIORITY))
)
,Person AS
(
SELECT DISTINCT e.FIRSTNAME||COALESCE(nullif(' '||e.MDLINIT,' '), '')||' '||e.LASTNAME AS PERSONNAME, l.PERSNBR, l.MEMBERAGREENBR, l.SHAREACCTNBR
FROM OSIBANK.PERS e
INNER JOIN PersonLookup l ON l.PERSNBR=e.PERSNBR
)
,Phone_list AS
(
SELECT DISTINCT p.PERSNBR, p.AREACD||p.EXCHANGE||p.PHONENBR AS phone_number, p.PHONEUSECD AS phone_type, p.PHONESEQ,
ROW_NUMBER () OVER(PARTITION BY p.PERSNBR, p.PHONEUSECD ORDER BY PREFERREDYN DESC, p.PHONESEQ DESC) AS rn
FROM OSIBANK.PERSPHONE p
INNER JOIN PersonLookup l ON l.PERSNBR=p.PERSNBR
WHERE p.PHONEUSECD IN ('PER', 'CELL', 'BUS')
)
,phone_part AS
(
SELECT * FROM
(
SELECT PERSNBR, phone_type, phone_number
FROM Phone_list
WHERE rn=1
)
PIVOT
(
MAX(phone_number) FOR phone_type IN ('PER' AS Home_Phone, 'CELL' AS Cell_Phone, 'BUS' AS Business_Phone)
)
)
,SharedAcctTran AS
(
SELECT t.ACCTNBR, a.PERSNBR, t.RTXNTYPCD, t.ORIGPOSTDATE, t.TRANAMT, a.SHAREACCTNBR,
CASE WHEN t.RTXNTYPCD = 'WTH' THEN 'WTH'
WHEN t.RTXNTYPCD IN ('DEP', 'XDEP') THEN 'DEP' END AS TransType
FROM PersonLookup a
INNER JOIN OSIBANK.RTXN t ON t.ACCTNBR=a.SHAREACCTNBR AND t.RTXNTYPCD IN ('WTH','DEP','XDEP')
ORDER BY t.ORIGPOSTDATE DESC
FETCH FIRST 1000 ROWS ONLY
)
,SharedAcctTranOrder AS
(
SELECT ACCTNBR, PERSNBR, ORIGPOSTDATE, TRANAMT, RTXNTYPCD, TransType, SHAREACCTNBR,
ROW_NUMBER() OVER(PARTITION BY ACCTNBR, TransType ORDER BY ORIGPOSTDATE DESC) AS rn
FROM SharedAcctTran
)
,SharedAcctTran_Part AS
(
SELECT ACCTNBR, PERSNBR, TransType, SHAREACCTNBR,
CASE WHEN TransType='WTH' THEN ORIGPOSTDATE END AS Last_ShareAcct_Withdrawal_DateTime,
CASE WHEN TransType='DEP' THEN ORIGPOSTDATE END AS Last_Share_Deposit_Date,
CASE WHEN TransType='DEP' THEN TRANAMT END AS Last_Share_Deposit_Amount
FROM SharedAcctTranOrder
WHERE rn=1
)
,Autoloan_Part AS
(
SELECT DISTINCT MAX(l.PERSNBR) AS PERSNBR, MAX(pr.PROPDESC) AS PROPDESC
FROM OSIBANK.ACCT a
INNER JOIN PersonLookup l ON a.ACCTNBR = l.SHAREACCTNBR OR a.TAXRPTFORPERSNBR = l.PERSNBR
INNER JOIN OSIBANK.ACCTPROP AP ON AP.ACCTNBR=a.ACCTNBR
INNER JOIN OSIBANK.prop pr ON pr.propnbr=ap.PROPNBR
WHERE a.MJACCTTYPCD='CNS'
AND a.CURRMIACCTTYPCD IN ('DL01','DL02','DL03','DL04','DV01','DV02','DV03','DV04')
GROUP BY (l.PERSNBR)
ORDER BY a.CONTRACTDATE DESC
)
SELECT DISTINCT
MAX(p.PERSNBR) AS PersonNumber,
MAX(e.PERSONNAME) AS PERSONNAME,
MAX(e.MEMBERAGREENBR) AS MemberNumber,
MAX(p.Home_Phone) AS HomePhone,
MAX(p.Cell_Phone) AS CellPhone,
MAX(p.Business_Phone) AS BusinessPhone,
MAX(w.Last_ShareAcct_Withdrawal_DateTime) AS LastShareAcctWithdrawalTime,
MAX(d.Last_Share_Deposit_Date) AS LastShareDepositDate,
MAX(d.Last_Share_Deposit_Amount) AS LastShareDepositAmount,
MAX(l.PROPDESC) AS VehicleYearMakeModelVin,
MAX(puf.VALUE) AS PassPhrase
FROM phone_part p
LEFT JOIN Person e ON p.PERSNBR=e.PERSNBR
LEFT JOIN PERSUSERFIELD puf on p.PERSNBR=puf.PERSNBR AND puf.userfieldcd='PASS'
LEFT JOIN SharedAcctTran_Part w ON e.SHAREACCTNBR=w.SHAREACCTNBR AND w.TransType='WTH'
LEFT JOIN SharedAcctTran_Part d ON e.SHAREACCTNBR=d.SHAREACCTNBR AND d.TransType='DEP'
LEFT JOIN Autoloan_Part l ON p.PERSNBR=l.PERSNBR
GROUP BY (p.PERSNBR)
FETCH FIRST 2 ROWS ONLY
@@ -0,0 +1,143 @@
/*New Activity Manager Incentive Referral Query
----------------------------------
DESCRIPTION:
Get all Activity Manager entries associated with incented referrals.
Supplies Activity Data, Associate Name information, as well as the Agreement Number, Card Status (Should always be ISS (issue)),
CardAgreementTypeCd, AccountNumber for the associated agreement as well as the account status at time the activity was generated.
RETURNS: Models/Activity/ActivityManagerIncentiveReferral.cs
PARAMS:
|afterActivityOd : Null or Int (as string)
|------------------------------------------------------------------------------
|Returns all Activity Manager entries with a ID after the supplied ID
|If null defaults to -1 which will return all Checking SalesActivities
|newerThanOriginationDate : Null or Datetime in format 'YYYY-MM-DD HH24:MI:SS' (as string)
|-----------------------------------------------------------------------------
|Returns all Activity Manager entries that were created after specified date time.
|The origination date is always the date that the activity was first entered into the system
|regardless of its initial station or what station it is in now
|If null defaults to '0001-01-01 00:00:00' which is oracles MIN Date time, this effectively
|returns all Checking Sales Activities
NOTES:
- When an activity's station is updated, its activity stays the same, but its created date and date last maintained
dates are updated to the StationDate. They are always with respect to the current station. To get the date that
the activity first entered activity manager, use OriginationDate
- When a referral is for a business the LF_PERS.EXTID3 column has a O in front of the OrgNbr,
When a referral is for a person the LFPERS.EXTID3 coulumn has a P in front of the PersNbr
- Remember that these fields are all entered manually by an employee. This should not be used as a source of truth for any given activity.
This data is supplied with the intention of matching this referral to a sale. It is the best plan to focus on the referred person,
and manually query for related accounts as opposed to using the 'custom fields'. We include them here for audit purposes.
CUSTOM FIELD INFO (ActivityManager.LF_LEAD_CUSTOM):
Credit Card Balance Transfer
--LeadCust_39 = External CC Account Number
--LeadCust_31 = Landmark Credit Card Number
--LeadCust_29 = Transfer Ammount
--LeadCust_28 = Payment State + Zip
--LeadCust_27 = Payment City
--LeadCust_26 = Payment Address Line 1
--LeadCust_24 = Transfer Institution
Direct Deposit
--LeadCust_38 = Direct Deposit is Qualified Referral
--LeadCust_4 = Direct Deposit Account Number
LF_PERSON-><COMM{int}TYPE>
B = PAGER
C = MOBILE
E = BUSINESS EMAIL
F = FAX
H = HOME
J = PERSONAL EMAIL
P = PHONE
*/
WITH EmployeeEmail AS (
SELECT pers.USERID AS SafUserId,
prod.PERSNBR AS SafPersNbr,
prod.PRODPERSID AS CorePersNbr,
addr.TEXT AS EmployeeEmail
FROM SAF.PERSUSER pers
JOIN SAF.PERSPROD prod ON
pers.PERSNBR = PROD.PERSNBR
AND prod.PRODNBR = '3'
JOIN OSIBANK.PERSADDRUSE paddr ON
prod.PRODPERSID = PADDR.PERSNBR
JOIN OSIBANK.ADDRLINE addr ON
paddr.ADDRNBR = addr.ADDRNBR
AND paddr.ADDRUSECD = 'EBUS'
)
SELECT ll.ID AS ActivityId,
-- These custom fields can be reused, guarentee their contents by only using them for their respective campaigns
(CASE WHEN ll.CAMPAIGN = 'CC Balance Transfer' THEN llc.LEADCUST_31 ELSE NULL END) AS LandmarkCreditCardNumber,
(CASE WHEN ll.CAMPAIGN = 'Direct Deposit' THEN llc.LEADCUST_4 ELSE NULL END) AS DirectDepositAccountNumber,
ll.ORIGINATOR AS OriginatorUserId,
safprod.PRODPERSID AS OriginatorPersNbr,
p.FIRSTNAME AS OriginatorFirstName,
p.LASTNAME AS OriginatorLastName,
p.MDLINIT AS OriginatorMiddleInitial,
ee.EmployeeEmail AS EmployeeEmail,
ll.CAMPAIGN AS Campaign,
ll.CATEGORY AS Category,
ll.STATION AS ReferralStation,
ll.DATELASTMAINT AS LastUpdatedDateTime,
(CASE WHEN att.INITIAL_STATION = 'Yes' THEN 1 ELSE 0 END) AS IsInitialStation,
(CASE WHEN att.FINAL_STATION = 'Yes' THEN 1 ELSE 0 END) AS IsFinalStation,
att.ACTIVITY_ORIGINATION_DATE AS OriginationDateTime,
att.ENTER_STATION_DATETIME AS StationDateTime,
ll.SOURCE AS OriginatingBranchName,
(CASE WHEN SUBSTR(lp.EXTID3, 1, 1) = 'P' THEN REGEXP_SUBSTR(lp.EXTID3, '\d+') ELSE NULL END) AS ReferredPersonNbr,
(CASE WHEN SUBSTR(lp.EXTID3, 1, 1) = 'O' THEN REGEXP_SUBSTR(lp.EXTID3, '\d+') ELSE NULL END) AS ReferredOrgNbr,
CASE WHEN REFPERS.LASTNAME IS NOT NULL THEN CONCAT(CONCAT(REFPERS.LASTNAMEUPPER, ','), REFPERS.FIRSTNAMEUPPER)
WHEN lp.LastName IS NOT NULL THEN CONCAT(CONCAT(UPPER(lp.LastName), ','), UPPER(lp.FirstName)) ELSE NULL END AS ReferredPersonName,
REFORG.ORGNAME AS ReferredOrgName,
lp.EXTID3 AS ReferredPersOrgNbr,
lp.PREFERRED_PHONE AS PreferredPhone,
COALESCE(lp.COMM1, '') AS COMM1,
COALESCE(lp.COMM2, '') AS COMM2,
COALESCE(lp.COMM3, '') AS COMM3,
COALESCE(lp.COMM4, '') AS COMM4,
COALESCE(lp.COMM5, '') AS COMM5,
COALESCE(lp.COMM6, '') AS COMM6,
COALESCE(lp.COMM7, '') AS COMM7
FROM ACTIVITYMANAGER.LF_LEAD ll
JOIN ACTIVITYMANAGER.LF_LEAD_CUSTOM llc ON
ll.ID = llc.ID
JOIN SAF.PERSUSER safp ON
safp.USERID = ll.ORIGINATOR
JOIN SAF.PERSPROD safprod ON
SAFPROD.PERSNBR = safp.PERSNBR AND
SAFPROD.PRODNBR = '3'
JOIN OSIBANK.PERS p ON
p.PERSNBR = SAFPROD.PRODPERSID
LEFT JOIN EmployeeEmail ee ON
ee.SafPersNbr = SAFP.PERSNBR
JOIN ACTIVITYMANAGER.LF_PERSON lp ON
lp.ID = ll.PERSONID
JOIN ACTIVITYMANAGER.ACTIVITY_TIME_TRACKING att
ON att.ACTIVITY_ID = ll.ID AND SEQUENCE_NUMBER = (
SELECT MAX(SEQUENCE_NUMBER)
FROM ACTIVITYMANAGER.ACTIVITY_TIME_TRACKING att2
WHERE att2.ACTIVITY_ID = ll.ID
)
LEFT JOIN OSIBANK.ORG REFORG ON reforg.ORGNBR = (CASE WHEN SUBSTR(lp.EXTID3, 1, 1) = 'O' THEN REGEXP_SUBSTR(lp.EXTID3, '\d+') ELSE NULL END)
LEFT JOIN OSIBANK.PERS REFPERS ON refpers.PERSNBR = (CASE WHEN SUBSTR(lp.EXTID3, 1, 1) = 'P' THEN REGEXP_SUBSTR(lp.EXTID3, '\d+') ELSE NULL END)
WHERE ll.CAMPAIGN IN (
'ATM Card',
'Check Card Referral',
'Checking Referral',
'Direct Deposit',
'CC Balance Transfer',
'Mortgage Referral',
'LIC Referral',
'First Mortgage Referral',
'eStatement Referral')
AND ll.ID > TO_NUMBER(COALESCE(:afterActivityId, '-1'))
AND att.ACTIVITY_ORIGINATION_DATE >= TO_TIMESTAMP(COALESCE(:newerThanOriginationDate, '0001-01-01 00:00:00'), 'YYYY-MM-DD HH24:MI:SS')
@@ -0,0 +1,136 @@
/*New ATM/Check Cards Sale Query
----------------------------------
DESCRIPTION:
Get all Activities related to New Check or ATM Cards (ActvType = AGRE and SubActivity contains a change
to the 'CardAgreement' table where the AgreeTypCd = 'DBT', 'DBT2', 'BDBT', 'ATM')
after a supplied DateTime (inclusive) or after a supplied ActivityNumber (not inclusive) or both.
Supplies Activity Data, Associate Name information, as well as the Agreement Number, Card Status (Should always be ISS (issue)),
CardAgreementTypeCd, AccountNumber for the associated agreement as well as the account status at time the activity was generated.
RETURNS: Models/Activity/NewAtmCheckCardActivity.cs
PARAMS:
|afterActivityNbr : Null or Int (as string)
|------------------------------------------------------------------------------
|Returns all Checking Sales with ActivityNbrs larger than the supplied number.
|If null defaults to -1 which will return all Checking SalesActivities
|newerThanDateTime : Null or Datetime in format 'YYYY-MM-DD HH24:MI:SS' (as string)
|-----------------------------------------------------------------------------
|Returns all Checking Sales with ActivityNbrs that occured on or after the supplied date
|If null defaults to '0001-01-01 00:00:00' which is oracles MIN Date time, this effectively
|returns all Checking Sales Activities
|limitAmount : Null or Int (as string)
|------------------------------------------------------------------------------
|Return record count
|If null defaults to '100'
NOTES:
- 'AGRE' activity is an activity related to a change or update to an agreement
- 'DBT', 'DBT2', 'BDBT' abd 'ATM are the only CardTypes that are incented
- This will return all new ATM/Check card sales, even those that were created when a new account was created,
Note that these are not incented. Uncommment the line in the where clause to filter out unincented accounts.
- Though not explicitly filtered these results will only include cards in the 'ISS' issued status. This is because
of the join with CARDMEMBERISSUEHIST
- The AcctStatDuringActivity column is the last status of the account (from ACCTACCTSTATHIST table) before or when
the activity occured. We do not return the current status at the time of the query.
- When Card is in APPR state, sometimes personNbr will be missing. When creating this query there were no situations
Where the cards was in ACT state and did not have a person number assigned to them
*/
WITH EmployeeEmail AS (
SELECT p.PERSNBR As CorePersNbr,
addr.TEXT AS EmployeeEmail
FROM OSIBANK.PERSEMPL p
JOIN OSIBANK.PERSADDRUSE paddr ON
p.PERSNBR = PADDR.PERSNBR
JOIN OSIBANK.ADDRLINE addr ON
paddr.ADDRNBR = addr.ADDRNBR
AND paddr.ADDRUSECD = 'EBUS'
),
ActivitySubActivity AS (
SELECT *
FROM OSIBANK.ACTVSUBACTV asa
WHERE asa.TABLEID = 'CardAgreement'
),
AGREEMENTACTIVITYDATA AS (
SELECT a.ACTVNBR AS ActivityNbr,
a.ACTVDATETIME AS ActivityDateTime,
a.RESPPERSNBR AS ResponsiblePersonNbr,
a.ACTVTYPCD AS ActivityTypeCde,
-- CardAgreement table has only one row in value table. Other rows may have duplicate unmatching data for Non-owner users
max(CASE WHEN asa.COLUMNID = 'AgreeNbr' THEN asa.NEWVALUE END) AS AgreementNbr,
max(CASE WHEN asa.COLUMNID = 'AgreeTypCd' THEN asa.NEWVALUE END) AS CardState,
max(CASE WHEN asa.COLUMNID = 'AgreeTypCd' THEN asa.NEWVALUE END) AS CardType,
max(CASE WHEN asa.COLUMNID = 'ServChgAcctNbr' THEN asa.NEWVALUE END) AS AccountNbr,
max(CASE WHEN asa.COLUMNID = 'OwnerPersNbr' THEN asa.NEWVALUE END) AS OwnerPersonNbr,
max(CASE WHEN asa.COLUMNID = 'OwnerOrgNbr' THEN asa.NEWVALUE END) AS OwnerOrgNbr
FROM OSIBANK.ACTV a
LEFT JOIN ActivitySubActivity asa ON asa.ACTVNBR = a.ACTVNBR
WHERE a.ACTVTYPCD = 'AGRE'
GROUP BY a.ACTVNBR, a.ACTVDATETIME, a.RESPPERSNBR, a.ACTVTYPCD
),
PHONEMETADATA AS (
SELECT p.PERSNBR,
LISTAGG((pp.AREACD || pp.EXCHANGE || pp.PHONENBR), ',') AS PhoneNumbers
FROM OSIBANK.PERS p
LEFT JOIN OSIBANK.PERSPHONE pp ON p.PERSNBR = pp.PERSNBR AND pp.PHONEUSECD != 'BUS'
GROUP BY p.PERSNBR
),
EMAILMETADATA AS (
SELECT p.PERSNBR,
LISTAGG(al.TEXT, ',') AS EmailAddresses
FROM OSIBANK.PERS p
LEFT JOIN OSIBANK.PERSADDRUSE pa ON p.PERSNBR = pa.PERSNBR AND pa.ADDRUSECD IN ('EHOM', 'EML')
LEFT JOIN OSIBANK.ADDRLINE al ON pa.ADDRNBR = al.ADDRNBR AND al.LINENBR = 1
GROUP BY p.PERSNBR
)
SELECT ActvData.*,
acc.CURRACCTSTATCD AS AcctStatAtQueryTime,
hist.ACCTSTATCD AS AcctStateAtActivity,
hist.EFFDATETIME AS AcctStateEffDateTime,
p.FIRSTNAME AS AssociateFirst,
p.LASTNAME AS AssociateLast,
p.MDLINIT AS AssociateMiddleInit,
CASE
WHEN acc.TAXRPTFORPERSNBR IS NOT NULL THEN CONCAT(CONCAT(TAXPERS.LASTNAMEUPPER, ','), TAXPERS.FIRSTNAMEUPPER)
ELSE NULL
END AS TaxPersonName,
TAXORG.ORGNAME AS TaxOrgName,
ee.EmployeeEmail AS EmployeeEmail,
pmd.PhoneNumbers AS TaxPersonPhoneNumbers,
emd.EmailAddresses AS TaxPersonEmailAddresses
FROM AGREEMENTACTIVITYDATA ActvData
-- Sometimes a card activity shows up with identical data but a different date time Seconds apart.
-- There seems to always be an entry created in CARDMEMBERISSUEHIST that has one record matching these timestamps
JOIN OSIBANK.CARDMEMBERISSUEHIST c ON
c.AGREENBR = ActvData.AgreementNbr
AND c.EFFDATETIME = ActvData.ActivityDateTime
JOIN OSIBANK.ACCT acc ON acc.ACCTNBR = ActvData.AccountNbr
LEFT JOIN OSIBANK.PERS taxpers ON ActvData.OwnerPersonNbr = TAXPERS.PERSNBR
LEFT JOIN OSIBANK.ORG taxorg ON ActvData.OwnerOrgNbr = TAXORG.ORGNBR
--Check for most recent account status before the Activity was recorded
--This has been verified to not produce duplicate rows and not eliminate rows
JOIN OSIBANK.ACCTACCTSTATHIST hist ON ActvData.AccountNbr = hist.ACCTNBR AND hist.TIMEUNIQUEEXTN = (
SELECT MAX(TIMEUNIQUEEXTN)
FROM OSIBANK.ACCTACCTSTATHIST histsearch
WHERE histsearch.EFFDATETIME <= ActvData.ActivityDateTime
AND histsearch.ACCTNBR = ActvData.AccountNbr
)
JOIN OSIBANK.PERS p ON ActvData.ResponsiblePersonNbr = p.PERSNBR
JOIN EmployeeEmail ee ON ActvData.ResponsiblePersonNbr = ee.CorePersNbr
LEFT JOIN PHONEMETADATA pmd ON taxpers.PERSNBR = pmd.PERSNBR
LEFT JOIN EMAILMETADATA emd ON taxpers.PERSNBR = emd.PERSNBR
WHERE (ActvData.AgreementNbr IS NOT NULL AND ActvData.CardState IS NOT NULL AND ActvData.CARDTYPE IS NOT NULL)
AND ActvData.CardType IN ('DBT', 'DBT2', 'BDBT', 'ATM')
--AND ACCTSTATCD = 'ACT' (Uncomment to only return cards that we issued to active accounts)
AND ActivityNbr > TO_NUMBER(COALESCE(:afterActivityNbr, '-1'))
AND ActivityDateTime >= TO_TIMESTAMP(COALESCE(:newerThanDateTime, '0001-01-01 00:00:00'), 'YYYY-MM-DD HH24:MI:SS')
ORDER BY ActvData.ActivityDateTime ASC
FETCH NEXT TO_NUMBER(COALESCE(:limitAmount, '100')) ROWS ONLY
@@ -0,0 +1,126 @@
/*New Checking Account Sale Query
----------------------------------
DESCRIPTION:
Get all Activities related to New checking accounts (ActvType = AADD and AccountType = 'Checking')
after a supplied DateTime (inclusive) or after a supplied ActivityNumber (not inclusive) or both.
Supplies Activity Data as well as the Account Number of the new account and the account status at the time of querying
RETURNS: Models/Activity/NewCheckingAccountActivity.cs
PARAMS:
|afterActivityNbr : Null or Int (as string)
|------------------------------------------------------------------------------
|Returns all Checking Sales with ActivityNbrs larger than the supplied number.
|If null defaults to -1 which will return all Checking SalesActivities
|newerThanDateTime : Null or Datetime in format 'YYYY-MM-DD HH24:MI:SS' (as string)
|-----------------------------------------------------------------------------
|Returns all Checking Sales with ActivityNbrs that occured on or after the supplied date
|If null defaults to '0001-01-01 00:00:00' which is oracles MIN Date time, this effectively
|returns all Checking Sales Activities
|limitAmount : Null or Int (as string)
|------------------------------------------------------------------------------
|Return record count
|If null defaults to '100'
NOTES:
- Activity Type Code 'AADD' are activities related to 'Adding an account'
- Limitation: You get the status of the account when querying. This could be different immediately after creation
- When Acct is associated with person, the TAXRPTFORPERSNBR will populate, when associated with organizations the
when associated with an organization the TAXRPTFORORGNBR will populate
- Using both the following sub account filters resulted in the same number of activities to be found (638) and removed duplicates. When neither of these are checked for null values, there are 662 (24 duplicates)
1. max(CASE WHEN a2.OLDVALUE = 'Key=' AND a2.TABLEID = 'Acct' AND a2.COLUMNID = 'AcctNbr' AND a2.DATABASEACTVCD = 'UPD' THEN a2.NEWVALUE END) AS SubActivityAccount (638 results)
2. max(CASE WHEN a2.COLUMNID = 'ACCTNBR' AND a2.TABLEID = 'ACCT' AND a2.DATABASEACTVCD = 'ADD' THEN a2.NEWVALUE END) AS SubActivityAccount (638 results)
*/
WITH EmployeeEmail AS (
SELECT p.PERSNBR As CorePersNbr,
addr.TEXT AS EmployeeEmail
FROM OSIBANK.PERSEMPL p
JOIN OSIBANK.PERSADDRUSE paddr ON
p.PERSNBR = PADDR.PERSNBR
JOIN OSIBANK.ADDRLINE addr ON
paddr.ADDRNBR = addr.ADDRNBR
AND paddr.ADDRUSECD = 'EBUS'
),
OriginalBalance AS (
--This assumes there is only 1 Note/Bal sub account for every account
--So far that has been true.
SELECT ACCTNBR, ORIGBAL
FROM OSIBANK.ACCTSUBACCT a2
WHERE a2.BALCATCD = 'NOTE'
AND a2.BALTYPCD = 'BAL'
),
ActivitySubActivity AS (
SELECT *
FROM OSIBANK.ACTVSUBACTV asa
WHERE asa.TABLEID = 'Acct'
),
NEWCHECKINGACTIVITYDATA AS (
SELECT a.ACTVNBR AS ActivityNbr,
a.ACTVDATETIME AS ActivityDateTime,
a.SUBJACCTNBR AS SubjectAccountNbr,
a.RESPPERSNBR AS ResponsiblePersonNbr,
a.ACTVTYPCD AS ActivityTypeCode,
--2 activities are sometimes created for adding an account, only 1 will update the account from key= to the actual account number value
max(CASE
WHEN asa.OLDVALUE = 'Key=' AND asa.COLUMNID = 'AcctNbr' AND asa.DATABASEACTVCD = 'UPD' THEN asa.NEWVALUE
END) AS SubActivityAccount
FROM OSIBANK.ACTV a
LEFT JOIN ActivitySubActivity asa ON asa.ACTVNBR = a.ACTVNBR
WHERE a.ACTVTYPCD = 'AADD'
GROUP BY a.ACTVNBR, a.ACTVDATETIME, a.SUBJACCTNBR, a.RESPPERSNBR, a.ACTVTYPCD
),
PHONEMETADATA AS (
SELECT p.PERSNBR,
LISTAGG((pp.AREACD || pp.EXCHANGE || pp.PHONENBR), ',') AS PhoneNumbers
FROM OSIBANK.PERS p
LEFT JOIN OSIBANK.PERSPHONE pp ON p.PERSNBR = pp.PERSNBR AND pp.PHONEUSECD != 'BUS'
GROUP BY p.PERSNBR
),
EMAILMETADATA AS (
SELECT p.PERSNBR,
LISTAGG(al.TEXT, ',') AS EmailAddresses
FROM OSIBANK.PERS p
LEFT JOIN OSIBANK.PERSADDRUSE pa ON p.PERSNBR = pa.PERSNBR AND pa.ADDRUSECD IN ('EHOM', 'EML')
LEFT JOIN OSIBANK.ADDRLINE al ON pa.ADDRNBR = al.ADDRNBR AND al.LINENBR = 1
GROUP BY p.PERSNBR
)
SELECT ActvData.*,
p.FIRSTNAME AS AssociateFirst,
p.LASTNAME AS AssociateLast,
p.MDLINIT AS AssociateMiddleInit,
ee.EmployeeEmail AS EmployeeEmail,
acc.CURRACCTSTATCD AS CurrentAccountStatus,
acc.TAXRPTFORPERSNBR AS TaxPersonNbr,
acc.TAXRPTFORORGNBR AS TaxOrgNbr,
CASE
WHEN acc.TAXRPTFORPERSNBR IS NOT NULL THEN CONCAT(CONCAT(TAXPERS.LASTNAMEUPPER, ','), TAXPERS.FIRSTNAMEUPPER)
ELSE NULL
END AS TaxPersonName,
TAXORG.ORGNAME AS TaxOrgName,
acc.BranchOrgNbr As BranchOrgNbr,
acc.CONTRACTDATE AS AccountContractDate,
acc.CURRMIACCTTYPCD AS MinorAccountType,
org.ORGNAME AS BranchOrgName,
ob.ORIGBAL AS OriginalBalance,
pmd.PhoneNumbers AS TaxPersonPhoneNumbers,
emd.EmailAddresses AS TaxPersonEmailAddresses
FROM NEWCHECKINGACTIVITYDATA ActvData
JOIN OSIBANK.PERS p ON p.PERSNBR = ActvData.ResponsiblePersonNbr
LEFT JOIN EmployeeEmail ee ON ee.CorePersNbr = ActvData.ResponsiblePersonNbr
JOIN OSIBANK.ACCT acc ON acc.ACCTNBR = ActvData.SubjectAccountNbr
JOIN OSIBANK.ORG org ON acc.BranchOrgNbr = org.ORGNBR
LEFT JOIN OSIBANK.PERS taxpers ON acc.TAXRPTFORPERSNBR = TAXPERS.PERSNBR
LEFT JOIN OSIBANK.ORG taxorg ON acc.TAXRPTFORORGNBR = TAXORG.ORGNBR
LEFT JOIN OriginalBalance ob ON acc.ACCTNBR = ob.AcctNbr
LEFT JOIN PHONEMETADATA pmd ON taxpers.PERSNBR = pmd.PERSNBR
LEFT JOIN EMAILMETADATA emd ON taxpers.PERSNBR = emd.PERSNBR
WHERE ActvData.SubActivityAccount IS NOT NULL
AND acc.CURRMIACCTTYPCD IN ('CK04', 'CK01', 'CK02', 'CK03', 'BC10', 'BC20', 'MMC5', 'BOC1', 'BOC2', 'BC01', 'MMC1', 'CK05', 'BC11', 'CK06')
AND ActivityNbr > TO_NUMBER(COALESCE(:afterActivityNbr, '-1'))
AND ActivityDateTime >= TO_TIMESTAMP(COALESCE(:newerThanDateTime, '0001-01-01 00:00:00'), 'YYYY-MM-DD HH24:MI:SS')
ORDER BY ActvData.ActivityDateTime ASC
FETCH NEXT TO_NUMBER(COALESCE(:limitAmount, '100')) ROWS ONLY
@@ -0,0 +1,103 @@
/*New Checking Account Sale Query
----------------------------------
DESCRIPTION:
Get all Activities related to New checking accounts (ActvType = ADAC and AccountType = 'Checking')
after a supplied DateTime (inclusive) or after a supplied ActivityNumber (not inclusive) or both.
Supplies Activity Data as well as the Account Number of the new account and the account status at the time of querying
RETURNS: Models/Activity/NewCheckingAccountActivity.cs
PARAMS:
|afterActivityNbr : Null or Int (as string)
|------------------------------------------------------------------------------
|Returns all Checking Sales with ActivityNbrs larger than the supplied number.
|If null defaults to -1 which will return all Checking SalesActivities
|newerThanDateTime : Null or Datetime in format 'YYYY-MM-DD HH24:MI:SS' (as string)
|-----------------------------------------------------------------------------
|Returns all Checking Sales with ActivityNbrs that occured on or after the supplied date
|If null defaults to '0001-01-01 00:00:00' which is oracles MIN Date time, this effectively
|returns all Checking Sales Activities
NOTES:
- Activity Type Code 'ADAC' are activities related to 'Adding an account'
- Limitation: You get the status of the account when querying. This could be different immediately after creation
- When Acct is associated with person, the TAXRPTFORPERSNBR will populate, when associated with organizations the
when associated with an organization the TAXRPTFORORGNBR will populate
- Using both the following sub account filters resulted in the same number of activities to be found (638) and removed duplicates. When neither of these are checked for null values, there are 662 (24 duplicates)
1. max(CASE WHEN a2.OLDVALUE = 'Key=' AND a2.TABLEID = 'Acct' AND a2.COLUMNID = 'AcctNbr' AND a2.DATABASEACTVCD = 'ADD' THEN a2.NEWVALUE END) AS SubActivityAccount (638 results)
2. max(CASE WHEN a2.COLUMNID = 'ACCTNBR' AND a2.TABLEID = 'ACCT' AND a2.DATABASEACTVCD = 'ADD' THEN a2.NEWVALUE END) AS SubActivityAccount (638 results)
*/
WITH OriginalBalance AS (
--This assumes there is only 1 Note/Bal sub account for every account
--So far that has been true.
SELECT ACCTNBR, ORIGBAL
FROM OSIBANK.ACCTSUBACCT a2
WHERE a2.BALCATCD = 'NOTE'
AND a2.BALTYPCD = 'BAL'
),
NEWCHECKINGACTIVITYDATA AS (
SELECT a.ACTVNBR AS ActivityNbr,
a.ACTVDATETIME AS ActivityDateTime,
a.SUBJACCTNBR AS SubjectAccountNbr,
a.RESPPERSNBR AS ResponsiblePersonNbr,
a.ACTVTYPCD AS ActivityTypeCode,
--2 activities are sometimes created for adding an account, only 1 will update the account from key= to the actual account number value
max(CASE
WHEN asa.OLDVALUE = 'Key=' AND asa.COLUMNID = 'AcctNbr' AND asa.DATABASEACTVCD = 'ADD' THEN asa.NEWVALUE
END) AS SubActivityAccount
FROM OSIBANK.ACTV a
LEFT JOIN OSIBANK.ACTVSUBACTV asa ON asa.ACTVNBR = a.ACTVNBR and asa.TABLEID = 'Acct'
WHERE a.ACTVTYPCD = 'ADAC'
GROUP BY a.ACTVNBR, a.ACTVDATETIME, a.SUBJACCTNBR, a.RESPPERSNBR, a.ACTVTYPCD
),
PHONEMETADATA AS (
SELECT p.PERSNBR,
LISTAGG((pp.AREACD || pp.EXCHANGE || pp.PHONENBR), ',') AS PhoneNumbers
FROM OSIBANK.PERS p
LEFT JOIN OSIBANK.PERSPHONE pp ON p.PERSNBR = pp.PERSNBR AND pp.PHONEUSECD != 'BUS'
GROUP BY p.PERSNBR
),
EMAILMETADATA AS (
SELECT p.PERSNBR,
LISTAGG(al.TEXT, ',') AS EmailAddresses
FROM OSIBANK.PERS p
LEFT JOIN OSIBANK.PERSADDRUSE pa ON p.PERSNBR = pa.PERSNBR AND pa.ADDRUSECD IN ('EHOM', 'EML')
LEFT JOIN OSIBANK.ADDRLINE al ON pa.ADDRNBR = al.ADDRNBR AND al.LINENBR = 1
GROUP BY p.PERSNBR )
SELECT ActvData.*,
'Digital' AS AssociateFirst,
'Banking' AS AssociateLast,
p.MDLINIT AS AssociateMiddleInit,
acc.CURRACCTSTATCD AS CurrentAccountStatus,
acc.TAXRPTFORPERSNBR AS TaxPersonNbr,
acc.TAXRPTFORORGNBR AS TaxOrgNbr,
'[email protected]' AS EmployeeEmail, --we will not have employee email for Digital Banking
CASE
WHEN acc.TAXRPTFORPERSNBR IS NOT NULL THEN CONCAT(CONCAT(TAXPERS.LASTNAMEUPPER, ','), TAXPERS.FIRSTNAMEUPPER)
ELSE NULL
END AS TaxPersonName,
TAXORG.ORGNAME AS TaxOrgName,
acc.BranchOrgNbr As BranchOrgNbr,
acc.CONTRACTDATE AS AccountContractDate,
acc.CURRMIACCTTYPCD AS MinorAccountType,
org.ORGNAME AS BranchOrgName,
ob.ORIGBAL AS OriginalBalance,
pmd.PhoneNumbers AS TaxPersonPhoneNumbers,
emd.EmailAddresses AS TaxPersonEmailAddresses
FROM NEWCHECKINGACTIVITYDATA ActvData
JOIN OSIBANK.PERS p ON p.PERSNBR = ActvData.ResponsiblePersonNbr
JOIN OSIBANK.ACCT acc ON acc.ACCTNBR = ActvData.SubjectAccountNbr
JOIN OSIBANK.ORG org ON acc.BranchOrgNbr = org.ORGNBR
LEFT JOIN OSIBANK.PERS taxpers ON acc.TAXRPTFORPERSNBR = TAXPERS.PERSNBR
LEFT JOIN OSIBANK.ORG taxorg ON acc.TAXRPTFORORGNBR = TAXORG.ORGNBR
LEFT JOIN OriginalBalance ob ON acc.ACCTNBR = ob.AcctNbr
LEFT JOIN PHONEMETADATA pmd ON taxpers.PERSNBR = pmd.PERSNBR
LEFT JOIN EMAILMETADATA emd ON taxpers.PERSNBR = emd.PERSNBR
WHERE acc.CURRMIACCTTYPCD IN ('CK04', 'CK01', 'CK02', 'CK03', 'BC10', 'BC20', 'MMC5', 'BOC1', 'BOC2', 'BC01', 'MMC1', 'CK05', 'BC11', 'CK06')
AND ActivityNbr > TO_NUMBER(COALESCE(:afterActivityNbr, '-1'))
AND ActivityDateTime >= TO_TIMESTAMP(COALESCE(:newerThanDateTime, '0001-01-01 00:00:00'), 'YYYY-MM-DD HH24:MI:SS')
ORDER BY ActvData.ActivityDateTime ASC
FETCH NEXT TO_NUMBER(COALESCE(:limitAmount, '200')) ROWS ONLY
@@ -0,0 +1,175 @@
/*New Debt Protected Loan Sale Query
----------------------------------
DESCRIPTION:
All activities related to new loans that can have debt protection associated with them, but are not
incentivised like Mortgages and Vehicles.
RETURNS: Models/Activity/NewCheckingAccountActivity.cs
PARAMS:
|afterActivityNbr : Null or Int (as string)
|------------------------------------------------------------------------------
|Returns all Sales with ActivityNbrs larger than the supplied number.
|If null defaults to -1 which will return all Checking SalesActivities
|newerThanDateTime : Null or Datetime in format 'YYYY-MM-DD HH24:MI:SS' (as string)
|-----------------------------------------------------------------------------
|Returns all Sales with ActivityNbrs that occured on or after the supplied date
|If null defaults to '0001-01-01 00:00:00' which is oracles MIN Date time, this effectively
|returns all Checking Sales Activities
NOTES:
- Use ContractDate as the date of the sale. This is the day that the customer signs for the loan. There is a legal grace-period between
When a loan is signed and when the loan is booked into the banking system. This is why there is a gap between contract date and activity date.
-Only need to know if an account has debt protection not how many debt protection policies the account has. We select the earliest sold
debt protection and add the date and type to signify that the loan has debt protection
- LADD type activities seem to produce duplicates occasionally, None were found for mortgage type accounts
*/
WITH EmployeeEmail AS (
SELECT p.PERSNBR As CorePersNbr,
addr.TEXT AS EmployeeEmail
FROM OSIBANK.PERSEMPL p
JOIN OSIBANK.PERSADDRUSE paddr ON
p.PERSNBR = PADDR.PERSNBR
JOIN OSIBANK.ADDRLINE addr ON
paddr.ADDRNBR = addr.ADDRNBR
AND paddr.ADDRUSECD = 'EBUS'
),
OriginatorRole AS (
SELECT ACCTNBR, PERSNBR, ACCTROLECD, DATELASTMAINT, EFFDATE
from OSIBANK.ACCTACCTROLEPERS a
WHERE ACCTROLECD = 'OEMP'
GROUP BY ACCTNBR, ACCTROLECD, DATELASTMAINT, EFFDATE, PERSNBR
HAVING DATELASTMAINT = MAX(DATELASTMAINT)
),
LoanLimit AS (
SELECT a2.ACCTNBR, a2.CREDITLIMITAMT, a2.DATELASTMAINT
FROM OSIBANK.ACCTLOANLIMITHIST a2
WHERE a2.CREDITLIMITAMT > '0'
GROUP BY a2.ACCTNBR, a2.CREDITLIMITAMT, a2.DATELASTMAINT
HAVING MIN(a2.DATELASTMAINT) = a2.DATELASTMAINT
ORDER BY CREDITLIMITAMT
),
OriginalBalance AS (
--This assumes there is only 1 Note/Bal sub account for every account
--So far that has been true.
SELECT ACCTNBR, ORIGBAL
FROM OSIBANK.ACCTSUBACCT a2
WHERE a2.BALCATCD = 'NOTE'
AND a2.BALTYPCD = 'BAL'
),
DebtProtection AS (
SELECT a.ACCTNBR,
MIN(var.CALCTYPEFFDATE) AS EffectiveDate,
a.BALCATCD
FROM OSIBANK.ACCTSUBACCT a
INNER JOIN (
SELECT ACCTNBR, MIN(SUBACCTNBR) AS SUBACCTNBR
FROM OSIBANK.ACCTSUBACCT sa
WHERE sa.BALTYPCD = 'SINS'
GROUP BY ACCTNBR
) b ON a.ACCTNBR = b.ACCTNBR AND a.SUBACCTNBR = b.SUBACCTNBR
INNER JOIN OSIBANK.ACCTSUBACCTCALCVAR var ON var.ACCTNBR = a.ACCTNBR AND a.SUBACCTNBR = var.SUBACCTNBR
GROUP BY a.ACCTNBR, var.CALCTYPEFFDATE, a.BALCATCD
),
BorrowerAge AS (
SELECT a.ACCTNBR, MAX(p.DATEBIRTH) AS YoungestBirthdate
FROM OSIBANK.ACCTACCTROLEPERS a
LEFT JOIN OSIBANK.ACCT acc ON a.ACCTNBR = acc.ACCTNBR
LEFT JOIN OSIBANK.ACCTROLE r ON r.ACCTROLECD = a.ACCTROLECD
LEFT JOIN OSIBANK.PERS p ON a.PERSNBR = p.PERSNBR
WHERE a.ACCTROLECD IN ('TRO', 'NTO', 'SIGN')
AND (p.DATEDEATH IS NULL OR p.DATEDEATH > acc.CONTRACTDATE)
GROUP BY a.ACCTNBR
),
PHONEMETADATA AS (
SELECT p.PERSNBR,
LISTAGG((pp.AREACD || pp.EXCHANGE || pp.PHONENBR), ',') AS PhoneNumbers
FROM OSIBANK.PERS p
LEFT JOIN OSIBANK.PERSPHONE pp ON p.PERSNBR = pp.PERSNBR AND pp.PHONEUSECD != 'BUS'
GROUP BY p.PERSNBR
),
EMAILMETADATA AS (
SELECT p.PERSNBR,
LISTAGG(al.TEXT, ',') AS EmailAddresses
FROM OSIBANK.PERS p
LEFT JOIN OSIBANK.PERSADDRUSE pa ON p.PERSNBR = pa.PERSNBR AND pa.ADDRUSECD IN ('EHOM', 'EML')
LEFT JOIN OSIBANK.ADDRLINE al ON pa.ADDRNBR = al.ADDRNBR AND al.LINENBR = 1
GROUP BY p.PERSNBR
)
SELECT a.ACTVNBR AS ActivityNbr,
a.ACTVDATETIME AS ActivityDateTime,
a.SUBJACCTNBR AS SubjectAccountNbr,
a.RESPPERSNBR AS ActivityResponsiblePersonNbr,
oe.PERSNBR AS OriginatingPersonNbr,
a.ACTVTYPCD AS ActivityTypeCode,
p.FIRSTNAME AS AssociateFirst,
p.LASTNAME AS AssociateLast,
p.MDLINIT AS AssociateMiddleInit,
--NEW = "New" | REFI = "Refinance"
ll.CREDITLIMITAMT AS LoanLimit,
ob.OrigBal AS OriginalBalance,
COALESCE(ll.CREDITLIMITAMT, ob.ORIGBAL) AS LoanAmount,
al.LOANSOURCECD AS LoanSourceCode,
--ABS(r.TRANAMT) AS LoanDispersalAmmount,
ee.EmployeeEmail AS EmployeeEmail,
acc.CURRACCTSTATCD AS CurrentAccountStatus,
acc.TAXRPTFORPERSNBR AS TaxPersonNbr,
acc.TAXRPTFORORGNBR AS TaxOrgNbr,
CASE WHEN acc.TAXRPTFORPERSNBR IS NOT NULL THEN CONCAT(CONCAT(TAXPERS.LASTNAMEUPPER, ','), TAXPERS.FIRSTNAMEUPPER) ELSE NULL END AS TaxPersonName,
TAXORG.ORGNAME AS TaxOrgName,
acc.BranchOrgNbr As BranchOrgNbr,
acc.MjAcctTypCd AS MajorAccountType,
acc.CURRMIACCTTYPCD AS MinorAccountType,
acc.CONTRACTDATE AS AccountContractDate,
org.ORGNAME AS BranchOrgName,
dp.EffectiveDate AS DebtProtectionEffectiveDate,
dp.BALCATCD AS DebtProtectionCategory,
CASE
WHEN
ba.YoungestBirthdate IS NOT NULL AND
p2.DATEBIRTH IS NOT NULL
THEN
GREATEST(ba.YOUNGESTBIRTHDATE, p2.DATEBIRTH)
ELSE
COALESCE(ba.YOUNGESTBIRTHDATE, p2.DATEBIRTH)
END AS YoungestBirthdateOnLoan,
CASE
WHEN
acc.ACCTNBR IN (
SELECT acctnbr
FROM OSIBANK.ACCTACCTROLEORG aro
Where aro.ACCTROLECD IN ('DBA', 'LLC', 'UNAS')
) OR
acc.TAXRPTFORORGNBR IS NOT NULL
THEN 1
ELSE 0
END AS HasOrgRoles,
pmd.PhoneNumbers AS TaxPersonPhoneNumbers,
emd.EmailAddresses AS TaxPersonEmailAddresses
FROM OSIBANK.ACTV a
LEFT JOIN OSIBANK.ACCT acc ON acc.ACCTNBR = a.SUBJACCTNBR
LEFT JOIN OriginatorRole oe ON acc.ACCTNBR = oe.AcctNbr
LEFT JOIN OSIBANK.PERS p ON p.PERSNBR = oe.PERSNBR
LEFT JOIN OSIBANK.PERS taxpers ON acc.TAXRPTFORPERSNBR = TAXPERS.PERSNBR
LEFT JOIN OSIBANK.ORG taxorg ON acc.TAXRPTFORORGNBR = TAXORG.ORGNBR
JOIN OSIBANK.ORG org ON org.ORGNBR = acc.BRANCHORGNBR
LEFT JOIN EmployeeEmail ee ON p.PERSNBR = ee.CorePersNbr
--Uncomment to get Loan Dispersal Transaction Information
--LEFT JOIN OSIBANK.RTXN r ON acc.ACCTNBR = r.ACCTNBR AND r.RTXNTYPCD = 'NDSB'
LEFT JOIN OSIBANK.ACCTLOAN al ON acc.ACCTNBR = al.ACCTNBR
LEFT JOIN LoanLimit ll ON ll.AcctNbr = acc.ACCTNBR
LEFT JOIN OriginalBalance ob ON ob.AcctNbr = acc.ACCTNBR
LEFT JOIN DebtProtection dp ON dp.ACCTNBR = acc.ACCTNBR
LEFT JOIN OSIBANK.ACTVSUBACTV sa ON sa.ACTVNBR = a.ACTVNBR
LEFT JOIN BorrowerAge ba ON ba.AcctNbr = acc.ACCTNBR
LEFT JOIN OSIBANK.PERS p2 ON acc.TAXRPTFORPERSNBR = p2.PERSNBR
LEFT JOIN PHONEMETADATA pmd ON taxpers.PERSNBR = pmd.PERSNBR
LEFT JOIN EMAILMETADATA emd ON taxpers.PERSNBR = emd.PERSNBR
WHERE acc.CURRMIACCTTYPCD IN ('SC01', 'SC02', 'SG01')
AND (a.ACTVTYPCD = 'ADAC' OR a.ACTVTYPCD = 'LADD')
AND LOWER(sa.TABLEID) = 'acct'
AND LOWER(sa.COLUMNID) = 'acctnbr'
AND a.ACTVNBR > TO_NUMBER(COALESCE(:afterActivityNbr, '-1'))
AND a.ACTVDATETIME >= TO_TIMESTAMP(COALESCE(:newerThanDateTime, '0001-01-01 00:00:00'), 'YYYY-MM-DD HH24:MI:SS')
@@ -0,0 +1,186 @@
/*New Mortgagage Account Sale Query
----------------------------------
DESCRIPTION:
Get all Activities related to New Mortgage Accounts (ActvType = AADD and AccountType = ('FE01', 'MF01', 'FE02', 'FLML')
after a supplied DateTime (inclusive) or after a supplied ActivityNumber (not inclusive) or both.
Supplies Activity Data as well as the Account Number of the new account and the account status at the time of querying
RETURNS: Models/Activity/NewCheckingAccountActivity.cs
PARAMS:
|afterActivityNbr : Null or Int (as string)
|------------------------------------------------------------------------------
|Returns all Checking Sales with ActivityNbrs larger than the supplied number.
|If null defaults to -1 which will return all Checking SalesActivities
|newerThanDateTime : Null or Datetime in format 'YYYY-MM-DD HH24:MI:SS' (as string)
|-----------------------------------------------------------------------------
|Returns all Checking Sales with ActivityNbrs that occured on or after the supplied date
|If null defaults to '0001-01-01 00:00:00' which is oracles MIN Date time, this effectively
|returns all Checking Sales Activities
NOTES:
- ALL HELOC type loans are technically 'children' of a mainline loan. A person may get approved for a 100,000 mainline loan
but take out only 5k at a time via fixed loans. For incentive purposes we do not want to pull in the activity for HELOC's children loans
instead we pull in Flex Mainline (FLML) Loans.
- For mainline loans we use the first credit limit amount that is not 0 as the loan amount (the amount the customer was approved for)
- For loans that do not have a parent mainline we use the original balance amount on the loan (the amount the customer has available after approval)
- Use ContractDate as the date of the sale. This is the day that the customer signs for the loan. There is a legal grace-period between
When a loan is signed and when the loan is booked into the banking system. This is why there is a gap between contract date and activity date.
-Only need to know if an account has debt protection not how many debt protection policies the account has. We select the earliest sold
debt protection and add the date and type to signify that the loan has debt protection
- LADD type activities seem to produce duplicates occasionally, None were found for mortgage type accounts
*/
WITH EmployeeEmail AS (
SELECT p.PERSNBR As CorePersNbr,
addr.TEXT AS EmployeeEmail
FROM OSIBANK.PERSEMPL p
JOIN OSIBANK.PERSADDRUSE paddr ON
p.PERSNBR = PADDR.PERSNBR
JOIN OSIBANK.ADDRLINE addr ON
paddr.ADDRNBR = addr.ADDRNBR
AND paddr.ADDRUSECD = 'EBUS'
),
OriginatorRole AS (
SELECT ACCTNBR, PERSNBR, ACCTROLECD, DATELASTMAINT, EFFDATE
from OSIBANK.ACCTACCTROLEPERS a
WHERE ACCTROLECD = 'OEMP'
GROUP BY ACCTNBR, ACCTROLECD, DATELASTMAINT, EFFDATE, PERSNBR
HAVING DATELASTMAINT = MAX(DATELASTMAINT)
),
LoanLimit AS (
SELECT a2.ACCTNBR, a2.CREDITLIMITAMT, a2.DATELASTMAINT
FROM OSIBANK.ACCTLOANLIMITHIST a2
WHERE a2.CREDITLIMITAMT > '0'
GROUP BY a2.ACCTNBR, a2.CREDITLIMITAMT, a2.DATELASTMAINT
HAVING MIN(a2.DATELASTMAINT) = a2.DATELASTMAINT
ORDER BY CREDITLIMITAMT
),
OriginalBalance AS (
--This assumes there is only 1 Note/Bal sub account for every account
--So far that has been true.
SELECT ACCTNBR, ORIGBAL
FROM OSIBANK.ACCTSUBACCT a2
WHERE a2.BALCATCD = 'NOTE'
AND a2.BALTYPCD = 'BAL'
),
DebtProtection AS (
SELECT a.ACCTNBR,
MIN(var.CALCTYPEFFDATE) AS EffectiveDate,
a.BALCATCD
FROM OSIBANK.ACCTSUBACCT a
INNER JOIN (
SELECT ACCTNBR, MIN(SUBACCTNBR) AS SUBACCTNBR
FROM OSIBANK.ACCTSUBACCT sa
WHERE sa.BALTYPCD = 'SINS'
GROUP BY ACCTNBR
) b ON a.ACCTNBR = b.ACCTNBR AND a.SUBACCTNBR = b.SUBACCTNBR
INNER JOIN OSIBANK.ACCTSUBACCTCALCVAR var ON var.ACCTNBR = a.ACCTNBR AND a.SUBACCTNBR = var.SUBACCTNBR
GROUP BY a.ACCTNBR, var.CALCTYPEFFDATE, a.BALCATCD
),
BorrowerAge AS (
SELECT a.ACCTNBR, MAX(p.DATEBIRTH) AS YoungestBirthdate
FROM OSIBANK.ACCTACCTROLEPERS a
LEFT JOIN OSIBANK.ACCT acc ON a.ACCTNBR = acc.ACCTNBR
LEFT JOIN OSIBANK.ACCTROLE r ON r.ACCTROLECD = a.ACCTROLECD
LEFT JOIN OSIBANK.PERS p ON a.PERSNBR = p.PERSNBR
WHERE a.ACCTROLECD IN ('TRO', 'NTO', 'SIGN')
AND (p.DATEDEATH IS NULL OR p.DATEDEATH > acc.CONTRACTDATE)
GROUP BY a.ACCTNBR
),
PHONEMETADATA AS (
SELECT p.PERSNBR,
LISTAGG((pp.AREACD || pp.EXCHANGE || pp.PHONENBR), ',') AS PhoneNumbers
FROM OSIBANK.PERS p
LEFT JOIN OSIBANK.PERSPHONE pp ON p.PERSNBR = pp.PERSNBR AND pp.PHONEUSECD != 'BUS'
GROUP BY p.PERSNBR
),
EMAILMETADATA AS (
SELECT p.PERSNBR,
LISTAGG(al.TEXT, ',') AS EmailAddresses
FROM OSIBANK.PERS p
LEFT JOIN OSIBANK.PERSADDRUSE pa ON p.PERSNBR = pa.PERSNBR AND pa.ADDRUSECD IN ('EHOM', 'EML')
LEFT JOIN OSIBANK.ADDRLINE al ON pa.ADDRNBR = al.ADDRNBR AND al.LINENBR = 1
GROUP BY p.PERSNBR
)
SELECT a.ACTVNBR AS ActivityNbr,
a.ACTVDATETIME AS ActivityDateTime,
a.SUBJACCTNBR AS SubjectAccountNbr,
a.RESPPERSNBR AS ActivityResponsiblePersonNbr,
oe.PERSNBR AS OriginatingPersonNbr,
a.ACTVTYPCD AS ActivityTypeCode,
p.FIRSTNAME AS AssociateFirst,
p.LASTNAME AS AssociateLast,
p.MDLINIT AS AssociateMiddleInit,
--NEW = "New" | REFI = "Refinance"
ll.CREDITLIMITAMT AS LoanLimit,
ob.OrigBal AS OriginalBalance,
COALESCE(ll.CREDITLIMITAMT, ob.ORIGBAL) AS LoanAmount,
al.LOANSOURCECD AS LoanSourceCode,
--ABS(r.TRANAMT) AS LoanDispersalAmmount,
ee.EmployeeEmail AS EmployeeEmail,
acc.CURRACCTSTATCD AS CurrentAccountStatus,
acc.TAXRPTFORPERSNBR AS TaxPersonNbr,
acc.TAXRPTFORORGNBR AS TaxOrgNbr,
CASE WHEN acc.TAXRPTFORPERSNBR IS NOT NULL THEN CONCAT(CONCAT(TAXPERS.LASTNAMEUPPER, ','), TAXPERS.FIRSTNAMEUPPER) ELSE NULL END AS TaxPersonName,
TAXORG.ORGNAME AS TaxOrgName,
acc.BranchOrgNbr As BranchOrgNbr,
acc.MjAcctTypCd AS MajorAccountType,
acc.CURRMIACCTTYPCD AS MinorAccountType,
acc.CONTRACTDATE AS AccountContractDate,
org.ORGNAME AS BranchOrgName,
dp.EffectiveDate AS DebtProtectionEffectiveDate,
dp.BALCATCD AS DebtProtectionCategory,
CASE
WHEN
ba.YOUNGESTBIRTHDATE IS NOT NULL AND
p2.DATEBIRTH IS NOT NULL
THEN
GREATEST(ba.YOUNGESTBIRTHDATE, p2.DATEBIRTH)
ELSE
COALESCE(ba.YOUNGESTBIRTHDATE, p2.DATEBIRTH)
END AS YoungestBirthdateOnLoan,
CASE
WHEN
acc.ACCTNBR IN (
SELECT acctnbr
FROM OSIBANK.ACCTACCTROLEORG aro
Where aro.ACCTROLECD IN ('DBA', 'LLC', 'UNAS')
) OR
acc.TAXRPTFORORGNBR IS NOT NULL
THEN 1
ELSE 0
END AS HasOrgRoles,
pmd.PhoneNumbers AS TaxPersonPhoneNumbers,
emd.EmailAddresses AS TaxPersonEmailAddresses
FROM OSIBANK.ACTV a
LEFT JOIN OSIBANK.ACCT acc ON acc.ACCTNBR = a.SUBJACCTNBR
LEFT JOIN OriginatorRole oe ON acc.ACCTNBR = oe.AcctNbr
LEFT JOIN OSIBANK.PERS p ON p.PERSNBR = oe.PERSNBR
LEFT JOIN OSIBANK.PERS taxpers ON acc.TAXRPTFORPERSNBR = TAXPERS.PERSNBR
LEFT JOIN OSIBANK.ORG taxorg ON acc.TAXRPTFORORGNBR = TAXORG.ORGNBR
JOIN OSIBANK.ORG org ON org.ORGNBR = acc.BRANCHORGNBR
LEFT JOIN EmployeeEmail ee ON p.PERSNBR = ee.CorePersNbr
--Uncomment to get Loan Dispersal Transaction Information
--LEFT JOIN OSIBANK.RTXN r ON acc.ACCTNBR = r.ACCTNBR AND r.RTXNTYPCD = 'NDSB'
LEFT JOIN OSIBANK.ACCTLOAN al ON acc.ACCTNBR = al.ACCTNBR
LEFT JOIN LoanLimit ll ON ll.AcctNbr = acc.ACCTNBR
LEFT JOIN OriginalBalance ob ON ob.AcctNbr = acc.ACCTNBR
LEFT JOIN DebtProtection dp ON dp.ACCTNBR = acc.ACCTNBR
LEFT JOIN OSIBANK.ACTVSUBACTV sa ON sa.ACTVNBR = a.ACTVNBR
LEFT JOIN BorrowerAge ba ON ba.AcctNbr = acc.ACCTNBR
LEFT JOIN OSIBANK.PERS p2 ON acc.TAXRPTFORPERSNBR = p2.PERSNBR
LEFT JOIN PHONEMETADATA pmd ON taxpers.PERSNBR = pmd.PERSNBR
LEFT JOIN EMAILMETADATA emd ON taxpers.PERSNBR = emd.PERSNBR
WHERE acc.MJACCTTYPCD IN ('CNS', 'MLN', 'MTG')
AND acc.CURRMIACCTTYPCD IN ('HE01', 'FE01', 'MF01', 'FE02', 'FNMA', 'FRML', 'FRMH', 'MPFR', 'MJ30', 'HM01', 'HM02',
'MF10', 'HM03', 'HM04', 'DEF3', 'ML01', 'ML03', 'MJ03', 'MJ05', 'MJ07', 'MF15', 'MF20', 'MF30', 'MC93', 'MA55', 'MS30',
'MS10', 'MS15', 'MS20', 'MS40', 'MC09', 'ML02', 'MA01', 'MP05', 'MA05', 'MC01', 'MI05', 'MC03', 'MJ55', 'MC91', 'MF40',
'MS05', 'MS07', 'MI03', 'MA03', 'MA07', 'MA27', 'ML23', 'ML21', 'MP25', 'MC21', 'MA21', 'MJ27', 'HM05', 'MA23', 'MA25',
'MI25', 'MJ23', 'MJ25')
AND (a.ACTVTYPCD = 'ADAC' OR a.ACTVTYPCD = 'LADD')
AND LOWER(sa.TABLEID) = 'acct'
AND LOWER(sa.COLUMNID) = 'acctnbr'
AND a.ACTVNBR > TO_NUMBER(COALESCE(:afterActivityNbr, '-1'))
AND a.ACTVDATETIME >= TO_TIMESTAMP(COALESCE(:newerThanDateTime, '0001-01-01 00:00:00'), 'YYYY-MM-DD HH24:MI:SS')
@@ -0,0 +1,164 @@
/*New Vehicle Account Sale Query
----------------------------------
DESCRIPTION:
Get all Activities related to New Mortgage Accounts (ActvType = AADD and AccountType = ('FE01', 'MF01', 'FE02', 'FLML')
after a supplied DateTime (inclusive) or after a supplied ActivityNumber (not inclusive) or both.
Supplies Activity Data as well as the Account Number of the new account and the account status at the time of querying
RETURNS: Models/Activity/NewCheckingAccountActivity.cs
PARAMS:
|afterActivityNbr : Null or Int (as string)
|------------------------------------------------------------------------------
|Returns all Checking Sales with ActivityNbrs larger than the supplied number.
|If null defaults to -1 which will return all Checking SalesActivities
|newerThanDateTime : Null or Datetime in format 'YYYY-MM-DD HH24:MI:SS' (as string)
|-----------------------------------------------------------------------------
|Returns all Checking Sales with ActivityNbrs that occured on or after the supplied date
|If null defaults to '0001-01-01 00:00:00' which is oracles MIN Date time, this effectively
|returns all Checking Sales Activities
Potential Types: DLxx may be added in the future
'BE21','DL01','DL06','DL07','DL08','DL09','DL10','DL11','DL12','DL13','DL14','DL16','DV01','DV02','DV03','DV04','DV05','DV06','DV07','DV08',
NOTES:
- See Mortgage Loan Notes
-Only need to know if an account has debt protection not how many debt protection policies the account has. We select the earliest sold
debt protection and add the date and type to signify that the loan has debt protection
- LADD type activities seem to produce duplicates occasionally, None were found for vehicle type accounts
*/
WITH EmployeeEmail AS (
SELECT
p.PERSNBR As CorePersNbr,
addr.TEXT AS EmployeeEmail
FROM
OSIBANK.PERSEMPL p
JOIN OSIBANK.PERSADDRUSE paddr ON
p.PERSNBR = PADDR.PERSNBR
JOIN OSIBANK.ADDRLINE addr ON
paddr.ADDRNBR = addr.ADDRNBR
AND paddr.ADDRUSECD = 'EBUS'
),
OriginatorRole AS (
SELECT ACCTNBR, PERSNBR, ACCTROLECD, DATELASTMAINT, EFFDATE from OSIBANK.ACCTACCTROLEPERS a
WHERE ACCTROLECD = 'OEMP'
GROUP BY ACCTNBR, ACCTROLECD, DATELASTMAINT, EFFDATE, PERSNBR
HAVING DATELASTMAINT = MAX(DATELASTMAINT)
),
OriginalBalance AS (
--This assumes there is only 1 Note/Bal sub account for every account
--So far that has been true.
SELECT ACCTNBR, ORIGBAL FROM OSIBANK.ACCTSUBACCT a2
WHERE a2.BALCATCD = 'NOTE' AND a2.BALTYPCD = 'BAL'
),
DebtProtection AS (
SELECT
a.ACCTNBR,
MIN(var.CALCTYPEFFDATE) AS EffectiveDate,
a.BALCATCD
FROM OSIBANK.ACCTSUBACCT a
INNER JOIN (
SELECT ACCTNBR, MAX(SUBACCTNBR) AS SUBACCTNBR FROM OSIBANK.ACCTSUBACCT sa
WHERE sa.BALTYPCD = 'SINS'
GROUP BY ACCTNBR
) b ON a.ACCTNBR = b.ACCTNBR AND a.SUBACCTNBR = b.SUBACCTNBR
INNER JOIN OSIBANK.ACCTSUBACCTCALCVAR var ON var.ACCTNBR = a.ACCTNBR AND a.SUBACCTNBR = var.SUBACCTNBR
GROUP BY a.ACCTNBR, var.CALCTYPEFFDATE, a.BALCATCD
),
BorrowerAge AS (
SELECT a.ACCTNBR, MAX(p.DATEBIRTH) AS YoungestBirthdate FROM OSIBANK.ACCTACCTROLEPERS a
LEFT JOIN OSIBANK.ACCT acc ON a.ACCTNBR = acc.ACCTNBR
LEFT JOIN OSIBANK.ACCTROLE r ON r.ACCTROLECD = a.ACCTROLECD
LEFT JOIN OSIBANK.PERS p ON a.PERSNBR = p.PERSNBR
WHERE a.ACCTROLECD IN ('TRO','NTO','SIGN') AND (p.DATEDEATH IS NULL OR p.DATEDEATH > acc.CONTRACTDATE)
GROUP BY a.ACCTNBR
),
PHONEMETADATA AS (
SELECT
p.PERSNBR,
LISTAGG((pp.AREACD || pp.EXCHANGE || pp.PHONENBR),',') AS PhoneNumbers
FROM OSIBANK.PERS p
LEFT JOIN OSIBANK.PERSPHONE pp ON p.PERSNBR = pp.PERSNBR AND pp.PHONEUSECD != 'BUS'
GROUP BY p.PERSNBR
),
EMAILMETADATA AS (
SELECT
p.PERSNBR,
LISTAGG(al.TEXT,',') AS EmailAddresses
FROM OSIBANK.PERS p
LEFT JOIN OSIBANK.PERSADDRUSE pa ON p.PERSNBR = pa.PERSNBR AND pa.ADDRUSECD IN ('EHOM','EML')
LEFT JOIN OSIBANK.ADDRLINE al ON pa.ADDRNBR = al.ADDRNBR AND al.LINENBR = 1
GROUP BY p.PERSNBR
)
SELECT
a.ACTVNBR AS ActivityNbr,
a.ACTVDATETIME AS ActivityDateTime,
a.SUBJACCTNBR AS SubjectAccountNbr,
a.RESPPERSNBR AS ActivityResponsiblePersonNbr,
oe.PERSNBR AS OriginatingPersonNbr,
a.ACTVTYPCD AS ActivityTypeCode,
p.FIRSTNAME AS AssociateFirst,
p.LASTNAME AS AssociateLast,
p.MDLINIT AS AssociateMiddleInit,
--NEW = "New" | REFI = "Refinance"
ob.OrigBal AS LoanAmount,
al.LOANSOURCECD AS LoanSourceCode,
--ABS(r.TRANAMT) AS LoanDispersalAmmount,
ee.EmployeeEmail AS EmployeeEmail,
acc.CURRACCTSTATCD AS CurrentAccountStatus,
acc.TAXRPTFORPERSNBR AS TaxPersonNbr,
acc.TAXRPTFORORGNBR AS TaxOrgNbr,
CASE WHEN acc.TAXRPTFORPERSNBR IS NOT NULL THEN CONCAT(CONCAT(TAXPERS.LASTNAMEUPPER, ','),TAXPERS.FIRSTNAMEUPPER) ELSE NULL END AS TaxPersonName,
TAXORG.ORGNAME AS TaxOrgName,
acc.BranchOrgNbr As BranchOrgNbr,
acc.MjAcctTypCd AS MajorAccountType,
acc.CURRMIACCTTYPCD AS MinorAccountType,
acc.CONTRACTDATE AS AccountContractDate,
org.ORGNAME AS BranchOrgName,
dp.EffectiveDate AS DebtProtectionEffectiveDate,
dp.BALCATCD AS DebtProtectionCategory,
CASE
WHEN
ba.YOUNGESTBIRTHDATE IS NOT NULL AND
p2.DATEBIRTH IS NOT NULL
THEN
GREATEST(ba.YoungestBirthdate, p2.DATEBIRTH)
ELSE
COALESCE (ba.YoungestBirthdate, p2.DATEBIRTH)
END AS YoungestBirthdateOnLoan,
CASE
WHEN
acc.ACCTNBR IN (
SELECT acctnbr FROM OSIBANK.ACCTACCTROLEORG aro
Where aro.ACCTROLECD IN ('DBA', 'LLC','UNAS')
) OR
acc.TAXRPTFORORGNBR IS NOT NULL
THEN 1
ELSE 0
END AS HasOrgRoles,
pmd.PhoneNumbers AS TaxPersonPhoneNumbers,
emd.EmailAddresses AS TaxPersonEmailAddresses
FROM OSIBANK.ACTV a
JOIN OSIBANK.ACCT acc ON acc.ACCTNBR = a.SUBJACCTNBR
LEFT JOIN OriginatorRole oe ON acc.ACCTNBR = oe.AcctNbr
LEFT JOIN OSIBANK.PERS p ON p.PERSNBR = oe.PERSNBR
LEFT JOIN OSIBANK.PERS taxpers ON acc.TAXRPTFORPERSNBR = TAXPERS.PERSNBR
LEFT JOIN OSIBANK.ORG taxorg ON acc.TAXRPTFORORGNBR = TAXORG.ORGNBR
JOIN OSIBANK.ORG org ON org.ORGNBR = acc.BRANCHORGNBR
LEFT JOIN EmployeeEmail ee ON p.PERSNBR = ee.CorePersNbr
--Uncomment to get Loan Dispersal Transaction Information
--LEFT JOIN OSIBANK.RTXN r ON acc.ACCTNBR = r.ACCTNBR AND r.RTXNTYPCD = 'NDSB'
LEFT JOIN OSIBANK.ACCTLOAN al ON acc.ACCTNBR = al.ACCTNBR
LEFT JOIN OriginalBalance ob ON ob.AcctNbr = acc.ACCTNBR
LEFT JOIN DebtProtection dp ON dp.ACCTNBR = acc.ACCTNBR
LEFT JOIN OSIBANK.ACTVSUBACTV sa ON sa.ACTVNBR = a.ACTVNBR
LEFT JOIN BorrowerAge ba ON ba.AcctNbr = acc.ACCTNBR
LEFT JOIN OSIBANK.PERS p2 ON acc.TAXRPTFORPERSNBR = p2.PERSNBR
LEFT JOIN PHONEMETADATA pmd ON taxpers.PERSNBR = pmd.PERSNBR
LEFT JOIN EMAILMETADATA emd ON taxpers.PERSNBR = emd.PERSNBR
WHERE
acc.MJACCTTYPCD IN ('CNS','CML')
AND acc.CURRMIACCTTYPCD IN ('BE21','DV01','DV02','DV03','DV04','DV05','DV06','DV07','DV08')
AND (a.ACTVTYPCD = 'ADAC' OR a.ACTVTYPCD = 'LADD') AND LOWER(sa.TABLEID) = 'acct' AND LOWER(sa.COLUMNID) = 'acctnbr'
AND a.ACTVNBR > TO_NUMBER(COALESCE( :afterActivityNbr, '-1'))
AND a.ACTVDATETIME >= TO_TIMESTAMP(COALESCE(:newerThanDateTime, '0001-01-01 00:00:00'), 'YYYY-MM-DD HH24:MI:SS')
@@ -0,0 +1,80 @@
/*
CUSTOM FIELD INFO (ActivityManager.LF_LEAD_CUSTOM):
Credit Card Balance Transfer
--LeadCust_39 = External CC Account Number
--LeadCust_31 = Landmark Credit Card Number
--LeadCust_29 = Transfer Ammount
--LeadCust_28 = Payment State + Zip
--LeadCust_27 = Payment City
--LeadCust_26 = Payment Address Line 1
--LeadCust_24 = Transfer Institution
Direct Deposit
--LeadCust_38 = Direct Deposit is Qualified Referral
--LeadCust_4 = Direct Deposit Account Number
*/
WITH EmployeeEmail AS (
SELECT pers.USERID AS SafUserId,
prod.PERSNBR AS SafPersNbr,
prod.PRODPERSID AS CorePersNbr,
addr.TEXT AS EmployeeEmail
FROM SAF.PERSUSER pers
JOIN SAF.PERSPROD prod ON
pers.PERSNBR = PROD.PERSNBR
AND prod.PRODNBR = '3'
JOIN OSIBANK.PERSADDRUSE paddr ON
prod.PRODPERSID = PADDR.PERSNBR
JOIN OSIBANK.ADDRLINE addr ON
paddr.ADDRNBR = addr.ADDRNBR
AND paddr.ADDRUSECD = 'EBUS'
)
SELECT ll.ID AS ActivityId,
-- These custom fields can be reused, guarentee their contents by only using them for their respective campaigns
(CASE WHEN ll.CAMPAIGN = 'CC Balance Transfer' THEN llc.LEADCUST_31 ELSE NULL END) AS LandmarkCreditCardNumber,
(CASE WHEN ll.CAMPAIGN = 'Direct Deposit' THEN llc.LEADCUST_4 ELSE NULL END) AS DirectDepositAccountNumber,
ll.ORIGINATOR AS OriginatorUserId,
safprod.PRODPERSID AS OriginatorPersNbr,
p.FIRSTNAME AS OriginatorFirstName,
p.LASTNAME AS OriginatorLastName,
p.MDLINIT AS OriginatorMiddleInitial,
ee.EmployeeEmail AS EmployeeEmail,
ll.CAMPAIGN AS Campaign,
ll.CATEGORY AS Category,
ll.STATION AS ReferralStation,
ll.DATELASTMAINT AS LastUpdatedDateTime,
(CASE WHEN att.INITIAL_STATION = 'Yes' THEN 1 ELSE 0 END) AS IsInitialStation,
(CASE WHEN att.FINAL_STATION = 'Yes' THEN 1 ELSE 0 END) AS IsFinalStation,
att.ACTIVITY_ORIGINATION_DATE AS OriginationDateTime,
att.ENTER_STATION_DATETIME AS StationDateTime,
ll.SOURCE AS OriginatingBranchName,
(CASE
WHEN SUBSTR(lp.EXTID3, 1, 1) = 'P' THEN REGEXP_SUBSTR(lp.EXTID3, '\d+')
ELSE NULL END
) AS ReferredPersonNbr,
(CASE
WHEN SUBSTR(lp.EXTID3, 1, 1) = 'O' THEN REGEXP_SUBSTR(lp.EXTID3, '\d+')
ELSE NULL END
) AS ReferredOrgNbr,
lp.EXTID3 AS ReferredPersOrgNbr
FROM ACTIVITYMANAGER.LF_LEAD ll
JOIN ACTIVITYMANAGER.LF_LEAD_CUSTOM llc ON
ll.ID = llc.ID
JOIN SAF.PERSUSER safp ON
safp.USERID = ll.ORIGINATOR
JOIN SAF.PERSPROD safprod ON
SAFPROD.PERSNBR = safp.PERSNBR AND
SAFPROD.PRODNBR = '3'
JOIN OSIBANK.PERS p ON
p.PERSNBR = SAFPROD.PRODPERSID
LEFT JOIN EmployeeEmail ee ON
ee.SafPersNbr = SAFP.PERSNBR
JOIN ACTIVITYMANAGER.LF_PERSON lp ON
lp.ID = ll.PERSONID
JOIN ACTIVITYMANAGER.ACTIVITY_TIME_TRACKING att
ON att.ACTIVITY_ID = ll.ID AND SEQUENCE_NUMBER = (
SELECT MAX(SEQUENCE_NUMBER)
FROM ACTIVITYMANAGER.ACTIVITY_TIME_TRACKING att2
WHERE att2.ACTIVITY_ID = ll.ID
)
WHERE ll.Id IN :activityIds
@@ -0,0 +1,43 @@
With PhoneMetaData as (
Select p.persnbr, ListAgg((pp.areacd || pp.exchange || pp.phonenbr), ',') As PhoneNumbers
From Osibank.Pers p
Left Join Osibank.PersPhone pp on p.persnbr = pp.persnbr and pp.phoneusecd != 'BUS'
Group By p.persnbr
),
EmailMetaData as (
Select p.persnbr, ListAgg(al.text, ',') As EmailAddresses
From Osibank.Pers p
Left Join Osibank.PersAddrUse pa on p.persnbr = pa.persnbr and pa.ADDRUSECD IN ('EHOM', 'EML')
Left Join Osibank.AddrLine al on pa.addrnbr = al.addrnbr and al.linenbr = 1
Group By p.persnbr),
ActivityData as (
Select activity.subjacctnbr as AccountNumber, activity.actvnbr as ActivityNumber, activity.datelastmaint as ActivityDateTime
From (Select av.subjacctnbr, asv.actvnbr, asv.datelastmaint, ROW_NUMBER() Over (Partition by av.subjacctnbr Order by asv.datelastmaint asc) deliveryUpdate
From Osibank.ActvSubActv asv
Join Osibank.Actv av on asv.actvnbr = av.actvnbr
where (
asv.columnID = 'OvrDeliveryMethCd'
and asv.OldValue = 'PRNT'
and asv.databaseactvcd = 'UPD'
and asv.NewValue = 'WWW'
and asv.datelastmaint > TO_TIMESTAMP(:newerThanDateTime, 'YYYY-MM-DD HH24:MI:SS')
)
) activity
Where deliveryUpdate = 1 and activity.datelastmaint > TO_TIMESTAMP(:newerThanDateTime, 'YYYY-MM-DD HH24:MI:SS'))
Select ad.*, ma.shareacctnbr as ShareAccountNumber,
ma.primarypersnbr as PersonNumber,
ac.taxrptfororgnbr as OrganizationNumber,
ac.currmiaccttypcd as MinorAccountType,
pe.firstname as FirstName, pe.lastname as LastName,
pmd.phonenumbers, emd.emailaddresses
From Osibank.Acct ac
Join ActivityData ad on ad.AccountNumber = ac.acctnbr
Join Osibank.MemberAgreement ma on ma.shareacctnbr = ac.acctnbr
Join Osibank.Pers pe on pe.persnbr = ma.primarypersnbr
Left Join PhoneMetaData pmd on pe.persnbr = pmd.persnbr
Left Join EmailMetaData emd on pe.persnbr = emd.persnbr
where ac.OvrDeliveryMethCd = 'WWW'
@@ -0,0 +1,38 @@
/*ActivityAccountDetailsByAccountNbr
-----------------------------------
Get Account Details that are used by Activities. Used to Re-query accounts to check for
relevant account fields changes.
--Notes
It is expected that this will grow over time and require joining on more fields, it is therefore kept separate from
a more generic account query.
*/
WITH DebtProtection AS (
SELECT a.ACCTNBR,
MAX(var.CALCTYPEFFDATE) AS EffectiveDate,
MAX(var.CALCINACTIVEDATE) AS InactiveDate,
a.BALCATCD AS DPCategory
FROM OSIBANK.ACCTSUBACCT a
INNER JOIN (
SELECT sa.ACCTNBR, sa.SUBACCTNBR AS SUBACCTNBR
FROM OSIBANK.ACCTSUBACCT sa
WHERE sa.BALTYPCD = 'SINS'
GROUP BY ACCTNBR, sa.SUBACCTNBR
) b ON a.ACCTNBR = b.ACCTNBR AND a.SUBACCTNBR = b.SUBACCTNBR
INNER JOIN OSIBANK.ACCTSUBACCTCALCVAR var ON a.ACCTNBR = var.ACCTNBR AND a.SUBACCTNBR = var.SUBACCTNBR
GROUP BY a.ACCTNBR, var.CALCTYPEFFDATE, var.CALCINACTIVEDATE, a.BALCATCD
)
SELECT acc.ACCTNBR AS AccountNumber,
acc.CURRACCTSTATCD AS CurrentAccountStatus,
acc.TAXRPTFORPERSNBR AS TaxPersonNbr,
acc.TAXRPTFORORGNBR AS TaxOrgNbr,
acc.BRANCHORGNBR As BranchOrgNbr,
acc.MJACCTTYPCD AS MajorAccountType,
acc.CURRMIACCTTYPCD AS MinorAccountType,
acc.CONTRACTDATE AS AccountContractDate,
dp.EffectiveDate AS DebtProtectionEffectiveDate,
dp.InactiveDate AS DebtProtectionInactiveDate,
dp.DPCategory AS DebtProtectionCategory
FROM OSIBANK.ACCT acc
LEFT JOIN DebtProtection dp ON dp.ACCTNBR = acc.ACCTNBR
WHERE acc.ACCTNBR IN :accountNumbers
@@ -0,0 +1,5 @@
SELECT ap.AgreeNbr AS AgreeNumber,
ap.PersNbr AS PersonNumber,
ap.UserId
FROM OSIBANK.agreepers ap
WHERE ap.UserId = :userId
@@ -0,0 +1,10 @@
select AP.USERID As UserId,
AP.PERSNBR As PersonNumber,
AG.AGREENBR As AgreeNumber
FROM OSIBANK.AGREE AG
INNER JOIN OSIBANK.AGREEPERS AP ON AP.AGREENBR=AG.AGREENBR AND
AP.ACTIVEYN='Y'
INNER JOIN OSIBANK.AGREEPERSACCESSTYP APAT ON APAT.AGREENBR=AP.AGREENBR AND
APAT.PERSNBR=AP.PERSNBR AND
APAT.ACCESSTYPCD='WWW'
WHERE AP.USERID LIKE '%-%'
@@ -0,0 +1,12 @@
select distinct
a.primarypersnbr AS PersonNumber
from memberagreement a
JOIN PERS b ON a.PRIMARYPERSNBR = b.PERSNBR
JOIN ACCT c ON b.PERSNBR = c.TAXRPTFORPERSNBR AND a.MEMBERAGREENBR = c.MEMBERAGREENBR
JOIN acctacctrolepers d ON c.acctnbr = d.ACCTNBR
JOIN PERS g ON d.PERSNBR = g.PERSNBR
JOIN AGREEPERSACCESSTYPACCT e ON e.ACCTNBR = c.acctnbr and e.PERSNBR = c.taxrptforpersnbr
JOIN AGREEPERSACCESSTYP f ON e.AGREENBR = f.AGREENBR
LEFT JOIN osibank.CARDAGREEMENT ca ON b.PERSNBR = ca.OWNERPERSNBR AND ca.AGREETYPCD = 'VRU'
WHERE d.acctrolecd in ('CUST','GUAD','REPP','PREP','VAFI')
AND activeyn = 'Y'
@@ -0,0 +1,15 @@
select distinct
ca.agreenbr AS AgreeNumber,
a.PRIMARYPERSNBR AS PersonNumber,
f.UserId AS UserId
from memberagreement a
JOIN PERS b ON a.PRIMARYPERSNBR = b.PERSNBR
JOIN ACCT c ON b.PERSNBR = c.TAXRPTFORPERSNBR AND a.MEMBERAGREENBR = c.MEMBERAGREENBR
JOIN acctacctrolepers d ON c.acctnbr = d.ACCTNBR
JOIN PERS g ON d.PERSNBR = g.PERSNBR
JOIN AGREEPERSACCESSTYPACCT e ON e.ACCTNBR = c.acctnbr and e.PERSNBR = c.taxrptforpersnbr
JOIN AGREEPERSACCESSTYP f ON e.AGREENBR = f.AGREENBR
INNER JOIN osibank.CARDAGREEMENT ca ON b.PERSNBR = ca.OWNERPERSNBR AND ca.AGREETYPCD = 'VRU'
INNER JOIN osibank.CARDMEMBERISSUE cmi ON cmi.AGREENBR = ca.AGREENBR
WHERE d.acctrolecd in ('CUST','GUAD','REPP','PREP','VAFI')
AND cmi.currstatuscd != 'CLOS'
@@ -0,0 +1,5 @@
select ap.AgreeNbr,
ap.PersNbr,
ap.UserId
from OSIBANK.agreepers ap
fetch first :fetchAmount rows only
@@ -0,0 +1,38 @@
SELECT A.ACCTNBR AS AccountNumber,
COALESCE(Y.AGREENBR,Z.AGREENBR) AS AgreeNumber,
CAST(TRIM(COALESCE(Y.USERID,Z.USERID,CASE WHEN A.MEMBERAGREENBR IS NULL THEN NULL ELSE 'M'||A.MEMBERAGREENBR END)) AS VARCHAR2(32)) AS UserId
FROM OSIBANK.ACCT A
LEFT JOIN (/*FIND PPL WHO HAVE ACCESS TO ACCT AS WWW AND ARE ACTIVE(IN TWO TABLES), BREAK TIES WITH LOWEST AGREENBR*/
SELECT ROW_NUMBER() OVER (PARTITION BY APATA.ACCTNBR,APATA.PERSNBR ORDER BY APATA.AGREENBR) AS ID,
APATA.ACCTNBR,
APATA.PERSNBR,
AP.USERID,
AG.AGREENBR
FROM OSIBANK.AGREE AG /*[PK:AGREENBR]*/
INNER JOIN OSIBANK.AGREEPERS AP ON AP.AGREENBR=AG.AGREENBR
AND AP.ACTIVEYN='Y' /*[PK:AGREENBR, PERSNBR] [NEEDS TO BE ACTIVE]*/
INNER JOIN OSIBANK.AGREEPERSACCESSTYP APAT ON APAT.AGREENBR=AP.AGREENBR
AND APAT.PERSNBR=AP.PERSNBR
AND APAT.ACCESSTYPCD='WWW'
AND APAT.ACTIVEYN='Y' /*[PK:AGREENBR, PERSNBR, ACCESSTYPCD('WWW')] [NEEDS TO BE ACTIVE]*/
INNER JOIN OSIBANK.AGREEPERSACCESSTYPACCT APATA ON APATA.AGREENBR=AP.AGREENBR
AND APATA.PERSNBR=AP.PERSNBR
AND APATA.ACCESSTYPCD=APAT.ACCESSTYPCD /*[PK:AGREENBR, PERSNBR, ACCESSTYPCD('WWW'), ACCTNBR]*/
) Y ON Y.ACCTNBR=A.ACCTNBR AND Y.PERSNBR=A.TAXRPTFORPERSNBR AND Y.ID=1
LEFT JOIN (/*FIND PPL WHO HAVE ACCESS TO ORG AS WWW AND ARE ACTIVE(IN TWO TABLES), BREAK TIES WITH PERSON WHO IS CURRENTLY ACTIVE, WAS ACTIVE FIRST, LOWEST AGREENBR, LOWEST PERSNBR*/
SELECT ROW_NUMBER() OVER (PARTITION BY AG.BYORGNBR ORDER BY CASE WHEN RO.EFFDATE<=TRUNC(CURRENT_DATE) AND (RO.INACTIVEDATE IS NULL OR RO.INACTIVEDATE>TRUNC(CURRENT_DATE)) THEN 0 ELSE 1 END,RO.EFFDATE,AG.AGREENBR,AP.PERSNBR) AS ID,
AG.BYORGNBR,
AP.USERID,
AG.AGREENBR
FROM OSIBANK.AGREE AG /*[PK:AGREENBR]*/
INNER JOIN OSIBANK.AGREEPERS AP ON AP.AGREENBR=AG.AGREENBR
AND AP.ACTIVEYN='Y' /*[PK:AGREENBR, PERSNBR] [NEEDS TO BE ACTIVE]*/
INNER JOIN OSIBANK.AGREEPERSACCESSTYP APAT ON APAT.AGREENBR=AP.AGREENBR
AND APAT.PERSNBR=AP.PERSNBR
AND APAT.ACCESSTYPCD='WWW'
AND APAT.ACTIVEYN='Y' /*[PK:AGREENBR, PERSNBR, ACCESSTYPCD('WWW')] [NEEDS TO BE ACTIVE]*/
LEFT JOIN OSIBANK.ORGPERSROLE RO ON RO.ORGNBR=AG.BYORGNBR
AND RO.PERSNBR=AP.PERSNBR
AND RO.PERSROLECD=APAT.ACCESSTYPCD /*[PK:ORGNBR, PERSROLECD, EFFDATE, PERSNBR]*/
) Z ON Z.BYORGNBR=A.TAXRPTFORORGNBR AND Z.ID=1
WHERE A.ACCTNBR in ({AccountNumbersHolder})
@@ -0,0 +1,8 @@
SELECT AP.USERID
FROM OSIBANK.AGREE AG /*[PK:AGREENBR]*/
INNER JOIN OSIBANK.AGREEPERS AP ON AP.AGREENBR=AG.AGREENBR AND AP.ACTIVEYN='Y' /*[PK:AGREENBR, PERSNBR] [NEEDS TO BE ACTIVE]*/
INNER JOIN OSIBANK.AGREEPERSACCESSTYP APAT ON APAT.AGREENBR=AP.AGREENBR AND APAT.PERSNBR=AP.PERSNBR AND APAT.ACCESSTYPCD='WWW' AND APAT.ACTIVEYN='Y' /*[PK:AGREENBR, PERSNBR, ACCESSTYPCD('WWW')] [NEEDS TO BE ACTIVE]*/
LEFT JOIN OSIBANK.ORGPERSROLE RO ON RO.ORGNBR=AG.BYORGNBR AND RO.PERSNBR=AP.PERSNBR AND RO.PERSROLECD=APAT.ACCESSTYPCD /*[PK:ORGNBR, PERSROLECD, EFFDATE, PERSNBR]*/
WHERE AG.BYORGNBR = :organizationNumber
ORDER BY ROW_NUMBER() OVER (PARTITION BY AG.BYORGNBR ORDER BY CASE WHEN RO.EFFDATE<=CURRENT_DATE AND (RO.INACTIVEDATE IS NULL OR RO.INACTIVEDATE>CURRENT_DATE) THEN 0 ELSE 1 END,RO.EFFDATE,AG.AGREENBR,AP.PERSNBR)
FETCH NEXT 1 ROWS ONLY
@@ -0,0 +1,5 @@
SELECT AP.USERID
FROM OSIBANK.AGREE AG /*[PK:AGREENBR]*/
INNER JOIN OSIBANK.AGREEPERS AP ON AP.AGREENBR=AG.AGREENBR AND AP.ACTIVEYN='Y' /*[PK:AGREENBR, PERSNBR] [NEEDS TO BE ACTIVE]*/
INNER JOIN OSIBANK.AGREEPERSACCESSTYP APAT ON APAT.AGREENBR=AP.AGREENBR AND APAT.PERSNBR=AP.PERSNBR AND APAT.ACCESSTYPCD='WWW' AND APAT.ACTIVEYN='Y' /*[PK:AGREENBR, PERSNBR, ACCESSTYPCD('WWW')] [NEEDS TO BE ACTIVE]*/
WHERE AG.BYORGNBR IS NULL AND AP.PERSNBR = :personNumber

Some files were not shown because too many files have changed in this diff Show More