Repository navigation
Feature/25 price lookup by date - #87
Merged
Merged
Conversation
lauriechammah
requested changes
Nov 18, 2026
lauriechammah
left a comment
Collaborator
There was a problem hiding this comment.
See requested changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #25
Overview
The donation value calculation (#30) needs the price of a food item on the date it was donated. This PR adds that lookup, plus an endpoint to read an item's price history.
Price lookup
PriceService.GetPriceInEffectAsync(catalogItemId, date)returns the price in effect on a date: the price with the latest effective date on or before that date. A price applies from its effective date itself.PriceHistory.FindPriceInEffect(in Core), so the service and any future code use the same logic.Clear behavior when there is no price
PriceNotFoundException. The error gives the item, the date asked for, and the first effective date, for example: "Catalog item … has no price on 2026-10-20: its first price starts on 2026-11-01."CatalogItemNotFoundException.API endpoints
GET /api/catalog-items/{id}/pricesreturns the price history, oldest first (an empty list if the item has no prices yet), or 404 if the item doesn't exist.GET /api/catalog-items/{id}/prices/in-effect?date=yyyy-MM-ddreturns the price on that date. It returns 404 with a clear message (andfirstEffectiveDate) if there is no price on that date or the item doesn't exist, and 400 if the date is missing or invalid.Errors use the standard
application/problem+jsonformat. I also updateddocs/database/prices.mdto explain the lookup and the endpoints, and added example requests toMoissonMontreal.Api.http.Open point: both endpoints only require a signed-in user (
access_as_userscope), like/api/me. There is no "view prices" permission yet, so someone in the Microsoft tenant who was never added to the app could still read prices. Should a permission protect these endpoints?Testing
Unit tests, no Docker needed (
PriceHistoryTests):Integration tests against PostgreSQL (Testcontainers):
PriceServiceTests: correct price for each date, a date before the first price, an item with no prices, an unknown item, another item's prices ignored, history orderCatalogItemPricesEndpointTests: both endpoints, the contents of the 404 errors, missing or invalid dates (400), missing token (401)Full suite: 343 tests passing (
dotnet test).Screenshots / Screencasts
N/A. This is a back-end change with no frontend components.
Checklist
Tip: You can make the issue and then check them after the fact or replace
[ ]with[x]to check it!Notes