From b607b5aad7875e9a5e58d29f367d19ffcc65a77e Mon Sep 17 00:00:00 2001 From: rrene Date: Wed, 27 Sep 2023 07:16:58 -0700 Subject: [PATCH] -option explciit --- Ventas/Ventas.aspx | 2 +- Ventas/Ventas.aspx.vb | 390 ++++-------------------------------------- 2 files changed, 39 insertions(+), 353 deletions(-) diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 37b4b57f8..6c126fd2d 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -5367,7 +5367,7 @@ - + diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index ea724257f..43d6fe095 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -3795,13 +3795,11 @@ Partial Class Ventas End If - If UsuarioActual.CveEmpresa = 13 Then DivEstimaciones.Visible = True GvEst.Visible = False ContratoDetalles.Visible = False GvContratoDetalles.Visible = True - BtnEstimacion.Visible = False End If @@ -3820,7 +3818,7 @@ Partial Class Ventas End Sub Private Sub CargaContratos() - Dim DrContrato = DtContratos.FiltroPrimero($"CveContrato = {DdlContratosModal.SelectedValue}") + Dim DrContrato As DataRow = DtContratos.FiltroPrimero($"CveContrato = {DdlContratosModal.SelectedValue}") If DrContrato Is Nothing Then Alert("Ocurrió un error al cargar la configuración del contrato. Por favor vuelva a intentar", TipoMensaje.MsgError) Exit Sub @@ -3834,11 +3832,6 @@ Partial Class Ventas EscontratoObra = False End If - - - - - LbContratoImporteTotal.Text = DrContrato("ImporteTotal").ToString().FormatoNumero LbContratoImporteMinimo.Text = DrContrato("ImporteMin").ToString().FormatoNumero LbContratoImporteMaximo.Text = DrContrato("ImporteMax").ToString().FormatoNumero @@ -3938,14 +3931,14 @@ Partial Class Ventas For Each gvr As GridViewRow In GvContratoDetalles.Rows gvr.FCTextBox("TxtCant").Enabled = False Next - Dim EsValido = True + Dim EsValido As Boolean = True For Each Dr As DataRow In TmpDT.Rows - Dim CantidadActual = Dr("Cantidad").ToString().ToDouble - Dim CantidadDispo = 0.0 - Dim CantidadAsignada = 0.0 + Dim CantidadActual As Decimal = Dr("Cantidad").ToString().ToDecimal + Dim CantidadDispo As Decimal = 0 + Dim CantidadAsignada As Decimal = 0 For Each gvr As GridViewRow In GvContratoDetalles.Rows If gvr.DataKey("CvePS").ToEntero() = Dr("CvePS").ToString().ToEntero() Then - CantidadDispo = gvr.DataKey("Cantidad").ToString().ToDouble - gvr.FCTextBox("TxtCant").Text.ToDouble + CantidadDispo = gvr.DataKey("Cantidad").ToString().ToDecimal - gvr.FCTextBox("TxtCant").Text.ToDecimal If CantidadDispo = 0 Then Continue For CantidadAsignada = If(CantidadDispo > CantidadActual, CantidadActual, CantidadDispo) gvr.FCTextBox("TxtCant").Text = (gvr.FCTextBox("TxtCant").Text.ToDouble + CantidadAsignada).ToString() @@ -4066,7 +4059,7 @@ Partial Class Ventas AplicaGastoContrato = If(DrContrato("CveContratoTipo").ToString().Contiene("9", "10", "13"), True, False) 'Arrendamiento, Servicios De Impresion, Financiamiento 'VALIDA IMPORTE DEL CONTRATO - Dim SeleccionadoContrato = 0.0 '(From row As GridViewRow In GvContratoDetalles.Rows.Cast(Of GridViewRow)() Select row.FCLabel("LtlTotal").Text.ToDecimal).Sum + Dim SeleccionadoContrato As Decimal = 0 '(From row As GridViewRow In GvContratoDetalles.Rows.Cast(Of GridViewRow)() Select row.FCLabel("LtlTotal").Text.ToDecimal).Sum TmpDT.Clear() TxtSubTotal.Text = "0" @@ -4080,7 +4073,7 @@ Partial Class Ventas 'VALIDA EXISTENCIAS DE ALMACÉN 'Dim DrPS = GlobalDTProductosServicios(CveEmpresa:=UsuarioActual.CveEmpresa, CvePS:=Row.DataKey("CvePS").ToEntero()).FiltroPrimero("") - Dim DrPS = GlobalDTPSSimplificado(CveEmpresa:=UsuarioActual.CveEmpresa, CvePS:=Row.DataKey("CvePS").ToEntero()).FiltroPrimero("") + Dim DrPS As DataRow = GlobalDTPSSimplificado(CveEmpresa:=UsuarioActual.CveEmpresa, CvePS:=Row.DataKey("CvePS").ToEntero()).FiltroPrimero("") If DrPS IsNot Nothing Then Dim CveTipoPS As Integer = DrPS("CveTipoPS").ToString().ToEntero() @@ -4097,7 +4090,7 @@ Partial Class Ventas Dim ObsPlantilla As String = PlantillaContrato(Row.DataKey("Observaciones")) - SeleccionadoContrato += Row.FCTextBox("TxtCant").Text.ToEntero() * Row.FCLiteral("LtlPU").Text.ToDouble + SeleccionadoContrato += Row.FCTextBox("TxtCant").Text.ToEntero() * Row.FCLiteral("LtlPU").Text.ToDecimal AgregarProductoServicio(Row.FCTextBox("TxtCant").Text.ToEntero(), Row.DataKey("CveUM").ToEntero(), Row.FCLiteral("LtlUM").Text, Row.DataKey("CveClasificacion").ToEntero(), Row.DataKey("Clasificacion"), Row.DataKey("CvePS").ToEntero(), Row.FCLiteral("LtlPS").Text, If(CveCicloComercial > 0, ObsPlantilla, $"/ {Row.FCLiteral("LtCveInterna").Text}"), Row.FCLiteral("LtlPU").Text.ToDecimal, 0, DrContrato("CveProyecto").ToString().ToEntero(), DrContrato("ProyectoContrato").ToString(), DrContrato("CveSubProyecto").ToString().ToEntero(), DrContrato("SubProyectoContrato").ToString(), CveContratoDetalle:=Row.DataKey("CveContratoDetalle").ToEntero()) @@ -4202,7 +4195,7 @@ Partial Class Ventas If ObjContratos.GetContratos(CveContrato, UsuarioActual.CveEmpresa, -1, -1, 1) Then If ObjContratos.DtResultados.Rows.Count > 0 Then - Dim CveContratoTipo = ObjContratos.DtResultados.Rows(0)("CveContratoTipo").ToString.ToEntero + Dim CveContratoTipo As Integer = ObjContratos.DtResultados.Rows(0)("CveContratoTipo").ToString.ToEntero 'Cargamos los datos del Cliente DtContratos = ObjContratos.DtResultados @@ -4267,7 +4260,7 @@ Partial Class Ventas RequiereAlmacenOrigen = True If CveContratoTipo.Contiene(7, 9, 13, 21, 27) Then - Dim CveTipoAlmacenOrigen = "12,15" + Dim CveTipoAlmacenOrigen As String = "12,15" If CveContratoTipo.Contiene(27) Then CveTipoAlmacenOrigen = "1" End If @@ -4341,7 +4334,7 @@ Partial Class Ventas Private Sub GvContratoDetalles_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvContratoDetalles.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then - Dim CantidadDisponible = If(e.Row.DBCampo("Cantidad").ToDouble < 0, "0", e.Row.DBCampo("Cantidad")) + Dim CantidadDisponible As String = If(e.Row.DBCampo("Cantidad").ToDouble < 0, "0", e.Row.DBCampo("Cantidad")) e.Row.FCLiteral("LtlCantDisp").Text = CantidadDisponible If CveCicloComercial > 0 Then 'Si es un Ciclo Comercial quitamos el límite de CantidadDisponible @@ -4394,7 +4387,7 @@ Partial Class Ventas Exit Sub End If - Dim DrContrato = DtContratos.FiltroPrimero($"CveContrato = {DdlContratosModal.SelectedValue}") + Dim DrContrato As DataRow = DtContratos.FiltroPrimero($"CveContrato = {DdlContratosModal.SelectedValue}") If DrContrato Is Nothing Then Alert("Ocurrió un error al cargar la configuración del contrato. Por favor vuelva a intentar", TipoMensaje.MsgError) Exit Sub @@ -6060,7 +6053,7 @@ Partial Class Ventas If UsuarioActual.CveRol = 1 AndAlso CveMetodoPago = 1 AndAlso DdlTipoComprobante.SelectedValue = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso TbDescuentosAdicionales.Visible Then If TmpDT.SUMD("Descuento") > 0 Then Dim TotalDescuento As Decimal = TmpDT.SUMD("Total", "Descuento > 0") * 0.05D - Dim RowDescuentos = TmpDT.Select("Descuento > 0") + Dim RowDescuentos As DataRow() = TmpDT.Select("Descuento > 0") If RowDescuentos IsNot Nothing Then LblDescuentoAdicional.Text = TotalDescuento.FormatoNumero(2) @@ -6779,7 +6772,7 @@ Partial Class Ventas If RequiereOC Then Dim Documentacion As String = "" 'RegistraScript("$('#DivDocsCliente').modal({ backdrop: 'static', keyboard: false });", "ModalArchivos") - Dim Count = 0 + Dim Count As Integer = 0 For Each GvRow As GridViewRow In GvDocumentosCliente.Rows If GvRow.DataKey("Orden").ToEntero() = 1 Then IndexDocumentoCliente = Count @@ -8358,7 +8351,7 @@ Partial Class Ventas If UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso ListaDescuentos IsNot Nothing AndAlso ObjDescuento IsNot Nothing Then Dim ConsecEliminar As Integer = TmpDT.Rows(e.RowIndex)("Consec").ToString().ToEntero() If ConsecEliminar > 0 Then - Dim descEliminar = ListaDescuentos.FirstOrDefault(Function(x) x.Consec = ConsecEliminar) + Dim descEliminar As Modelos.VentaDescuentos = ListaDescuentos.FirstOrDefault(Function(x) x.Consec = ConsecEliminar) If descEliminar IsNot Nothing Then ListaDescuentos.Remove(descEliminar) End If @@ -8516,9 +8509,9 @@ Partial Class Ventas Protected Sub GvPS_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvPS.RowDeleting If UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso ListaDescuentos IsNot Nothing Then - Dim ConsecEliminar = TmpDT.Rows(e.RowIndex)("Consec").ToString().ToEntero() + Dim ConsecEliminar As Integer = TmpDT.Rows(e.RowIndex)("Consec").ToString().ToEntero() If ConsecEliminar > 0 Then - Dim descEliminar = ListaDescuentos.FirstOrDefault(Function(x) x.Consec = ConsecEliminar) + Dim descEliminar As Modelos.VentaDescuentos = ListaDescuentos.FirstOrDefault(Function(x) x.Consec = ConsecEliminar) If descEliminar IsNot Nothing Then ListaDescuentos.Remove(descEliminar) End If @@ -8822,13 +8815,12 @@ Partial Class Ventas 'End If Dim EsPersonaMoral As Boolean = Me.TipoPersona - Dim DtUsosCFDI = GlobalDTSATUsosCFDI(If(Not EsPersonaMoral, 1, 0), RegimenFiscalReceptor:=RegimenFiscalCliente).FiltraParametros($"CveUsoCFDI = {DdlUsoCFDI.SelectedValue}") + Dim DtUsosCFDI As DataTable = GlobalDTSATUsosCFDI(If(Not EsPersonaMoral, 1, 0), RegimenFiscalReceptor:=RegimenFiscalCliente).FiltraParametros($"CveUsoCFDI = {DdlUsoCFDI.SelectedValue}") If DtUsosCFDI.Rows.Count = 0 Then Alert("El Uso CFDI no corresponde con el tipo de persona (fisca, moral) y el régimen fiscal.", TipoMensaje.MsgAdvertencia) Exit Sub End If - End If If Not ValidaImportePublicoGeneral() Then @@ -9479,7 +9471,7 @@ Partial Class Ventas CreaObjetosVenta(TipoDoctoViejo:=TipoDoctoViejo) - If ObjFactura Is Nothing Or (ObjFactura.Cliente Is Nothing And Not CveEmpresaCRM > 0) Then + If ObjFactura Is Nothing OrElse (ObjFactura.Cliente Is Nothing And Not CveEmpresaCRM > 0) Then Alert("Ocurrió un error al procesar los datos de la Venta.", TipoMensaje.MsgError) ObjFactura = Nothing Exit Sub @@ -9562,22 +9554,6 @@ Partial Class Ventas End If End If - - 'VERIFICA QUE LA MONEDA DE LA LINEA ADICIONAL SEA LA MISMA QUE LA VENTA - 'If Me.CveMonedaLineaAdicional <> ObjFactura.CveMoneda Then - ' TmpDT = TmpDTError.Copy() - ' CalculaTotalesVenta(RecalcularTotalOriginal:=False) - ' Alert("La moneda de la linea adicional de crédito debe ser la misma que la factura.", TipoMensaje.MsgAdvertencia) - ' Exit Sub - 'Else - ' If ObjFactura.TipoDocto = "Ing" AndAlso Me.SaldoIngresosLineaAdicional < ObjFactura.Total Then - ' TmpDT = TmpDTError.Copy() - ' CalculaTotalesVenta(RecalcularTotalOriginal:=False) - ' Alert("El saldo de la linea adicional debe ser mayor o igual al de la factura", TipoMensaje.MsgAdvertencia) - ' Exit Sub - ' End If - 'End If - 'VERIFICA QUE EL SALDO DISPONIBLE SEA MENOR AL IMPORTE 'If ObjFactura.TipoDocto = "Rem" AndAlso Me.SaldoLineaAdicional < ObjFactura.Total Then ' TmpDT = TmpDTError.Copy() @@ -9595,16 +9571,6 @@ Partial Class Ventas End If - 'If Not CveEmpresaCRM > 0 Then - ' If ObjFactura.Cliente.AplicaComercioExterior Then - ' If Not ValidaComercioExterior() Then - ' ObjFactura = Nothing - ' Exit Sub - ' End If - ' End If - 'End If - - 'VALIDA TOTAL DE LA NOTA DE CREDITO Y LA FACTURA VINCULADA *** ESTABA TRONANDO EN COMPU 11/01/17 *** 'If ObjFactura.TipoDocto.Contiene("Egs", "Dev") Then ' If SubTotalFacturaVinNC() > 0 Then 'pendiente @@ -9657,24 +9623,6 @@ Partial Class Ventas ErrorList = New List(Of String) MensajeAlert = New StringBuilder - 'VERIFICA QUE EL FOLIO NO SEA IGUAL AL DE LA FACTURA ANTERIOR - 'If ObjFactura.Folio = TxtFolio.Text.ToEntero() Then - ' If ObjFolios.GetFolios(ObjFactura.TipoDocto, UsuarioActual.CveEmpresa) Then - ' Dim DtFolios As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format(" CveSucursal = {0} And Estado = 'Activo'", ObjFactura.CveSucursal)) - ' If DtFolios.Rows.Count > 0 Then - ' 'ViewState("CveFolio") = DtFolios.Rows(0)("CveFolio").ToString().ToEntero() - ' 'ViewState("NumAprobacion") = CLng(DtFolios.Rows(0)("Aprobacion").ToString()) - ' 'ViewState("FechaAprobacion") = DtFolios.Rows(0)("FechaAprobacion").ToString().ToDate - ' 'ViewState("FolioActual") = DtFolios.Rows(0)("FActual").ToString() - ' 'LblSerie.Text = DtFolios.Rows(0)("Serie").ToString() - - ' If UsuarioActual.CveEmpresa <> 72 Then - ' ObjFactura.Folio = DtFolios.Rows(0)("FActual").ToString().ToEntero() - ' End If - ' End If - ' End If - 'End If - 'GUARDA VENTA Dim TieneAnticipo As Boolean = False @@ -10055,6 +10003,9 @@ Partial Class Ventas If ObjFactura.CveVenta > 0 AndAlso ErrorList.Count = 0 AndAlso (SeGuardoPrePoliza Or ObjFactura.TipoDocto.Contiene("Ped", "Cot", "DPe", "PeC", "PA", "Pd2")) Then ObjVentas.Commit() + ObjFactura.DtDetalle = TmpDT 'actualiza por cambios de pedimentos. + ObjFactura.Timbre = PreParaTimbre(ObjFactura) + 'ENVIAR POLIZA VIRTUAL If ErrorList.Count = 0 Then If UsuarioActual.Empresa.Funcionalidad(576) = "1" AndAlso EsProduccion Then @@ -10068,11 +10019,11 @@ Partial Class Ventas Dim Titulo As String = "Solicitud de autorización" 'usuarios de crédito y cobranza Dim Msg As String = String.Format("{0} - Folio {1} ", DdlSubProyectoDatos.SelectedItem.Text, TxtFolio.Text) - If UsuarioActual.CveEmpresa = 119 Then - ClsSisNotificaciones.SendNotificacionERP(1715, Titulo, Msg, 1) - ClsSisNotificaciones.SendNotificacionERP(1815, Titulo, Msg, 1) - ClsSisNotificaciones.SendNotificacionERP(1830, Titulo, Msg, 1) - End If + 'If UsuarioActual.CveEmpresa = 119 Then + ' ClsSisNotificaciones.SendNotificacionERP(1715, Titulo, Msg, 1) + ' ClsSisNotificaciones.SendNotificacionERP(1815, Titulo, Msg, 1) + ' ClsSisNotificaciones.SendNotificacionERP(1830, Titulo, Msg, 1) + 'End If End If Catch ex As Exception @@ -11312,9 +11263,7 @@ Partial Class Ventas End If ObjFactura.Version = "4.0" - If ObjFactura.Cliente Is Nothing Then - ObjFactura.Cliente = New Modelos.ClienteModel - End If + If ObjFactura.Cliente Is Nothing Then ObjFactura.Cliente = New Modelos.ClienteModel ObjFactura.Cliente.CodigoRegimenFiscal = ClienteCodigoRegimenFiscal ObjFactura.Cliente.RegimenFiscal = ClienteRegimenFiscal @@ -11331,7 +11280,6 @@ Partial Class Ventas ObjFactura.TipoDocto = If(IfNull(ViewState("CveRemision"), 0).ToString().ToEntero() > 0, "Ing", DdlTipoComprobante.SelectedValue) ObjFactura.FacturarSucursal = (Me.FacturarSucursal AndAlso DdlSucursalCliente.SelectedValue.ToEntero() > 0 AndAlso (Me.ClienteSucursal IsNot Nothing AndAlso Not String.IsNullOrEmpty(Me.ClienteSucursal.RFC))) ObjFactura.VentaDesglosaIEPS = Me.VentaDesglosaIEPS - 'ObjFactura.RefDocto = TxtDocto.Text.Trim If EsCreaApartirDe Then ViewState("EstablecioFolio") = False @@ -11389,19 +11337,9 @@ Partial Class Ventas ObjFactura.UsuarioCreo = LblUsuario.Text.Trim ObjFactura.CveCondicionEntrega = If(DdlFormaEntrega.SelectedItem IsNot Nothing, DdlFormaEntrega.SelectedValue.ToEntero(), -1) ObjFactura.CondicionEntrega = If(DdlFormaEntrega.SelectedItem IsNot Nothing, DdlFormaEntrega.SelectedItem.Text, "") - 'ObjFactura.NumeroCuenta = TxtNumCtaPago.Text.Trim - 'ObjFactura.Cliente.NumCtaPago = TxtNumCtaPago.Text.Trim ObjFactura.CondicionesPago = If(RBLPago.SelectedValue = "2", 0, If(RBLPago.SelectedValue = "1", 1, 2)) ' 0 - Contado, 1 - Credito, 2 - termianl ObjFactura.FormaPago = 0 'DdlFormaPago.SelectedValue.ToEntero() - - 'ObjFactura.AnticipoPosicion = DdlAmortizacionConceptos.SelectedValue.ToEntero() - 'ObjFactura.AnticipoEnSubTotal = If(ChkAnticipoEnSubTotal.Checked, True, False) - 'ObjFactura.CveTipoRelacion = DdlTipoRelacion.SelectedValue.ToEntero() - - - 'ObjFactura.SerieFolio = String.Format("{0}-{1}", LblSerie.Text, TxtFolio.Text) - 'ObjFactura.PedidoContrato = TxtPedidoContrato.Text.Trim ObjFactura.AtencionA = TxtAtencionA.Text ObjFactura.FordGSDB = "" @@ -11933,7 +11871,7 @@ Partial Class Ventas End If End If - If CveCliente > 0 Then ObjFactura.Timbre = PreParaTimbre(ObjFactura) + ' If CveCliente > 0 Then ObjFactura.Timbre = PreParaTimbre(ObjFactura) 'SI SE ESTA EDITANDO ACTUALIZA LOS IMPORTES DEL DT If GvImpuestosLocales2.Visible AndAlso GvImpuestosLocales2.Enabled Then @@ -12341,10 +12279,7 @@ Partial Class Ventas Private Function PreParaTimbre(Obj As Modelos.Factura) As CFDITimbre Dim Timbre As New CFDITimbre - - Timbre.Comprobante.Version = "4.0" - 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 @@ -12386,25 +12321,6 @@ Partial Class Ventas Timbre.CFDIRelacionados.TipoRelacion = "07" Timbre.CFDIRelacionados.TipoRelacionTexto = "07-CFDI por aplicación de anticipo" - - 'If Timbre.Comprobante.TipoComprobante = "E" Then - ' If Obj.TipoDocumento.Contiene("Nota de Crédito") Then - ' Timbre.CFDIRelacionados.TipoRelacion = "01" - ' Timbre.CFDIRelacionados.TipoRelacionTexto = "Nota de Crédito aplicada a Ingreso" - ' End If - ' If Obj.TipoDocumento.Contiene("Nota de Devolución") Then - ' Timbre.CFDIRelacionados.TipoRelacion = "03" - ' Timbre.CFDIRelacionados.TipoRelacionTexto = "Devolución aplicada a Ingreso" - ' End If - ' Timbre.CFDIRelacionados.UUID.Add(HdnFolioFiscalNC.Value) - 'End If - '' cuando es refacturacoin es cfdirelacionado, con relacion 04 - 'If Timbre.Comprobante.TipoComprobante = "I" AndAlso NuevaFactura = 1 Then - ' Timbre.CFDIRelacionados.TipoRelacion = "04" - ' Timbre.CFDIRelacionados.TipoRelacionTexto = "Refacturación de Ingreso" - ' Timbre.CFDIRelacionados.UUID.Add(HdnFolioFiscalNC.Value) - 'End If - Else 'SI LA FACTURA VIENE DE SER CANCELADA SISTEMA CUANDO SE REFACTURO NO HAY QUE RELACIONAR If (CveEstatusFacturaPadre > 0 AndAlso CveEstatusFacturaPadre <> 4) OrElse (DtVentasNC IsNot Nothing AndAlso DtVentasNC.Rows.Count > 0) OrElse HdnFolioFiscalNC.Value.ToString() <> "" Then @@ -12449,10 +12365,8 @@ Partial Class Ventas End If End If End If - End If End If - End If 'SI LAS FACTURAS SE RELACIONARAN MANUALMENTE SE AGREGAN @@ -12472,7 +12386,6 @@ Partial Class Ventas Timbre.CFDIRelacionados.UUID.Add(GvRow.DataKey("FolioFiscal").Replace("test", "")) End If Next - End If Dim totSubTotal As Decimal = Obj.SubTotal @@ -15302,195 +15215,7 @@ Partial Class Ventas Return ErrorPrepoliza End Function - 'Private Function generaNC(ByRef ObjVentas As ClsVentas, ByRef ObjConta As ClsContabilidad, ByRef ObjInventario As ClsInventarios, ByRef ObjContr As ClsContratos, ByRef ObjContPaq As ClsContPAQi, ByVal factura As Modelos.Factura, ByRef ObjBancos As ClsBancos, ByRef ObjEventos As ClsOIEventos) As List(Of Object) - ' Dim Obj As New List(Of Object) - ' Dim CveVentaNueva As Integer = ObjVentas.CveVenta - ' Dim BanderaGeneraNC As Boolean = True - ' '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 - ' Dim CveNCaVincular As Integer = DdlNCFactura.SelectedValue.ToEntero() - ' '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() - - ' 'Carga Detalle Sucursal - ' CargaClienteSucursal(drv("CveClienteSucursal").ToString().ToEntero(), ObjVentas) - - ' '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() - ' 'factura.SerieFolioPadre = drv("SerieFolio").ToString() - ' HdnFolioFiscalNC.Value = drv("FolioFiscal").ToString() - - ' ViewState("FolioFiscal") = drv("FolioFiscal").ToString() - - ' 'JJMQ 20160506: Se agrego para la validacion de pago de contado. - ' 'CVImporteContado.ValueToCompare = TxtTotal.Text.Replace(",", "") - - ' UpContado.Update() - ' 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 - - ' If FolioFiscal = "" Then - ' CveEstatus = 4 - ' Else - ' CveEstatus = 5 - ' End If - - ' '[IPP] - CANCELA INVENTARIO DE VENTA NUEVA Y NO TRASPASA MOVTOS DE ALMACEN - ' 'If UsuarioActual.CveEmpresa.Contiene(1) Then - ' 'QUEMA DOCUMENTO NUEVO - ' If Not ObjInventario.ActualizarEsDevolucionVenta(CveVentaNueva, 2) Then - ' Return Nothing - ' End If - ' 'Else - ' ' 'TRASPASA ALMACEN A DOCUMENTO NUEVO - ' ' If Not CancelarMovimientoInventario(ObjInventario, ObjConta, CveVentaNueva, CveDevolucion) Then - ' ' Return Nothing - ' ' End If - ' 'End If - - ' 'CANCELA PAGOS - ' If ObjFacturaDevolucion.TipoDocto.Contiene("Ing", "Ant") Then - ' If Not ObjConta.PrePolizasCancelarPagos(CveDevolucion, ObjFactura.CvePrePoliza) Then - ' Return Nothing - ' End If - ' End If - - ' 'CANCELA FACTURA - - ' BanderaGeneraNC = True - ' '2019.05.10- RMF. se activa la bandera a true, para que siempre se cancele, y no genere la NC - - ' If Month(factura.Fecha) = Month(Now) OrElse BanderaGeneraNC = True Then - ' If CancelarFactura(ObjVentas, ObjConta, ObjContPaq, ObjBancos) Then - ' Obj.Add(factura) - ' Else - ' Return Nothing - ' End If - ' Else - ' ObjFacturaDevolucion.TipoDocto = "Egs" - ' ObjFacturaDevolucion.Fecha = Now - ' If RegistrarNC(ObjVentas, ObjConta, ObjInventario, ObjContr, ObjContPaq, ObjFacturaDevolucion, ObjBancos, TmpDTconceptos, ObjEventos) Then - ' Obj.Add(ObjFacturaDevolucion) - ' Else - ' Return Nothing - ' End If - ' End If - - ' 'TRASPASA PAGADO - ' If Not ObjConta.TraspasarSaldosPrePolizas(CveDevolucion, ObjFactura.CveVenta, ObjFactura.CvePrePoliza) Then - ' Return Nothing - ' End If - - ' If Not ObjInventario.TraspasaEntregaDirectaOCInv(ObjFactura.CveVenta, UsuarioActual.CveEmpresa) 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 RegistrarNC(ObjVentas As ClsVentas, ObjConta As ClsContabilidad, ObjInventario As ClsInventarios, ObjContr As ClsContratos, ObjContPaq As ClsContPAQi, ByVal factura As Modelos.Factura, ObjBancos As ClsBancos, TmpDTconceptos As DataTable, ByRef ObjEventos As ClsOIEventos) As Boolean - ' Dim ProcesoCorrecto As Boolean = True - ' RefacturacionGeneroNC = True - - ' ''Generamos el nuevo folio - ' 'Dim ObjFolios As New ClsGralFolios(ObjVentas.IniciaTransacSQL()) - ' 'If ObjFolios.GetFolios(factura.TipoDocto, UsuarioActual.CveEmpresa) Then - ' ' Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format(" CveSubProyecto = {0} And Estado = 'Activo'", DdlSubProyectoDatos.SelectedValue)) - ' ' If DT.Rows.Count > 0 Then - ' ' factura.Folio = DT.Rows(0)("FActual").ToString().ToEntero() - ' ' Else - ' ' ProcesoCorrecto = False - ' ' End If - ' ' DT.Dispose() - ' 'End If - ' factura.Folio = -1 - - ' 'Registramos la venta - ' GuardarVenta(ObjVentas, ObjConta, ObjInventario, ObjContr, factura, TmpDTconceptos, -1, ObjContPaq, ObjBancos) - ' 'CargaNCDT(factura.CveVentaPadre, factura.Total) - - ' 'ObjFacturaDevolucion.Timbre = PreParaTimbre(ObjFacturaDevolucion) - ' ''Timbramos - ' 'If factura.TipoDocto.Contiene("Ing", "Egs", "Ant") AndAlso FolioFiscal <> "" Then - ' ' If UsuarioActual.Empresa.TipoFacturacion = "CFDi" AndAlso UsuarioActual.Empresa.FacturaProduccion Then - - ' ' Dim sw As New Diagnostics.Stopwatch - ' ' sw.Start() - - ' ' 'FACTURA INGRESO/EGRESO - ' ' Dim ObjTimbrado As New Modelos.Timbrado - ' ' Dim FM As New Modelos.FemsaFactura - ' ' Dim TmpDT7Eleven As New DataTable - ' ' Dim TmpDTComplementosTimbrado As New DataTable - - ' ' PrepararTimbrado(FM, TmpDT7Eleven, TmpDTComplementosTimbrado) - - ' ' ObjTimbrado.TimbrarFactura(UsuarioActual, factura, FM, TmpDT, TmpDTImpuestos, TmpDT7Eleven, TmpDTComplementosTimbrado, Ruta, LstFordASN, TxtFordGSDB.Text, ObjVentas) - - ' ' sw.Stop() - ' ' GuardaLogTimbrado(sw.ElapsedMilliseconds.ToString(), UsuarioActual.Empresa.CvePAC) - - ' ' ElseIf UsuarioActual.Empresa.TipoFacturacion = "CBB" Then - ' ' GeneraPDFCBB(ObjFactura.Fecha, Nothing, ObjFactura.SerieFolio, False) - ' ' End If - ' 'End If - - ' If ErrorList.Count > 0 Then - ' ProcesoCorrecto = False - ' End If - - ' Return ProcesoCorrecto - 'End Function #End Region #Region " VISTA PREVIA NEW " @@ -16396,6 +16121,7 @@ Partial Class Ventas CreaObjetosVenta() 'PARA CUANDO YA ESTA GUARDADA LA VENTA + ObjFactura.Timbre = PreParaTimbre(ObjFactura) ObjFactura.CveVenta = CveVenta ObjFactura.Serie = Serie ObjFactura.Folio = Folio @@ -20158,15 +19884,6 @@ Partial Class Ventas Optional CveAlmacenDestino As Integer = -1) As Integer Dim OcurrioError As Boolean = False Dim ContadorMovtosDetalles As Integer = 0 - - 'If Not AplicaMovimientoDetalleEntrada Then - ' Dim rowa As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen={0}", CveAlmacen)) - ' If Not IsNothing(rowa) AndAlso rowa("CveTipoAlmacen").ToString() = "10" Then - ' AplicaMovimientoDetalleEntrada = True - ' End If - 'End If - 'Creamos el movimiento - Dim CveMovimientoInventario As Integer = ObjInventario.AddMovimiento(CveAlmacen, ConceptoEntrada, CveMoneda, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, -1, -1, CveMovimientoRelacionado:=CveMovimientoRelacionado, CveAlmacenDestino:=CveAlmacenDestino, Modulo:="Vta/E4") @@ -20202,21 +19919,6 @@ Partial Class Ventas CveVentaDetalleRemision = MovDet("CveVentaDetalle").ToString().ToEntero() End If - 'If ConceptoEntrada = 3 Then - ' CveVentaDetalle = TmpDT.FiltroPrimeroValor("CveVentaDetalle", $"Consec={Consec}").ToEntero() - 'ElseIf ConceptoEntrada = 40 Then - ' CveVentaDetalle = MovDet("CveVentaDetalle").ToString().ToEntero() - ' CveVentaDetallePadre = TmpDT.FiltroPrimeroValor("CveVentaDetalle", $"Consec={Consec}").ToEntero() - ' 'CUANDO LA VENTADETALLE NO TENGA VALOR DEBE MARCAR ERROR, NUEVA RESTRICCION DE ALMACEN - ' If CveVentaDetallePadre < 0 Then - ' Alert("no se encontro la venta detalle nueva. Por favor comuniquese con atención SIG.", TipoMensaje.ToastError) - ' OcurrioError = True - ' Exit For - ' End If - 'Else - ' CveVentaDetalle = MovDet("CveVentaDetalle").ToString().ToEntero() - 'End If - 'CUANDO LA VENTADETALLE NO TENGA VALOR DEBE MARCAR ERROR, NUEVA RESTRICCION DE ALMACEN If CveVentaDetalle < 0 Then Alert("no se encontro la venta detalle. Por favor comuniquese con atención SIG.", TipoMensaje.ToastError) @@ -20312,13 +20014,16 @@ Partial Class Ventas For Each drt As DataRow In dttped.FiltraParametros("Pedimento <> ''").Rows ObjInventario.UpdateVentasDetalleNumeroPedimento(CveVenta, drt("CveVentaDetalle").ToString.ToEntero, drt("Pedimento").ToString) + Dim dtr As DataRow() = TmpDT.Select($"CveVentaDetalle ={drt("CveVentaDetalle")}") + If dtr IsNot Nothing Then 'actualizamos los datos temporales para timbrar + dtr(0)("NumeroPedimento") = drt("Pedimento").ToString + End If Next End If End If Else OcurrioError = True End If - End If End If @@ -27331,7 +27036,6 @@ Partial Class Ventas Next End If Next - End If 'VERIFICA SI TIENE BONIFICACIONES PARA AGREGARLAS @@ -29172,7 +28876,7 @@ Partial Class Ventas Dim PU As Decimal = If(AplicaPUEditado, Gv.FCTextBox("TxtPrecioEditado").Text.ToDecimal, Gv.DataKey("PU").ToDecimal) Dim Total As Decimal = (Cantidad * PU) Dim TotalImpuestos As Decimal = (Cantidad * PU) - Descuento - Dim TotalCalculableImpuestosIVA = TotalImpuestos * (1 + Gv.DataKey("PorcentajeIEPS").ToString().ToDecimal) + Dim TotalCalculableImpuestosIVA As Decimal = TotalImpuestos * (1 + Gv.DataKey("PorcentajeIEPS").ToString().ToDecimal) Dim ImporteIVA As Decimal = TotalCalculableImpuestosIVA * Gv.DataKey("PorcentajeIVA").ToString().ToDecimal Dim ImporteRetIVA As Decimal = TotalImpuestos * Gv.DataKey("PorcentajeRetIVA").ToString().ToDecimal Dim ImporteRetISR As Decimal = TotalImpuestos * Gv.DataKey("PorcentajeRetISR").ToString().ToDecimal @@ -33716,16 +33420,9 @@ Partial Class Ventas ObjFacturaProntoPago.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", $"CveMoneda = {CveMoneda}") ObjFacturaProntoPago.Serie = Serie ObjFacturaProntoPago.Folio = Folio - ObjFacturaProntoPago.Fecha = Now - ObjFacturaProntoPago.CvePrePoliza = -1 - ObjFacturaProntoPago.CveMetodoPago = 0 - ObjFacturaProntoPago.CondicionesPago = 0 ' 0 - Contado, 1 - Credito (CHECAR) - ObjFacturaProntoPago.FormaPago = 0 ObjFacturaProntoPago.TipoDocto = "Egs" ObjFacturaProntoPago.Fecha = Now - - ObjFacturaProntoPago.Version = "4.0" If ObjFacturaProntoPago.Cliente Is Nothing Then @@ -33748,8 +33445,6 @@ Partial Class Ventas ObjFacturaProntoPago.CveCliente = CveCliente ObjFacturaProntoPago.SetCliente() - - If ObjCliente.GetClientes(ObjFacturaProntoPago.CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, -1, TipoCliente:=-1) Then If ObjCliente.DtResultados.Rows.Count > 0 Then @@ -33793,16 +33488,6 @@ Partial Class Ventas End Select ObjFacturaProntoPago.FechaPago = Now - - ObjFacturaProntoPago.CveCorte = -1 - 'ObjFacturaProntoPago.CveMesa = -1 - ObjFacturaProntoPago.NumeroPersonas = 0 - ObjFacturaProntoPago.CveContrato = -1 - ObjFacturaProntoPago.DescripcionContrato = "" - ObjFacturaProntoPago.CveClienteSucursal = -1 - ObjFacturaProntoPago.Entrega = "" - ObjFacturaProntoPago.CveAlmacen = -1 - Dim DtVentasNC As DataTable = InicializaDTVentasNCProntoPago() Dim TotalImporte As Decimal = ObjFacturaProntoPago.DtDetalle.SUMD("TotalImporte") @@ -34147,6 +33832,7 @@ Partial Class Ventas TmpDT.Columns.Add("AFValorInicial", GetType(Decimal)) TmpDT.Columns.Add("NumTurnos", GetType(Decimal)) TmpDT.Columns("NumTurnos").DefaultValue = 0D + TmpDT.Columns.Add("NumeroPedimento", GetType(String)) Return TmpDT End Function @@ -35111,7 +34797,7 @@ Partial Class Ventas #End Region Protected Sub BtnGenerarPoliza_Click(sender As Object, e As EventArgs) - CreaObjetosVenta() + 'CreaObjetosVenta() 'If UsuarioActual.Empresa.TipoContabilidad = 2 Then