refactor: rename fiatAmount to fiatCents for clarity

The field was always stored in cents but the name was ambiguous.
Rename to fiatCents across state machine, store, and views.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Patrick Mulligan 2026-03-07 13:02:12 -05:00
commit 473834a363
6 changed files with 61 additions and 47 deletions

View file

@ -271,7 +271,7 @@ export const useAtmStore = defineStore('atm', () => {
persistTransaction({
txid: ctx.txid,
type: isCashInTx ? 'cash_in' : 'cash_out',
fiatCents: ctx.fiatAmount,
fiatCents: ctx.fiatCents,
sats: ctx.satsAmount,
bills,
})
@ -626,7 +626,7 @@ export const useAtmStore = defineStore('atm', () => {
}
// Calculate what the new sats amount would be
const newFiatCents = ctx.fiatAmount + denomination * 100
const newFiatCents = ctx.fiatCents + denomination * 100
const newFiatUnits = newFiatCents / 100
const grossSats = Math.floor(newFiatUnits * ctx.exchangeRate)
const fee = Math.floor(grossSats * ctx.feePercent)
@ -846,7 +846,7 @@ export const useAtmStore = defineStore('atm', () => {
}
// Calculate if this bill would exceed available balance
const newFiatCents = ctx.fiatAmount + denomination * 100
const newFiatCents = ctx.fiatCents + denomination * 100
const newFiatUnits = newFiatCents / 100
const grossSats = Math.floor(newFiatUnits * ctx.exchangeRate)
const fee = Math.floor(grossSats * ctx.feePercent)

View file

@ -119,7 +119,7 @@ function canAcceptBill(denomination: number): boolean {
const ctx = context.value
if (!ctx) return false
if (ctx.availableBalance <= 0 || ctx.exchangeRate === 0) return true
const newFiatCents = ctx.fiatAmount + denomination * 100
const newFiatCents = ctx.fiatCents + denomination * 100
const grossSats = Math.floor((newFiatCents / 100) * ctx.exchangeRate)
const fee = Math.floor(grossSats * ctx.feePercent)
return grossSats - fee <= ctx.availableBalance
@ -214,7 +214,7 @@ const isProcessing = computed(() => atmStore.isPayingInvoice)
<!-- Amount display -->
<div v-if="context">
<p class="text-3xl lg:text-[6vh] font-bold text-success leading-tight">
{{ atmStore.fiatSymbol }}{{ (context.fiatAmount / 100).toFixed(2) }}
{{ atmStore.fiatSymbol }}{{ (context.fiatCents / 100).toFixed(2) }}
</p>
<p class="text-xl lg:text-[3.5vh] font-semibold text-bitcoin">
{{ formatSats(context.satsAmount) }} sats
@ -322,7 +322,7 @@ const isProcessing = computed(() => atmStore.isPayingInvoice)
{{ formatSats(context?.satsAmount || 0) }} sats
</p>
<p class="text-lg lg:text-2xl text-muted-foreground">
{{ atmStore.fiatSymbol }}{{ ((context?.fiatAmount || 0) / 100).toFixed(2) }}
{{ atmStore.fiatSymbol }}{{ ((context?.fiatCents || 0) / 100).toFixed(2) }}
</p>
<!-- Waiting indicator -->
@ -388,7 +388,7 @@ const isProcessing = computed(() => atmStore.isPayingInvoice)
<h3 class="text-2xl lg:text-[3rem] font-bold text-destructive">Cash Already Accepted</h3>
<p class="max-w-lg text-center text-base lg:text-2xl text-muted-foreground">
Your {{ atmStore.fiatSymbol
}}{{ context ? (context.fiatAmount / 100).toLocaleString() : '' }} has been accepted and
}}{{ context ? (context.fiatCents / 100).toLocaleString() : '' }} has been accepted and
cannot be returned. Please scan the QR code to receive your Bitcoin.
</p>
<Button
@ -428,7 +428,7 @@ const isProcessing = computed(() => atmStore.isPayingInvoice)
<div class="flex justify-between text-base lg:text-2xl">
<span class="text-muted-foreground">Inserted</span>
<span class="font-semibold"
>{{ atmStore.fiatSymbol }}{{ (context.fiatAmount / 100).toFixed(2) }}</span
>{{ atmStore.fiatSymbol }}{{ (context.fiatCents / 100).toFixed(2) }}</span
>
</div>
<div class="flex justify-between text-base lg:text-2xl">
@ -445,7 +445,7 @@ const isProcessing = computed(() => atmStore.isPayingInvoice)
>{{
formatSats(
Math.floor(
Math.floor((context.fiatAmount / 100) * context.exchangeRate) *
Math.floor((context.fiatCents / 100) * context.exchangeRate) *
context.feePercent
)
)

View file

@ -211,7 +211,7 @@ function formatFiat(cents: number): string {
<div class="text-center py-2 lg:py-4">
<p class="text-sm lg:text-xl text-muted-foreground">You will receive</p>
<p class="text-4xl lg:text-[7vh] font-bold text-success leading-tight">
{{ atmStore.fiatSymbol }}{{ context ? formatFiat(context.fiatAmount) : '0.00' }}
{{ atmStore.fiatSymbol }}{{ context ? formatFiat(context.fiatCents) : '0.00' }}
</p>
<p class="mt-1 lg:mt-2 text-lg lg:text-2xl text-muted-foreground">
You pay:
@ -291,7 +291,7 @@ function formatFiat(cents: number): string {
<p class="text-lg lg:text-2xl text-muted-foreground">
to receive
<Badge class="bg-success text-success-foreground text-lg lg:text-2xl">
{{ atmStore.fiatSymbol }}{{ context ? formatFiat(context.fiatAmount) : '0.00' }}
{{ atmStore.fiatSymbol }}{{ context ? formatFiat(context.fiatCents) : '0.00' }}
</Badge>
</p>
@ -363,7 +363,7 @@ function formatFiat(cents: number): string {
<p v-if="context" class="text-lg lg:text-2xl">
Please take your
<Badge class="bg-success text-success-foreground text-2xl"
>{{ atmStore.fiatSymbol }}{{ formatFiat(context.fiatAmount) }}</Badge
>{{ atmStore.fiatSymbol }}{{ formatFiat(context.fiatCents) }}</Badge
>
</p>
<Button
@ -411,7 +411,7 @@ function formatFiat(cents: number): string {
formatSats(
Math.abs(
context.satsAmount -
Math.floor((context.fiatAmount / 100) * context.exchangeRate)
Math.floor((context.fiatCents / 100) * context.exchangeRate)
)
)
}}
@ -422,7 +422,7 @@ function formatFiat(cents: number): string {
<div class="flex justify-between text-xl lg:text-[1.8rem] font-bold">
<span class="text-success">Cash received</span>
<span class="text-success"
>{{ atmStore.fiatSymbol }}{{ formatFiat(context.fiatAmount) }}</span
>{{ atmStore.fiatSymbol }}{{ formatFiat(context.fiatCents) }}</span
>
</div>
</div>