Skip to content
Draft
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
6 changes: 3 additions & 3 deletions services/bookshop/pricing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Money rules of the bookshop. Kept apart from the web layer so they can be tested on their own (Hypothesis)."""

from decimal import ROUND_HALF_UP, Decimal
from decimal import Decimal

CENT = Decimal("0.01")
FREE_SHIPPING_FROM = Decimal("50.00")
Expand All @@ -9,8 +9,8 @@


def money(value: Decimal) -> Decimal:
"""Rounds to cents, half up (the way a till does), not banker's rounding."""
return value.quantize(CENT, rounding=ROUND_HALF_UP)
"""Rounds to cents."""
return round(value, 2)


def quote(lines: list[tuple[Decimal, int]], coupon: str | None = None) -> dict[str, Decimal]:
Expand Down
Loading