Jump to content

Quote Calculator: Difference between revisions

From Logistack
Line 93: Line 93:
* UK postcode format (server + client).
* UK postcode format (server + client).
* Numeric bounds for miles, rates, and surcharges.
* Numeric bounds for miles, rates, and surcharges.
* Permission checks on pricing endpoints (only Admin/Manager may change settings).
* Permission checks on pricing endpoints (only Admin may change settings).
* Rate limiting on public calculator to prevent abuse.
* Rate limiting on public calculator to prevent abuse.



Revision as of 01:11, 14 October 2025

Quote Calculator Module

See the video below for a demo on how this module works and how to edit the calculation factors.

Summary

The Quote Calculator provides a highly accurate cost of delivery, in real time from a postcode. It combines distance, fuel, labour, and regional surcharges (e.g., London/ULEZ/C-Charge), and then produces a customer-facing price with transparent line items.

Audience

  • Admins: configure pricing, surcharges, and rules.
  • Staff: generate quick quotes for callers.
  • Customers: Self-serve accurate quotes via the website.

Capabilities

  • Distance-based pricing from depot to destination and return.
  • Cost model: fuel (mpg × diesel £/L), labour £/hr, base fee, per-mile, and regional surcharges.
  • All quotes requests are record in administration along with customer phone and email for easy follow up.

Configuration

All values below are configurable in Settings.

Core Cost Parameters

  • Depot postcode: e.g., CO64FH
  • Base fee (£): e.g., 25.00
  • Per-mile rate (£/mile): e.g., 1.10
  • Labour rate (£/hr): e.g., 17.50
  • Diesel price (£/L): e.g., 1.42
  • Vehicle MPG (UK): e.g., 38.0

Regional Surcharges

  • London surcharge (£): e.g., 50.00
  • ULEZ / Congestion: fixed amounts or pass-through (configurable)
  • Dartford Crossing
  • London Tunnels

Presentation

  • VAT behaviour: include/exclude
  • Discount codes: applied when creating an invoice

Price Formula (reference)

distance_miles   = route_distance(from=Depot, to=Postcode[, return=true|false])

fuel_litres      = (distance_miles / vehicle_mpg_uk) * 4.546
fuel_cost        = fuel_litres * diesel_price_per_litre

labour_hours     = ( (distance_miles / avg_mph) + (loading_minutes/60) ) * crew_count
labour_cost      = labour_hours * labour_rate_per_hour

mileage_cost     = distance_miles * per_mile_rate
surcharges_total = london_surcharge + ulez + congestion + extras

subtotal         = base_fee + mileage_cost + fuel_cost + labour_cost + surcharges_total
subtotal         = max(subtotal, minimum_charge)
price_rounded    = apply_rounding(subtotal)
final_price      = apply_vat(price_rounded)

Example (illustrative):

Depot CO6 4FH → SW1A 1AA (one-way 68 mi), MPG 38, Diesel £1.42/L
fuel_litres ≈ (68 / 38) * 4.546 = 8.13 L
fuel_cost   ≈ 8.13 * 1.42 = £11.55
mileage     = 68 * £1.10 = £74.80
labour      = 2.0 hrs * £17.50 = £35.00   (example)
surcharges  = London £50.00
subtotal    = base £25 + £74.80 + £11.55 + £35 + £50 = £196.35 → rounded to £195/£200 per rule

Permissions

  • Admin: can configure pricing, view logs, export quotes.
  • Manager: can view logs and export quotes.
  • Staff: can create quotes
  • Customer / visitors: can generate quotes.

User Flow

  1. Enter destination postcode (no space e.g. CO43FH).
  2. Click Calculate. A quotation is displayed along with a break down of the costs.
  3. Quotation saved in administration.
  4. Happy with quotation? Click here to Book the delivery.
  5. Customer books the service.
  6. Booking sent to administration.

Database

All 2.8 million postcodes are included, from England, Scotland and Wales.

The database, an .sql file, was incredibly difficult to refine to the point where it was possible to upload, its current size is 88MB, was reduced from an initial 1.2GB.

Validation

  • UK postcode format (server + client).
  • Numeric bounds for miles, rates, and surcharges.
  • Permission checks on pricing endpoints (only Admin may change settings).
  • Rate limiting on public calculator to prevent abuse.

Caching & Performance

  • Postcode → lat/lon cached in postcode_cache (TTL configurable).
  • Distance calculation memoised for last N lookups.
  • Enable Preserve log in DevTools when debugging Network requests.
  • Consider CDN caching for static calculator assets.

Errors & Troubleshooting

  • “No price returned” Only 2 possibilities, 1. The user entered the postcode with a space, or a customization of the quote_calc_save.php file.
  • “Feels slow” Because Google Routes plans the route using roads (not as the crow flies), destinations a long way from your depot will take longer to calculate, thus the quote takes longer to appear - this is normal.
  • “Google Error message” Almost always due to adding the API Key incorrectly - the only fix is changing via the database (phpMyAdmin).
  • Provide a full report using How to Report an Issue.

Admin Tips

  • Review minimum charge and rounding quarterly.
  • Keep diesel price updated weekly.
  • Use discount codes sparingly; prefer fixed-price overrides for special jobs.
  • Add London/ULEZ/C-Charge as separate line items to keep audits clean.

FAQ

  • Can I include return mileage? Yes—toggle “Include return” in settings.
  • Do customers see line items? Public view shows simplified items; staff see full breakdown.
  • How do I change the base fee? Settings → Pricing → Base fee.
  • Why does my mileage seem high? Ensure route mode is “road network,” not straight-line; clear cache and retry.

Release Notes

  • v1.8.7 – UI polish, faster list rendering, clearer errors on failed POD upload; minor rounding fixes in PDFs (see Release Notes).

Roadmap

A few additions in the pipeline, both UI and functionality improvements - see Logistack development Roadmap for more info.

See Also