Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*.user
*.userosscache
*.sln.docstates
.vshistory/

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
Expand Down
8 changes: 8 additions & 0 deletions src/OpenAC.Net.DFe.Core/Common/DFeArquivosConfigBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ public string ArquivoServicos
/// </summary>
public bool Salvar { get; set; }

/// <summary>
/// Define se os nomes dos arquivos devem ser padronizados,
/// utilizando a chave da NFSe, Id do DPS ou NSU, conforme o tipo de operação.
/// Quando <c>false</c>, utiliza o comportamento padrão da biblioteca,
/// cujo formato pode variar e não segue um padrão fixo.
/// </summary>
public bool PadronizarNomes { get; set; }

/// <summary>
/// Define/retorna se deve ser adicionado um literal ao caminho de salvamento.
/// </summary>
Expand Down
16 changes: 15 additions & 1 deletion src/OpenAC.Net.DFe.Core/Extensions/DFeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

namespace OpenAC.Net.DFe.Core.Extensions;

internal static class DFeExtensions
public static class DFeExtensions
{
public static DFeBaseAttribute GetElementAtt(this PropertyInfo prop)
{
Expand Down Expand Up @@ -154,4 +154,18 @@ public static bool IsValidXml(this string xmlstring)
return false;
}
}

/// <summary>
/// Formata uma string numérica com zeros à esquerda.
/// </summary>
/// <param name="value">String numérica</param>
public static string FillZeros(this string? value, int tamanho = 6, string fallback = "000000")
{
if (string.IsNullOrWhiteSpace(value))
return fallback;

return int.TryParse(value, out var numero)
? numero.ToString(new string('0', tamanho))
: fallback;
}
}