refactor: use destructuring instead of indexing
This commit is contained in:
parent
dd6bb6a8d3
commit
23eadc1717
1 changed files with 2 additions and 4 deletions
|
|
@ -152,11 +152,9 @@ function plugins (settings, deviceId) {
|
||||||
const sumTxs = (sum, tx) => {
|
const sumTxs = (sum, tx) => {
|
||||||
// cash-out-helper sends 0 as fallback value, need to filter it out as there are no '0' denominations
|
// cash-out-helper sends 0 as fallback value, need to filter it out as there are no '0' denominations
|
||||||
const bills = _.filter(it => _.includes('recycler', it.name) && it.denomination > 0, tx.bills)
|
const bills = _.filter(it => _.includes('recycler', it.name) && it.denomination > 0, tx.bills)
|
||||||
const sameDenominations = a => a[0]?.denomination === a[1]?.denomination
|
|
||||||
|
|
||||||
const doDenominationsMatch = _.every(sameDenominations, _.zip(recyclers, bills))
|
const sameDenominations = ([recycler, bill]) => recycler?.denomination === bill?.denomination
|
||||||
|
if (!_.every(sameDenominations, _.zip(recyclers, bills))) {
|
||||||
if (!doDenominationsMatch) {
|
|
||||||
throw new Error('Denominations don\'t add up, recyclers were changed.')
|
throw new Error('Denominations don\'t add up, recyclers were changed.')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue