Surface add-on prices and add an add-ons total sensor

Add-on rows already carried quantity, unit and extended price; only the name
was exposed. The attribute now renders the full line and a new monetary
sensor reports the add-ons subtotal separately from the box.

The fixture totals were copied from a seven-add-on cart while the fixture
itself had one, so they are now self-consistent and a test asserts that
add-ons plus box price equals the portal's subtotal.
This commit is contained in:
flan
2026-08-03 19:15:19 +00:00
parent a97f0aec6a
commit 527f662189
10 changed files with 174 additions and 32 deletions
+36 -3
View File
@@ -70,13 +70,46 @@
</div>
</div>
</div>
<!-- Multi-quantity add-on: item-total is the EXTENDED price, 4 x $4.49. -->
<div id='DODRow-4' class='cart-item qv-button shop-item-cursor' data-qvid='9012'>
<img class='cart-item-img' src='https://cdn.freshharvest.com/y.jpg' alt='Complete Recovery Smoothie' />
<div class='item-details'>
<span class='item-name'><div>Complete Recovery Smoothie</div></span>
<span class='item-total'>$17.96</span>
<span class='item-uom'><div>15.2 fl oz</div><div class='snap-tag-cart'></div></span>
<div class='item-order-wrapper'>
<div class='item-order item-order-disabled'>
<div class='btn-round item-order-remove qv-ignore'></div>
<span class='item-order-quantity qv-ignore' data-item-quantity='9012'>4</span>
<div class='btn-round item-order-add qv-ignore'></div>
</div>
</div>
</div>
</div>
<div id='DODRow-5' class='cart-item qv-button shop-item-cursor' data-qvid='9105'>
<img class='cart-item-img' src='https://cdn.freshharvest.com/z.jpg' alt='Organic Fruit Punch Juice Boxes' />
<div class='item-details'>
<span class='item-name'><div>Organic Fruit Punch Juice Boxes</div></span>
<span class='item-total'>$13.98</span>
<span class='item-uom'><div>8 count</div><div class='snap-tag-cart'></div></span>
<div class='item-order-wrapper'>
<div class='item-order item-order-disabled'>
<div class='btn-round item-order-remove qv-ignore'></div>
<span class='item-order-quantity qv-ignore' data-item-quantity='9105'>2</span>
<div class='btn-round item-order-add qv-ignore'></div>
</div>
</div>
</div>
</div>
</div>
<div id='OrderTotals-2772590'>
<div class='cart-summary'>
<span class='summary-item label'>Subtotal</span><span class='summary-item value'>$105.88</span>
<span class='summary-item label'>Tax</span><span class='summary-item value'>$3.18</span>
<!-- Self-consistent: box 33.00 + add-ons 39.93 = 72.93 subtotal, which is
over the $70 free-delivery threshold, hence the $0.00 fee. -->
<span class='summary-item label'>Subtotal</span><span class='summary-item value'>$72.93</span>
<span class='summary-item label'>Tax</span><span class='summary-item value'>$2.19</span>
<span class='summary-item label'>Delivery</span><span class='summary-item value'>$0.00</span>
<span class='summary-item label demi-bold total'>Order Total <span>See Details</span></span><span class='summary-item value'>$109.06</span>
<span class='summary-item label demi-bold total'>Order Total <span>See Details</span></span><span class='summary-item value'>$75.12</span>
</div>
</div>
+20 -6
View File
@@ -70,16 +70,30 @@ def test_next_order_is_the_locked_one(snapshot):
def test_next_order_totals_and_contents(snapshot):
order = snapshot.next_order
assert order.box_name == "Georgia Grown Small Box"
assert (order.subtotal, order.tax, order.delivery_fee) == (105.88, 3.18, 0.0)
assert order.total == 109.06
assert (order.subtotal, order.tax, order.delivery_fee) == (72.93, 2.19, 0.0)
assert order.total == 75.12
assert [(i.quantity, i.name, i.unit) for i in order.items] == [
(1, "Bolero Carrots", ".5 lb"),
(2, "Georgia Peaches", "6 count"),
]
assert [
(a.name, a.price, a.quantity, a.unit) for a in order.addons
] == [("Black Mission Figs", 7.99, 1, "1 pint")]
assert len(order.all_items) == 3
assert [(a.name, a.price, a.quantity, a.unit) for a in order.addons] == [
("Black Mission Figs", 7.99, 1, "1 pint"),
("Complete Recovery Smoothie", 17.96, 4, "15.2 fl oz"),
("Organic Fruit Punch Juice Boxes", 13.98, 2, "8 count"),
]
assert len(order.all_items) == 5
def test_addons_total_reconciles_with_the_subtotal(snapshot):
"""Add-ons plus the box price must equal the subtotal the portal reports."""
order = snapshot.next_order
assert order.addons_total == 39.93
assert round(order.addons_total + order.box_price, 2) == order.subtotal
def test_addons_total_is_zero_when_nothing_is_added(snapshot):
assert snapshot.open_order.addons == []
assert snapshot.open_order.addons_total == 0.0
def test_open_order(snapshot):