Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions DanfeSharp/Graphics/Gfx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

namespace DanfeSharp.Graphics
{
internal class Gfx
internal class Gfx
{
public PrimitiveComposer PrimitiveComposer { get; private set; }

public Gfx(PrimitiveComposer primitiveComposer)
{
PrimitiveComposer = primitiveComposer ?? throw new ArgumentNullException(nameof(primitiveComposer));
}
PrimitiveComposer = primitiveComposer ?? throw new ArgumentNullException(nameof(primitiveComposer));
}

internal void DrawString(string str, RectangleF rect, Fonte fonte, AlinhamentoHorizontal ah = AlinhamentoHorizontal.Esquerda, AlinhamentoVertical av = AlinhamentoVertical.Topo)
{
Expand All @@ -27,7 +27,7 @@ internal void DrawString(string str, RectangleF rect, Fonte fonte, AlinhamentoHo
if (av == AlinhamentoVertical.Base)
p.Y = rect.Bottom - fonte.AlturaLinha;
else if (av == AlinhamentoVertical.Centro)
p.Y += (rect.Height - fonte.AlturaLinha) / 2F ;
p.Y += (rect.Height - fonte.AlturaLinha) / 2F;

if (ah == AlinhamentoHorizontal.Direita)
p.X = rect.Right - fonte.MedirLarguraTexto(str);
Expand All @@ -50,7 +50,7 @@ public void SetFont(Fonte fonte)
public String ClearNonPrintableCharacters(String text)
{
var result = new string(text.Where(c =>
!((int)c < 31 || ((int)c >= 127 && (int)c <= 160))
!((int)c == 173 || (int)c < 31 || ((int)c >= 127 && (int)c <= 160))
).ToArray());

return result;
Expand All @@ -72,12 +72,12 @@ public void ShowXObject(XObject xobj, RectangleF r)
SizeF s = new SizeF();
SizeF xs = xobj.Size.ToMm();

if(r.Height >= r.Width)
if (r.Height >= r.Width)
{
if(xs.Height >= xs.Width)
if (xs.Height >= xs.Width)
{
s.Height = r.Height;
s.Width = (s.Height * xs.Width) / xs.Height;
s.Width = (s.Height * xs.Width) / xs.Height;
}
else
{
Expand Down Expand Up @@ -138,7 +138,5 @@ private void CheckPoint(PointF p)
public void Flush() => PrimitiveComposer.Flush();
public void Fill() => PrimitiveComposer.Fill();
public void DrawRectangle(float x, float y, float w, float h) => DrawRectangle(new RectangleF(x, y, w, h));


}
}
}
39 changes: 24 additions & 15 deletions DanfeSharp/Modelo/DanfeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public float Margem
/// </summary>
public String ChaveAcesso { get; set; }


/// <summary>
/// <para>Descrição da Natureza da Operação</para>
/// <para>Tag natOp</para>
Expand Down Expand Up @@ -128,12 +127,12 @@ public float Margem
/// <summary>
/// <para>Data e Hora da entrada em contingência - dhCont
/// </summary>
public DateTimeOffset? DataHoraContingencia { get;set; }
public DateTimeOffset? DataHoraContingencia { get; set; }

/// <summary>
/// <para> Justificativa da entrada em contingência - xJust
/// </summary>
public String MotivoContingencia { get;set; }
public String MotivoContingencia { get; set; }

/// <summary>
/// <para>Tipo Emissao
Expand Down Expand Up @@ -171,7 +170,6 @@ public float Margem
/// </summary>
public CalculoIssqnViewModel CalculoIssqn { get; set; }


/// <summary>
/// Tipo de Ambiente
/// </summary>
Expand Down Expand Up @@ -211,7 +209,6 @@ public float Margem

#endregion


#region Opções de exibição

/// <summary>
Expand Down Expand Up @@ -244,10 +241,8 @@ public DanfeViewModel()
ExibirPisConfins = true;
}


public Boolean MostrarCalculoIssqn { get; set; }


/// <summary>
/// Substitui o ponto e vírgula (;) por uma quebra de linha.
/// </summary>
Expand Down Expand Up @@ -282,12 +277,30 @@ public virtual String TextoReservadoFisco()
if (TipoEmissao == 4)
{
sb.Append("CONTINGÊNCIA DPEC");

sb.AppendChaveValor("Entrada em contingência", DataHoraContingencia.Value.ToString("yyyy-MM-ddThh:mm:sszzz")); // data hora

sb.AppendChaveValor("Justificativa", MotivoContingencia); // just
}

// 5 = Contingência FSDA
if (TipoEmissao == 5)
{
sb.Append("CONTINGÊNCIA FSDA");
sb.AppendChaveValor("Entrada em contingência", DataHoraContingencia.Value.ToString("yyyy-MM-ddThh:mm:sszzz")); // data hora
sb.AppendChaveValor("Justificativa", MotivoContingencia); // just
}
// 6 = Contingência SVC-AN
else if (TipoEmissao == 6)
{
sb.Append("CONTINGÊNCIA SVC-AN");
sb.AppendChaveValor("Entrada em contingência", DataHoraContingencia.Value.ToString("yyyy-MM-ddThh:mm:sszzz")); // data hora
sb.AppendChaveValor("Justificativa", MotivoContingencia); // just
}
// 7 = Contingência SVC-RS
else if (TipoEmissao == 7)
{
sb.Append("CONTINGÊNCIA SVC-RS");
sb.AppendChaveValor("Entrada em contingência", DataHoraContingencia.Value.ToString("yyyy-MM-ddThh:mm:sszzz")); // data hora
sb.AppendChaveValor("Justificativa", MotivoContingencia); // just
}
return sb.ToString();
}

Expand Down Expand Up @@ -317,14 +330,12 @@ public virtual String TextoAdicional()
if (!String.IsNullOrEmpty(NotaEmpenho))
sb.AppendChaveValor("Nota de Empenho", NotaEmpenho);


foreach (var nfref in NotasFiscaisReferenciadas)
{
if (sb.Length > 0) sb.Append(" ");
sb.Append(nfref);
}


#region NT 2013.003 Lei da Transparência

if (CalculoImposto.ValorAproximadoTributos.HasValue && (String.IsNullOrEmpty(InformacoesComplementares) ||
Expand All @@ -337,12 +348,10 @@ public virtual String TextoAdicional()

#endregion


return sb.ToString();
}

public Boolean IsRetrato => Orientacao == Orientacao.Retrato;
public Boolean IsPaisagem => Orientacao == Orientacao.Paisagem;

}
}
}
11 changes: 4 additions & 7 deletions DanfeSharp/Modelo/DanfeViewModelCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static DanfeViewModel CriarDeArquivoXml(String caminho)
/// <returns>Modelo</returns>
public static DanfeViewModel CriarDeArquivoXml(Stream stream)
{
if (stream == null) throw new ArgumentNullException(nameof(stream));
if (stream == null) throw new ArgumentNullException(nameof(stream));

using (StreamReader sr = new StreamReader(stream, true))
{
Expand All @@ -106,7 +106,6 @@ public static DanfeViewModel CriarDeStringXml(string str)
}
}


private static DanfeViewModel CriarDeArquivoXmlInternal(TextReader reader)
{
ProcNFe nfe = null;
Expand Down Expand Up @@ -152,7 +151,6 @@ internal static void ExtrairDatas(DanfeViewModel model, InfNFe infNfe)
{
model.HoraSaidaEntrada = TimeSpan.Parse(ide.hSaiEnt);
}

}
}

Expand Down Expand Up @@ -194,7 +192,7 @@ public static DanfeViewModel CreateFromProcNFe(ProcNFe procNfe)
throw new Exception("Somente o mod==55 está implementado.");
}

if (ide.tpEmis != FormaEmissao.Normal && ide.tpEmis != FormaEmissao.ContingenciaDPEC)
if (ide.tpEmis != FormaEmissao.Normal && ide.tpEmis != FormaEmissao.ContingenciaDPEC && ide.tpEmis != FormaEmissao.ContingenciaFSDA && ide.tpEmis != FormaEmissao.ContingenciaSVCAN && ide.tpEmis != FormaEmissao.ContingenciaSVCRS)
{
throw new Exception("Somente o tpEmis==1 está implementado.");
}
Expand Down Expand Up @@ -241,7 +239,7 @@ public static DanfeViewModel CreateFromProcNFe(ProcNFe procNfe)
produto.ValorUnitario = det.prod.vUnCom;
produto.ValorTotal = det.prod.vProd;
produto.InformacoesAdicionais = det.infAdProd;

var imposto = det.imposto;

if (imposto != null)
Expand Down Expand Up @@ -352,6 +350,5 @@ public static DanfeViewModel CreateFromProcNFe(ProcNFe procNfe)

return model;
}

}
}
}