Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ enum class LicensingType {
HMO_MANDATORY_LICENCE,
HMO_ADDITIONAL_LICENCE,
NO_LICENSING,
PROVIDE_LATER,
;

companion object {
val licencedEntries = entries.minus(NO_LICENSING)
val licencedEntries = entries.minus(NO_LICENSING).minus(PROVIDE_LATER)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class MessageKeyConverter {
LicensingType.HMO_MANDATORY_LICENCE -> "forms.licensingType.radios.option.hmoMandatory.label"
LicensingType.HMO_ADDITIONAL_LICENCE -> "forms.licensingType.radios.option.hmoAdditional.label"
LicensingType.NO_LICENSING -> "forms.checkPropertyAnswers.propertyDetails.noLicensing"
LicensingType.PROVIDE_LATER -> "forms.checkPropertyAnswers.propertyDetails.licensingProvideLater"
}

private fun convertOwnershipType(ownershipType: OwnershipType): String =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.Prope
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.ProvideElectricalCertLaterStep
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.ProvideEpcLaterStep
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.ProvideGasCertLaterStep
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.ProvideLicensingLaterStep
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RemoveElectricalCertUploadStep
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RemoveGasCertUploadStep
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RentAmountStep
Expand Down Expand Up @@ -605,6 +606,7 @@ class PropertyRegistrationJourney(
override val selectiveLicenceStep: SelectiveLicenceStep,
override val hmoMandatoryLicenceStep: HmoMandatoryLicenceStep,
override val hmoAdditionalLicenceStep: HmoAdditionalLicenceStep,
override val provideLicensingLaterStep: ProvideLicensingLaterStep,
// Occupation steps
override val occupied: OccupiedStep,
// Nested households and tenants task
Expand Down Expand Up @@ -748,6 +750,7 @@ class PropertyRegistrationJourney(
override var backUrlKey: Int? by delegateProvider.nullableDelegate("backUrlKey")

override val allowProvideCertificateLaterRoute: Boolean = true
override val allowProvideLicensingLaterRoute: Boolean = true

override fun generateJourneyId(seed: Any?): String {
val user = seed as? Principal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@ import uk.gov.communities.prsdb.webapp.constants.enums.LicensingType
import uk.gov.communities.prsdb.webapp.journeys.JourneyState
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HmoAdditionalLicenceStep
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HmoMandatoryLicenceStep
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.LicensingTypeMode
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.LicensingTypeStep
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.ProvideLicensingLaterStep
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.SelectiveLicenceStep

interface LicensingState : JourneyState {
val allowProvideLicensingLaterRoute: Boolean
val isOccupied: Boolean?

val licensingTypeStep: LicensingTypeStep
val selectiveLicenceStep: SelectiveLicenceStep
val hmoMandatoryLicenceStep: HmoMandatoryLicenceStep
val hmoAdditionalLicenceStep: HmoAdditionalLicenceStep
val provideLicensingLaterStep: ProvideLicensingLaterStep

fun getLicenceNumberOrNull(): String? =
when (licensingTypeStep.formModelOrNull?.licensingType) {
Expand All @@ -23,4 +29,14 @@ interface LicensingState : JourneyState {

fun getLicenceNumber(): String =
getLicenceNumberOrNull() ?: throw IllegalStateException("Licence number is not available for the current licensing type")

fun getLicensingType(): LicensingType =
when (val outcome = licensingTypeStep.outcome) {
LicensingTypeMode.SELECTIVE_LICENCE -> LicensingType.SELECTIVE_LICENCE
LicensingTypeMode.HMO_MANDATORY_LICENCE -> LicensingType.HMO_MANDATORY_LICENCE
LicensingTypeMode.HMO_ADDITIONAL_LICENCE -> LicensingType.HMO_ADDITIONAL_LICENCE
LicensingTypeMode.NO_LICENSING -> LicensingType.NO_LICENSING
LicensingTypeMode.PROVIDE_LATER -> LicensingType.PROVIDE_LATER
null -> throw IllegalStateException("Licensing type has not been provided")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,36 @@ package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps

import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.JourneyFrameworkComponent
import uk.gov.communities.prsdb.webapp.config.managers.FeatureFlagManager
import uk.gov.communities.prsdb.webapp.constants.CONTINUE_BUTTON_ACTION_NAME
import uk.gov.communities.prsdb.webapp.constants.PROPERTY_REGISTRATION_RESTRUCTURE_AND_SKIPPING
import uk.gov.communities.prsdb.webapp.constants.PROVIDE_THIS_LATER_BUTTON_ACTION_NAME
import uk.gov.communities.prsdb.webapp.constants.enums.LicensingType
import uk.gov.communities.prsdb.webapp.journeys.AbstractRequestableStepConfig
import uk.gov.communities.prsdb.webapp.journeys.JourneyState
import uk.gov.communities.prsdb.webapp.journeys.JourneyStep.RequestableStep
import uk.gov.communities.prsdb.webapp.journeys.UnrecoverableJourneyStateException
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.LicensingState
import uk.gov.communities.prsdb.webapp.models.requestModels.formModels.LicensingTypeFormModel
import uk.gov.communities.prsdb.webapp.models.viewModels.formModels.RadiosButtonViewModel
import uk.gov.communities.prsdb.webapp.models.viewModels.formModels.RadiosDividerViewModel

@JourneyFrameworkComponent
class LicensingTypeStepConfig(
private val featureFlagManager: FeatureFlagManager,
) : AbstractRequestableStepConfig<LicensingTypeMode, LicensingTypeFormModel, JourneyState>() {
) : AbstractRequestableStepConfig<LicensingTypeMode, LicensingTypeFormModel, LicensingState>() {
override val formModelClass = LicensingTypeFormModel::class

override fun getStepSpecificContent(state: JourneyState): Map<String, Any?> {
// TODO(PDJB-990): add a 'Provide this later' button to the licensing page behind the FF: pdjb-939-property-registration-restructure-and-skipping/PROPERTY_REGISTRATION_RESTRUCTURE_AND_SKIPPING
override fun getStepSpecificContent(state: LicensingState): Map<String, Any?> {
val showProvideThisLater =
state.allowProvideLicensingLaterRoute &&
featureFlagManager.checkFeature(PROPERTY_REGISTRATION_RESTRUCTURE_AND_SKIPPING)
return mapOf(
"fieldSetHeading" to "forms.licensingType.fieldSetHeading",
"fieldSetHint" to "forms.licensingType.fieldSetHint",
"submitButtonText" to "forms.buttons.saveAndContinue",
"showSecondarySubmitButton" to showProvideThisLater,
"submitButtonAction" to CONTINUE_BUTTON_ACTION_NAME,
"secondarySubmitButtonText" to "forms.buttons.provideThisLater",
"secondarySubmitButtonAction" to PROVIDE_THIS_LATER_BUTTON_ACTION_NAME,
"radioOptions" to
listOf(
RadiosButtonViewModel(
Expand All @@ -47,23 +58,39 @@ class LicensingTypeStepConfig(
)
}

override fun chooseTemplate(state: JourneyState): String = "forms/licensingTypeForm"
override fun chooseTemplate(state: LicensingState): String = "forms/licensingTypeForm"

override fun mode(state: JourneyState) =
getFormModelFromStateOrNull(state)?.licensingType?.let { licensingType ->
when (licensingType) {
LicensingType.SELECTIVE_LICENCE -> LicensingTypeMode.SELECTIVE_LICENCE
LicensingType.HMO_MANDATORY_LICENCE -> LicensingTypeMode.HMO_MANDATORY_LICENCE
LicensingType.HMO_ADDITIONAL_LICENCE -> LicensingTypeMode.HMO_ADDITIONAL_LICENCE
LicensingType.NO_LICENSING -> LicensingTypeMode.NO_LICENSING
override fun mode(state: LicensingState) =
getFormModelFromStateOrNull(state)?.let { formModel ->
if (formModel.action == PROVIDE_THIS_LATER_BUTTON_ACTION_NAME) {
if (state.allowProvideLicensingLaterRoute &&
featureFlagManager.checkFeature(PROPERTY_REGISTRATION_RESTRUCTURE_AND_SKIPPING)
) {
LicensingTypeMode.PROVIDE_LATER
} else {
throw UnrecoverableJourneyStateException(
state.journeyId,
"The 'Provide this later' route is not available for this journey",
)
}
} else {
formModel.licensingType?.let { licensingType ->
when (licensingType) {
LicensingType.SELECTIVE_LICENCE -> LicensingTypeMode.SELECTIVE_LICENCE
LicensingType.HMO_MANDATORY_LICENCE -> LicensingTypeMode.HMO_MANDATORY_LICENCE
LicensingType.HMO_ADDITIONAL_LICENCE -> LicensingTypeMode.HMO_ADDITIONAL_LICENCE
LicensingType.NO_LICENSING -> LicensingTypeMode.NO_LICENSING
LicensingType.PROVIDE_LATER -> LicensingTypeMode.PROVIDE_LATER
}
}
}
}
}

@JourneyFrameworkComponent
final class LicensingTypeStep(
stepConfig: LicensingTypeStepConfig,
) : RequestableStep<LicensingTypeMode, LicensingTypeFormModel, JourneyState>(stepConfig) {
) : RequestableStep<LicensingTypeMode, LicensingTypeFormModel, LicensingState>(stepConfig) {
companion object {
const val ROUTE_SEGMENT = "licensing-type"
}
Expand All @@ -74,4 +101,5 @@ enum class LicensingTypeMode {
HMO_MANDATORY_LICENCE,
HMO_ADDITIONAL_LICENCE,
NO_LICENSING,
PROVIDE_LATER,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps

import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.JourneyFrameworkComponent
import uk.gov.communities.prsdb.webapp.journeys.AbstractRequestableStepConfig
import uk.gov.communities.prsdb.webapp.journeys.JourneyStep.RequestableStep
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.LicensingState
import uk.gov.communities.prsdb.webapp.journeys.shared.Complete
import uk.gov.communities.prsdb.webapp.models.requestModels.formModels.NoInputFormModel

@JourneyFrameworkComponent
class ProvideLicensingLaterStepConfig : AbstractRequestableStepConfig<Complete, NoInputFormModel, LicensingState>() {
override val formModelClass = NoInputFormModel::class

override fun getStepSpecificContent(state: LicensingState) =
mapOf(
"submitButtonText" to if (state.isOccupied == true) "forms.buttons.continue" else "forms.buttons.saveAndContinue",
)

override fun chooseTemplate(state: LicensingState): String =
state.isOccupied?.let { isOccupied ->
if (isOccupied) "forms/provideLicensingLaterOccupiedForm" else "forms/provideLicensingLaterUnoccupiedForm"
} ?: throw IllegalStateException("ProvideLicensingLaterStep should not be reachable before isOccupied is set")

override fun mode(state: LicensingState) = getFormModelFromStateOrNull(state)?.let { Complete.COMPLETE }
}

@JourneyFrameworkComponent
final class ProvideLicensingLaterStep(
stepConfig: ProvideLicensingLaterStepConfig,
) : RequestableStep<Complete, NoInputFormModel, LicensingState>(stepConfig) {
companion object {
const val ROUTE_SEGMENT = "provide-licensing-later"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import uk.gov.communities.prsdb.webapp.journeys.JourneyStep
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.PropertyRegistrationJourneyState
import uk.gov.communities.prsdb.webapp.journeys.shared.Complete
import uk.gov.communities.prsdb.webapp.journeys.shared.YesOrNo
import uk.gov.communities.prsdb.webapp.models.requestModels.formModels.LicensingTypeFormModel
import uk.gov.communities.prsdb.webapp.models.requestModels.formModels.NewNumberOfPeopleFormModel
import uk.gov.communities.prsdb.webapp.models.requestModels.formModels.NumberOfBedroomsFormModel
import uk.gov.communities.prsdb.webapp.models.requestModels.formModels.NumberOfHouseholdsFormModel
Expand Down Expand Up @@ -71,7 +70,7 @@ class SavePropertyRegistrationDataStepConfig(
} else {
null
},
licenseType = state.licensingTypeStep.formModel.notNullValue(LicensingTypeFormModel::licensingType),
licenseType = state.getLicensingType(),
licenceNumber = state.getLicenceNumberOrNull() ?: "",
ownershipType = state.ownershipTypeStep.formModel.notNullValue(OwnershipTypeFormModel::ownershipType),
isOccupied = isOccupied,
Expand Down Expand Up @@ -141,6 +140,7 @@ class SavePropertyRegistrationDataStepConfig(
.formModelIfReachableOrNull
?.exemptionReason,
epcProvideLater = state.hasEpcStep.outcome == HasEpcMode.PROVIDE_LATER,
licenseProvideLater = state.licensingTypeStep.outcome == LicensingTypeMode.PROVIDE_LATER,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks

import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.JourneyFrameworkComponent
import uk.gov.communities.prsdb.webapp.config.managers.FeatureFlagManager
import uk.gov.communities.prsdb.webapp.journeys.OrParents
import uk.gov.communities.prsdb.webapp.journeys.Task
import uk.gov.communities.prsdb.webapp.journeys.hasOutcome
Expand All @@ -11,15 +10,13 @@ import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HmoAd
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HmoMandatoryLicenceStep
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.LicensingTypeMode
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.LicensingTypeStep
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.ProvideLicensingLaterStep
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.SelectiveLicenceStep

@JourneyFrameworkComponent
class LicensingTask(
private val featureFlagManager: FeatureFlagManager,
) : Task<LicensingState>() {
class LicensingTask : Task<LicensingState>() {
override fun makeSubJourney(state: LicensingState) =
subJourney(state) {
// TODO(PDJB-990): route to the 'provide details about licensing later' page when 'Provide this later' is selected behind the FF: pdjb-939-property-registration-restructure-and-skipping/PROPERTY_REGISTRATION_RESTRUCTURE_AND_SKIPPING

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we're not using the feature flag manager in this class - should we be? Or should it be removed?

step(journey.licensingTypeStep) {
routeSegment(LicensingTypeStep.ROUTE_SEGMENT)
nextStep { mode ->
Expand All @@ -28,6 +25,7 @@ class LicensingTask(
LicensingTypeMode.HMO_MANDATORY_LICENCE -> journey.hmoMandatoryLicenceStep
LicensingTypeMode.HMO_ADDITIONAL_LICENCE -> journey.hmoAdditionalLicenceStep
LicensingTypeMode.NO_LICENSING -> exitStep
LicensingTypeMode.PROVIDE_LATER -> journey.provideLicensingLaterStep
}
}
}
Expand All @@ -46,13 +44,20 @@ class LicensingTask(
parents { journey.licensingTypeStep.hasOutcome(LicensingTypeMode.HMO_ADDITIONAL_LICENCE) }
nextStep { exitStep }
}
step(journey.provideLicensingLaterStep) {
routeSegment(ProvideLicensingLaterStep.ROUTE_SEGMENT)
parents { journey.licensingTypeStep.hasOutcome(LicensingTypeMode.PROVIDE_LATER) }
nextStep { exitStep }
savable()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for this step being savable but the others aren't?

}
exitStep {
parents {
OrParents(
journey.licensingTypeStep.hasOutcome(LicensingTypeMode.NO_LICENSING),
journey.selectiveLicenceStep.isComplete(),
journey.hmoMandatoryLicenceStep.isComplete(),
journey.hmoAdditionalLicenceStep.isComplete(),
journey.provideLicensingLaterStep.isComplete(),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.Finis
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HmoAdditionalLicenceStep
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HmoMandatoryLicenceStep
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.LicensingTypeStep
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.ProvideLicensingLaterStep
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.SelectiveLicenceStep
import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.LicensingTask
import uk.gov.communities.prsdb.webapp.journeys.shared.states.CheckYourAnswersJourneyState
Expand Down Expand Up @@ -110,6 +111,7 @@ class UpdateLicensingJourney(
override val selectiveLicenceStep: SelectiveLicenceStep,
override val hmoMandatoryLicenceStep: HmoMandatoryLicenceStep,
override val hmoAdditionalLicenceStep: HmoAdditionalLicenceStep,
override val provideLicensingLaterStep: ProvideLicensingLaterStep,
// Check your answers step
override val cyaStep: UpdateLicensingCyaStep,
override val finishCyaStep: FinishCyaJourneyStep,
Expand All @@ -126,6 +128,9 @@ class UpdateLicensingJourney(

override var originalJourneyUpdated: Instant? by delegateProvider.nullableDelegate("originalJourneyUpdated")
override var cyaUrlPath: String? by delegateProvider.nullableDelegate("cyaRouteSegment")

override val allowProvideLicensingLaterRoute: Boolean = false
override val isOccupied: Boolean? = null
}

interface UpdateLicensingJourneyState :
Expand Down
Loading
Loading