feat: add cash_level to availability broadcast
Publish cash level (none/low/good/full) in the Kind 30078 event based on total bill count across all cassettes. Enables monitoring dashboards to show cash availability without revealing exact amounts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
018ef3c60a
commit
b0ec3ab7b3
1 changed files with 10 additions and 0 deletions
|
|
@ -48,10 +48,20 @@ export function useAvailabilityBroadcast(options: UseAvailabilityBroadcastOption
|
||||||
return { cashIn, cashOut }
|
return { cashIn, cashOut }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Cash level: none / low / good / full based on total bills */
|
||||||
|
function cashLevel(): string {
|
||||||
|
const totalBills = Object.values(inventory.value).reduce((s, c) => s + c, 0)
|
||||||
|
if (totalBills === 0) return 'none'
|
||||||
|
if (totalBills < 20) return 'low'
|
||||||
|
if (totalBills < 80) return 'good'
|
||||||
|
return 'full'
|
||||||
|
}
|
||||||
|
|
||||||
async function publish(avail: ATMAvailability) {
|
async function publish(avail: ATMAvailability) {
|
||||||
const content = JSON.stringify({
|
const content = JSON.stringify({
|
||||||
cash_in: avail.cashIn,
|
cash_in: avail.cashIn,
|
||||||
cash_out: avail.cashOut,
|
cash_out: avail.cashOut,
|
||||||
|
cash_level: cashLevel(),
|
||||||
fiat: fiatCode,
|
fiat: fiatCode,
|
||||||
model,
|
model,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue