diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 3ea56173b..0bc461505 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -3493,7 +3493,9 @@ Kilometraje  - + + + Correo Notificación Usuario Final:   diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 119df860e..fe76a8aab 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -1290,6 +1290,15 @@ Partial Class Ventas End Set End Property + Private Property CveVentaUsadoDevolucionEfectivo As Integer + Get + Return If(IsNothing(ViewState("CveVentaUsadoDevolucionEfectivo")), 0, CType(ViewState("CveVentaUsadoDevolucionEfectivo"), Integer)) + End Get + Set(value As Integer) + ViewState("CveVentaUsadoDevolucionEfectivo") = value + End Set + End Property + #End Region #Region "Propiedades PuntoVenta" @@ -7236,6 +7245,13 @@ Partial Class Ventas End If End If + If UsuarioActual.Empresa.Funcionalidad(558).ToEntero() = 1 AndAlso TrKilometraje.Visible Then + If TxtKilometraje.Text.Length < 6 Then + Alert("El kilometraje debe tener 6 digitos.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + 'CUANDO ES COTIZACION Y SE VA A FACTURAR SE HACE INGRESO If DdlTipoComprobante.SelectedValue = "Cot" AndAlso BtnEmitirImprimir.Text = "Facturar" Then DdlTipoComprobante.SelectedValue = "Ing" @@ -10774,6 +10790,13 @@ Partial Class Ventas Me.AplicaRelacionManual = False End If + 'SI SE SELECCIONO UNA FACTURA PARA DEVOLUCION DE EFECTIVO DEBE ASOCIARLA A LA NOTA DE CREDITO + If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso factura.TipoDocto = "Egs" AndAlso Me.CveVentaUsadoDevolucionEfectivo > 0 Then + If Not ObjVentas.AddVentasRelacionadas(ObjVentas.CveVenta, CveVentaUsadoDevolucionEfectivo) Then + ErrorList.Add("Ocurrió un error al relacionar la venta de devolución de efectivo entre si.") + End If + End If + If UsuarioActual.Empresa.Funcionalidad(280) = "1" And RblPaqueteria.SelectedValue = "1" And Not factura.TipoDocto.Contiene("Rem", "Ped") Then NotificarPaqueteria() End If @@ -19123,7 +19146,7 @@ Partial Class Ventas If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Dev", "Egs") Then Dim sb As New StringBuilder() - If Not String.IsNullOrEmpty(FolioFiscal) Then + If Not String.IsNullOrEmpty(FolioFiscal) AndAlso Not (UsuarioActual.Empresa.Funcionalidad(529) = "1") Then sb.Append("La factura se encuentra en el siguiente estatus del SAT:
") Dim TotalT As Decimal = TxtTotal.Text.ToDecimal @@ -24675,9 +24698,14 @@ Partial Class Ventas End If 'SOLO APLICA SI NO HAY DOCUMENTOS QUE SELECCIONAR - If UsuarioActual.CveEmpresa = 140 Then + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then If GvCxC.Rows.Count = 0 OrElse GvCxC.Rows.Cast(Of GridViewRow)().Count(Function(gvr) gvr.FCCheckBox("ChkCxC").Checked) = 0 Then - Alert("No se ha seleccionado ninguna factura, en caso de no seleccionar ninguna se creará una nueva nota de crédito. ¿Está seguro de realizar esta acción?", TipoMensaje.MsgConfirmacion, JSBtnAceptar:="BtnAplicaNuevaNC();", TextoConfirmacion:="    Si    ", TextoCancelacion:="    No    ") + If ClienteEsDistribuidor AndAlso TxtImportesRemisionesNC.Text.ToDecimal() > 0 Then + Alert("No se puede generar una nota de crédito para devolución de efectivo si el cliente es distribuidor.", TipoMensaje.MsgAdvertencia) + Else + Alert("No se ha seleccionado ninguna factura, en caso de no seleccionar ninguna se creará una nueva nota de crédito. ¿Está seguro de realizar esta acción?", TipoMensaje.MsgConfirmacion, JSBtnAceptar:="BtnAplicaNuevaNC();", TextoConfirmacion:="    Si    ", TextoCancelacion:="    No    ") + End If + Else AplicarNotaCreditoDesdeVenta() End If @@ -24694,6 +24722,8 @@ Partial Class Ventas Private Sub AplicarNotaCreditoDesdeVenta(Optional AplicaNuevoDocumento As Boolean = False) RegistraScript("$('#ModalAplicarNC').modal('hide');", "EscondeModalNC") + CveVentaUsadoDevolucionEfectivo = -1 + DdlTipoComprobante.SelectedValue = "Egs" Dim AplicaImpuestosLocales As Boolean = False @@ -24722,6 +24752,11 @@ Partial Class Ventas End If ObjVentas.Dispose() + 'SI SE SELECCIONO UNA FACTURA PARA DEVOLUCION DE EFECTIVO DEBE ASOCIARLA A LA NOTA DE CREDITO + If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso AplicaNuevoDocumento AndAlso DdlVentaUsado.SelectedValue.ToEntero() > 0 AndAlso TxtImportesRemisionesNC.Text.ToDecimal() > 0 Then + CveVentaUsadoDevolucionEfectivo = DdlVentaUsado.SelectedValue.ToEntero() + End If + AplicarNC(DdlNCPS.SelectedValue.ToEntero(), EsNCAmortizacion:=ChkAplicaNCAnticipo.Checked, AplicaImpuestosLocales:=AplicaImpuestosLocales, AplicaNuevoDocumento:=AplicaNuevoDocumento, AplicoNCFacturaActual:=True) End Sub @@ -26688,6 +26723,9 @@ Partial Class Ventas Dim Cves As New StringBuilder Dim CveMetodoPago As Integer = -1 Dim MetodoPagoDif As Boolean = False + + Dim ListaVentaDetalleCotizacion As List(Of MVentaDetalleCotizacion) = Nothing + If ChkCotProductos.Checked Then For Each row As DataRow In DTSeleccionadas.Rows If CveMetodoPago <> -1 And row("CveMetodoPago33").ToString().ToEntero() <> CveMetodoPago Then @@ -26702,7 +26740,7 @@ Partial Class Ventas 'CARGA LOS USADOS RELACIONADOS A LOS PRODUCTOS SELECCIONADOS DE LA COTIZACION If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then - CalculaUsadosCotizacion(Cves, DTSeleccionadas, DtCotizaciones) + ListaVentaDetalleCotizacion = CalculaUsadosCotizacion(Cves, DTSeleccionadas, DtCotizaciones) End If Else @@ -26728,6 +26766,18 @@ Partial Class Ventas ObjClientes.Dispose() Cves.Clear() + 'SI SE CALCULARON USADOS LA CANTIDAD DEBE ASIGNARSE A PARTIR DEL CALCULO + If ListaVentaDetalleCotizacion IsNot Nothing AndAlso ListaVentaDetalleCotizacion.Count > 0 Then + + For Each Dr As DataRow In DtCotizacionesPS.Rows + Dim VentaDetalle = ListaVentaDetalleCotizacion.FirstOrDefault(Function(cot) cot.CveVentaDetalle = Dr("CveVentaDetalle").ToString().ToEntero()) + If VentaDetalle IsNot Nothing Then + Dr("Cantidad") = VentaDetalle.Cantidad + End If + Next + + End If + If Not AgregaPSCotizacion() Then Alert("Ocurrió un error validar las partidas de las cotizaciones seleccionadas. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) Exit Sub @@ -26749,14 +26799,29 @@ Partial Class Ventas UpPS.Update() UpParametros.Update() End Sub + Private Class MVentaDetalleCotizacion + Public Property CveVentaDetalle As Integer + Public Property Cantidad As Decimal + End Class + + Private Function CalculaUsadosCotizacion(ByRef SbVentasDetalle As StringBuilder, ByVal DTSeleccionadas As DataTable, ByVal DtCotizaciones As DataTable) As List(Of MVentaDetalleCotizacion) + Dim Retorno As New List(Of MVentaDetalleCotizacion) - Private Sub CalculaUsadosCotizacion(ByRef SbVentasDetalle As StringBuilder, ByVal DTSeleccionadas As DataTable, ByVal DtCotizaciones As DataTable) If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Cot", "Dev") Then Dim DTTamanios As DataTable = GlobalDTAcumTamaños() Dim DTCvePSCostos As DataTable = DTTamanios.FiltraParametros("", "", {"CvePSCargo"}) + + For Each Dr As DataRow In DTSeleccionadas.Rows + Dim tCantidad = If(ChkCotProductos.Checked, GvCotPS.Rows(IndiceGVCotDataKey(GvCotPS, Dr("CveVentaDetalle").ToString())).FCTextBox("TxtCantidadCot").Text.ToDecimal, Dr("Cantidad")).ToString().ToDecimal + Dr("Cantidad") = tCantidad + + Retorno.Add(New MVentaDetalleCotizacion() With {.CveVentaDetalle = Dr("CveVentaDetalle").ToString().ToEntero(), .Cantidad = tCantidad}) + + Next + Dim TmpDTCalculo As DataRow() = DTSeleccionadas.Rows.Cast(Of DataRow).ToArray() Dim DTPSTemp As New DataTable '= TmpDT.Clone @@ -26812,11 +26877,15 @@ Partial Class Ventas Dim CveVentaDetalleUsado = DtCotizaciones.FiltroPrimeroValor("CveVentaDetalle", $"CveVenta = {drowPsTamaños("CveVenta")} AND CvePS = {drowPsTamaños("CvePS")}").ToEntero() SbVentasDetalle.AppendFormat("{0},", CveVentaDetalleUsado) + Retorno.Add(New MVentaDetalleCotizacion() With {.CveVentaDetalle = CveVentaDetalleUsado, .Cantidad = drowPsTamaños("Cantidad").ToString().ToDecimal()}) + End If Next End If - End Sub + + Return Retorno + End Function Private Sub VerificaCotizaciones(ByRef dt As DataTable) If ChkCotProductos.Checked Then For Each Gvr As GridViewRow In GvCotPS.Rows @@ -26862,7 +26931,12 @@ Partial Class Ventas If DtCotizacionesPS IsNot Nothing Then Dim tCantidad As Decimal = 0 For Each Dr As DataRow In DtCotizacionesPS.Select() - tCantidad = If(ChkCotProductos.Checked, GvCotPS.Rows(IndiceGVCotDataKey(GvCotPS, Dr("CveVentaDetalle").ToString())).FCTextBox("TxtCantidadCot").Text.ToDecimal, Dr("Cantidad")).ToString().ToDecimal + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + tCantidad = Dr("Cantidad").ToString().ToDecimal() + Else + tCantidad = If(ChkCotProductos.Checked, GvCotPS.Rows(IndiceGVCotDataKey(GvCotPS, Dr("CveVentaDetalle").ToString())).FCTextBox("TxtCantidadCot").Text.ToDecimal, Dr("Cantidad")).ToString().ToDecimal + End If + AgregarProductoServicio(tCantidad, Dr("CveUM").ToString().ToEntero(), Dr("UM").ToString(), Dr("CveClasificacion").ToString().ToEntero(), Dr("Clasificacion").ToString(), Dr("CvePS").ToString().ToEntero(), Dr("PS").ToString(), Dr("Obs").ToString(), Dr("PU").ToString().ToDecimal, Dr("Descuento").ToString().ToDecimal, Dr("CveProyecto").ToString().ToEntero(), Dr("Proyecto").ToString(), Dr("CveSubProyecto").ToString().ToEntero(), Dr("SubProyecto").ToString(),