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: memo structure in xero app #1094

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

feat: memo structure in xero app #1094

wants to merge 1 commit into from

Conversation

NileshPant1999
Copy link
Contributor

@NileshPant1999 NileshPant1999 commented Dec 3, 2024

Description

memo structure in xero app

Clickup

https://app.clickup.com/tsdfsdfsd/

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced customization options for exporting data to Xero, including new fields for memo structures.
    • Added a "Customization" section in the settings interface, allowing users to select data points for line item-level descriptions.
    • Introduced a preview area for users to see the current memo text.
  • Improvements

    • Improved clarity and guidance for users on configuring export settings.
    • Enhanced user experience with dynamic updates to memo previews based on selected options.

Copy link
Contributor

coderabbitai bot commented Dec 3, 2024

Walkthrough

The changes in this pull request involve modifications to configuration objects related to Xero and Fyle integrations. New properties have been added to enhance customization options for exporting memo fields. Updates to the HTML template and component logic improve user interaction with these settings, including a new multi-select component for memo structure customization. The data model has also been updated to accommodate these changes, ensuring that the integration settings are clearer and more functional.

Changes

File Path Change Summary
src/app/branding/c1-contents-config.ts Modified c1Contents configuration to add new properties under xero and advancedSettings.
src/app/branding/fyle-contents-config.ts Updated fyleContents with new properties in xero.advancedSettings for memo field customization.
src/app/core/models/xero/xero-configuration/xero-advanced-settings.model.ts Added memo_structure property to XeroAdvancedSettingWorkspaceGeneralSetting and updated relevant methods.
src/app/integrations/xero/xero-shared/xero-advanced-settings/xero-advanced-settings.component.html Added new "Customization" section with multi-select component for memo fields and a preview area.
src/app/integrations/xero/xero-shared/xero-advanced-settings/xero-advanced-settings.component.ts Introduced properties and methods for handling memo structures, including memo preview and selection changes.

Possibly related PRs

Suggested labels

size/M

Suggested reviewers

  • ashwin1111
  • DhaaraniCIT

🐰 In the meadow, changes bloom,
New settings bring a brighter room.
Memo fields now dance and play,
Customization leads the way!
With every tweak, the users cheer,
Integration's path is now more clear! 🌼


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/M Medium PR label Dec 3, 2024
Copy link

github-actions bot commented Dec 3, 2024

Unit Test Coverage % values
Statements 34.68% ( 4245 / 12240 )
Branches 28.66% ( 1232 / 4298 )
Functions 27.35% ( 938 / 3429 )
Lines 34.82% ( 4175 / 11990 )

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

🧹 Outside diff range and nitpick comments (4)
src/app/core/models/xero/xero-configuration/xero-advanced-settings.model.ts (1)

115-115: Add validation for memoStructure control

The memoStructure form control is added without any validation rules. Consider adding validation to ensure at least one memo field is selected.

-memoStructure: new FormControl(advancedSettings.workspace_general_settings.memo_structure),
+memoStructure: new FormControl(advancedSettings.workspace_general_settings.memo_structure, [Validators.required, Validators.minLength(1)]),
src/app/integrations/xero/xero-shared/xero-advanced-settings/xero-advanced-settings.component.ts (1)

126-134: Extract preview values to a configuration file

The preview values are hardcoded in the component. Consider moving them to a configuration file for better maintainability.

+// src/app/core/config/memo-preview.config.ts
+export const memoPreviewConfig = {
+  employee_email: '[email protected]',
+  category: 'Meals and Entertainment',
+  purpose: 'Client Meeting',
+  merchant: 'Pizza Hut',
+  report_number: 'C/2021/12/R/1',
+  expense_link: `${environment.fyle_app_url}/app/main/#/enterprise/view_expense/`
+};

-const previewValues: { [key: string]: string } = {
-  employee_email: '[email protected]',
-  category: 'Meals and Entertainment',
-  purpose: 'Client Meeting',
-  merchant: 'Pizza Hut',
-  report_number: 'C/2021/12/R/1',
-  spent_on: today.toLocaleDateString(),
-  expense_link: `${environment.fyle_app_url}/app/main/#/enterprise/view_expense/`
-};
+const previewValues = {
+  ...memoPreviewConfig,
+  spent_on: today.toLocaleDateString()
+};
src/app/integrations/xero/xero-shared/xero-advanced-settings/xero-advanced-settings.component.html (2)

110-121: Enhance accessibility for multi-select component

Add ARIA attributes to improve accessibility for screen readers.

 <app-configuration-multi-select
   [form]="advancedSettingForm"
   [isFieldMandatory]="false"
   [mandatoryErrorListName]="'Item level description'"
   [label]="'Set the line item-level Description Field in Xero'"
   [subLabel]="'You can choose from a list of available data points that you\'d like to export to the description field in Xero.'"
   [options]="defaultMemoFields"
   [iconPath]="'list'"
   [placeholder]="'Set description'"
   [formControllerName]="'memoStructure'"
+  [ariaLabel]="'Select memo structure fields'"
+  [ariaDescribedBy]="'memo-structure-description'"
   (changeInMultiSelect)="onMultiSelectChange()">
 </app-configuration-multi-select>

122-127: Improve preview section handling

Add handling for empty preview text and loading states.

 <div class="preview-text">
   <h4 class="tw-text-form-label-text-color tw-mb-12-px">Preview of the Description Field</h4>
   <div class="preview-box">
-    {{memoPreviewText}}
+    <ng-container *ngIf="memoPreviewText; else emptyPreview">
+      {{memoPreviewText}}
+    </ng-container>
+    <ng-template #emptyPreview>
+      <span class="tw-text-gray-500">Select fields to see preview</span>
+    </ng-template>
   </div>
 </div>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 304ba01 and 706afd3.

📒 Files selected for processing (5)
  • src/app/branding/c1-contents-config.ts (1 hunks)
  • src/app/branding/fyle-contents-config.ts (1 hunks)
  • src/app/core/models/xero/xero-configuration/xero-advanced-settings.model.ts (3 hunks)
  • src/app/integrations/xero/xero-shared/xero-advanced-settings/xero-advanced-settings.component.html (1 hunks)
  • src/app/integrations/xero/xero-shared/xero-advanced-settings/xero-advanced-settings.component.ts (6 hunks)

Comment on lines +131 to +132
auto_create_merchant_destination_entity: advancedSettingsForm.get('autoCreateMerchantDestinationEntity')?.value,
memo_structure: advancedSettingsForm.get('memoStructure')?.value
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add default value handling for memo_structure

The payload construction doesn't handle the case where memoStructure control value is undefined or null. Consider adding a default empty array.

-memo_structure: advancedSettingsForm.get('memoStructure')?.value
+memo_structure: advancedSettingsForm.get('memoStructure')?.value || []
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
auto_create_merchant_destination_entity: advancedSettingsForm.get('autoCreateMerchantDestinationEntity')?.value,
memo_structure: advancedSettingsForm.get('memoStructure')?.value
auto_create_merchant_destination_entity: advancedSettingsForm.get('autoCreateMerchantDestinationEntity')?.value,
memo_structure: advancedSettingsForm.get('memoStructure')?.value || []

Comment on lines +90 to +94
onMultiSelectChange() {
const memo = this.advancedSettingForm.controls.memoStructure.value;
const changedMemo = AdvancedSettingsModel.formatMemoPreview(memo, this.defaultMemoFields)[1];
this.advancedSettingForm.controls.memoStructure.patchValue(changedMemo);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling for multi-select changes

The method directly accesses form control values without proper error handling. Consider adding null checks and error handling.

 onMultiSelectChange() {
-  const memo = this.advancedSettingForm.controls.memoStructure.value;
-  const changedMemo = AdvancedSettingsModel.formatMemoPreview(memo, this.defaultMemoFields)[1];
-  this.advancedSettingForm.controls.memoStructure.patchValue(changedMemo);
+  try {
+    const memo = this.advancedSettingForm.get('memoStructure')?.value;
+    if (memo) {
+      const changedMemo = AdvancedSettingsModel.formatMemoPreview(memo, this.defaultMemoFields)[1];
+      this.advancedSettingForm.get('memoStructure')?.patchValue(changedMemo);
+    }
+  } catch (error) {
+    console.error('Error updating memo structure:', error);
+  }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
onMultiSelectChange() {
const memo = this.advancedSettingForm.controls.memoStructure.value;
const changedMemo = AdvancedSettingsModel.formatMemoPreview(memo, this.defaultMemoFields)[1];
this.advancedSettingForm.controls.memoStructure.patchValue(changedMemo);
}
onMultiSelectChange() {
try {
const memo = this.advancedSettingForm.get('memoStructure')?.value;
if (memo) {
const changedMemo = AdvancedSettingsModel.formatMemoPreview(memo, this.defaultMemoFields)[1];
this.advancedSettingForm.get('memoStructure')?.patchValue(changedMemo);
}
} catch (error) {
console.error('Error updating memo structure:', error);
}
}

Comment on lines +152 to +159
private createMemoStructureWatcher(): void {
this.memoStructure = this.advancedSettingForm.get('memoStructure')?.value;
this.formatMemoPreview();
this.advancedSettingForm.controls.memoStructure.valueChanges.subscribe((memoChanges) => {
this.memoStructure = memoChanges;
this.formatMemoPreview();
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix potential memory leak in subscription

The subscription to valueChanges is not being unsubscribed, which could lead to memory leaks. Consider implementing OnDestroy and properly managing the subscription.

+private memoStructureSubscription: Subscription;

 private createMemoStructureWatcher(): void {
   this.memoStructure = this.advancedSettingForm.get('memoStructure')?.value;
   this.formatMemoPreview();
-  this.advancedSettingForm.controls.memoStructure.valueChanges.subscribe((memoChanges) => {
+  this.memoStructureSubscription = this.advancedSettingForm.get('memoStructure')?.valueChanges.subscribe((memoChanges) => {
     this.memoStructure = memoChanges;
     this.formatMemoPreview();
   });
 }

+ngOnDestroy(): void {
+  if (this.memoStructureSubscription) {
+    this.memoStructureSubscription.unsubscribe();
+  }
+}

Committable suggestion skipped: line range outside the PR's diff.

src/app/branding/c1-contents-config.ts Show resolved Hide resolved
Comment on lines +249 to +252
topLevelMemoStructureLabel: 'Customize the Top-Level Memo Field',
topLevelMemoStructureSubLabel: 'Select the datapoints you\'d like to export to QuickBooks Desktop’s top-level memo field when exporting expenses from Fyle.',
memoStructureLabel: 'Customize the Line-Item Level Memo Field',
memoStructureSubLabel: 'Select the datapoints you\'d like to export to QuickBooks Desktop\’s line-item level memo field when exporting expenses from Fyle.',
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix incorrect reference to QuickBooks Desktop in Xero configuration

The labels incorrectly reference QuickBooks Desktop instead of Xero in both the top-level and line-item level memo structure configurations.

Apply this diff to fix the references:

-                topLevelMemoStructureLabel: 'Customize the Top-Level Memo Field',
-                topLevelMemoStructureSubLabel: 'Select the datapoints you\'d like to export to QuickBooks Desktop's top-level memo field when exporting expenses from Fyle.',
-                memoStructureLabel: 'Customize the Line-Item Level Memo Field',
-                memoStructureSubLabel: 'Select the datapoints you\'d like to export to QuickBooks Desktop\'s line-item level memo field when exporting expenses from Fyle.',
+                topLevelMemoStructureLabel: 'Customize the Top-Level Memo Field',
+                topLevelMemoStructureSubLabel: 'Select the datapoints you\'d like to export to Xero\'s top-level memo field when exporting expenses from Fyle.',
+                memoStructureLabel: 'Customize the Line-Item Level Memo Field',
+                memoStructureSubLabel: 'Select the datapoints you\'d like to export to Xero\'s line-item level memo field when exporting expenses from Fyle.',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
topLevelMemoStructureLabel: 'Customize the Top-Level Memo Field',
topLevelMemoStructureSubLabel: 'Select the datapoints you\'d like to export to QuickBooks Desktop’s top-level memo field when exporting expenses from Fyle.',
memoStructureLabel: 'Customize the Line-Item Level Memo Field',
memoStructureSubLabel: 'Select the datapoints you\'d like to export to QuickBooks Desktop\’s line-item level memo field when exporting expenses from Fyle.',
topLevelMemoStructureLabel: 'Customize the Top-Level Memo Field',
topLevelMemoStructureSubLabel: 'Select the datapoints you\'d like to export to Xero\'s top-level memo field when exporting expenses from Fyle.',
memoStructureLabel: 'Customize the Line-Item Level Memo Field',
memoStructureSubLabel: 'Select the datapoints you\'d like to export to Xero\'s line-item level memo field when exporting expenses from Fyle.',

@@ -214,6 +214,8 @@ export const c1Contents = {
cccExpenseBankAccountLabel: 'Which bank account should the bank transactions post to?',
cccExpenseStateSubLabel: 'You can choose to only export expenses when they\'ve been labeled approved or closed. '
},
memoStructureLabel: 'Set the line-item description field in NetSuite',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Xero

Copy link
Contributor

Choose a reason for hiding this comment

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

instead of netsuite, to make it xero

@@ -246,6 +246,10 @@ export const fyleContents = {
billPaymentAccountSubLabel: ', the payment entries will be posted to the selected Payment account in ',
postEntriesCurrentPeriod: 'Post entries in the current accounting period',
contentText: 'In this section, you can customize the integration based on your accounting requirements. ',
topLevelMemoStructureLabel: 'Customize the Top-Level Memo Field',
topLevelMemoStructureSubLabel: 'Select the datapoints you\'d like to export to QuickBooks Desktop’s top-level memo field when exporting expenses from Fyle.',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Xero

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