diff --git a/lib/constants.js b/lib/constants.js
index d771542e..ab00e704 100644
--- a/lib/constants.js
+++ b/lib/constants.js
@@ -14,6 +14,14 @@ const anonymousCustomer = {
}
const CASH_UNIT_CAPACITY = {
+ default: {
+ cashbox: 600,
+ cassette: 500
+ },
+ douro: {
+ cashbox: 600,
+ cassette: 500
+ },
grandola: {
cashbox: 2000,
recycler: 2800
diff --git a/lib/plugins.js b/lib/plugins.js
index fa6fe92f..41cb1bd7 100644
--- a/lib/plugins.js
+++ b/lib/plugins.js
@@ -737,6 +737,13 @@ function plugins (settings, deviceId) {
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) {
const cashOutConfig = configManager.getCashOut(device.deviceId, settings.config)
const denomination1 = cashOutConfig.cassette1
@@ -768,7 +775,7 @@ function plugins (settings, deviceId) {
}
: 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',
cassette: 1,
@@ -780,7 +787,7 @@ function plugins (settings, deviceId) {
}
: 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',
cassette: 2,
@@ -792,7 +799,7 @@ function plugins (settings, deviceId) {
}
: 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',
cassette: 3,
@@ -804,7 +811,7 @@ function plugins (settings, deviceId) {
}
: 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',
cassette: 4,
@@ -816,7 +823,7 @@ function plugins (settings, deviceId) {
}
: 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',
cassette: 4,
@@ -828,7 +835,7 @@ function plugins (settings, deviceId) {
}
: 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',
cassette: 4,
@@ -840,7 +847,7 @@ function plugins (settings, deviceId) {
}
: 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',
cassette: 4,
@@ -852,7 +859,7 @@ function plugins (settings, deviceId) {
}
: 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',
cassette: 4,
@@ -864,7 +871,7 @@ function plugins (settings, deviceId) {
}
: 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',
cassette: 4,
@@ -876,7 +883,7 @@ function plugins (settings, deviceId) {
}
: 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',
cassette: 4,
diff --git a/new-lamassu-admin/src/pages/Maintenance/CashUnitDetails.js b/new-lamassu-admin/src/pages/Maintenance/CashUnitDetails.js
index 9e6c6905..dd2c8934 100644
--- a/new-lamassu-admin/src/pages/Maintenance/CashUnitDetails.js
+++ b/new-lamassu-admin/src/pages/Maintenance/CashUnitDetails.js
@@ -7,7 +7,7 @@ import { CashOut } from 'src/components/inputs'
import { Label1, TL2 } from 'src/components/typography'
import { offDarkColor } from 'src/styling/variables'
import { fromNamespace } from 'src/utils/config'
-import { cashUnitCapacity, modelPrettifier } from 'src/utils/machine'
+import { getCashUnitCapacity, modelPrettifier } from 'src/utils/machine'
const styles = {
wrapper: {
@@ -134,7 +134,7 @@ const CashUnitDetails = ({
threshold={
fillingPercentageSettings[`fillingPercentageCassette${it}`]
}
- capacity={cashUnitCapacity[machine.model].cassette}
+ capacity={getCashUnitCapacity(machine.model, 'cassette')}
/>
{it !== machine.numberOfCassettes && (
@@ -165,7 +165,7 @@ const CashUnitDetails = ({
`fillingPercentageCassette${it}`
]
}
- capacity={cashUnitCapacity[machine.model].cassette}
+ capacity={getCashUnitCapacity(machine.model, 'cassette')}
/>
))(R.range(1, machine.numberOfCassettes + 1))}
@@ -193,7 +193,7 @@ const CashUnitDetails = ({
`fillingPercentageStacker${it}f`
]
}
- capacity={cashUnitCapacity[machine.model].stacker}
+ capacity={getCashUnitCapacity(machine.model, 'stacker')}
/>
diff --git a/new-lamassu-admin/src/pages/Maintenance/Wizard/Wizard.js b/new-lamassu-admin/src/pages/Maintenance/Wizard/Wizard.js
index bb9f6a16..3713da6a 100644
--- a/new-lamassu-admin/src/pages/Maintenance/Wizard/Wizard.js
+++ b/new-lamassu-admin/src/pages/Maintenance/Wizard/Wizard.js
@@ -4,7 +4,7 @@ import * as Yup from 'yup'
import Modal from 'src/components/Modal'
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 WizardSplash from './WizardSplash'
@@ -108,10 +108,13 @@ const Wizard = ({ machine, cashoutSettings, locale, onClose, save, error }) => {
.required()
.min(0)
.max(
- cashUnitCapacity[machine.model].cassette,
- `${modelPrettifier[machine.model]} maximum cassette capacity is ${
- cashUnitCapacity[machine.model].cassette
- } bills`
+ getCashUnitCapacity(machine.model, 'cassette'),
+ `${
+ modelPrettifier[machine.model]
+ } maximum cassette capacity is ${getCashUnitCapacity(
+ machine.model,
+ 'cassette'
+ )} bills`
)
})
}))
diff --git a/new-lamassu-admin/src/pages/Maintenance/Wizard/WizardStep.js b/new-lamassu-admin/src/pages/Maintenance/Wizard/WizardStep.js
index 378c4041..b4ea0c95 100644
--- a/new-lamassu-admin/src/pages/Maintenance/Wizard/WizardStep.js
+++ b/new-lamassu-admin/src/pages/Maintenance/Wizard/WizardStep.js
@@ -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 { ReactComponent as TxOutIcon } from 'src/styling/icons/direction/cash-out.svg'
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 { startCase } from 'src/utils/string'
@@ -170,7 +170,8 @@ const WizardStep = ({
const cassetteTotal = values => cassetteCount(values) * cashUnitDenomination
const getPercentage = R.pipe(
cassetteCount,
- count => 100 * (count / cashUnitCapacity[machine.model][cashUnitCategory]),
+ count =>
+ 100 * (count / getCashUnitCapacity(machine.model, cashUnitCategory)),
R.clamp(0, 100)
)
diff --git a/new-lamassu-admin/src/pages/Maintenance/helper.js b/new-lamassu-admin/src/pages/Maintenance/helper.js
index 77b4af29..656df6a0 100644
--- a/new-lamassu-admin/src/pages/Maintenance/helper.js
+++ b/new-lamassu-admin/src/pages/Maintenance/helper.js
@@ -4,7 +4,7 @@ import { IconButton } from 'src/components/buttons'
import { CashIn, CashOutLite } from 'src/components/inputs/cashbox/Cashbox'
import { ReactComponent as EditIcon } from 'src/styling/icons/action/edit/enabled.svg'
import { fromNamespace } from 'src/utils/config'
-import { cashUnitCapacity } from 'src/utils/machine'
+import { getCashUnitCapacity } from 'src/utils/machine'
const getElements = (
classes,
@@ -68,7 +68,7 @@ const getElements = (
threshold={
fillingPercentageSettings[`fillingPercentageCassette${it}`]
}
- capacity={cashUnitCapacity[m.model].cassette}
+ capacity={getCashUnitCapacity(m.model, 'cassette')}
/>
))(R.range(1, m.numberOfCassettes + 1))}
@@ -87,7 +87,7 @@ const getElements = (
`fillingPercentageStacker${it}f`
]
}
- capacity={cashUnitCapacity[m.model].stacker}
+ capacity={getCashUnitCapacity(m.model, 'stacker')}
/>
{it !== m.numberOfStackers && (
diff --git a/new-lamassu-admin/src/utils/machine.js b/new-lamassu-admin/src/utils/machine.js
index 2fe36976..d90249f1 100644
--- a/new-lamassu-admin/src/utils/machine.js
+++ b/new-lamassu-admin/src/utils/machine.js
@@ -8,6 +8,14 @@ const modelPrettifier = {
}
const cashUnitCapacity = {
+ default: {
+ cashbox: 600,
+ cassette: 500
+ },
+ douro: {
+ cashbox: 600,
+ cassette: 500
+ },
grandola: {
cashbox: 2000,
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 }