mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 08:53:13 +00:00
fix(costs): keep convertBooked at five parameters and update the tests to as-typed display rows
The display-currency check is its own helper (inDisplayCurrency), used by the Costs model and the shared trip page. The tests that pinned #2525's reading of a display-currency bill through the trip currency now pin the as-typed reading, which the balances use too; read in the trip currency, such a bill and its repayment may stay a euro cent apart.
This commit is contained in:
@@ -3,7 +3,7 @@ import { catMeta } from '../../components/Budget/costsCategories'
|
||||
import { fs, NEUTRAL_TINT } from '../../components/shared/DialogShell'
|
||||
import { CountPill } from '../../components/Planner/bookings/bookingParts'
|
||||
import { TripMemberAvatar } from '../../components/Trips/TripMemberAvatar'
|
||||
import { convertBooked, convertedLine } from '../../hooks/useExchangeRates'
|
||||
import { convertBooked, convertedLine, inDisplayCurrency } from '../../hooks/useExchangeRates'
|
||||
import { useTranslation } from '../../i18n'
|
||||
import { avatarSrc } from '../../utils/avatarSrc'
|
||||
import { currencyDecimals } from '../../utils/formatters'
|
||||
@@ -92,7 +92,11 @@ export function SharedCostsView({ items, base, tripCurrency, convert }: CostsPro
|
||||
const { t, locale } = useTranslation()
|
||||
if (items.length === 0) return <EmptySection icon={<Wallet size={22} />} text={t('shared.emptyCosts')} />
|
||||
const amountOf = (i: Expense) => Number.parseFloat(String(i.total_price ?? '')) || 0
|
||||
const valueOf = (i: Expense) => convertBooked(amountOf(i), i.currency, i.exchange_rate, tripCurrency, convert, base)
|
||||
// A bill in the owner's display currency reads as typed, as in Costs (#2965).
|
||||
const valueOf = (i: Expense) =>
|
||||
inDisplayCurrency(i.currency, tripCurrency, base)
|
||||
? amountOf(i)
|
||||
: convertBooked(amountOf(i), i.currency, i.exchange_rate, tripCurrency, convert)
|
||||
// In the reader's own number format with the currency's code: a public page has
|
||||
// no idea where its reader is, and "$" alone does not say which dollar.
|
||||
// Whole cents: a converted amount otherwise printed a third decimal.
|
||||
|
||||
Reference in New Issue
Block a user