update bill count in config
This commit is contained in:
parent
84a93599f5
commit
cc32bc39e8
1 changed files with 42 additions and 5 deletions
|
|
@ -15,6 +15,7 @@ const wallet = require('./wallet')
|
|||
const exchange = require('./exchange')
|
||||
const sms = require('./sms')
|
||||
const email = require('./email')
|
||||
const settingsLoader = require('./settings-loader')
|
||||
|
||||
const mapValuesWithKey = _.mapValues.convert({cap: false})
|
||||
|
||||
|
|
@ -515,12 +516,48 @@ function plugins (settings, deviceId) {
|
|||
//
|
||||
// However, we should make all config changes atomic in the future.
|
||||
const config = configManager.machineScoped(deviceId, settings.config)
|
||||
config.topCashOutDenomination -= tx.bills[0].actualDispense +
|
||||
tx.bills[0].rejected
|
||||
config.bottomCashOutDenomination -= tx.bills[1].actualDispense +
|
||||
tx.bills[1].rejected
|
||||
const topCashOutDenomination = config.topCashOutDenomination -
|
||||
(tx.bills[0].actualDispense + tx.bills[0].rejected)
|
||||
const bottomCashOutDenomination = config.bottomCashOutDenomination -
|
||||
(tx.bills[1].actualDispense + tx.bills[1].rejected)
|
||||
|
||||
// save
|
||||
const newFields = [
|
||||
{
|
||||
fieldLocator: {
|
||||
fieldScope: {
|
||||
crypto: 'global',
|
||||
machine: deviceId
|
||||
},
|
||||
code: 'topCashOutDenomination',
|
||||
fieldType: 'integer',
|
||||
fieldClass: null
|
||||
},
|
||||
fieldValue: {
|
||||
fieldType: 'integer',
|
||||
value: topCashOutDenomination
|
||||
}
|
||||
},
|
||||
{
|
||||
fieldLocator: {
|
||||
fieldScope: {
|
||||
crypto: 'global',
|
||||
machine: deviceId
|
||||
},
|
||||
code: 'bottomCashOutDenomination',
|
||||
fieldType: 'integer',
|
||||
fieldClass: null
|
||||
},
|
||||
fieldValue: {
|
||||
fieldType: 'integer',
|
||||
value: bottomCashOutDenomination
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
return settingsLoader.loadLatest()
|
||||
.then(settings => {
|
||||
return settingsLoader.save({config: settingsLoader.mergeValues(settings.config, newFields)})
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue