This commit is contained in:
@@ -9471,326 +9471,390 @@ Partial Class Clientes
|
||||
Next
|
||||
|
||||
Return Timbre
|
||||
End Function
|
||||
|
||||
'Private Function GenerarNotaCredito(CvePS As Integer, Tipo As Integer, CveUnidadMedida As Integer, Importe As Decimal, Iva As Decimal, Descripcion As String, CveClasificacion As Integer) As Boolean
|
||||
|
||||
' Dim Respuesta As Boolean = False
|
||||
|
||||
' Dim ObjVentas As New ClsVentas
|
||||
' Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL())
|
||||
' Dim ObjAcum As New ClsAcumuladores(ObjVentas.IniciaTransacSQL())
|
||||
|
||||
' Dim ErrorVentas As Boolean = False
|
||||
' Dim SubTotal As Decimal = Importe
|
||||
' Dim Total As Decimal = Importe + Iva
|
||||
|
||||
' Dim RetIVA As Decimal = 0
|
||||
' Dim RetISR As Decimal = 0
|
||||
' Dim TipoCambio As Decimal = 0
|
||||
' Dim FechaVencimiento As Date = Now
|
||||
' Dim fecha As Date = Now
|
||||
|
||||
' Dim Folio As Integer = 0
|
||||
' Dim Serie As String = ""
|
||||
|
||||
' If FolioNotaCredito() Then
|
||||
' Folio = FolioNotaAcumulador
|
||||
' Serie = SerieNotaAcumulador
|
||||
' End If
|
||||
|
||||
' Dim CveSubProyecto As Integer = DdlSubProyecto.SelectedValue.ToEntero
|
||||
|
||||
' Dim CveVenta As Integer
|
||||
|
||||
' If Folio > 0 Then
|
||||
|
||||
' Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas($"Clientes/{Descripcion}", 1, Total, Total, 1, fecha, "Nota de crédito por Cargo", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||
|
||||
' If ObjVentas.AddVenta("Egs", Folio, CveCliente.ToEntero, -1, SubTotal, 0, 0, Iva, RetIVA, RetISR, Total, 1, TipoCambio,
|
||||
' 0, 0, 0, FechaVencimiento, fecha, "", "", fecha, -1, "", "", "", 0, 0, 0, "-1".ToDate, "-1".ToDate, "-1".ToDate, -1, -1, 0, CvePrePoliza,
|
||||
' UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Serie:=Serie, CveSubProyecto:=CveSubProyecto, CveSubProyectoEjecucion:=CveSubProyecto) Then
|
||||
|
||||
' CveVenta = ObjVentas.CveVenta
|
||||
|
||||
' If CveVenta > 0 Then
|
||||
' If ObjVentas.AddVentaDetalle(CveVenta, CvePS, 1, CveUnidadMedida, SubTotal, 0.16, SubTotal * 0.16, Descripcion, 0, 0, -1, 0) Then
|
||||
|
||||
' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, SubTotal, Folio.ToString, 150, String.Format("{0}-{1}", Serie, Folio), fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveClasificacion:=CveClasificacion, ImporteMX:=SubTotal, CveSubProyecto:=CveSubProyecto) Then
|
||||
' ErrorVentas = True
|
||||
' End If
|
||||
' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total, Folio.ToString, 12, String.Format("{0}-{1}", Serie, Folio), fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=Total) Then
|
||||
' ErrorVentas = True
|
||||
' End If
|
||||
' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Iva, Folio.ToString, 13, String.Format("{0}-{1}", Serie, Folio), fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=Iva) Then
|
||||
' ErrorVentas = True
|
||||
' End If
|
||||
|
||||
' If Not ErrorVentas Then
|
||||
' For Each GvRow As GridViewRow In GvAcum.Rows
|
||||
' Dim CveMovto As Integer = GvRow.DataKey("CveMovto").ToEntero
|
||||
|
||||
' If (Tipo = 1 And GvRow.FCCheckBox("ChkCargo").Checked) Or (Tipo = 2 And GvRow.FCCheckBox("ChkBonificacion").Checked) Then
|
||||
|
||||
' If ObjAcum.DistribuidorActualizarFacturados(CveMovto, UsuarioActual.CveEmpresa, Tipo, CveVenta) Then
|
||||
' Respuesta = True
|
||||
' ErrorVentas = False
|
||||
' CveVentaNota = CveVenta
|
||||
' Else
|
||||
' Respuesta = False
|
||||
' ErrorVentas = True
|
||||
' CveVentaNota = 0
|
||||
' Exit For
|
||||
' End If
|
||||
|
||||
' End If
|
||||
' Next
|
||||
' End If
|
||||
|
||||
|
||||
' If Not ErrorVentas Then
|
||||
' Alert($"Nota de crédito generada correctamente <a href='./Ventas.aspx?CveVenta={CveVenta}' >{Serie}-{Folio}</a>")
|
||||
' End If
|
||||
|
||||
|
||||
' Else
|
||||
' ErrorVentas = True
|
||||
' End If
|
||||
' Else
|
||||
' ErrorVentas = True
|
||||
' End If
|
||||
|
||||
' Else
|
||||
' ErrorVentas = True
|
||||
' End If
|
||||
' Else
|
||||
' Alert("No se pudo obtener el Folio.", TipoMensaje.MsgError)
|
||||
' End If
|
||||
|
||||
|
||||
|
||||
' If ErrorVentas Then
|
||||
' ObjVentas.RollBack()
|
||||
' Else
|
||||
|
||||
' ObjVentas.Commit()
|
||||
' CargaUsados()
|
||||
|
||||
' Dim DtDetallesVenta As New DataTable
|
||||
|
||||
' If ObjVentas.GetVentaDetalle(CveVenta) Then
|
||||
|
||||
' DtDetallesVenta = ObjVentas.DtResultados
|
||||
' 'CreaObjetosVenta(CveVenta, Serie, Folio, SubTotal, Iva, DtDetallesVenta)
|
||||
|
||||
' ObjFactura.Timbre = PreParaTimbre(ObjFactura, ObjFactura.CveSubProyecto)
|
||||
|
||||
' Dim ObjTimbrado As New Timbrado
|
||||
' Dim SeTimbro As Boolean = False
|
||||
|
||||
' SeTimbro = ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura)
|
||||
|
||||
' If SeTimbro Then
|
||||
' Alert("Se timbro correctamente")
|
||||
' Else
|
||||
' Alert("No se pudo timbrar, intente mas tarde.", TipoMensaje.MsgError)
|
||||
' End If
|
||||
|
||||
' Else
|
||||
' Alert("No se pudo timbrar, no se pudieron obtener los detalles de la venta.", TipoMensaje.MsgError)
|
||||
' End If
|
||||
|
||||
' End If
|
||||
|
||||
|
||||
|
||||
' ObjVentas.Dispose()
|
||||
' Return Respuesta
|
||||
|
||||
'End Function
|
||||
'Private Function generaNC(CveVenta As Integer, ByRef ObjVentas As ClsVentas, ByVal factura As Modelos.Factura) As List(Of Object)
|
||||
|
||||
' Dim Obj As New List(Of Object)
|
||||
' Dim CveVentaNueva As Integer = ObjVentas.CveVenta
|
||||
' Dim BanderaGeneraNC As Boolean = False
|
||||
' If UsuarioActual.CveEmpresa.Contiene(1, 119) Then BanderaGeneraNC = True
|
||||
|
||||
' If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then
|
||||
' If ObjVentas.DtResultados IsNot Nothing AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then
|
||||
' Dim drv As DataRow = ObjVentas.DtResultados.Rows(0)
|
||||
' Dim TmpDTconceptos As DataTable = Nothing
|
||||
|
||||
' ''CargaCliente
|
||||
|
||||
' Dim CveCliente As Integer = drv("CveCliente").ToString.ToEntero
|
||||
' If UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 77 AndAlso Not CveCliente.Contiene(10450, 10460, 10458) Then
|
||||
' Return Nothing
|
||||
' ElseIf UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 21 AndAlso Not CveCliente.Contiene(27448) Then
|
||||
' Return Nothing
|
||||
' End If
|
||||
' factura.TipoDocto = drv("TipoDocto").ToString
|
||||
' factura.Serie = drv("Serie").ToString
|
||||
' factura.FechaEjecucion = drv("FechaEjecucion").ToString.ToDateTime
|
||||
' factura.Fecha = drv("Fecha").ToString.ToDateTime
|
||||
' factura.CveSubProyectoEjecucion = drv("CveSubProyectoEjecucion").ToString.ToEntero
|
||||
' factura.CveSubProyectoCobranza = drv("CveSubProyectoCobranza").ToString.ToEntero
|
||||
' factura.CveClienteSucursal = drv("CveClienteSucursal").ToString.ToEntero
|
||||
' factura.CveSubProyecto = drv("CveSubProyecto").ToString.ToEntero
|
||||
|
||||
|
||||
' ''CargaDetalle
|
||||
' If ObjVentas.GetVentaDetalle(CveVenta) Then
|
||||
' TmpDTconceptos = ObjVentas.DtResultados
|
||||
' TmpDTconceptos.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
|
||||
' GvPS.DataSource = TmpDTconceptos
|
||||
' GvPS.DataBind()
|
||||
' End If
|
||||
|
||||
' '' Carga Totales
|
||||
' factura.SubTotal = drv("SubTotal").ToString.ToDecimal
|
||||
' factura.Descuento = drv("Descuento").ToString.ToDecimal
|
||||
' factura.Amortizacion = drv("Amortizacion").ToString.ToDecimal
|
||||
' factura.IVA = drv("IVA").ToString.ToDecimal
|
||||
' factura.RetIVA = drv("RetIVA").ToString.ToDecimal
|
||||
' factura.RetISR = drv("RetISR").ToString.ToDecimal
|
||||
' factura.Total = drv("Total").ToString.ToDecimal
|
||||
' factura.MotivoDescuento = drv("MotivoDescuento").ToString
|
||||
' factura.Observaciones = drv("Observaciones").ToString
|
||||
' factura.CveMoneda = drv("CveMoneda").ToString.ToEntero
|
||||
' factura.TipoCambio = drv("TipoCambio").ToString.ToDecimal
|
||||
' factura.CveVendedor = drv("CveVendedor").ToString.ToEntero
|
||||
' factura.RefDocto = drv("Ref").ToString
|
||||
|
||||
' If factura.CveCliente > 0 Then
|
||||
' If Not IsNothing(TmpDTconceptos) AndAlso TmpDTconceptos.Rows.Count > 0 Then
|
||||
|
||||
' If Not drv("Total").ToString.ToDecimal = factura.Total Then
|
||||
' Return Nothing
|
||||
' End If
|
||||
|
||||
|
||||
|
||||
' End If
|
||||
' End If
|
||||
' End If
|
||||
' End If
|
||||
|
||||
' If Obj.Count > 0 Then
|
||||
' Return Obj
|
||||
' Else
|
||||
' Return Nothing
|
||||
' End If
|
||||
|
||||
'End Function
|
||||
|
||||
'Private Function PreParaTimbre(Obj As Modelos.Factura, CveSubProyecto As Integer) As CFDITimbre
|
||||
|
||||
' Dim Timbre As New CFDITimbre
|
||||
' Timbre.Comprobante.TipoComprobante = If(Obj.TipoDocto.Contiene("Ing", "Ant"), "I", If(Obj.TipoDocto.Contiene("Egs", "Dev"), "E", ""))
|
||||
' Timbre.Comprobante.Folio = Obj.Folio.ToString
|
||||
' Timbre.Comprobante.Serie = Obj.Serie
|
||||
' Timbre.Comprobante.Fecha = Obj.Fecha
|
||||
' Timbre.Comprobante.FormadePago = Obj.FormaPagoSAT33
|
||||
' Timbre.Comprobante.CondicionesdePago = Obj.FormaPago33
|
||||
' Timbre.Comprobante.MetodoPago = Obj.ClaveMetodoPagoSAT
|
||||
' Timbre.Comprobante.Subtotal = Obj.SubTotal
|
||||
|
||||
' Timbre.Comprobante.Descuentos = Obj.Descuento
|
||||
' Timbre.Comprobante.Moneda = Obj.MonedaSAT
|
||||
' Timbre.Comprobante.TipoCambio = If(Obj.CveMoneda = 1, "1", Obj.TipoCambio.ToString)
|
||||
' Timbre.Comprobante.Total = Obj.Total
|
||||
|
||||
' Try
|
||||
' Obj.SetSubProyecto(Me)
|
||||
' Timbre.Comprobante.LugarExpedicion = Obj.SubProyecto.CP
|
||||
' Catch ex As Exception
|
||||
|
||||
' End Try
|
||||
|
||||
' Timbre.Comprobante.Confirmacion = ""
|
||||
|
||||
' Timbre.Receptor.RFC = TxtRFC.Text
|
||||
' Timbre.Receptor.Nombre = TxtNombre.Text
|
||||
' Timbre.Receptor.ResidenciaFiscal = ""
|
||||
' Timbre.Receptor.NumeroRegistroTributario = ""
|
||||
' Timbre.Receptor.UsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("UsoCFDI", $"CveUsoCFDI = {DdlUsoCFDI.SelectedValue}")
|
||||
|
||||
' Dim totSubTotal As Decimal = Obj.SubTotal
|
||||
' Dim totIVA As Decimal = Obj.IVA
|
||||
' Dim totRetIVA As Decimal = Obj.RetIVA
|
||||
' Dim totRetISR As Decimal = Obj.RetISR
|
||||
' Dim TasaRetIVA As Decimal = 0
|
||||
' Dim TasaRetISR As Decimal = 0
|
||||
' Dim i As Integer = 1
|
||||
|
||||
' ''detalles
|
||||
' Dim tPS As String = ""
|
||||
|
||||
' For Each drr As DataRow In Obj.DtDetalle.Rows
|
||||
' If drr("PS").ToString.Length = 1 Then
|
||||
' tPS = drr("Obs").ToString
|
||||
' Else
|
||||
' If drr("PS").ToString.Length = 0 Then
|
||||
' tPS = ""
|
||||
' Else
|
||||
' tPS = String.Format("{0} {1}", drr("PS"), drr("Obs"))
|
||||
' End If
|
||||
' End If
|
||||
' '' condicionante, especial
|
||||
' If UsuarioActual.CveEmpresa = 15 Then drr("UM") = "" ' les comentan que no debe de ir la etiqueta de "unidad" en el producto
|
||||
|
||||
' Dim concepto As New CFDIConceptos With {.Cantidad = drr("Cantidad").ToString.ToDecimal,
|
||||
' .Descripcion = tPS,
|
||||
' .ValorUnitario = drr("PU").ToString.ToDecimal,
|
||||
' .Importe = drr("TotalImporte").ToString.ToDecimal,
|
||||
' .Descuento = drr("Descuento").ToString.ToDecimal,
|
||||
' .Unidad = drr("UM").ToString,
|
||||
' .ClaveUnidad = drr("SATClaveUM").ToString,
|
||||
' .ClaveProdServ = drr("SATClaveProdServ").ToString,
|
||||
' .Noidentificacion = drr("Noidentificacion").ToString,
|
||||
' .CuentaPredial = drr("CuentaPredial").ToString}
|
||||
' '' verifica suma subtotales
|
||||
' If i = Obj.DtDetalle.Rows.Count AndAlso totSubTotal <> concepto.Importe Then 'proceso de ajusta de decimales
|
||||
' concepto.Importe = totSubTotal
|
||||
' End If
|
||||
' totSubTotal = totSubTotal - concepto.Importe
|
||||
|
||||
' ''siempre estaremos agregando el iva, auqnue sea en importe cero o tasa cero, para que se emita la factura
|
||||
' If drr("ImporteIVA").ToString.ToDouble > 0 Then
|
||||
' concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeIVA").ToString.ToDecimal, .Impuesto = "002", .Importe = drr("ImporteIVA").ToString.ToDecimal})
|
||||
' End If
|
||||
|
||||
' If drr("ImporteIEPS").ToString.ToDouble > 0 Then
|
||||
' concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeIEPS").ToString.ToDecimal, .Impuesto = "003", .Importe = drr("ImporteIEPS").ToString.ToDecimal})
|
||||
' End If
|
||||
|
||||
' If drr("ImporteRetIVA").ToString.ToDouble > 0 Then 'si hay retenciones
|
||||
' concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "R", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = TasaRetIVA, .Impuesto = "002", .Importe = drr("ImporteRetIVA").ToString.ToDecimal})
|
||||
' End If
|
||||
|
||||
' If drr("ImporteRetISR").ToString.ToDouble > 0 Then 'retención de ISR
|
||||
' concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "R", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = TasaRetISR, .Impuesto = "001", .Importe = drr("ImporteRetISR").ToString.ToDecimal})
|
||||
' End If
|
||||
|
||||
' Timbre.Conceptos.Add(concepto)
|
||||
' i += 1
|
||||
' Next
|
||||
|
||||
' Dim AplicaComercioExteriorSubProyecto As Boolean = If(GlobalDTSubProyectos(-1, Obj.CveSubProyecto)(0)("AplicaComercioExterior").ToString = "True", True, False)
|
||||
' Timbre.Complementos.ComercioExterior11.AplicaComercioExteriorSubProyecto = AplicaComercioExteriorSubProyecto
|
||||
|
||||
' If Obj.Cliente.AplicaComercioExterior And AplicaComercioExteriorSubProyecto Then
|
||||
|
||||
' Timbre.Receptor.ResidenciaFiscal = Obj.Cliente.ClaveSATPais
|
||||
' Timbre.Receptor.NumeroRegistroTributario = Obj.Cliente.NumRegIdTrib
|
||||
|
||||
' End If
|
||||
|
||||
' Return Timbre
|
||||
'End Function
|
||||
|
||||
End Function
|
||||
|
||||
'Private Function GenerarNotaCredito(CvePS As Integer, Tipo As Integer, CveUnidadMedida As Integer, Importe As Decimal, Iva As Decimal, Descripcion As String, CveClasificacion As Integer) As Boolean
|
||||
|
||||
' Dim Respuesta As Boolean = False
|
||||
|
||||
' Dim ObjVentas As New ClsVentas
|
||||
' Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL())
|
||||
' Dim ObjAcum As New ClsAcumuladores(ObjVentas.IniciaTransacSQL())
|
||||
|
||||
' Dim ErrorVentas As Boolean = False
|
||||
' Dim SubTotal As Decimal = Importe
|
||||
' Dim Total As Decimal = Importe + Iva
|
||||
|
||||
' Dim RetIVA As Decimal = 0
|
||||
' Dim RetISR As Decimal = 0
|
||||
' Dim TipoCambio As Decimal = 0
|
||||
' Dim FechaVencimiento As Date = Now
|
||||
' Dim fecha As Date = Now
|
||||
|
||||
' Dim Folio As Integer = 0
|
||||
' Dim Serie As String = ""
|
||||
|
||||
' If FolioNotaCredito() Then
|
||||
' Folio = FolioNotaAcumulador
|
||||
' Serie = SerieNotaAcumulador
|
||||
' End If
|
||||
|
||||
' Dim CveSubProyecto As Integer = DdlSubProyecto.SelectedValue.ToEntero
|
||||
|
||||
' Dim CveVenta As Integer
|
||||
|
||||
' If Folio > 0 Then
|
||||
|
||||
' Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas($"Clientes/{Descripcion}", 1, Total, Total, 1, fecha, "Nota de crédito por Cargo", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||
|
||||
' If ObjVentas.AddVenta("Egs", Folio, CveCliente.ToEntero, -1, SubTotal, 0, 0, Iva, RetIVA, RetISR, Total, 1, TipoCambio,
|
||||
' 0, 0, 0, FechaVencimiento, fecha, "", "", fecha, -1, "", "", "", 0, 0, 0, "-1".ToDate, "-1".ToDate, "-1".ToDate, -1, -1, 0, CvePrePoliza,
|
||||
' UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Serie:=Serie, CveSubProyecto:=CveSubProyecto, CveSubProyectoEjecucion:=CveSubProyecto) Then
|
||||
|
||||
' CveVenta = ObjVentas.CveVenta
|
||||
|
||||
' If CveVenta > 0 Then
|
||||
' If ObjVentas.AddVentaDetalle(CveVenta, CvePS, 1, CveUnidadMedida, SubTotal, 0.16, SubTotal * 0.16, Descripcion, 0, 0, -1, 0) Then
|
||||
|
||||
' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, SubTotal, Folio.ToString, 150, String.Format("{0}-{1}", Serie, Folio), fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveClasificacion:=CveClasificacion, ImporteMX:=SubTotal, CveSubProyecto:=CveSubProyecto) Then
|
||||
' ErrorVentas = True
|
||||
' End If
|
||||
' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total, Folio.ToString, 12, String.Format("{0}-{1}", Serie, Folio), fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=Total) Then
|
||||
' ErrorVentas = True
|
||||
' End If
|
||||
' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Iva, Folio.ToString, 13, String.Format("{0}-{1}", Serie, Folio), fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=Iva) Then
|
||||
' ErrorVentas = True
|
||||
' End If
|
||||
|
||||
' If Not ErrorVentas Then
|
||||
' For Each GvRow As GridViewRow In GvAcum.Rows
|
||||
' Dim CveMovto As Integer = GvRow.DataKey("CveMovto").ToEntero
|
||||
|
||||
' If (Tipo = 1 And GvRow.FCCheckBox("ChkCargo").Checked) Or (Tipo = 2 And GvRow.FCCheckBox("ChkBonificacion").Checked) Then
|
||||
|
||||
' If ObjAcum.DistribuidorActualizarFacturados(CveMovto, UsuarioActual.CveEmpresa, Tipo, CveVenta) Then
|
||||
' Respuesta = True
|
||||
' ErrorVentas = False
|
||||
' CveVentaNota = CveVenta
|
||||
' Else
|
||||
' Respuesta = False
|
||||
' ErrorVentas = True
|
||||
' CveVentaNota = 0
|
||||
' Exit For
|
||||
' End If
|
||||
|
||||
' End If
|
||||
' Next
|
||||
' End If
|
||||
|
||||
|
||||
' If Not ErrorVentas Then
|
||||
' Alert($"Nota de crédito generada correctamente <a href='./Ventas.aspx?CveVenta={CveVenta}' >{Serie}-{Folio}</a>")
|
||||
' End If
|
||||
|
||||
|
||||
' Else
|
||||
' ErrorVentas = True
|
||||
' End If
|
||||
' Else
|
||||
' ErrorVentas = True
|
||||
' End If
|
||||
|
||||
' Else
|
||||
' ErrorVentas = True
|
||||
' End If
|
||||
' Else
|
||||
' Alert("No se pudo obtener el Folio.", TipoMensaje.MsgError)
|
||||
' End If
|
||||
|
||||
|
||||
|
||||
' If ErrorVentas Then
|
||||
' ObjVentas.RollBack()
|
||||
' Else
|
||||
|
||||
' ObjVentas.Commit()
|
||||
' CargaUsados()
|
||||
|
||||
' Dim DtDetallesVenta As New DataTable
|
||||
|
||||
' If ObjVentas.GetVentaDetalle(CveVenta) Then
|
||||
|
||||
' DtDetallesVenta = ObjVentas.DtResultados
|
||||
' 'CreaObjetosVenta(CveVenta, Serie, Folio, SubTotal, Iva, DtDetallesVenta)
|
||||
|
||||
' ObjFactura.Timbre = PreParaTimbre(ObjFactura, ObjFactura.CveSubProyecto)
|
||||
|
||||
' Dim ObjTimbrado As New Timbrado
|
||||
' Dim SeTimbro As Boolean = False
|
||||
|
||||
' SeTimbro = ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura)
|
||||
|
||||
' If SeTimbro Then
|
||||
' Alert("Se timbro correctamente")
|
||||
' Else
|
||||
' Alert("No se pudo timbrar, intente mas tarde.", TipoMensaje.MsgError)
|
||||
' End If
|
||||
|
||||
' Else
|
||||
' Alert("No se pudo timbrar, no se pudieron obtener los detalles de la venta.", TipoMensaje.MsgError)
|
||||
' End If
|
||||
|
||||
' End If
|
||||
|
||||
|
||||
|
||||
' ObjVentas.Dispose()
|
||||
' Return Respuesta
|
||||
|
||||
'End Function
|
||||
'Private Function generaNC(CveVenta As Integer, ByRef ObjVentas As ClsVentas, ByVal factura As Modelos.Factura) As List(Of Object)
|
||||
|
||||
' Dim Obj As New List(Of Object)
|
||||
' Dim CveVentaNueva As Integer = ObjVentas.CveVenta
|
||||
' Dim BanderaGeneraNC As Boolean = False
|
||||
' If UsuarioActual.CveEmpresa.Contiene(1, 119) Then BanderaGeneraNC = True
|
||||
|
||||
' If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then
|
||||
' If ObjVentas.DtResultados IsNot Nothing AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then
|
||||
' Dim drv As DataRow = ObjVentas.DtResultados.Rows(0)
|
||||
' Dim TmpDTconceptos As DataTable = Nothing
|
||||
|
||||
' ''CargaCliente
|
||||
|
||||
' Dim CveCliente As Integer = drv("CveCliente").ToString.ToEntero
|
||||
' If UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 77 AndAlso Not CveCliente.Contiene(10450, 10460, 10458) Then
|
||||
' Return Nothing
|
||||
' ElseIf UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 21 AndAlso Not CveCliente.Contiene(27448) Then
|
||||
' Return Nothing
|
||||
' End If
|
||||
' factura.TipoDocto = drv("TipoDocto").ToString
|
||||
' factura.Serie = drv("Serie").ToString
|
||||
' factura.FechaEjecucion = drv("FechaEjecucion").ToString.ToDateTime
|
||||
' factura.Fecha = drv("Fecha").ToString.ToDateTime
|
||||
' factura.CveSubProyectoEjecucion = drv("CveSubProyectoEjecucion").ToString.ToEntero
|
||||
' factura.CveSubProyectoCobranza = drv("CveSubProyectoCobranza").ToString.ToEntero
|
||||
' factura.CveClienteSucursal = drv("CveClienteSucursal").ToString.ToEntero
|
||||
' factura.CveSubProyecto = drv("CveSubProyecto").ToString.ToEntero
|
||||
|
||||
|
||||
' ''CargaDetalle
|
||||
' If ObjVentas.GetVentaDetalle(CveVenta) Then
|
||||
' TmpDTconceptos = ObjVentas.DtResultados
|
||||
' TmpDTconceptos.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
|
||||
' GvPS.DataSource = TmpDTconceptos
|
||||
' GvPS.DataBind()
|
||||
' End If
|
||||
|
||||
' '' Carga Totales
|
||||
' factura.SubTotal = drv("SubTotal").ToString.ToDecimal
|
||||
' factura.Descuento = drv("Descuento").ToString.ToDecimal
|
||||
' factura.Amortizacion = drv("Amortizacion").ToString.ToDecimal
|
||||
' factura.IVA = drv("IVA").ToString.ToDecimal
|
||||
' factura.RetIVA = drv("RetIVA").ToString.ToDecimal
|
||||
' factura.RetISR = drv("RetISR").ToString.ToDecimal
|
||||
' factura.Total = drv("Total").ToString.ToDecimal
|
||||
' factura.MotivoDescuento = drv("MotivoDescuento").ToString
|
||||
' factura.Observaciones = drv("Observaciones").ToString
|
||||
' factura.CveMoneda = drv("CveMoneda").ToString.ToEntero
|
||||
' factura.TipoCambio = drv("TipoCambio").ToString.ToDecimal
|
||||
' factura.CveVendedor = drv("CveVendedor").ToString.ToEntero
|
||||
' factura.RefDocto = drv("Ref").ToString
|
||||
|
||||
' If factura.CveCliente > 0 Then
|
||||
' If Not IsNothing(TmpDTconceptos) AndAlso TmpDTconceptos.Rows.Count > 0 Then
|
||||
|
||||
' If Not drv("Total").ToString.ToDecimal = factura.Total Then
|
||||
' Return Nothing
|
||||
' End If
|
||||
|
||||
|
||||
|
||||
' End If
|
||||
' End If
|
||||
' End If
|
||||
' End If
|
||||
|
||||
' If Obj.Count > 0 Then
|
||||
' Return Obj
|
||||
' Else
|
||||
' Return Nothing
|
||||
' End If
|
||||
|
||||
'End Function
|
||||
|
||||
'Private Function PreParaTimbre(Obj As Modelos.Factura, CveSubProyecto As Integer) As CFDITimbre
|
||||
|
||||
' Dim Timbre As New CFDITimbre
|
||||
' Timbre.Comprobante.TipoComprobante = If(Obj.TipoDocto.Contiene("Ing", "Ant"), "I", If(Obj.TipoDocto.Contiene("Egs", "Dev"), "E", ""))
|
||||
' Timbre.Comprobante.Folio = Obj.Folio.ToString
|
||||
' Timbre.Comprobante.Serie = Obj.Serie
|
||||
' Timbre.Comprobante.Fecha = Obj.Fecha
|
||||
' Timbre.Comprobante.FormadePago = Obj.FormaPagoSAT33
|
||||
' Timbre.Comprobante.CondicionesdePago = Obj.FormaPago33
|
||||
' Timbre.Comprobante.MetodoPago = Obj.ClaveMetodoPagoSAT
|
||||
' Timbre.Comprobante.Subtotal = Obj.SubTotal
|
||||
|
||||
' Timbre.Comprobante.Descuentos = Obj.Descuento
|
||||
' Timbre.Comprobante.Moneda = Obj.MonedaSAT
|
||||
' Timbre.Comprobante.TipoCambio = If(Obj.CveMoneda = 1, "1", Obj.TipoCambio.ToString)
|
||||
' Timbre.Comprobante.Total = Obj.Total
|
||||
|
||||
' Try
|
||||
' Obj.SetSubProyecto(Me)
|
||||
' Timbre.Comprobante.LugarExpedicion = Obj.SubProyecto.CP
|
||||
' Catch ex As Exception
|
||||
|
||||
' End Try
|
||||
|
||||
' Timbre.Comprobante.Confirmacion = ""
|
||||
|
||||
' Timbre.Receptor.RFC = TxtRFC.Text
|
||||
' Timbre.Receptor.Nombre = TxtNombre.Text
|
||||
' Timbre.Receptor.ResidenciaFiscal = ""
|
||||
' Timbre.Receptor.NumeroRegistroTributario = ""
|
||||
' Timbre.Receptor.UsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("UsoCFDI", $"CveUsoCFDI = {DdlUsoCFDI.SelectedValue}")
|
||||
|
||||
' Dim totSubTotal As Decimal = Obj.SubTotal
|
||||
' Dim totIVA As Decimal = Obj.IVA
|
||||
' Dim totRetIVA As Decimal = Obj.RetIVA
|
||||
' Dim totRetISR As Decimal = Obj.RetISR
|
||||
' Dim TasaRetIVA As Decimal = 0
|
||||
' Dim TasaRetISR As Decimal = 0
|
||||
' Dim i As Integer = 1
|
||||
|
||||
' ''detalles
|
||||
' Dim tPS As String = ""
|
||||
|
||||
' For Each drr As DataRow In Obj.DtDetalle.Rows
|
||||
' If drr("PS").ToString.Length = 1 Then
|
||||
' tPS = drr("Obs").ToString
|
||||
' Else
|
||||
' If drr("PS").ToString.Length = 0 Then
|
||||
' tPS = ""
|
||||
' Else
|
||||
' tPS = String.Format("{0} {1}", drr("PS"), drr("Obs"))
|
||||
' End If
|
||||
' End If
|
||||
' '' condicionante, especial
|
||||
' If UsuarioActual.CveEmpresa = 15 Then drr("UM") = "" ' les comentan que no debe de ir la etiqueta de "unidad" en el producto
|
||||
|
||||
' Dim concepto As New CFDIConceptos With {.Cantidad = drr("Cantidad").ToString.ToDecimal,
|
||||
' .Descripcion = tPS,
|
||||
' .ValorUnitario = drr("PU").ToString.ToDecimal,
|
||||
' .Importe = drr("TotalImporte").ToString.ToDecimal,
|
||||
' .Descuento = drr("Descuento").ToString.ToDecimal,
|
||||
' .Unidad = drr("UM").ToString,
|
||||
' .ClaveUnidad = drr("SATClaveUM").ToString,
|
||||
' .ClaveProdServ = drr("SATClaveProdServ").ToString,
|
||||
' .Noidentificacion = drr("Noidentificacion").ToString,
|
||||
' .CuentaPredial = drr("CuentaPredial").ToString}
|
||||
' '' verifica suma subtotales
|
||||
' If i = Obj.DtDetalle.Rows.Count AndAlso totSubTotal <> concepto.Importe Then 'proceso de ajusta de decimales
|
||||
' concepto.Importe = totSubTotal
|
||||
' End If
|
||||
' totSubTotal = totSubTotal - concepto.Importe
|
||||
|
||||
' ''siempre estaremos agregando el iva, auqnue sea en importe cero o tasa cero, para que se emita la factura
|
||||
' If drr("ImporteIVA").ToString.ToDouble > 0 Then
|
||||
' concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeIVA").ToString.ToDecimal, .Impuesto = "002", .Importe = drr("ImporteIVA").ToString.ToDecimal})
|
||||
' End If
|
||||
|
||||
' If drr("ImporteIEPS").ToString.ToDouble > 0 Then
|
||||
' concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeIEPS").ToString.ToDecimal, .Impuesto = "003", .Importe = drr("ImporteIEPS").ToString.ToDecimal})
|
||||
' End If
|
||||
|
||||
' If drr("ImporteRetIVA").ToString.ToDouble > 0 Then 'si hay retenciones
|
||||
' concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "R", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = TasaRetIVA, .Impuesto = "002", .Importe = drr("ImporteRetIVA").ToString.ToDecimal})
|
||||
' End If
|
||||
|
||||
' If drr("ImporteRetISR").ToString.ToDouble > 0 Then 'retención de ISR
|
||||
' concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "R", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = TasaRetISR, .Impuesto = "001", .Importe = drr("ImporteRetISR").ToString.ToDecimal})
|
||||
' End If
|
||||
|
||||
' Timbre.Conceptos.Add(concepto)
|
||||
' i += 1
|
||||
' Next
|
||||
|
||||
' Dim AplicaComercioExteriorSubProyecto As Boolean = If(GlobalDTSubProyectos(-1, Obj.CveSubProyecto)(0)("AplicaComercioExterior").ToString = "True", True, False)
|
||||
' Timbre.Complementos.ComercioExterior11.AplicaComercioExteriorSubProyecto = AplicaComercioExteriorSubProyecto
|
||||
|
||||
' If Obj.Cliente.AplicaComercioExterior And AplicaComercioExteriorSubProyecto Then
|
||||
|
||||
' Timbre.Receptor.ResidenciaFiscal = Obj.Cliente.ClaveSATPais
|
||||
' Timbre.Receptor.NumeroRegistroTributario = Obj.Cliente.NumRegIdTrib
|
||||
|
||||
' End If
|
||||
|
||||
' Return Timbre
|
||||
'End Function
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "C L I E N T E S G R I D S I M P R I M I R P D F/Excel"
|
||||
Private Sub LnkCotizacionesPDF_Click(sender As Object, e As EventArgs) Handles LnkCotizacionesPDF.Click
|
||||
ImprimeGridsProveedores("PDF", DTCobrosRealizados, "RepClientesCotizaciones")
|
||||
End Sub
|
||||
Private Sub LnkCotizacionesExcel_Click(sender As Object, e As EventArgs) Handles LnkCotizacionesExcel.Click
|
||||
ImprimeGridsProveedores("Excel", DTCobrosRealizados, "RepClientesCotizaciones")
|
||||
End Sub
|
||||
|
||||
Private Sub LnkCxCActivasPDF_Click(sender As Object, e As EventArgs) Handles LnkCxCActivasPDF.Click
|
||||
ImprimeGridsProveedores("PDF", DTCobrosRealizados, "RepClientesCotizaciones")
|
||||
End Sub
|
||||
Private Sub LnkCxCActivasExcel_Click(sender As Object, e As EventArgs) Handles LnkCxCActivasExcel.Click
|
||||
ImprimeGridsProveedores("Excel", DTCobrosRealizados, "RepClientesCotizaciones")
|
||||
End Sub
|
||||
|
||||
Private Sub LnkHistorialCxCPDF_Click(sender As Object, e As EventArgs) Handles LnkHistorialCxCPDF.Click
|
||||
ImprimeGridsProveedores("PDF", DTCobrosRealizados, "RepClientesCotizaciones")
|
||||
End Sub
|
||||
Private Sub LnkHistorialCxCExcel_Click(sender As Object, e As EventArgs) Handles LnkHistorialCxCExcel.Click
|
||||
ImprimeGridsProveedores("Excel", DTCobrosRealizados, "RepClientesCotizaciones")
|
||||
End Sub
|
||||
|
||||
Private Sub LnkAnticipoClientePDF_Click(sender As Object, e As EventArgs) Handles LnkAnticipoClientePDF.Click
|
||||
ImprimeGridsProveedores("PDF", DTCobrosRealizados, "RepClientesCotizaciones")
|
||||
End Sub
|
||||
Private Sub LnkAnticipoClienteExcel_Click(sender As Object, e As EventArgs) Handles LnkAnticipoClienteExcel.Click
|
||||
ImprimeGridsProveedores("Excel", DTCobrosRealizados, "RepClientesCotizaciones")
|
||||
End Sub
|
||||
|
||||
Private Sub LnkAnticipoHistorialPDF_Click(sender As Object, e As EventArgs) Handles LnkAnticipoHistorialPDF.Click
|
||||
ImprimeGridsProveedores("PDF", DTCobrosRealizados, "RepClientesCotizaciones")
|
||||
End Sub
|
||||
Private Sub LnkAnticipoHistorialExcel_Click(sender As Object, e As EventArgs) Handles LnkAnticipoHistorialExcel.Click
|
||||
ImprimeGridsProveedores("Excel", DTCobrosRealizados, "RepClientesCotizaciones")
|
||||
End Sub
|
||||
|
||||
Private Sub LnkCuentasBancariasPDF_Click(sender As Object, e As EventArgs) Handles LnkCuentasBancariasPDF.Click
|
||||
ImprimeGridsProveedores("PDF", DTCobrosRealizados, "RepClientesCotizaciones")
|
||||
End Sub
|
||||
Private Sub LnkCuentasBancariasExcel_Click(sender As Object, e As EventArgs) Handles LnkCuentasBancariasExcel.Click
|
||||
ImprimeGridsProveedores("Excel", DTCobrosRealizados, "RepClientesCotizaciones")
|
||||
End Sub
|
||||
|
||||
Private Sub ImprimeGridsProveedores(Formato As String, DtTemp As DataTable, NombreFormato As String)
|
||||
If DtTemp IsNot Nothing And DtTemp.Rows.Count > 0 Then
|
||||
Dim params As New List(Of ReportParameter)
|
||||
|
||||
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
|
||||
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
|
||||
|
||||
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
||||
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
||||
params.Add(New ReportParameter("AgrupadoPor", "Cliente: " & LtlCliente.Text))
|
||||
|
||||
If Imagen.Exists Then
|
||||
params.Add(New ReportParameter("LogoPath", logouri))
|
||||
Else
|
||||
params.Add(New ReportParameter("LogoPath", ""))
|
||||
End If
|
||||
ImprimirPDF("Empresas\Grales\Formatos\" & NombreFormato & ".rdlc", DtTemp, params, NombreFormato & "_" & Now.ToString("yyyyMMddhhmmss"), Formato:=Formato)
|
||||
Else
|
||||
Alert("No se encontró información.", TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
|
||||
Reference in New Issue
Block a user