Skip to content

Conversation

@zulquer
Copy link
Collaborator

@zulquer zulquer commented Aug 28, 2025

This pull request updates the handling of tax rate percentages in the CartItem class to use integers instead of floats, and adds new tests to verify correct behavior for both integer and float inputs, including edge cases like zero. These changes improve type consistency and ensure robust handling of tax rate values.

Type consistency improvements:

  • Changed the tax_rate_percentage parameter type from float to int in the add_tax_rate_percentage method and its docstring in cart_item.py, ensuring that only integer values are expected for tax rates. [1] [2]

Behavioral adjustments:

  • Updated the calculation in add_tax_rate_percentage to use an intermediate variable rating, clarifying the conversion logic before setting tax_table_selector.

Test coverage enhancements:

  • Updated the existing test to pass an integer tax rate percentage instead of a float, reflecting the new expected input type.
  • Added new tests to verify that both 0 and 0.0 tax rate percentages are correctly handled, ensuring that edge cases and type flexibility are covered.

@zulquer zulquer requested review from Copilot and danielcivit August 28, 2025 07:41
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request changes the tax_rate_percentage parameter type from float to int in the CartItem class to improve type consistency, while adding comprehensive test coverage for edge cases including zero values.

  • Updated add_tax_rate_percentage method signature and documentation to expect integer input
  • Added intermediate variable for calculation clarity
  • Enhanced test coverage with edge cases for zero tax rates

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/multisafepay/api/shared/cart/cart_item.py Changed parameter type from float to int and updated calculation logic
tests/multisafepay/unit/api/shared/cart/test_unit_cart_item.py Updated existing test and added new tests for zero tax rate scenarios

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

"""
item = CartItem()
item.add_tax_rate_percentage(0.0)
print(item)
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

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

Debug print statement should be removed from test code. This appears to be leftover debugging code that should not be committed.

Suggested change
print(item)

Copilot uses AI. Check for mistakes.
def add_tax_rate_percentage(
self: "CartItem",
tax_rate_percentage: float,
tax_rate_percentage: int,
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

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

The test shows that 0.0 (float) is still being passed to this method, but the type annotation now requires int. This creates an inconsistency where the API accepts floats in practice but the type annotation suggests only integers are valid.

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Aug 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.49%. Comparing base (26cb336) to head (0482a4a).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #30   +/-   ##
=======================================
  Coverage   90.48%   90.49%           
=======================================
  Files         107      107           
  Lines        2323     2324    +1     
=======================================
+ Hits         2102     2103    +1     
  Misses        221      221           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zulquer zulquer force-pushed the PTHMINT-81-tax_rate_percentage-should-be-integer branch from 2b03e10 to 0482a4a Compare August 28, 2025 13:23
@zulquer zulquer merged commit 997881d into master Aug 28, 2025
6 checks passed
@zulquer zulquer deleted the PTHMINT-81-tax_rate_percentage-should-be-integer branch August 28, 2025 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants