fix: add discount percentage to fiat profit calculation

This commit is contained in:
Sérgio Salgado 2021-12-13 23:01:31 +00:00
parent 9553bf8fc9
commit 442ba37ec5

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))
} }