Open
Conversation
- Add BOMItem, InventoryCheckResult, NotificationEvent models
- Extend Booking with client_supply_override and artisan_device_token
- Add Alembic migration for new tables/columns
- Implement RouteService with Haversine corridor computation
- Add pluggable StoreAdapterProtocol and MockStoreAdapter
- Implement InventoryCheckerService with Redis caching and error isolation
- Implement NotificationService with FCM HTTP v1 and 5-notification cap
- Wire run_inventory_check background task to IN_PROGRESS booking transition
- Add GET /inventory/{booking_id}/results and POST /bookings/{booking_id}/supply-override endpoints
- Add InventoryResultsPanel and ClientSupplyOverrideToggle frontend components
- Add api.inventory methods to frontend API client
- 50 backend tests passing
|
@johnsmccain Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Collaborator
|
hi @johnsmccain please help look in to failing CI |
Author
|
done |
Collaborator
|
please resolve conflicts @johnsmccain, also look in to ci fail |
- contracts.yml: fix toolchain version (1.90.0 -> stable) - contracts.yml: add --features testutils to cargo test - ci.yml: replace STELLAR_ESCROW_PUBLIC with ESCROW_CONTRACT_ID - frontend-check.yml: add push trigger on main branch
Author
|
Hi @gabito1451 review pr please |
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.
feat: Route-Based Inventory Check
Summary
Implements the route-based inventory check feature end-to-end. When an artisan's booking transitions to
IN_PROGRESS, the system computes a geographic corridor along their route to the job site, queries external store inventory APIs for each BOM item at stores within that corridor, and dispatches push notifications to the artisan for any items found in stock. Clients can suppress the entire flow by setting aclient_supply_overrideflag on their booking.Closes #162
What changed
Database
bom_itemstable — stores Bill of Materials line items per bookinginventory_check_resultstable — persists per-store, per-item availability resultsnotification_eventstable — audit log for every FCM push notification sentbookingstable withclient_supply_override(bool) andartisan_device_token(str)001_add_inventory_bom_notification_tablesBackend services
RouteService(services/route_service.py) — Haversine-based bounding-box corridor computation with configurable half-width (default 500 m)StoreAdapterProtocol+MockStoreAdapter(services/inventory/) — pluggable interface for store API integrationsInventoryCheckerService(services/inventory/checker.py) — corridor filtering, Redis caching (TTL 5 min), per-adapter timeout (5 s), full error isolationNotificationService(services/notification_service.py) — FCM HTTP v1, capped at 5 notifications per run, persistsNotificationEventrows regardless of FCM outcomerun_inventory_checkbackground task (services/inventory/tasks.py) — wired into the booking status endpoint; skips whenclient_supply_override=True; never raisesAPI endpoints
GET /inventory/{booking_id}/results— returns inventory results; marks results older than 24 h asstalePOST /bookings/{booking_id}/supply-override— client-only; validates ownership and booking status (PENDING/CONFIRMED); returns HTTP 403 otherwiseFrontend
InventoryResultsPanelcomponent — renders results with availability badges, stale badges, and pre-pay links; shows empty state when no dataClientSupplyOverrideTogglecomponent — checkbox that disables for non-pending/confirmed bookings; calls API on change; shows sonner toastsClientSupplyOverrideToggleinto the bookings dashboard pageapi.inventory.getResults()andapi.inventory.setSupplyOverride()tolib/api.tsConfig additions
Tests
50 backend tests added, all passing:
test_route_service.pytest_inventory_checker.pytest_inventory_schemas.pytest_notification_service.pytest_background_task.pytest_inventory_endpoints.pyFrontend Vitest tests added for
InventoryResultsPanel(9 tests) andClientSupplyOverrideToggle(8 tests).Run backend tests:
cd backend pytest app/tests/test_route_service.py app/tests/test_inventory_checker.py \ app/tests/test_inventory_schemas.py app/tests/test_notification_service.py \ app/tests/test_background_task.py app/tests/test_inventory_endpoints.py -vRun frontend tests (after
npm install):cd frontend npx vitest run components/booking/Architecture
Notes
FCM_PROJECT_IDis not set — safe to deploy without credentialsalembic upgrade headInventoryCheckerServiceis initialised with an empty adapter list until store integrations are addedChecklist
db/base.py