Merge pull request #996 from chaotixkilla/fix-release-fiat-profit-records

[Release] Fix fiat profit calculation
This commit is contained in:
Rafael Taranto 2021-12-16 11:47:21 +00:00 committed by GitHub
commit 13b42b0753

View file

@ -100,7 +100,10 @@ function simplifiedBatch (data) {
const getCryptoAmount = it => coinUtils.toUnit(BN(it.cryptoAtoms), it.cryptoCode).toString() const getCryptoAmount = it => coinUtils.toUnit(BN(it.cryptoAtoms), it.cryptoCode).toString()
const getProfit = it => { const getProfit = it => {
const getCommissionFee = it => BN(it.commissionPercentage).mul(BN(it.fiat)) const discountValue = _.isNil(it.discount) ? BN(100) : BN(100).sub(it.discount)
const discountPercentage = BN(discountValue).div(100)
const commissionPercentage = BN(it.commissionPercentage).mul(discountPercentage)
const getCommissionFee = it => BN(commissionPercentage).mul(BN(it.fiat))
if (!it.cashInFee) return getCommissionFee(it) if (!it.cashInFee) return getCommissionFee(it)
return getCommissionFee(it).add(BN(it.cashInFee)) return getCommissionFee(it).add(BN(it.cashInFee))
} }