Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/multisafepay/api/shared/cart/cart_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def add_weight(self: "CartItem", weight: Weight) -> "CartItem":

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.
) -> "CartItem":
"""
Add tax rate percentage to the cart item.
Expand All @@ -261,7 +261,7 @@ def add_tax_rate_percentage(

Parameters
----------
tax_rate_percentage: (float) The tax rate percentage to be added.
tax_rate_percentage: (int) The tax rate percentage to be added.

Returns
-------
Expand All @@ -279,7 +279,8 @@ def add_tax_rate_percentage(
)

try:
self.tax_table_selector = str(tax_rate_percentage / 100)
rating = tax_rate_percentage / 100
self.tax_table_selector = str(rating)
except (ValueError, TypeError) as e:
raise InvalidArgumentException(
"Tax rate percentage cannot be converted to a string.",
Expand Down
22 changes: 21 additions & 1 deletion tests/multisafepay/unit/api/shared/cart/test_unit_cart_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,25 @@ def test_add_tax_rate_percentage():

"""
item = CartItem()
item.add_tax_rate_percentage(21.0)
item.add_tax_rate_percentage(21)
assert item.tax_table_selector == "0.21"


def test_add_tax_rate_percentage():
"""
Test that a 0 tax rate percentage is correctly set as the tax table selector in a CartItem.

"""
item = CartItem()
item.add_tax_rate_percentage(0)
assert item.tax_table_selector == "0.0"


def test_add_tax_rate_percentage():
"""
Test that a 0.0 tax rate percentage is correctly set as the tax table selector in a CartItem.

"""
item = CartItem()
item.add_tax_rate_percentage(0.0)
assert item.tax_table_selector == "0.0"