Skip to content

Commit

Permalink
Correções na leitura de arquivo e ajuste nos tipos de frete conforme …
Browse files Browse the repository at this point in the history
…nova versão do layout da EFD Fiscal, correções nos tipos e tamanhos de registros do Bloco F da EFD Contribuições,
  • Loading branch information
orochasamuel committed Aug 15, 2023
1 parent a1dac96 commit 422b0f6
Show file tree
Hide file tree
Showing 6 changed files with 195 additions and 145 deletions.
18 changes: 15 additions & 3 deletions src/FiscalBr.Common/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -875,10 +875,22 @@ public enum IndTipoPagamento
public enum IndTipoFrete
{
[DefaultValue("")] None = -1,
[DefaultValue("0")] ContaEmitente = 0,
[DefaultValue("1")] ContaDestinatarioRemetente = 1,

[DefaultValue("0")] ContaRemetenteCif = 0,
[DefaultValue("1")] ContaDestinatarioFob = 1,
[DefaultValue("2")] ContaTerceiros = 2,
[DefaultValue("9")] SemCobrancaFrete = 9
[DefaultValue("3")] ContaProprioRemetente = 3,
[DefaultValue("4")] ContaProprioDestinatario = 4,

[DefaultValue("9")] SemCobrancaFrete = 9,

[DefaultValue("0")] ContaTerceirosPre2012 = 120,
[DefaultValue("1")] ContaEmitentePre2012 = 121,
[DefaultValue("2")] ContaDestinatarioPre2012 = 122,

[DefaultValue("0")] ContaEmitentePre2018 = 180,
[DefaultValue("1")] ContaDestinatarioRemetentePre2018 = 181,
[DefaultValue("2")] ContaTerceirosPre2018 = 182
}

/// <summary>
Expand Down
27 changes: 24 additions & 3 deletions src/FiscalBr.Common/Sped/LerCamposSped.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;

namespace FiscalBr.Common.Sped
{
Expand Down Expand Up @@ -72,9 +74,28 @@ public static object LerCampos(this string line, string file = Constantes.EFDFis

else if (propType.IsEnum)
{
var convertedEnum = Enum.Parse(propType, value.ToStringSafe());

prop.SetValue(instantiatedObject, convertedEnum);
foreach (var currentEnumItem in propType.GetEnumValues())
{
MemberInfo memberInfo = propType.GetMember(currentEnumItem.ToString()).FirstOrDefault();

if (memberInfo != null)
{
DefaultValueAttribute attribute = (DefaultValueAttribute)
memberInfo.GetCustomAttributes(typeof(DefaultValueAttribute), false)
.FirstOrDefault();

if (attribute != null)
{
if (attribute.Value.ToString() == value.ToString())
{
var convertedEnum = Enum.Parse(propType, currentEnumItem.ToString());

prop.SetValue(instantiatedObject, convertedEnum);
break;
}
}
}
}
}

else if (propType == typeof(Decimal) || propType == typeof(Nullable<Decimal>))
Expand Down
Loading

0 comments on commit 422b0f6

Please sign in to comment.