Repository: bcgov/business-filings-ui
Pull request #744: 27042 remove address fetch error
Author: login: bobdev-94
Created: 2025-04-22T15:50:41Z | Merged: 2025-04-29T17:22:15Z

*Issue #:* /bcgov/entity#27042

*Description of changes:*


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the business-filings-ui license (Apache 2.0).



Diff:
diff --git a/package-lock.json b/package-lock.json
index 2400f3fde..6f1eacef1 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
 {
   "name": "business-filings-ui",
-  "version": "7.4.35",
+  "version": "7.4.36",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
       "name": "business-filings-ui",
-      "version": "7.4.35",
+      "version": "7.4.36",
       "dependencies": {
         "@babel/compat-data": "^7.21.5",
         "@bcrs-shared-components/base-address": "2.0.46",
diff --git a/package.json b/package.json
index 6c736a0b0..83e83c678 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "business-filings-ui",
-  "version": "7.4.35",
+  "version": "7.4.36",
   "private": true,
   "appName": "Business Filings UI",
   "sbcName": "SBC Common Components",
diff --git a/src/components/common/OfficeAddresses.vue b/src/components/common/OfficeAddresses.vue
index 02cb3f1f2..ba0964d31 100644
--- a/src/components/common/OfficeAddresses.vue
+++ b/src/components/common/OfficeAddresses.vue
@@ -23,7 +23,9 @@
               <label v-if="!showAddressForm"><strong>Delivery Address</strong></label>
 
               <div class="address-wrapper">
+                <span v-if="isEmptyObject(deliveryAddress) && !showAddressForm">(Not entered)</span>
                 <delivery-address
+                  v-else
                   :address="deliveryAddress"
                   :editing="showAddressForm"
                   :schema="officeAddressSchema"
@@ -72,8 +74,7 @@
             <label>{{ showAddressForm ? "Mailing Address" : "" }}</label>
             <div class="meta-container__inner">
               <label
-                v-if="!showAddressForm
-                  && !isSame(deliveryAddress, mailingAddress, ['actions','addressType'])"
+                v-if="!showAddressForm"
               >
                 <strong>Mailing Address</strong>
               </label>
@@ -85,8 +86,9 @@
                   label="Same as Delivery Address"
                 />
               </div>
+              <span v-if="isEmptyObject(mailingAddress) && !showAddressForm">(Not entered)</span>
               <div
-                v-if="showAddressForm ||
+                v-else-if="showAddressForm ||
                   !isSame(deliveryAddress, mailingAddress, ['actions','addressType'])"
                 class="address-wrapper"
               >
@@ -131,6 +133,7 @@
                 <div class="meta-container__inner">
                   <label v-if="!showAddressForm"><strong>Delivery Address</strong></label>
                   <div class="address-wrapper">
+                    <span v-if="isEmptyObject(recDeliveryAddress) && !showAddressForm">(Not entered)</span>
                     <delivery-address
                       :address="recDeliveryAddress"
                       :editing="showAddressForm"
@@ -149,8 +152,9 @@
                 <label>{{ showAddressForm ? "Mailing Address" : "" }}</label>
                 <div class="meta-container__inner">
                   <label
-                    v-if="!showAddressForm &&
-                      !isSame(recDeliveryAddress, recMailingAddress, ['actions','addressType'])"
+                    v-if="(!showAddressForm &&
+                      !isSame(recDeliveryAddress, recMailingAddress, ['actions','addressType'])) ||
+                      isEmptyObject(recMailingAddress)"
                   >
                     <strong>Mailing Address</strong>
                   </label>
@@ -162,8 +166,9 @@
                       label="Same as Delivery Address"
                     />
                   </div>
+                  <span v-if="isEmptyObject(recMailingAddress) && !showAddressForm">(Not entered)</span>
                   <div
-                    v-if="showAddressForm ||
+                    v-else-if="showAddressForm ||
                       !isSame(recDeliveryAddress, recMailingAddress, ['actions','addressType'])"
                     class="address-wrapper"
                   >
@@ -233,6 +238,7 @@ import { Component, Emit, Mixins, Prop, Watch } from 'vue-property-decorator'
 import axios from '@/axios-auth'
 import { isEmpty } from 'lodash'
 import { Getter } from 'pinia-class'
+import { StatusCodes } from 'http-status-codes'
 import { officeAddressSchema } from '@/schemas'
 import { BaseAddress } from '@bcrs-shared-components/base-address'
 import { CommonMixin } from '@/mixins'
@@ -256,7 +262,7 @@ export default class OfficeAddresses extends Mixins(CommonMixin) {
    */
   @Prop({ default: () => {} }) readonly addresses!: RegRecAddressesIF
 
-  @Getter(useBusinessStore) getIdentifier!: string
+  // @Getter(useBusinessStore) getIdentifier!: string
   @Getter(useBusinessStore) isBaseCompany!: boolean
 
   /** Effective date for fetching office addresses. */
@@ -295,7 +301,7 @@ export default class OfficeAddresses extends Mixins(CommonMixin) {
   /** Whether the address form is valid. */
   get formValid (): boolean {
     return ((this.deliveryAddressValid && (this.inheritDeliveryAddress || this.mailingAddressValid)) &&
-      (this.recDeliveryAddressValid && (this.inheritRecDeliveryAddress || this.recMailingAddressValid)))
+      (this.inheritRegisteredAddress || (this.recDeliveryAddressValid && (this.inheritRecDeliveryAddress || this.recMailingAddressValid))))
   }
 
   /** Whether any address has been modified from the original. */
@@ -312,17 +318,27 @@ export default class OfficeAddresses extends Mixins(CommonMixin) {
   // FUTURE: this API call should be in the parent component or some mixin/service
   async fetchAddresses (): Promise<void> {
     if (this.getIdentifier && this.asOfDate) {
+      // initialize the original address
+      this.original = {
+        registeredOffice: {
+          deliveryAddress: { actions: [] } as AddressIF,
+          mailingAddress: { actions: [] } as AddressIF
+        },
+        recordsOffice: {
+          deliveryAddress: { actions: [] } as AddressIF,
+          mailingAddress: { actions: [] } as AddressIF
+        }
+      } as RegRecAddressesIF
+
       const url = `businesses/${this.getIdentifier}/addresses?date=${this.asOfDate}`
       await axios.get(url).then(response => {
-        // registered office is required
+        // registered office is required for all companies
         const registeredOffice = response?.data?.registeredOffice
         if (registeredOffice) {
           this.original.registeredOffice = {
             deliveryAddress: { ...registeredOffice.deliveryAddress, actions: [] },
             mailingAddress: { ...registeredOffice.mailingAddress, actions: [] }
           }
-        } else {
-          throw new Error('Missing registered office address')
         }
 
         // records office is required for base companies
@@ -332,10 +348,11 @@ export default class OfficeAddresses extends Mixins(CommonMixin) {
             deliveryAddress: { ...recordsOffice.deliveryAddress, actions: [] },
             mailingAddress: { ...recordsOffice.mailingAddress, actions: [] }
           }
-        } else if (this.isBaseCompany) {
-          throw new Error('Missing records office address')
+        } else if (!this.isBaseCompany) {
+          this.original.recordsOffice = null
         }
       }).catch(error => {
+        if (error.response.status === StatusCodes.NOT_FOUND) return
         // eslint-disable-next-line no-console
         console.log('fetchAddresses() error =', error)
         // re-throw error
@@ -393,8 +410,8 @@ export default class OfficeAddresses extends Mixins(CommonMixin) {
         this.isSame(this.recDeliveryAddress, this.recMailingAddress, ['addressType'])
 
       this.inheritRegisteredAddress = (
-        this.isSame(this.deliveryAddress, this.recDeliveryAddress) &&
-        this.isSame(this.mailingAddress, this.recMailingAddress)
+        !this.isEmptyObject(this.deliveryAddress) && this.isSame(this.deliveryAddress, this.recDeliveryAddress) &&
+        !this.isEmptyObject(this.mailingAddress) && this.isSame(this.mailingAddress, this.recMailingAddress)
       )
     }
   }
diff --git a/src/mixins/common-mixin.ts b/src/mixins/common-mixin.ts
index 5e6c0e01a..0a0a111f3 100644
--- a/src/mixins/common-mixin.ts
+++ b/src/mixins/common-mixin.ts
@@ -99,4 +99,21 @@ export default class CommonMixin extends Vue {
       this.$router.push(route).catch(() => {}) // ignore potential navigation abort errors
     }
   }
+
+  /**
+   * Check if an obj is empty.
+   * @param obj the obj to check
+   * @returns a boolean if the obj is empty
+   */
+  isEmptyObject (obj): boolean {
+    if (!obj || typeof obj !== 'object' || Array.isArray(obj)) return true
+    return Object.values(obj).every((v) => {
+      return (
+        v === null ||
+        v === undefined ||
+        (typeof v === 'string' && v.trim() === '') ||
+        (Array.isArray(v) && v.length === 0)
+      )
+    })
+  }
 }
diff --git a/src/views/StandaloneOfficeAddressFiling.vue b/src/views/StandaloneOfficeAddressFiling.vue
index b71aba7de..b816f1da5 100644
--- a/src/views/StandaloneOfficeAddressFiling.vue
+++ b/src/views/StandaloneOfficeAddressFiling.vue
@@ -356,7 +356,10 @@ export default class StandaloneOfficeAddressFiling extends Mixins(CommonMixin, D
     this.setFilingData([])
 
     // listen for fetch error events
-    this.$root.$on('fetch-error-event', () => { this.fetchErrorDialog = true })
+    this.$root.$on('fetch-error-event', (error) => {
+      console.log(error)
+      this.fetchErrorDialog = true
+    })
 
     // before unloading this page, if there are changes then prompt user
     window.onbeforeunload = (event) => {


Reviews:
user: login: bobdev-94
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-22T15:52:53Z
user: login: severinbeauvais
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-22T16:32:20Z
user: login: severinbeauvais
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-22T16:37:57Z
user: login: severinbeauvais
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-28T16:24:16Z
user: login: severinbeauvais
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-28T16:26:17Z
user: login: bobdev-94
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-28T17:25:31Z
user: login: severinbeauvais
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-28T17:47:03Z
user: login: severinbeauvais
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-28T17:49:37Z
user: login: severinbeauvais
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-28T17:54:01Z
user: login: severinbeauvais
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-28T17:58:08Z
user: login: severinbeauvais
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-28T17:58:47Z
user: login: bobdev-94
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-28T18:12:02Z
user: login: bobdev-94
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-28T18:13:37Z
user: login: JazzarKarim
body: Looks good. Great stuff!
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-04-28T19:08:13Z
user: login: bobdev-94
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-28T19:08:31Z
user: login: bobdev-94
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-28T19:10:37Z
user: login: severinbeauvais
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-28T19:19:16Z
user: login: severinbeauvais
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-28T19:21:50Z
user: login: ArwenQin
body: Thank you. Looks great!
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-04-28T19:21:50Z
user: login: severinbeauvais
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-28T19:24:14Z
user: login: bobdev-94
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-28T19:55:12Z
user: login: bobdev-94
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-28T22:13:09Z
user: login: bobdev-94
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-28T22:13:23Z
user: login: severinbeauvais
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-29T17:18:24Z
user: login: severinbeauvais
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-29T17:19:03Z
user: login: severinbeauvais
body: I tested a few things and everything looks good.

For future consideration (no changes needed right now):
- I would like the template conditional code to be simplified :)
- `isEmptyObject` is somewhat specific to the address object, and ultimately it would be generalized or another function would be used instead for addresses; oh well, this is future problem if at all

Ready to merge!
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-04-29T17:21:58Z

Review comments:
diff_hunk: @@ -355,9 +355,6 @@ export default class StandaloneOfficeAddressFiling extends Mixins(CommonMixin, D
     // init
     this.setFilingData([])
 
-    // listen for fetch error events
-    this.$root.$on('fetch-error-event', () => { this.fetchErrorDialog = true })
-
path: src/views/StandaloneOfficeAddressFiling.vue
user: login: bobdev-94
body: Removed the fetch-error-event because at this moment, only fetch the address.
created_at: 2025-04-22T15:52:53Z
author_association: NONE
diff_hunk: @@ -355,9 +355,6 @@ export default class StandaloneOfficeAddressFiling extends Mixins(CommonMixin, D
     // init
     this.setFilingData([])
 
-    // listen for fetch error events
-    this.$root.$on('fetch-error-event', () => { this.fetchErrorDialog = true })
-
path: src/views/StandaloneOfficeAddressFiling.vue
user: login: severinbeauvais
body: So this ignores address fetch errors, right?

What if there's a legitimate address fetch error (other than "address not found")?
created_at: 2025-04-22T16:32:20Z
author_association: CONTRIBUTOR
diff_hunk: @@ -355,9 +355,6 @@ export default class StandaloneOfficeAddressFiling extends Mixins(CommonMixin, D
     // init
     this.setFilingData([])
 
-    // listen for fetch error events
-    this.$root.$on('fetch-error-event', () => { this.fetchErrorDialog = true })
-
path: src/views/StandaloneOfficeAddressFiling.vue
user: login: severinbeauvais
body: I think I need to clarify the requirements.

If the "fetch addresses" call returns "address not found" then:
- [ ] the change of address filing must start without errors
- [ ] the addresses component must show "(Not entered") for each address
- [ ] it must be possible to enter new addresses
- [ ] the filing must not be valid until new, valid addresses are entered
- [ ] the filing must be paid and filed without errors.

Otherwise, report errors as usual.
created_at: 2025-04-22T16:37:57Z
author_association: CONTRIBUTOR
diff_hunk: @@ -99,4 +99,20 @@ export default class CommonMixin extends Vue {
       this.$router.push(route).catch(() => {}) // ignore potential navigation abort errors
     }
   }
+
+  /**
+   * Check if an obj is empty.
+   * @param obj the obj to check
+   * @returns a boolean if the obj is empty
+   */
+  isEmptyObject (obj): boolean {
+    return Object.values(obj).every((v) => {
+      return (
+        v === null ||
+        v === undefined ||
+        (typeof v === 'string' && v.trim() === '') ||
+        (Array.isArray(v) && v.length === 0)
+      )
+    })
+  }
path: src/mixins/common-mixin.ts
user: login: severinbeauvais
body: Since we already import lodash, would it make sense to use Lodash.isEmpty() instead?
created_at: 2025-04-28T16:24:15Z
author_association: CONTRIBUTOR
diff_hunk: @@ -355,9 +355,6 @@ export default class StandaloneOfficeAddressFiling extends Mixins(CommonMixin, D
     // init
     this.setFilingData([])
 
-    // listen for fetch error events
-    this.$root.$on('fetch-error-event', () => { this.fetchErrorDialog = true })
-
path: src/views/StandaloneOfficeAddressFiling.vue
user: login: severinbeauvais
body: This code has been reverted.

I will move the requirements (above) to a new comment, and then I'll resolve this conversation.
created_at: 2025-04-28T16:26:16Z
author_association: CONTRIBUTOR
diff_hunk: @@ -99,4 +99,20 @@ export default class CommonMixin extends Vue {
       this.$router.push(route).catch(() => {}) // ignore potential navigation abort errors
     }
   }
+
+  /**
+   * Check if an obj is empty.
+   * @param obj the obj to check
+   * @returns a boolean if the obj is empty
+   */
+  isEmptyObject (obj): boolean {
+    return Object.values(obj).every((v) => {
+      return (
+        v === null ||
+        v === undefined ||
+        (typeof v === 'string' && v.trim() === '') ||
+        (Array.isArray(v) && v.length === 0)
+      )
+    })
+  }
path: src/mixins/common-mixin.ts
user: login: bobdev-94
body: https://github.com/bcgov/business-filings-ui/blob/5a130f3a2928baf36a53836a62ba8ac48867daa4/src/components/common/OfficeAddresses.vue#L338-L339

From the above line, after fetching, the address object can be - {actions: [] }
but, Lodash.isEmpty({actions: []}): false.
In this case, I think it needs to be empty - true.
created_at: 2025-04-28T17:25:31Z
author_association: NONE
diff_hunk: @@ -99,4 +99,20 @@ export default class CommonMixin extends Vue {
       this.$router.push(route).catch(() => {}) // ignore potential navigation abort errors
     }
   }
+
+  /**
+   * Check if an obj is empty.
+   * @param obj the obj to check
+   * @returns a boolean if the obj is empty
+   */
+  isEmptyObject (obj): boolean {
+    return Object.values(obj).every((v) => {
+      return (
+        v === null ||
+        v === undefined ||
+        (typeof v === 'string' && v.trim() === '') ||
+        (Array.isArray(v) && v.length === 0)
+      )
+    })
+  }
path: src/mixins/common-mixin.ts
user: login: severinbeauvais
body: Ideally this would accept a list of props to omit from the check, but this is OK for now.
created_at: 2025-04-28T17:47:02Z
author_association: CONTRIBUTOR
diff_hunk: @@ -99,4 +99,20 @@ export default class CommonMixin extends Vue {
       this.$router.push(route).catch(() => {}) // ignore potential navigation abort errors
     }
   }
+
+  /**
+   * Check if an obj is empty.
+   * @param obj the obj to check
+   * @returns a boolean if the obj is empty
+   */
+  isEmptyObject (obj): boolean {
+    return Object.values(obj).every((v) => {
+      return (
+        v === null ||
+        v === undefined ||
+        (typeof v === 'string' && v.trim() === '') ||
+        (Array.isArray(v) && v.length === 0)
+      )
+    })
+  }
path: src/mixins/common-mixin.ts
user: login: severinbeauvais
body: Please check if you can use `isSame(address, {}, ['actions'])`...?
created_at: 2025-04-28T17:49:37Z
author_association: CONTRIBUTOR
diff_hunk: @@ -99,4 +99,20 @@ export default class CommonMixin extends Vue {
       this.$router.push(route).catch(() => {}) // ignore potential navigation abort errors
     }
   }
+
+  /**
+   * Check if an obj is empty.
+   * @param obj the obj to check
+   * @returns a boolean if the obj is empty
+   */
+  isEmptyObject (obj): boolean {
+    return Object.values(obj).every((v) => {
+      return (
+        v === null ||
+        v === undefined ||
+        (typeof v === 'string' && v.trim() === '') ||
+        (Array.isArray(v) && v.length === 0)
+      )
+    })
+  }
path: src/mixins/common-mixin.ts
user: login: severinbeauvais
body: Please check the dev console for errors when adding a single address to this example:
https://business-filings-dev--pr-744-z19ltces.web.app/BC0883825/standalone-addresses?accountid=3040&filingId=0
created_at: 2025-04-28T17:54:01Z
author_association: CONTRIBUTOR
diff_hunk: @@ -99,4 +99,20 @@ export default class CommonMixin extends Vue {
       this.$router.push(route).catch(() => {}) // ignore potential navigation abort errors
     }
   }
+
+  /**
+   * Check if an obj is empty.
+   * @param obj the obj to check
+   * @returns a boolean if the obj is empty
+   */
+  isEmptyObject (obj): boolean {
+    return Object.values(obj).every((v) => {
+      return (
+        v === null ||
+        v === undefined ||
+        (typeof v === 'string' && v.trim() === '') ||
+        (Array.isArray(v) && v.length === 0)
+      )
+    })
+  }
path: src/mixins/common-mixin.ts
user: login: severinbeauvais
body: This causes an exception if `obj` is null or undefined. What prevention is there against this?
created_at: 2025-04-28T17:58:08Z
author_association: CONTRIBUTOR
diff_hunk: @@ -336,6 +342,14 @@ export default class OfficeAddresses extends Mixins(CommonMixin) {
           throw new Error('Missing records office address')
         }
       }).catch(error => {
+        if (error.response.status === StatusCodes.NOT_FOUND) {
+          this.original.registeredOffice = null
+          if (this.isBaseCompany) {
+            this.original.recordsOffice = null
+          }
path: src/components/common/OfficeAddresses.vue
user: login: severinbeauvais
body: Would it make more sense to initialize registeredOffice and recordsOffice to {} instead?
created_at: 2025-04-28T17:58:47Z
author_association: CONTRIBUTOR
diff_hunk: @@ -99,4 +99,20 @@ export default class CommonMixin extends Vue {
       this.$router.push(route).catch(() => {}) // ignore potential navigation abort errors
     }
   }
+
+  /**
+   * Check if an obj is empty.
+   * @param obj the obj to check
+   * @returns a boolean if the obj is empty
+   */
+  isEmptyObject (obj): boolean {
+    return Object.values(obj).every((v) => {
+      return (
+        v === null ||
+        v === undefined ||
+        (typeof v === 'string' && v.trim() === '') ||
+        (Array.isArray(v) && v.length === 0)
+      )
+    })
+  }
path: src/mixins/common-mixin.ts
user: login: bobdev-94
body: I missed it. I will update.
created_at: 2025-04-28T18:12:02Z
author_association: NONE
diff_hunk: @@ -336,6 +342,14 @@ export default class OfficeAddresses extends Mixins(CommonMixin) {
           throw new Error('Missing records office address')
         }
       }).catch(error => {
+        if (error.response.status === StatusCodes.NOT_FOUND) {
+          this.original.registeredOffice = null
+          if (this.isBaseCompany) {
+            this.original.recordsOffice = null
+          }
path: src/components/common/OfficeAddresses.vue
user: login: bobdev-94
body: I think it's more sensible.
But, not able to setup to {} because `this.original` was typed RegRecAddressesIF
https://github.com/bobdev-94/business-filings-ui/blob/968590f5f1ddf86323006318d91e7c215a5a16c4/src/components/common/OfficeAddresses.vue#L266

`original = {} as RegRecAddressesIF`


created_at: 2025-04-28T18:13:37Z
author_association: NONE
diff_hunk: @@ -99,4 +99,20 @@ export default class CommonMixin extends Vue {
       this.$router.push(route).catch(() => {}) // ignore potential navigation abort errors
     }
   }
+
+  /**
+   * Check if an obj is empty.
+   * @param obj the obj to check
+   * @returns a boolean if the obj is empty
+   */
+  isEmptyObject (obj): boolean {
+    return Object.values(obj).every((v) => {
+      return (
+        v === null ||
+        v === undefined ||
+        (typeof v === 'string' && v.trim() === '') ||
+        (Array.isArray(v) && v.length === 0)
+      )
+    })
+  }
path: src/mixins/common-mixin.ts
user: login: bobdev-94
body: This error?
<img width="1422" alt="Screenshot 2025-04-28 at 12 08 06 PM" src="https://github.com/user-attachments/assets/e99493c7-9d07-4a3c-bbd3-ffcbb656fcef" />

created_at: 2025-04-28T19:08:31Z
author_association: NONE
diff_hunk: @@ -99,4 +99,20 @@ export default class CommonMixin extends Vue {
       this.$router.push(route).catch(() => {}) // ignore potential navigation abort errors
     }
   }
+
+  /**
+   * Check if an obj is empty.
+   * @param obj the obj to check
+   * @returns a boolean if the obj is empty
+   */
+  isEmptyObject (obj): boolean {
+    return Object.values(obj).every((v) => {
+      return (
+        v === null ||
+        v === undefined ||
+        (typeof v === 'string' && v.trim() === '') ||
+        (Array.isArray(v) && v.length === 0)
+      )
+    })
+  }
path: src/mixins/common-mixin.ts
user: login: bobdev-94
body: Updated
created_at: 2025-04-28T19:10:37Z
author_association: NONE
diff_hunk: @@ -336,6 +342,14 @@ export default class OfficeAddresses extends Mixins(CommonMixin) {
           throw new Error('Missing records office address')
         }
       }).catch(error => {
+        if (error.response.status === StatusCodes.NOT_FOUND) {
+          this.original.registeredOffice = null
+          if (this.isBaseCompany) {
+            this.original.recordsOffice = null
+          }
path: src/components/common/OfficeAddresses.vue
user: login: severinbeauvais
body: I'd be OK with `this.original.recordsOffice = {} as OfficeAddressIF` if needed.
created_at: 2025-04-28T19:19:16Z
author_association: CONTRIBUTOR
diff_hunk: @@ -99,4 +99,20 @@ export default class CommonMixin extends Vue {
       this.$router.push(route).catch(() => {}) // ignore potential navigation abort errors
     }
   }
+
+  /**
+   * Check if an obj is empty.
+   * @param obj the obj to check
+   * @returns a boolean if the obj is empty
+   */
+  isEmptyObject (obj): boolean {
+    return Object.values(obj).every((v) => {
+      return (
+        v === null ||
+        v === undefined ||
+        (typeof v === 'string' && v.trim() === '') ||
+        (Array.isArray(v) && v.length === 0)
+      )
+    })
+  }
path: src/mixins/common-mixin.ts
user: login: severinbeauvais
body: I still see a console error with this one. To reproduce:
1. open the link
2. click Change button
3. enter just Registered Office Delivery Address
4. verify Registered Office Mailing Address is "Same as Delivery Address"
5. click checknox for Records Office "Same as Registered Office"
6. click Update Addresses

![image](https://github.com/user-attachments/assets/ae4a21cf-76c3-409f-956f-2aad3d0375c7)

created_at: 2025-04-28T19:21:50Z
author_association: CONTRIBUTOR
diff_hunk: @@ -99,4 +99,20 @@ export default class CommonMixin extends Vue {
       this.$router.push(route).catch(() => {}) // ignore potential navigation abort errors
     }
   }
+
+  /**
+   * Check if an obj is empty.
+   * @param obj the obj to check
+   * @returns a boolean if the obj is empty
+   */
+  isEmptyObject (obj): boolean {
+    return Object.values(obj).every((v) => {
+      return (
+        v === null ||
+        v === undefined ||
+        (typeof v === 'string' && v.trim() === '') ||
+        (Array.isArray(v) && v.length === 0)
+      )
+    })
+  }
path: src/mixins/common-mixin.ts
user: login: severinbeauvais
body: Yes.
created_at: 2025-04-28T19:24:14Z
author_association: CONTRIBUTOR
diff_hunk: @@ -99,4 +99,20 @@ export default class CommonMixin extends Vue {
       this.$router.push(route).catch(() => {}) // ignore potential navigation abort errors
     }
   }
+
+  /**
+   * Check if an obj is empty.
+   * @param obj the obj to check
+   * @returns a boolean if the obj is empty
+   */
+  isEmptyObject (obj): boolean {
+    return Object.values(obj).every((v) => {
+      return (
+        v === null ||
+        v === undefined ||
+        (typeof v === 'string' && v.trim() === '') ||
+        (Array.isArray(v) && v.length === 0)
+      )
+    })
+  }
path: src/mixins/common-mixin.ts
user: login: bobdev-94
body: > Please check if you can use `isSame(address, {}, ['actions'])`...?

it's a little difficult. :(
created_at: 2025-04-28T19:55:12Z
author_association: NONE
diff_hunk: @@ -99,4 +99,20 @@ export default class CommonMixin extends Vue {
       this.$router.push(route).catch(() => {}) // ignore potential navigation abort errors
     }
   }
+
+  /**
+   * Check if an obj is empty.
+   * @param obj the obj to check
+   * @returns a boolean if the obj is empty
+   */
+  isEmptyObject (obj): boolean {
+    return Object.values(obj).every((v) => {
+      return (
+        v === null ||
+        v === undefined ||
+        (typeof v === 'string' && v.trim() === '') ||
+        (Array.isArray(v) && v.length === 0)
+      )
+    })
+  }
path: src/mixins/common-mixin.ts
user: login: bobdev-94
body: > Please check the dev console for errors when adding a single address to this example: https://business-filings-dev--pr-744-z19ltces.web.app/BC0883825/standalone-addresses?accountid=3040&filingId=0

fixed
created_at: 2025-04-28T22:13:09Z
author_association: NONE
diff_hunk: @@ -336,6 +342,14 @@ export default class OfficeAddresses extends Mixins(CommonMixin) {
           throw new Error('Missing records office address')
         }
       }).catch(error => {
+        if (error.response.status === StatusCodes.NOT_FOUND) {
+          this.original.registeredOffice = null
+          if (this.isBaseCompany) {
+            this.original.recordsOffice = null
+          }
path: src/components/common/OfficeAddresses.vue
user: login: bobdev-94
body: Updated
created_at: 2025-04-28T22:13:23Z
author_association: NONE
diff_hunk: @@ -99,4 +99,20 @@ export default class CommonMixin extends Vue {
       this.$router.push(route).catch(() => {}) // ignore potential navigation abort errors
     }
   }
+
+  /**
+   * Check if an obj is empty.
+   * @param obj the obj to check
+   * @returns a boolean if the obj is empty
+   */
+  isEmptyObject (obj): boolean {
+    return Object.values(obj).every((v) => {
+      return (
+        v === null ||
+        v === undefined ||
+        (typeof v === 'string' && v.trim() === '') ||
+        (Array.isArray(v) && v.length === 0)
+      )
+    })
+  }
path: src/mixins/common-mixin.ts
user: login: severinbeauvais
body: Looks good! Resolving.
created_at: 2025-04-29T17:18:24Z
author_association: CONTRIBUTOR
diff_hunk: @@ -336,6 +342,14 @@ export default class OfficeAddresses extends Mixins(CommonMixin) {
           throw new Error('Missing records office address')
         }
       }).catch(error => {
+        if (error.response.status === StatusCodes.NOT_FOUND) {
+          this.original.registeredOffice = null
+          if (this.isBaseCompany) {
+            this.original.recordsOffice = null
+          }
path: src/components/common/OfficeAddresses.vue
user: login: severinbeauvais
body: Looks good. Resolving.
created_at: 2025-04-29T17:19:03Z
author_association: CONTRIBUTOR

PR comments:
user: login: bobdev-94
created_at: 2025-04-22T15:59:48Z
body: > Temporary Url for review: https://business-filings-dev--pr-744-z19ltces.web.app

https://business-filings-dev--pr-744-z19ltces.web.app/CP1002579/standalone-addresses?accountid=3040&businessid=CP1002579&filingId=0

https://business-filings-dev--pr-744-z19ltces.web.app/CP1002539/standalone-addresses?accountid=3040&businessid=CP1002539&filingId=0

https://business-filings-dev--pr-744-z19ltces.web.app/BC0887743/standalone-addresses?accountid=3040&businessid=BC0887743&filingId=0

https://business-filings-dev--pr-744-z19ltces.web.app/BC0883825/standalone-addresses?accountid=3040&businessid=BC0883825&filingId=0
author_association: NONE
user: login: severinbeauvais
created_at: 2025-04-24T17:22:53Z
body: Please do a bunch of testing. I see some edge cases that aren't right.

### 1. Both addresses should show "not entered"

![image](https://github.com/user-attachments/assets/62be3581-b7f6-45ea-8b65-c120f6d0aafa)

https://business-filings-dev--pr-744-z19ltces.web.app/CP1002539/standalone-addresses?accountid=3040&businessid=CP1002539&filingId=0

### 2. Wrong display after entering one or both addresses

![image](https://github.com/user-attachments/assets/a97953c5-351d-4509-8622-dbd0851585ab)

https://business-filings-dev--pr-744-z19ltces.web.app/CP1002579/standalone-addresses?accountid=3040&businessid=CP1002579&filingId=0

### 4. Upon entereding a new address, country should default to Canada (CA)

![image](https://github.com/user-attachments/assets/7671d9d7-57c5-40ee-a744-ca96d0110e46)

### 5. All four addresses should show "not entered"

![image](https://github.com/user-attachments/assets/f0a1233a-cc13-4af5-a2c9-57b48cb6716e)

https://business-filings-dev--pr-744-z19ltces.web.app/BC0887743/standalone-addresses?accountid=3040&businessid=BC0887743&filingId=0

### 6. Records Office body shouldn't display when "same as reg office" is checked

![image](https://github.com/user-attachments/assets/249fd98d-d72b-4367-b684-8597d7a914d5)

https://business-filings-dev--pr-744-z19ltces.web.app/BC0883825/standalone-addresses?accountid=3040&businessid=BC0883825&filingId=0

**_Update: these are now fixed._**
author_association: CONTRIBUTOR
user: login: bobdev-94
created_at: 2025-04-28T15:44:24Z
body: /gcbrun
author_association: NONE
user: login: bcregistry-sre
created_at: 2025-04-28T15:47:38Z
body: Temporary Url for review: https://business-filings-dev--pr-744-z19ltces.web.app
author_association: COLLABORATOR
user: login: severinbeauvais
created_at: 2025-04-28T16:26:10Z
body: ### Requirements

If the "fetch addresses" call returns "address not found" then:
- [ ] the change of address filing must start without errors
- [ ] the addresses component must show "(Not entered") for each address
- [ ] it must be possible to enter new addresses
- [ ] the filing must not be valid until new, valid addresses are entered
- [ ] the filing must be paid and filed without errors.

Otherwise, report errors as usual.
author_association: CONTRIBUTOR
user: login: bobdev-94
created_at: 2025-04-28T16:48:53Z
body: 1. Both addresses should show "not entered"

<img width="1390" alt="Screenshot 2025-04-28 at 9 08 33 AM" src="https://github.com/user-attachments/assets/ab06d5cf-fa7c-4c29-9a6d-f3e0a34be3a4" />

[CP1002539](https://business-filings-dev--pr-744-z19ltces.web.app/CP1002539/standalone-addresses?accountid=3040&businessid=CP1002539&filingId=0)

2. Wrong display after entering one or both addresses
<img width="1050" alt="Screenshot 2025-04-28 at 9 12 11 AM" src="https://github.com/user-attachments/assets/6262b8f5-e7c8-4a44-9e41-2f801c2fe1fa" />

[CP1002579](https://business-filings-dev--pr-744-z19ltces.web.app/CP1002579/standalone-addresses?accountid=3040&businessid=CP1002579&filingId=0)

5. All four addresses should show "not entered"

<img width="1057" alt="Screenshot 2025-04-28 at 9 13 51 AM" src="https://github.com/user-attachments/assets/7d0038ef-c0d1-4a53-a017-966ecaaef745" />

[BC0887743](https://business-filings-dev--pr-744-z19ltces.web.app/BC0887743/standalone-addresses?accountid=3040&businessid=BC0887743&filingId=0)

6. Records Office body shouldn't display when "same as reg office" is checked
<img width="1095" alt="Screenshot 2025-04-28 at 9 48 28 AM" src="https://github.com/user-attachments/assets/8a15c00e-eecf-4a6d-bf1f-b1b5269f4fc5" />

[BC0883825](https://business-filings-dev--pr-744-z19ltces.web.app/BC0883825/standalone-addresses?accountid=3040&businessid=BC0883825&filingId=0)

author_association: NONE
user: login: severinbeauvais
created_at: 2025-04-28T17:59:23Z
body: I didin't file any of the address changes but I tried all examples they worked well 👍 
author_association: CONTRIBUTOR
user: login: severinbeauvais
created_at: 2025-04-28T18:37:44Z
body: Bobby, please rebase your branch in preparation for merging it. Thanks.
author_association: CONTRIBUTOR
user: login: bobdev-94
created_at: 2025-04-28T18:52:19Z
body: /gcbrun
author_association: NONE
user: login: bcregistry-sre
created_at: 2025-04-28T18:55:47Z
body: Temporary Url for review: https://business-filings-dev--pr-744-z19ltces.web.app
author_association: COLLABORATOR
user: login: bobdev-94
created_at: 2025-04-28T19:09:17Z
body: > Bobby, please rebase your branch in preparation for merging it. Thanks.

I did
author_association: NONE
user: login: bobdev-94
created_at: 2025-04-28T22:13:42Z
body: /gcbrun
author_association: NONE
user: login: bcregistry-sre
created_at: 2025-04-28T22:16:07Z
body: Temporary Url for review: https://business-filings-dev--pr-744-z19ltces.web.app
author_association: COLLABORATOR
user: login: sonarqubecloud[bot]
created_at: 2025-04-28T22:16:43Z
body: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=bcgov_business-filings-ui&pullRequest=744) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=bcgov_business-filings-ui&pullRequest=744&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=bcgov_business-filings-ui&pullRequest=744&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=bcgov_business-filings-ui&pullRequest=744&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=bcgov_business-filings-ui&pullRequest=744&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=bcgov_business-filings-ui&pullRequest=744&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=bcgov_business-filings-ui&pullRequest=744)


author_association: NONE
user: login: bobdev-94
created_at: 2025-04-28T22:17:00Z
body: /gcbrun
author_association: NONE
user: login: bcregistry-sre
created_at: 2025-04-28T22:20:17Z
body: Temporary Url for review: https://business-filings-dev--pr-744-z19ltces.web.app
author_association: COLLABORATOR