fix: profit display on admin
This commit is contained in:
parent
952cbd661e
commit
6d0e510d60
5 changed files with 1 additions and 74 deletions
|
|
@ -1 +0,0 @@
|
||||||
LAMASSU_DB=DEV
|
|
||||||
|
|
@ -1,8 +1,5 @@
|
||||||
## Database variables
|
## Database variables
|
||||||
|
|
||||||
# Used to describe which database to use. Possible values include: DEV, RELEASE, STRESS_TEST
|
|
||||||
LAMASSU_DB=
|
|
||||||
|
|
||||||
# Postgres related environment variables
|
# Postgres related environment variables
|
||||||
POSTGRES_USER=
|
POSTGRES_USER=
|
||||||
POSTGRES_PASSWORD=
|
POSTGRES_PASSWORD=
|
||||||
|
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
const fs = require('fs')
|
|
||||||
const path = require('path')
|
|
||||||
const os = require('os')
|
|
||||||
const argv = require('minimist')(process.argv.slice(2))
|
|
||||||
const _ = require('lodash/fp')
|
|
||||||
|
|
||||||
require('./environment-helper')
|
|
||||||
|
|
||||||
const DATABASE = process.env.LAMASSU_DB ?? 'PROD'
|
|
||||||
const dbMapping = psqlConf => ({
|
|
||||||
STRESS_TEST: _.replace('lamassu', 'lamassu_stress', psqlConf),
|
|
||||||
PAZUZ: _.replace('lamassu', 'lamassu_pazuz', psqlConf),
|
|
||||||
RELEASE: _.replace('lamassu', 'lamassu_release', psqlConf),
|
|
||||||
DEV: _.replace('lamassu', 'lamassu', psqlConf),
|
|
||||||
PROD: _.replace('lamassu', 'lamassu', psqlConf)
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {{path: string, opts: any}}
|
|
||||||
*/
|
|
||||||
function load () {
|
|
||||||
if (process.env.LAMASSU_CONFIG) {
|
|
||||||
const configPath = process.env.LAMASSU_CONFIG
|
|
||||||
return {
|
|
||||||
path: configPath,
|
|
||||||
opts: JSON.parse(fs.readFileSync(configPath))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argv.f) {
|
|
||||||
const configPath = argv.f
|
|
||||||
return {
|
|
||||||
path: configPath,
|
|
||||||
opts: JSON.parse(fs.readFileSync(configPath))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const globalConfigPath = path.resolve('/etc', 'lamassu', 'lamassu.json')
|
|
||||||
const config = {
|
|
||||||
path: globalConfigPath,
|
|
||||||
opts: JSON.parse(fs.readFileSync(globalConfigPath))
|
|
||||||
}
|
|
||||||
|
|
||||||
config.opts.postgresql = dbMapping(config.opts.postgresql)[DATABASE]
|
|
||||||
|
|
||||||
return config
|
|
||||||
} catch (_) {
|
|
||||||
try {
|
|
||||||
const homeConfigPath = path.resolve(os.homedir(), '.lamassu', 'lamassu.json')
|
|
||||||
const config = {
|
|
||||||
path: homeConfigPath,
|
|
||||||
opts: JSON.parse(fs.readFileSync(homeConfigPath))
|
|
||||||
}
|
|
||||||
|
|
||||||
config.opts.postgresql = dbMapping(config.opts.postgresql)[DATABASE]
|
|
||||||
|
|
||||||
return config
|
|
||||||
} catch (_) {
|
|
||||||
console.error("Couldn't open lamassu.json config file.")
|
|
||||||
process.exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = load
|
|
||||||
|
|
@ -130,9 +130,7 @@ const DetailsRow = ({ it: tx, timezone }) => {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const commission = BigNumber(tx.profit)
|
const commission = BigNumber(tx.profit).toFixed(2, 1) // ROUND_DOWN
|
||||||
.abs()
|
|
||||||
.toFixed(2, 1) // ROUND_DOWN
|
|
||||||
const commissionPercentage =
|
const commissionPercentage =
|
||||||
Number.parseFloat(tx.commissionPercentage, 2) * 100
|
Number.parseFloat(tx.commissionPercentage, 2) * 100
|
||||||
const cashInFee = isCashIn ? Number.parseFloat(tx.cashInFee) : 0
|
const cashInFee = isCashIn ? Number.parseFloat(tx.cashInFee) : 0
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ const setEnvVariable = require('./set-env-var')
|
||||||
|
|
||||||
fs.copyFileSync(path.resolve(__dirname, '../.sample.env'), path.resolve(__dirname, '../.env'))
|
fs.copyFileSync(path.resolve(__dirname, '../.sample.env'), path.resolve(__dirname, '../.env'))
|
||||||
|
|
||||||
setEnvVariable('LAMASSU_DB', 'DEV')
|
|
||||||
setEnvVariable('POSTGRES_USER', 'postgres')
|
setEnvVariable('POSTGRES_USER', 'postgres')
|
||||||
setEnvVariable('POSTGRES_PASSWORD', 'postgres123')
|
setEnvVariable('POSTGRES_PASSWORD', 'postgres123')
|
||||||
setEnvVariable('POSTGRES_HOST', 'localhost')
|
setEnvVariable('POSTGRES_HOST', 'localhost')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue