fix: commissions overrides and coinatmradar
This commit is contained in:
parent
520efc0c27
commit
be7e4c5c10
3 changed files with 30 additions and 20 deletions
|
|
@ -46,15 +46,14 @@ function mapCoin (rates, deviceId, settings, cryptoCode) {
|
|||
}
|
||||
}
|
||||
|
||||
function mapIdentification (config, deviceId) {
|
||||
const triggers = configManager.getTriggers(deviceId, config)
|
||||
const compatTriggers = complianceTriggers.getBackwardsCompatibleTriggers(triggers)
|
||||
function mapIdentification (config) {
|
||||
const triggers = configManager.getTriggers(config)
|
||||
|
||||
return {
|
||||
isPhone: !!compatTriggers.sms,
|
||||
isPhone: complianceTriggers.hasPhone(triggers),
|
||||
isPalmVein: false,
|
||||
isPhoto: !!compatTriggers.facephoto,
|
||||
isIdDocScan: !!compatTriggers.idData,
|
||||
isPhoto: complianceTriggers.hasFacephoto(triggers),
|
||||
isIdDocScan: complianceTriggers.hasIdScan(triggers),
|
||||
isFingerprint: false
|
||||
}
|
||||
}
|
||||
|
|
@ -64,8 +63,8 @@ function mapMachine (rates, settings, machineRow) {
|
|||
const config = settings.config
|
||||
|
||||
const coinAtmRadar = configManager.getCoinAtmRadar(config)
|
||||
const triggers = configManager.getTriggers(deviceId, config)
|
||||
const compatTriggers = complianceTriggers.getBackwardsCompatibleTriggers(triggers)
|
||||
const triggers = configManager.getTriggers(config)
|
||||
const triggerCashLimit = complianceTriggers.getCashLimit(triggers)
|
||||
const locale = configManager.getLocale(deviceId, config)
|
||||
const cashOutConfig = configManager.getCashOut(deviceId, config)
|
||||
|
||||
|
|
@ -76,19 +75,13 @@ function mapMachine (rates, settings, machineRow) {
|
|||
const showSupportedBuySellDirection = coinAtmRadar.supportedBuySellDirection
|
||||
const showLimitsAndVerification = coinAtmRadar.limitsAndVerification
|
||||
|
||||
// TODO new-admin: this is relaying info with backwards compatible triggers
|
||||
// need to get in touch with coinatmradar before updating this
|
||||
// TODO all directions and max between them instead of min
|
||||
const cashLimit = showLimitsAndVerification ? (
|
||||
!!compatTriggers.block
|
||||
? compatTriggers.block
|
||||
: Infinity ) : null
|
||||
const cashLimit = showLimitsAndVerification ? ( triggerCashLimit || Infinity ) : null
|
||||
|
||||
const cryptoCurrencies = locale.cryptoCurrencies
|
||||
const cashInEnabled = showSupportedBuySellDirection ? true : null
|
||||
const cashOutEnabled = showSupportedBuySellDirection ? cashOutConfig.active : null
|
||||
const fiat = showSupportedFiat ? locale.fiatCurrency : null
|
||||
const identification = mapIdentification(config, deviceId)
|
||||
const identification = mapIdentification(config)
|
||||
const coins = showSupportedCryptocurrencies ?
|
||||
_.map(_.partial(mapCoin, [rates, deviceId, settings]), cryptoCurrencies)
|
||||
: null
|
||||
|
|
|
|||
|
|
@ -14,4 +14,17 @@ function maxDaysThreshold (triggers) {
|
|||
return _.max(_.map('thresholdDays')(triggers))
|
||||
}
|
||||
|
||||
module.exports = { getBackwardsCompatibleTriggers, hasSanctions, maxDaysThreshold }
|
||||
function getCashLimit (triggers) {
|
||||
const withFiat = _.filter(({ triggerType }) => _.includes(['txVolume', 'txAmount'])(triggerType))
|
||||
const blocking = _.filter(({ requirement }) => _.includes(['block', 'suspend'])(requirement))
|
||||
|
||||
return _.compose(_.minBy('threshold'), blocking, withFiat)(triggers)
|
||||
}
|
||||
|
||||
const hasRequirement = requirement => _.compose(_.negate(_.isEmpty), _.find(_.matches({ requirement })))
|
||||
|
||||
const hasPhone = hasRequirement('sms')
|
||||
const hasFacephoto = hasRequirement('facephoto')
|
||||
const hasIdScan = hasRequirement('idCardData')
|
||||
|
||||
module.exports = { getBackwardsCompatibleTriggers, hasSanctions, maxDaysThreshold, getCashLimit, hasPhone, hasFacephoto, hasIdScan }
|
||||
|
|
@ -22,17 +22,21 @@ const fromNamespace = _.curry((key, config) => _.compose(strip(key), filter(key)
|
|||
const toNamespace = (key, config) => _.mapKeys(it => `${key}_${it}`)(config)
|
||||
|
||||
const resolveOverrides = (original, filter, overrides, overridesPath = 'overrides') => {
|
||||
if (_.isEmpty(overrides)) return original
|
||||
if (_.isEmpty(overrides)) return _.omit(overridesPath, original)
|
||||
|
||||
return _.omit(overridesPath, _.mergeAll([original, ..._.filter(filter)(overrides)]))
|
||||
}
|
||||
|
||||
const getCommissions = (cryptoCode, deviceId, config) => {
|
||||
const commissions = fromNamespace(namespaces.COMMISSIONS)(config)
|
||||
const overrides = commissions.overrides
|
||||
|
||||
const filter = it => it.machine === deviceId && _.includes(cryptoCode)(it.cryptoCurrencies)
|
||||
// TODO new-admin. We have a all machines override now
|
||||
return resolveOverrides(commissions, filter, commissions.overrides)
|
||||
const allFilter = it => it.machine === 'ALL_MACHINES' && _.includes(cryptoCode)(it.cryptoCurrencies)
|
||||
|
||||
if (_.isEmpty(overrides)) return _.omit('overrides', commissions)
|
||||
|
||||
return _.omit('overrides', _.mergeAll([commissions, ..._.filter(allFilter)(overrides), ..._.filter(filter)(overrides)]))
|
||||
}
|
||||
|
||||
const getLocale = (deviceId, it) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue