Skip to content

Commit

Permalink
Padronizado modo de arredondamento das classes da NFe e DFe e refator…
Browse files Browse the repository at this point in the history
…ado nomes das variáveis
  • Loading branch information
AgnaldoSilva0 committed Jan 8, 2025
1 parent ad08372 commit dbaf397
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions DFe.Classes/Valor.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using System.Globalization;
using System;
using System.Globalization;

namespace DFe.Classes
{
public static class Valor
{
public static decimal Arredondar(this decimal valor, int casasDecimais)
{
var valorNovo = decimal.Round(valor, casasDecimais);
var valorNovoStr = valorNovo.ToString("F" + casasDecimais, CultureInfo.CurrentCulture);
return decimal.Parse(valorNovoStr);
var valorArredondado = decimal.Round(valor, casasDecimais, MidpointRounding.ToEven);
var valorArredondadoFormatado = valorArredondado.ToString("F" + casasDecimais, CultureInfo.CurrentCulture);
return decimal.Parse(valorArredondadoFormatado);
}

public static decimal? Arredondar(this decimal? valor, int casasDecimais)
Expand Down
6 changes: 3 additions & 3 deletions NFe.Classes/Valor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ public static class Valor
{
public static decimal Arredondar(this decimal valor, int casasDecimais)
{
var valorNovo = decimal.Round(valor, casasDecimais, MidpointRounding.AwayFromZero);
var valorNovoStr = valorNovo.ToString("F" + casasDecimais, CultureInfo.CurrentCulture);
return decimal.Parse(valorNovoStr);
var valorArredondado = decimal.Round(valor, casasDecimais, MidpointRounding.ToEven);
var valorArredondadoFormatado = valorArredondado.ToString("F" + casasDecimais, CultureInfo.CurrentCulture);
return decimal.Parse(valorArredondadoFormatado);
}

public static decimal? Arredondar(this decimal? valor, int casasDecimais)
Expand Down

0 comments on commit dbaf397

Please sign in to comment.