diff --git a/apps/machine/src/views/CashInView.vue b/apps/machine/src/views/CashInView.vue index 48c6d02..d907f15 100644 --- a/apps/machine/src/views/CashInView.vue +++ b/apps/machine/src/views/CashInView.vue @@ -114,6 +114,23 @@ function skipReceipt() { atmStore.skipReceipt() } +// Check if a bill denomination can still be accepted without exceeding available balance +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 grossSats = Math.floor((newFiatCents / 100) * ctx.exchangeRate) + const fee = Math.floor(grossSats * ctx.feePercent) + return grossSats - fee <= ctx.availableBalance +} + +const balanceLimitReached = computed(() => { + if (!context.value || context.value.availableBalance <= 0) return false + // Check if even the smallest denomination ($1) would exceed + return !canAcceptBill(1) +}) + // Simulate bill insertion (for development) function simulateBill(denomination: number) { atmStore.insertBill(denomination) @@ -210,10 +227,26 @@ const isProcessing = computed(() => atmStore.isPayingInvoice || atmStore.isReque + +
Insert bills into the acceptor
++ Maximum amount reached — press Done to continue +
+Insert bills into the acceptor
+