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

@ -167,13 +167,25 @@ const dynamicConfig = ({ deviceId, operatorId, pid, pq, settings, }) => {
)(cassettes) :
null
const massageStackers = stackers =>
stackers ?
_.flow(
stackers => _.set('physical', _.get('stackers', stackers), stackers),
stackers => _.set('virtual', _.get('virtualStackers', stackers), stackers),
_.unset('stackers'),
_.unset('virtualStackers')
)(stackers) :
null
state.pids = _.update(operatorId, _.set(deviceId, { pid, ts: Date.now() }), state.pids)
return _.flow(
_.pick(['areThereAvailablePromoCodes', 'balances', 'cassettes', 'coins', 'rates']),
_.pick(['areThereAvailablePromoCodes', 'balances', 'cassettes', 'stackers', 'coins', 'rates']),
_.update('cassettes', massageCassettes),
_.update('stackers', massageStackers),
/* [{ cryptoCode, rates }, ...] => [[cryptoCode, rates], ...] */
_.update('coins', _.map(({ cryptoCode, rates }) => [cryptoCode, rates])),
@ -185,9 +197,10 @@ const dynamicConfig = ({ deviceId, operatorId, pid, pq, settings, }) => {
/* Group the separate objects by cryptoCode */
/* { balances, coins, rates } => { cryptoCode: { balance, ask, bid, cashIn, cashOut }, ... } */
({ areThereAvailablePromoCodes, balances, cassettes, coins, rates }) => ({
({ areThereAvailablePromoCodes, balances, cassettes, stackers, coins, rates }) => ({
areThereAvailablePromoCodes,
cassettes,
stackers,
coins: _.flow(
_.reduce(
(ret, [cryptoCode, obj]) => _.update(cryptoCode, _.assign(obj), ret),
@ -216,22 +229,25 @@ const dynamicConfig = ({ deviceId, operatorId, pid, pq, settings, }) => {
const configs = (parent, { currentConfigVersion }, { deviceId, deviceName, operatorId, pid, settings }, info) =>
plugins(settings, deviceId)
.pollQueries()
.then(pq => ({
static: staticConfig({
currentConfigVersion,
deviceId,
deviceName,
pq,
settings,
}),
dynamic: dynamicConfig({
deviceId,
operatorId,
pid,
pq,
settings,
}),
}))
.then(pq => {
console.log(pq)
return {
static: staticConfig({
currentConfigVersion,
deviceId,
deviceName,
pq,
settings,
}),
dynamic: dynamicConfig({
deviceId,
operatorId,
pid,
pq,
settings,
}),
}
})
const massageTerms = terms => (terms.active && terms.text) ? ({