lamassu-server/lib/compliance-triggers.js
2020-05-27 22:43:00 +01:00

9 lines
No EOL
381 B
JavaScript

const _ = require('lodash/fp')
function getBackwardsCompatibleTriggers (triggers) {
const filtered = _.filter(_.matches({ triggerType: 'volume', cashDirection: 'both' }))(triggers)
const grouped = _.groupBy(_.prop('requirement'))(filtered)
return _.mapValues(_.compose(_.get('threshold'), _.minBy('threshold')))(grouped)
}
module.exports = { getBackwardsCompatibleTriggers}