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

fix: added special conditional checks for intacct and qbo for supporting card num and employee name #1119

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

anishfyle
Copy link
Contributor

@anishfyle anishfyle commented Dec 12, 2024

Description

  • fix for memo field in qbo and intacct

Clickup

Summary by CodeRabbit

  • New Features

    • Enhanced memo fields in the Intacct advanced settings component, now dynamically retrieved from the updated model.
  • Bug Fixes

    • Improved consistency between UI memo fields and underlying configurations.
  • Refactor

    • Updated method signatures and logic for handling application configurations in the advanced settings model.

Copy link
Contributor

coderabbitai bot commented Dec 12, 2024

Walkthrough

The changes in this pull request primarily involve modifications to the AdvancedSettingsModel and IntacctAdvancedSettingsComponent classes. The getMemoOptions method in AdvancedSettingsModel has been updated to accept IntacctConfiguration, altering its logic to handle memo options based on the application name. In the IntacctAdvancedSettingsComponent, the defaultMemoFields property now dynamically retrieves memo options using the updated method, ensuring alignment with the current settings. These changes enhance the handling of memo fields in the context of Intacct configurations.

Changes

File Path Change Summary
src/app/core/models/common/advanced-settings.model.ts - Updated method signature for getMemoOptions to accept IntacctConfiguration.
- Added import statement for IntacctConfiguration.
- Modified logic in getMemoOptions to check for AppName.INTACCT and retrieve corporate_credit_card_expenses_object.
- Updated filtering logic for cccExportType to include 'quickbooks online'.
src/app/integrations/intacct/intacct-shared/intacct-advanced-settings/intacct-advanced-settings.component.ts - Changed initialization of defaultMemoFields to use AdvancedSettingsModel.getMemoOptions(configuration, AppName.INTACCT).
- Updated getSettingsAndSetupForm method to align defaultMemoFields with current configuration settings.

Possibly related PRs

Suggested labels

deploy, size/M

Suggested reviewers

  • DhaaraniCIT
  • ashwin1111

Poem

🐇 In the meadow where changes bloom,
Advanced settings find more room.
Memo fields dance with new delight,
Intacct's charm shines ever bright.
Hopping through code, we celebrate,
With each tweak, we elevate! 🌼


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. (Experiment)
  • @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/XS Extra Small PR label Dec 12, 2024
@anishfyle anishfyle requested a review from ashwin1111 December 12, 2024 08:54
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

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

91-94: Improve app name comparison robustness

The current implementation has several potential issues:

  1. Case-sensitive string comparison could be fragile
  2. String literals are used instead of enum values
  3. Complex conditional logic could be simplified

Consider this improved implementation:

- if (cccExportType && ['netsuite', 'quickbooks online', 'sage intacct'].includes(appName.toLowerCase())) {
-   return defaultOptions; // Allow all options including 'card_number'
- }
-   return defaultOptions.filter(option => option !== 'card_number'); // Omit 'card_number' for other apps
+ const supportedApps = [
+   AppName.NETSUITE.toLowerCase(),
+   AppName.QBO.toLowerCase(),
+   AppName.INTACCT.toLowerCase()
+ ];
+ return cccExportType && supportedApps.includes(appName.toLowerCase())
+   ? defaultOptions
+   : defaultOptions.filter(option => option !== 'card_number');
src/app/integrations/intacct/intacct-shared/intacct-advanced-settings/intacct-advanced-settings.component.ts (1)

Line range hint 192-208: Consider enhancing memo preview with real data

The preview functionality uses hardcoded values (e.g., "John Doe", "**** 3456"). Consider enhancing it to use real sample data from the configuration when available, especially for card numbers and employee names.

 const previewValues: { [key: string]: string } = {
-  employee_email: '[email protected]',
-  employee_name: 'John Doe',
-  card_number: '**** 3456',
+  employee_email: this.configuration?.sample_employee_email || '[email protected]',
+  employee_name: this.configuration?.sample_employee_name || 'John Doe',
+  card_number: this.configuration?.sample_card_number || '**** 3456',
   category: 'Meals and Entertainment',
   purpose: 'Client Meeting',
   merchant: 'Pizza Hut',
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2933601 and 17878ef.

📒 Files selected for processing (2)
  • src/app/core/models/common/advanced-settings.model.ts (2 hunks)
  • src/app/integrations/intacct/intacct-shared/intacct-advanced-settings/intacct-advanced-settings.component.ts (2 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/app/core/models/common/advanced-settings.model.ts

[error] 80-80: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)

🔇 Additional comments (4)
src/app/core/models/common/advanced-settings.model.ts (2)

7-7: LGTM: Import addition is appropriate

The IntacctConfiguration import is correctly added and necessary for the type changes in getMemoOptions.


83-85: Verify type casting and error handling

The type casting to IntacctConfiguration should be verified to ensure it's safe in all scenarios.

✅ Verification successful

Let me gather more information about the type definitions and usage to verify the type casting safety.


Based on the gathered information, I can now provide the final response:

Type casting in getMemoOptions is safe and properly handled

The type casting to IntacctConfiguration is safe because:

  • The method uses type discrimination with appName === AppName.INTACCT before the cast
  • The type definitions show that IntacctConfiguration and ExportSettingGet have different structures
  • The code uses proper type guards with 'configurations' in exportSettings to handle different types
  • Error handling is implicit through the optional chaining (?.) and nullish coalescing (??) operators
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for all usages of getMemoOptions to verify correct parameter types
rg -A 2 "getMemoOptions\(" 

Length of output: 3038


Script:

#!/bin/bash
# Search for IntacctConfiguration type definition and related types
ast-grep --pattern 'type IntacctConfiguration = $_'

# Search for the complete class/interface definition
ast-grep --pattern 'interface IntacctConfiguration {
  $$$
}'

# Search for ExportSettingGet type definition
ast-grep --pattern 'type ExportSettingGet = $_'

# Look for configurations property usage
rg "'configurations' in" -A 2

Length of output: 3115

src/app/integrations/intacct/intacct-shared/intacct-advanced-settings/intacct-advanced-settings.component.ts (2)

96-96: LGTM: Default initialization looks good

The initialization of defaultMemoFields using AdvancedSettingsModel.getDefaultMemoOptions() provides a good default value before the configuration is loaded.


316-316: Verify configuration object fields for memo options

The update to use getMemoOptions with configuration and AppName.INTACCT looks good and aligns with the PR objectives for supporting card number and employee name in memo fields.

Let's verify that the configuration object contains all required fields for memo options:

✅ Verification successful

Based on the search results, I can now generate the final response since I have enough information to verify the configuration object and memo options implementation:

Configuration object contains required fields for memo options

The implementation looks correct and safe:

  • The Configuration interface in advanced-settings.model.ts includes the required memo_structure field
  • The getMemoOptions method is properly used across different components (Intacct, QBO, NetSuite)
  • The memo structure is correctly:
    • Stored in configuration object
    • Used in form initialization with setDescriptionField control
    • Validated with required validator
    • Watched for changes to update preview
  • Default memo fields include all necessary options including card number and employee name
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if configuration object contains required fields for memo options

# Search for configuration type definition and usage
ast-grep --pattern 'interface Configuration {
  $$$
  employee_field_mapping: $_
  $$$
}'

# Search for getMemoOptions implementation to verify field usage
ast-grep --pattern 'getMemoOptions(configuration: $_, appName: $_) {
  $$$
}'

Length of output: 171


Script:

#!/bin/bash
# Let's try a different approach to find the configuration interface and getMemoOptions implementation

# Search for Configuration interface
rg -A 10 "interface Configuration" 

# Search for getMemoOptions implementation
rg -A 10 "getMemoOptions.*configuration.*appName"

# Search for defaultMemoFields usage
rg "defaultMemoFields.*getMemoOptions"

Length of output: 1590


Script:

#!/bin/bash
# Let's find the implementation of getMemoOptions in AdvancedSettingsModel

# Search for getMemoOptions static method in advanced-settings.model.ts
rg -A 15 "static getMemoOptions" src/app/core/models/intacct/intacct-configuration/advanced-settings.model.ts

# Also check how memo_structure is used
rg "memo_structure" src/app/core/models/intacct/intacct-configuration/advanced-settings.model.ts

Length of output: 301


Script:

#!/bin/bash
# Let's try a broader search to find the getMemoOptions implementation and its usage

# Search for getMemoOptions in the entire codebase with more context
rg -B 5 -A 15 "getMemoOptions" 

# Search for setDescriptionField to understand memo structure setup
rg -B 5 -A 10 "setDescriptionField"

Length of output: 40735

Copy link

Unit Test Coverage % values
Statements 34.07% ( 4206 / 12342 )
Branches 27.63% ( 1210 / 4378 )
Functions 26.73% ( 924 / 3456 )
Lines 34.23% ( 4138 / 12086 )

@anishfyle anishfyle merged commit ae2b2a3 into master Dec 12, 2024
4 checks passed
anishfyle added a commit that referenced this pull request Dec 12, 2024
JustARatherRidiculouslyLongUsername added a commit that referenced this pull request Dec 12, 2024
* fix: remove validation temporarily (#1111)

* fix: add a default bank account field for CCC expenses

* fix: add missing options to bank accounts on page init

* fix: dynamic content for xero customize settings (#1112)

* fix: update sublabel key to avoid build fail (#1116)

* fix: Prod fixes of QBD direct (#1118)

* fix bugs (#1119)

* refactor: capitalization

* fix: only ccc exports not being saved (#1121)

---------

Co-authored-by: Ashwin Thanaraj <[email protected]>
Co-authored-by: Nilesh Pant <[email protected]>
Co-authored-by: Dhaarani <[email protected]>
Co-authored-by: Anish Kr Singh <[email protected]>
JustARatherRidiculouslyLongUsername added a commit that referenced this pull request Dec 12, 2024
* fix: restrict JE modules to group by expense only

* fix: add a default bank account field for CCC expenses (#1114)

* fix: remove validation temporarily (#1111)

* fix: add a default bank account field for CCC expenses

* fix: add missing options to bank accounts on page init

* fix: dynamic content for xero customize settings (#1112)

* fix: update sublabel key to avoid build fail (#1116)

* fix: Prod fixes of QBD direct (#1118)

* fix bugs (#1119)

* refactor: capitalization

* fix: only ccc exports not being saved (#1121)

---------

Co-authored-by: Ashwin Thanaraj <[email protected]>
Co-authored-by: Nilesh Pant <[email protected]>
Co-authored-by: Dhaarani <[email protected]>
Co-authored-by: Anish Kr Singh <[email protected]>

---------

Co-authored-by: Ashwin Thanaraj <[email protected]>
Co-authored-by: Nilesh Pant <[email protected]>
Co-authored-by: Dhaarani <[email protected]>
Co-authored-by: Anish Kr Singh <[email protected]>
JustARatherRidiculouslyLongUsername added a commit that referenced this pull request Dec 12, 2024
* fix: initialize chart of accounts multiselect when there is no api response (#1110)

* fix: remove the posted at date option for ccc expenses grouped by report (#1105)

* fix: update login error flow and fix redirect url (#1117)

* fix: restrict JE modules to group by expense only (#1113)

* fix: restrict JE modules to group by expense only

* fix: add a default bank account field for CCC expenses (#1114)

* fix: remove validation temporarily (#1111)

* fix: add a default bank account field for CCC expenses

* fix: add missing options to bank accounts on page init

* fix: dynamic content for xero customize settings (#1112)

* fix: update sublabel key to avoid build fail (#1116)

* fix: Prod fixes of QBD direct (#1118)

* fix bugs (#1119)

* refactor: capitalization

* fix: only ccc exports not being saved (#1121)

---------

Co-authored-by: Ashwin Thanaraj <[email protected]>
Co-authored-by: Nilesh Pant <[email protected]>
Co-authored-by: Dhaarani <[email protected]>
Co-authored-by: Anish Kr Singh <[email protected]>

---------

Co-authored-by: Ashwin Thanaraj <[email protected]>
Co-authored-by: Nilesh Pant <[email protected]>
Co-authored-by: Dhaarani <[email protected]>
Co-authored-by: Anish Kr Singh <[email protected]>

---------

Co-authored-by: Ashwin Thanaraj <[email protected]>
Co-authored-by: Nilesh Pant <[email protected]>
Co-authored-by: Dhaarani <[email protected]>
Co-authored-by: Anish Kr Singh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XS Extra Small PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants