feat(cassettes): record operations from the dashboard instead of counts
The cassettes tab no longer has editable count fields, because there is no longer an endpoint that would accept them. The bays render read-only from the machine's own report, and a Record-operation dialog captures what the operator did: a refill in notes added, an empty, a recount, a denomination change. This removes the failure the tab used to invite. A form loaded before a dispense held a count that was already wrong, and publishing it overwrote the dispense with no error on either side. Recording a delta instead means a dispense that happened while the dialog was open is kept rather than discarded, and a recount is now an explicit act — what an operator opening a bay and counting actually does — rather than being indistinguishable from a stale form. A recent-operations list shows each one as Applied or Pending from acked_at, which is the machine echoing the id back. Pending needs no retry button: every publish carries the recent window, so an operation that missed its own publish keeps being re-offered until it lands, and saying so in the panel is more useful than a button that would do nothing new. The counts-uncertain banner tells the operator when the machine cannot vouch for its own numbers and asks for the recount that clears it. The machine row is re-read on every cassette refresh, since that flag is set by the consumer while the dialog is open.
This commit is contained in:
parent
c76a1bb125
commit
79a4f83293
2 changed files with 275 additions and 148 deletions
|
|
@ -1151,23 +1151,22 @@
|
|||
<div class="col">
|
||||
<h6 class="q-my-none">Cassettes</h6>
|
||||
<p class="text-caption q-my-none" :style="{opacity: 0.7}">
|
||||
Per-cassette count and physical bay position. Denomination
|
||||
set is hardware-determined (re-provision via atm-tui to
|
||||
change). "Publish to ATM" encrypts + signs + sends the new
|
||||
config to the machine via Nostr.
|
||||
The machine owns these counts — it holds the notes. You
|
||||
record what you <i>did</i> to a bay and it keeps the
|
||||
running total. Bay count and denomination set are
|
||||
hardware-determined (re-provision via atm-tui to change
|
||||
the bays themselves).
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<q-btn flat dense icon="undo" label="Revert"
|
||||
:disable="!machineDetail.cassettesDirty"
|
||||
@click="revertCassetteEdits">
|
||||
<q-tooltip>Discard unsaved edits</q-tooltip>
|
||||
<q-btn flat dense icon="refresh" label="Refresh"
|
||||
:loading="machineDetail.cassettesLoading"
|
||||
@click="loadMachineCassettes">
|
||||
<q-tooltip>Re-read the machine's latest report</q-tooltip>
|
||||
</q-btn>
|
||||
<q-btn color="primary" icon="cloud_upload"
|
||||
label="Publish to ATM"
|
||||
:disable="!machineDetail.cassettesDirty"
|
||||
:loading="machineDetail.cassettesPublishing"
|
||||
@click="openCassettePublishConfirm"></q-btn>
|
||||
<q-btn color="primary" icon="add" label="Record operation"
|
||||
:disable="!machineDetail.cassettes.length"
|
||||
@click="openCassetteOpDialog()"></q-btn>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -1179,64 +1178,108 @@
|
|||
<span v-text="machineDetail.cassettesError"></span>
|
||||
</q-banner>
|
||||
|
||||
<q-banner v-if="!machineDetail.cassetteEdits.length
|
||||
<q-banner v-if="machineDetail.machine
|
||||
&& machineDetail.machine.counts_uncertain_since"
|
||||
class="bg-orange-1 text-grey-9 q-mb-md">
|
||||
<template v-slot:avatar>
|
||||
<q-icon name="help_outline" color="warning"></q-icon>
|
||||
</template>
|
||||
<b>The machine can't vouch for these counts.</b>
|
||||
A dispense ended without a reliable count of what left the bay
|
||||
(<span v-text="formatTime(machineDetail.machine.counts_uncertain_since)"></span>).
|
||||
Open the bay, count it, and record a <b>Recount</b> — the
|
||||
machine clears this on its own once you do.
|
||||
</q-banner>
|
||||
|
||||
<q-banner v-if="!machineDetail.cassettes.length
|
||||
&& !machineDetail.cassettesLoading"
|
||||
class="bg-blue-1 text-grey-9">
|
||||
<template v-slot:avatar>
|
||||
<q-icon name="hourglass_empty" color="blue"></q-icon>
|
||||
</template>
|
||||
Waiting for the ATM's bootstrap state event. Power on the ATM
|
||||
Waiting for the ATM's state event. Power on the ATM
|
||||
and confirm it has reached the configured relay; cassette
|
||||
rows will auto-populate on receipt.
|
||||
</q-banner>
|
||||
|
||||
<q-table v-if="machineDetail.cassetteEdits.length"
|
||||
<q-table v-if="machineDetail.cassettes.length"
|
||||
dense flat
|
||||
:rows="machineDetail.cassetteEdits"
|
||||
:rows="machineDetail.cassettes"
|
||||
row-key="position"
|
||||
:columns="cassettesTable.columns"
|
||||
:pagination="cassettesTable.pagination"
|
||||
hide-pagination>
|
||||
<template v-slot:body="props">
|
||||
<q-tr :props="props"
|
||||
:style="props.row._dirty
|
||||
? {boxShadow: 'inset 4px 0 0 0 #fdd835'}
|
||||
: {}">
|
||||
<q-tr :props="props">
|
||||
<q-td key="position" class="text-right">
|
||||
<b v-text="'Bay ' + props.row.position"></b>
|
||||
</q-td>
|
||||
<q-td key="denomination" class="text-right">
|
||||
<q-input v-model.number="props.row.denomination"
|
||||
type="number" min="1" step="1" dense outlined
|
||||
:suffix="machineDetail.machine.fiat_code || ''"
|
||||
:style="{width: '140px', display: 'inline-block'}"
|
||||
@update:model-value="markCassetteDirty(props.row)"></q-input>
|
||||
<span v-text="props.row.denomination"></span>
|
||||
<span :style="{opacity: 0.6}"
|
||||
v-text="' ' + (machineDetail.machine.fiat_code || '')"></span>
|
||||
</q-td>
|
||||
<q-td key="count" class="text-right">
|
||||
<q-input v-model.number="props.row.count" type="number"
|
||||
min="0" step="1" dense outlined
|
||||
:style="{width: '120px', display: 'inline-block'}"
|
||||
@update:model-value="markCassetteDirty(props.row)"></q-input>
|
||||
<b v-text="props.row.count"></b>
|
||||
<span :style="{opacity: 0.6}"> notes</span>
|
||||
</q-td>
|
||||
<q-td key="state" class="text-right">
|
||||
<span v-if="props.row.state_denomination !== null"
|
||||
:style="{fontSize: '0.85em', opacity: 0.7}">
|
||||
<span v-text="props.row.state_denomination"></span>
|
||||
<span :style="{opacity: 0.6}"
|
||||
v-text="' ' + (machineDetail.machine.fiat_code || '')"></span>
|
||||
<span :style="{opacity: 0.6}"> · </span>
|
||||
<span v-text="'×' + props.row.state_count"></span>
|
||||
</span>
|
||||
<span v-else :style="{opacity: 0.4}">—</span>
|
||||
</q-td>
|
||||
<q-td key="updated_at">
|
||||
<q-td key="state_at">
|
||||
<span :style="{fontSize: '0.85em', opacity: 0.7}"
|
||||
v-text="formatTime(props.row.updated_at)"></span>
|
||||
v-text="props.row.state_at
|
||||
? formatTime(props.row.state_at)
|
||||
: 'never'"></span>
|
||||
</q-td>
|
||||
<q-td key="actions" class="text-right">
|
||||
<q-btn flat dense size="sm" icon="edit_note"
|
||||
@click="openCassetteOpDialog(props.row.position)">
|
||||
<q-tooltip>Record an operation on this bay</q-tooltip>
|
||||
</q-btn>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</q-table>
|
||||
|
||||
<div v-if="machineDetail.cassettes.length" class="q-mt-lg">
|
||||
<div class="text-subtitle2 q-mb-xs">Recent operations</div>
|
||||
<p class="text-caption q-mt-none q-mb-sm" :style="{opacity: 0.7}">
|
||||
"Pending" means sent but not yet echoed back by the machine.
|
||||
Every publish carries the recent window, so a pending
|
||||
operation keeps being re-offered until it lands — there is
|
||||
nothing to retry by hand.
|
||||
</p>
|
||||
<q-banner v-if="!machineDetail.cassetteOps.length"
|
||||
class="bg-grey-3 text-grey-9">
|
||||
No operations recorded yet.
|
||||
</q-banner>
|
||||
<q-list v-else dense bordered separator>
|
||||
<q-item v-for="op in machineDetail.cassetteOps" :key="op.id">
|
||||
<q-item-section avatar>
|
||||
<q-icon :name="cassetteOpIcon(op.op_type)"
|
||||
:color="op.acked_at ? 'positive' : 'grey'"></q-icon>
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
<q-item-label v-text="cassetteOpSummary(op)"></q-item-label>
|
||||
<q-item-label caption
|
||||
v-text="formatTime(op.created_at)"></q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section side>
|
||||
<q-chip dense size="sm"
|
||||
:color="op.acked_at ? 'green-1' : 'orange-1'"
|
||||
text-color="grey-9"
|
||||
:label="op.acked_at ? 'Applied' : 'Pending'">
|
||||
<q-tooltip v-if="op.acked_at">
|
||||
Machine confirmed at
|
||||
<span v-text="formatTime(op.acked_at)"></span>
|
||||
</q-tooltip>
|
||||
<q-tooltip v-else>
|
||||
Sent; waiting for the machine to echo this id back
|
||||
</q-tooltip>
|
||||
</q-chip>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</div>
|
||||
|
||||
</q-tab-panel>
|
||||
</q-tab-panels>
|
||||
</q-card-section>
|
||||
|
|
@ -1244,53 +1287,82 @@
|
|||
</q-dialog>
|
||||
|
||||
<!-- =============================================================== -->
|
||||
<!-- CASSETTE PUBLISH CONFIRM DIALOG -->
|
||||
<!-- RECORD CASSETTE OPERATION DIALOG -->
|
||||
<!-- =============================================================== -->
|
||||
<q-dialog v-model="cassettePublishConfirm.show" persistent>
|
||||
<q-dialog v-model="cassetteOpDialog.show" persistent>
|
||||
<q-card :style="{width: '480px', maxWidth: '95vw'}">
|
||||
<q-card-section class="row items-center q-pb-none">
|
||||
<div class="text-h6">Publish cassette config to ATM</div>
|
||||
<div class="text-h6">Record cassette operation</div>
|
||||
<q-space ></q-space>
|
||||
<q-btn icon="close" flat round dense v-close-popup></q-btn>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-banner class="bg-orange-1 text-grey-9 q-mb-md">
|
||||
<q-banner class="bg-blue-1 text-grey-9 q-mb-md">
|
||||
<template v-slot:avatar>
|
||||
<q-icon name="warning" color="warning"></q-icon>
|
||||
<q-icon name="info" color="blue"></q-icon>
|
||||
</template>
|
||||
<b>This publish will overwrite the ATM's currently-tracked
|
||||
counts.</b> If the ATM has dispensed cash since your last
|
||||
refill or count baseline, those decrements will be lost.
|
||||
Publish only after a physical refill (a known total), not to
|
||||
"tweak" counts mid-day. v2 reconciliation will replace this
|
||||
modal with reconciled state display.
|
||||
Record what you did to the bay. The machine applies it to the
|
||||
count it already holds, so a dispense that happened while this
|
||||
dialog was open is kept, not overwritten.
|
||||
</q-banner>
|
||||
|
||||
<q-select v-model.number="cassetteOpDialog.position"
|
||||
:options="cassetteBayOptions"
|
||||
emit-value map-options
|
||||
label="Bay" dense outlined
|
||||
class="q-mb-md"></q-select>
|
||||
|
||||
<q-select v-model="cassetteOpDialog.op_type"
|
||||
:options="cassetteOpTypeOptions"
|
||||
emit-value map-options
|
||||
label="Operation" dense outlined
|
||||
class="q-mb-md"
|
||||
@update:model-value="resetCassetteOpValue"></q-select>
|
||||
|
||||
<q-input v-if="cassetteOpDialog.op_type === 'refill'"
|
||||
v-model.number="cassetteOpDialog.bills"
|
||||
type="number" min="1" step="1" dense outlined
|
||||
label="Notes added"
|
||||
hint="How many notes you put IN — a delta, not a total."
|
||||
></q-input>
|
||||
|
||||
<q-input v-if="cassetteOpDialog.op_type === 'recount'"
|
||||
v-model.number="cassetteOpDialog.count"
|
||||
type="number" min="0" step="1" dense outlined
|
||||
label="Notes counted"
|
||||
hint="What you physically counted in the bay, right now."
|
||||
></q-input>
|
||||
|
||||
<q-input v-if="cassetteOpDialog.op_type === 'set_denomination'"
|
||||
v-model.number="cassetteOpDialog.denomination"
|
||||
type="number" min="1" step="1" dense outlined
|
||||
label="Denomination"
|
||||
:suffix="machineDetail.machine
|
||||
? (machineDetail.machine.fiat_code || '') : ''"
|
||||
hint="What is now loaded in that bay. The machine can't
|
||||
know this — only you can."
|
||||
></q-input>
|
||||
|
||||
<q-banner v-if="cassetteOpDialog.op_type === 'empty'"
|
||||
class="bg-grey-3 text-grey-9">
|
||||
The bay is now empty. Nothing else to enter.
|
||||
</q-banner>
|
||||
|
||||
<q-banner v-if="cassetteOpDialog.error"
|
||||
class="bg-red-1 text-grey-9 q-mt-md">
|
||||
<template v-slot:avatar>
|
||||
<q-icon name="warning" color="negative"></q-icon>
|
||||
</template>
|
||||
<span v-text="cassetteOpDialog.error"></span>
|
||||
</q-banner>
|
||||
<p class="q-mb-sm">Sending to ATM:</p>
|
||||
<q-list dense bordered>
|
||||
<q-item v-for="row in machineDetail.cassetteEdits"
|
||||
:key="row.position">
|
||||
<q-item-section>
|
||||
<q-item-label>
|
||||
<b v-text="'Bay ' + row.position"></b>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section side>
|
||||
<q-item-label caption>
|
||||
<b v-text="row.denomination + ' ' +
|
||||
(machineDetail.machine.fiat_code || '')"></b>
|
||||
· count
|
||||
<b v-text="row.count"></b>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-card-section>
|
||||
<q-card-actions align="right">
|
||||
<q-btn flat label="Cancel" v-close-popup></q-btn>
|
||||
<q-btn color="primary"
|
||||
label="Publish to ATM"
|
||||
:loading="machineDetail.cassettesPublishing"
|
||||
@click="submitCassettePublish"></q-btn>
|
||||
label="Record + publish"
|
||||
:disable="!cassetteOpIsComplete"
|
||||
:loading="cassetteOpDialog.saving"
|
||||
@click="submitCassetteOp"></q-btn>
|
||||
</q-card-actions>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue