diff --git a/amazonorders/cli.py b/amazonorders/cli.py index 0da1724..9022cb8 100644 --- a/amazonorders/cli.py +++ b/amazonorders/cli.py @@ -348,6 +348,8 @@ def _order_output(order: Order, 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)}" if order.subscription_discount: order_str += f"\n Subscription Discount: {config.constants.format_currency(order.subscription_discount)}" if order.total_before_tax: diff --git a/amazonorders/entity/order.py b/amazonorders/entity/order.py index 1817a5f..486d09d 100644 --- a/amazonorders/entity/order.py +++ b/amazonorders/entity/order.py @@ -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)) diff --git a/tests/entity/test_order.py b/tests/entity/test_order.py index dc44926..fa40bbf 100644 --- a/tests/entity/test_order.py +++ b/tests/entity/test_order.py @@ -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"),