val txAmt tx getAmountNQT val distribOpt DistributionDatabase getDistr

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
val txAmt = tx.getAmountNQT
val distribOpt = DistributionDatabase.getDistribution(dp.assetId, dp.distribHeight)
val mbOwner = tx.getRecipientId
distribOpt match {
case Some(distrib) =>
val shares = distrib.ownership.get(mbOwner).getOrElse(0L)
val diff = shares / (distrib.totalAssets - distrib.issuerAssets) * dp.bunchNqtAmount - txAmt
//100 nqt max error
if (Math.abs(diff) < 100) {
ClauseParams.byAssetId(dp.assetId).map{clause =>
val updatedClause = clause.copy(dividendsPaid = clause.dividendsPaid + txAmt)
ClauseParams.save(updatedClause)
}
}