Skip to content

Instantly share code, notes, and snippets.

@ThomasKruegl
Last active September 18, 2019 14:02
Show Gist options
  • Save ThomasKruegl/a706ffb60ca8c75c9cd9b58f2b13f7ca to your computer and use it in GitHub Desktop.
Save ThomasKruegl/a706ffb60ca8c75c9cd9b58f2b13f7ca to your computer and use it in GitHub Desktop.
function getAccountStatusInfo(userPrimaryAccountTags, userPrimaryPartyTags, account_status) {
let accountStatus = [];
if (account_status === 'CLOSED') {
accountStatus.push('Closed');
}
const primaryStatus = getPrimaryStatusFromTags(userPrimaryAccountTags);
if (primaryStatus) {
accountStatus.push(primaryStatus);
}
if (userPrimaryPartyTags && userPrimaryPartyTags.indexOf('NoActvty') > -1) {
accountStatus.push('Inactive');
}
// If Account Tags, Party Tags and Limiation status are empty, the set the Account Status as Open
const status = accountStatus.length === 0 ? 'Open' : accountStatus.join(' - ');
return {
status,
restricted: isRestricted(userPrimaryAccountTags),
isAccountLocked: isAccountLocked(userPrimaryAccountTags)
};
}
function getPrimaryStatusFromTags(userPrimaryAccountTags) {
if (userPrimaryAccountTags) {
if (userPrimaryAccountTags.indexOf('OFAC_LCK') > -1) {
return 'Locked - Sanction List';
}
else if (userPrimaryAccountTags.indexOf('LOCKED') > -1) {
if (userPrimaryAccountTags.indexOf('ChargOff') > -1) {
return 'Locked - Charged-Off';
}
else {
return 'Locked';
}
}
else if (userPrimaryAccountTags.indexOf('RSTRCTD') > -1) {
if (userPrimaryAccountTags.indexOf('NO_RCV') > -1) {
return 'Limited High';
}
else {
return 'Limited';
}
}
else if (userPrimaryAccountTags.indexOf('RSTRT_NT') > -1) {
return 'Pending Limited';
}
//else if (limitationStatus && limitationStatus.hasWarnings) {
else if (userPrimaryAccountTags.indexOf('RstrWarn') > -1) {
return 'Warning';
}
}
}
function isRestricted(userPrimaryAccountTags) {
return !!userPrimaryAccountTags && ['RSTRT_NT','RSTRCTD','LOCKED'].some(str => userPrimaryAccountTags.includes(str));
}
function isAccountLocked(userPrimaryAccountTags) {
return !!userPrimaryAccountTags && userPrimaryAccountTags.includes('LOCKED');
}
console.log(getAccountStatusInfo());
console.log(getAccountStatusInfo("LOCKED"));
console.log(getAccountStatusInfo("RSTRCTD","NoActvty"));
console.log(getAccountStatusInfo("RSTRCTD"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment