Created
January 24, 2012 15:14
-
-
Save rponte/1670630 to your computer and use it in GitHub Desktop.
Revisions
-
rponte revised this gist
Jan 24, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -5,8 +5,8 @@ public class LimiteDeSaldo { private BigDecimal margemDeCredito; public LimiteDeSaldo(BigDecimal disponivel, BigDecimal concedido, BigDecimal margemDeCredito) { this.disponivel = disponivel; this.concedido = concedido; this.margemDeCredito = margemDeCredito.setScale(2, RoundingMode.HALF_DOWN); } -
rponte revised this gist
Jan 24, 2012 . 1 changed file with 13 additions and 13 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -9,19 +9,6 @@ public LimiteDeSaldo(BigDecimal disponivel, BigDecimal concedido, BigDecimal mar this.concedido = concedido.setScale(2); this.margemDeCredito = margemDeCredito.setScale(2, RoundingMode.HALF_DOWN); } public void debita(BigDecimal valorASerDebitado) { if (!possuiDisponivel(valorASerDebitado)) @@ -33,4 +20,17 @@ public void debitaSemConsultaDeLimite(BigDecimal valorASerDebitado) { disponivel = disponivel.subtract(valorASerDebitado); } private boolean possuiDisponivel(BigDecimal valor) { return getDisponivelComMargemDeCredito().compareTo(valor) >= 0; } private BigDecimal getDisponivelComMargemDeCredito() { return calculaDisponivelComMargemDeCredito(); } private BigDecimal calculaDisponivelComMargemDeCredito() { BigDecimal margem = disponivel.multiply(margemDeCredito); return disponivel.add(margem).setScale(2, RoundingMode.UP); } } -
rponte revised this gist
Jan 24, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ public LimiteDeSaldo(BigDecimal disponivel, BigDecimal concedido, BigDecimal mar this.margemDeCredito = margemDeCredito.setScale(2, RoundingMode.HALF_DOWN); } private BigDecimal getDisponivelComMargemDeCredito() { return calculaDisponivelComMargemDeCredito(); } @@ -19,7 +19,7 @@ private BigDecimal calculaDisponivelComMargemDeCredito() { return disponivel.add(margem).setScale(2, RoundingMode.UP); } private boolean possuiDisponivel(BigDecimal valor) { return getDisponivelComMargemDeCredito().compareTo(valor) >= 0; } -
rponte created this gist
Jan 24, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ public class LimiteDeSaldo { private BigDecimal disponivel; private BigDecimal concedido; private BigDecimal margemDeCredito; public LimiteDeSaldo(BigDecimal disponivel, BigDecimal concedido, BigDecimal margemDeCredito) { this.disponivel = disponivel.setScale(2); this.concedido = concedido.setScale(2); this.margemDeCredito = margemDeCredito.setScale(2, RoundingMode.HALF_DOWN); } public BigDecimal getDisponivelComMargemDeCredito() { return calculaDisponivelComMargemDeCredito(); } private BigDecimal calculaDisponivelComMargemDeCredito() { BigDecimal margem = disponivel.multiply(margemDeCredito); return disponivel.add(margem).setScale(2, RoundingMode.UP); } public boolean possuiDisponivel(BigDecimal valor) { return getDisponivelComMargemDeCredito().compareTo(valor) >= 0; } public void debita(BigDecimal valorASerDebitado) { if (!possuiDisponivel(valorASerDebitado)) throw new LimiteDeSaldoDisponivelInsuficienteException(disponivel); disponivel = disponivel.subtract(valorASerDebitado); } public void debitaSemConsultaDeLimite(BigDecimal valorASerDebitado) { disponivel = disponivel.subtract(valorASerDebitado); } }