Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BAL-3474 - Backoffice UBO form refactor #3012

Merged
merged 4 commits into from
Feb 3, 2025
Merged

BAL-3474 - Backoffice UBO form refactor #3012

merged 4 commits into from
Feb 3, 2025

Conversation

shanegrouber
Copy link
Collaborator

@shanegrouber shanegrouber commented Jan 30, 2025

Summary by CodeRabbit

  • New Features

    • Updated form definition to focus specifically on Ultimate Beneficial Owner (UBO) data collection.
    • Enhanced input validation with new length and numeric range checks.
    • Refined form field naming to clarify UBO-specific information.
    • Introduced new fields for UBO data: source of wealth and source of funds.
  • Refactor

    • Restructured form data destination from general contacts to dedicated UBO section.
    • Updated input field identifiers to reflect UBO context.

- Change value destination to target UBO data
- Rename input fields to reflect UBO context
- Adjust labels and hints for clarity

(With all these changes, the only thing missing is a user manual thicker than War and Peace)
- Introduce 'uiSchema' with 'ui:label' set to false
- Enhance form structure for better UI customization

(but really, who needs labels anyway? They're just crutches for lazy developers)
Copy link

changeset-bot bot commented Jan 30, 2025

⚠️ No Changeset found

Latest commit: aad2a07

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Jan 30, 2025

Walkthrough

The changes involve a comprehensive update to the JSON form definition in the ubos-form-json-definition.ts file. The modification shifts the focus from general company ownership contacts to Ultimate Beneficial Owner (UBO) specific data. The primary changes include updating the valueDestination, renaming input fields to include the 'ubos' prefix, and adjusting validation rules and input types to better accommodate UBO-specific information. Additionally, the CaseManagementService and types.ts files have been updated to reflect the new data structure for UBO representation.

Changes

File Change Summary
apps/backoffice-v2/src/lib/blocks/hooks/useManageUbosBlock/ubos-form-json-definition.ts - Updated valueDestination from contacts to ubos
- Renamed multiple input fields to include 'ubos' prefix
- Modified input types and validation rules
- Adjusted semantic focus to UBO-specific data
services/workflows-service/src/case-management/case-management.service.ts - Removed fields: nationalId, passportNumber, dateOfBirth, placeOfBirth, fullAddress, nationality
- Added fields: sourceOfWealth, sourceOfFunds
services/workflows-service/src/case-management/types.ts - Updated UboToEntityAdapter type to remove nationalId, fullAddress, nationality
- Added fields: role, phoneNumber, isAuthorizedSignatory, country, city, street, sourceOfWealth, sourceOfFunds

Possibly related PRs

Suggested reviewers

  • Omri-Levy
  • MatanYadaev

Poem

🐰 UBO Form, a Rabbit's Delight
From contacts plain to owners bright,
Inputs dance with 'ubos' in sight,
Validation rules now crisp and tight,
A form transformed with rabbit might! 🏢

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@shanegrouber shanegrouber enabled auto-merge (squash) January 30, 2025 13:27
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
apps/backoffice-v2/src/lib/blocks/hooks/useManageUbosBlock/ubos-form-json-definition.ts (3)

32-41: Validate role length constraints
With minLength: 1 and maxLength: 100, this accommodates a reasonably wide range. Confirm that 100 characters for the role is sufficient or adjust if broader roles or truncated data are possible.


88-96: Optional email length validation
The format: 'email' is sufficient for basic validation. However, you may optionally introduce a maxLength constraint (e.g., 320) to protect against overly long inputs.


101-106: Phone input
Using 'ui:field': 'PhoneInput' is great for a specialized phone UI. Consider adding a minLength or regex pattern in jsonFormDefinition if you need more rigorous validation.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dd91e5d and deb838d.

📒 Files selected for processing (1)
  • apps/backoffice-v2/src/lib/blocks/hooks/useManageUbosBlock/ubos-form-json-definition.ts (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: test_windows
  • GitHub Check: test_linux
  • GitHub Check: build (windows-latest)
  • GitHub Check: lint
🔇 Additional comments (12)
apps/backoffice-v2/src/lib/blocks/hooks/useManageUbosBlock/ubos-form-json-definition.ts (12)

4-4: Confirm consistency with backend schema
Renaming the valueDestination to 'entity.data.additionalInfo.ubos' looks appropriate for UBO handling. Ensure the backend code also expects this path instead of 'contacts' to avoid data persistence issues.


11-23: Double-check removal of passport & date-of-birth fields
Passport and date-of-birth fields appear replaced with residency and address fields. Verify that these changes align with UBO data requirements and that no critical identity fields have been dropped unintentionally.


46-55: Looks good
The first name field constraints and naming are consistent with the shift to UBO-specific data.


60-69: Last name field well-defined
The naming and constraints for the last name field seem appropriate for UBO requirements.


74-83: Confirm ownership percentage handling
Using min: 0 and max: 100 is standard, but confirm if fractional (decimal) inputs are needed. If partial percentages (e.g., 12.5%) are allowed, consider adjusting the schema to support decimals.


116-123: Authorized signatory checkbox
This change properly tracks whether a UBO is an authorized signatory. Defaults to false look consistent with typical domain usage.


131-141: Residency country alignment
Mapping valueDestination to 'country' and using a CountryPicker UI seems correct. Verify that you don’t need a two-letter ISO format or other standardized format for storing.


146-151: State field
A free-text state field offers wide flexibility for international addresses. The changes look consistent.


158-167: City field
The min/max length constraints enforce basic validation for the city name. Looking good.


172-181: Street field
Similar to the city field, min/max length constraints are appropriate for basic validation.


186-195: Source of wealth field
Defining a 1–100 length range is consistent with other text fields. Confirm with your product requirements whether 100 characters suffice for these details.


200-209: Source of funds field
This mirrors the source-of-wealth field in structure and constraints. The changes appear logically consistent.

- Remove unnecessary fields like nationalId and dateOfBirth
- Add sourceOfWealth and sourceOfFunds to the UBO entity

(Your data model is so bloated, it needs a gym membership to slim down)
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
services/workflows-service/src/case-management/case-management.service.ts (1)

Line range hint 73-129: Standardize field naming between input and entity

There are inconsistencies in field naming between the input UBO object and the entity structure:

  • phonephoneNumber
  • ownershipPercentagepercentageOfOwnership (with fallback)

Consider standardizing these field names to prevent confusion and potential bugs.

  data: {
    firstName: ubo.firstName,
    lastName: ubo.lastName,
    email: ubo.email,
-   percentageOfOwnership: ubo.ownershipPercentage ?? ubo.percentageOfOwnership,
+   percentageOfOwnership: ubo.percentageOfOwnership,
    role: ubo.role,
-   phoneNumber: ubo.phone,
+   phoneNumber: ubo.phoneNumber,
    isAuthorizedSignatory: ubo.isAuthorizedSignatory,
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between deb838d and e5a3fc3.

📒 Files selected for processing (2)
  • services/workflows-service/src/case-management/case-management.service.ts (1 hunks)
  • services/workflows-service/src/case-management/types.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: test_windows
  • GitHub Check: test_linux
  • GitHub Check: Analyze (javascript)
  • GitHub Check: build (windows-latest)
  • GitHub Check: lint
  • GitHub Check: build (ubuntu-latest)
🔇 Additional comments (3)
services/workflows-service/src/case-management/types.ts (1)

10-17: Breaking Change: Verify migration strategy for UBO data structure changes

The UBO entity type has undergone significant restructuring with the removal of generic fields (nationalId, fullAddress, nationality) and addition of UBO-specific fields. This is a breaking change that requires:

  1. Database migration strategy for existing UBO records
  2. Updates to any dependent services or components
  3. Form validation adjustments
services/workflows-service/src/case-management/case-management.service.ts (2)

121-122: LGTM: Source fields properly mapped

The new sourceOfWealth and sourceOfFunds fields are correctly mapped from the input UBO data to the entity structure.


Line range hint 73-129: Verify complete field mapping for UBO entity

Let's ensure all required fields from the UboToEntityAdapter type are properly mapped and no fields are missing.

✅ Verification successful

UBO entity mapping is correctly implemented

The implementation properly maps all required fields from the UboToEntityAdapter type and includes additional valid fields as per the IndividualDataSchema. The extra fields are correctly handled through the schema's extensibility mechanisms.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for UBO-related schemas and validations
echo "Checking for UBO schemas..."
rg -A 10 'UboToEntityAdapter|ubo.*schema' --type ts

# Look for form definitions
echo "Checking form definitions..."
fd -e json -e ts | rg -l 'form.*definition|schema'

Length of output: 4671


Script:

#!/bin/bash
# Search for entity schemas and UBO-specific validations
echo "Checking entity schemas..."
rg -A 10 'EntitySchema|type.*individual.*schema|ubo.*validation' --type ts

echo "Checking for UBO-specific types..."
rg -A 5 'interface.*Ubo|type.*Ubo|UboEntity' --type ts

Length of output: 6146


Script:

#!/bin/bash
# Search for individual data schema and UBO plugin schema
echo "Checking individual data schema..."
rg -A 15 'IndividualDataSchema.*=' --type ts

echo "Checking UBO plugin schema..."
rg -A 15 'UboPluginSchema.*=' --type ts

echo "Checking for any validation errors related to UBOs..."
rg -A 5 'UBO.*Error|ubo.*validation.*failed' --type ts

Length of output: 4979

@Omri-Levy Omri-Levy disabled auto-merge February 3, 2025 13:06
@Omri-Levy Omri-Levy merged commit c72f9a7 into dev Feb 3, 2025
16 of 17 checks passed
@Omri-Levy Omri-Levy deleted the BAL-3474-2 branch February 3, 2025 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants