refactor: destruct recycler object
This commit is contained in:
parent
de80cd8e24
commit
104f9061f9
1 changed files with 3 additions and 5 deletions
|
|
@ -236,19 +236,17 @@ function plugins (settings, deviceId) {
|
|||
if (!cashOutConfig.active) return Promise.resolve()
|
||||
|
||||
return Promise.all([dbm.recyclerCounts(deviceId), cashOutHelper.redeemableTxs(deviceId, excludeTxId)])
|
||||
.then(([_recyclers, _redeemableTxs]) => {
|
||||
.then(([{ counts, numberOfRecyclers }, _redeemableTxs]) => {
|
||||
const redeemableTxs = _.reject(_.matchesProperty('id', excludeTxId), _redeemableTxs)
|
||||
|
||||
const denominations = []
|
||||
|
||||
_.forEach(it => {
|
||||
denominations.push(cashOutConfig[`recycler${it + 1}`])
|
||||
}, _.times(_.identity(), _recyclers.numberOfRecyclers))
|
||||
}, _.times(_.identity(), numberOfRecyclers))
|
||||
|
||||
const virtualRecyclers = denominations.length ? [Math.max(..._.flatten(denominations)) * 2] : []
|
||||
|
||||
const counts = _recyclers.counts
|
||||
|
||||
if (counts.length !== denominations.length) {
|
||||
throw new Error('Denominations and respective counts do not match!')
|
||||
}
|
||||
|
|
@ -261,7 +259,7 @@ function plugins (settings, deviceId) {
|
|||
denomination: parseInt(denominations[it], 10),
|
||||
count: parseInt(counts[it], 10)
|
||||
})
|
||||
}, _.times(_.identity(), _recyclers.numberOfRecyclers))
|
||||
}, _.times(_.identity(), numberOfRecyclers))
|
||||
|
||||
try {
|
||||
return {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue