diff --git a/lib/cash-in/cash-in-atomic.js b/lib/cash-in/cash-in-atomic.js index 56a810ad..7c87bdc7 100644 --- a/lib/cash-in/cash-in-atomic.js +++ b/lib/cash-in/cash-in-atomic.js @@ -41,13 +41,24 @@ function insertNewBills (t, billRows, machineTx) { if (_.isEmpty(bills)) return Promise.resolve([]) const dbBills = _.map(cashInLow.massage, bills) + const getBillsByDestination = destination => _.filter(it => it.destination_unit === destination)(dbBills) + const columns = ['id', 'fiat', 'fiat_code', 'crypto_code', 'cash_in_fee', 'cash_in_txs_id', 'device_time', 'destination_unit'] const sql = pgp.helpers.insert(dbBills, columns, 'bills') const deviceID = machineTx.deviceId - const sql2 = `update devices set cashbox = cashbox + $2 + const sql2 = `update devices set cashbox = cashbox + $2, stacker1f = stacker1f + $3, stacker1r = stacker1r + $4, stacker2f = stacker2f + $5, stacker2r = stacker2r + $6, stacker3f = stacker3f + $7, stacker3r = stacker3r + $8 where device_id = $1` - return t.none(sql2, [deviceID, dbBills.length]) + return t.none(sql2, [ + deviceID, + getBillsByDestination('cashbox').length, + getBillsByDestination('stacker1f').length, + getBillsByDestination('stacker1r').length, + getBillsByDestination('stacker2f').length, + getBillsByDestination('stacker2r').length, + getBillsByDestination('stacker3f').length, + getBillsByDestination('stacker3r').length + ]) .then(() => { return t.none(sql) }) diff --git a/lib/graphql/resolvers.js b/lib/graphql/resolvers.js index d9e20e4b..984e090b 100644 --- a/lib/graphql/resolvers.js +++ b/lib/graphql/resolvers.js @@ -229,25 +229,22 @@ const dynamicConfig = ({ deviceId, operatorId, pid, pq, settings, }) => { const configs = (parent, { currentConfigVersion }, { deviceId, deviceName, operatorId, pid, settings }, info) => plugins(settings, deviceId) .pollQueries() - .then(pq => { - console.log(pq) - return { - static: staticConfig({ - currentConfigVersion, - deviceId, - deviceName, - pq, - settings, - }), - dynamic: dynamicConfig({ - deviceId, - operatorId, - pid, - pq, - settings, - }), - } - }) + .then(pq => ({ + static: staticConfig({ + currentConfigVersion, + deviceId, + deviceName, + pq, + settings, + }), + dynamic: dynamicConfig({ + deviceId, + operatorId, + pid, + pq, + settings, + }), + })) const massageTerms = terms => (terms.active && terms.text) ? ({ diff --git a/new-lamassu-admin/src/pages/Maintenance/Wizard/Wizard.js b/new-lamassu-admin/src/pages/Maintenance/Wizard/Wizard.js index f1ae5143..2c26fda4 100644 --- a/new-lamassu-admin/src/pages/Maintenance/Wizard/Wizard.js +++ b/new-lamassu-admin/src/pages/Maintenance/Wizard/Wizard.js @@ -156,7 +156,7 @@ const Wizard = ({ machine, cashoutSettings, locale, onClose, save, error }) => { ]) ) - const makeInitialValues = () => + const makeCassettesInitialValues = () => !R.isEmpty(cashoutSettings) ? R.reduce( (acc, value) => { @@ -168,6 +168,22 @@ const Wizard = ({ machine, cashoutSettings, locale, onClose, save, error }) => { ) : {} + const makeStackersInitialValues = () => + !R.isEmpty(cashoutSettings) + ? R.reduce( + (acc, value) => { + acc[`stacker${value}f`] = '' + acc[`stacker${value}r`] = '' + return acc + }, + {}, + R.range(1, numberOfStackers + 1) + ) + : {} + + const makeInitialValues = () => + R.merge(makeCassettesInitialValues(), makeStackersInitialValues()) + const steps = R.pipe( R.concat(makeStackerSteps(numberOfStackers)), R.concat(makeCassetteSteps(numberOfCassettes)),