Skip to content

Conversation

@ashwin1111
Copy link
Contributor

@ashwin1111 ashwin1111 commented Dec 10, 2024

Description

Please add PR description here, add screenshots if needed

Clickup

https://app.clickup.com/t

Summary by CodeRabbit

  • New Features

    • Enhanced flexibility in handling accounting export parameters.
    • Improved error handling for export errors based on application context.
  • Bug Fixes

    • Adjusted logic for fetching export errors and tasks to accommodate new application-specific requirements.
  • Documentation

    • Updated method signatures to reflect new parameters for better clarity and usage.
  • Chores

    • Removed unused input properties to streamline component structure.

@github-actions github-actions bot added the size/S Small PR label Dec 10, 2024
@ashwin1111 ashwin1111 added staging_deploy Triggers deployment of active branch to Staging and removed size/S Small PR labels Dec 10, 2024
@ashwin1111 ashwin1111 added staging_deploy Triggers deployment of active branch to Staging and removed staging_deploy Triggers deployment of active branch to Staging labels Dec 10, 2024
@github-actions github-actions bot added the size/S Small PR label Dec 10, 2024
@ashwin1111 ashwin1111 added staging_deploy Triggers deployment of active branch to Staging and removed staging_deploy Triggers deployment of active branch to Staging labels Dec 10, 2024
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 10, 2024

Warning

Rate limit exceeded

@ashwin1111 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 44 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 99c7871 and 8ad2e3b.

📒 Files selected for processing (1)
  • src/app/core/models/enum/enum.model.ts (1 hunks)

Walkthrough

The changes in this pull request involve modifications to several TypeScript files and an HTML template within the application. Key updates include adjustments to the AccountingExportGetParam type, enhancements to the DashboardService and AccountingExportService methods to accommodate an appName parameter, and refinements in the QbdDirectDashboardComponent for handling export errors. Additionally, changes to the HTML template reflect updates in input bindings. These alterations aim to improve flexibility and clarity in the handling of accounting exports and dashboard functionalities.

Changes

File Change Summary
src/app/core/models/db/accounting-export.model.ts Updated AccountingExportGetParam type: type__in changed to optional (string[]?), status__in changed to accept `string[]
src/app/core/models/enum/enum.model.ts Modified QBD_DIRECT enum value from 'QuickBooks Desktop ' to 'QuickBooks Desktop' (removed trailing space).
src/app/core/services/common/accounting-export.service.ts Updated getAccountingExports method to handle appName for QBD_DIRECT; modifies status__in to ERROR if FAILED is present and removes type__in from apiParams.
src/app/core/services/common/dashboard.service.ts Updated getExportErrors, getTasks, and getAllTasks methods to include optional appName parameter; modified logic to prioritize appName over version for error handling.
src/app/integrations/qbd-direct/qbd-direct-main/qbd-direct-dashboard/qbd-direct-dashboard.component.html Removed [accountingExportType] binding from app-dashboard-export-summary-section; added [exportKey] binding to app-dashboard-error-section.
src/app/integrations/qbd-direct/qbd-direct-main/qbd-direct-dashboard/qbd-direct-dashboard.component.ts Updated getExportErrors$ observable to include undefined parameter; removed accountingExportType array; modified pollExportStatus and setupPage methods to pass an empty array for export types.
src/app/shared/components/dashboard/dashboard-error-section/dashboard-error-section.component.ts Updated handleResolvedMappingStat method to include appName parameter in getExportErrors call.

Possibly related PRs

Suggested labels

size/M

Suggested reviewers

  • DhaaraniCIT
  • ruuushhh

Poem

In a world of code where rabbits play,
We hop through changes, brightening the day.
With types and enums, we make our stand,
Flexibility blooms, like carrots from the land!
So here's to the code, both clever and neat,
A rabbit's delight, oh what a treat! 🐇✨


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.

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 (3)
src/app/core/services/common/accounting-export.service.ts (1)

75-78: Document the status mapping for QBD Direct

The status mapping from FAILED to ERROR for QBD Direct appears to handle a specific case differently. Consider adding a comment explaining why this mapping is necessary for better maintainability.

+  // QBD Direct uses ERROR status instead of FAILED status for consistency with its error handling
   if (apiParams.status__in?.includes(AccountingExportStatus.FAILED)) {
     apiParams.status__in = AccountingExportStatus.ERROR;
   }

Additionally, consider using undefined assignment instead of delete operator for better performance:

-  delete apiParams.type__in;
+  apiParams.type__in = undefined;
🧰 Tools
🪛 Biome (1.9.4)

[error] 78-78: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

src/app/core/services/common/dashboard.service.ts (1)

Line range hint 39-46: Add JSDoc to document the method parameters

The method signature has been updated to include an optional appName parameter. Consider adding JSDoc to document the parameters and their purpose.

+  /**
+   * Get export errors based on version and app name
+   * @param version - Optional version string, defaults to latest
+   * @param appName - Optional app name to handle app-specific error fetching
+   * @returns Observable containing error response
+   */
   getExportErrors(version?: string | 'v1', appName?: string): Observable<any> {
src/app/integrations/qbd-direct/qbd-direct-main/qbd-direct-dashboard/qbd-direct-dashboard.component.ts (1)

97-98: Consider making the polling interval configurable

The polling interval is currently hardcoded to 3000ms. Consider making this configurable through a constant or environment variable to allow easier adjustments for different environments.

+  private readonly EXPORT_STATUS_POLLING_INTERVAL = 3000; // ms
   interval(3000).pipe(
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1dd10f0 and c2a0be9.

📒 Files selected for processing (6)
  • src/app/core/models/db/accounting-export.model.ts (1 hunks)
  • src/app/core/services/common/accounting-export.service.ts (1 hunks)
  • src/app/core/services/common/dashboard.service.ts (2 hunks)
  • src/app/integrations/qbd-direct/qbd-direct-main/qbd-direct-dashboard/qbd-direct-dashboard.component.html (0 hunks)
  • src/app/integrations/qbd-direct/qbd-direct-main/qbd-direct-dashboard/qbd-direct-dashboard.component.ts (4 hunks)
  • src/app/shared/components/dashboard/dashboard-error-section/dashboard-error-section.component.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • src/app/integrations/qbd-direct/qbd-direct-main/qbd-direct-dashboard/qbd-direct-dashboard.component.html
🧰 Additional context used
🪛 Biome (1.9.4)
src/app/core/services/common/accounting-export.service.ts

[error] 78-78: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

🔇 Additional comments (5)
src/app/core/services/common/dashboard.service.ts (1)

66-66: LGTM!

The simplified condition for typeKey assignment improves readability while maintaining the same logic.

src/app/integrations/qbd-direct/qbd-direct-main/qbd-direct-dashboard/qbd-direct-dashboard.component.ts (3)

55-55: LGTM!

The explicit undefined parameter makes it clear that we're using the app-specific error handling for QBD Direct.


134-135: Good addition of error handling

The addition of catchError operator for getAccountingExportSummary$ improves resilience by preventing crashes when the summary cannot be retrieved.


98-98: Verify the impact of filtering and tracking changes

Two significant changes have been made:

  1. Removal of accountingExportType filter from getAllTasks
  2. Changed mapping to use taskLog.id instead of taskLog.expense_group

Please verify that:

  1. Removing the export type filter doesn't result in processing unnecessary tasks
  2. Using taskLog.id correctly identifies failed tasks for retry

Also applies to: 121-121

✅ Verification successful

Based on the search results, I can now generate the final response:

Changes to task filtering and tracking are safe

  1. The removal of accountingExportType filter from getAllTasks is intentional as the filtering is now handled by the exportableAccountingExportIds parameter which contains the specific IDs to process
  2. The change from expense_group to id for tracking failed tasks is consistent with the codebase - both fields are used to track task failures across different integrations, with id being the more direct reference

The changes maintain proper task filtering and tracking while simplifying the implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any potential task types that might be missed
ast-grep --pattern 'getAllTasks($$$, $$$, $accountingExportType, $$$)' | grep -B 2 -A 2 accountingExportType

# Check for references to expense_group in task logs
rg -A 2 'expense_group' --type ts

Length of output: 74080

src/app/core/models/db/accounting-export.model.ts (1)

51-52: LGTM! Verify usage of modified parameters across the codebase.

The type changes enhance flexibility:

  • Making type__in optional accommodates cases where type filtering isn't needed
  • Allowing status__in to accept both string[] and string supports varied filtering scenarios

Let's verify that all usages of AccountingExportGetParam have been updated to handle these changes:

✅ Verification successful

Let me search for the interface usage and parameter patterns to verify the impact of these changes.


The changes to AccountingExportGetParam are safely handled across the codebase

The verification shows that all usages of these parameters are compatible with the type changes:

  • The optional type__in is correctly handled, with code even explicitly removing it in some cases (e.g., delete apiParams.type__in for QBD_DIRECT)
  • status__in is used consistently with both array and string types, with proper type handling in conditional checks (e.g., status__in?.includes())
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usages of AccountingExportGetParam to ensure they handle optional type__in
ast-grep --pattern 'type__in: $$$'

# Search for status__in assignments to ensure they handle both string and string[]
ast-grep --pattern 'status__in: $$$'

Length of output: 75


Script:

#!/bin/bash
# Search for files containing AccountingExportGetParam
rg -l "AccountingExportGetParam"

# Then search for actual usage patterns of these parameters
rg "type__in|status__in" -A 2 -B 2

Length of output: 8976


handleResolvedMappingStat(): void {
this.dashboardService.getExportErrors(this.errorsVersion).subscribe((errors) => {
this.dashboardService.getExportErrors(this.errorsVersion, this.appName).subscribe((errors) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Update required: Inconsistent usage of getExportErrors parameters across components

Several components need to be updated to align with the new getExportErrors signature:

  • intacct-dashboard.component.ts: Only passes version parameter
  • xero-dashboard.component.ts: Only passes version parameter
  • qbo-dashboard.component.ts: Only passes version parameter
  • business-central-dashboard.component.ts: No parameters passed
  • sage300-dashboard.component.ts: No parameters passed
  • netsuite-dashboard.component.ts: Only passes version parameter

Only qbd-direct-dashboard.component.ts and dashboard-error-section.component.ts are using both parameters correctly.

🔗 Analysis chain

LGTM! Verify error handling for different app types.

The addition of this.appName parameter to getExportErrors call aligns with the service's updated signature. This change enables app-specific error handling.

Let's verify that all components using DashboardService.getExportErrors have been updated:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for all calls to getExportErrors to ensure consistent parameter usage
ast-grep --pattern 'this.dashboardService.getExportErrors($$$)'

Length of output: 1592

@ashwin1111 ashwin1111 added staging_deploy Triggers deployment of active branch to Staging and removed staging_deploy Triggers deployment of active branch to Staging labels Dec 10, 2024
@ashwin1111 ashwin1111 added staging_deploy Triggers deployment of active branch to Staging and removed staging_deploy Triggers deployment of active branch to Staging labels Dec 10, 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: 1

🧹 Outside diff range and nitpick comments (2)
src/app/core/services/common/dashboard.service.ts (2)

39-42: Consider simplifying the version and appName conditions

The error handling logic looks correct but could be more maintainable.

Consider this refactoring:

-  getExportErrors(version?: string | 'v1', appName?: string): Observable<any> {
-    if (!appName && version === 'v1') {
-      return this.apiService.get(`/v2/workspaces/${this.workspaceId}/errors/`, {is_resolved: false});
-    } else if (appName ===  AppName.QBD_DIRECT) {
+  getExportErrors(version?: string | 'v1', appName?: string): Observable<any> {
+    const params = { is_resolved: false };
+    
+    if (appName === AppName.QBD_DIRECT) {
+      return this.apiService.get(`/workspaces/${this.workspaceId}/export_logs/errors/`, params);
+    } else if (version === 'v1') {
+      return this.apiService.get(`/v2/workspaces/${this.workspaceId}/errors/`, params);
+    }

66-66: Consider using a constant for the type key mapping

The type key mapping logic could be more maintainable.

Consider extracting the mapping to a constant:

private readonly TYPE_KEY_MAP = {
  [AppName.INTACCT]: 'task_type',
  DEFAULT: 'type__in'
} as const;

// Then in the code:
const typeKey = this.TYPE_KEY_MAP[appName as AppName] || this.TYPE_KEY_MAP.DEFAULT;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1dd10f0 and 99c7871.

📒 Files selected for processing (7)
  • src/app/core/models/db/accounting-export.model.ts (1 hunks)
  • src/app/core/models/enum/enum.model.ts (1 hunks)
  • src/app/core/services/common/accounting-export.service.ts (1 hunks)
  • src/app/core/services/common/dashboard.service.ts (2 hunks)
  • src/app/integrations/qbd-direct/qbd-direct-main/qbd-direct-dashboard/qbd-direct-dashboard.component.html (1 hunks)
  • src/app/integrations/qbd-direct/qbd-direct-main/qbd-direct-dashboard/qbd-direct-dashboard.component.ts (5 hunks)
  • src/app/shared/components/dashboard/dashboard-error-section/dashboard-error-section.component.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/app/core/models/enum/enum.model.ts
🧰 Additional context used
🪛 Biome (1.9.4)
src/app/core/services/common/accounting-export.service.ts

[error] 78-78: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

🔇 Additional comments (5)
src/app/integrations/qbd-direct/qbd-direct-main/qbd-direct-dashboard/qbd-direct-dashboard.component.html (1)

46-47: LGTM! Verify error handling behavior

The addition of errorsVersion and exportKey attributes aligns with the service layer changes for QBD-specific error handling.

Let's verify the error handling configuration is consistent across the codebase:

✅ Verification successful

Consistent error handling configuration found across integrations

The verification shows that:

  • All integrations consistently use errorsVersion="v1" where error versioning is implemented
  • exportKey is appropriately customized per integration:
    • QBD Direct: "export_log"
    • Business Central & Sage300: "accounting_export"
    • Default (in component): "expense_group"

The implementation in the dashboard-error-section component properly handles these configurations through @Input() decorators and uses them correctly in the error handling logic.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other instances of dashboard-error-section to ensure consistent version handling
rg -l 'app-dashboard-error-section' | xargs rg 'errorsVersion|exportKey'

Length of output: 1961

src/app/integrations/qbd-direct/qbd-direct-main/qbd-direct-dashboard/qbd-direct-dashboard.component.ts (2)

55-55: Update required: Inconsistent usage of getExportErrors parameters across components

Several components need to be updated to align with the new getExportErrors signature:

  • intacct-dashboard.component.ts: Only passes version parameter
  • xero-dashboard.component.ts: Only passes version parameter
  • qbo-dashboard.component.ts: Only passes version parameter
  • business-central-dashboard.component.ts: No parameters passed
  • sage300-dashboard.component.ts: No parameters passed
  • netsuite-dashboard.component.ts: Only passes version parameter

119-121: LGTM! Improved error handling by including fatal errors

The error handling has been enhanced by including both TaskLogState.ERROR and TaskLogState.FATAL states. This ensures that all types of errors are properly captured and handled.

src/app/shared/components/dashboard/dashboard-error-section/dashboard-error-section.component.ts (1)

213-213: LGTM! Proper implementation of app-specific error handling

The addition of this.appName parameter to getExportErrors call aligns with the service's updated signature. This change enables proper app-specific error handling.

src/app/core/models/db/accounting-export.model.ts (1)

51-52: LGTM! Enhanced type flexibility

The type improvements make the interface more flexible and practical:

  1. Making type__in optional allows for cases where the type filter isn't needed
  2. Allowing status__in to accept either an array or single string accommodates different usage patterns

Comment on lines +75 to +78
if (apiParams.status__in?.includes(AccountingExportStatus.FAILED)) {
apiParams.status__in = AccountingExportStatus.ERROR;
}
delete apiParams.type__in;
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

Improve error status handling and avoid delete operator

The status mapping for QBD_DIRECT looks correct, but there are a few improvements we can make:

Consider this refactoring to improve performance and readability:

-      if (apiParams.status__in?.includes(AccountingExportStatus.FAILED)) {
-        apiParams.status__in = AccountingExportStatus.ERROR;
-      }
-      delete apiParams.type__in;
+      // Map FAILED status to ERROR for QBD_DIRECT
+      apiParams.status__in = Array.isArray(apiParams.status__in) 
+        ? apiParams.status__in.map(status => status === AccountingExportStatus.FAILED ? AccountingExportStatus.ERROR : status)
+        : apiParams.status__in;
+      apiParams.type__in = undefined;

This change:

  1. Handles both array and string status values
  2. Avoids the delete operator which can impact performance
  3. Makes the status mapping more explicit
📝 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
if (apiParams.status__in?.includes(AccountingExportStatus.FAILED)) {
apiParams.status__in = AccountingExportStatus.ERROR;
}
delete apiParams.type__in;
// Map FAILED status to ERROR for QBD_DIRECT
apiParams.status__in = Array.isArray(apiParams.status__in)
? apiParams.status__in.map(status => status === AccountingExportStatus.FAILED ? AccountingExportStatus.ERROR : status)
: apiParams.status__in;
apiParams.type__in = undefined;
🧰 Tools
🪛 Biome (1.9.4)

[error] 78-78: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

@ashwin1111 ashwin1111 added staging_deploy Triggers deployment of active branch to Staging and removed staging_deploy Triggers deployment of active branch to Staging labels Dec 10, 2024
@github-actions
Copy link

Unit Test Coverage % values
Statements 34.06% ( 4197 / 12319 )
Branches 27.69% ( 1205 / 4351 )
Functions 26.69% ( 922 / 3454 )
Lines 34.22% ( 4129 / 12063 )

@ashwin1111 ashwin1111 merged commit bac7872 into master Dec 10, 2024
7 checks passed
ashwin1111 added a commit that referenced this pull request Dec 10, 2024
* fix: QBD Dashboard bugs

* fix: QBD Dashboard bugs

* fix: QBD Dashboard bugs

* fix: QBD Dashboard bugs

* fix: QBD Dashboard bugs

* fix: QBD Dashboard bugs

* fix: QBD Dashboard bugs
@coderabbitai coderabbitai bot mentioned this pull request Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Small PR staging_deploy Triggers deployment of active branch to Staging

Development

Successfully merging this pull request may close these issues.

2 participants