feat: add per-item currency support with server-side exchange rate co…#175
feat: add per-item currency support with server-side exchange rate co…#175BKSalman wants to merge 1 commit intomauriceboe:devfrom
Conversation
bd15d63 to
38b8acb
Compare
|
Hey, nice work on this. The overall design is solid: per-item currency with server-side conversion, SQLite-cached rates with stale fallback, WebSocket propagation, and all aggregations correctly using COALESCE(converted_price, total_price). Found one bug though: Simplest fix: use Also the package-lock.json changes add |
38b8acb to
32fbeb1
Compare
fc50de0 to
2034489
Compare
|
ok, now it should be fixed, with other small bug fixes, and I also added the tables to the schema.ts file please tell me if there is anything else wrong with it |
|
Hey, thanks for the update – the Found a couple more things though:
These are pretty quick fixes. Once 1 and 2 are sorted I'm happy to merge. |
|
@mauriceboe Thank you for your time, it should be good now |
|
just resolved conflicts, and tested the basic functionality, and it seems like it's working |
mauriceboe
left a comment
There was a problem hiding this comment.
Hey, nice work on this. The overall approach is solid and the earlier feedback was addressed well. Found a few more things though:
Bugs
1. item_currency not normalized on update
createBudgetItem correctly does .toUpperCase(), but updateBudgetItem writes data.item_currency straight into the DB without normalizing. If someone sends "eur" via PUT, it lands lowercase in the DB. The route validation (isValidCurrency) accepts it because it checks val.toUpperCase() but passes the original value through. Easy fix: normalize in updateBudgetItem before passing to the query.
2. Race condition in recalculateTrip – parallel API fetches
Promise.all over all items means if 10 items share the same foreign currency, all 10 hit the cache miss simultaneously and fire 10 parallel fetchAndCacheRates("JPY") calls before the first one finishes caching. Could trigger rate limits on the external API.
Fix: collect unique item currencies first, fetch them sequentially (or deduplicated), then convert locally.
Security
3. refresh-rates doesn't check budget_edit permission
The endpoint only checks verifyTripAccess – any trip member (even read-only) can spam rate refreshes and hammer the external API. Should either require budget_edit or have some rate limiting.
Cleanup
formatConvertedAmountinformatters.tsis exported but never imported anywhere – dead code.- The
package-lock.jsonstill has the unrelated"peer": trueadditions from the earlier review.
1–3 should be addressed before merge, the rest is nice-to-have.
|
@mauriceboe ok, done 👍 |
|
fixed failing tests |
|
resolved conflicts, and removed |
resolves #38
these changes were AI assisted, since I'm currently on a trip 😅, but I would really appreciate this feature being added
if there is anything you don't like or think is AI slop, I can manually change it