Skip to content

Commit

Permalink
18535 - Add Amalgamating Businesses Part 1 (bcgov#585)
Browse files Browse the repository at this point in the history
* 18535 - Add Amalgamating Businesses Part 1

* Fixed id name

* Cleanup + added fix for new note

* First set of fixes in response to Sev's comments

* fixed lint error

* Part fix in response to Sev's comments
  • Loading branch information
JazzarKarim committed Jan 26, 2024
1 parent e4add08 commit 1eaa2d7
Show file tree
Hide file tree
Showing 7 changed files with 283 additions and 35 deletions.
37 changes: 30 additions & 7 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "business-create-ui",
"version": "5.6.3",
"version": "5.6.4",
"private": true,
"appName": "Create UI",
"sbcName": "SBC Common Components",
Expand All @@ -17,7 +17,7 @@
"@bcrs-shared-components/approval-type": "1.0.19",
"@bcrs-shared-components/base-address": "2.0.3",
"@bcrs-shared-components/breadcrumb": "2.1.15",
"@bcrs-shared-components/business-lookup": "1.1.30",
"@bcrs-shared-components/business-lookup": "1.2.3",
"@bcrs-shared-components/certify": "2.1.15",
"@bcrs-shared-components/completing-party": "2.1.30",
"@bcrs-shared-components/confirm-dialog": "1.2.1",
Expand Down
232 changes: 232 additions & 0 deletions src/components/Amalgamation/AmalgamatingBusinesses.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
<template>
<div id="amalgamating-businesses">
<v-btn
id="btn-add-amalgamating-business"
outlined
color="primary"
class="btn-outlined-primary"
:disabled="isAddingAmalgamatingBusiness || isAddingAmalgamatingForeignBusiness"
@click="onAddBusinessClick()"
>
<v-icon>mdi-domain-plus</v-icon>
<span>Add an Amalgamating Business</span>
</v-btn>

<v-btn
v-if="isRoleStaff"
id="btn-add-amalgamating-foreign-business"
outlined
color="primary"
class="ml-2 btn-outlined-primary"
:disabled="isAddingAmalgamatingBusiness || isAddingAmalgamatingForeignBusiness"
@click="onAddForeignBusinessClick()"
>
<v-icon>mdi-domain-plus</v-icon>
<span>Add an Amalgamating Foreign Business</span>
</v-btn>

<!-- Add an Amalgamating Business button clicked -->
<v-expand-transition>
<v-card
v-if="isAddingAmalgamatingBusiness"
flat
class="section-container mt-4 pr-0"
>
<v-row
no-gutters
>
<v-col
cols="12"
sm="3"
>
<label>Add a Business Registered in BC</label>
</v-col>

<v-col
cols="12"
sm="8"
class="ml-8"
>
<span>Enter the name or the incorporation number of the registered BC business
to add to this application.
</span>
<BusinessLookup
:showErrors="false"
:businessLookup="initialBusinessLookupObject"
:BusinessLookupServices="BusinessLookupServices"
label="Business Name or Incorporation Number"
@setBusiness="saveAmalgamatingBusiness($event)"
/>
<v-row
class="justify-end mr-0 mt-2"
>
<v-btn
id="app-cancel-btn"
large
outlined
color="primary"
@click="addAmalgamatingBusinessCancel()"
>
<span>Cancel</span>
</v-btn>
</v-row>
</v-col>
</v-row>
</v-card>
</v-expand-transition>

<!-- Add an Amalgamating Foreign Business button clicked -->
<v-expand-transition>
<v-card
v-if="isAddingAmalgamatingForeignBusiness"
flat
class="section-container mt-4"
>
<v-row
no-gutters
>
<v-col
cols="12"
sm="3"
>
<label>Add a Foreign Business</label>
</v-col>

<v-col
cols="12"
sm="8"
class="ml-8"
>
<span>**TODO**</span>
</v-col>

<!-- extra column is for possible action button -->
</v-row>
</v-card>
</v-expand-transition>
<v-row class="mt-4 ml-1">
<ul>
Amalgamating Businesses: <br><br>
<li
v-for="(business, index) in amalgamatingBusinesses"
:key="index"
>
<template v-if="business.foundingDate">
Legal Name: {{ business.legalName }} <br>
Legal Type: {{ business.legalType }} <br>
Mailing Address: {{ business.officeAddress.mailingAddress }} <br>
State: {{ business.state }} <br>
Good Standing: {{ business.goodStanding }} <br>
</template>
<template v-else>
Legal Name: {{ business.name }} <br>
Legal Type: {{ business.legalType }} <br>
Identifier: {{ business.identifier }} <br>
Status: {{ business.status }}
</template>
</li>
</ul>
</v-row>
</div>
</template>

<script lang="ts">
import { Component, Mixins } from 'vue-property-decorator'
import { Action, Getter } from 'pinia-class'
import { useStore } from '@/store/store'
import { CommonMixin } from '@/mixins'
import { BusinessLookupServices, LegalServices } from '@/services'
import { BusinessLookup } from '@bcrs-shared-components/business-lookup'
import { BusinessIF, BusinessLookupIF, EmptyBusinessLookup } from '@/interfaces'
@Component({
components: {
BusinessLookup
}
})
export default class AmalgamatingBusinesses extends Mixins(CommonMixin) {
@Getter(useStore) getAmalgamatingBusinesses!: Array<BusinessIF>
@Getter(useStore) isAmalgamationFilingHorizontal!: boolean
@Getter(useStore) isRoleStaff!: boolean
@Action(useStore) setAmalgamatingBusinesses!: (x: Array<BusinessIF>) => void
// Local properties
amalgamatingBusinessesValid = false
amalgamatingBusinesses = []
initialBusinessLookupObject = EmptyBusinessLookup
// Button properties
isAddingAmalgamatingBusiness = false
isAddingAmalgamatingForeignBusiness = false
readonly BusinessLookupServices = BusinessLookupServices
// Cancel button in "Add an Amalgamating Business" is pressed.
addAmalgamatingBusinessCancel (): void {
this.isAddingAmalgamatingBusiness = false
}
// "Add an Amalgamating Business" button is pressed.
onAddBusinessClick (): void {
this.isAddingAmalgamatingBusiness = true
this.isAddingAmalgamatingForeignBusiness = false
}
// "Add an Amalgamating Foreign Business" button is pressed.
onAddForeignBusinessClick (): void {
this.isAddingAmalgamatingBusiness = false
this.isAddingAmalgamatingForeignBusiness = true
}
async saveAmalgamatingBusiness (businessLookup: BusinessLookupIF): Promise<void> {
// Get the amalgamating business information
// Will have a different format depending on the business
let business = await LegalServices.fetchBusinessInfo(businessLookup.identifier)
.then((response) => {
return response?.data?.business
}).catch(() => {
return businessLookup
})
// Get the address of the amalgamating business
if (businessLookup.identifier && business.foundingDate) {
const addresses = await LegalServices.fetchAddresses(businessLookup.identifier)
.then((data) => {
// SP and GP have businessOffice instead of registeredOffice
return data?.registeredOffice || data?.businessOffice
}).catch(() => {
return undefined
})
if (addresses) {
business.officeAddress = addresses
}
}
// If the amalgamating businesses array is not empty, check if identifier already exists.
// If identifier already exists, don't add the business to the array.
if (this.amalgamatingBusinesses.length > 0) {
const businessExists = this.amalgamatingBusinesses.find(function (id) {
return id.identifier === business.identifier
})
if (!businessExists) this.amalgamatingBusinesses.push(business)
} else {
this.amalgamatingBusinesses.push(business)
}
// Set the amalgamated businesses array in the store.
this.setAmalgamatingBusinesses(this.amalgamatingBusinesses)
// Close the "Add an Amalgamating Business" Panel.
this.addAmalgamatingBusinessCancel()
}
}
</script>

<style lang="scss" scoped>
@import '@/assets/styles/theme.scss';
.v-btn:not(.v-btn--round).v-size--default {
height: 44px;
}
</style>
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import { AmalgamationTypes, ApprovalTypes, RelationshipTypes } from '@/enums'
import { CourtOrderIF } from '@/interfaces'
import { AmalgamationTypes } from '@/enums'
import { BusinessIF } from '@/interfaces'

export interface AmalgamationStateIF {
applicationDate?: string // YYYY-MM-DD
approvalType: ApprovalTypes
approvalTypeValid: boolean
businessNameValid: boolean
courtOrder?: CourtOrderIF
expiry?: string // YYYY-MM-DD
noticeDate?: string // YYYY-MM-DD
relationships?: RelationshipTypes[]
restorationTypeValid: boolean
amalgamatingBusinesses: Array<BusinessIF>
type: AmalgamationTypes
}
12 changes: 1 addition & 11 deletions src/store/state/state-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,7 @@ export const stateModel: StateModelIF = {
isAutoPopulatedBusinessNumber: false
},
amalgamation: {
applicationDate: null,
approvalType: null,
approvalTypeValid: true,
businessNameValid: false,
courtOrder: {
fileNumber: null
},
expiry: null,
noticeDate: null,
relationships: [],
restorationTypeValid: false,
amalgamatingBusinesses: [],
type: null
},
restoration: {
Expand Down
9 changes: 9 additions & 0 deletions src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
AddressIF,
AffidavitResourceIF,
BusinessAddressIF,
BusinessIF,
BusinessWarningIF,
CertifyIF,
CompletingPartyIF,
Expand Down Expand Up @@ -741,6 +742,11 @@ export const useStore = defineStore('store', {
return this.stateModel.restoration.approvalTypeValid
},

/** The amalgamating businesses. */
getAmalgamatingBusinesses (): Array<BusinessIF> {
return this.stateModel.amalgamation.amalgamatingBusinesses
},

//
// Dissolution getters
//
Expand Down Expand Up @@ -1219,6 +1225,9 @@ export const useStore = defineStore('store', {
setWindowWidth (width: number) {
this.stateModel.windowWidth = width
},
setAmalgamatingBusinesses (amalgamatingBusinesses: Array<BusinessIF>) {
this.stateModel.amalgamation.amalgamatingBusinesses = amalgamatingBusinesses
},
setAmalgamationType (type: AmalgamationTypes) {
this.stateModel.amalgamation.type = type
},
Expand Down
Loading

0 comments on commit 1eaa2d7

Please sign in to comment.