Skip to main content

ADR-002: Pricing Category Support

Status

Accepted

Context

We needed to support different container types (skip bin, hook bin, trash bag) in our pricing system. Before this change, everything was treated as "skip bin" implicitly.

Goals:

  • Filter pricing by container type
  • Keep existing data working
  • Update all pricing APIs to use category

Decision: Add Category to Pricing Records

Added a category column to the pricings table. Existing records were filled with the category from their waste type.

Trade-offs

Good:

  • Simple change - just one new column
  • Existing data automatically updated
  • Can filter pricing by container type

Bad:

  • Category can be empty (null) if not set
  • Could have duplicate pricing rows for same supplier/area/type/container with different categories

Decision: Optional Category Filtering

Pricing queries filter by category only when one is provided. If no category is given, the query returns all pricing records.

Trade-offs

Good:

  • Old code still works without changes
  • Can get pricing for specific container types or all types

Bad:

  • If you forget to pass the category, you might get wrong pricing
  • No requirement that every query must include a category

Decision: Category Parameter Through All APIs

Every API endpoint that gets pricing now accepts a category parameter. This includes admin, vendor, and public APIs.

Trade-offs

Good:

  • All pricing requests can specify the container type
  • Consistent approach across the whole system

Bad:

  • Had to update 20+ files
  • If the request doesn't include category, we fall back to the waste container's category
  • All API consumers need to send the category now

Decision: Category Dropdown in UI

Admin and Dashboard pages now have a dropdown to filter pricing by container type (skip bin, hook bin, etc). Changing the dropdown reloads the page with the selected category.

Trade-offs

Good:

  • Users can view pricing for specific container types
  • URL includes the filter so you can bookmark it

Bad:

  • Page reloads when changing category (not instant)
  • Have to preserve the category in all navigation links (Next/Prev dates, reset pricing buttons)

Decision: Category Falls Back to Waste Container

If an API request doesn't specify a category, we use the category from the waste container (bin size) being requested.

Trade-offs

Good:

  • Old API calls still work without changes
  • Each bin size knows its own category

Bad:

  • Assumes every waste container has a category set
  • Creates hidden dependency - pricing queries rely on waste container data

Decision: New Pricing Inherits Container Category

When creating a new bin size, the pricing records automatically get the same category as the bin size.

Trade-offs

Good:

  • New pricing has correct category automatically
  • No manual steps needed

Bad:

  • Uses fixed values internally (waste type 19, service areas 2-6)

Decision: One-Way Data Migration

The migration that fills in categories for existing pricing records doesn't have a rollback. Once populated, we don't try to undo it.

Trade-offs

Good:

  • Acknowledges this is a one-time data fix

Bad:

  • Can't fully roll back to before this change

Date

April 24, 2026

Author

Cascade AI Assistant (based on commits by Aryan Jaya)