bcgov / entity

ServiceBC Registry Team working on Legal Entities
Apache License 2.0
23 stars 57 forks source link

UI: MHR Corrections Drafts #19622

Open arlentees opened 3 months ago

arlentees commented 3 months ago
LizGovier commented 2 months ago

Hey team! Please add your planning poker estimate with Zenhub @cameron-eyds @chdivyareddy @dimak1 @doug-lovett

cameron-eyds commented 1 month ago

@arlentees As per out discussions in standup, to avoid confusion with Staff i have hidden the 'Save' and 'Save Resume Later' buttons for the MHR Corrections flow until the later date when we pick up this ticket.

arlentees commented 1 month ago

Great, thanks @cameron-eyds!

dimak1 commented 2 weeks ago

@LizGovier @chdivyareddy When saving the MHR Correction, the registration is added to MHR table as draft. It is saved as a regular reg draft, so when you open it to Edit, there are no indications that this is a Correction - the title and information is pre-filled, but the correction badges are not showing. Is this how it supposed to be? cc: @arlentees

Correction before Save and Resume

Screenshot 2024-04-29 at 04.33.35.png

Draft on Resume

Screenshot 2024-04-29 at 04.34.13.png
cameron-eyds commented 2 weeks ago

@dimak1 I don't believe so, no. We need to use the document type to indicate that this is a correction filing not a registration when opening the correction(or amendment) draft. All distinct APIRegistrationTypes types. This should be either REGC_STAFF, REGC_CLIENT or PUBA.

Ensuring that type is set should also resolve the tittle (not sure about the -draft portion tho) and the absence of badges

dimak1 commented 2 weeks ago

Thanks for clarification @cameron-eyds. When I tried to save the draft with a corrections type, I got error from API that it is not the supported one. I will connect with @doug-lovett about it.

"rootCause": "detail:[Schema validation: 'REGC_STAFF' is not one of ['DECAL_REPLACE', 'EXEMPTION_RES', 'EXEMPTION_NON_RES', 'MHREG', 'PERMIT', 'PERMIT_EXTENSION', 'TRANS', 'TRAND', 'TRANS_AFFIDAVIT', 'TRANS_ADMIN', 'TRANS_WILL', 'REG_STAFF_ADMIN'].],message:003: Draft request data validation errors. "

cameron-eyds commented 2 weeks ago

@dimak1 No prob, sounds good!

doug-lovett commented 2 weeks ago

@dimak1 as discussed, REGC_STAFF is a document type, not a registration type. The registrationType should be REG_STAFF_ADMIN and the documentType should be in the draft registration payload.

dimak1 commented 2 weeks ago

Need to talk to Doug about potential API changes to support the Draft Corrections. Will put this back into Spring backlog for now.

doug-lovett commented 2 weeks ago

Hi @dimak1 the API endpoint for maintaining drafts is designed so the draft JSON can be whatever you want without validation, so I would be surprised if this needs changing. It could be the drafts summary that shows up in the UI account registrations table needs updating?

dimak1 commented 2 weeks ago

Hi @doug-lovett, I tried to save the draft with registrationType: "REGC_STAFF" to indicate this was Staff Correction, but when I tried to load the draft, the prop is not there. There is not enough info in the draft response to load the proper correction type.

Screenshot 2024-05-02 at 03.05.39.png

Response when loading the draft

Screenshot 2024-05-02 at 03.05.21.png
doug-lovett commented 2 weeks ago

@dimak1 here is correction draft that works: POST https://bcregistry-dev.apigee.net/mhr/api/v1/drafts:

{
  "type": "REG_STAFF_ADMIN",
  "registration": {
      "mhrNumber": "108328",
      "clientReferenceId": "UT-REGC-LOCATION",
      "ownLand": false,
      "attentionReference": "James Irving",
      "documentType": "REGC_STAFF",
      "documentId": "80899007",
      "submittingParty": {
        "businessName": "ABC UNIT TEST COMPANY",
        "address": {
          "street": "222 SUMMER STREET",
          "city": "VICTORIA",
          "region": "BC",
          "country": "CA",
          "postalCode": "V8W 2V8"
        },
        "emailAddress": "test1@abc-ut.com"
      },
      "location": {
        "locationType": "OTHER",
        "lot": "22",
        "plan": "22",
        "landDistrict": "SIMILKAMEEM",
        "address": {
          "street": "8300 GALLAGHER LK FRONTAGE RD",
          "city": "NELSON",
          "region": "BC",
          "country": "CA",
          "postalCode": " "
        },
        "leaveProvince": false
      }
  }
}

And the fetch that works: GET https://bcregistry-dev.apigee.net/mhr/api/v1/drafts/000479 response:

{
  "createDateTime": "2024-05-02T17:26:13+00:00",
  "draftNumber": "000479",
  "lastUpdateDateTime": "2024-05-02T17:26:13+00:00",
  "outOfDate": false,
  "registration": {
    "attentionReference": "James Irving",
    "clientReferenceId": "UT-REGC-LOCATION",
    "documentId": "80899007",
    "documentType": "REGC_STAFF",
    "location": {
      "address": {
        "city": "NELSON",
        "country": "CA",
        "postalCode": " ",
        "region": "BC",
        "street": "8300 GALLAGHER LK FRONTAGE RD"
      },
      "landDistrict": "SIMILKAMEEM",
      "leaveProvince": false,
      "locationType": "OTHER",
      "lot": "22",
      "plan": "22"
    },
    "mhrNumber": "108328",
    "ownLand": false,
    "submittingParty": {
      "address": {
        "city": "VICTORIA",
        "country": "CA",
        "postalCode": "V8W 2V8",
        "region": "BC",
        "street": "222 SUMMER STREET"
      },
      "businessName": "ABC UNIT TEST COMPANY",
      "emailAddress": "test1@abc-ut.com"
    }
  },
  "type": "REG_STAFF_ADMIN"
}

And the fetch for your draft that returns a 200: GET https://bcregistry-dev.apigee.net/mhr/api/v1/drafts/000477 response:

{
  "createDateTime": "2024-05-02T10:01:40+00:00",
  "draftNumber": "000477",
  "lastUpdateDateTime": "2024-05-02T10:01:40+00:00",
  "outOfDate": false,
  "registration": {
    "clientReferenceId": "",
    "description": {
      "baseInformation": {
        "make": "Watson",
        "model": "Duchess",
        "year": 2012
      },
      "hasNoCertification": true,
      "manufacturer": "Starline",
      "sectionCount": 1,
      "sections": [
        {
          "lengthFeet": 52,
          "lengthInches": 7,
          "serialNumber": "BC873487",
          "widthFeet": 35,
          "widthInches": 5
        }
      ]
    },
    "documentId": "",
    "documentType": "REGC_STAFF",
    "location": {
      "address": {
        "city": "BURLINGTON",
        "country": "CA",
        "postalCode": "L7P 4X5",
        "region": "ON",
        "street": "32-1150 SKYVIEW DR"
      },
      "legalDescription": "THE NORTH WEST 1/4 OF SECTION 8 TOWNSHIP 79 RANGE 15 WEST OF THE 6TH MERIDIAN PEACE RIVER DISTRICT",
      "locationId": 200851,
      "locationType": "STRATA",
      "otherType": "STRATA",
      "pidNumber": "014597365",
      "status": "ACTIVE"
    },
    "mhrNumber": "108323",
    "ownLand": false,
    "ownerGroups": [
      {
        "groupId": 1,
        "interest": "Undivided",
        "interestDenominator": 3,
        "interestNumerator": 1,
        "owners": [
          {
            "address": {
              "city": "NEW YORK",
              "country": "US",
              "postalCode": "10017-1103",
              "region": "NY",
              "street": "423 MADISON AVE"
            },
            "groupId": 1,
            "organizationName": "ALTAC SERVICES INC.",
            "ownerId": 993797,
            "partyType": "OWNER_BUS",
            "phoneExtension": "1",
            "phoneNumber": "8745823953",
            "status": "ACTIVE",
            "type": "JOINT"
          },
          {
            "address": {
              "city": "VICTORIA",
              "country": "CA",
              "postalCode": "V8V 1X6",
              "region": "BC",
              "street": "243-617 GOVERNMENT ST"
            },
            "groupId": 1,
            "organizationName": "SPIRAL ORGANICS LIMITED",
            "ownerId": 993798,
            "partyType": "OWNER_BUS",
            "phoneExtension": "1",
            "phoneNumber": "9328948239",
            "status": "ACTIVE",
            "type": "JOINT"
          },
          {
            "address": {
              "city": "CHILLIWACK",
              "country": "CA",
              "postalCode": "V2R 0H4",
              "region": "BC",
              "street": "42-6577 SOUTHDOWNE PL"
            },
            "groupId": 1,
            "individualName": {
              "first": "CHARLIE",
              "last": "HAWKINS"
            },
            "ownerId": 993799,
            "partyType": "OWNER_IND",
            "phoneExtension": "53423",
            "phoneNumber": "2389592839",
            "status": "ACTIVE",
            "type": "JOINT"
          }
        ],
        "status": "ACTIVE",
        "tenancySpecified": true,
        "type": "JOINT"
      },
      {
        "groupId": 2,
        "interest": "Undivided",
        "interestDenominator": 3,
        "interestNumerator": 1,
        "owners": [
          {
            "address": {
              "city": "TORONTO",
              "country": "CA",
              "postalCode": "M5N 2P3",
              "region": "ON",
              "street": "423-2121 BATHURST ST"
            },
            "description": "ADMINISTRATOR OF THE ESTATE OF HIRAM SHELTON, DECEASED",
            "groupId": 2,
            "individualName": {
              "first": "CLARK",
              "last": "MACDONALD",
              "middle": "S"
            },
            "ownerId": 993800,
            "partyType": "ADMINISTRATOR",
            "status": "ACTIVE",
            "type": "NA"
          }
        ],
        "status": "ACTIVE",
        "tenancySpecified": true,
        "type": "NA"
      },
      {
        "groupId": 3,
        "interest": "Undivided",
        "interestDenominator": 3,
        "interestNumerator": 1,
        "owners": [
          {
            "address": {
              "city": "NORTH YORK",
              "country": "CA",
              "postalCode": "M6B 1W8",
              "region": "ON",
              "street": "123-160 TYCOS DR"
            },
            "description": "EXECUTOR OF THE WILL OF RALEIGH MCCARTY, DECEASED",
            "groupId": 3,
            "individualName": {
              "first": "KIM",
              "last": "SMITH"
            },
            "ownerId": 993801,
            "partyType": "EXECUTOR",
            "status": "ACTIVE",
            "type": "NA"
          }
        ],
        "status": "ACTIVE",
        "tenancySpecified": true,
        "type": "NA"
      }
    ],
    "registrationType": "REGC_STAFF",
    "submittingParty": {
      "address": {},
      "personName": {}
    }
  },
  "type": "REG_STAFF_ADMIN"
}
doug-lovett commented 2 weeks ago

The API looks like it is working correctly to me saving and retrieving a correction draft.

LizGovier commented 1 week ago

Hey @dimak1 To answer your question:

When saving the MHR Correction, the registration is added to MHR table as draft. It is saved as a regular reg draft, so when you open it to Edit, there are no indications that this is a Correction - the title and information is pre-filled, but the correction badges are not showing. Is this how it supposed to be?

When opening a draft, the correction badges should still show .

dimak1 commented 1 week ago

@LizGovier I figured it out, all good now. It will be soon available for UXA. Thanks!

LizGovier commented 1 week ago

@dimak1 Race Conditions And as per our discussion regarding race conditions, if changes to the home have been registered by another and user clicks 'Save and Resume later', save or 'Register and Pay', a model will appear. Providing three options,"Return to my registration, (X), or 'Update to latest Version'. Update to latest version will load the page to the latest registered version of the MHR Info page. I've created a UI design for reference: https://www.figma.com/file/6emtVNBTFZxm5Sd9ls9dNW/MHR---Conditions?type=design&node-id=862-70792&mode=design

dimak1 commented 1 week ago

Thanks @LizGovier. I suggest we UXA this ticket, even thou there are no UXA label. Preview link: https://bcregistry-assets-dev--pr-1858-m6z907xf.web.app/ cc: @saragunnarsson

LizGovier commented 1 week ago

Hey @dimak1

Private Zenhub Video

dimak1 commented 1 week ago

@LizGovier sorry I forgot to reset the flag for the modal. It is fixed now, thank you. https://bcregistry-assets-dev--pr-1858-m6z907xf.web.app/

LizGovier commented 1 week ago

Hey @dimak1, The modal seems to be missing when I click "Register and Pay.

Race Condition Scenario Step 1 (in Tab 1): Opened MHR #108326 > Clicked 'Registry Corrections' > 'Client Omission/Error' to open up the correction flow.

Step 2 (in Tab 2): Opened MHR #108326 > Clicked 'Registry Corrections' > 'Client Omission/Error' to open up the correction flow > made correction > registered correction

Step 3 (In Tab 1) Made a correction in MHR #108326, went to click 'Register and Pay' then nothing happens. It looks like the page is trying to load the Modal (See video)

Private Zenhub Video

dimak1 commented 1 week ago

@LizGovier I tried twice (mhr 108328) but could not reproduce what you got. Both times the registration went thru, which I think is expected, because each new correction is overwriting the previous one. I don't think this is true race condition - Tab 1 and Tab 2 does not know about each other, it is two separate flows, one after another. To see the Outdated Modal we need to save a draft, overwrite MHR with a Correction, and then try to load that draft, which would be outdated.

LizGovier commented 1 week ago

@dimak1 I'm only able to test using the one account so I used two separate tabs, which technically it should work because the "register and Pay' should compare the updated registered information on what the person was working on. However, maybe we need to push this to dev to test on different accounts.

dimak1 commented 1 week ago

@doug-lovett could you please add your comments regarding race conditions while using two separate tabs? I'm pretty sure two Corrections could be submitted from two tabs, one after another.

doug-lovett commented 1 week ago

@dimak1 @LizGovier the "race condition" check only applies to registrations where drafts are saved. Submitting 2 changes on the same MH at almost the same time where there is no draft saved is valid. The race condition check only applies to a change registration with a draft where a registration completes after the draft was created. Testing should work with 2 tabs or some chrome Incognito windows. And it should work with any registration type. For example saving a draft correction, then completing a transport permit on the same MH. Submitting the correction with the saved draft should then fail.

dimak1 commented 1 week ago

Thanks @doug-lovett. So yea, we need to save a draft at some point to trigger a race condition @LizGovier

LizGovier commented 1 week ago

Right... Just re-reviewing the task in this ticket and realized that this is specific only to drafts.

@dimak1 Let me know if you'd like another ticket created, but above I was referring to the race condition when two users are making changes to the same registration: If an MHR is being worked on by two users at the same time, the user who registers their document changes first will not be effected. The other user’s document will be invalid and they will need to start again with the latest version. Design (15846 Race Conditions): https://www.figma.com/file/6emtVNBTFZxm5Sd9ls9dNW/MHR---Conditions?type=design&node-id=862-70792&mode=design

dimak1 commented 1 week ago

@LizGovier the race conditions for the MHR Registration or Transfers should already be in place. If we do find something isn't working as it should be - we can create a ticket.

LizGovier commented 1 week ago

Thanks @dimak1 this is RFQA

@chdivyareddy I've added a verify task regarding a race condition at the top of this ticket. Let me know if you have questions

chdivyareddy commented 4 days ago

@dimak1 , Please take a look at the following scenarios and let me know if you are unable to reproduce those, thanks!

chdivyareddy commented 3 days ago

Hey @dimak1 , for the public amendment, when the submitting party details are entered and saved, then trying to resume draft by clicking on the edit button redirects user back to the dashboard. Please take a look, thanks!

Private Zenhub Video

dimak1 commented 3 days ago

Hi @chdivyareddy, thanks for the video. Public amendment is fixed in the same PR, and ready to be merged, pls let me know.

I noticed that saved drafts are also in the table after filing. I assume they should not be showing? @doug-lovett

Screenshot 2024-05-15 at 11.12.59.png
dimak1 commented 3 days ago

Hi @chdivyareddy, thanks for the video. Public amendment is fixed in the same PR, and ready to be merged, pls let me know.

I noticed that saved drafts are also in the table after filing. I assume they should not be showing? @doug-lovett

Screenshot 2024-05-15 at 11.12.59.png
chdivyareddy commented 3 days ago

@dimak1 , Please go ahead!

From your screenshot, drafts can still be shown in the table, but user cannot edit those, as soon as they click on the edit button "Draft no longer valid" modal gets displayed and can delete those.

image.png

But, if you are submitting the saved draft then the draft should no longer be displayed in the table.

dimak1 commented 3 days ago

@chdivyareddy Fixes for Draft Corrections and PUBA and in DEV. Regarding the screenshot, yes, i was submitting the saved draft.

chdivyareddy commented 2 days ago

@dimak1 , I'm seeing issues with the race condition scenarios, please take a look at it and let me know if you are unable to reproduce them, thank you!

Race condition scenarios:

image.png image.png image.png

{ "errorMessage": "API backend third party service error.", "rootCause": "detail:[Additional validation: Document ID must be unique: provided value already exists. The owner group interest numerator sum does not equal the interest common denominator. The owner group with ID 9 is not active and cannot be changed. The owner group with ID 10 is not active and cannot be changed. The owner group with ID 11 is not active and cannot be changed. The owner group with ID 12 is not active and cannot be changed. ],message:003: Registration request data validation errors. " }

image.png

{ "errorMessage": "API backend third party service error.", "rootCause": "detail:[Additional validation: Document ID must be unique: provided value already exists. The owner group interest numerator sum does not equal the interest common denominator. The owner group with ID 15 is not active and cannot be changed. The owner group with ID 16 is not active and cannot be changed. ],message:003: Registration request data validation errors. " }

dimak1 commented 2 days ago

Thanks @chdivyareddy I will take a look.

dimak1 commented 2 days ago

@chdivyareddy Issue 1 - I think this is a valid scenario. Saving one draft after another should be allowed. This is not a filing, so I think there could be many drafts saved concurrently. We can confirm with @doug-lovett

For other issues, when we do a Corrections filing, we were missing a condition for failed admin-registration attempt. Because of the nature of this error (unique Document ID required), it does not mean there is existing registration already, it's just a Doc Id validation failed. I fixed it and now it displays a generic error modal. To have a 'Changes Cannot Be Saved' modal, we'll need API to return a specific error. (eg. for outdated transfers API returns error The owner group with ID ... is not active and cannot be changed). @doug-lovett

Screenshot 2024-05-17 at 07.03.51.png

\