Skip to content

Commit

Permalink
CVSL-1606 Adding logging when prison staff modify conditions (#1522)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrlee authored Jan 22, 2024
1 parent 078373d commit b547252
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion server/routes/conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,16 @@ export default ({
const additional = additionalConditions ? conditionsService.formatConditionInputs(req.body) : {}
const newConditionsObject = conditionsService.createConditionsObjectForLicence(additional, bespoke)

await licenceService.updateLicenceConditions(
const updateOccurred = await licenceService.updateLicenceConditions(
bookingId,
res.locals.licence,
newConditionsObject,
res.locals.postRelease
)
if (updateOccurred) {
const { username, role } = req.user
logger.info(`conditions - updated conditions - ${username} - ${role} - ${bookingId}`)
}

const newVersion = conditionsServiceFactory.getNewVersion(res.locals.licence)

Expand Down Expand Up @@ -157,6 +161,8 @@ export default ({
const { action } = req.params

if (conditionId) {
const { username, role } = req.user
logger.info(`conditions - delete condition - ${username} - ${role} - ${bookingId}`)
await licenceService.deleteLicenceCondition(bookingId, res.locals.licence, conditionId)
}

Expand Down
6 changes: 3 additions & 3 deletions server/services/licenceService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ export class LicenceService {
const licenceConditions = { ...existingLicenceConditions, ...newConditionsObject }

if (equals(existingLicenceConditions, licenceConditions)) {
return null
return false
}

await this.updateModificationStage(bookingId, existingLicence.stage, { requiresApproval: true })

return await this.licenceClient.updateSection('licenceConditions', bookingId, licenceConditions, postRelease)
await this.licenceClient.updateSection('licenceConditions', bookingId, licenceConditions, postRelease)
return true
} catch (error) {
logger.error('Error during updateAdditionalConditions', error.stack)
throw error
Expand Down

0 comments on commit b547252

Please sign in to comment.