Skip to content

Commit

Permalink
21310 Implement Authorization Date min date validation (bcgov#701)
Browse files Browse the repository at this point in the history
* - app version = 5.10.20
- added Authorization Date min date validation

* - trimmed whitespace from text input fields
- now deep-watch objects

* - changed inner comment to JSDoc comment

---------

Co-authored-by: Severin Beauvais <severin.beauvais@gov.bc.ca>
  • Loading branch information
severinbeauvais and Severin Beauvais authored Jun 4, 2024
1 parent a859f3c commit 90487df
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 22 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "business-create-ui",
"version": "5.10.19",
"version": "5.10.20",
"private": true,
"appName": "Create UI",
"sbcName": "SBC Common Components",
Expand Down
28 changes: 26 additions & 2 deletions src/components/ContinuationIn/ContinuationAuthorization.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
:persistentHint="true"
:initialValue="authorization.date"
:inputRules="getShowErrors ? authorizationDateRules : []"
:minDate="minAuthorizationDate"
:maxDate="getCurrentDate"
@emitDateSync="authorization.date = $event"
/>
Expand Down Expand Up @@ -136,7 +137,7 @@ import { Action, Getter } from 'pinia-class'
import { StatusCodes } from 'http-status-codes'
import { useStore } from '@/store/store'
import { DocumentMixin } from '@/mixins'
import { ContinuationAuthorizationIF, FormIF, PresignedUrlIF } from '@/interfaces'
import { ContinuationAuthorizationIF, ExistingBusinessInfoIF, FormIF, PresignedUrlIF } from '@/interfaces'
import { PdfPageSize } from '@/enums'
import { VuetifyRuleFunction } from '@/types'
import FileUploadPreview from '@/components/common/FileUploadPreview.vue'
Expand All @@ -160,6 +161,7 @@ export default class ExtraproRegistration extends Mixins(DocumentMixin) {
@Getter(useStore) getContinuationAuthorization!: ContinuationAuthorizationIF
@Getter(useStore) getCurrentDate!: string
@Getter(useStore) getExistingBusinessInfo!: ExistingBusinessInfoIF
@Getter(useStore) getKeycloakGuid!: string
@Getter(useStore) getShowErrors!: boolean
Expand All @@ -170,10 +172,31 @@ export default class ExtraproRegistration extends Mixins(DocumentMixin) {
fileValidity = false
customErrorMessage = ['', '', '', '', ''] // max 5 files
/**
* The minimum date for the Authorization Date:
* - the BC Founding Date (if it exists, ie, expro business)
* - else the Home Jurisdiction Incorporation Date (ie, manual entry)
* - else fall back to null (not undefined)
*/
get minAuthorizationDate (): string {
return (
this.getExistingBusinessInfo.bcFoundingDate ||
this.getExistingBusinessInfo.homeIncorporationDate ||
null
)
}
get authorizationDateRules (): Array<VuetifyRuleFunction> {
const bcFoundingDate = this.getExistingBusinessInfo.bcFoundingDate
const homeIncorporationDate = this.getExistingBusinessInfo.homeIncorporationDate
return [
(v) => !!v || 'Authorization Date is required',
() => (this.authorization.date <= this.getCurrentDate) || 'Authorization Date cannot be in the future'
() => (this.authorization.date <= this.getCurrentDate) || 'Authorization Date cannot be in the future',
() => (!bcFoundingDate || (this.authorization.date >= bcFoundingDate)) ||
'Authorization Date cannot be before Date of Registration in B.C.',
() => (!homeIncorporationDate || (this.authorization.date >= homeIncorporationDate)) ||
'Authorization Date cannot be before Date of Incorporation in Home Jurisdiction'
]
}
Expand Down Expand Up @@ -253,6 +276,7 @@ export default class ExtraproRegistration extends Mixins(DocumentMixin) {
}
@Watch('getShowErrors')
@Watch('minAuthorizationDate') // because Authorization Date depends on this
@Watch('authorization.date') // because Expiry Date depends on this
private async onGetShowErrors (): Promise<void> {
if (this.getShowErrors) {
Expand Down
16 changes: 7 additions & 9 deletions src/components/ContinuationIn/ExtraproRegistration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
sm="9"
>
<v-text-field
v-model="business.homeIdentifier"
v-model.trim="business.homeIdentifier"
class="identifying-number-home"
filled
hide-details="auto"
Expand All @@ -159,7 +159,7 @@
sm="9"
>
<v-text-field
v-model="business.homeLegalName"
v-model.trim="business.homeLegalName"
class="name-home-jurisdiction"
filled
hide-details="auto"
Expand Down Expand Up @@ -475,13 +475,13 @@ export default class ExtraproRegistration extends Mixins(DateMixin) {
}
readonly homeIdentifierRules: Array<VuetifyRuleFunction> = [
(v) => !!v || 'Identifying Number is required',
(v) => (v && v.length <= 50) || 'Cannot exceed 50 characters'
(v) => !!v?.trim() || 'Identifying Number is required',
(v) => (v && v.trim().length <= 50) || 'Cannot exceed 50 characters'
]
readonly homeLegalNameRules: Array<VuetifyRuleFunction> = [
(v) => !!v || 'Name is required',
(v) => (v && v.length <= 1000) || 'Cannot exceed 1000 characters'
(v) => !!v?.trim() || 'Name is required',
(v) => (v && v.trim().length <= 1000) || 'Cannot exceed 1000 characters'
]
get incorporationDateRules (): Array<VuetifyRuleFunction> {
Expand Down Expand Up @@ -640,10 +640,8 @@ export default class ExtraproRegistration extends Mixins(DateMixin) {
/** Emits form validity. */
@Watch('isBusinessActive')
@Watch('business.homeJurisdiction')
@Watch('business.homeIncorporationDate')
@Watch('business', { deep: true })
@Watch('isContinuationInAffidavitRequired')
@Watch('business.affidavitFileKey')
@Watch('formValid')
@Emit('valid')
private onComponentValid (): boolean {
Expand Down
15 changes: 7 additions & 8 deletions src/components/ContinuationIn/ManualBusinessInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
sm="9"
>
<v-text-field
v-model="business.homeIdentifier"
v-model.trim="business.homeIdentifier"
class="identifying-number"
filled
hide-details="auto"
Expand All @@ -124,7 +124,7 @@
sm="9"
>
<v-text-field
v-model="business.homeLegalName"
v-model.trim="business.homeLegalName"
class="business-name"
filled
hide-details="auto"
Expand Down Expand Up @@ -296,13 +296,13 @@ export default class ManualBusinessInfo extends Mixins(CountriesProvincesMixin,
formValid = false
readonly identifyingNumberRules: Array<VuetifyRuleFunction> = [
(v) => !!v || 'Identifying Number is required',
(v) => (v && v.length <= 50) || 'Cannot exceed 50 characters'
(v) => !!v?.trim() || 'Identifying Number is required',
(v) => (v && v.trim().length <= 50) || 'Cannot exceed 50 characters'
]
readonly businessNameRules: Array<VuetifyRuleFunction> = [
(v) => !!v || 'Business Name is required',
(v) => (v && v.length <= 1000) || 'Cannot exceed 1000 characters'
(v) => !!v?.trim() || 'Business Name is required',
(v) => (v && v.trim().length <= 1000) || 'Cannot exceed 1000 characters'
]
get incorporationDateRules (): Array<VuetifyRuleFunction> {
Expand Down Expand Up @@ -383,8 +383,7 @@ export default class ManualBusinessInfo extends Mixins(CountriesProvincesMixin,
}
/** Emits form validity. */
@Watch('business.homeJurisdiction')
@Watch('business.homeIncorporationDate')
@Watch('business', { deep: true })
@Watch('formValid')
@Emit('valid')
private onComponentValid (): boolean {
Expand Down

0 comments on commit 90487df

Please sign in to comment.