create or replace function price_on_location(sku integer, loc integer)
  returns Numeric(9,2)
language sql as
$$
  select max(price) as unit_price  -- Maximum price for all batches.
  from                             -- Only discounts can reduce
    "batches"                      -- the price of an item on the cart
  join
    itemsonshelf
  on
    "batches".id = itemsonshelf.batch
  where
    itemsonshelf.location = $2 and "batches".sku = $1
$$;