Last active
May 12, 2016 15:45
-
-
Save douglasnomizo/8f952d189dbcdb554bde977a410514c3 to your computer and use it in GitHub Desktop.
listCustom.scala.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Option 1 | |
@defining( | |
(for { | |
custo <- cotacaoItem.custo | |
aliquotaSts <- custo.custoIcms.percentualAliquota | |
aliquotaFornecedor <- cotacaoItem.produto.percentualAliquotaIcms | |
cssClass <- if (aliquotaFornecedor.equals(aliquotaSts)) {Some("")} else {None} | |
} yield { cssClass }) getOrElse { "red" } | |
) { cssClass => | |
<td nowrap class="@cssClass">@cotacaoItem.produto.percentualAliquotaIcms.map { v => @formatValorAliquota(v) }</td> | |
<td nowrap class="@cssClass">@cotacaoItem.custo.map { c => @formatValorAliquota(c.custoIcms.percentualAliquota.getOrElse(BigDecimal(0)))}</td> | |
} | |
// Option 2 | |
@defining(cotacaoItem.custo.map { c => | |
c.custoIpi.percentualAliquota.map { a => | |
cotacaoItem.produto.percentualAliquotaIpi.map { f => | |
if(!f.equals(a)){"red"} | |
}.getOrElse("red") | |
}.getOrElse("red") | |
}.getOrElse("red")) { cssClass => | |
<td nowrap class="@cssClass">@cotacaoItem.produto.percentualAliquotaIpi.map { v => @formatValorAliquota(v) }</td> | |
<td nowrap class="@cssClass">@cotacaoItem.custo.map { c => @formatValorAliquota(c.custoIpi.percentualAliquota.getOrElse(BigDecimal(0)))}</td> | |
} | |
// Option 3 | |
@defining( | |
cotacaoItem.custo | |
.flatMap(_.custoIpi.percentualAliquota) | |
.flatMap( sts => | |
cotacaoItem.produto.percentualAliquotaIpi.map(forn => forn.equals(sts))) | |
.flatMap( equalsResult => { if (equalsResult) {Some("")} else {Some("red")} } ) | |
.getOrElse("red") | |
) { cssClass => | |
<td nowrap class="@cssClass">@cotacaoItem.produto.percentualAliquotaIpi.map { v => @formatValorAliquota(v) }</td> | |
<td nowrap class="@cssClass">@cotacaoItem.custo.map { c => @formatValorAliquota(c.custoIpi.percentualAliquota.getOrElse(BigDecimal(0)))}</td> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment