diff --git a/.gitignore b/.gitignore index b548cb6..7900859 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ ################################################################################ /.vs/PrototipoAfip/v15/.suo +/.vs/PrototipoAfip/v15/Server/sqlite3 diff --git a/PrototipoAfip/FacturaForm.Designer.vb b/PrototipoAfip/FacturaForm.Designer.vb index bf9097a..72962b5 100644 --- a/PrototipoAfip/FacturaForm.Designer.vb +++ b/PrototipoAfip/FacturaForm.Designer.vb @@ -22,7 +22,7 @@ Partial Class FacturaForm 'No lo modifique con el editor de código. Private Sub InitializeComponent() - Me.Button1 = New System.Windows.Forms.Button() + Me.CargaBtn = New System.Windows.Forms.Button() Me.Label1 = New System.Windows.Forms.Label() Me.TiposComprobantesCMB = New System.Windows.Forms.ComboBox() Me.Label2 = New System.Windows.Forms.Label() @@ -76,14 +76,14 @@ Partial Class FacturaForm Me.GroupBox1.SuspendLayout() Me.SuspendLayout() ' - 'Button1 + 'CargaBtn ' - Me.Button1.Location = New System.Drawing.Point(230, 34) - Me.Button1.Name = "Button1" - Me.Button1.Size = New System.Drawing.Size(75, 44) - Me.Button1.TabIndex = 0 - Me.Button1.Text = "Cargar" - Me.Button1.UseVisualStyleBackColor = True + Me.CargaBtn.Location = New System.Drawing.Point(230, 34) + Me.CargaBtn.Name = "CargaBtn" + Me.CargaBtn.Size = New System.Drawing.Size(75, 44) + Me.CargaBtn.TabIndex = 0 + Me.CargaBtn.Text = "Cargar" + Me.CargaBtn.UseVisualStyleBackColor = True ' 'Label1 ' @@ -619,7 +619,7 @@ Partial Class FacturaForm Me.Controls.Add(Me.Label15) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) - Me.Controls.Add(Me.Button1) + Me.Controls.Add(Me.CargaBtn) Me.Name = "FacturaForm" Me.Text = "FacturaForm" Me.GroupBox1.ResumeLayout(False) @@ -629,7 +629,7 @@ Partial Class FacturaForm End Sub - Friend WithEvents Button1 As Button + Friend WithEvents CargaBtn As Button Friend WithEvents Label1 As Label Friend WithEvents TiposComprobantesCMB As ComboBox Friend WithEvents Label2 As Label diff --git a/PrototipoAfip/FacturaForm.vb b/PrototipoAfip/FacturaForm.vb index c8b1d36..3b97b91 100644 --- a/PrototipoAfip/FacturaForm.vb +++ b/PrototipoAfip/FacturaForm.vb @@ -1,4 +1,5 @@ Imports PrototipoAfip.WSFEHOMO + Public Class FacturaForm Property Login As LoginClass Property TiposComprobantes As CbteTipoResponse @@ -10,14 +11,15 @@ Public Class FacturaForm Property opcionales As OpcionalTipoResponse Property authRequest As FEAuthRequest Private url As String - Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click + Private Sub CargaBtn_Click(sender As Object, e As EventArgs) Handles CargaBtn.Click Try authRequest = New FEAuthRequest() authRequest.Cuit = MyCuitTX.Text authRequest.Sign = Login.Sign authRequest.Token = Login.Token - Dim service As Service = getServicio() + Dim service As New WSFEHOMO.Service + service.Url = url service.ClientCertificates.Add(Login.certificado) @@ -39,7 +41,8 @@ Public Class FacturaForm TiposIVA = service.FEParamGetTiposIva(authRequest) TipoIVACmb.DataSource = TiposIVA.ResultGet - NroCbteTX.Text = service.FECompUltimoAutorizado(authRequest, 4, TiposComprobantes.ResultGet(0).Id).CbteNro + 1 + Dim lastCbteObj = service.FECompUltimoAutorizado(authRequest, 4, TiposComprobantes.ResultGet(0).Id) + NroCbteTX.Text = lastCbteObj.CbteNro + 1 opcionales = service.FEParamGetTiposOpcional(authRequest) Catch ex As Exception @@ -110,7 +113,8 @@ Public Class FacturaForm Try Dim service As WSFEHOMO.Service = getServicio() service.ClientCertificates.Add(Login.certificado) - Dim pv As Integer = Integer.Parse(InputBox("Pto Venta")) + Dim pvObj As PtoVenta = ptos_venta_cm.SelectedItem + Dim pv As Integer = pvObj.Nro Dim cm As CbteTipo = TiposComprobantesCMB.SelectedItem Dim req As New FECAERequest @@ -174,10 +178,21 @@ Public Class FacturaForm m &= "Desde-Hasta: " & r.FeDetResp(0).CbteDesde & "-" & r.FeDetResp(0).CbteHasta m &= vbCrLf - For Each o In r.FeDetResp(0).Observaciones - m &= String.Format("Obs: {0} ({1})", o.Msg, o.Code) & vbCrLf - Next - + If r.FeDetResp(0).Observaciones IsNot Nothing Then + For Each o In r.FeDetResp(0).Observaciones + m &= String.Format("Obs: {0} ({1})", o.Msg, o.Code) & vbCrLf + Next + End If + If r.Errors IsNot Nothing Then + For Each er In r.Errors + m &= String.Format("Er: {0}: {1}", er.Code, er.Msg) & vbCrLf + Next + End If + If r.Events IsNot Nothing Then + For Each ev In r.Events + m &= String.Format("Ev: {0}: {1}", ev.Code, ev.Msg) & vbCrLf + Next + End If Resultado.Text = m Catch ex As Exception @@ -189,7 +204,8 @@ Public Class FacturaForm Try Dim service As WSFEHOMO.Service = getServicio() service.ClientCertificates.Add(Login.certificado) - Dim pv As Integer = Integer.Parse(InputBox("Pto Venta")) + Dim pvObj As PtoVenta = ptos_venta_cm.SelectedItem + Dim pv As Integer = pvObj.Nro Dim cm As CbteTipo = TiposComprobantesCMB.SelectedItem Dim last As FERecuperaLastCbteResponse = service.FECompUltimoAutorizado(authRequest, pv, cm.Id) @@ -200,9 +216,23 @@ Public Class FacturaForm consulta.PtoVta = last.PtoVta Dim asdf As FECompConsultaResponse = service.FECompConsultar(authRequest, consulta) - Dim r = asdf.ResultGet + mostrar(asdf) - Dim m As String = "Estado: " & r.Resultado & vbCrLf + + + + + MsgBox("El Ultimo fue: " & last.CbteNro.ToString) + Catch ex As Exception + MsgBox(ex.Message) + End Try + End Sub + + Private Sub mostrar(asdf As FECompConsultaResponse) + Dim r = asdf.ResultGet + Dim m As String = "" + If r IsNot Nothing Then + m = "Estado: " & r.Resultado & vbCrLf m &= "CAE: " & r.CodAutorizacion m &= vbCrLf m &= "Vto: " & r.FchVto @@ -216,11 +246,12 @@ Public Class FacturaForm m &= "Total: " & r.ImpTotal m &= vbCrLf - For Each o In r.Observaciones - m &= String.Format("Obs: {0} ({1})", o.Msg, o.Code) & vbCrLf - Next + If r.Observaciones IsNot Nothing Then + For Each o In r.Observaciones + m &= String.Format("Obs: {0} ({1})", o.Msg, o.Code) & vbCrLf + Next + End If - Resultado.Text = m With LinearWinForm2 @@ -241,12 +272,21 @@ Public Class FacturaForm .ImageFormat = Imaging.ImageFormat.Bmp .drawBarcode(LinearWinForm2.CreateGraphics) End With + Else + m = "No hay ninguno anterior" + End If - - MsgBox("El Ultimo fue: " & last.CbteNro.ToString) - Catch ex As Exception - MsgBox(ex.Message) - End Try + If asdf.Errors IsNot Nothing Then + For Each er In asdf.Errors + m &= vbCrLf & String.Format("Er: {0}: {1}", er.Code, er.Msg) + Next + End If + If asdf.Events IsNot Nothing Then + For Each ev In asdf.Events + m &= vbCrLf & String.Format("Ev: {0}: {1}", ev.Code, ev.Msg) + Next + End If + Resultado.Text = m End Sub Private Sub testing_rb_CheckedChanged(sender As Object, e As EventArgs) Handles testing_rb.CheckedChanged @@ -271,4 +311,11 @@ Public Class FacturaForm Dim p = String.Format("{0}\codigo.bmp", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)) LinearWinForm2.SaveAsImage(p) End Sub + + Private Sub TiposComprobantesCMB_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TiposComprobantesCMB.SelectedIndexChanged + Dim cm As CbteTipo = TiposComprobantesCMB.SelectedItem + Dim last = getServicio.FECompUltimoAutorizado(authRequest, 4, cm.Id) + Dim ultimo_nro As Integer = last.CbteNro + NroCbteTX.Text = ultimo_nro + 1 + End Sub End Class \ No newline at end of file diff --git a/PrototipoAfip/bin/Debug/PrototipoAfip.exe b/PrototipoAfip/bin/Debug/PrototipoAfip.exe index f4044fe..f12de51 100644 Binary files a/PrototipoAfip/bin/Debug/PrototipoAfip.exe and b/PrototipoAfip/bin/Debug/PrototipoAfip.exe differ diff --git a/PrototipoAfip/bin/Debug/PrototipoAfip.exe.config b/PrototipoAfip/bin/Debug/PrototipoAfip.exe.config index 25b88bb..6bb5202 100644 --- a/PrototipoAfip/bin/Debug/PrototipoAfip.exe.config +++ b/PrototipoAfip/bin/Debug/PrototipoAfip.exe.config @@ -26,7 +26,7 @@ wsfe - 20079870626 + 20095214526 diff --git a/PrototipoAfip/bin/Debug/PrototipoAfip.pdb b/PrototipoAfip/bin/Debug/PrototipoAfip.pdb index 32d0489..d212bac 100644 Binary files a/PrototipoAfip/bin/Debug/PrototipoAfip.pdb and b/PrototipoAfip/bin/Debug/PrototipoAfip.pdb differ diff --git a/PrototipoAfip/obj/Debug/PrototipoAfip.exe b/PrototipoAfip/obj/Debug/PrototipoAfip.exe index f4044fe..f12de51 100644 Binary files a/PrototipoAfip/obj/Debug/PrototipoAfip.exe and b/PrototipoAfip/obj/Debug/PrototipoAfip.exe differ diff --git a/PrototipoAfip/obj/Debug/PrototipoAfip.pdb b/PrototipoAfip/obj/Debug/PrototipoAfip.pdb index 32d0489..d212bac 100644 Binary files a/PrototipoAfip/obj/Debug/PrototipoAfip.pdb and b/PrototipoAfip/obj/Debug/PrototipoAfip.pdb differ diff --git a/PrototipoAfip/obj/Debug/PrototipoAfip.vbproj.CopyComplete b/PrototipoAfip/obj/Debug/PrototipoAfip.vbproj.CopyComplete new file mode 100644 index 0000000..e69de29 diff --git a/PrototipoAfip/obj/Debug/PrototipoAfip.vbproj.CoreCompileInputs.cache b/PrototipoAfip/obj/Debug/PrototipoAfip.vbproj.CoreCompileInputs.cache new file mode 100644 index 0000000..b879e21 --- /dev/null +++ b/PrototipoAfip/obj/Debug/PrototipoAfip.vbproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +7f64352696657d4e9be54e901589b1da61748147 diff --git a/PrototipoAfip/obj/Debug/PrototipoAfip.vbproj.FileListAbsolute.txt b/PrototipoAfip/obj/Debug/PrototipoAfip.vbproj.FileListAbsolute.txt index 55eb444..8bf4e37 100644 --- a/PrototipoAfip/obj/Debug/PrototipoAfip.vbproj.FileListAbsolute.txt +++ b/PrototipoAfip/obj/Debug/PrototipoAfip.vbproj.FileListAbsolute.txt @@ -14,3 +14,21 @@ C:\Users\Guille\documents\visual studio 2017\Projects\PrototipoAfip\PrototipoAfi C:\Users\Guille\Documents\Visual Studio 2017\Projects\PrototipoAfip\PrototipoAfip\obj\Debug\PrototipoAfip.vbprojResolveAssemblyReference.cache C:\Users\Guille\Documents\Visual Studio 2017\Projects\PrototipoAfip\PrototipoAfip\bin\Debug\BarcodeLib.Barcode.WinForms.dll C:\Users\Guille\Documents\Visual Studio 2017\Projects\PrototipoAfip\PrototipoAfip\obj\Debug\PrototipoAfip.FacturaPrueba.resources +C:\Users\Guille\Source\Repos\afip_wsfe_prototype\PrototipoAfip\bin\Debug\Templates\LoginTemplate.xml +C:\Users\Guille\Source\Repos\afip_wsfe_prototype\PrototipoAfip\bin\Debug\PrototipoAfip.exe.config +C:\Users\Guille\Source\Repos\afip_wsfe_prototype\PrototipoAfip\bin\Debug\PrototipoAfip.exe +C:\Users\Guille\Source\Repos\afip_wsfe_prototype\PrototipoAfip\bin\Debug\PrototipoAfip.pdb +C:\Users\Guille\Source\Repos\afip_wsfe_prototype\PrototipoAfip\bin\Debug\PrototipoAfip.xml +C:\Users\Guille\Source\Repos\afip_wsfe_prototype\PrototipoAfip\bin\Debug\BarcodeLib.Barcode.WinForms.dll +C:\Users\Guille\Source\Repos\afip_wsfe_prototype\PrototipoAfip\obj\Debug\PrototipoAfip.vbprojResolveAssemblyReference.cache +C:\Users\Guille\Source\Repos\afip_wsfe_prototype\PrototipoAfip\obj\Debug\PrototipoAfip.FacturaForm.resources +C:\Users\Guille\Source\Repos\afip_wsfe_prototype\PrototipoAfip\obj\Debug\PrototipoAfip.FacturaPrueba.resources +C:\Users\Guille\Source\Repos\afip_wsfe_prototype\PrototipoAfip\obj\Debug\PrototipoAfip.Form1.resources +C:\Users\Guille\Source\Repos\afip_wsfe_prototype\PrototipoAfip\obj\Debug\PrototipoAfip.LargeText.resources +C:\Users\Guille\Source\Repos\afip_wsfe_prototype\PrototipoAfip\obj\Debug\PrototipoAfip.Resources.resources +C:\Users\Guille\Source\Repos\afip_wsfe_prototype\PrototipoAfip\obj\Debug\PrototipoAfip.vbproj.GenerateResource.Cache +C:\Users\Guille\Source\Repos\afip_wsfe_prototype\PrototipoAfip\obj\Debug\PrototipoAfip.exe +C:\Users\Guille\Source\Repos\afip_wsfe_prototype\PrototipoAfip\obj\Debug\PrototipoAfip.xml +C:\Users\Guille\Source\Repos\afip_wsfe_prototype\PrototipoAfip\obj\Debug\PrototipoAfip.pdb +C:\Users\Guille\Source\Repos\afip_wsfe_prototype\PrototipoAfip\obj\Debug\PrototipoAfip.vbproj.CoreCompileInputs.cache +C:\Users\Guille\Source\Repos\afip_wsfe_prototype\PrototipoAfip\obj\Debug\PrototipoAfip.vbproj.CopyComplete diff --git a/PrototipoAfip/obj/Debug/PrototipoAfip.vbproj.GenerateResource.Cache b/PrototipoAfip/obj/Debug/PrototipoAfip.vbproj.GenerateResource.Cache index 0f79490..88ebb5e 100644 Binary files a/PrototipoAfip/obj/Debug/PrototipoAfip.vbproj.GenerateResource.Cache and b/PrototipoAfip/obj/Debug/PrototipoAfip.vbproj.GenerateResource.Cache differ diff --git a/PrototipoAfip/obj/Debug/PrototipoAfip.vbprojResolveAssemblyReference.cache b/PrototipoAfip/obj/Debug/PrototipoAfip.vbprojResolveAssemblyReference.cache index 9c25e9a..fd6779d 100644 Binary files a/PrototipoAfip/obj/Debug/PrototipoAfip.vbprojResolveAssemblyReference.cache and b/PrototipoAfip/obj/Debug/PrototipoAfip.vbprojResolveAssemblyReference.cache differ