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

chore(inheritance-report): assets overview changes and minor spouse share fix #14652

Merged
merged 6 commits into from
May 6, 2024

Conversation

stjanilofts
Copy link
Member

@stjanilofts stjanilofts commented Apr 30, 2024

Assets overview changes and minor spouse share fix

They liked the way the new design of the "assets to share" values screen looked and wanted the assets overview screen to have the same design.

image

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • Refactor

    • Centralized asset total calculation for improved consistency.
    • Streamlined inheritance value calculations by removing conditional additions.
  • New Features

    • Introduced comprehensive asset overview with detailed information.
    • Added new types and functions for enhanced asset display.
  • Documentation

    • Updated component exports and imports for new functionalities.
  • Bug Fixes

    • Improved asset section forms with new custom fields for better data handling.

@stjanilofts stjanilofts requested a review from a team as a code owner April 30, 2024 16:37
Copy link
Contributor

coderabbitai bot commented Apr 30, 2024

Walkthrough

The recent updates to the inheritance-report application streamline asset calculations, refine inheritance value computations, and enhance asset overview components. These changes centralize data handling and improve the application's functionality.

Changes

File Path Change Summary
.../CalculateTotalAssets/index.tsx,
.../lib/utils/calculateTotalAssets.ts
Refactored asset calculations using calculateTotalAssets utility function.
.../HeirsAndPartitionRepeater/index.tsx,
.../fields/CalculateShare/index.tsx
Adjusted inheritance value calculations and handling.
.../OverviewAssets/index.tsx,
.../OverviewAssets/rows.ts,
.../OverviewAssets/types.ts
Improved asset overview generation and introduced structured data types.
.../fields/index.ts,
.../forms/sections/assets.ts
Updated exports and configurations for asset overview integration.
.../lib/dataSchema.ts,
.../lib/utils/calculateTotalAssets.ts
Restructured data schema for custom share percentage handling.
.../lib/messages.ts Added a new message for custom spouse share percentage validation.
.../template-api-modules/src/lib/modules/templates/inheritance-report/utils/mappers.ts Updated expandAnswers function for nested custom share properties.
.../fields/AssetsRepeater/index.tsx Utilized formatMessage for button and label text rendering.
.../types.ts Expanded StocksData interface with descriptive fields.

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

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: 4

Out of diff range and nitpick comments (1)
libs/application/templates/inheritance-report/src/fields/OverviewAssets/types.ts (1)

12-15: Consider adding comments to describe optional properties in RowType.

Adding comments can improve the readability and maintainability of the type definitions, especially for new developers or external contributors.

@datadog-island-is
Copy link

datadog-island-is bot commented Apr 30, 2024

Datadog Report

Branch report: chore/ir-overviewchanges
Commit report: e9dc54b
Test service: api

✅ 0 Failed, 4 Passed, 0 Skipped, 21.86ms Wall Time
➡️ Test Sessions change in coverage: 1 no change

Copy link

codecov bot commented Apr 30, 2024

Codecov Report

Attention: Patch coverage is 0% with 201 lines in your changes are missing coverage. Please review.

Project coverage is 37.03%. Comparing base (fa51195) to head (6fdbc23).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #14652      +/-   ##
==========================================
- Coverage   37.04%   37.03%   -0.02%     
==========================================
  Files        6259     6210      -49     
  Lines      126918   127074     +156     
  Branches    36315    36611     +296     
==========================================
+ Hits        47023    47063      +40     
- Misses      79895    80011     +116     
Flag Coverage Δ
api 3.47% <ø> (ø)
services-university-gateway 48.48% <ø> (+0.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...ritance-report/src/fields/AssetsRepeater/index.tsx 0.00% <ø> (ø)
...es/inheritance-report/src/forms/sections/assets.ts 0.00% <ø> (ø)
...tes/inheritance-report/src/forms/sections/heirs.ts 0.00% <ø> (ø)
...n/templates/inheritance-report/src/lib/messages.ts 0.00% <ø> (ø)
...CalculationsOfTotal/CalculateTotalAssets/index.tsx 0.00% <0.00%> (ø)
...ort/src/fields/HeirsAndPartitionRepeater/index.tsx 0.00% <0.00%> (ø)
...ules/templates/inheritance-report/utils/mappers.ts 3.26% <0.00%> (ø)
...ritance-report/src/fields/CalculateShare/index.tsx 0.00% <0.00%> (ø)
...templates/inheritance-report/src/lib/dataSchema.ts 0.00% <0.00%> (ø)
...tance-report/src/lib/utils/calculateTotalAssets.ts 0.00% <0.00%> (ø)
... and 2 more

... and 279 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eb7108c...6fdbc23. Read the comment docs.

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: 4

Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 069a10b and d550ff4.
Files selected for processing (8)
  • libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/utils/mappers.ts (1 hunks)
  • libs/application/templates/inheritance-report/src/fields/AssetsRepeater/index.tsx (2 hunks)
  • libs/application/templates/inheritance-report/src/fields/CalculateShare/index.tsx (3 hunks)
  • libs/application/templates/inheritance-report/src/fields/OverviewAssets/index.tsx (1 hunks)
  • libs/application/templates/inheritance-report/src/forms/sections/assets.ts (3 hunks)
  • libs/application/templates/inheritance-report/src/forms/sections/heirs.ts (2 hunks)
  • libs/application/templates/inheritance-report/src/lib/dataSchema.ts (1 hunks)
  • libs/application/templates/inheritance-report/src/lib/messages.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • libs/application/templates/inheritance-report/src/lib/messages.ts
Files skipped from review as they are similar to previous changes (2)
  • libs/application/templates/inheritance-report/src/fields/OverviewAssets/index.tsx
  • libs/application/templates/inheritance-report/src/forms/sections/assets.ts
Additional Context Used
Path-based Instructions (5)
libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/utils/mappers.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/inheritance-report/src/forms/sections/heirs.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/inheritance-report/src/fields/AssetsRepeater/index.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/inheritance-report/src/lib/dataSchema.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/inheritance-report/src/fields/CalculateShare/index.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
Additional comments not posted (5)
libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/utils/mappers.ts (1)

283-288: Ensure the customShare object handles empty arrays correctly.

Verification successful

The review comment was concerned with ensuring that the customShare object handles empty arrays correctly. From the script output, we can see several references to customShare across different files in the inheritance report module. Notably, in the mappers.ts file, the handling of hasCustomSpouseSharePercentage uses the nullish coalescing operator (??) to provide a default value of an empty array if the property is undefined. This is a correct way to handle potential undefined or null values, ensuring that the property defaults to an empty array when not specified.

Given this, the customShare object does handle empty arrays correctly as it provides a default empty array when the value is not present, which aligns with the expectations set in the review comment.

Conclusion:

  • The customShare object in the mappers.ts file is implemented to handle empty arrays correctly by providing default values where necessary.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the `customShare` object handles empty arrays correctly.

# Test: Search for the function usage. Expect: Proper handling of empty arrays.
rg --type typescript $'customShare'

Length of output: 69



Script:

#!/bin/bash
# Description: Verify that the `customShare` object handles empty arrays correctly.

# Correcting the previous script error by specifying the correct file type for TypeScript files.
rg --type ts 'customShare'

Length of output: 1728

libs/application/templates/inheritance-report/src/forms/sections/heirs.ts (2)

65-69: Ensure the customShare.customSpouseSharePercentage field is properly integrated with the rest of the form logic.

Verification successful

The customShare.customSpouseSharePercentage field is referenced in multiple parts of the codebase, indicating its integration within the form logic:

  • It is defined as a field ID in libs/application/templates/inheritance-report/src/forms/sections/heirs.ts.
  • It is used in libs/application/templates/inheritance-report/src/fields/CalculateShare/index.tsx where its value is set and it is referenced by name in a component.

This suggests that the field is actively used and likely integrated with the form's logic as expected.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the `customShare.customSpouseSharePercentage` field is properly integrated with the rest of the form logic.

# Test: Search for the field usage. Expect: Proper integration with form logic.
rg --type typescript $'customShare.customSpouseSharePercentage'

Length of output: 97



Script:

#!/bin/bash
# Description: Re-verify the integration of `customShare.customSpouseSharePercentage` in the form logic.

# Correcting the file type issue and re-running the search for the field usage.
rg 'customShare.customSpouseSharePercentage' --type js,ts

Length of output: 87



Script:

#!/bin/bash
# Description: Attempting a different approach to verify the integration of `customShare.customSpouseSharePercentage` in the form logic.

# Using a broader search without specifying file types to ensure the command executes correctly.
rg 'customShare.customSpouseSharePercentage'

Length of output: 468


127-134: Check the currency formatting for inheritance and taxFreeInheritance fields.

Verification successful

The search results confirm that the currency property is indeed used in the context of the inheritance and taxFreeInheritance fields within the heirs.ts file, as well as in various other parts of the application. This indicates that the currency formatting is likely implemented and utilized across different modules and forms in the application.

Given this information, the review comment concerning the verification of currency formatting for these fields is consistent with the findings in the codebase. The use of the currency property in the specified fields suggests that the application is handling currency formatting as expected.

Final Conclusion:

  • The currency formatting for the inheritance and taxFreeInheritance fields is implemented and utilized as indicated by the presence of the currency property in the relevant sections of the codebase.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Check the currency formatting for `inheritance` and `taxFreeInheritance` fields.

# Test: Search for the currency formatting logic. Expect: Proper formatting.
rg --type typescript $'currency'

Length of output: 66



Script:

#!/bin/bash
# Description: Check the currency formatting for `inheritance` and `taxFreeInheritance` fields.

# Test: Search for the currency formatting logic in TypeScript files. Expect: Proper formatting.
rg 'currency' --glob '*.ts'

Length of output: 16983

libs/application/templates/inheritance-report/src/fields/AssetsRepeater/index.tsx (1)

277-277: Ensure the label for each field is correctly formatted and localized.

libs/application/templates/inheritance-report/src/lib/dataSchema.ts (1)

580-601: Validate the logic for customSpouseSharePercentage to ensure it handles edge cases correctly.

Verification successful

The verification of the logic for customSpouseSharePercentage has been successfully completed. The search results indicate that this variable is extensively used across various files in the inheritance report module, particularly within the CalculateShare component and the dataSchema.ts file where the validation logic is defined.

The validation logic in dataSchema.ts ensures that if hasCustomSpouseSharePercentage is true and not empty, the customSpouseSharePercentage must be a number between 50 and 100. This logic appears to handle the edge cases correctly by ensuring that the percentage is within a valid range when specified.

Given the widespread usage and the specific validation checks in place, it seems that the logic for handling customSpouseSharePercentage is robust and correctly implemented across the relevant parts of the codebase.

  • Files and locations using customSpouseSharePercentage:
    • libs/application/templates/inheritance-report/src/forms/sections/heirs.ts
    • libs/application/templates/inheritance-report/src/fields/CalculateShare/index.tsx (multiple occurrences)
    • libs/application/templates/inheritance-report/src/lib/dataSchema.ts (validation logic)
    • libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/utils/mappers.ts
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Validate the logic for `customSpouseSharePercentage` to ensure it handles edge cases correctly.

# Test: Search for the validation logic usage. Expect: Proper handling of edge cases.
rg --type typescript $'customSpouseSharePercentage'

Length of output: 85



Script:

#!/bin/bash
# Description: Validate the logic for `customSpouseSharePercentage` to ensure it handles edge cases correctly.

# Corrected Test: Search for the validation logic usage. Expect: Proper handling of edge cases.
rg --type ts 'customSpouseSharePercentage'

Length of output: 2827

@albinagu albinagu added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label May 6, 2024
@kodiakhq kodiakhq bot merged commit 053bdc3 into main May 6, 2024
44 checks passed
@kodiakhq kodiakhq bot deleted the chore/ir-overviewchanges branch May 6, 2024 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated:automerge (Disabled) Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants