feat: send individual discounts to machine

This commit is contained in:
Sérgio Salgado 2021-07-22 20:04:23 +01:00 committed by Josh Harvey
parent 29257c42ec
commit eda6decae0
2 changed files with 9 additions and 6 deletions

View file

@ -33,8 +33,7 @@ function getAvailableIndividualDiscounts () {
id: it.id,
idType: _.camelCase(it.identification),
value: it.value,
discount: it.discount,
softDeleted: it.soft_deleted
discount: it.discount
}), res))
}

View file

@ -230,6 +230,7 @@ function plugins (settings, deviceId) {
const pingPromise = recordPing(deviceTime, machineVersion, machineModel)
const currentConfigVersionPromise = fetchCurrentConfigVersion()
const currentAvailablePromoCodes = loyalty.getNumberOfAvailablePromoCodes()
const currentAvailableIndividualDiscounts = loyalty.getAvailableIndividualDiscounts()
const timezoneObj = { utcOffset: timezone[0], dstOffset: timezone[1] }
const promises = [
@ -241,7 +242,8 @@ function plugins (settings, deviceId) {
tickerPromises,
balancePromises,
testnetPromises,
currentAvailablePromoCodes
currentAvailablePromoCodes,
currentAvailableIndividualDiscounts
)
return Promise.all(promises)
@ -252,10 +254,11 @@ function plugins (settings, deviceId) {
const cryptoCodesCount = cryptoCodes.length
const tickers = arr.slice(4, cryptoCodesCount + 4)
const balances = arr.slice(cryptoCodesCount + 4, 2 * cryptoCodesCount + 4)
const testNets = arr.slice(2 * cryptoCodesCount + 4, arr.length - 1)
const testNets = arr.slice(2 * cryptoCodesCount + 4, arr.length - 2)
const coinParams = _.zip(cryptoCodes, testNets)
const coinsWithoutRate = _.map(mapCoinSettings, coinParams)
const areThereAvailablePromoCodes = arr[arr.length - 1] > 0
const areThereAvailablePromoCodes = arr[arr.length - 2] > 0
const individualDiscounts = arr[arr.length - 1]
return {
cassettes,
@ -264,7 +267,8 @@ function plugins (settings, deviceId) {
coins: _.zipWith(_.assign, coinsWithoutRate, tickers),
configVersion,
areThereAvailablePromoCodes,
timezone: tz
timezone: tz,
individualDiscounts
}
})
}