Skip to content

Commit

Permalink
Declared Value Commas (#1815)
Browse files Browse the repository at this point in the history
* Declared Value Commas

* revert flags
  • Loading branch information
cameron-eyds authored Apr 9, 2024
1 parent 3b03e2b commit edc06bf
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
31 changes: 19 additions & 12 deletions ppr-ui/src/components/mhrTransfers/TransferType.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<v-text-field
id="declared-value"
ref="declaredValueRef"
v-model.number="declaredValue"
v-model="declaredValue"
class="declared-value px-2"
variant="filled"
color="primary"
Expand Down Expand Up @@ -182,7 +182,8 @@ export default defineComponent({
} = storeToRefs(useStore())
const {
isJointTenancyStructure
isJointTenancyStructure,
hasGroupsWithPersonOwners
} = useTransferOwners()
const localState = reactive({
Expand All @@ -194,7 +195,7 @@ export default defineComponent({
declaredValueRules: computed((): Array<()=>string|boolean> => {
return customRules(
maxLength(7, true),
isNumber(),
isNumber(null, null, null, null, true),
getMhrTransferType.value?.transferType === ApiTransferTypes.TO_EXECUTOR_UNDER_25K_WILL
? greaterThan(25000,
transfersErrors.declaredHomeValueMax[ApiTransferTypes.TO_EXECUTOR_UNDER_25K_WILL])
Expand Down Expand Up @@ -267,14 +268,6 @@ export default defineComponent({
transferTypeForm.value?.resetValidation()
switch (val.transferType) {
case ApiTransferTypes.SALE_OR_GIFT:
case ApiTransferTypes.TO_EXECUTOR_PROBATE_WILL:
case ApiTransferTypes.TO_EXECUTOR_UNDER_25K_WILL:
case ApiTransferTypes.TO_ADMIN_NO_WILL:
localState.transferTypeRules = customRules(
required('Select transfer type')
)
break
case ApiTransferTypes.SURVIVING_JOINT_TENANT:
localState.transferTypeRules = customRules(
required('Select transfer type'),
Expand All @@ -284,8 +277,22 @@ export default defineComponent({
]
)
break
case ApiTransferTypes.TO_EXECUTOR_PROBATE_WILL:
case ApiTransferTypes.TO_EXECUTOR_UNDER_25K_WILL:
case ApiTransferTypes.TO_ADMIN_NO_WILL:
localState.transferTypeRules = customRules(
required('Select transfer type'),
[
() => hasGroupsWithPersonOwners.value ||
'An owner group with an individual person is required for this transfer type'
]
)
break
case ApiTransferTypes.SALE_OR_GIFT:
default:
localState.transferTypeRules = required('Select transfer type')
localState.transferTypeRules = customRules(
required('Select transfer type')
)
}
})
Expand Down
2 changes: 1 addition & 1 deletion ppr-ui/src/composables/mhrInformation/useMhrInformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ export const useMhrInformation = () => {
const data: MhrTransferApiIF = {
draftNumber: getMhrInformation.value.draftNumber,
mhrNumber: getMhrInformation.value.mhrNumber,
declaredValue: getMhrTransferDeclaredValue.value,
declaredValue: parseInt(getMhrTransferDeclaredValue.value?.replace(/,/g, '')), // Cast to Int and remove commas
consideration: getMhrTransferConsideration.value,
transferDate: getMhrTransferDate.value,
ownLand: getMhrTransferOwnLand.value,
Expand Down
8 changes: 8 additions & 0 deletions ppr-ui/src/composables/mhrInformation/useTransferOwners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ export const useTransferOwners = (enableAllActions: boolean = false) => {
)
})

/** Returns true when ownership structure contains at least 1 group with owners that are not all businesses. **/
const hasGroupsWithPersonOwners = computed((): boolean => {
return getMhrTransferCurrentHomeOwnerGroups.value.some(group => group.owners
.some(owner => owner.partyType !== HomeOwnerPartyTypes.OWNER_BUS)
)
})

/** Conditionally show DeathCertificate based on Transfer Type **/
const showDeathCertificate = (): boolean => {
return getMhrTransferType.value?.transferType === ApiTransferTypes.SURVIVING_JOINT_TENANT
Expand Down Expand Up @@ -805,6 +812,7 @@ export const useTransferOwners = (enableAllActions: boolean = false) => {
getCurrentOwnerStateById,
groupHasAllAddedOwners,
groupHasAllBusinesses,
hasGroupsWithPersonOwners,
groupHasRemovedAllCurrentOwners,
getCurrentOwnerGroupIdByOwnerId,
hasCurrentOwnerChanges,
Expand Down
6 changes: 4 additions & 2 deletions ppr-ui/src/composables/useInputRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,17 @@ export const useInputRules = () => {
numberType: string = null,
maxDigits: number = null,
maxValue: number = null,
customMsg: string = null
customMsg: string = null,
allowComma: boolean = false
): Array<(v:any)=>string|boolean> => {
const maxDigitRule = new RegExp(`^\\d{1,${maxDigits}}$`)

return [
v => ((v && numberType) ? /^\d+$/g.test(v) : true) || `${numberType} must be a valid whole number (cannot contain decimals)`,
v => ((v && maxDigits) ? maxDigitRule.test(v) : true) || `Maximum ${maxDigits} characters`,
v => ((v && maxValue) ? v < maxValue : true) || `${numberType} must be less than ${maxValue}`,
v => (v ? /^\d+$/g.test(v) : true) || `${customMsg || 'Must contain numbers only'}`
v => (v && allowComma ? /^\d+(,\d+)*$/g.test(v) : true) || `${customMsg || 'Must contain numbers only'}`,
v => (v && !allowComma ? /^\d+$/g.test(v) : true) || `${customMsg || 'Must contain numbers only'}`
]
}

Expand Down

0 comments on commit edc06bf

Please sign in to comment.