Skip to content

Commit

Permalink
Merge pull request #6000 from NMDSdevopsServiceAdm/fix/establishmentName
Browse files Browse the repository at this point in the history
remove the empty return for cssr
  • Loading branch information
Zuhal-Ayob authored Dec 4, 2023
2 parents 7e4df0e + 9b18adf commit f97c5f7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
25 changes: 16 additions & 9 deletions server/models/classes/establishment.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class Establishment extends EntityValidator {
this._pensionContribution = null;
this._sickPay = null;
this._recruitmentJourneyExistingUserBanner = false;
this._primaryAuthorityCssr = null;

// interim reasons for leaving - https://trello.com/c/vNHbfdms
this._reasonsForLeaving = null;
Expand Down Expand Up @@ -390,6 +391,9 @@ class Establishment extends EntityValidator {
return this._recruitmentJourneyExistingUserBanner;
}

get primaryAuthorityCssr() {
return this._primaryAuthorityCssr;
}
// used by save to initialise a new Establishment; returns true if having initialised this Establishment
_initialise() {
if (this._uid === null) {
Expand Down Expand Up @@ -607,6 +611,9 @@ class Establishment extends EntityValidator {
if ('recruitmentJourneyExistingUserBanner' in document) {
this._recruitmentJourneyExistingUserBanner = document.recruitmentJourneyExistingUserBanner;
}
if ('primaryAuthorityCssr' in document) {
this._primaryAuthorityCssr = document.primaryAuthorityCssr;
}
}

// allow for deep restoration of entities (associations - namely Worker here)
Expand Down Expand Up @@ -832,6 +839,7 @@ class Establishment extends EntityValidator {
pensionContribution: this._pensionContribution,
careWorkersLeaveDaysPerYear: this._careWorkersLeaveDaysPerYear,
recruitmentJourneyExistingUserBanner: this._recruitmentJourneyExistingUserBanner,
primaryAuthorityCssr: this._primaryAuthorityCssr,
};

// need to create the Establishment record and the Establishment Audit event
Expand Down Expand Up @@ -1033,6 +1041,7 @@ class Establishment extends EntityValidator {
pensionContribution: this._pensionContribution,
careWorkersLeaveDaysPerYear: this._careWorkersLeaveDaysPerYear,
recruitmentJourneyExistingUserBanner: bulkUploaded ? true : this._recruitmentJourneyExistingUserBanner,
primaryAuthorityCssr: this._primaryAuthorityCssr,
};

// Every time the establishment is saved, need to calculate
Expand Down Expand Up @@ -1293,7 +1302,6 @@ class Establishment extends EntityValidator {
}

const fetchResults = await models.establishment.findOne(fetchQuery);
console.log({ fetchResults: fetchResults });
if (fetchResults && fetchResults.id && Number.isInteger(fetchResults.id)) {
// update self - don't use setters because they modify the change state
this._isNew = false;
Expand Down Expand Up @@ -1348,6 +1356,8 @@ class Establishment extends EntityValidator {
this._pensionContribution = fetchResults.pensionContribution;
this._careWorkersLeaveDaysPerYear = fetchResults.careWorkersLeaveDaysPerYear;
this._careWorkersCashLoyaltyForFirstTwoYears = fetchResults.careWorkersCashLoyaltyForFirstTwoYears;

this._primaryAuthorityCssr = this.primaryAuthorityCssr;
// if history of the User is also required; attach the association
// and order in reverse chronological - note, order on id (not when)
// because ID is primay key and hence indexed
Expand Down Expand Up @@ -1517,16 +1527,13 @@ class Establishment extends EntityValidator {

const cssrResults = await models.pcodedata.getLinkedCssrRecordsFromPostcode(this._postcode);

if (!cssrResults || cssrResults.length == 0) {
console.log('Could not retrieve cssr record');
return {};
if (cssrResults.length > 0) {
fetchResults.primaryAuthorityCssr = {
id: cssrResults[0].cssrRecord.id,
name: cssrResults[0].cssrRecord.name,
};
}

fetchResults.primaryAuthorityCssr = {
id: cssrResults[0].cssrRecord.id,
name: cssrResults[0].cssrRecord.name,
};

if (fetchResults.auditEvents) {
this._auditEvents = fetchResults.auditEvents;
}
Expand Down
8 changes: 0 additions & 8 deletions server/services/establishment/establishment.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ const addEstablishment = async (req, res) => {
// gets requested establishment
// optional parameter - "history" must equal "none" (default), "property", "timeline" or "full"
const getEstablishment = async (req, res) => {
console.log('getEstablishment request');
const establishmentId = req.params.id;

const showHistory =
Expand All @@ -198,12 +197,6 @@ const getEstablishment = async (req, res) => {
const showPropertyHistoryOnly = req.query.history === 'property';

const thisEstablishment = new Establishment.Establishment(req.username);
console.log({
thisEstablishment: thisEstablishment,
establishmentId: establishmentId,
showHistory: showHistory,
history: req.query.history,
});
try {
if (await thisEstablishment.restore(establishmentId, showHistory && req.query.history !== 'property')) {
// the property based framework for "other services" and "capacity services"
Expand Down Expand Up @@ -231,7 +224,6 @@ const getEstablishment = async (req, res) => {
}
if (!jsonResponse.isParent && jsonResponse.parentUid !== null) {
const parentEstablishmentName = await thisEstablishment.fetchParentDetails(jsonResponse.parentUid);
console.log({ parentEstablishmentName: parentEstablishmentName });
if (parentEstablishmentName) {
jsonResponse.parentName = parentEstablishmentName.parentName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ export class WorkplaceInfoPanelComponent implements OnInit, OnDestroy {
event.preventDefault();

this.establishmentService.getEstablishment(this.workplace.uid).subscribe((data) => {
console.log({ workplaceDATA: data });
if (data.employerType == null) {
this.establishmentService.setEmployerTypeHasValue(false);
this.router.navigate(['/workplace', this.workplace.uid, 'type-of-employer']);
Expand Down

0 comments on commit f97c5f7

Please sign in to comment.