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
8 changes: 4 additions & 4 deletions apps/api/app/services/pricing_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,12 @@ async def calculate_quotation(
coating_charge = money(total_area * coat_rate)

minimum_job = _rule_amount(rules, PricingRuleType.MINIMUM_JOB)
if minimum_job is None:
if minimum_job is None and not approved:
raise ValueError("No minimum job charge configured on the active pricing profile")
territory_minimum = (
data.territory.minimum_job_value_gbp if data.territory else Decimal("0")
)
effective_minimum = minimum_job if approved else max(minimum_job, territory_minimum)
effective_minimum = Decimal("0") if approved else max(minimum_job, territory_minimum)

# Minimum applies to the works (surface + washing + coating) before travel.
# Travel is added afterwards. This order is intentional and matches the previous engine.
Expand Down Expand Up @@ -405,8 +405,8 @@ async def calculate_quotation(
"policy_source": "owner_configured" if configured_discount_policy else "approved_defaults",
},
"minimum_rule": (
"Works subtotal is raised to the greater of the pricing-rule minimum "
"and the territory minimum. Travel is added after that. "
("Approved restoration has no minimum job charge. " if approved else "Works subtotal is raised to the greater of the pricing-rule minimum and the territory minimum. ") +
"Travel is added after that. "
"The amount the customer pays is then rounded up to the next £5. "
"VAT is added before that rounding only when the company is VAT registered "
"on the pricing date."
Expand Down
4 changes: 2 additions & 2 deletions apps/api/tests/test_approved_restoration_pricing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
("imprinted-concrete-restoration", SurfaceType.IMPRINTED_CONCRETE, "approved-clear", "12", "3", "810"),
("imprinted-concrete-colour-restoration", SurfaceType.IMPRINTED_CONCRETE, "approved-colour", "14", "2.97", "930"),
])
@pytest.mark.parametrize("area", [10, 20, 50, 60, 84, 100, 200])
@pytest.mark.parametrize("area", [10, 18, 20, 50, 60, 84, 100, 200])
async def test_approved_restoration(monkeypatch, slug, surface, label, rate, materials, expected, area):
profile = PricingProfile(id=uuid4(), name="surfacecoat-approved-restoration", version=3)
profile.rules = [
Expand All @@ -41,7 +41,7 @@ async def active(db):
assert result.breakdown["visits"] == 2
assert result.vat_gbp == 0
assert result.estimated_materials_gbp == Decimal(materials) * area
works = max(Decimal('350'), Decimal(rate) * area)
works = Decimal(rate) * area
expected_total = ((works + Decimal('86')) / 5).to_integral_value(rounding=ROUND_CEILING) * 5
assert expected_total % 5 == 0
discounts = {50: Decimal(".03"), 60: Decimal(".03"), 84: Decimal(".03"), 100: Decimal(".05"), 200: Decimal(".10")}
Expand Down
Loading