Skip to content

Commit

Permalink
Adicionadas e tratadas urls para NFce das seguintes SEFAZes: SVRS, AM…
Browse files Browse the repository at this point in the history
…, MT, PR, RS e SP;

Substituídas as urls da SEFAZ RS, conforme nota divulgada em 08/04/2015;
Correção no arredondamento de valores: Não estava gravando os campos do tipo decimal? com todas as casas decimais definidas na função Valor.Arredondar;
Adicionado, na tela do aplicativo de demonstração, guia "Geral", opção para escolha do tipo de documento (NFe ou NFCe).
  • Loading branch information
adeniltonbs committed May 4, 2015
1 parent 93152f2 commit c7705a8
Show file tree
Hide file tree
Showing 13 changed files with 1,524 additions and 848 deletions.
131 changes: 72 additions & 59 deletions NFe.AppTeste/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
d:DataContext="{d:DesignInstance {x:Type local:ConfiguracaoApp}, IsDesignTimeCreatable=True}">
<Window.Resources>
<local:EnumParaBool x:Key="EnumParaBool" />
<local:EnumParaInteger x:Key="EnumParaInteger"></local:EnumParaInteger>
<local:EnumParaInteger x:Key="EnumParaInteger" />
<CollectionViewSource x:Key="Estados">
<!--Coleção para ordernar o Enum que poderá ser usado em combos, listboxes, etc-->
<CollectionViewSource.SortDescriptions>
Expand Down Expand Up @@ -95,64 +95,77 @@
</TabItem>
<TabItem Header="Geral">
<Grid Background="White">
<GroupBox Header="Geral" HorizontalAlignment="Left" Margin="0,10,0,0"
VerticalAlignment="Top" Height="349" Width="308">
<Grid>
<GroupBox Header="Forma de Emissão" HorizontalAlignment="Left"
VerticalAlignment="Top" Height="153" Width="286" Margin="0,10,0,0">
<Grid>
<RadioButton Content="Normal" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="10,10,0,0"
IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teNormal}, Converter={StaticResource EnumParaBool}}" />
<RadioButton Content="FSIA" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="139,10,0,0"
RenderTransformOrigin="0.118,0.6"
IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teFSIA}, Converter={StaticResource EnumParaBool}}" />
<RadioButton Content="SCAN" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="10,40,0,0"
IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teSCAN}, Converter={StaticResource EnumParaBool}}"
IsEnabled="False" />
<RadioButton Content="EPEC" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="139,40,0,0"
RenderTransformOrigin="0.118,0.6"
IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teDPEC}, Converter={StaticResource EnumParaBool}}" />
<RadioButton Content="FSDA" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="10,70,0,0"
IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teFSDA}, Converter={StaticResource EnumParaBool}}" />
<RadioButton Content="SVC-AN" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="139,70,0,0"
RenderTransformOrigin="0.118,0.6"
IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teSVCAN}, Converter={StaticResource EnumParaBool}}" />
<RadioButton Content="SVC-RS" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="10,100,0,0"
IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teSVCRS}, Converter={StaticResource EnumParaBool}}" />
<RadioButton Content="NFC-e OffLine" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="139,100,0,0"
RenderTransformOrigin="0.118,0.6"
IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teOffLine}, Converter={StaticResource EnumParaBool}}" />
</Grid>
</GroupBox>
<Label Content="Diretório dos Schemas" HorizontalAlignment="Left" Margin="10,180,0,0"
VerticalAlignment="Top" RenderTransformOrigin="0.211,-0.577" Width="132" />
<TextBox x:Name="TxtDiretorioSchema" HorizontalAlignment="Left" Height="23"
Margin="10,211,0,0" TextWrapping="Wrap" VerticalAlignment="Top"
Width="250"
Text="{Binding CfgServico.DiretorioSchemas, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True" />
<Button x:Name="BtnDiretorioSchema" Content="..." Margin="265,211,0,93" Width="21"
HorizontalAlignment="Left" Click="BtnDiretorioSchema_Click" />
<StackPanel>
<GroupBox Header="Forma de Emissão" HorizontalAlignment="Left"
VerticalAlignment="Top" Height="153" Width="298" Margin="0,10,0,0">
<Grid>
<RadioButton Content="Normal" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="10,10,0,0"
IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teNormal}, Converter={StaticResource EnumParaBool}}" />
<RadioButton Content="FSIA" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="139,10,0,0"
RenderTransformOrigin="0.118,0.6"
IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teFSIA}, Converter={StaticResource EnumParaBool}}" />
<RadioButton Content="SCAN" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="10,40,0,0"
IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teSCAN}, Converter={StaticResource EnumParaBool}}"
IsEnabled="False" />
<RadioButton Content="EPEC" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="139,40,0,0"
RenderTransformOrigin="0.118,0.6"
IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teDPEC}, Converter={StaticResource EnumParaBool}}" />
<RadioButton Content="FSDA" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="10,70,0,0"
IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teFSDA}, Converter={StaticResource EnumParaBool}}" />
<RadioButton Content="SVC-AN" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="139,70,0,0"
RenderTransformOrigin="0.118,0.6"
IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teSVCAN}, Converter={StaticResource EnumParaBool}}" />
<RadioButton Content="SVC-RS" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="10,100,0,0"
IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teSVCRS}, Converter={StaticResource EnumParaBool}}" />
<RadioButton Content="NFC-e OffLine" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="139,100,0,0"
RenderTransformOrigin="0.118,0.6"
IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teOffLine}, Converter={StaticResource EnumParaBool}}" />
</Grid>
</GroupBox>

<GroupBox x:Name="GpbModeloDocumento" Header="Selecione o Tipo de Documento" Height="60" Margin="0,0,10,0">
<Grid x:Name="GrdModeloDocumento">
<RadioButton x:Name="RbtNfe" Content="NFe"
HorizontalAlignment="Left" VerticalAlignment="Top"
Margin="10,13,0,0"
IsChecked="{Binding CfgServico.ModeloDocumento, ConverterParameter={x:Static nfeclsidetipos:ModeloDocumento.NFe}, Converter={StaticResource EnumParaBool}}" />
<RadioButton x:Name="RbtNfce" Content="NFCe"
HorizontalAlignment="Left" VerticalAlignment="Top"
Margin="117,13,0,0"
IsChecked="{Binding CfgServico.ModeloDocumento, ConverterParameter={x:Static nfeclsidetipos:ModeloDocumento.NFCe}, Converter={StaticResource EnumParaBool}}" />
</Grid>
</GroupBox>

<CheckBox Name="CbxSalvarXml" Content="Salvar arquivos XML's em:" HorizontalAlignment="Left" Margin="10,260,0,0"
VerticalAlignment="Top" RenderTransformOrigin="0.211,-0.577" Width="178"
<StackPanel Margin="10,10,0,0">
<Label Content="Diretório dos Schemas" HorizontalAlignment="Left" VerticalAlignment="Top" Width="132" />
<DockPanel Margin="0,5,0,0">
<TextBox x:Name="TxtDiretorioSchema" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" VerticalAlignment="Top"
Width="250"
Text="{Binding CfgServico.DiretorioSchemas, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True" />
<Button x:Name="BtnDiretorioSchema" Content="..." Width="21" DockPanel.Dock="Right" Click="BtnDiretorioSchema_Click" />
</DockPanel>
</StackPanel>

<StackPanel Margin="10,10,0,0">
<CheckBox Name="CbxSalvarXml" Content="Salvar arquivos XML's em:" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="178"
IsChecked="{Binding CfgServico.SalvarXmlServicos}" Click="CbxSalvarXml_Click" />
<TextBox x:Name="TxtDiretorioXml" HorizontalAlignment="Left" Height="23"
Margin="10,291,0,0" TextWrapping="Wrap" VerticalAlignment="Top"
Width="250"
Text="{Binding CfgServico.DiretorioSalvarXml, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True" />
<Button x:Name="BtnDiretorioXml" Content="..." Margin="265,291,0,13" Width="21"
HorizontalAlignment="Left" Click="BtnDiretorioXml_Click" />
<DockPanel Margin="0,5,0,0">
<TextBox x:Name="TxtDiretorioXml" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" VerticalAlignment="Top" Width="250"
Text="{Binding CfgServico.DiretorioSalvarXml, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True" />
<Button x:Name="BtnDiretorioXml" Content="..." Width="21" DockPanel.Dock="Right" Click="BtnDiretorioXml_Click" />
</DockPanel>

</Grid>
</GroupBox>
</StackPanel>
</StackPanel>
</Grid>
</TabItem>
<TabItem Header="WeService">
Expand Down Expand Up @@ -493,10 +506,10 @@
SelectedItem="{Binding EnderecoEmitente.UF}" />
</Grid>
<ComboBox x:Name="CmbCrt" Margin="10,383,10,83"
ItemsSource="{Binding Source={StaticResource Crts}}"
SelectedItem="{Binding Emitente.CRT}" />
ItemsSource="{Binding Source={StaticResource Crts}}"
SelectedItem="{Binding Emitente.CRT}" />
<Label Content="CRT" HorizontalAlignment="Left" Margin="10,362,0,0"
VerticalAlignment="Top" />
VerticalAlignment="Top" />
</Grid>
</TabItem>
<TabItem Header="Email">
Expand Down
11 changes: 6 additions & 5 deletions NFe.AppTeste/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ protected virtual infNFe GetInf(int numero, ModeloDocumento modelo, VersaoServic

for (var i = 0; i < 1; i++)
{
infNFe.det.Add(GetDetalhe(i, infNFe.emit.CRT));
infNFe.det.Add(GetDetalhe(i, infNFe.emit.CRT, modelo));
}
infNFe.total = GetTotal(versao, infNFe.det);

Expand Down Expand Up @@ -886,7 +886,7 @@ protected virtual enderDest GetEnderecoDestinatario()
return enderDest;
}

protected virtual det GetDetalhe(int i, CRT crt)
protected virtual det GetDetalhe(int i, CRT crt, ModeloDocumento modelo)
{
var det = new det
{
Expand All @@ -900,11 +900,12 @@ protected virtual det GetDetalhe(int i, CRT crt)
TipoICMS = crt == CRT.SimplesNacional ? InformarCSOSN(Csosnicms.Csosn102) : InformarICMS(Csticms.Cst00, VersaoServico.ve310)
},
COFINS = new COFINS {TipoCOFINS = new COFINSOutr {CST = CSTCOFINS.cofins99, pCOFINS = 0, vBC = 0, vCOFINS = 0}},
PIS = new PIS {TipoPIS = new PISOutr {CST = CSTPIS.pis99, pPIS = 0, vBC = 0, vPIS = 0}},
IPI = new IPI() { cEnq = "999", TipoIPI = new IPITrib() { CST = CSTIPI.ipi00, pIPI = 5, vBC = 1, vIPI = 0.05m} }
PIS = new PIS {TipoPIS = new PISOutr {CST = CSTPIS.pis99, pPIS = 0, vBC = 0, vPIS = 0}}
}
};

if (modelo == ModeloDocumento.NFe) //NFCe não aceita grupo "IPI"
det.imposto.IPI = new IPI() {cEnq = "999", TipoIPI = new IPITrib() {CST = CSTIPI.ipi00, pIPI = 5, vBC = 1, vIPI = 0.05m}};
//det.impostoDevol = new impostoDevol() { IPI = new IPIDevolvido() { vIPIDevol = 10 }, pDevol = 100 };

return det;
Expand Down Expand Up @@ -1012,7 +1013,7 @@ protected virtual total GetTotal(VersaoServico versao, List<det> produtos)

foreach (var produto in produtos)
{
if (produto.imposto.IPI.TipoIPI.GetType() == typeof(IPITrib))
if (produto.imposto.IPI != null && produto.imposto.IPI.TipoIPI.GetType() == typeof(IPITrib))
icmsTot.vIPI = icmsTot.vIPI + ((IPITrib)produto.imposto.IPI.TipoIPI).vIPI ?? 0;
if (produto.imposto.ICMS.TipoICMS.GetType() == typeof (ICMS00))
{
Expand Down
8 changes: 6 additions & 2 deletions NFe.Classes/Valor.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
using System;
using System.Globalization;

namespace NFe.Classes
{
public static class Valor
{
public static decimal Arredondar(decimal valor, int casasDecimais)
{
return Decimal.Round(valor, casasDecimais);
var valorNovo = Decimal.Round(valor, casasDecimais);
var valorNovoStr = valorNovo.ToString("F" + casasDecimais, CultureInfo.CurrentCulture);
return Decimal.Parse(valorNovoStr);
}

public static decimal? Arredondar(decimal? valor, int casasDecimais)
{
return valor.HasValue ? decimal.Round(valor.Value, casasDecimais) : (decimal?) null;
if (valor == null) return null;
return Arredondar(valor.Value, casasDecimais);
}
}
}
Loading

0 comments on commit c7705a8

Please sign in to comment.