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

feat: add split expense grouping config to xero export settings #1071

Conversation

JustARatherRidiculouslyLongUsername
Copy link
Contributor

@JustARatherRidiculouslyLongUsername JustARatherRidiculouslyLongUsername commented Nov 13, 2024

Clickup

https://app.clickup.com/t/86cx0vjyk

Summary by CodeRabbit

  • New Features

    • Introduced a new field for split expense grouping in Xero export settings, allowing users to specify how expenses should be categorized.
    • Added options for selecting split expense grouping, enhancing user control over expense categorization.
    • Enhanced the Xero clone settings component with a new field for grouping split expenses when exporting.
  • Bug Fixes

    • Improved validation logic for credit card expenses to include the new split expense grouping field.
  • Documentation

    • Updated component templates to reflect the new split expense grouping functionality, ensuring clear user guidance.

Copy link
Contributor

coderabbitai bot commented Nov 13, 2024

Walkthrough

The changes primarily focus on enhancing the XeroExportSettings functionality by introducing a new property, split_expense_grouping, to the XeroExpenseGroupSettingPost and XeroExportSettingPost types. This includes updates to validation methods and the addition of a static method for options retrieval. Additionally, the Angular template for the Xero export settings component has been modified to conditionally render a new field for split expense grouping based on specific feature flags. The component's TypeScript file has also been updated to include new properties for managing these options.

Changes

File Change Summary
src/app/core/models/xero/xero-export-settings.model.ts - Added split_expense_grouping: SplitExpenseGrouping to XeroExpenseGroupSettingPost and XeroExportSettingPost.
- Introduced static method getSplitExpenseGroupingOptions().
- Updated mapAPIResponseToFormGroup and constructPayload methods to include splitExpenseGrouping.
src/app/integrations/xero/xero-shared/xero-export-settings/xero-export-settings.component.html - Added conditional rendering for <app-configuration-select-field> for split expense grouping based on feature flags.
src/app/integrations/xero/xero-shared/xero-export-settings/xero-export-settings.component.ts - Added readonly XeroCorporateCreditCardExpensesObject and splitExpenseGroupingOptions properties to the component.
src/app/integrations/xero/xero-onboarding/xero-clone-settings/xero-clone-settings.component.html - Added conditional field <app-clone-setting-field> for split expense grouping in corporate credit card expenses section.
src/app/integrations/xero/xero-onboarding/xero-clone-settings/xero-clone-settings.component.ts - Added brandingFeatureConfig, splitExpenseGroupingOptions, and XeroCorporateCreditCardExpensesObject properties to the component.

Possibly related PRs

Suggested labels

size/L

Suggested reviewers

  • DhaaraniCIT
  • ashwin1111

🐰 In the fields of Xero, we play,
With expenses grouped in a new way.
A select field appears, oh what a sight,
Splitting expenses feels just right!
With options to choose, we hop with glee,
Thanks to the changes, we're wild and free! 🌼


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

@github-actions github-actions bot added the size/S Small PR label Nov 13, 2024
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

🧹 Outside diff range and nitpick comments (3)
src/app/core/models/xero/xero-configuration/xero-export-settings.model.ts (2)

187-187: Consider adding validation rules for split expense grouping

While the field is added to validators, there are no specific rules checking if the selected value is valid. Consider adding an ExportModuleRule to validate against allowed values from SplitExpenseGrouping enum.

 const exportModuleRule: ExportModuleRule[] = [
   {
     formController: 'reimbursableExportType',
     requiredValue: {
     }
   },
   {
     formController: 'creditCardExportType',
     requiredValue: {
     }
+  },
+  {
+    formController: 'splitExpenseGrouping',
+    requiredValue: {
+      allowedValues: Object.values(SplitExpenseGrouping)
+    }
   }
 ];

222-222: Consider setting a default value for splitExpenseGrouping control

The control is initialized without a default value. Consider setting SplitExpenseGrouping.MULTIPLE_LINE_ITEM as default to match the behavior in constructPayload.

src/app/integrations/xero/xero-shared/xero-export-settings/xero-export-settings.component.html (1)

200-201: Consider enhancing field labels for better accessibility.

The current labels could be more descriptive for screen readers.

Consider updating the labels:

-                            [label]="'How should the split expenses be grouped?'"
-                            [subLabel]="'Choose how expenses should be grouped for split expenses'"
+                            [label]="'Split Expense Grouping Method'"
+                            [subLabel]="'Select how you want to group expenses that have been split across multiple categories or projects'"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 5fcb07e and 2535939.

📒 Files selected for processing (3)
  • src/app/core/models/xero/xero-configuration/xero-export-settings.model.ts (5 hunks)
  • src/app/integrations/xero/xero-shared/xero-export-settings/xero-export-settings.component.html (1 hunks)
  • src/app/integrations/xero/xero-shared/xero-export-settings/xero-export-settings.component.ts (3 hunks)
🔇 Additional comments (6)
src/app/integrations/xero/xero-shared/xero-export-settings/xero-export-settings.component.ts (1)

9-9: LGTM! The changes follow Angular best practices.

The additions are well-structured and maintain consistency with the existing codebase:

  • Import is properly grouped with related enums
  • Properties follow established patterns
  • Readonly decorator is correctly used for template exposure

Let's verify the template usage of these new properties:

Also applies to: 52-52, 91-91

src/app/core/models/xero/xero-configuration/xero-export-settings.model.ts (4)

171-182: LGTM! Method follows established patterns

The implementation is consistent with other similar methods in the class and provides clear options for split expense grouping.


233-234: LGTM! Proper default handling

The implementation correctly handles the default case and follows the established payload structure.


221-221: Verify the purpose of searchOption control

The addition of searchOption control seems unrelated to the split expense grouping feature. Please clarify its purpose or consider moving it to a separate PR.

#!/bin/bash
# Search for other occurrences of searchOption
rg "searchOption" --type ts

15-16: ⚠️ Potential issue

Consider making split_expense_grouping optional to maintain backward compatibility

Adding a required property to XeroExpenseGroupSettingPost is a breaking change that could affect existing code. Consider making it optional with ? modifier or providing a default value in the consuming code.

Let's check for existing usages that might break:

src/app/integrations/xero/xero-shared/xero-export-settings/xero-export-settings.component.html (1)

194-207: LGTM! The implementation is consistent with existing patterns.

The new split expense grouping field follows the established patterns:

  • Proper conditional rendering based on feature flags
  • Consistent styling and spacing
  • Clear labeling and field configuration

Let's verify the feature flag implementation:

✅ Verification successful

Feature flag implementation is consistent across integrations

The split expense grouping feature is consistently implemented across Xero, QBO, and Intacct integrations:

  • All implementations use the same feature flag path brandingFeatureConfig.featureFlags.exportSettings.splitExpenseGrouping
  • Each integration follows similar conditional rendering based on export type
  • Consistent field configuration with same labels, mandatory status, and form control name
  • Proper component usage (app-configuration-select-field or app-clone-setting-field) based on context
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify feature flag usage consistency across the codebase
# Look for other usages of splitExpenseGrouping feature flag to ensure consistent implementation

rg -l "exportSettings.splitExpenseGrouping" 

Length of output: 429


Script:

#!/bin/bash
# Let's examine how splitExpenseGrouping is used in other files to ensure consistency
rg "splitExpenseGrouping" -A 5 -B 5 src/app/integrations/qbo/qbo-onboarding/qbo-clone-settings/qbo-clone-settings.component.html src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.html src/app/integrations/intacct/intacct-shared/intacct-export-settings/intacct-export-settings.component.html

Length of output: 10965

@github-actions github-actions bot added size/M Medium PR and removed size/S Small PR labels Nov 15, 2024
Copy link

Unit Test Coverage % values
Statements 35.37% ( 4222 / 11935 )
Branches 29% ( 1228 / 4234 )
Functions 27.95% ( 935 / 3345 )
Lines 35.5% ( 4148 / 11682 )

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

🧹 Outside diff range and nitpick comments (2)
src/app/integrations/xero/xero-onboarding/xero-clone-settings/xero-clone-settings.component.ts (1)

Line range hint 1-424: Consider adding unit tests for the new functionality

While the implementation looks correct, we should ensure proper test coverage for the new split expense grouping feature.

Would you like me to help generate unit tests for:

  1. Initialization of splitExpenseGroupingOptions
  2. Feature flag conditional rendering
  3. Form control binding and validation
src/app/integrations/xero/xero-onboarding/xero-clone-settings/xero-clone-settings.component.html (1)

181-195: LGTM! New split expense grouping field is well-integrated.

The implementation follows the existing UI patterns and properly handles conditional rendering based on feature flags and export type.

Consider adding aria-label and aria-describedby attributes to improve accessibility:

                    <app-clone-setting-field
                        [iconSource]="'question-square-outline'"
                        [label]="'How should the split expenses be grouped?'"
                        [options]="splitExpenseGroupingOptions"
                        [placeholder]="'Select split expense grouping'"
                        [form]="exportSettingForm"
                        [isFieldMandatory]="true"
                        [formControllerName]="'splitExpenseGrouping'"
                        [dropdownDisplayKey]="'label'"
+                       [ariaLabel]="'Split expense grouping selection'"
+                       [ariaDescribedBy]="'split-expense-grouping-tooltip'"
                        [tooltipText]="'The selected option will dictate how split expenses will be exported to Xero.'">
                    </app-clone-setting-field>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2535939 and d8f58c8.

📒 Files selected for processing (2)
  • src/app/integrations/xero/xero-onboarding/xero-clone-settings/xero-clone-settings.component.html (1 hunks)
  • src/app/integrations/xero/xero-onboarding/xero-clone-settings/xero-clone-settings.component.ts (4 hunks)
🔇 Additional comments (3)
src/app/integrations/xero/xero-onboarding/xero-clone-settings/xero-clone-settings.component.ts (2)

5-5: LGTM: Import statements are properly organized

The new imports for brandingFeatureConfig and XeroCorporateCreditCardExpensesObject are correctly added to their respective existing import statements, maintaining code organization.

Also applies to: 11-11


43-44: Verify feature flag usage across the template

The new properties are correctly initialized:

  • brandingFeatureConfig for feature flags
  • splitExpenseGroupingOptions using the static method from XeroExportSettingModel
  • XeroCorporateCreditCardExpensesObject enum for type safety

However, we should verify that these properties are properly used in the template file.

Also applies to: 65-66, 140-141

✅ Verification successful

Feature flag and properties are correctly used in the template

The verification shows that:

  • The feature flag brandingFeatureConfig.featureFlags.exportSettings.splitExpenseGrouping is properly used in an *ngIf directive to conditionally render the split expense grouping field
  • The splitExpenseGroupingOptions is correctly bound to the options input of the clone setting field
  • The field is only shown when credit card export type is set to BANK_TRANSACTION
  • The form control is properly set up with required validation
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if brandingFeatureConfig.featureFlags.exportSettings.splitExpenseGrouping is used in the template
# and if splitExpenseGroupingOptions is bound to a form control

# Search for feature flag usage in template
rg -l "brandingFeatureConfig\.featureFlags\.exportSettings\.splitExpenseGrouping" \
   --type html \
   "src/app/integrations/xero/xero-onboarding/xero-clone-settings/"

# Search for splitExpenseGroupingOptions usage in template
rg -l "splitExpenseGroupingOptions" \
   --type html \
   "src/app/integrations/xero/xero-onboarding/xero-clone-settings/"

Length of output: 463


Script:

#!/bin/bash
# Let's check the actual usage in the template file
rg -A 5 -B 5 "brandingFeatureConfig\.featureFlags\.exportSettings\.splitExpenseGrouping|splitExpenseGroupingOptions" \
   --type html \
   "src/app/integrations/xero/xero-onboarding/xero-clone-settings/xero-clone-settings.component.html"

Length of output: 1301

src/app/integrations/xero/xero-onboarding/xero-clone-settings/xero-clone-settings.component.html (1)

181-195: Verify form validation and feature flag configuration.

Please ensure:

  1. The form validation in the component class properly handles the new splitExpenseGrouping control
  2. The feature flag exportSettings.splitExpenseGrouping is properly configured in the environment
✅ Verification successful

Form validation and feature flag integration are properly configured

The verification shows:

  1. The splitExpenseGrouping control is properly included in the validation rules for credit card expenses in XeroExportSettingModel.getValidators()
  2. The form validation is handled through the helper service's addExportSettingFormValidator method, which is correctly called in the component
  3. The feature flag is referenced across multiple components (Xero, QBO, Intacct) and branding configurations, indicating proper integration
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the feature flag is properly configured
rg -A 5 "exportSettings:\s*{[^}]*splitExpenseGrouping" 

# Check if form validation is properly handled in the component
rg "splitExpenseGrouping.*Validators" 

Length of output: 242


Script:

#!/bin/bash
# Check feature flag configuration with a simpler pattern
rg -l "splitExpenseGrouping" 

# Check form validation in the component file
rg -A 5 "exportSettingForm.*=.*FormGroup" src/app/integrations/xero/xero-onboarding/xero-clone-settings/

# Check the component class for splitExpenseGrouping
ast-grep --pattern 'class XeroCloneSettingsComponent {
  $$$
  splitExpenseGrouping
  $$$
}'

Length of output: 2608


Script:

#!/bin/bash
# Check the feature flag configuration in branding config files
rg -A 5 "exportSettings.*splitExpenseGrouping" src/app/branding/

# Check the form model and validation rules
rg -A 10 "class XeroExportSettingModel" src/app/core/models/xero/xero-configuration/

# Check helper service for form validation
rg -A 5 "addExportSettingFormValidator" src/app/integrations/xero/

Length of output: 3195


Script:

#!/bin/bash
# Check the helper service implementation for form validation
rg -A 10 "class.*HelperService" src/app/integrations/xero/

# Check the model for splitExpenseGrouping
rg -A 5 "splitExpenseGrouping.*interface|interface.*splitExpenseGrouping" src/app/core/models/xero/

# Check the validators implementation
rg -A 10 "getValidators\(\)" src/app/core/models/xero/xero-configuration/xero-export-settings.model.ts

Length of output: 846

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/M Medium PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants