fix: bills and machine data fetching for machine profile page
This commit is contained in:
parent
e55ebd5d84
commit
266eb44076
5 changed files with 32 additions and 16 deletions
|
|
@ -20,7 +20,7 @@ const getBills = filters => {
|
|||
SELECT id, device_id FROM cash_in_txs ${deviceStatement}
|
||||
) AS cit ON cit.id = b.cash_in_txs_id ${batchStatement(filters.batch)} ${_.isNil(batchStatement(filters.batch)) ? `WHERE` : `AND`} b.destination_unit = 'cashbox'`
|
||||
|
||||
const sql2 = `SELECT b.id, b.fiat, b.fiat_code, b.created, b.cashbox_batch_id, b.device_id FROM empty_unit_bills b ${deviceStatement} ${!_.isNil(filters.deviceId) && !_.isNil(filters.batch) ? `AND` : ``} ${batchStatement(filters.batch)}`
|
||||
const sql2 = `SELECT b.id, b.fiat, b.fiat_code, b.created, b.cashbox_batch_id, b.device_id FROM empty_unit_bills b ${deviceStatement} ${!_.isNil(filters.deviceId) && !_.isNil(filters.batch) ? `AND ${_.replace('WHERE', '', batchStatement(filters.batch))}` : `${batchStatement(filters.batch)}`}`
|
||||
|
||||
return Promise.all([db.any(sql), db.any(sql2)])
|
||||
.then(([bills, operationalBills]) => _.map(_.mapKeys(_.camelCase), _.concat(bills, operationalBills)))
|
||||
|
|
|
|||
|
|
@ -65,20 +65,19 @@ const CashCassettes = ({ machine, config, refetchData, bills }) => {
|
|||
refetchQueries: () => refetchData()
|
||||
})
|
||||
|
||||
const onSave = (_, cashbox, cassettes) =>
|
||||
const onSave = (_, cashUnits) =>
|
||||
setCassetteBills({
|
||||
variables: {
|
||||
action: 'setCassetteBills',
|
||||
deviceId: machine.deviceId,
|
||||
cashbox,
|
||||
...cassettes
|
||||
cashUnits
|
||||
}
|
||||
})
|
||||
|
||||
const InnerCashUnitDetails = ({ it }) => (
|
||||
<CashUnitDetails
|
||||
machine={it}
|
||||
bills={bills[it.id] ?? []}
|
||||
bills={bills[it.deviceId] ?? []}
|
||||
currency={fiatCurrency}
|
||||
config={config}
|
||||
hideMachineData
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ const Machines = ({ data, refetch, reload }) => {
|
|||
|
||||
const machine = R.path(['machine'])(data) ?? {}
|
||||
const config = R.path(['config'])(data) ?? {}
|
||||
const bills = R.path(['bills'])(data) ?? []
|
||||
const bills = R.groupBy(bill => bill.deviceId)(R.path(['bills'])(data) ?? [])
|
||||
|
||||
const machineName = R.path(['name'])(machine) ?? null
|
||||
const machineID = R.path(['deviceId'])(machine) ?? null
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ const styles = {
|
|||
billList: ({ hideMachineData }) => ({
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
minWidth: hideMachineData ? 80 : 160,
|
||||
minWidth: hideMachineData ? 60 : 160,
|
||||
'& > span': {
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
|
|
@ -126,7 +126,11 @@ const CashUnitDetails = ({
|
|||
height={40}
|
||||
currency={{ code: currency }}
|
||||
notes={machine.cashUnits[`cassette${it}`]}
|
||||
denomination={getCashoutSettings(machine.id)[`cassette${it}`]}
|
||||
denomination={
|
||||
getCashoutSettings(machine.id ?? machine.deviceId)[
|
||||
`cassette${it}`
|
||||
]
|
||||
}
|
||||
threshold={
|
||||
fillingPercentageSettings[`fillingPercentageCassette${it}`]
|
||||
}
|
||||
|
|
@ -152,7 +156,9 @@ const CashUnitDetails = ({
|
|||
currency={{ code: currency }}
|
||||
notes={machine.cashUnits[`cassette${it}`]}
|
||||
denomination={
|
||||
getCashoutSettings(machine.id)[`cassette${it}`]
|
||||
getCashoutSettings(machine.id ?? machine.deviceId)[
|
||||
`cassette${it}`
|
||||
]
|
||||
}
|
||||
threshold={
|
||||
fillingPercentageSettings[
|
||||
|
|
@ -178,7 +184,9 @@ const CashUnitDetails = ({
|
|||
currency={{ code: currency }}
|
||||
notes={machine.cashUnits[`stacker${it}f`]}
|
||||
denomination={
|
||||
getCashoutSettings(machine.id)[`stacker${it}f`]
|
||||
getCashoutSettings(machine.id ?? machine.deviceId)[
|
||||
`stacker${it}f`
|
||||
]
|
||||
}
|
||||
threshold={
|
||||
fillingPercentageSettings[
|
||||
|
|
@ -193,7 +201,9 @@ const CashUnitDetails = ({
|
|||
currency={{ code: currency }}
|
||||
notes={machine.cashUnits[`stacker${it}r`]}
|
||||
denomination={
|
||||
getCashoutSettings(machine.id)[`stacker${it}r`]
|
||||
getCashoutSettings(machine.id ?? machine.deviceId)[
|
||||
`stacker${it}r`
|
||||
]
|
||||
}
|
||||
threshold={
|
||||
fillingPercentageSettings[
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ const getElements = (
|
|||
widths,
|
||||
setMachineId
|
||||
) => {
|
||||
console.log(config)
|
||||
const fillingPercentageSettings = fromNamespace('notifications', config)
|
||||
const locale = fromNamespace('locale')(config)
|
||||
const cashout = fromNamespace('cashOut')(config)
|
||||
|
|
@ -37,7 +38,7 @@ const getElements = (
|
|||
<CashIn
|
||||
currency={{ code: fiatCurrency }}
|
||||
notes={m.cashUnits.cashbox}
|
||||
total={R.sum(R.map(it => it.fiat, bills[m.id] ?? []))}
|
||||
total={R.sum(R.map(it => it.fiat, bills[m.id ?? m.deviceId] ?? []))}
|
||||
width={25}
|
||||
height={45}
|
||||
omitInnerPercentage
|
||||
|
|
@ -61,7 +62,9 @@ const getElements = (
|
|||
width={'100%'}
|
||||
currency={{ code: fiatCurrency }}
|
||||
notes={m.cashUnits[`cassette${it}`]}
|
||||
denomination={getCashoutSettings(m.id)[`cassette${it}`]}
|
||||
denomination={
|
||||
getCashoutSettings(m.id ?? m.deviceId)[`cassette${it}`]
|
||||
}
|
||||
threshold={
|
||||
fillingPercentageSettings[`fillingPercentageCassette${it}`]
|
||||
}
|
||||
|
|
@ -76,7 +79,9 @@ const getElements = (
|
|||
width={'100%'}
|
||||
currency={{ code: fiatCurrency }}
|
||||
notes={m.cashUnits[`stacker${it}f`]}
|
||||
denomination={getCashoutSettings(m.id)[`stacker${it}f`]}
|
||||
denomination={
|
||||
getCashoutSettings(m.id ?? m.deviceId)[`stacker${it}f`]
|
||||
}
|
||||
threshold={
|
||||
fillingPercentageSettings[
|
||||
`fillingPercentageStacker${it}f`
|
||||
|
|
@ -88,7 +93,9 @@ const getElements = (
|
|||
width={'100%'}
|
||||
currency={{ code: fiatCurrency }}
|
||||
notes={m.cashUnits[`stacker${it}r`]}
|
||||
denomination={getCashoutSettings(m.id)[`stacker${it}r`]}
|
||||
denomination={
|
||||
getCashoutSettings(m.id ?? m.deviceId)[`stacker${it}r`]
|
||||
}
|
||||
threshold={
|
||||
fillingPercentageSettings[
|
||||
`fillingPercentageStacker${it}r`
|
||||
|
|
@ -118,7 +125,7 @@ const getElements = (
|
|||
return (
|
||||
<IconButton
|
||||
onClick={() => {
|
||||
!R.isNil(setMachineId) && setMachineId(m.id)
|
||||
!R.isNil(setMachineId) && setMachineId(m.id ?? m.deviceId)
|
||||
setWizard(true)
|
||||
}}>
|
||||
<EditIcon />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue