diff --git a/package-lock.json b/package-lock.json index e8e6814b9..10a543311 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,17 @@ { "name": "name-request", - "version": "5.3.9", + "version": "5.3.10", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "name-request", - "version": "5.3.9", + "version": "5.3.10", "dependencies": { "@babel/compat-data": "^7.21.5", "@bcrs-shared-components/breadcrumb": "2.1.24", "@bcrs-shared-components/corp-type-module": "1.0.13", - "@bcrs-shared-components/enums": "1.0.44", + "@bcrs-shared-components/enums": "1.1.1", "@bcrs-shared-components/genesys-web-message": "1.0.0", "@bcrs-shared-components/interfaces": "1.0.67", "@bcrs-shared-components/staff-payment": "1.0.29", @@ -1918,9 +1918,9 @@ "integrity": "sha512-Wa8H/bxo8GAlcG7YdiP4zl1wzqxewiCO0TC+pBaYUc4+eufuInlS3yYFa9MFg8+vIL/pDfamRtXqdg1I6C6QYA==" }, "node_modules/@bcrs-shared-components/enums": { - "version": "1.0.44", - "resolved": "https://registry.npmjs.org/@bcrs-shared-components/enums/-/enums-1.0.44.tgz", - "integrity": "sha512-ElBaAzi2fQAow4ysPHlZW5PRWlsYyrOPqIhd4APG4BXIL+quSrcva1MfKHxNkzMenNp4BnDTlyZVhapNaWQEEA==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@bcrs-shared-components/enums/-/enums-1.1.1.tgz", + "integrity": "sha512-EyjoIo5NkzdXeJ/bAtjVgPErH1qH5LhObBa5//uoQ45DYZlKUdAcg8HPC4XStMZVFvjVzABYPqrQkdB8Zhh/Mw==", "dependencies": { "@bcrs-shared-components/corp-type-module": "^1.0.13" } @@ -1987,6 +1987,19 @@ "vue": "^2.7.14" } }, + "node_modules/@bcrs-shared-components/interfaces/node_modules/@bcrs-shared-components/corp-type-module": { + "version": "1.0.14", + "resolved": "https://registry.npmjs.org/@bcrs-shared-components/corp-type-module/-/corp-type-module-1.0.14.tgz", + "integrity": "sha512-SZhJw4hpqQT2BL3RuVB0Z1hmShhrv5byhH4gnaF1fVl9jsUGkjC/Ytic08UnEX4DIyR1/VWNyjTclNgxi9+0Bw==" + }, + "node_modules/@bcrs-shared-components/interfaces/node_modules/@bcrs-shared-components/enums": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@bcrs-shared-components/enums/-/enums-1.1.2.tgz", + "integrity": "sha512-ttgHwwnLZh9f75GlxpMU0hI22Nd98zzdq+vBEQd95U6k5UrZI0jGwKFYhtuyjoLLPwtiSsjtsLdSw/n/lJTfZw==", + "dependencies": { + "@bcrs-shared-components/corp-type-module": "^1.0.14" + } + }, "node_modules/@bcrs-shared-components/interfaces/node_modules/@vue/compiler-sfc": { "version": "2.7.14", "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-2.7.14.tgz", diff --git a/package.json b/package.json index 741e3662d..0b8ad4af7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "name-request", - "version": "5.3.9", + "version": "5.3.10", "private": true, "appName": "Name Request UI", "sbcName": "SBC Common Components", @@ -16,7 +16,7 @@ "@babel/compat-data": "^7.21.5", "@bcrs-shared-components/breadcrumb": "2.1.24", "@bcrs-shared-components/corp-type-module": "1.0.13", - "@bcrs-shared-components/enums": "1.0.44", + "@bcrs-shared-components/enums": "1.1.1", "@bcrs-shared-components/genesys-web-message": "1.0.0", "@bcrs-shared-components/interfaces": "1.0.67", "@bcrs-shared-components/staff-payment": "1.0.29", diff --git a/src/App.vue b/src/App.vue index 787a025df..9cd567e0f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -81,6 +81,11 @@ :dialog="getIncorporateNowErrorStatus" @close="closeIncorporateNowErrorDialog()" /> + @@ -121,8 +126,8 @@ import { Breadcrumb } from '@/components/common' import GenesysWebMessage from '@bcrs-shared-components/genesys-web-message/GenesysWebMessage.vue' import { WebChat as ChatPopup } from '@bcrs-shared-components/web-chat' import { - AffiliationErrorDialog, CancelDialog, ConditionsDialog, ErrorDialog, ExitDialog, HelpMeChooseDialog, - IncorporateNowErrorDialog, MrasSearchInfoDialog, NrNotRequiredDialog, ConfirmNrDialog, + AffiliationErrorDialog, AmalgamateNowErrorDialog, CancelDialog, ConditionsDialog, ErrorDialog, ExitDialog, + HelpMeChooseDialog, IncorporateNowErrorDialog, MrasSearchInfoDialog, NrNotRequiredDialog, ConfirmNrDialog, PaymentCompleteDialog, PickEntityOrConversionDialog, RenewDialog, ReceiptsDialog, RefundDialog, ResubmitDialog, RetryDialog, StaffPaymentErrorDialog, UpgradeDialog, ExitIncompletePaymentDialog } from '@/components/dialogs' @@ -137,10 +142,11 @@ import { CorpTypeCd } from '@bcrs-shared-components/corp-type-module' @Component({ components: { - ChatPopup, AffiliationErrorDialog, + AmalgamateNowErrorDialog, Breadcrumb, CancelDialog, + ChatPopup, ConditionsDialog, ConfirmNrDialog, ErrorDialog, @@ -168,12 +174,14 @@ export default class App extends Mixins( DateMixin, LoadKeycloakRolesMixin, NrAffiliationMixin, UpdateUserMixin ) { // Global getters + @Getter getAmalgamateNowErrorStatus!: boolean @Getter getDisplayedComponent!: string @Getter getIncorporateNowErrorStatus!: boolean @Getter getNrId!: number @Getter isAuthenticated!: boolean @Getter isRoleStaff!: boolean @Getter isMobile!: boolean + @Getter isNewBusiness!: boolean // Global actions @Action resetAnalyzeName!: ActionBindingIF @@ -267,13 +275,22 @@ export default class App extends Mixins( // if there is stored legal type for an IA then incorporate/register it now const legaltype = sessionStorage.getItem('LEGAL_TYPE') + if (legaltype) { try { - await this.incorporateNow(legaltype as CorpTypeCd) + if (this.isNewBusiness) { + await this.incorporateNow(legaltype as CorpTypeCd) + } else { + await this.amalgamateNow(legaltype as CorpTypeCd) + } // clear the legal type data sessionStorage.removeItem('LEGAL_TYPE') } catch (error) { - this.setIncorporateNowErrorStatus(true) + if (this.isNewBusiness) { + this.setIncorporateNowErrorStatus(true) + } else { + this.setAmalgamateNowErrorStatus(true) + } console.error(error) } } @@ -348,6 +365,12 @@ export default class App extends Mixins( sessionStorage.removeItem('LEGAL_TYPE') this.setIncorporateNowErrorStatus(false) } + + /** Close AmalgamateNowErrorDialog and clear session storage. */ + closeAmalgamateNowErrorDialog (): void { + sessionStorage.removeItem('LEGAL_TYPE') + this.setAmalgamateNowErrorStatus(false) + } } diff --git a/src/components/dialogs/amalgamate-now-error.vue b/src/components/dialogs/amalgamate-now-error.vue new file mode 100644 index 000000000..48dcf71a9 --- /dev/null +++ b/src/components/dialogs/amalgamate-now-error.vue @@ -0,0 +1,96 @@ + + + + + diff --git a/src/components/dialogs/index.ts b/src/components/dialogs/index.ts index 7f939119b..4fc905b09 100644 --- a/src/components/dialogs/index.ts +++ b/src/components/dialogs/index.ts @@ -1,4 +1,5 @@ export { default as AffiliationErrorDialog } from './affiliation-error.vue' +export { default as AmalgamateNowErrorDialog } from './amalgamate-now-error.vue' export { default as CancelDialog } from './cancel.vue' export { default as ConditionsDialog } from './conditions.vue' export { default as ConfirmNrDialog } from './confirm-name-request.vue' diff --git a/src/components/existing-request/existing-request-display.vue b/src/components/existing-request/existing-request-display.vue index 5f520b58a..dc944dfe0 100644 --- a/src/components/existing-request/existing-request-display.vue +++ b/src/components/existing-request/existing-request-display.vue @@ -313,7 +313,7 @@ :approvedName="approvedName && approvedName.name" :emailAddress="nr && nr.applicants && nr.applicants.emailAddress" :disabled="disableUnfurnished" - @incorporateRegisterYourBusiness="incorporateRegisterYourBusiness()" + @affiliateYourBusiness="affiliateYourBusiness()" @goToSocietiesOnline="goToSocietiesOnline()" @goToCorpOnline="goToCorpOnline()" @goToEntityDashboard="goToEntityDashboard(nr.corpNum)" @@ -368,7 +368,6 @@ export default class ExistingRequestDisplay extends Mixins( @Getter getNrId!: number @Getter getNrState!: NrState @Getter isMobile!: boolean - // Global actions @Action editExistingRequest!: ActionBindingIF @Action setDisplayedComponent!: ActionBindingIF @@ -773,8 +772,8 @@ export default class ExistingRequestDisplay extends Mixins( this.setConditionsModalVisible(true) } - /** Called to incorporate/register the business. */ - async incorporateRegisterYourBusiness (): Promise { + /** Called to incorporate/register/amalgamate the business. */ + async affiliateYourBusiness (): Promise { // safety check if (!this.isNrApprovedOrConditional) return diff --git a/src/components/existing-request/nr-approved-gray-box.vue b/src/components/existing-request/nr-approved-gray-box.vue index 116fbc503..d4e90555f 100644 --- a/src/components/existing-request/nr-approved-gray-box.vue +++ b/src/components/existing-request/nr-approved-gray-box.vue @@ -12,7 +12,7 @@ class="register-btn mt-30" min-width="20rem" :disabled="disabled" - @click="$emit('incorporateRegisterYourBusiness')" + @click="$emit('affiliateYourBusiness')" > Register Your Business @@ -26,7 +26,7 @@ class="incorporate-now-btn mt-30" min-width="20rem" :disabled="disabled" - @click="$emit('incorporateRegisterYourBusiness')" + @click="$emit('affiliateYourBusiness')" > Incorporate Your Business @@ -72,7 +72,7 @@ class="amalgamate-now-btn mt-30" min-width="20rem" :disabled="disabled" - @click="$emit('goToEntityDashboard')" + @click="$emit('affiliateYourBusiness')" > Amalgamate Now @@ -225,7 +225,7 @@ export default class NrApprovedGrayBox extends Mixins(CommonMixin) { } get showOpenExternalIcon (): boolean { - if (this.showAmalgamateNowButton && !this.isSupportedAmalgamation(this.getNr.requestTypeCd)) return true + if (this.showAmalgamateNowButton && !this.isSupportedAmalgamation(this.getNr.entity_type_cd)) return true if (this.showAlterNowButton && !this.isSupportedAlteration(this.getNr.requestTypeCd)) return true return false } diff --git a/src/components/new-request/search.vue b/src/components/new-request/search.vue index aacea41bf..c34e7dff7 100644 --- a/src/components/new-request/search.vue +++ b/src/components/new-request/search.vue @@ -628,7 +628,7 @@ export default class Search extends Mixins(CommonMixin, NrAffiliationMixin, Sear /** Retrieve text based on selected action/flow */ get actionNowButtonText (): string { if (this.isContinuationIn) return 'Continue In Now' - if (this.isAmalgamation) return null // should never happen + if (this.isAmalgamation) return 'Amalgamate Now' if (this.isConversion) return 'Alter Now' if (this.isRestoration) return 'Restore Now' if (this.isChangeName) return 'Change Name Now' @@ -707,6 +707,8 @@ export default class Search extends Mixins(CommonMixin, NrAffiliationMixin, Sear if (this.isAuthenticated) { if (this.isConversion || this.isRestoration || this.isChangeName) { this.goToEntityDashboard(this.getSearchBusiness.identifier) + } else if (this.isAmalgamation) { + await this.amalgamateNow(legalType) } else { await this.incorporateNow(legalType) } diff --git a/src/interfaces/business.ts b/src/interfaces/business.ts index 9a29c0043..15dba6a55 100644 --- a/src/interfaces/business.ts +++ b/src/interfaces/business.ts @@ -1,4 +1,5 @@ import { EntityStates, EntityTypes } from '@/enums' +import { AmalgamationTypes } from '@bcrs-shared-components/enums' export interface BusinessRequest { filing: { @@ -15,6 +16,13 @@ export interface BusinessRequest { nrNumber?: string } }, + amalgamation?: { + nameRequest: { + legalType: string + nrNumber?: string + }, + type: AmalgamationTypes + }, registration?: { business: { natureOfBusiness: string diff --git a/src/interfaces/new-request-interface.ts b/src/interfaces/new-request-interface.ts index 4cd50e0d0..478a4b28f 100644 --- a/src/interfaces/new-request-interface.ts +++ b/src/interfaces/new-request-interface.ts @@ -11,6 +11,7 @@ export interface NewRequestIF { addressSuggestions: any[] affiliationErrorModalValue: NrAffiliationErrors allowAutoApprove: boolean + amalgamateNowError: boolean analysisJSON: AnalysisJSONI applicant: ApplicantI assumedNameOriginal: string diff --git a/src/mixins/nr-affiliation-mixin.ts b/src/mixins/nr-affiliation-mixin.ts index c4ce3170e..bd7ae0ae6 100644 --- a/src/mixins/nr-affiliation-mixin.ts +++ b/src/mixins/nr-affiliation-mixin.ts @@ -9,11 +9,13 @@ import { CommonMixin } from '@/mixins' import { NrAffiliationErrors } from '@/enums' import { CREATED, BAD_REQUEST } from 'http-status-codes' import { CorpTypeCd } from '@bcrs-shared-components/corp-type-module' +import { AmalgamationTypes, FilingTypes } from '@bcrs-shared-components/enums' @Component({}) export class NrAffiliationMixin extends Mixins(CommonMixin) { // Global action @Action setAffiliationErrorModalValue!: ActionBindingIF + @Action setAmalgamateNowErrorStatus!: ActionBindingIF @Action setIncorporateNowErrorStatus!: ActionBindingIF /** @@ -138,21 +140,35 @@ export class NrAffiliationMixin extends Mixins(CommonMixin) { let legalType = '' let businessRequest = {} as BusinessRequest const nrNumber = nr.nrNum - if (!this.isFirm(nr)) { - name = 'incorporationApplication' - legalType = this.entityTypeToCorpType(nr.entity_type_cd) - businessRequest = { - filing: { - business: { legalType }, - header: { accountId, name }, - incorporationApplication: { - nameRequest: { legalType, nrNumber } + if (nr.request_action_cd === 'AML') { + name = FilingTypes.AMALGAMATION + legalType = nr.legalType + businessRequest = { + filing: { + business: { legalType }, + header: { accountId, name }, + amalgamation: { + type: AmalgamationTypes.REGULAR, + nameRequest: { legalType, nrNumber } + } + } + } + } else { + name = FilingTypes.INCORPORATION_APPLICATION + legalType = this.entityTypeToCorpType(nr.entity_type_cd) + businessRequest = { + filing: { + business: { legalType }, + header: { accountId, name }, + incorporationApplication: { + nameRequest: { legalType, nrNumber } + } } } } } else { - name = 'registration' + name = FilingTypes.REGISTRATION legalType = nr.legalType businessRequest = { filing: { @@ -198,6 +214,59 @@ export class NrAffiliationMixin extends Mixins(CommonMixin) { } } + /** + * Handle "Amalgamate Now" button. + * Submit an amalgamation draft depending on business type. + * Redirect to Dashboard. + * @param legalType The legal type of the amalgamated business + */ + async amalgamateNow (legalType: CorpTypeCd): Promise { + try { + // show spinner since this is a network call + this.$root.$emit('showSpinner', true) + const accountId = +JSON.parse(sessionStorage.getItem('CURRENT_ACCOUNT'))?.id || 0 + const businessId = await this.createBusinessAA(accountId, legalType) + this.goToEntityDashboard(businessId) + return + } catch (error) { + this.$root.$emit('showSpinner', false) + this.setAmalgamateNowErrorStatus(true) + throw new Error('Unable to Amalgamate Now ' + error) + } + } + + /** + * Create a draft amalgamation application based on selected business type. + * @param accountId Account ID of logged in user. + * @param legalType The legal type of the amalgamated business + */ + async createBusinessAA (accountId: number, legalType: CorpTypeCd): Promise { + const businessRequest = { + filing: { + header: { + name: FilingTypes.AMALGAMATION, + accountId: accountId + }, + business: { + legalType: legalType + }, + amalgamation: { + nameRequest: { + legalType: legalType + }, + type: AmalgamationTypes.REGULAR + } + } + } as BusinessRequest + + const createBusinessResponse = + await BusinessServices.createBusiness(businessRequest).catch(error => { + throw new Error('Unable to create new Amalgamation Draft ' + error) + }) + + return createBusinessResponse.data?.filing?.business?.identifier as string + } + /** * Create a draft business based on selected business type (If applicable). * @param accountId Account ID of logged in user. diff --git a/src/store/actions.ts b/src/store/actions.ts index 0a72839cd..8d9f0404d 100644 --- a/src/store/actions.ts +++ b/src/store/actions.ts @@ -1253,6 +1253,10 @@ export const setIncorporateNowErrorStatus = ({ commit }, incorporateNowError: bo commit('mutateIncorporateNowErrorStatus', incorporateNowError) } +export const setAmalgamateNowErrorStatus = ({ commit }, amalgamateNowError: boolean): void => { + commit('mutateAmalgamateNowErrorStatus', amalgamateNowError) +} + export const setSearchBusiness = ({ commit }, val: BusinessSearchIF): void => { commit('mutateSearchBusiness', val) } diff --git a/src/store/getters.ts b/src/store/getters.ts index ce3278396..5437e4213 100644 --- a/src/store/getters.ts +++ b/src/store/getters.ts @@ -1243,6 +1243,10 @@ export const getIncorporateNowErrorStatus = (state: StateIF): boolean => { return state.stateModel.newRequestModel.incorporateNowError } +export const getAmalgamateNowErrorStatus = (state: StateIF): boolean => { + return state.stateModel.newRequestModel.amalgamateNowError +} + /** True if current request action requires business lookup. */ export const isBusinessLookupRequestAction = (state: StateIF): boolean => { return BusinessLookupRequestActions.includes(getRequestActionCd(state)) diff --git a/src/store/mutations.ts b/src/store/mutations.ts index ea7d79a61..420a34160 100644 --- a/src/store/mutations.ts +++ b/src/store/mutations.ts @@ -580,6 +580,10 @@ export const mutateIncorporateNowErrorStatus = (state: StateIF, incorporateNowEr state.stateModel.newRequestModel.incorporateNowError = incorporateNowError } +export const mutateAmalgamateNowErrorStatus = (state: StateIF, amalgamateNowError: boolean) => { + state.stateModel.newRequestModel.amalgamateNowError = amalgamateNowError +} + export const mutateSearchBusiness = (state: StateIF, val: BusinessSearchIF) => { state.stateModel.newRequestModel.search.business = val } diff --git a/src/store/state.ts b/src/store/state.ts index 9ed249f1b..877e7da9c 100644 --- a/src/store/state.ts +++ b/src/store/state.ts @@ -77,6 +77,7 @@ export const stateModel: StateModelIF = { helpMeChooseModalVisible: false, affiliationErrorModalValue: NrAffiliationErrors.NONE, // initially hidden incorporateNowError: false, + amalgamateNowError: false, isPersonsName: false, issueIndex: 0, location: null,