fix: code review changes

This commit is contained in:
Rafael Taranto 2023-10-16 16:58:47 +01:00
parent e58acdb8be
commit 1e1bfe58a4
3 changed files with 10 additions and 10 deletions

View file

@ -45,7 +45,7 @@ function insertNewBills (t, billRows, machineTx) {
// bills before 8.6 don't have destination_unit
const dbBills = _.map(_.defaults({ destination_unit: 'cashbox'}))(_dbBills)
const getBillsByDestination = destination => _.filter(it => it.destination_unit === destination)(dbBills)
const billsByDestination = _.countBy(_.get(['distination_unit']) ,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')
@ -55,12 +55,12 @@ function insertNewBills (t, billRows, machineTx) {
return t.none(sql2, [
deviceID,
getBillsByDestination('recycler1').length,
getBillsByDestination('recycler2').length,
getBillsByDestination('recycler3').length,
getBillsByDestination('recycler4').length,
getBillsByDestination('recycler5').length,
getBillsByDestination('recycler6').length
_.defaultTo(0, billsByDestination.recycler1),
_.defaultTo(0, billsByDestination.recycler2),
_.defaultTo(0, billsByDestination.recycler3),
_.defaultTo(0, billsByDestination.recycler4),
_.defaultTo(0, billsByDestination.recycler5),
_.defaultTo(0, billsByDestination.recycler6)
])
.then(() => {
return t.none(sql)

View file

@ -127,7 +127,7 @@ const getCashUnitFieldName = (step, numberOfCassettes, numberOfRecyclers) => {
category: 'cassette'
}
const recyclerStepsStart = CASHBOX_STEP + numberOfCassettes + 1
if (step < recyclerStepsStart + numberOfRecyclers * 2)
if (step < recyclerStepsStart + numberOfRecyclers)
return {
name: `recycler${Math.ceil(step - recyclerStepsStart + 1)}`,
category: 'recycler'

View file

@ -185,7 +185,7 @@ const FiatBalance = ({ section, min = 0, max = 100, fieldWidth = 80 }) => {
percent={
values[
`fillingPercentageRecycler${(it + 1) * 2 - 1}`
] ?? data[`recycler${(it + 1) * 2 - 1}f`]
] ?? data[`recycler${(it + 1) * 2 - 1}`]
}
applyColorVariant
applyFiatBalanceAlertsStyling
@ -237,7 +237,7 @@ const FiatBalance = ({ section, min = 0, max = 100, fieldWidth = 80 }) => {
</div>
</>
],
R.times(R.identity, maxNumberOfRecyclers)
R.times(R.identity, maxNumberOfRecyclers / 2)
)}
</div>
</Form>