Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add order free shipping #47

Merged
merged 3 commits into from
Mar 8, 2025
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
2 changes: 2 additions & 0 deletions amazonorders/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@
order_str += f"\n Subtotal: {config.constants.format_currency(order.subtotal)}"
if order.shipping_total:
order_str += f"\n Shipping Total: {config.constants.format_currency(order.shipping_total)}"
if order.free_shipping:
order_str += f"\n Free Shipping: {config.constants.format_currency(order.free_shipping)}"

Check warning on line 352 in amazonorders/cli.py

View check run for this annotation

Codecov / codecov/patch

amazonorders/cli.py#L352

Added line #L352 was not covered by tests
if order.subscription_discount:
order_str += f"\n Subscription Discount: {config.constants.format_currency(order.subscription_discount)}"
if order.total_before_tax:
Expand Down
2 changes: 2 additions & 0 deletions amazonorders/entity/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def __init__(self,
self.subtotal: Optional[float] = self._if_full_details(self._parse_currency("subtotal"))
#: The Order shipping total. Only populated when ``full_details`` is ``True``.
self.shipping_total: Optional[float] = self._if_full_details(self._parse_currency("shipping"))
#: The Order free shipping. Only populated when ``full_details`` is ``True``.
self.free_shipping: Optional[float] = self._if_full_details(self._parse_currency("free shipping"))
#: The Order promotion applied. Only populated when ``full_details`` is ``True``.
self.promotion_applied: Optional[float] = self._if_full_details(
self._parse_currency("promotion", combine_multiple=True))
Expand Down
13 changes: 13 additions & 0 deletions tests/entity/test_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ def test_order_coupon_savings(self):
# THEN
self.assertEqual(order.coupon_savings, -3.89)

def test_order_free_shipping(self):
# GIVEN
with open(os.path.join(self.RESOURCES_DIR, "orders", "order-details-111-6778632-7354601.html"),
"r",
encoding="utf-8") as f:
parsed = BeautifulSoup(f.read(), self.test_config.bs4_parser)

# WHEN
order = Order(parsed, self.test_config, full_details=True)

# THEN
self.assertEqual(order.free_shipping, -2.99)

def test_order_coupon_savings_multiple(self):
# GIVEN
with open(os.path.join(self.RESOURCES_DIR, "orders", "order-details-coupon-savings-multiple.html"),
Expand Down
Loading