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: CCC Tax #617

Closed
wants to merge 4 commits into from
Closed

Fix: CCC Tax #617

wants to merge 4 commits into from

Conversation

ruuushhh
Copy link
Contributor

@ruuushhh ruuushhh commented May 30, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced purchase processing to handle multiple line items.
    • Added tax calculation for each line item in purchases.
    • Improved handling of credit card purchases with multiple line items.
    • Support for negative amounts in credit transactions.
  • Improvements

    • Enhanced logging for better tracking of purchase payload information.

@ruuushhh ruuushhh self-assigned this May 30, 2024
Copy link

coderabbitai bot commented May 30, 2024

Warning

Rate Limit Exceeded

@ruuushhh has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 18 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 Files that changed from the base of the PR and between f314707 and 72e9e96.

Walkthrough

The utils.py file in the quickbooks_online app has been updated to enhance the handling of multiple line items in purchase object payloads and credit card purchases. The purchase_object_payload and __construct_credit_card_purchase methods now process lists of line items, calculate tax rates for each, and handle negative amounts for credit transactions, improving the overall functionality and accuracy of transaction processing.

Changes

Files Change Summary
apps/quickbooks_online/utils.py Updated purchase_object_payload to handle multiple line items, calculate tax rates, and include tax details.
apps/quickbooks_online/utils.py Modified __construct_credit_card_purchase to handle multiple credit card purchase line items and negative amounts.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant System
    participant QuickBooks API

    User->>System: Create Purchase with Multiple Line Items
    System->>System: Call purchase_object_payload with line items
    System->>System: Calculate tax rates for each line item
    System->>QuickBooks API: Send processed payload
    QuickBooks API->>System: Acknowledge receipt

    User->>System: Create Credit Card Purchase
    System->>System: Call __construct_credit_card_purchase with line items
    System->>System: Handle negative amounts for credits
    System->>QuickBooks API: Send credit card purchase payload
    QuickBooks API->>System: Acknowledge receipt
Loading

Poem

In the code where data flows,
Line by line, the payload grows.
Taxes calculated, credits too,
For each line item, something new.
QuickBooks smiles with every call,
As transactions now stand tall. 🌟


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 Configration 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

Tests Skipped Failures Errors Time
234 0 💤 10 ❌ 0 🔥 1m 5s ⏱️

Copy link

Tests Skipped Failures Errors Time
234 0 💤 10 ❌ 0 🔥 1m 6s ⏱️

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 6a18167 and b555b1c.
Files selected for processing (1)
  • apps/quickbooks_online/utils.py (3 hunks)
Additional comments not posted (4)
apps/quickbooks_online/utils.py (4)

488-488: The variable tax_rate_refs is initialized as an empty list which is appropriate for its use in accumulating tax rate references. This is a good practice as it clearly defines the variable's role at its point of use.


819-824: The handling of negative amounts in __construct_credit_card_purchase is correctly implemented by checking if the amount is negative and then converting it to a positive value. This is crucial for ensuring the accuracy of financial transactions.


486-487: The variable general_mappings is declared using type annotation but without an assignment operator. This might cause a syntax error in Python. Consider initializing it properly.

- general_mappings: GeneralMapping = GeneralMapping.objects.filter(workspace_id=self.workspace_id).first()
+ general_mappings = GeneralMapping.objects.filter(workspace_id=self.workspace_id).first()

Likely invalid or redundant comment.


Line range hint 480-516: The method purchase_object_payload has been updated to handle multiple line items and tax calculations. Ensure that all calls to this method have been updated to pass a list of line items instead of a single line item.

Verification successful

The verification script output shows that the purchase_object_payload method is called in three places within apps/quickbooks_online/utils.py. Each call passes a variable named line or lines as the second argument, which aligns with the updated method signature expecting a list of line items.

  • qbo_expense_payload = self.purchase_object_payload(qbo_expense, line, account_ref=qbo_expense.expense_account_id, payment_type='Cash')
  • cheque_payload = self.purchase_object_payload(cheque, line, account_ref=cheque.bank_account_id, payment_type='Check')
  • credit_card_purchase_payload = self.purchase_object_payload(credit_card_purchase, lines, account_ref=credit_card_purchase.ccc_account_id, payment_type='CreditCard', doc_number=credit_card_purchase.credit_card_purchase_number, credit=credit)

These calls indicate that the method is being used correctly with the new signature.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify all function calls to `purchase_object_payload` match the new signature.

# Test: Search for the function usage. Expect: Only occurances of the new signature.
rg --type python $'purchase_object_payload'

Length of output: 73



Script:

#!/bin/bash
# Description: Verify all function calls to `purchase_object_payload` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg 'purchase_object_payload'

Length of output: 1297



Script:

#!/bin/bash
# Description: Verify the arguments passed to `purchase_object_payload` in each call.

# Extract lines where `purchase_object_payload` is called and display the surrounding context.
rg 'purchase_object_payload' -A 2 -B 2

Length of output: 3614

@ruuushhh ruuushhh temporarily deployed to CI Environment May 30, 2024 04:40 — with GitHub Actions Inactive
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 b555b1c and f314707.
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

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

@ruuushhh ruuushhh temporarily deployed to CI Environment May 30, 2024 04:44 — with GitHub Actions Inactive
Copy link

Tests Skipped Failures Errors Time
234 0 💤 0 ❌ 0 🔥 58.910s ⏱️

@ruuushhh ruuushhh added the deploy Triggers deployment of active branch to Staging label May 30, 2024
@ruuushhh ruuushhh temporarily deployed to CI Environment May 30, 2024 05:02 — with GitHub Actions Inactive
@ruuushhh ruuushhh temporarily deployed to CI Environment May 30, 2024 05:24 — with GitHub Actions Inactive
@ruuushhh ruuushhh added deploy Triggers deployment of active branch to Staging and removed deploy Triggers deployment of active branch to Staging labels May 30, 2024
@ruuushhh ruuushhh temporarily deployed to CI Environment May 30, 2024 05:24 — with GitHub Actions Inactive
Copy link

Tests Skipped Failures Errors Time
234 0 💤 0 ❌ 0 🔥 44.390s ⏱️

@ruuushhh ruuushhh closed this May 30, 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.

1 participant