-
Notifications
You must be signed in to change notification settings - Fork 0
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: support split expense grouping for Xero #1075
feat: support split expense grouping for Xero #1075
Conversation
* feat: add split expense grouping config to xero export settings * feat: add split expense grouping config to xero clone settings (#1072)
WalkthroughThe changes enhance the Changes
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 (8)
src/app/integrations/xero/xero-shared/xero-export-settings/xero-export-settings.component.ts (1)
52-53
: Add type annotation for better type safety.Consider adding a type annotation to the
splitExpenseGroupingOptions
property to maintain consistency with TypeScript best practices.- splitExpenseGroupingOptions = XeroExportSettingModel.getSplitExpenseGroupingOptions(); + splitExpenseGroupingOptions: SelectFormOption[] = XeroExportSettingModel.getSplitExpenseGroupingOptions();src/app/core/models/xero/xero-configuration/xero-export-settings.model.ts (2)
171-182
: Consider adding JSDoc comments for better documentationThe new method follows the established pattern and provides clear options. Consider adding JSDoc comments to document the purpose and return type.
+ /** + * Returns the available options for split expense grouping + * @returns {SelectFormOption[]} Array of options for configuring how split expenses should be grouped + */ static getSplitExpenseGroupingOptions() {
233-234
: Document the default value for split_expense_groupingThe code sets
MULTIPLE_LINE_ITEM
as the default value forsplit_expense_grouping
. Consider adding a comment explaining why this is the chosen default.+ // Default to MULTIPLE_LINE_ITEM for split expenses to maintain backward compatibility split_expense_grouping: exportSettingsForm.get('splitExpenseGrouping')?.value ? exportSettingsForm.get('splitExpenseGrouping')?.value : SplitExpenseGrouping.MULTIPLE_LINE_ITEM
src/app/integrations/xero/xero-shared/xero-export-settings/xero-export-settings.component.html (2)
193-207
: LGTM! Consider enhancing validation feedback.The implementation of the split expense grouping field follows consistent patterns with other configuration fields and is properly integrated within the form structure. The conditional rendering is appropriate, ensuring the field only appears when relevant.
Consider adding validation messages to provide clear feedback when the field is required but empty. You can add an error message template similar to other mandatory fields in the form:
<app-configuration-select-field [form]="exportSettingForm" [isFieldMandatory]="true" [showClearIcon]="true" [mandatoryErrorListName]="'split expense grouping'" [label]="'How should the split expenses be grouped?'" [subLabel]="'Choose how expenses should be grouped for split expenses'" [options]="splitExpenseGroupingOptions" [iconPath]="'question-square-outline'" [placeholder]="'Select the split expense grouping type'" - [formControllerName]="'splitExpenseGrouping'"> + [formControllerName]="'splitExpenseGrouping'" + [validationErrorMessage]="'Please select how split expenses should be grouped'"> </app-configuration-select-field>
193-207
: Enhance accessibility for the split expense grouping field.While the implementation follows the standard component pattern, consider these accessibility improvements:
- Add ARIA attributes to provide better screen reader support:
<app-configuration-select-field [form]="exportSettingForm" [isFieldMandatory]="true" [showClearIcon]="true" [mandatoryErrorListName]="'split expense grouping'" + [ariaLabel]="'Split expense grouping selection'" + [ariaDescribedBy]="'split-expense-grouping-description'" [label]="'How should the split expenses be grouped?'" [subLabel]="'Choose how expenses should be grouped for split expenses'" [options]="splitExpenseGroupingOptions" [iconPath]="'question-square-outline'" [placeholder]="'Select the split expense grouping type'" [formControllerName]="'splitExpenseGrouping'"> </app-configuration-select-field>
- Ensure the error state is properly announced to screen readers by implementing appropriate ARIA live regions in the parent component.
src/app/integrations/xero/xero-onboarding/xero-clone-settings/xero-clone-settings.component.ts (2)
11-11
: LGTM with a minor suggestion.The import of
XeroCorporateCreditCardExpensesObject
is correctly added. Consider splitting this line into multiple lines for better readability if more enums are added in the future.-import { AppName, ConfigurationCta, ConfigurationWarningEvent, InputType, ToastSeverity, XeroCorporateCreditCardExpensesObject, XeroFyleField } from 'src/app/core/models/enum/enum.model'; +import { + AppName, + ConfigurationCta, + ConfigurationWarningEvent, + InputType, + ToastSeverity, + XeroCorporateCreditCardExpensesObject, + XeroFyleField +} from 'src/app/core/models/enum/enum.model';
43-44
: Add type annotations to the new properties.While the properties are correctly placed and initialized, they're missing TypeScript type annotations. This is inconsistent with TypeScript best practices and could make the code harder to maintain.
- brandingFeatureConfig = brandingFeatureConfig; + brandingFeatureConfig: typeof brandingFeatureConfig = brandingFeatureConfig; - splitExpenseGroupingOptions = XeroExportSettingModel.getSplitExpenseGroupingOptions(); + splitExpenseGroupingOptions: SelectFormOption[] = XeroExportSettingModel.getSplitExpenseGroupingOptions(); - XeroCorporateCreditCardExpensesObject = XeroCorporateCreditCardExpensesObject; + readonly XeroCorporateCreditCardExpensesObject: typeof XeroCorporateCreditCardExpensesObject = XeroCorporateCreditCardExpensesObject;Also applies to: 65-66, 140-141
src/app/integrations/xero/xero-onboarding/xero-clone-settings/xero-clone-settings.component.html (1)
182-183
: Consider simplifying the conditional rendering.The multi-line condition could be extracted to a component property or method for better readability and maintainability.
- <div class="clone-setting--field" *ngIf="brandingFeatureConfig.featureFlags.exportSettings.splitExpenseGrouping && - exportSettingForm.controls.creditCardExportType.value === XeroCorporateCreditCardExpensesObject.BANK_TRANSACTION"> + <div class="clone-setting--field" *ngIf="shouldShowSplitExpenseGrouping()">Add this method to your component:
shouldShowSplitExpenseGrouping(): boolean { return this.brandingFeatureConfig.featureFlags.exportSettings.splitExpenseGrouping && this.exportSettingForm.controls.creditCardExportType.value === this.XeroCorporateCreditCardExpensesObject.BANK_TRANSACTION; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (5)
src/app/core/models/xero/xero-configuration/xero-export-settings.model.ts
(5 hunks)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)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 (11)
src/app/integrations/xero/xero-shared/xero-export-settings/xero-export-settings.component.ts (3)
9-9
: LGTM!
The import of XeroCorporateCreditCardExpensesObject
is properly placed with related enums and follows the established naming pattern.
91-92
: LGTM!
The readonly property is properly defined and follows the established pattern for exposing enums to the template.
52-53
: Verify related changes for split expense grouping.
The additions look good, but please ensure:
- The template file (
xero-export-settings.component.html
) properly uses these new properties - The form validation in
XeroExportSettingModel.getValidators()
includes rules for split expense grouping - The
constructPayloadAndSave
method correctly handles the new split expense grouping option
Also applies to: 91-92
✅ Verification successful
Based on the search results, I can now generate a final response. The code shows that:
- The template file properly uses
splitExpenseGroupingOptions
as evidenced by its presence inxero-export-settings.component.html
- The form validation includes split expense grouping in
XeroExportSettingModel.getValidators()
where it's added to thecreditCardExpense
validator rules - The
constructPayloadAndSave
method inxero-export-settings.component.ts
correctly handles saving all form values throughXeroExportSettingModel.constructPayload(this.exportSettingForm)
All required changes for split expense grouping are properly implemented.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify related changes for split expense grouping implementation
# Check template usage
echo "Checking template usage..."
rg -l "splitExpenseGroupingOptions" --type html
# Check validator implementation
echo "Checking validator implementation..."
rg "getValidators.*split" --type typescript
# Check payload handling
echo "Checking payload construction..."
rg "constructPayload.*split" --type typescript
Length of output: 916
Script:
#!/bin/bash
# Let's try different search patterns and file extensions
# Check validator implementation
echo "Checking validator implementation..."
rg "getValidators" -A 5 -B 5 "*.ts"
# Check payload handling
echo "Checking payload construction..."
rg "constructPayloadAndSave" -A 10 -B 2 "*.ts"
# Check model implementation
echo "Checking model implementation..."
ast-grep --pattern 'class XeroExportSettingModel {
$$$
static getValidators() {
$$$
}
$$$
}'
Length of output: 512
Script:
#!/bin/bash
# Let's try without file extension filters since they're causing issues
# Check validator implementation
echo "Checking validator implementation..."
rg "getValidators" -A 5 -B 5
# Check payload handling
echo "Checking payload construction..."
rg "constructPayloadAndSave" -A 10 -B 2
# Check XeroExportSettingModel implementation
echo "Checking XeroExportSettingModel implementation..."
rg "class XeroExportSettingModel" -A 20
Length of output: 108561
src/app/core/models/xero/xero-configuration/xero-export-settings.model.ts (4)
5-5
: LGTM: Import statement is correctly updated
The addition of SplitExpenseGrouping
to the enum imports is appropriate for the new split expense grouping feature.
187-187
: Verify if split expense grouping is intentionally limited to credit card expenses
The validator includes splitExpenseGrouping
only in creditCardExpense
rules. Let's verify if this is intentional and aligns with the business requirements.
#!/bin/bash
# Search for related test files and business logic
echo "=== Searching for related test files ==="
rg -l "splitExpenseGrouping|split_expense_grouping" "**/*.spec.ts"
echo "=== Searching for business logic documentation ==="
fd -e md | xargs rg -l "split expense"
221-222
: Query the purpose of the searchOption form control
The addition of searchOption
seems unrelated to the split expense grouping feature. Could you clarify its purpose?
#!/bin/bash
# Search for other occurrences of searchOption
rg "searchOption" --type ts
15-16
: Verify backward compatibility of the new required field
The addition of split_expense_grouping
as a required field in XeroExpenseGroupSettingPost
might affect existing code. Let's verify that all implementations provide this field.
✅ Verification successful
Based on the search results, I can see that the split_expense_grouping
field is properly handled in the codebase:
- It's included in form initialization with a default value:
splitExpenseGrouping: new FormControl(exportSettings?.expense_group_settings?.split_expense_grouping)
- It's included in payload construction with a default value:
split_expense_grouping: exportSettingsForm.get('splitExpenseGrouping')?.value ? exportSettingsForm.get('splitExpenseGrouping')?.value : SplitExpenseGrouping.MULTIPLE_LINE_ITEM
- The field is consistently used across different integrations (Xero, QBO, Intacct, etc.) in their export settings forms and models.
No backward compatibility issues with the new required field
The codebase properly handles the split_expense_grouping
field by providing a default value of SplitExpenseGrouping.MULTIPLE_LINE_ITEM
when constructing the payload. This ensures backward compatibility as existing code will always have a valid value for this required field.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for places where XeroExpenseGroupSettingPost is constructed
rg -l "XeroExpenseGroupSettingPost" | while read -r file; do
echo "=== $file ==="
# Show the context where the type is used
rg -C 5 "XeroExpenseGroupSettingPost" "$file"
done
Length of output: 11302
Script:
#!/bin/bash
# Search for XeroExpenseGroupSettingPost type definition and its usage
ast-grep --pattern 'interface XeroExpenseGroupSettingPost {
$$$
}'
# Also search for any object creation or type usage
rg -A 5 -B 5 "XeroExpenseGroupSettingPost" --type ts
Length of output: 4137
Script:
#!/bin/bash
# Search for places where XeroExportSettingPost is constructed to see how the expense_group_settings is handled
rg -A 10 -B 10 "new FormGroup\({[^}]*expense_group_settings" --type ts
# Also search for any direct object creation
rg -A 5 -B 5 "expense_group_settings:\s*{" --type ts
Length of output: 387
Script:
#!/bin/bash
# Search for form initialization or object creation related to expense_group_settings
rg -A 5 -B 5 "expense_group_settings" --type ts
# Also look for any test files that might show object construction
rg -A 5 -B 5 "XeroExpenseGroupSettingPost" --type spec.ts
Length of output: 55727
src/app/integrations/xero/xero-shared/xero-export-settings/xero-export-settings.component.html (1)
193-207
: Verify form validation and save handling for the new field.
The new split expense grouping field is well-integrated into the form structure, but let's ensure proper handling during form submission.
✅ Verification successful
Based on the comprehensive code analysis, I can now provide a definitive response about the form validation and save handling for the split expense grouping field:
Form validation and save handling are properly implemented
The split expense grouping field is well-integrated into the export settings form with proper:
-
Form initialization:
- Added as a FormControl with proper model binding
- Default value set to MULTIPLE_LINE_ITEM if not specified
-
Save handling:
- Included in the payload construction in XeroExportSettingModel
- Properly mapped to the API format in constructPayload method
- Has fallback to default value if not specified
-
Type safety:
- Uses proper enum SplitExpenseGrouping
- Consistent implementation across different integrations (Xero, QBO, Intacct)
-
UI Options:
- Proper options setup through getSplitExpenseGroupingOptions()
- Consistent options: Single Line Item and Multiple Line Item
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify form handling implementation for split expense grouping
# Check for form validation handling in component
rg -A 5 "splitExpenseGrouping" --type ts
# Check for proper save/submit handling
rg -A 10 "constructPayloadAndSave|save\(" --type ts
# Look for related test coverage
rg -g "*spec.ts" "splitExpenseGrouping"
Length of output: 188364
Script:
#!/bin/bash
# Check form validation and save handling for split expense grouping in the component
ast-grep --pattern $'class XeroExportSettingModel {
$$$
static constructPayload($_, $_) {
$$$
}
$$$
}'
# Look for test coverage specifically around split expense grouping
rg -g "*spec.ts" -B 5 -A 5 "splitExpenseGrouping.*value"
Length of output: 174
Script:
#!/bin/bash
# Check the model and component implementation for split expense grouping
rg -A 10 "class XeroExportSettingModel" --type ts
# Check form handling in the component
rg -A 10 "splitExpenseGrouping.*FormControl" --type ts
# Check payload construction
rg -A 10 "split_expense_grouping.*payload" --type ts
Length of output: 5586
Script:
#!/bin/bash
# Check for split expense grouping in model and payload construction
rg -B 5 -A 15 "split_expense_grouping.*:" --type ts
# Check for enum or type definition related to split expense grouping
rg -B 2 -A 2 "SplitExpenseGrouping" --type ts
# Check component initialization and form setup
rg -B 5 -A 10 "splitExpenseGroupingOptions" --type ts
Length of output: 56048
src/app/integrations/xero/xero-onboarding/xero-clone-settings/xero-clone-settings.component.ts (2)
5-5
: LGTM!
The import of brandingFeatureConfig
is correctly added to the existing branding imports.
Line range hint 43-141
: Verify template usage of the new properties.
Please ensure that these properties are correctly used in the component's template file (xero-clone-settings.component.html
).
✅ Verification successful
Based on the shell script results, I can now generate the final response since I have enough information to verify the template usage.
Template correctly uses all the new properties
The verification shows that:
splitExpenseGroupingOptions
is properly used in the template with correct binding to form controls and necessary conditionsbrandingFeatureConfig
is used extensively throughout the template for feature flag checksXeroCorporateCreditCardExpensesObject
is used correctly in conditional statements for split expense grouping
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check template usage of the new properties
# Check for usage of splitExpenseGroupingOptions
echo "Checking splitExpenseGroupingOptions usage:"
rg -A 3 "splitExpenseGroupingOptions" --type html
# Check for usage of brandingFeatureConfig
echo "Checking brandingFeatureConfig usage:"
rg -A 3 "brandingFeatureConfig" --type html
# Check for usage of XeroCorporateCreditCardExpensesObject
echo "Checking XeroCorporateCreditCardExpensesObject usage:"
rg -A 3 "XeroCorporateCreditCardExpensesObject" --type html
Length of output: 101805
src/app/integrations/xero/xero-onboarding/xero-clone-settings/xero-clone-settings.component.html (1)
184-194
: LGTM! The field configuration follows the established pattern.
The new split expense grouping field is well-structured and consistent with other fields in the form:
- Uses the same
app-clone-setting-field
component - Includes appropriate icon and tooltip
- Properly configured as a mandatory field
- Uses consistent naming conventions
|
Description
feat: add split expense grouping config to xero export settings (feat: add split expense grouping config to xero export settings #1071)
feat: add split expense grouping config to xero export settings
feat: add split expense grouping config to xero clone settings (feat: add split expense grouping config to xero clone settings #1072)
Clickup
https://app.clickup.com/t/86cx0vhuu
Summary by CodeRabbit
Release Notes
New Features
Enhancements
These updates provide users with greater flexibility and control over their expense grouping settings when exporting to Xero.