fix: multiple fixes related with recyclers/stackers

feat: add bill destination unit for cash-in txs
feat: l-m communication regarding cash unit state
This commit is contained in:
Sérgio Salgado 2023-04-20 17:58:50 +01:00
parent 2638bd1717
commit 2967ad3a75
17 changed files with 573 additions and 102 deletions

View file

@ -40,6 +40,21 @@ exports.cassetteCounts = function cassetteCounts (deviceId) {
})
}
exports.stackerCounts = function stackerCounts (deviceId) {
const sql = 'SELECT stacker1f, stacker1r, stacker2f, stacker2r, stacker3f, stacker3r, number_of_stackers FROM devices ' +
'WHERE device_id=$1'
return db.one(sql, [deviceId])
.then(row => {
const counts = []
_.forEach(it => {
counts.push(row[`stacker${it + 1}f`], row[`stacker${it + 1}r`])
}, _.times(_.identity(), row.number_of_stackers))
return { numberOfStackers: row.number_of_stackers, counts }
})
}
// Note: since we only prune on insert, we'll always have
// last known state.
exports.machineEvent = function machineEvent (rec) {