feat: assign unit destination during cash-in
fix: cash cassettes wizard initial values
This commit is contained in:
parent
2967ad3a75
commit
2d010fc359
3 changed files with 46 additions and 22 deletions
|
|
@ -41,13 +41,24 @@ function insertNewBills (t, billRows, machineTx) {
|
||||||
if (_.isEmpty(bills)) return Promise.resolve([])
|
if (_.isEmpty(bills)) return Promise.resolve([])
|
||||||
|
|
||||||
const dbBills = _.map(cashInLow.massage, bills)
|
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 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 sql = pgp.helpers.insert(dbBills, columns, 'bills')
|
||||||
const deviceID = machineTx.deviceId
|
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`
|
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(() => {
|
.then(() => {
|
||||||
return t.none(sql)
|
return t.none(sql)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -229,9 +229,7 @@ const dynamicConfig = ({ deviceId, operatorId, pid, pq, settings, }) => {
|
||||||
const configs = (parent, { currentConfigVersion }, { deviceId, deviceName, operatorId, pid, settings }, info) =>
|
const configs = (parent, { currentConfigVersion }, { deviceId, deviceName, operatorId, pid, settings }, info) =>
|
||||||
plugins(settings, deviceId)
|
plugins(settings, deviceId)
|
||||||
.pollQueries()
|
.pollQueries()
|
||||||
.then(pq => {
|
.then(pq => ({
|
||||||
console.log(pq)
|
|
||||||
return {
|
|
||||||
static: staticConfig({
|
static: staticConfig({
|
||||||
currentConfigVersion,
|
currentConfigVersion,
|
||||||
deviceId,
|
deviceId,
|
||||||
|
|
@ -246,8 +244,7 @@ const configs = (parent, { currentConfigVersion }, { deviceId, deviceName, opera
|
||||||
pq,
|
pq,
|
||||||
settings,
|
settings,
|
||||||
}),
|
}),
|
||||||
}
|
}))
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
const massageTerms = terms => (terms.active && terms.text) ? ({
|
const massageTerms = terms => (terms.active && terms.text) ? ({
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ const Wizard = ({ machine, cashoutSettings, locale, onClose, save, error }) => {
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
|
||||||
const makeInitialValues = () =>
|
const makeCassettesInitialValues = () =>
|
||||||
!R.isEmpty(cashoutSettings)
|
!R.isEmpty(cashoutSettings)
|
||||||
? R.reduce(
|
? R.reduce(
|
||||||
(acc, value) => {
|
(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(
|
const steps = R.pipe(
|
||||||
R.concat(makeStackerSteps(numberOfStackers)),
|
R.concat(makeStackerSteps(numberOfStackers)),
|
||||||
R.concat(makeCassetteSteps(numberOfCassettes)),
|
R.concat(makeCassetteSteps(numberOfCassettes)),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue