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

Fix fiat profit calculation
This commit is contained in:
Rafael Taranto 2021-12-16 11:47:26 +00:00 committed by GitHub
commit b9f9f574fa

View file

@ -130,7 +130,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).times(BN(it.fiat)) const discountValue = _.isNil(it.discount) ? BN(100) : BN(100).minus(it.discount)
const discountPercentage = BN(discountValue).div(100)
const commissionPercentage = BN(it.commissionPercentage).times(discountPercentage)
const getCommissionFee = it => BN(commissionPercentage).times(BN(it.fiat))
if (!it.cashInFee) return getCommissionFee(it) if (!it.cashInFee) return getCommissionFee(it)
return getCommissionFee(it).plus(BN(it.cashInFee)) return getCommissionFee(it).plus(BN(it.cashInFee))
} }