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 CCP -ve Tax Amount #659

Merged
merged 6 commits into from
Aug 12, 2024
Merged

Fix CCP -ve Tax Amount #659

merged 6 commits into from
Aug 12, 2024

Conversation

ruuushhh
Copy link
Contributor

@ruuushhh ruuushhh commented Aug 9, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced handling of tax calculations for credit card purchases to ensure the tax amount is consistently positive when processing credits.
  • Bug Fixes

    • Resolved potential discrepancies in tax calculations related to credit card purchases by updating logic for the TaxAmount field.

@ruuushhh ruuushhh self-assigned this Aug 9, 2024
Copy link

coderabbitai bot commented Aug 9, 2024

Walkthrough

The recent changes improve the __construct_credit_card_purchase method in utils.py, ensuring the TaxAmount is always a positive value. The updated logic now iterates through all line items, handling negative amounts more robustly by setting both the Amount and TaxAmount to their absolute values. This enhancement eliminates discrepancies during credit transactions, leading to more accurate and consistent tax calculations in financial applications.

Changes

Files Change Summary
apps/quickbooks_online/utils.py Enhanced __construct_credit_card_purchase to iterate through all line items and ensure TaxAmount is absolute for negative amounts.

Poem

In the world of finance, we hop and we play,
With credit cards dancing, bright as the day.
Tax amounts tidy, no more dismay,
A rabbit's delight in the numbers at bay! 🐰✨
Hooray for the changes, so clever and spry,
Keeping our ledgers both neat and awry!


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@ruuushhh ruuushhh added the deploy Triggers deployment of active branch to Staging label Aug 9, 2024
Copy link

github-actions bot commented Aug 9, 2024

Tests Skipped Failures Errors Time
245 0 💤 0 ❌ 0 🔥 1m 9s ⏱️

Copy link

github-actions bot commented Aug 9, 2024

Tests Skipped Failures Errors Time
245 0 💤 0 ❌ 0 🔥 1m 1s ⏱️

Copy link

@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, codebase verification and nitpick comments (1)
apps/quickbooks_online/utils.py (1)

964-964: Inconsistent application of absolute value logic for TaxAmount.

The logic to ensure TaxAmount is positive using abs() is applied in some parts of the codebase but not consistently across all instances.

  • File: apps/quickbooks_online/utils.py
    • Line: 964: line[0][credit_card_purchase_lineitems[0].detail_type]['TaxAmount'] = abs(line[0][credit_card_purchase_lineitems[0].detail_type]['TaxAmount'])
    • Other instances in the same file do not use abs().

Please review and ensure consistent application of this logic to prevent potential discrepancies in financial calculations.

Analysis chain

Ensure TaxAmount is always positive.

The change to set TaxAmount to its absolute value when the Amount is negative is a good fix. This ensures consistency in tax calculations.

Verify that this logic is applied consistently across all relevant parts of the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the logic of setting TaxAmount to absolute value is applied consistently across the codebase.

# Test: Search for instances where TaxAmount is set. Expect: Consistent application of absolute value logic.
rg --type python $'TaxAmount'

Length of output: 59


Script:

#!/bin/bash
# Description: Verify that the logic of setting TaxAmount to absolute value is applied consistently across the codebase.

# Test: Search for instances where TaxAmount is set. Expect: Consistent application of absolute value logic.
rg --type py $'TaxAmount'

Length of output: 6944

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8a890cd and 89b25be.

Files selected for processing (1)
  • apps/quickbooks_online/utils.py (1 hunks)

@ruuushhh ruuushhh added deploy Triggers deployment of active branch to Staging and removed deploy Triggers deployment of active branch to Staging labels Aug 9, 2024
Copy link

github-actions bot commented Aug 9, 2024

Tests Skipped Failures Errors Time
245 0 💤 0 ❌ 0 🔥 1m 2s ⏱️

Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 89b25be and 93a8e78.

Files selected for processing (1)
  • apps/quickbooks_online/utils.py (1 hunks)
Files skipped from review due to trivial changes (1)
  • apps/quickbooks_online/utils.py

@ruuushhh ruuushhh requested a review from ashwin1111 August 9, 2024 09:13
line[0]['Amount'] = abs(line[0]['Amount'])
line[0][credit_card_purchase_lineitems[0].detail_type]['TaxAmount'] = abs(tax_amount) if tax_amount else None
Copy link
Contributor

Choose a reason for hiding this comment

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

iterate and set all lines to +ve

@ruuushhh ruuushhh added deploy Triggers deployment of active branch to Staging and removed deploy Triggers deployment of active branch to Staging labels Aug 12, 2024
Copy link

Tests Skipped Failures Errors Time
245 0 💤 1 ❌ 0 🔥 1m 8s ⏱️

1 similar comment
Copy link

Tests Skipped Failures Errors Time
245 0 💤 1 ❌ 0 🔥 1m 8s ⏱️

Copy link

Tests Skipped Failures Errors Time
245 0 💤 0 ❌ 0 🔥 46.938s ⏱️

@ruuushhh ruuushhh added deploy Triggers deployment of active branch to Staging and removed deploy Triggers deployment of active branch to Staging labels Aug 12, 2024
Copy link

Tests Skipped Failures Errors Time
245 0 💤 0 ❌ 0 🔥 53.398s ⏱️

Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 93a8e78 and 8540f38.

Files selected for processing (1)
  • apps/quickbooks_online/utils.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/quickbooks_online/utils.py

Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 93a8e78 and 8540f38.

Files selected for processing (1)
  • apps/quickbooks_online/utils.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/quickbooks_online/utils.py

@ruuushhh ruuushhh merged commit bbd9ef0 into master Aug 12, 2024
4 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy Triggers deployment of active branch to Staging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants