orochasamuel / fiscalbr-net

Para facilitar seu dia a dia como desenvolvedor \o/
MIT License
91 stars 48 forks source link

[FEATURE] Implementar leitura retroativa de (enum) frete da EFD Fiscal #100

Closed orochasamuel closed 12 months ago

orochasamuel commented 12 months ago

Leitura retroativa para IndicadorTipoFrete na EFD Fiscal implementado, há como melhorar. Por hora, essa implementação inicial atende.


// TODO: Refatorar e simplificar verificação
if (propType.Name == nameof(IndTipoFrete))
{
    // Se houver data informada no Registro0000 deve usar esta data como referencia
    DateTime? dtInicial = this.Bloco0?.Reg0000?.DtIni;
    if (dtInicial.HasValue)
    {
        if (dtInicial.Value < new DateTime(2012, 1, 1))
        {
            switch (attribute.Value.ToString())
            {
                case "0":
                    isSet = true;
                    prop.SetValue(instantiatedObject, IndTipoFrete.ContaTerceirosPre2012);
                    break;
                case "1":
                    isSet = true;
                    prop.SetValue(instantiatedObject, IndTipoFrete.ContaEmitentePre2012);
                    break;
                case "2":
                    isSet = true;
                    prop.SetValue(instantiatedObject, IndTipoFrete.ContaDestinatarioPre2012);
                    break;
                default:
                    break;
            }
        }
        else if (dtInicial.Value >= new DateTime(2012, 1, 1) 
            && dtInicial.Value < new DateTime(2018, 1, 1))
        {
            switch (attribute.Value.ToString())
            {
                case "0":
                    isSet = true;
                    prop.SetValue(instantiatedObject, IndTipoFrete.ContaEmitentePre2018);
                    break;
                case "1":
                    isSet = true;
                    prop.SetValue(instantiatedObject, IndTipoFrete.ContaDestinatarioRemetentePre2018);
                    break;
                case "2":
                    isSet = true;
                    prop.SetValue(instantiatedObject, IndTipoFrete.ContaTerceirosPre2018);
                    break;
                default:
                    break;
            }
        }
    }
}

Há 2 testes para verificar a leitura retroativa: Teste_Leitura_Isolada_C100_indmod_1B_VNova_2011() e Teste_Leitura_Isolada_C100_indmod_1B_VNova_2015()