fix: migrate accounts and default cash-out commissions
This commit is contained in:
parent
b0fa62a9f3
commit
8403736026
2 changed files with 15 additions and 9 deletions
|
|
@ -81,6 +81,11 @@ function migrateCommissions (config) {
|
|||
}
|
||||
|
||||
const { global, scoped } = getConfigFields(_.keys(codes), config)
|
||||
const defaultCashOutCommissions = { code: 'cashOutCommission', value: 0, scope: global[0].scope }
|
||||
const isCashOutDisabled =
|
||||
_.isEmpty(_.filter(commissionElement => commissionElement.code === 'cashOutCommission', global))
|
||||
const globalWithDefaults =
|
||||
isCashOutDisabled ? _.concat(global, defaultCashOutCommissions) : global
|
||||
|
||||
const machineAndCryptoScoped = scoped.filter(
|
||||
f => f.scope.machine !== GLOBAL_SCOPE.machine && f.scope.crypto.length === 1
|
||||
|
|
@ -112,7 +117,7 @@ function migrateCommissions (config) {
|
|||
const allCommissionsOverrides = withCryptoScoped.concat(filteredMachineScoped)
|
||||
|
||||
return {
|
||||
..._.fromPairs(global.map(f => [`commissions_${codes[f.code]}`, f.value])),
|
||||
..._.fromPairs(globalWithDefaults.map(f => [`commissions_${codes[f.code]}`, f.value])),
|
||||
...(allCommissionsOverrides.length > 0 && {
|
||||
commissions_overrides: allCommissionsOverrides.map(s => ({
|
||||
..._.fromPairs(s.values.map(f => [codes[f.code], f.value])),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue