chore: create defaults for cashUnitCapacity
This commit is contained in:
parent
ce91591af5
commit
9f520afd71
7 changed files with 61 additions and 27 deletions
|
|
@ -14,6 +14,14 @@ const anonymousCustomer = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const CASH_UNIT_CAPACITY = {
|
const CASH_UNIT_CAPACITY = {
|
||||||
|
default: {
|
||||||
|
cashbox: 600,
|
||||||
|
cassette: 500
|
||||||
|
},
|
||||||
|
douro: {
|
||||||
|
cashbox: 600,
|
||||||
|
cassette: 500
|
||||||
|
},
|
||||||
grandola: {
|
grandola: {
|
||||||
cashbox: 2000,
|
cashbox: 2000,
|
||||||
recycler: 2800
|
recycler: 2800
|
||||||
|
|
|
||||||
|
|
@ -737,6 +737,13 @@ function plugins (settings, deviceId) {
|
||||||
return _.map(device => checkDeviceCashBalances(fiatCode, device), devices)
|
return _.map(device => checkDeviceCashBalances(fiatCode, device), devices)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCashUnitCapacity (model, device) {
|
||||||
|
if (!CASH_UNIT_CAPACITY[model]) {
|
||||||
|
return CASH_UNIT_CAPACITY.default[device]
|
||||||
|
}
|
||||||
|
return CASH_UNIT_CAPACITY[model][device]
|
||||||
|
}
|
||||||
|
|
||||||
function checkDeviceCashBalances (fiatCode, device) {
|
function checkDeviceCashBalances (fiatCode, device) {
|
||||||
const cashOutConfig = configManager.getCashOut(device.deviceId, settings.config)
|
const cashOutConfig = configManager.getCashOut(device.deviceId, settings.config)
|
||||||
const denomination1 = cashOutConfig.cassette1
|
const denomination1 = cashOutConfig.cassette1
|
||||||
|
|
@ -768,7 +775,7 @@ function plugins (settings, deviceId) {
|
||||||
}
|
}
|
||||||
: null
|
: null
|
||||||
|
|
||||||
const cassette1Alert = device.numberOfCassettes >= 1 && isUnitLow(device.cashUnits.cassette1, CASH_UNIT_CAPACITY[device.model]['cassette'], notifications.fillingPercentageCassette1)
|
const cassette1Alert = device.numberOfCassettes >= 1 && isUnitLow(device.cashUnits.cassette1, getCashUnitCapacity(device.model, 'cassette'), notifications.fillingPercentageCassette1)
|
||||||
? {
|
? {
|
||||||
code: 'LOW_CASH_OUT',
|
code: 'LOW_CASH_OUT',
|
||||||
cassette: 1,
|
cassette: 1,
|
||||||
|
|
@ -780,7 +787,7 @@ function plugins (settings, deviceId) {
|
||||||
}
|
}
|
||||||
: null
|
: null
|
||||||
|
|
||||||
const cassette2Alert = device.numberOfCassettes >= 2 && isUnitLow(device.cashUnits.cassette2, CASH_UNIT_CAPACITY[device.model]['cassette'], notifications.fillingPercentageCassette2)
|
const cassette2Alert = device.numberOfCassettes >= 2 && isUnitLow(device.cashUnits.cassette2, getCashUnitCapacity(device.model, 'cassette'), notifications.fillingPercentageCassette2)
|
||||||
? {
|
? {
|
||||||
code: 'LOW_CASH_OUT',
|
code: 'LOW_CASH_OUT',
|
||||||
cassette: 2,
|
cassette: 2,
|
||||||
|
|
@ -792,7 +799,7 @@ function plugins (settings, deviceId) {
|
||||||
}
|
}
|
||||||
: null
|
: null
|
||||||
|
|
||||||
const cassette3Alert = device.numberOfCassettes >= 3 && isUnitLow(device.cashUnits.cassette3, CASH_UNIT_CAPACITY[device.model]['cassette'], notifications.fillingPercentageCassette3)
|
const cassette3Alert = device.numberOfCassettes >= 3 && isUnitLow(device.cashUnits.cassette3, getCashUnitCapacity(device.model, 'cassette'), notifications.fillingPercentageCassette3)
|
||||||
? {
|
? {
|
||||||
code: 'LOW_CASH_OUT',
|
code: 'LOW_CASH_OUT',
|
||||||
cassette: 3,
|
cassette: 3,
|
||||||
|
|
@ -804,7 +811,7 @@ function plugins (settings, deviceId) {
|
||||||
}
|
}
|
||||||
: null
|
: null
|
||||||
|
|
||||||
const cassette4Alert = device.numberOfCassettes >= 4 && isUnitLow(device.cashUnits.cassette4, CASH_UNIT_CAPACITY[device.model]['cassette'], notifications.fillingPercentageCassette4)
|
const cassette4Alert = device.numberOfCassettes >= 4 && isUnitLow(device.cashUnits.cassette4, getCashUnitCapacity(device.model, 'cassette'), notifications.fillingPercentageCassette4)
|
||||||
? {
|
? {
|
||||||
code: 'LOW_CASH_OUT',
|
code: 'LOW_CASH_OUT',
|
||||||
cassette: 4,
|
cassette: 4,
|
||||||
|
|
@ -816,7 +823,7 @@ function plugins (settings, deviceId) {
|
||||||
}
|
}
|
||||||
: null
|
: null
|
||||||
|
|
||||||
const stacker1fAlert = device.numberOfStackers >= 1 && isUnitLow(device.cashUnits.stacker1f, CASH_UNIT_CAPACITY[device.model]['stacker'], notifications.fillingPercentageStacker1f)
|
const stacker1fAlert = device.numberOfStackers >= 1 && isUnitLow(device.cashUnits.stacker1f, getCashUnitCapacity(device.model, 'stacker'), notifications.fillingPercentageStacker1f)
|
||||||
? {
|
? {
|
||||||
code: 'LOW_RECYCLER_STACKER',
|
code: 'LOW_RECYCLER_STACKER',
|
||||||
cassette: 4,
|
cassette: 4,
|
||||||
|
|
@ -828,7 +835,7 @@ function plugins (settings, deviceId) {
|
||||||
}
|
}
|
||||||
: null
|
: null
|
||||||
|
|
||||||
const stacker1rAlert = device.numberOfStackers >= 1 && isUnitLow(device.cashUnits.stacker1r, CASH_UNIT_CAPACITY[device.model]['stacker'], notifications.fillingPercentageStacker1r)
|
const stacker1rAlert = device.numberOfStackers >= 1 && isUnitLow(device.cashUnits.stacker1r, getCashUnitCapacity(device.model, 'stacker'), notifications.fillingPercentageStacker1r)
|
||||||
? {
|
? {
|
||||||
code: 'LOW_RECYCLER_STACKER',
|
code: 'LOW_RECYCLER_STACKER',
|
||||||
cassette: 4,
|
cassette: 4,
|
||||||
|
|
@ -840,7 +847,7 @@ function plugins (settings, deviceId) {
|
||||||
}
|
}
|
||||||
: null
|
: null
|
||||||
|
|
||||||
const stacker2fAlert = device.numberOfStackers >= 2 && isUnitLow(device.cashUnits.stacker2f, CASH_UNIT_CAPACITY[device.model]['stacker'], notifications.fillingPercentageStacker2f)
|
const stacker2fAlert = device.numberOfStackers >= 2 && isUnitLow(device.cashUnits.stacker2f, getCashUnitCapacity(device.model, 'stacker'), notifications.fillingPercentageStacker2f)
|
||||||
? {
|
? {
|
||||||
code: 'LOW_RECYCLER_STACKER',
|
code: 'LOW_RECYCLER_STACKER',
|
||||||
cassette: 4,
|
cassette: 4,
|
||||||
|
|
@ -852,7 +859,7 @@ function plugins (settings, deviceId) {
|
||||||
}
|
}
|
||||||
: null
|
: null
|
||||||
|
|
||||||
const stacker2rAlert = device.numberOfStackers >= 2 && isUnitLow(device.cashUnits.stacker2r, CASH_UNIT_CAPACITY[device.model]['stacker'], notifications.fillingPercentageStacker2r)
|
const stacker2rAlert = device.numberOfStackers >= 2 && isUnitLow(device.cashUnits.stacker2r, getCashUnitCapacity(device.model, 'stacker'), notifications.fillingPercentageStacker2r)
|
||||||
? {
|
? {
|
||||||
code: 'LOW_RECYCLER_STACKER',
|
code: 'LOW_RECYCLER_STACKER',
|
||||||
cassette: 4,
|
cassette: 4,
|
||||||
|
|
@ -864,7 +871,7 @@ function plugins (settings, deviceId) {
|
||||||
}
|
}
|
||||||
: null
|
: null
|
||||||
|
|
||||||
const stacker3fAlert = device.numberOfStackers >= 3 && isUnitLow(device.cashUnits.stacker3f, CASH_UNIT_CAPACITY[device.model]['stacker'], notifications.fillingPercentageStacker3f)
|
const stacker3fAlert = device.numberOfStackers >= 3 && isUnitLow(device.cashUnits.stacker3f, getCashUnitCapacity(device.model, 'stacker'), notifications.fillingPercentageStacker3f)
|
||||||
? {
|
? {
|
||||||
code: 'LOW_RECYCLER_STACKER',
|
code: 'LOW_RECYCLER_STACKER',
|
||||||
cassette: 4,
|
cassette: 4,
|
||||||
|
|
@ -876,7 +883,7 @@ function plugins (settings, deviceId) {
|
||||||
}
|
}
|
||||||
: null
|
: null
|
||||||
|
|
||||||
const stacker3rAlert = device.numberOfStackers >= 3 && isUnitLow(device.cashUnits.stacker3r, CASH_UNIT_CAPACITY[device.model]['stacker'], notifications.fillingPercentageStacker3r)
|
const stacker3rAlert = device.numberOfStackers >= 3 && isUnitLow(device.cashUnits.stacker3r, getCashUnitCapacity(device.model, 'stacker'), notifications.fillingPercentageStacker3r)
|
||||||
? {
|
? {
|
||||||
code: 'LOW_RECYCLER_STACKER',
|
code: 'LOW_RECYCLER_STACKER',
|
||||||
cassette: 4,
|
cassette: 4,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import { CashOut } from 'src/components/inputs'
|
||||||
import { Label1, TL2 } from 'src/components/typography'
|
import { Label1, TL2 } from 'src/components/typography'
|
||||||
import { offDarkColor } from 'src/styling/variables'
|
import { offDarkColor } from 'src/styling/variables'
|
||||||
import { fromNamespace } from 'src/utils/config'
|
import { fromNamespace } from 'src/utils/config'
|
||||||
import { cashUnitCapacity, modelPrettifier } from 'src/utils/machine'
|
import { getCashUnitCapacity, modelPrettifier } from 'src/utils/machine'
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
wrapper: {
|
wrapper: {
|
||||||
|
|
@ -134,7 +134,7 @@ const CashUnitDetails = ({
|
||||||
threshold={
|
threshold={
|
||||||
fillingPercentageSettings[`fillingPercentageCassette${it}`]
|
fillingPercentageSettings[`fillingPercentageCassette${it}`]
|
||||||
}
|
}
|
||||||
capacity={cashUnitCapacity[machine.model].cassette}
|
capacity={getCashUnitCapacity(machine.model, 'cassette')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{it !== machine.numberOfCassettes && (
|
{it !== machine.numberOfCassettes && (
|
||||||
|
|
@ -165,7 +165,7 @@ const CashUnitDetails = ({
|
||||||
`fillingPercentageCassette${it}`
|
`fillingPercentageCassette${it}`
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
capacity={cashUnitCapacity[machine.model].cassette}
|
capacity={getCashUnitCapacity(machine.model, 'cassette')}
|
||||||
/>
|
/>
|
||||||
))(R.range(1, machine.numberOfCassettes + 1))}
|
))(R.range(1, machine.numberOfCassettes + 1))}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -193,7 +193,7 @@ const CashUnitDetails = ({
|
||||||
`fillingPercentageStacker${it}f`
|
`fillingPercentageStacker${it}f`
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
capacity={cashUnitCapacity[machine.model].stacker}
|
capacity={getCashUnitCapacity(machine.model, 'stacker')}
|
||||||
/>
|
/>
|
||||||
<CashOut
|
<CashOut
|
||||||
width={60}
|
width={60}
|
||||||
|
|
@ -210,7 +210,7 @@ const CashUnitDetails = ({
|
||||||
`fillingPercentageStacker${it}r`
|
`fillingPercentageStacker${it}r`
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
capacity={cashUnitCapacity[machine.model].stacker}
|
capacity={getCashUnitCapacity(machine.model, 'stacker')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import * as Yup from 'yup'
|
||||||
|
|
||||||
import Modal from 'src/components/Modal'
|
import Modal from 'src/components/Modal'
|
||||||
import { MAX_NUMBER_OF_CASSETTES } from 'src/utils/constants'
|
import { MAX_NUMBER_OF_CASSETTES } from 'src/utils/constants'
|
||||||
import { cashUnitCapacity, modelPrettifier } from 'src/utils/machine'
|
import { getCashUnitCapacity, modelPrettifier } from 'src/utils/machine'
|
||||||
import { defaultToZero } from 'src/utils/number'
|
import { defaultToZero } from 'src/utils/number'
|
||||||
|
|
||||||
import WizardSplash from './WizardSplash'
|
import WizardSplash from './WizardSplash'
|
||||||
|
|
@ -108,10 +108,13 @@ const Wizard = ({ machine, cashoutSettings, locale, onClose, save, error }) => {
|
||||||
.required()
|
.required()
|
||||||
.min(0)
|
.min(0)
|
||||||
.max(
|
.max(
|
||||||
cashUnitCapacity[machine.model].cassette,
|
getCashUnitCapacity(machine.model, 'cassette'),
|
||||||
`${modelPrettifier[machine.model]} maximum cassette capacity is ${
|
`${
|
||||||
cashUnitCapacity[machine.model].cassette
|
modelPrettifier[machine.model]
|
||||||
} bills`
|
} maximum cassette capacity is ${getCashUnitCapacity(
|
||||||
|
machine.model,
|
||||||
|
'cassette'
|
||||||
|
)} bills`
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import tejo4CassetteThree from 'src/styling/icons/cassettes/tejo/4-cassettes/4-c
|
||||||
import tejo4CassetteFour from 'src/styling/icons/cassettes/tejo/4-cassettes/4-cassettes-open-4-left.svg'
|
import tejo4CassetteFour from 'src/styling/icons/cassettes/tejo/4-cassettes/4-cassettes-open-4-left.svg'
|
||||||
import { ReactComponent as TxOutIcon } from 'src/styling/icons/direction/cash-out.svg'
|
import { ReactComponent as TxOutIcon } from 'src/styling/icons/direction/cash-out.svg'
|
||||||
import { comet, errorColor } from 'src/styling/variables'
|
import { comet, errorColor } from 'src/styling/variables'
|
||||||
import { cashUnitCapacity } from 'src/utils/machine'
|
import { getCashUnitCapacity } from 'src/utils/machine'
|
||||||
import { numberToFiatAmount } from 'src/utils/number'
|
import { numberToFiatAmount } from 'src/utils/number'
|
||||||
import { startCase } from 'src/utils/string'
|
import { startCase } from 'src/utils/string'
|
||||||
|
|
||||||
|
|
@ -170,7 +170,8 @@ const WizardStep = ({
|
||||||
const cassetteTotal = values => cassetteCount(values) * cashUnitDenomination
|
const cassetteTotal = values => cassetteCount(values) * cashUnitDenomination
|
||||||
const getPercentage = R.pipe(
|
const getPercentage = R.pipe(
|
||||||
cassetteCount,
|
cassetteCount,
|
||||||
count => 100 * (count / cashUnitCapacity[machine.model][cashUnitCategory]),
|
count =>
|
||||||
|
100 * (count / getCashUnitCapacity(machine.model, cashUnitCategory)),
|
||||||
R.clamp(0, 100)
|
R.clamp(0, 100)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { IconButton } from 'src/components/buttons'
|
||||||
import { CashIn, CashOutLite } from 'src/components/inputs/cashbox/Cashbox'
|
import { CashIn, CashOutLite } from 'src/components/inputs/cashbox/Cashbox'
|
||||||
import { ReactComponent as EditIcon } from 'src/styling/icons/action/edit/enabled.svg'
|
import { ReactComponent as EditIcon } from 'src/styling/icons/action/edit/enabled.svg'
|
||||||
import { fromNamespace } from 'src/utils/config'
|
import { fromNamespace } from 'src/utils/config'
|
||||||
import { cashUnitCapacity } from 'src/utils/machine'
|
import { getCashUnitCapacity } from 'src/utils/machine'
|
||||||
|
|
||||||
const getElements = (
|
const getElements = (
|
||||||
classes,
|
classes,
|
||||||
|
|
@ -68,7 +68,7 @@ const getElements = (
|
||||||
threshold={
|
threshold={
|
||||||
fillingPercentageSettings[`fillingPercentageCassette${it}`]
|
fillingPercentageSettings[`fillingPercentageCassette${it}`]
|
||||||
}
|
}
|
||||||
capacity={cashUnitCapacity[m.model].cassette}
|
capacity={getCashUnitCapacity(m.model, 'cassette')}
|
||||||
/>
|
/>
|
||||||
))(R.range(1, m.numberOfCassettes + 1))}
|
))(R.range(1, m.numberOfCassettes + 1))}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -87,7 +87,7 @@ const getElements = (
|
||||||
`fillingPercentageStacker${it}f`
|
`fillingPercentageStacker${it}f`
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
capacity={cashUnitCapacity[m.model].stacker}
|
capacity={getCashUnitCapacity(m.model, 'stacker')}
|
||||||
/>
|
/>
|
||||||
<CashOutLite
|
<CashOutLite
|
||||||
width={'100%'}
|
width={'100%'}
|
||||||
|
|
@ -101,7 +101,7 @@ const getElements = (
|
||||||
`fillingPercentageStacker${it}r`
|
`fillingPercentageStacker${it}r`
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
capacity={cashUnitCapacity[m.model].stacker}
|
capacity={getCashUnitCapacity(m.model, 'stacker')}
|
||||||
/>
|
/>
|
||||||
{it !== m.numberOfStackers && (
|
{it !== m.numberOfStackers && (
|
||||||
<span className={classes.verticalLine} />
|
<span className={classes.verticalLine} />
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,14 @@ const modelPrettifier = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const cashUnitCapacity = {
|
const cashUnitCapacity = {
|
||||||
|
default: {
|
||||||
|
cashbox: 600,
|
||||||
|
cassette: 500
|
||||||
|
},
|
||||||
|
douro: {
|
||||||
|
cashbox: 600,
|
||||||
|
cassette: 500
|
||||||
|
},
|
||||||
grandola: {
|
grandola: {
|
||||||
cashbox: 2000,
|
cashbox: 2000,
|
||||||
recycler: 2800
|
recycler: 2800
|
||||||
|
|
@ -36,4 +44,11 @@ const cashUnitCapacity = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { modelPrettifier, cashUnitCapacity }
|
const getCashUnitCapacity = (model, device) => {
|
||||||
|
if (!cashUnitCapacity[model]) {
|
||||||
|
return cashUnitCapacity.default[device]
|
||||||
|
}
|
||||||
|
return cashUnitCapacity[model][device]
|
||||||
|
}
|
||||||
|
|
||||||
|
export { modelPrettifier, cashUnitCapacity, getCashUnitCapacity }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue