Skip to content

Commit

Permalink
1351 character issues (#571)
Browse files Browse the repository at this point in the history
* added new indexes

* added indexes

* export character issues - added status and stage optional filters

* flagApplicationIssues - include applicationRecord.issues.characterIssues subcollection with char info v1 or v2 as appropriate instead of including the entire char info collection itself

* exportApplicationCharacterIssues - added more data to the export

* exclude membership data from export

* updated description of declaredBankruptOrIVA enum

* exportApplicationCharacterIssues - removed redundant code

* no message
  • Loading branch information
HalcyonJAC authored May 28, 2021
1 parent c971183 commit 0c7c390
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 110 deletions.
121 changes: 13 additions & 108 deletions functions/actions/exercises/exportApplicationCharacterIssues.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ module.exports = (firebase, db) => {
nationalInsuranceNumber: _.get(applicationRecord, 'application.personalDetails.nationalInsuranceNumber', ''),
citizenship: _.get(applicationRecord, 'application.personalDetails.citizenship', ''),
reasonableAdjustments: _.get(applicationRecord, 'application.personalDetails.reasonableAdjustmentsDetails', ''),
characterInformation: getCharacterInformationString(application),
characterInformation: getCharacterInformationString(applicationRecord, application),
...getEqualityAndDiversityData(application),
locationPreferences: getLocationPreferencesString(application),
jurisdictionPreferences: getJurisdictionPreferencesString(application),
Expand Down Expand Up @@ -180,122 +180,27 @@ module.exports = (firebase, db) => {
}).join('\r\n\r\n\r\n').trim();
}

function getCharacterInformationString(application) {
function getCharacterInformationString(applicationRecord, application) {
if (!application.progress || !application.progress.characterInformation) {
return ''; //If they haven't completed the section, skip it in the report.
}
let characterInfo = []; //Array - we'll join with line breaks as we return this information.
if (!application.characterInformation && !application.characterInformationV2) {
return '';
}
const info = application.characterInformationV2 || application.characterInformation;
if (info.bankruptcies) {
characterInfo.push(condenseOffenceDetails(info.bankruptcyDetails, 'Bankruptcies'));
}
if (info.complaintOrDisciplinaryAction) {
characterInfo.push(condenseOffenceDetails(info.complaintOrDisciplinaryActionDetails, 'Complaints or Disciplinary Actions'));
}
if (info.criminalCautions) {
characterInfo.push(condenseOffenceDetails(info.criminalCautionDetails, 'Criminal Cautions'));
}
if (info.criminalConvictions) {
characterInfo.push(condenseOffenceDetails(info.criminalConvictionDetails, 'Criminal Convictions'));
}
if (info.criminalOffences) {
characterInfo.push(condenseOffenceDetails(info.criminalOffenceDetails, 'Criminal Offences'));
}
if (info.declaredBankruptOrIVA) {
characterInfo.push(condenseOffenceDetails(info.declaredBankruptOrIVADetails, 'Declared Bankrupt or IVA'));
}
if (info.diciplinaryActionOrAskedToResign) {
characterInfo.push(condenseOffenceDetails(info.diciplinaryActionOrAskedToResignDetails, 'Disciplinary Action or Asked to Resign'));
}
if (info.drivingDisqualifications) {
characterInfo.push(condenseOffenceDetails(info.drivingDisqualificationDetails, 'Driving Disqualifications'));
}
if (info.drivingDisqualificationDrinkDrugs) {
characterInfo.push(condenseOffenceDetails(info.drivingDisqualificationDrinkDrugsDetails, 'Driving Disqualifications - Drink Or Drugs'));
}
if (info.endorsementsOrMotoringFixedPenalties) {
characterInfo.push(condenseOffenceDetails(info.endorsementsOrMotoringFixedPenaltiesDetails, 'Endorsements or Motoring Fixed Penalties'));
}
if (info.fixedPenalties) {
characterInfo.push(condenseOffenceDetails(info.fixedPenaltyDetails, 'Fixed Penalties'));
}
if (info.hmrcFines) {
characterInfo.push(condenseOffenceDetails(info.hmrcFineDetails, 'HMRC Fines'));
}
if (info.involvedInProfessionalMisconduct) {
characterInfo.push(condenseOffenceDetails(info.involvedInProfessionalMisconductDetails, 'Involved in Professional Misconduct'));
}
if (info.ivas) {
characterInfo.push(condenseOffenceDetails(info.ivaDetails, 'IVAs'));
}
if (info.lateTaxReturns) {
characterInfo.push(condenseOffenceDetails(info.lateTaxReturnDetails, 'Late Tax Returns'));
}
if (info.lateTaxReturnOrFined) {
characterInfo.push(condenseOffenceDetails(info.lateTaxReturnOrFinedDetails, 'Late Tax Returns Or Fines'));
}
if (info.lateVatReturns) {
characterInfo.push(condenseOffenceDetails(info.lateVatReturnDetails, 'Late VAT Returns'));
}
if (info.nonMotoringFixedPenaltyNotices) {
characterInfo.push(condenseOffenceDetails(info.nonMotoringFixedPenaltyNoticesDetails, 'Non Motoring Fixed Penalty Notices'));
}
if (info.recentDrivingConvictions) {
characterInfo.push(condenseOffenceDetails(info.recentDrivingConvictionDetails, 'Recent Driving Convictions'));
}
if (info.requestedToResign) {
characterInfo.push(condenseOffenceDetails(info.requestedToResignDetails, 'Requested to Resign'));
}
if (info.subjectOfAllegationOrClaimOfDiscriminationProceeding) {
characterInfo.push(condenseOffenceDetails(
info.subjectOfAllegationOrClaimOfDiscriminationProceedingDetails,
'Subject of Allegation or Claim of Discrimination'
));
}
if (info.subjectOfAllegationOrClaimOfHarassmentProceeding) {
characterInfo.push(condenseOffenceDetails(
info.subjectOfAllegationOrClaimOfHarassmentProceedingDetails,
'Subject of Allegation or Claim of Harassment'
));
}
if (info.subjectOfAllegationOrClaimOfNegligence) {
characterInfo.push(condenseOffenceDetails(
info.subjectOfAllegationOrClaimOfNegligenceDetails,
'Subject of Allegation or Claim of Negligence'
));
}
if (info.subjectOfAllegationOrClaimOfProfessionalMisconduct) {
characterInfo.push(condenseOffenceDetails(
info.subjectOfAllegationOrClaimOfProfessionalMisconductDetails,
'Subject of Allegation or Claim of Professional Misconduct'
));
}
if (info.subjectOfAllegationOrClaimOfWrongfulDismissal) {
characterInfo.push(condenseOffenceDetails(
info.subjectOfAllegationOrClaimOfWrongfulDismissalDetails,
'Subject of Allegation or Claim of Wrongful Dismissal'
));
}

if (info.otherCharacterIssues) {
characterInfo.push(condenseOffenceDetails(info.otherCharacterIssuesDetails, 'Other Character Issues'));
}
if (info.furtherInformation) {
characterInfo.push(condenseOffenceDetails(info.furtherInformationDetails, 'Further Information'));
}
return characterInfo.filter(Boolean).join('\r\n\r\n\r\n'); //Each separate section should have space in the cell between them.
return applicationRecord.issues.characterIssues.map((issue) => {
if (!issue.events || issue.events.length === 0) {
return '';
}
return issue.events.map((event) => {
return `${issue.summary.toUpperCase()}\r\n${swapDY(formatDate(event.date))} - ${event.title || ''}\r\n${event.details}`;
}).join('\r\n\r\n\r\n').trim(); //Each separate section should have space in the cell between them.
}).join('\r\n\r\n\r\n').trim(); //Each separate section should have space in the cell between them.
}

function condenseOffenceDetails(details, title) {
//Join the offence details into 'date - title <br> details <br><br>date - title <br>....'...etc
const offences = details.filter(Boolean).filter(d => (typeof d.details !== 'undefined')).map(detail => (`${formatDate(detail.date)}${typeof detail.title !== 'undefined' ? ` - ${detail.title}` : ''}\r\n${detail.details}`)).join('\r\n\r\n');
if (offences.length === 0) {
return false;
}
return `${title.toUpperCase()}\r\n${offences}`;
function swapDY(d) {
const parts = d.split('-');
return `${parts[2]}/${parts[1]}/${parts[0]}`;
}

function getPostQualificationExperienceString(application)
Expand Down
2 changes: 1 addition & 1 deletion functions/shared/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module.exports = {
declaredBankruptOrIVA: {
title: 'Declared Bankrupt Or IVA',
details: 'declaredBankruptOrIVADetails',
summary: 'Candidate has been convicted of a criminal offence',
summary: 'Candidate has been declared bankrupt or entered into an Individual Voluntary Agreement (IVA)',
},
diciplinaryActionOrAskedToResign: {
title: 'Disciplinary Action Or Asked To Resign',
Expand Down
2 changes: 1 addition & 1 deletion nodeScripts/shared/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module.exports = {
declaredBankruptOrIVA: {
title: 'Declared Bankrupt Or IVA',
details: 'declaredBankruptOrIVADetails',
summary: 'Candidate has been convicted of a criminal offence',
summary: 'Candidate has been declared bankrupt or entered into an Individual Voluntary Agreement (IVA)',
},
diciplinaryActionOrAskedToResign: {
title: 'Disciplinary Action Or Asked To Resign',
Expand Down

0 comments on commit 0c7c390

Please sign in to comment.