diff --git a/App_Code/ClsContratos.vb b/App_Code/ClsContratos.vb index c716f91b6..2f6dc4b60 100644 --- a/App_Code/ClsContratos.vb +++ b/App_Code/ClsContratos.vb @@ -1415,6 +1415,33 @@ Public Class ClsContratos + + Public Function UpdateContratosEstimacion(CveEstimacion As Integer, CveUsuario As Integer, CveEmpresa As Integer, CveEstimacionEstatus As Integer) As Boolean + + Dim Retorno = False + + DataAdapter("PA_Con_ContratosEstimacionUpdate") + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveEstimacion", SqlDbType.Int).Value = CveEstimacion + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveEstimacionEstatus", SqlDbType.Int).Value = CveEstimacionEstatus + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la estimacion.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + + Public Function RemoveContratosAvance(CveContratoAvance As Integer, CveEmpresa As Integer) As Boolean Dim Retorno = False diff --git a/App_Code/ClsMovimientos.vb b/App_Code/ClsMovimientos.vb index 6ea168a78..56ebab4bf 100644 --- a/App_Code/ClsMovimientos.vb +++ b/App_Code/ClsMovimientos.vb @@ -454,6 +454,26 @@ Public Class ClsMovimientos OnError("Ocurrió un error al consultar los Anticipos del Cliente.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) End Try + Return Retorno + End Function + Public Function GetRemisionesNCCliente(CveCliente As Integer, MostarDetalle As Boolean, Optional CveMoneda As Integer = -1, Optional CveClienteSucursal As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_ClienteRemisionesNC") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@MostarDetalle", SqlDbType.Bit).Value = MostarDetalle + .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + OnError("Ocurrió un error al consultar los Anticipos del Cliente.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno End Function diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 58f52703a..a704afaf3 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -4860,6 +4860,7 @@ Public Class ClsPaginas PaginaDict.Add("/RH/SolicitudViaticos.aspx".ToUpper(), 663) PaginaDict.Add("/RH/ReporteViaticos.aspx".ToUpper(), 664) PaginaDict.Add("/RH/MiPerfil.aspx".ToUpper(), -1) ' se dejará libre el módulo para que cualquier que tenga cvepersonal, pueda acceder + PaginaDict.Add("/RH/CatChecadores.aspx".ToUpper(), 694) #End Region #Region "Sistema" 'Cargo las páginas que deben tener restricción @@ -6753,7 +6754,7 @@ Public Class ClsPaginas End If 'ECONOLLANTAS - AGREGAR QR DE DESCARGA - If UsuarioActual.CveEmpresa = 141 Then + If UsuarioActual.CveEmpresa.Contiene(141, 152, 159, 160, 161, 162, 163) Then Dim QRDescarga As String = "" Dim cfdi As New RVCFDI33.GeneraCFDI() diff --git a/App_Code/ClsRH.vb b/App_Code/ClsRH.vb index 5508900fd..b7729c3f2 100644 --- a/App_Code/ClsRH.vb +++ b/App_Code/ClsRH.vb @@ -6879,6 +6879,81 @@ chkAplicaVacacion As Boolean, chkAplicaIncapacidad As Boolean, chkAplicaRetardo #End Region +#Region "Checador" + Public Function GetChecadores(CveChecador As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_RH_ChecadorGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveChecador", SqlDbType.Int).Value = CveChecador + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el listado de checadores", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function AddChecadores(Checador As String, CveSubProyecto As Integer, IPLocal As String, Puerto As String, CveUsuario As Integer, Optional CveModelo As Integer = 1, Optional Estatus As Integer = 1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_RH_ChecadorAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@Checador", SqlDbType.NVarChar).Value = Checador + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@IPLocal", SqlDbType.NVarChar).Value = IPLocal + .Add("@Puerto", SqlDbType.NVarChar).Value = Puerto + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveModelo", SqlDbType.Int).Value = CveModelo + .Add("@Estatus", SqlDbType.Int).Value = Estatus + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el checador", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function UpdateChecadores(CveChecador As Integer, Checador As String, CveSubProyecto As Integer, IPLocal As String, Puerto As String, Optional CveModelo As Integer = 1, Optional Estatus As Boolean = True) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_RH_ChecadorUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveChecador", SqlDbType.Int).Value = CveChecador + .Add("@Checador", SqlDbType.NVarChar).Value = Checador + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@IPLocal", SqlDbType.NVarChar).Value = IPLocal + .Add("@Puerto", SqlDbType.NVarChar).Value = Puerto + .Add("@CveModelo", SqlDbType.Int).Value = CveModelo + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el checador", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function RemoveChecadores(CveChecador As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_RH_ChecadorDelete") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveChecador", SqlDbType.Int).Value = CveChecador + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el checador", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function +#End Region + 'Public msgsError As New StringBuilder() 'Public Sub OnError(Mensaje As String, Exeption As Exception, Optional InfoAdicional As String = "") diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index ca2415149..d0648d098 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -764,6 +764,25 @@ Public Class ClsVentas Return Retorno End Function + Public Function UpdateVentaRNCUsado(CveVentaRNC As Integer, CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_VentasRNCUsadosUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaRNC", SqlDbType.Int).Value = CveVentaRNC + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la relacion con el usado.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function Public Function UpdateCancelaVenta(CveVenta As Integer, FechaCancelacion As DateTime, SelloCancelacionSAT As String, CveEmpresa As Integer, Optional CvePAC As Integer = -1, Optional CveEstatusRefacturacion As Integer = 0) As Boolean Dim Retorno As Boolean = False @@ -4788,6 +4807,26 @@ Public Class ClsVentas Return Retorno End Function + Public Function AddVentaDetalleRNCFacturada(CveVentaDetalleRNC As Integer, CveVentaDetalle As Integer, CantidadFacturada As Decimal) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentaDetalleRNCFacturadaAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaDetalleRNC", SqlDbType.Int).Value = CveVentaDetalleRNC + .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle + .Add("@CantidadFacturada", SqlDbType.Float).Value = CantidadFacturada + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + OnError("Ocurrió un error al agregar lo facturado de la RNC.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + #End Region diff --git a/Bancos/PopUpBuscarIE.aspx b/Bancos/PopUpBuscarIE.aspx index 5c650cbcd..228691300 100644 --- a/Bancos/PopUpBuscarIE.aspx +++ b/Bancos/PopUpBuscarIE.aspx @@ -74,17 +74,17 @@
- - + + - - - + + +
diff --git a/Compras/Compras.aspx b/Compras/Compras.aspx index 092f884ab..d0118d925 100644 --- a/Compras/Compras.aspx +++ b/Compras/Compras.aspx @@ -632,6 +632,7 @@
+ Tipo de Gasto @@ -675,6 +676,7 @@ + @@ -4284,8 +4286,19 @@ <%-- --%> + + +
+
+ + + +
+
+ diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index fc53b60e5..da0b58856 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -1319,6 +1319,15 @@ Partial Class Compras_Compras DdlPersonal.DataBind() DdlPersonalReembolso.DataBind() + If UsuarioActual.Empresa.Funcionalidad(590).ToString.ToEntero = 1 Then + DVCultivosCuadro.Visible = True + DdlSubProyecto.AutoPostBack = True + DdlCultivosCuadro.DataSource = GlobalDTCultivosCuadro(UsuarioActual.CveEmpresa).FiltraParametros($"CveSubProyecto = {DdlSubProyecto.SelectedValue}") + DdlCultivosCuadro.DataBind() + DdlCultivosCuadro.Items.Insert(0, New ListItem("Seleccione uno", "-1")) + + End If + 'Carga Proveedor If Request("CveProveedor") IsNot Nothing AndAlso IsNumeric(Request("CveProveedor")) AndAlso Request("CveProveedor").ToEntero > 0 Then @@ -17655,6 +17664,15 @@ Partial Class Compras_Compras If Modalidad <> "U" Or Not CveFactura > 0 Then DdlPSChange() End If + + If UsuarioActual.Empresa.Funcionalidad(590).ToString.ToEntero = 1 Then + + DdlCultivosCuadro.Items.Clear() + DdlCultivosCuadro.DataSource = GlobalDTCultivosCuadro(UsuarioActual.CveEmpresa).FiltraParametros($" CveSubProyecto = {DdlSubProyecto.SelectedValue}") + DdlCultivosCuadro.DataBind() + DdlCultivosCuadro.Items.Insert(0, New ListItem("Seleccione uno", "-1")) + + End If End Sub Private Sub DdlPSChange() If CveProveedor > 0 Then diff --git a/Contratos/ContratoObraAutorizacion.aspx b/Contratos/ContratoObraAutorizacion.aspx index f22ccaceb..39a0117da 100644 --- a/Contratos/ContratoObraAutorizacion.aspx +++ b/Contratos/ContratoObraAutorizacion.aspx @@ -85,7 +85,7 @@
@@ -149,7 +149,7 @@
- + diff --git a/Contratos/ContratoObraAutorizacion.aspx.vb b/Contratos/ContratoObraAutorizacion.aspx.vb index bec497e3b..312288238 100644 --- a/Contratos/ContratoObraAutorizacion.aspx.vb +++ b/Contratos/ContratoObraAutorizacion.aspx.vb @@ -216,6 +216,9 @@ Partial Class Contratos_ContratoObraAutorizacion DTEstimaciones = ObjContratos.DtResultados CveContratoEstimacion = DDlContratosEstimaciones.SelectedValue.ToEntero + If DTEstimaciones.Rows.Count > 0 Then + CveEstimacionActual = DTEstimaciones.FiltroPrimeroValor("CveEstimacion", "CveEstimacion > 0").ToString.ToEntero + End If End If @@ -652,6 +655,34 @@ Partial Class Contratos_ContratoObraAutorizacion + End Sub + Protected Sub BtnAutoriza_Click(sender As Object, e As EventArgs) + + + + Dim ErrorProceso As Boolean = True + + + + Dim ObjContrato As New ClsContratos + + If ObjContrato.UpdateContratosEstimacion(CveEstimacionActual, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 3) Then + ErrorProceso = False + End If + + ObjContrato.Dispose() + + If Not ErrorProceso Then + + CveEstimacionActual = -1 + CargaAvancesParaEstimar() + Alert("Avance autorizado correctamente.") + + End If + + + + End Sub End Class diff --git a/General/CatModelos.aspx b/General/CatModelos.aspx index 09c09dba2..15aeee825 100644 --- a/General/CatModelos.aspx +++ b/General/CatModelos.aspx @@ -27,6 +27,7 @@ CssClass="table table-striped table-advance table-hover ScrollAD mysmallbtn" data-sort="true" Width="100%" GridLines="None"> + diff --git a/General/SaldosIniciales.aspx.vb b/General/SaldosIniciales.aspx.vb index 8e68f2b23..b26306076 100644 --- a/General/SaldosIniciales.aspx.vb +++ b/General/SaldosIniciales.aspx.vb @@ -853,7 +853,7 @@ Partial Class General_SaldosIniciales If Codigo.Length > 0 Then - If ObjPS.AddPS(CveClasificacion, 1, CveUnidadMedida, Codigo, "", CodigoBarras, Descripcion, Precio, 0, 0, False, 0, False, True, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, 1, + If ObjPS.AddPS(CveClasificacion, 1, CveUnidadMedida, Codigo, "", CodigoBarras, Descripcion, Precio, -1, 0, False, 0, False, True, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, 1, CveTipoPS:=CveTipoPS, CveSATPS:=CveSATPS, CveMarca:=CveMarca, CveTamaño:=CveTamaño, CveMedida:=CveMedida, CveRinTamaño:=CveRinTamaño, CveModelo:=CveModelo, Litraje:=Litraje, IEPSPorcentaje:=IEPS, CveClasificacion2:=CveClasificacion2, CveClasificacionDetalle:=CveClasificacionDetalle) <= 0 Then 'If ObjPS.AddPS(CveClasificacion, 1, CveUnidadMedida, Codigo, "", "", Descripcion, 0, 0, 0, False, 0, False, True, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, 1, diff --git a/Inventarios/InventarioFisicoDetalle.aspx b/Inventarios/InventarioFisicoDetalle.aspx index 6a15e7ad1..e7c1feb0c 100644 --- a/Inventarios/InventarioFisicoDetalle.aspx +++ b/Inventarios/InventarioFisicoDetalle.aspx @@ -229,7 +229,7 @@
- +
@@ -240,7 +240,7 @@
-
+
@@ -259,12 +259,22 @@
-
-
- +
+ +
+ + <%--Seleccione--%> + + +
+
+
+
+
+
diff --git a/Inventarios/InventarioFisicoDetalle.aspx.vb b/Inventarios/InventarioFisicoDetalle.aspx.vb index a1678237c..a5abf5a98 100644 --- a/Inventarios/InventarioFisicoDetalle.aspx.vb +++ b/Inventarios/InventarioFisicoDetalle.aspx.vb @@ -6,7 +6,7 @@ Imports Extensiones Imports Microsoft.Reporting.WebForms Partial Class Inventarios_InventarioFisicoDetalle - Inherits ClsPaginas + Inherits ClsPaginas #Region "Propiedades" Public Property DtEquivalencias() As DataTable Get @@ -39,9 +39,18 @@ Partial Class Inventarios_InventarioFisicoDetalle Set(value As DataTable) ViewState("DtVentas") = value End Set - End Property + End Property + Private Property CveAlmacenes As String + Get + Return ViewState("CveAlmacenes").ToString + End Get + Set(value As String) + ViewState("CveAlmacenes") = value + End Set + End Property + #End Region - + Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not IsPostBack Then If Request("CveInventarioFisico") IsNot Nothing AndAlso Request("CveInventarioFisico").ToString.ToEntero > 0 Then @@ -51,10 +60,10 @@ Partial Class Inventarios_InventarioFisicoDetalle End If End If - End Sub - - - + End Sub + + + #Region " USUARIOS " Private Sub CargaUsuarios() ddlUsuario.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 1", "Nombre") @@ -82,9 +91,9 @@ Partial Class Inventarios_InventarioFisicoDetalle UPAgregarPro.Update() UPPInventario.Update() - End Sub + End Sub #End Region - + #Region " CARGA DATOS " Private Sub CargaDatos(CveInventarioFisico As Integer, CveEmpresa As Integer, Optional CveUsuario As Integer = -1) @@ -135,13 +144,16 @@ Partial Class Inventarios_InventarioFisicoDetalle If ObjInventario.GetInventarioFisicoDetallesAlmacen(CveInventarioFisico, UsuarioActual.CveEmpresa) Then Dim dt As DataTable = ObjInventario.DtResultados Dim str As New StringBuilder + Dim CveAlmacenesStr As New StringBuilder If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then For Each dr As DataRow In dt.Rows str.AppendFormat("{0},", dr("almacen")) + CveAlmacenesStr.AppendFormat("{0},", dr("CveAlmacen")) Next End If LblAlmacenes.Text = str.ToString + CveAlmacenes = CveAlmacenesStr.ToString.Substring(0, CveAlmacenesStr.Length - 1) End If If ObjInventario.GetInventarioFisicoDetallesClasificacion(CveInventarioFisico, UsuarioActual.CveEmpresa) Then @@ -246,11 +258,11 @@ Partial Class Inventarios_InventarioFisicoDetalle RegistraScript("OrdenarGV();") End If UPPInventario.Update() - End Sub + End Sub #End Region - + #Region " AGREGAR " - + Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click Dim Valido As Boolean = False @@ -260,8 +272,9 @@ Partial Class Inventarios_InventarioFisicoDetalle Dim CodigoBarras As String = If(TxtCodigoBarras.Text.Trim <> "", TxtCodigoBarras.Text.Trim, "-1").Replace("'", "''") ' scanner cambian los guiones por apostrofes Dim Serie As String = TxtCodigoSerie.Text.Trim Dim Lote As String = If(TxtLote.Text.Length > 0, TxtLote.Text, "-1") - Dim FechaCaducidad As String=MinFecha.ToString + Dim FechaCaducidad As String = MinFecha.ToString Dim CveSeccionAlmacen As Integer = -1 + Dim SeccionAlmacen As String = "" Dim Cantidad = TxtCantidadProducto.Text.ToDouble @@ -279,11 +292,13 @@ Partial Class Inventarios_InventarioFisicoDetalle Dim AplicaCaducidad As Boolean = dr("AplicaCaducidad") = "1" Dim AplicaLote As Boolean = dr("AplicaLote") = "1" Dim AplicaSerie As Boolean = dr("AplicaSerie") = "1" + Dim AplicaSeccion As Boolean = dr("AplicaSeccion") = "1" 'divSeccionAlmacen.Visible = AplicaSeccion divLote.Visible = AplicaLote divFechaCaducidad.Visible = AplicaCaducidad divSerie.Visible = AplicaSerie + UPAgregarPro.Update() If AplicaSerie And Serie = "" Then @@ -294,7 +309,7 @@ Partial Class Inventarios_InventarioFisicoDetalle RFVSerie.ValidationGroup = " " Exit Sub End If - If AplicaLote And Lote = "" Then + If AplicaLote And (Lote = "" Or Lote = "-1") Then RFVLote.Enabled = True RFVLote.Visible = True RFVLote.SetFocusOnError = True @@ -313,13 +328,46 @@ Partial Class Inventarios_InventarioFisicoDetalle End If FechaCaducidad = If(TxtFechaCaducidad.Text.Length > 0, TxtFechaCaducidad.Text, MinFecha.ToString) End If - + If AplicaSeccion Then + Dim ObjInv As New ClsInventarios + Dim SeccionesAlmacenDelProducto As New DataTable + If ObjInv.GetProductosServiciosAlmacenSeccion(CveProducto, -1, -1, UsuarioActual.CveEmpresa) Then + SeccionesAlmacenDelProducto = ObjInv.DtResultados.FiltraParametros(String.Format("CveAlmacen IN ({0})", CveAlmacenes)) + End If + 'Dim SeccionesAlmacenDelProducto As DataTable = (UsuarioActual.CveEmpresa, -1, CveProducto) '.FiltraParametros(String.Format("CveAlmacen IN ({0})", CveAlmacenes)) + 'Alert(SeccionesAlmacenDelProducto.Rows.Count.ToString) + If SeccionesAlmacenDelProducto.Rows.Count = 1 Then + CveSeccionAlmacen = SeccionesAlmacenDelProducto.FiltroPrimeroValor("CveSeccionAlmacen") + Else + divSeccion.Visible = AplicaSeccion + If DdlSeccionAlmacen.Items.Count = 0 Then + DdlSeccionAlmacen.DataSource = SeccionesAlmacenDelProducto + DdlSeccionAlmacen.DataBind() + DdlSeccionAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + + If DdlSeccionAlmacen.SelectedValue = "-1" Then + RfvSeccionAlmacen.Enabled = True + RfvSeccionAlmacen.Visible = True + RfvSeccionAlmacen.SetFocusOnError = True + RfvSeccionAlmacen.Validate() + RfvSeccionAlmacen.ValidationGroup = " " + Exit Sub + End If + CveSeccionAlmacen = DdlSeccionAlmacen.SelectedValue.ToEntero + End If + ObjInv.Dispose() + SeccionAlmacen = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, -1).FiltroPrimeroValor("SeccionAlmacen", String.Format("CveSeccionAlmacen = {0}", CveSeccionAlmacen)) + End If + RFVSerie.ValidationGroup = "GrpIngresar" RFVSerie.Enabled = False RFVLote.ValidationGroup = "GrpIngresar" RFVLote.Enabled = False RFVCaducidad.ValidationGroup = "GrpIngresar" RFVCaducidad.Enabled = False + RfvSeccionAlmacen.ValidationGroup = "GrpIngresar" + RfvSeccionAlmacen.Enabled = False 'VALIDA QUE LA SERIE NO SEA IGUAL AL CODIGO O CODIGOBARRAS If Serie <> "" And (Serie.ToUpper = dr("Codigo").ToString.ToUpper Or Serie.ToUpper = dr("CodigoBarras").ToString.ToUpper) Then @@ -331,7 +379,7 @@ Partial Class Inventarios_InventarioFisicoDetalle Using Inventarios As New ClsInventarios If Inventarios.AddInventarioFisicoDetalle(CveInventarioFisico, CveProducto, CveUnidadMedida, If(AplicaSerie, 1, Cantidad), Serie, UsuarioActual.CveUsuario, - CveSeccionAlmacen:=-1, Lote:=Lote, FechaCaducidad:=FechaCaducidad.ToDate) Then + CveSeccionAlmacen:=CveSeccionAlmacen, Lote:=Lote, FechaCaducidad:=FechaCaducidad.ToDate) Then GvIFDUltimoRegistrado.Columns(4).Visible = CveSeccionAlmacen > 0 GvIFDUltimoRegistrado.Columns(5).Visible = Serie <> "" @@ -344,7 +392,7 @@ Partial Class Inventarios_InventarioFisicoDetalle GvIFDUltimoRegistrado.Rows(0).Cells(1).Text = dr("CodigoBarras").ToString GvIFDUltimoRegistrado.Rows(0).Cells(2).Text = dr("Codigo").ToString GvIFDUltimoRegistrado.Rows(0).Cells(3).Text = dr("PSCodigo").ToString - GvIFDUltimoRegistrado.Rows(0).Cells(4).Text = "" + GvIFDUltimoRegistrado.Rows(0).Cells(4).Text = SeccionAlmacen GvIFDUltimoRegistrado.Rows(0).Cells(5).Text = TxtCodigoSerie.Text.Trim GvIFDUltimoRegistrado.Rows(0).Cells(6).Text = Lote GvIFDUltimoRegistrado.Rows(0).Cells(7).Text = FechaCaducidad @@ -371,6 +419,7 @@ Partial Class Inventarios_InventarioFisicoDetalle divLote.Visible = False divFechaCaducidad.Visible = False divSerie.Visible = False + divSeccion.Visible = False RegistraScript("playsonidito('beep-07.wav')") Else TxtCodigoSerie.Text = "" @@ -386,6 +435,7 @@ Partial Class Inventarios_InventarioFisicoDetalle divLote.Visible = False divFechaCaducidad.Visible = False divSerie.Visible = False + divSeccion.Visible = False TxtLote.Text = "" TxtFechaCaducidad.Text = "" Alert("No se encontró el producto, favor de escribirlo correctamente.", TipoMensaje.MsgError) @@ -395,9 +445,9 @@ Partial Class Inventarios_InventarioFisicoDetalle DivBuscador.Visible = False UPPInventario.Update() - End Sub + End Sub #End Region - + #Region " ELIMINAR " Protected Sub gvInventarioFisicoDetalle_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvIFD.RowDeleting If ddlUsuario.SelectedValue = UsuarioActual.CveUsuario.ToString OrElse UsuarioActual.TienePermisoProceso(283) Then @@ -425,9 +475,9 @@ Partial Class Inventarios_InventarioFisicoDetalle Alert("No se puede eliminar un producto registrado por otro usuario.", TipoMensaje.MsgAdvertencia) RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") End If - End Sub + End Sub #End Region - + #Region " FINALIZAR " Protected Sub btnFin_Click(sender As Object, e As EventArgs) Handles btnFin.Click If btnFin.Text.Contains("Iniciar") Then @@ -475,9 +525,9 @@ Partial Class Inventarios_InventarioFisicoDetalle UPAgregarPro.Update() UPPInventario.Update() - End Sub + End Sub #End Region - + #Region " VER AVANCE " Protected Sub LBAvance_Click(sender As Object, e As EventArgs) Response.Redirect($"~/Inventarios/RepAnomalias.aspx?CveInventarioFisico={CveInventarioFisico}&EsAvance=1") diff --git a/Inventarios/RecepcionUsados.aspx.vb b/Inventarios/RecepcionUsados.aspx.vb index 4f19a33b8..7c83727db 100644 --- a/Inventarios/RecepcionUsados.aspx.vb +++ b/Inventarios/RecepcionUsados.aspx.vb @@ -2525,8 +2525,14 @@ Partial Class Inventarios_RecepcionUsados If RblUsadosAjuste.SelectedValue = "1" Then 'agrego un registro extra del importe de ajuste Dim PU As Decimal = TxtImporteAjuste.Text.ToDecimal - Dim CveSATNC As String = "84111506" - Dim Dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:=CveSATNC, AplicaParaVenta:=1).FiltroPrimero("") + 'CONSULTA EL CONCEPTO DE NC + Dim ArrayNC As String() = UsuarioActual.Empresa.Funcionalidad(591).Split(",".ToCharArray()) + Dim NCAjuste As Integer = -1 + If ArrayNC.Length > 5 Then + NCAjuste = ArrayNC(5).ToEntero() + End If + + Dim Dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=NCAjuste, AplicaParaVenta:=1).FiltroPrimero("") If Dr IsNot Nothing Then Dim CveUnidadMedida, CveClasificacion, CvePS As Integer @@ -2534,7 +2540,7 @@ Partial Class Inventarios_RecepcionUsados CveClasificacion = Dr("CveClasificacion").ToString.ToEntero CvePS = Dr("CvePS").ToString.ToEntero Dim PorcentajeIVA As Decimal = 0.16D - Dim Obs As String = "Descuento por garantía" + Dim Obs As String = $"Descuento por garantía. BCI: {DdlBCIAjuste.SelectedValue}" AddPSRNC(ObjRemisionNC.DtDetalle, 1, CveUnidadMedida, "", CveClasificacion, "", CvePS, "", Obs, PU, 0, -1, "", ObjRemisionNC.CveSubProyecto, ObjRemisionNC.SubProyecto.SubProyecto, PorcentajeIVA:=PorcentajeIVA) @@ -2806,13 +2812,6 @@ Partial Class Inventarios_RecepcionUsados Dim ClasificacionPS As String = GlobalDTClasificaciones(CveEmpresa:=UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacionPS).FiltroPrimeroValor("Clasificacion").ToString() Select Case TipoFolio Case "GENERAL" - '20520 ACUM. AUTOMOTRIZ - '20522 ACUM. ESPECIALES - '20513 ACUM. ESTANDAR - '20521 ACUM. PESADO - '20512 ACUM. PREMIUM - '20514 ACUM. VALUE - '20229 Acumulador ListaClasificacionesPermitidas.Add(20520) 'ACUM. AUTOMOTRIZ ListaClasificacionesPermitidas.Add(20522) 'ACUM. ESPECIALES ListaClasificacionesPermitidas.Add(20513) 'ACUM. ESTANDAR diff --git a/Inventarios/RepAnomalias.aspx b/Inventarios/RepAnomalias.aspx index 3751b969e..61dc09004 100644 --- a/Inventarios/RepAnomalias.aspx +++ b/Inventarios/RepAnomalias.aspx @@ -198,6 +198,7 @@ + @@ -232,6 +233,7 @@ + diff --git a/Inventarios/RepAnomalias.aspx.vb b/Inventarios/RepAnomalias.aspx.vb index a71900ab2..12433a1ec 100644 --- a/Inventarios/RepAnomalias.aspx.vb +++ b/Inventarios/RepAnomalias.aspx.vb @@ -194,6 +194,9 @@ Partial Class Inventarios_RepAnomalias e.Row.Cells(8).Text = "0" End If + If e.Row.Cells(7).Text = MinFecha Then + e.Row.Cells(7).Text = "" + End If e.Row.FCLabel("Lblc").Text = e.Row.RowIndex + 1 End If @@ -273,9 +276,10 @@ Partial Class Inventarios_RepAnomalias #End Region Private Sub BanderaSerieLoteCad(Gv As GridView, resultado As DataTable) - Gv.Columns(4).Visible = resultado.MAX("Serie") <> "" - Gv.Columns(5).Visible = resultado.MAX("Lote") <> "" - Gv.Columns(6).Visible = resultado.MAX("FechaCaducidad").ToDate > MinFecha + Gv.Columns(4).Visible = resultado.MAX("CveSeccionAlmacen").ToEntero > 0 + Gv.Columns(5).Visible = resultado.MAX("Serie") <> "" + Gv.Columns(6).Visible = resultado.MAX("Lote") <> "" + Gv.Columns(7).Visible = resultado.MAX("FechaCaducidad").ToDate > MinFecha End Sub End Class diff --git a/OC/CatEstatus.aspx.vb b/OC/CatEstatus.aspx.vb index f44f0a3d6..7a9255c82 100644 --- a/OC/CatEstatus.aspx.vb +++ b/OC/CatEstatus.aspx.vb @@ -69,14 +69,14 @@ Partial Class OC_CatEstatus CargaDatos() CargaEstatus() CargaProyectos() - CargaUsuarios() - - 'SOLO MUESTRA SUBPROYECTO - If UsuarioActual.Empresa.GralSoloProyecto Then - 'TdProyecto.Visible = False - 'TdSubProyectoTitulo.Visible = False - - DivProyecto.Visible = False + CargaUsuarios() + + 'SOLO MUESTRA SUBPROYECTO + + 'TdProyecto.Visible = False + 'TdSubProyectoTitulo.Visible = False + + DivProyecto.Visible = False LblSubproyecto.Visible = False @@ -84,9 +84,9 @@ Partial Class OC_CatEstatus CboSubProyecto.DataBind() CboSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) - CboSubProyecto_SelectedIndexChanged(CboSubProyecto, EventArgs.Empty) - End If - + CboSubProyecto_SelectedIndexChanged(CboSubProyecto, EventArgs.Empty) + + chkMostrarLimites.Attributes.Add("onchange", "javascript:chkMostrarLimitesCambio();") MaintainScrollPositionOnPostBack = True @@ -614,7 +614,7 @@ Partial Class OC_CatEstatus 'Insertar el nuevo registro Else - If Not objEstatusOC.AddEstatusUsuarios(CveEstatus, CveSubProyecto, Row.DataKey("CveUsuario").ToString.ToEntero, True) Then + If Not objEstatusOC.AddEstatusUsuarios(CveEstatus, CveSubProyecto, Row.DataKey("CveUsuario").ToString.ToEntero, True, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then HuboErrores = True Exit For End If @@ -699,6 +699,7 @@ Partial Class OC_CatEstatus If Not HuboErrores Then objEstatusOC.Commit() + GlobalDTSubProyectosUsuarios(-1, -1, UsuarioActual.CveEmpresa) = Nothing Alert("Se guardaron los Cambios exitosamente", TipoMensaje.MsgInformacion) Else objEstatusOC.RollBack() diff --git a/OC/OC.aspx b/OC/OC.aspx index b7c9eb33e..a5c5ecb11 100644 --- a/OC/OC.aspx +++ b/OC/OC.aspx @@ -811,6 +811,7 @@
+ Cultivo: @@ -941,9 +942,7 @@ - - - + diff --git a/OC/OC.aspx.vb b/OC/OC.aspx.vb index 07bd1ee2d..440141f5c 100644 --- a/OC/OC.aspx.vb +++ b/OC/OC.aspx.vb @@ -801,6 +801,9 @@ Partial Class OC If UsuarioActual.Empresa.Funcionalidad(590).ToString.ToEntero = 1 Then DVCultivosCuadro.Visible = True + DdlSubProyecto.AutoPostBack = True + DdlCultivosCuadro.DataSource = GlobalDTCultivosCuadro(UsuarioActual.CveEmpresa).FiltraParametros($"CveSubProyecto = {DdlSubProyecto.SelectedValue}") + DdlCultivosCuadro.DataBind() DdlCultivosCuadro.Items.Insert(0, New ListItem("Seleccione uno", "-1")) End If @@ -3562,7 +3565,9 @@ Partial Class OC If e.Row.RowState = DataControlRowState.Normal Or e.Row.RowState = DataControlRowState.Alternate Then If UsuarioActual.Empresa.Tipo_CentroCosto = 1 Or UsuarioActual.Empresa.Tipo_CentroCosto = 2 Then - e.Row.FCLiteral("LtlSubProyecto").Text = e.Row.DBCampo("SubProyecto") + Dim Str As String = e.Row.DBCampo("SubProyecto") + If e.Row.DBCampo("Cuadro") <> "" Then Str = String.Format("{0}
{1}", Str, e.Row.DBCampo("Cuadro")) + e.Row.FCLiteral("LtlSubProyecto").Text = Str End If End If diff --git a/RH/CatChecadores.aspx b/RH/CatChecadores.aspx new file mode 100644 index 000000000..0e7b07707 --- /dev/null +++ b/RH/CatChecadores.aspx @@ -0,0 +1,101 @@ +<%@ Page Title="RH - Catálogo de Checadores" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="CatChecadores.aspx.cs" Inherits="RH_CatChecadores" %> + +<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> + + + + + + + + Catálogo de Checadores + + + + +
  • + +
  • + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RH/CatChecadores.aspx.cs b/RH/CatChecadores.aspx.cs new file mode 100644 index 000000000..c05160605 --- /dev/null +++ b/RH/CatChecadores.aspx.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Extensiones; +using System.Data; + +public partial class RH_CatChecadores : ClsPaginas +{ + private int CveChecador + { + get + { + return ViewState["CveChecador"].ToString().ToEntero(); + } + + set + { + ViewState["CveChecador"] = value; + } + } + + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + CargaDatos(); + CargaSubProyectos(); + } + } + + private void CargaDatos() + { + ClsRH ObjRH = new ClsRH(); + if (ObjRH.GetChecadores(-1, UsuarioActual.CveEmpresa)) + { + GvDatos.DataSource = ObjRH.DtResultados; + } + ObjRH.Dispose(); + GvDatos.DataBind(); + } + + private void CargaSubProyectos() + { + DdlSubProyecto.DataSource = get_GlobalDTSubProyectos(-1, CveEmpresa: UsuarioActual.CveEmpresa); + DdlSubProyecto.DataBind(); + } + + protected void BtnAgregarChecador_Click(object sender, EventArgs e) + { + TxtChecador.Text = ""; + DdlSubProyecto.SelectedValue = "-1"; + TxtIPLocal.Text = ""; + TxtPuerto.Text = ""; + BtnChecadorAgregar.Text = "Agregar"; + divChkEstatus.Visible = false; + UpModalTiposD.Update(); + RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD")); + } + + protected void BtnChecadorAgregar_Click(object sender, EventArgs e) + { + ClsRH ObjRH = new ClsRH(); + if (BtnChecadorAgregar.Text == "Agregar") + { + if (ObjRH.AddChecadores(TxtChecador.Text, DdlSubProyecto.SelectedValue.ToEntero(), TxtIPLocal.Text, TxtPuerto.Text, UsuarioActual.CveUsuario)) + { + Alert("Checador agregado correctamente"); + } + } + else + { + if (ObjRH.UpdateChecadores(CveChecador,TxtChecador.Text,DdlSubProyecto.SelectedValue.ToEntero(),TxtIPLocal.Text,TxtPuerto.Text,Estatus: ChkEstatus.Checked)) + { + Alert("Checador actualizado correctamente"); + } + } + ObjRH.Dispose(); + CargaDatos(); + UpDatos.Update(); + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD")); + } + + protected void LnkEditar_Click(object sender, EventArgs e) + { + GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer); + + CveChecador = GvRow.DataKey("CveChecador").ToEntero(); + TxtChecador.Text = GvRow.DataKey("Checador"); + DdlSubProyecto.SelectedValue = GvRow.DataKey("CveSubProyecto"); + TxtIPLocal.Text = GvRow.DataKey("IPLocal"); + TxtPuerto.Text = GvRow.DataKey("Puerto"); + BtnChecadorAgregar.Text = "Actualizar"; + ChkEstatus.Checked = GvRow.DataKey("Estatus") == "Activo"; + divChkEstatus.Visible = true; + UpModalTiposD.Update(); + RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD")); + } + + protected void LnkEliminar_Click(object sender, EventArgs e) + { + GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer); + + ClsRH ObjRH = new ClsRH(); + if (ObjRH.RemoveChecadores(GvRow.DataKey("CveChecador").ToEntero())) + { + Alert("Checador eliminado correctamente"); + CargaDatos(); + UpDatos.Update(); + } + ObjRH.Dispose(); + } +} \ No newline at end of file diff --git a/Ventas/Clientes.aspx.vb b/Ventas/Clientes.aspx.vb index afd23bfe7..a996cf41b 100644 --- a/Ventas/Clientes.aspx.vb +++ b/Ventas/Clientes.aspx.vb @@ -9161,7 +9161,7 @@ Partial Class Clientes End If - If ObjAcum.GetMovimientosDistribuidorResumen(CveCliente, UsuarioActual.CveEmpresa, TxtFechaIUsados.Text.ToDate, TxtFechaFUsados.Text.ToDate) Then + If ObjAcum.GetMovimientosDistribuidorResumen(CveCliente, UsuarioActual.CveEmpresa) Then GvUsadosResumen.DataSource = ObjAcum.DtResultados End If GvUsadosResumen.DataBind() diff --git a/Ventas/ProductosServicios.aspx.vb b/Ventas/ProductosServicios.aspx.vb index 6f9b5de8f..18dbbe908 100644 --- a/Ventas/ProductosServicios.aspx.vb +++ b/Ventas/ProductosServicios.aspx.vb @@ -1257,7 +1257,7 @@ Partial Class ProductosyServicios End If Next End If - If UsuarioActual.Empresa.Funcionalidad(563) <> "" Then + If UsuarioActual.Empresa.Funcionalidad(563) <> "" AndAlso ChkAplicaParaVenta.Checked Then TieneError = GuardarProductoEnFranquicia(ObjProductosServicios, PSS, CveMetodoInv, EsPaquete, True) End If @@ -1323,7 +1323,7 @@ Partial Class ProductosyServicios Next End If - If UsuarioActual.Empresa.Funcionalidad(563) <> "" Then + If UsuarioActual.Empresa.Funcionalidad(563) <> "" AndAlso ChkAplicaParaVenta.Checked Then TieneError = GuardarProductoEnFranquicia(ObjProductosServicios, PSS, CveMetodoInv, EsPaquete, False) End If diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index bab37aa2a..cb3ea762a 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -2746,14 +2746,15 @@ - + - +
    Contrato: +
    - - - - + + + + @@ -2790,19 +2791,23 @@
    -
    - -
    - +
    + +
    +
    - - + + - - + + -
    + +
    Estimacion: Estimacion: + +
    +
    @@ -2819,7 +2824,7 @@ <%----%> - +
    @@ -4314,7 +4319,7 @@ - + @@ -6289,6 +6294,11 @@ " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info">
    +
    + +
    +
    +
    @@ -6320,6 +6330,35 @@
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -6439,7 +6478,7 @@
    -
    +
    @@ -7988,65 +8027,65 @@ } - function FnCambiaAnt(chk, txt, saldo) { - debugger; + function FnCambiaAnt(chk, txt, saldo) { + debugger; - var Total = ToDouble($get('TxtSubTotal').value); - let TipoAnticipo = $('#<%= DdlTipoAmortizacionAnticipo.ClientID %>').val(); - let importeTxt = parseFloat(txt.value.replace(/,/g, '')); + var Total = ToDouble($get('TxtSubTotal').value); + let TipoAnticipo = $('#<%= DdlTipoAmortizacionAnticipo.ClientID %>').val(); + let importeTxt = parseFloat(txt.value.replace(/,/g, '')); - if (isNaN(importeTxt)) { - importeTxt = 0; - } else { - if (importeTxt <= 0) { + if (isNaN(importeTxt)) { importeTxt = 0; - chk.checked = false; - return; + } else { + if (importeTxt <= 0) { + importeTxt = 0; + chk.checked = false; + return; + } } + + saldo = (importeTxt > saldo) ? saldo : importeTxt; + + + + var SaldoCompra = (Total - FnSumaValoresAnt() + ToDouble(txt.value)).toFixed(2); // le agrego lo del valor actual para validarlo //parseFloat(parseFloat($get('HdnVentaSaldo').value).toFixed(2)); + if (SaldoCompra < 0) txt.value = SaldoCompra - txt.value; + //minimo entre saldocompra y el saldoanticipo + if (SaldoCompra < saldo) saldo = SaldoCompra; + + if (ToDouble(txt.value) > 0) { + chk.checked = true; + } else { + chk.checked = false; + } + + if (ToDouble(txt.value) > saldo) { + txt.value = saldo; + alert("El Importe no debe de exceder a el saldo"); + } + + $("#LblTotalAnticipos").text(FormatoNumero(FnSumaValoresAnt(), 2)); + + + $get('HdnVentaSaldo').value = Total - FnSumaValoresAnt(); } - saldo = (importeTxt > saldo) ? saldo : importeTxt; + function FnSumaValoresAnt() { + debugger; + var totalPoints = 0; + var t = ''; + $('input[name*=TxtAnticipo]').each(function () { + totalPoints += ToDouble($(this).val()); + }); - var SaldoCompra = (Total - FnSumaValoresAnt() + ToDouble(txt.value)).toFixed(2); // le agrego lo del valor actual para validarlo //parseFloat(parseFloat($get('HdnVentaSaldo').value).toFixed(2)); - if (SaldoCompra < 0) txt.value = SaldoCompra - txt.value; - //minimo entre saldocompra y el saldoanticipo - if (SaldoCompra < saldo) saldo = SaldoCompra; - if (ToDouble(txt.value) > 0) { - chk.checked = true; - } else { - chk.checked = false; + return Math.round(totalPoints * 100) / 100; } - if (ToDouble(txt.value) > saldo) { - txt.value = saldo; - alert("El Importe no debe de exceder a el saldo"); - } - - $("#LblTotalAnticipos").text(FormatoNumero(FnSumaValoresAnt(), 2)); - - - $get('HdnVentaSaldo').value = Total - FnSumaValoresAnt(); - } - - function FnSumaValoresAnt() { - debugger; - var totalPoints = 0; - var t = ''; - - - $('input[name*=TxtAnticipo]').each(function () { - totalPoints += ToDouble($(this).val()); - }); - - - return Math.round(totalPoints * 100) / 100; - } - - function LimpiaModal() { - $('#<%= TxtDireccion.ClientID %>').val(''); + function LimpiaModal() { + $('#<%= TxtDireccion.ClientID %>').val(''); $('#<%= TxtColonia.ClientID %>').val(''); $('#<%= TxtCiudad.ClientID %>').val(''); $('#<%= TxtEstado.ClientID %>').val(''); @@ -8271,68 +8310,68 @@ function ConvertirDolares(ChkConvertirDolares) { //LIMPIA $('#<%= LblDolaresConvertidos.ClientID %>').text(''); - $("#TrConversionDolaresTexto").hide(); + $("#TrConversionDolaresTexto").hide(); - //CALCULA - if (ChkConvertirDolares.checked) { - ConvertirPesosDlls(); - } - } + //CALCULA + if (ChkConvertirDolares.checked) { + ConvertirPesosDlls(); + } + } - //FUNCIONES PARA MODAL "ModalAplicarNC" - function CalculaImporteNC() { - var ImporteReferencia = (($('#C_DdlNCNivelImporte').val() == "1") ? ToDouble($get('TxtTotal').value) : ToDouble($get('TxtSubTotal').value)); - //var ImporteReferencia = ToDouble($get('TxtTotal').value); + //FUNCIONES PARA MODAL "ModalAplicarNC" + function CalculaImporteNC() { + var ImporteReferencia = (($('#C_DdlNCNivelImporte').val() == "1") ? ToDouble($get('TxtTotal').value) : ToDouble($get('TxtSubTotal').value)); + //var ImporteReferencia = ToDouble($get('TxtTotal').value); - $get('TxtNCImporte').value = FormatoNumero((ToDouble($get('TxtNCPorcentaje').value) * ImporteReferencia) / 100, 2); - } + $get('TxtNCImporte').value = FormatoNumero((ToDouble($get('TxtNCPorcentaje').value) * ImporteReferencia) / 100, 2); + } - function CalculaPorcentajeNC() { - var ImporteReferencia = (($('#C_DdlNCNivelImporte').val() == "1") ? ToDouble($get('TxtTotal').value) : ToDouble($get('TxtSubTotal').value)); - //var ImporteReferencia = ToDouble($get('TxtTotal').value); - $get('TxtNCPorcentaje').value = FormatoNumero((ToDouble($get('TxtNCImporte').value) * 100) / ImporteReferencia, 4); - } + function CalculaPorcentajeNC() { + var ImporteReferencia = (($('#C_DdlNCNivelImporte').val() == "1") ? ToDouble($get('TxtTotal').value) : ToDouble($get('TxtSubTotal').value)); + //var ImporteReferencia = ToDouble($get('TxtTotal').value); + $get('TxtNCPorcentaje').value = FormatoNumero((ToDouble($get('TxtNCImporte').value) * 100) / ImporteReferencia, 4); + } - function CambioTipoMoneda(chk, saldo, txt, tipocambio, CveMoneda) { - debugger; - if (tipocambio.value.length > 0) { + function CambioTipoMoneda(chk, saldo, txt, tipocambio, CveMoneda) { + debugger; + if (tipocambio.value.length > 0) { - if (CveMoneda == 1) { - txt.value = FormatoNumero(ToDouble(saldo / tipocambio.value), 2); - } else { - txt.value = FormatoNumero(ToDouble(saldo * tipocambio.value), 2); + if (CveMoneda == 1) { + txt.value = FormatoNumero(ToDouble(saldo / tipocambio.value), 2); + } else { + txt.value = FormatoNumero(ToDouble(saldo * tipocambio.value), 2); - } - } - } + } + } + } - function BuscarOCRegistrada() { - $('#btnBuscarOCRegistrada').click(); - } + function BuscarOCRegistrada() { + $('#btnBuscarOCRegistrada').click(); + } - function ValidaAnticipoBoton() { + function ValidaAnticipoBoton() { - var Descuentototal = ToDouble($('#LblDescuentos').text()).toFixed(2); - var TotalAnticipos = ToDouble($('#LblTotalAnticipos').text()).toFixed(2); + var Descuentototal = ToDouble($('#LblDescuentos').text()).toFixed(2); + var TotalAnticipos = ToDouble($('#LblTotalAnticipos').text()).toFixed(2); - var IndexActualDdl = parseInt($('#<%= DdlTipoAmortizacionAnticipo.ClientID %>').prop('selectedIndex')); + var IndexActualDdl = parseInt($('#<%= DdlTipoAmortizacionAnticipo.ClientID %>').prop('selectedIndex')); if (IndexActualDdl == 1 && IndexActualDd2 > 0 && TotalAnticipos > 0) { if (TotalAnticipos > 0) { $('#<%= BtnAceptarAnticipos.ClientID %>').prop('disabled', false); - } else { - $('#<%= BtnAceptarAnticipos.ClientID %>').prop('disabled', true); - } - } else { - $('#<%= BtnAceptarAnticipos.ClientID %>').prop('disabled', true); - } + } else { + $('#<%= BtnAceptarAnticipos.ClientID %>').prop('disabled', true); + } + } else { + $('#<%= BtnAceptarAnticipos.ClientID %>').prop('disabled', true); + } - } + } - function showDivEC() { - $('#<%= TxtRFCCliente.ClientID %>').val(''); + function showDivEC() { + $('#<%= TxtRFCCliente.ClientID %>').val(''); $('#<%= TxtNombreCliente.ClientID %>').val(''); $('#<%= TxtDireccionCliente.ClientID %>').val(''); $('#<%= TxtNumExtCliente.ClientID %>').val(''); diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index a6142e15a..2a8583eed 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -144,6 +144,22 @@ Partial Class Ventas ViewState("TmpDTRNCBonificacionesSeleccionadas") = value End Set End Property + Private Property TmpDTRNCDetalle As DataTable + Get + Return If(IsNothing(ViewState("TmpDTRNCDetalle")), Nothing, CType(ViewState("TmpDTRNCDetalle"), DataTable)) + End Get + Set(value As DataTable) + ViewState("TmpDTRNCDetalle") = value + End Set + End Property + Private Property TmpDTRNCDetalleSelecciondas As DataTable + Get + Return If(IsNothing(ViewState("TmpDTRNCDetalleSelecciondas")), Nothing, CType(ViewState("TmpDTRNCDetalleSelecciondas"), DataTable)) + End Get + Set(value As DataTable) + ViewState("TmpDTRNCDetalleSelecciondas") = value + End Set + End Property Private Property TmpDTError As DataTable Get Return If(IsNothing(ViewState("TmpDTError")), Nothing, CType(ViewState("TmpDTError"), DataTable)) @@ -1861,6 +1877,22 @@ Partial Class Ventas ViewState("SerieVenta") = value End Set End Property + Private Property AplicaDocumentoNuevoNC As Boolean + Get + Return CBool(IfNull(ViewState("AplicaDocumentoNuevoNC"), "False", ViewState("AplicaDocumentoNuevoNC"))) + End Get + Set(value As Boolean) + ViewState("AplicaDocumentoNuevoNC") = value + End Set + End Property + Private Property AplicaRNCXDetalle As Boolean + Get + Return CBool(IfNull(ViewState("AplicaRNCXDetalle"), "False", ViewState("AplicaRNCXDetalle"))) + End Get + Set(value As Boolean) + ViewState("AplicaRNCXDetalle") = value + End Set + End Property #End Region @@ -3928,6 +3960,7 @@ Partial Class Ventas TmpDT = ObjVentas.DtResultados TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer)) + TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer)) GvPS.DataSource = ObjVentas.DtResultados GvPS.DataBind() @@ -5618,7 +5651,7 @@ Partial Class Ventas Dim ObjClientes As New ClsClientes If ObjClientes.GetHistorialVentas(CveCliente, 1000, CveClienteSucursal:=-1, TipoDocto:="Ing", CveEstatusFactura:=-1, FechaI:=Now.AddMonths(-1)) Then - DdlVentaUsado.DataSource = ObjClientes.DtResultados + DdlVentaUsado.DataSource = ObjClientes.DtResultados.FiltraParametros("UsadoMarcado = 0") End If ObjClientes.Dispose() @@ -6664,6 +6697,7 @@ Partial Class Ventas TmpDT.Rows(e.RowIndex)("ImporteIVA") = (TmpDT.Rows(e.RowIndex)("PorcentajeIVA").ToString().ToDecimal * TotalCalculableImpuestosIVA).RoundSQL(NumeroDecimales) TmpDT.Rows(e.RowIndex)("ImporteIEPS") = (TmpDT.Rows(e.RowIndex)("PorcentajeIEPS").ToString().ToDecimal * TotalCalculableImpuestos).RoundSQL(NumeroDecimales) TmpDT.Rows(e.RowIndex)("ImporteRetIVA") = (ClienteRetIVA * TotalCalculableImpuestos).RoundSQL(NumeroDecimales) + TmpDT.Rows(e.RowIndex)("RetIVA") = (ClienteRetIVA * TotalCalculableImpuestos).RoundSQL(NumeroDecimales) TmpDT.Rows(e.RowIndex)("ImporteRetISR") = (ClienteRetISR * TotalCalculableImpuestos).RoundSQL(NumeroDecimales) TmpDT.Rows(e.RowIndex)("PorcentajeRetIVA") = ClienteRetIVA TmpDT.Rows(e.RowIndex)("PorcentajeRetISR") = ClienteRetISR @@ -8577,7 +8611,7 @@ Partial Class Ventas End If 'SI NO ES REFACTURACION - If NuevaFactura <> 1 Then + If NuevaFactura <> 1 AndAlso Not AplicaDocumentoNuevoNC Then If DtVentasNC Is Nothing Then InicializaDTVentasNC() Dim Drt = DtVentasNC.NewRow Drt("CveVenta") = ObjFactura.CveVenta @@ -10499,6 +10533,15 @@ Partial Class Ventas Catch ex As Exception End Try + 'SI SE FACTURA UNA RNC SE MUESTRA + If UsuarioActual.CveEmpresa = 140 AndAlso factura.TipoDocto = "Egs" Then + If Row("CveVentaDetalleRNC").ToString().ToEntero() > 0 Then + If Not ObjVentas.AddVentaDetalleRNCFacturada(Row("CveVentaDetalleRNC").ToString().ToEntero(), ObjVentas.CveVentaDetalle, Row("Cantidad").ToString().ToDecimal()) Then + ErrorList.Add("Ocurrió un error al agregar la venta detalle devolución.") + End If + End If + End If + End If Next @@ -11591,6 +11634,13 @@ Partial Class Ventas CveCuenta = ObjFactura.Cliente.CveCuentaMonedaExtranjera End If + 'ACTUALIZA SI LA VENTA FUE MARCADA CON OTRA PARA EL FILTRO DE USADOS + If ObjRNC.Num3 > 0 Then + If Not ObjVentas.UpdateVentaRNCUsado(ObjRNC.CveVenta, ObjRNC.Num3.ToEntero()) Then + ErrorPrepoliza = True + End If + End If + IdCtaContableCliente = IdCtaContable CveCuentaCliente = CveCuenta @@ -16259,6 +16309,7 @@ Partial Class Ventas Row("IVA") = Row("PorcentajeIVA") Row("ImporteIVA") = (Row("PorcentajeIVA").ToString().ToDecimal * TotalCalculableImpuestosIVA).RoundAD(NumeroDecimales) Row("ImporteRetIVA") = (ClienteRetIVA * TotalCalculableImpuestos).RoundAD(NumeroDecimales) + Row("RetIVA") = (ClienteRetIVA * TotalCalculableImpuestos).RoundAD(NumeroDecimales) Row("ImporteRetISR") = (ClienteRetISR * TotalCalculableImpuestos).RoundAD(NumeroDecimales) Row("PorcentajeRetIVA") = ClienteRetIVA Row("PorcentajeRetISR") = ClienteRetISR @@ -16510,6 +16561,7 @@ Partial Class Ventas TmpDT.Columns.Add("EsOutSourcing", GetType(Boolean)) TmpDT.Columns.Add("EsCargo", GetType(Boolean)) + TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer)) TmpDT.Columns("EsOutSourcing").DefaultValue = False TmpDT.Columns("EsCargo").DefaultValue = False @@ -23572,6 +23624,18 @@ Partial Class Ventas ObjMovtos.Dispose() GvCxC.DataBind() End Sub + Protected Sub ChkMostarProductosRNC_CheckedChanged(sender As Object, e As EventArgs) + If ChkMostarProductosRNC.Checked Then + DivRNCCargos.Visible = False + DivRNCCargosDetalle.Visible = True + CargaRNCDetalle(DdlVentaUsado.SelectedValue.ToEntero()) + Else + DivRNCCargos.Visible = True + DivRNCCargosDetalle.Visible = False + CargaRNC(DdlVentaUsado.SelectedValue.ToEntero()) + End If + UpModalRemisionesNC.Update() + End Sub Private Sub CargaRNC(Optional CveVentaUsado As Integer = -1) Dim DtNC As DataTable = Nothing @@ -23605,8 +23669,58 @@ Partial Class Ventas If ObjAcum.GetMovimientosDistribuidorResumen(CveCliente, UsuarioActual.CveEmpresa) Then Dim RowUsadosNC As DataRow = ObjAcum.DtResultados.Rows(2) DivSMU.Visible = True - HdnSaldoMaximoUsados.Value = RowUsadosNC("Valor").ToString() - LtlSMU.Text = RowUsadosNC("Valor").ToString().ToDecimal().FormatoNumero(2) + HdnSaldoMaximoUsados.Value = RowUsadosNC("ValorConImpuestos").ToString() + LtlSMU.Text = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal().FormatoNumero(2) + Else + DivSMU.Visible = False + HdnSaldoMaximoUsados.Value = "0" + LtlSMU.Text = "0" + End If + ObjAcum.Dispose() + End If + + UpModalRemisionesNC.Update() + UpDescNC.Update() + End Sub + Private Sub CargaRNCDetalle(Optional CveVentaUsado As Integer = -1) + Dim DtNC As DataTable = Nothing + + Dim ObjMovtos As New ClsMovimientos() + If ObjMovtos.GetRemisionesNCCliente(CveCliente, True, CveMoneda:=-1, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero()) Then + Me.TmpDTRNCDetalle = ObjMovtos.DtResultados.Copy() + End If + ObjMovtos.Dispose() + + Me.TmpDTRNCDetalle.Columns.Add(New DataColumn("CveVentaDetalleNCGenerada", GetType(Integer))) + + Me.TmpDTRNCDetalleSelecciondas = Nothing + Me.TmpDTRNCDetalleSelecciondas = TmpDTRNCDetalle.Clone() + Me.TmpDTRNCDetalleSelecciondas.Clear() + + GvRemisionesNCDetalle.DataSource = TmpDTRNCDetalle.FiltraParametros("TipoRNC = 1") + 'GvRemisionesNCBon.DataSource = TmpDTRNCBonificacionesSeleccionadas + + 'Me.TmpDTRNCBonificacionesCliente = DtNC.FiltraParametros("TipoRNC = 2") + 'Me.TmpDTRNCBonificacionesCliente.Columns.Add("ImporteBonificacion", GetType(Decimal)) + 'Me.TmpDTRNCBonificacionesCliente.Columns.Add("IVABonificacion", GetType(Decimal)) + 'Me.TmpDTRNCBonificacionesCliente.Columns.Add("CveVentaRNCCargo", GetType(Integer)) + + GvRemisionesNCDetalle.DataBind() + 'GvRemisionesNCBon.DataBind() + + If CveVentaUsado > 0 Then + DivSMU.Visible = True + Dim FacUsado As New Modelos.Factura(UsuarioActual, CveVentaUsado, UsuarioActual.CveEmpresa) + Dim SaldoMaximoUsados As Decimal = FacUsado.DtDetalle.SUM("Total", "EsCargo = True").ToDecimal() + FacUsado.DtDetalle.SUM("ImporteIVA", "EsCargo = True").ToDecimal() + HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString() + LtlSMU.Text = String.Format("{0:N2}", SaldoMaximoUsados) + Else + Dim ObjAcum As New ClsAcumuladores + If ObjAcum.GetMovimientosDistribuidorResumen(CveCliente, UsuarioActual.CveEmpresa) Then + Dim RowUsadosNC As DataRow = ObjAcum.DtResultados.Rows(2) + DivSMU.Visible = True + HdnSaldoMaximoUsados.Value = RowUsadosNC("ValorConImpuestos").ToString() + LtlSMU.Text = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal().FormatoNumero(2) Else DivSMU.Visible = False HdnSaldoMaximoUsados.Value = "0" @@ -23816,6 +23930,15 @@ Partial Class Ventas e.Row.FCTextBox("TxtImporte").Attributes.Add("onkeyup", $"LimitaSaldoRNCChk({e.Row.FCTextBox("TxtImporte").ClientID},{e.Row.DBCampo("Saldo").ToDouble}, this);") End If End Sub + Protected Sub GvRemisionesNCDetalle_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvRemisionesNCDetalle.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CveVentaDetalleRNC").ToEntero() = 0 Then + e.Row.CssClass = "Totales" + e.Row.FCCheckBox("ChkAplicar").Visible = False + e.Row.FCTextBox("TxtCantidadRNC").Visible = False + End If + End If + End Sub Protected Sub DdlNCNivelImporte_SelectedIndexChanged(sender As Object, e As EventArgs) Dim ImporteReferencia As Double = 0, PorcentajeMaximo As Double = 0 @@ -23844,7 +23967,7 @@ Partial Class Ventas 'SOLO APLICA SI NO HAY DOCUMENTOS QUE SELECCIONAR If UsuarioActual.CveEmpresa = 140 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 nota de crédito, 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    ") + 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    ") Else AplicarNotaCreditoDesdeVenta() End If @@ -23900,6 +24023,7 @@ Partial Class Ventas Private Sub AplicarNC(CvePS As Integer, Optional NCDescuento As Boolean = False, Optional EsNCAmortizacion As Boolean = False, Optional AplicaImpuestosLocales As Boolean = True, Optional AplicaNuevoDocumento As Boolean = False, Optional AplicoNCFacturaActual As Boolean = False) Try + Me.AplicaDocumentoNuevoNC = AplicaNuevoDocumento Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") If DrPS Is Nothing Then Alert("Ocurrió un error al cargar la información del producto. Por favor comuniquese con asistencia SIG", TipoMensaje.MsgError) @@ -24068,11 +24192,22 @@ Partial Class Ventas TmpDTDescNC.Clear() If UsuarioActual.CveEmpresa = 140 Then + If AplicaRNCXDetalle Then + CrearDTNCCargoDetalle(ListaNCDesc, TmpDTDescNC, DrPS, CveProyecto, Proyecto, CveSubProyecto, SubProyecto) + Else + CrearDTNCCargo(ListaNCDesc, TmpDTDescNC, DrPS, CveProyecto, Proyecto, CveSubProyecto, SubProyecto) + End If - CrearDTNCCargo(ListaNCDesc, DtImpuestos, TmpDTDescNC, DrPS, CveProyecto, Proyecto, CveSubProyecto, SubProyecto) + + 'CONSULTA EL CONCEPTO DE NC + Dim ArrayNC As String() = UsuarioActual.Empresa.Funcionalidad(591).Split(",".ToCharArray()) + Dim NCBonificacion As Integer = 0 + If ArrayNC.Length > 4 Then + NCBonificacion = ArrayNC(4).ToEntero() + End If 'EN LA NC DE BONIFICACION EL CONCEPTO DEBE SER SIEMPRE 'BONIFICACION POR USADO' - Dim DrPSBonificacion = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=360481).FiltroPrimero("") + Dim DrPSBonificacion = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=NCBonificacion).FiltroPrimero("") If DrPSBonificacion IsNot Nothing Then CrearDTNCBonificacion(ListaNCDesc, DtImpuestosBonificacion, TmpDTDescNC, DrPSBonificacion, CveProyecto, Proyecto, CveSubProyecto, SubProyecto) Else @@ -24109,9 +24244,20 @@ Partial Class Ventas 'DEBE AGREGAR LOS USADOS DE LA REMISION EN LA NOTA DE CREDITO If UsuarioActual.CveEmpresa = 140 AndAlso (ListaRemisionesNC IsNot Nothing AndAlso ListaRemisionesNC.Count > 0) Then - CrearDTNCCargo(ListaRemisionesNC, DtImpuestos, TmpDT, DrPS, CveProyecto, Proyecto, CveSubProyecto, SubProyecto) + If AplicaRNCXDetalle Then + CrearDTNCCargoDetalle(ListaRemisionesNC, TmpDT, DrPS, CveProyecto, Proyecto, CveSubProyecto, SubProyecto) + Else + CrearDTNCCargo(ListaRemisionesNC, TmpDT, DrPS, CveProyecto, Proyecto, CveSubProyecto, SubProyecto) + End If + 'EN LA NC DE BONIFICACION EL CONCEPTO DEBE SER SIEMPRE 'BONIFICACION POR USADO' - Dim DrPSBonificacion = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=360481).FiltroPrimero("") + 'CONSULTA EL CONCEPTO DE NC + Dim ArrayNC As String() = UsuarioActual.Empresa.Funcionalidad(591).Split(",".ToCharArray()) + Dim NCBonificacion As Integer = 0 + If ArrayNC.Length > 4 Then + NCBonificacion = ArrayNC(4).ToEntero() + End If + Dim DrPSBonificacion = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=NCBonificacion).FiltroPrimero("") If DrPSBonificacion IsNot Nothing Then CrearDTNCBonificacion(ListaRemisionesNC, DtImpuestosBonificacion, TmpDT, DrPSBonificacion, CveProyecto, Proyecto, CveSubProyecto, SubProyecto) Else @@ -24172,42 +24318,104 @@ Partial Class Ventas UPCondicionesPago.Update() End Sub - Private Sub CrearDTNCCargo(ListaNC As List(Of Modelos.Factura), DtImpuestos As DataTable, ByRef TmpDTCargo As DataTable, DrPS As DataRow, CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String) - For Each Dr As DataRow In DtImpuestos.Rows - For Each RNC In ListaNC - Dim UltimoRenglonRNC As Integer = 1 - For Each RowUsado As DataRow In RNC.DtDetalle.Rows + Private Sub CrearDTNCCargo(ListaNC As List(Of Modelos.Factura), ByRef TmpDTCargo As DataTable, DrPS As DataRow, CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String) + For Each RNC In ListaNC + Dim UltimoRenglonRNC As Integer = 1 + Dim TotalAcumuladoRNC As Decimal = 0 - Dim PorcentajeUsado = ((RowUsado("Total").ToString().ToDecimal() - RowUsado("Descuento").ToString().ToDecimal() + RowUsado("ImporteIVA").ToString().ToDecimal() + RowUsado("ImporteIEPS").ToString().ToDecimal() - RowUsado("ImporteRetIVA").ToString().ToDecimal() - RowUsado("ImporteRetISR").ToString().ToDecimal()) / RNC.Total) / ListaNC.Count - Dim Obs = RowUsado("CodigoPS").ToString() + For Each RowUsado As DataRow In RNC.DtDetalle.Rows - If Not String.IsNullOrEmpty(TxtNCObservaciones.Text.Trim()) Then - Obs = String.Format("{0} - {1}", Obs, TxtNCObservaciones.Text.Trim()) + Dim PorcentajeAplicado = (RNC.TotalRemNCAplicado / RNC.Total) + + Dim Cantidad As Decimal = RowUsado("Cantidad").ToString().ToDecimal() * PorcentajeAplicado + + Dim Obs = RowUsado("CodigoPS").ToString() + + If Not String.IsNullOrEmpty(TxtNCObservaciones.Text.Trim()) Then + Obs = String.Format("{0} - {1}", Obs, TxtNCObservaciones.Text.Trim()) + End If + + Dim ImportePU = RowUsado("PU").ToString().ToDecimal + + Dim TotalCalculableImpuestos As Decimal = (Cantidad * ImportePU) + + Dim ImporteIVA = (TotalCalculableImpuestos * RowUsado("PorcentajeIVA").ToString().ToDecimal).RoundSQL(2) + Dim ImporteIEPS = (TotalCalculableImpuestos * RowUsado("PorcentajeIEPS").ToString().ToDecimal).RoundSQL(2) + Dim ImporteRetIVA = (TotalCalculableImpuestos * RowUsado("PorcentajeRetIVA").ToString().ToDecimal).RoundSQL(2) + Dim ImporteRetISR = (TotalCalculableImpuestos * RowUsado("PorcentajeRetISR").ToString().ToDecimal).RoundSQL(2) + Dim ImporteTotal = TotalCalculableImpuestos + + TotalAcumuladoRNC += (TotalCalculableImpuestos + ImporteIVA + ImporteIEPS - ImporteRetIVA - ImporteRetISR) + + 'SI ES EL ULTIMO REGLON REALIZA UN AJUSTE + If UltimoRenglonRNC = RNC.DtDetalle.Rows.Count Then + Dim Ajuste As Decimal = 0 + If Math.Abs(RNC.TotalRemNCAplicado - TotalAcumuladoRNC) > 0.00 Then + Ajuste = RNC.TotalRemNCAplicado - TotalAcumuladoRNC + + ImporteIVA += Ajuste End If + End If + UltimoRenglonRNC += 1 - Dim ImportePU = Dr("ImportePU").ToString().ToDecimal * PorcentajeUsado - Dim ImporteIVA = Dr("ImporteIVA").ToString().ToDecimal * PorcentajeUsado - Dim ImporteRetIVA = Dr("ImporteRetIVA").ToString().ToDecimal * PorcentajeUsado - Dim ImporteRetISR = Dr("ImporteRetISR").ToString().ToDecimal * PorcentajeUsado - Dim ImporteIEPS = Dr("ImporteIEPS").ToString().ToDecimal * PorcentajeUsado - Dim ImporteTotal = Dr("ImporteTotal").ToString().ToDecimal * PorcentajeUsado - - 'If UltimoRenglonRNC = RNC.DtDetalle.Rows.Count Then - ' ImportePU += Ajuste - 'End If - - AgregaTempDT(TmpDTCargo, DrPS("CvePS").ToString().ToEntero(), DrPS("PS").ToString(), DrPS("Codigo").ToString(), DrPS("PSCodigo").ToString(), DrPS("CveTipoPS").ToString().ToEntero(), DrPS("Inv_CveMetodoInventario").ToString().ToEntero(), + AgregaTempDT(TmpDTCargo, DrPS("CvePS").ToString().ToEntero(), DrPS("PS").ToString(), DrPS("Codigo").ToString(), DrPS("PSCodigo").ToString(), DrPS("CveTipoPS").ToString().ToEntero(), DrPS("Inv_CveMetodoInventario").ToString().ToEntero(), DrPS("CveUM").ToString().ToEntero(), DrPS("UnidadMedida").ToString(), DrPS("CveClasificacion").ToString().ToEntero(), DrPS("Clasificacion").ToString(), CveProyecto, Proyecto, CveSubProyecto, SubProyecto, - Obs, 1, ImportePU, Dr("PorcentajeIVA").ToString().ToDecimal, ImporteIVA, Dr("PorcentajeRetIVA").ToString().ToDecimal, ImporteRetIVA, - Dr("PorcentajeRetISR").ToString().ToDecimal, ImporteRetISR, Dr("PorcentajeIEPS").ToString().ToDecimal, ImporteIEPS, -1, 0.0, ImporteTotal, "", "", -1, -1, - DrPS("SATClavePS").ToString(), DrPS("SATClaveUnidadMedida").ToString(), -1, -1, -1, -1, -1, -1) - - UltimoRenglonRNC += 1 - Next - + Obs, Cantidad, ImportePU, RowUsado("PorcentajeIVA").ToString().ToDecimal, ImporteIVA, RowUsado("PorcentajeRetIVA").ToString().ToDecimal, ImporteRetIVA, + RowUsado("PorcentajeRetISR").ToString().ToDecimal, ImporteRetISR, RowUsado("PorcentajeIEPS").ToString().ToDecimal, ImporteIEPS, -1, 0.0, ImporteTotal, "", "", -1, -1, + DrPS("SATClavePS").ToString(), DrPS("SATClaveUnidadMedida").ToString(), -1, -1, -1, -1, -1, -1, CveVentaDetalleRNC:=RowUsado("CveVentaDetalle").ToString().ToEntero()) Next + Next End Sub + Private Sub CrearDTNCCargoDetalle(ListaNC As List(Of Modelos.Factura), ByRef TmpDTCargo As DataTable, DrPS As DataRow, CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String) + For Each RNC In ListaNC + Dim UltimoRenglonRNC As Integer = 1 + Dim TotalAcumuladoRNC As Decimal = 0 + + For Each RowUsado As DataRow In Me.TmpDTRNCDetalleSelecciondas.FiltraParametros($"CveVenta={RNC.CveVenta}").Rows + + Dim Cantidad As Decimal = RowUsado("Cantidad").ToString().ToDecimal() + + Dim Obs = RowUsado("CodigoPS").ToString() + + If Not String.IsNullOrEmpty(TxtNCObservaciones.Text.Trim()) Then + Obs = String.Format("{0} - {1}", Obs, TxtNCObservaciones.Text.Trim()) + End If + + Dim ImportePU = RowUsado("PU").ToString().ToDecimal + + Dim TotalCalculableImpuestos As Decimal = (Cantidad * ImportePU) + + Dim ImporteIVA = (TotalCalculableImpuestos * RowUsado("PorcentajeIVA").ToString().ToDecimal).RoundSQL(2) + Dim ImporteIEPS = 0 '(TotalCalculableImpuestos * RowUsado("PorcentajeIEPS").ToString().ToDecimal).RoundSQL(2) + Dim ImporteRetIVA = 0 ' (TotalCalculableImpuestos * RowUsado("PorcentajeRetIVA").ToString().ToDecimal).RoundSQL(2) + Dim ImporteRetISR = 0 ' (TotalCalculableImpuestos * RowUsado("PorcentajeRetISR").ToString().ToDecimal).RoundSQL(2) + Dim ImporteTotal = TotalCalculableImpuestos + + TotalAcumuladoRNC += (TotalCalculableImpuestos + ImporteIVA) + + 'SI ES EL ULTIMO REGLON REALIZA UN AJUSTE + If UltimoRenglonRNC = RNC.DtDetalle.Rows.Count Then + Dim Ajuste As Decimal = 0 + If Math.Abs(RNC.TotalRemNCAplicado - TotalAcumuladoRNC) > 0.00 Then + Ajuste = RNC.TotalRemNCAplicado - TotalAcumuladoRNC + + ImporteIVA += Ajuste + End If + End If + UltimoRenglonRNC += 1 + + AgregaTempDT(TmpDTCargo, DrPS("CvePS").ToString().ToEntero(), DrPS("PS").ToString(), DrPS("Codigo").ToString(), DrPS("PSCodigo").ToString(), DrPS("CveTipoPS").ToString().ToEntero(), DrPS("Inv_CveMetodoInventario").ToString().ToEntero(), + DrPS("CveUM").ToString().ToEntero(), DrPS("UnidadMedida").ToString(), DrPS("CveClasificacion").ToString().ToEntero(), DrPS("Clasificacion").ToString(), CveProyecto, Proyecto, CveSubProyecto, SubProyecto, + Obs, Cantidad, ImportePU, RowUsado("PorcentajeIVA").ToString().ToDecimal, ImporteIVA, 0, ImporteRetIVA, + 0, ImporteRetISR, 0, ImporteIEPS, -1, 0.0, ImporteTotal, "", "", -1, -1, + DrPS("SATClavePS").ToString(), DrPS("SATClaveUnidadMedida").ToString(), -1, -1, -1, -1, -1, -1, CveVentaDetalleRNC:=RowUsado("CveVentaDetalleRNC").ToString().ToEntero()) + Next + + Next + End Sub + + Private Sub CrearDTNCBonificacion(ListaNC As List(Of Modelos.Factura), DtImpuestosBonificacion As DataTable, ByRef TmpDTNC As DataTable, DrPS As DataRow, CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String) 'SI TIENE DE BONIFICACION LOS AGREGA If DtImpuestosBonificacion IsNot Nothing AndAlso ListaNCBonificacion IsNot Nothing AndAlso ListaNCBonificacion.Count > 0 Then @@ -24215,39 +24423,54 @@ Partial Class Ventas TmpDTDescNCBonificacion = TmpDTNC.Clone() TmpDTDescNCBonificacion.Clear() - For Each Dr As DataRow In DtImpuestosBonificacion.Rows - For Each RNC In ListaNCBonificacion - Dim UltimoRenglonRNC As Integer = 1 + For Each RNCBonificacion In ListaNCBonificacion + Dim UltimoRenglonRNC As Integer = 1 + Dim TotalAcumuladoRNC As Decimal = 0 - Dim RNCCargo = ListaNC.Where(Function(f) f.CveVenta = RNC.CveVentaRNCCargo).FirstOrDefault() + Dim RNCCargo = ListaNC.Where(Function(f) f.CveVenta = RNCBonificacion.CveVentaRNCCargo).FirstOrDefault() - For Each RowCargo As DataRow In RNCCargo.DtDetalle.Rows + For Each RowCargo As DataRow In RNCCargo.DtDetalle.Rows - Dim PorcentajeCargo = ((RowCargo("Total").ToString().ToDecimal() - RowCargo("Descuento").ToString().ToDecimal() + RowCargo("ImporteIVA").ToString().ToDecimal() + RowCargo("ImporteIEPS").ToString().ToDecimal() - RowCargo("ImporteRetIVA").ToString().ToDecimal() - RowCargo("ImporteRetISR").ToString().ToDecimal()) / RNCCargo.Total) / ListaNCBonificacion.Count + Dim PorcentajeAplicado = (RNCBonificacion.TotalRemNCAplicado / RNCBonificacion.Total) - Dim Obs = RowCargo("CodigoPS").ToString() + Dim Cantidad As Decimal = RowCargo("Cantidad").ToString().ToDecimal() * PorcentajeAplicado - If Not String.IsNullOrEmpty(TxtNCObservaciones.Text.Trim()) Then - Obs = String.Format("{0} - {1}", Obs, TxtNCObservaciones.Text.Trim()) + Dim Obs = RowCargo("CodigoPS").ToString() + + If Not String.IsNullOrEmpty(TxtNCObservaciones.Text.Trim()) Then + Obs = String.Format("{0} - {1}", Obs, TxtNCObservaciones.Text.Trim()) + End If + + Dim ImportePU = RowCargo("PUBonificacion").ToString().ToDecimal + + Dim TotalCalculableImpuestos As Decimal = (Cantidad * ImportePU) + + Dim ImporteIVA = (TotalCalculableImpuestos * RowCargo("PorcentajeIVA").ToString().ToDecimal).RoundSQL(2) + Dim ImporteIEPS = (TotalCalculableImpuestos * RowCargo("PorcentajeIEPS").ToString().ToDecimal).RoundSQL(2) + Dim ImporteRetIVA = (TotalCalculableImpuestos * RowCargo("PorcentajeRetIVA").ToString().ToDecimal).RoundSQL(2) + Dim ImporteRetISR = (TotalCalculableImpuestos * RowCargo("PorcentajeRetISR").ToString().ToDecimal).RoundSQL(2) + Dim ImporteTotal = TotalCalculableImpuestos + + TotalAcumuladoRNC += (TotalCalculableImpuestos + ImporteIVA + ImporteIEPS - ImporteRetIVA - ImporteRetISR) + + 'SI ES EL ULTIMO REGLON REALIZA UN AJUSTE + If UltimoRenglonRNC = RNCCargo.DtDetalle.Rows.Count Then + Dim Ajuste As Decimal = 0 + If Math.Abs(RNCBonificacion.TotalRemNCAplicado - TotalAcumuladoRNC) > 0.00 Then + Ajuste = RNCBonificacion.TotalRemNCAplicado - TotalAcumuladoRNC + + ImporteIVA += Ajuste End If + End If + UltimoRenglonRNC += 1 - Dim ImportePU = Dr("ImportePU").ToString().ToDecimal * PorcentajeCargo - Dim ImporteIVA = Dr("ImporteIVA").ToString().ToDecimal * PorcentajeCargo - Dim ImporteRetIVA = Dr("ImporteRetIVA").ToString().ToDecimal * PorcentajeCargo - Dim ImporteRetISR = Dr("ImporteRetISR").ToString().ToDecimal * PorcentajeCargo - Dim ImporteIEPS = Dr("ImporteIEPS").ToString().ToDecimal * PorcentajeCargo - Dim ImporteTotal = Dr("ImporteTotal").ToString().ToDecimal * PorcentajeCargo - - AgregaTempDT(TmpDTDescNCBonificacion, DrPS("CvePS").ToString().ToEntero(), DrPS("PS").ToString(), DrPS("Codigo").ToString(), DrPS("PSCodigo").ToString(), DrPS("CveTipoPS").ToString().ToEntero(), DrPS("Inv_CveMetodoInventario").ToString().ToEntero(), + AgregaTempDT(TmpDTDescNCBonificacion, DrPS("CvePS").ToString().ToEntero(), DrPS("PS").ToString(), DrPS("Codigo").ToString(), DrPS("PSCodigo").ToString(), DrPS("CveTipoPS").ToString().ToEntero(), DrPS("Inv_CveMetodoInventario").ToString().ToEntero(), DrPS("CveUM").ToString().ToEntero(), DrPS("UnidadMedida").ToString(), DrPS("CveClasificacion").ToString().ToEntero(), DrPS("Clasificacion").ToString(), CveProyecto, Proyecto, CveSubProyecto, SubProyecto, - Obs, 1, ImportePU, Dr("PorcentajeIVA").ToString().ToDecimal, ImporteIVA, Dr("PorcentajeRetIVA").ToString().ToDecimal, ImporteRetIVA, - Dr("PorcentajeRetISR").ToString().ToDecimal, ImporteRetISR, Dr("PorcentajeIEPS").ToString().ToDecimal, ImporteIEPS, -1, 0.0, ImporteTotal, "", "", -1, -1, + Obs, Cantidad, ImportePU, RowCargo("PorcentajeIVA").ToString().ToDecimal, ImporteIVA, RowCargo("PorcentajeRetIVA").ToString().ToDecimal, ImporteRetIVA, + RowCargo("PorcentajeRetISR").ToString().ToDecimal, ImporteRetISR, RowCargo("PorcentajeIEPS").ToString().ToDecimal, ImporteIEPS, -1, 0.0, ImporteTotal, "", "", -1, -1, DrPS("SATClavePS").ToString(), DrPS("SATClaveUnidadMedida").ToString(), -1, -1, -1, -1, -1, -1) - - UltimoRenglonRNC += 1 - Next - Next + Next End If End Sub @@ -24362,7 +24585,7 @@ Partial Class Ventas PorcentajeRetISR As Double, ImporteRetISR As Double, PorcentajeIEPS As Double, ImporteIEPS As Double, TipoDescuento As Integer, Descuento As Double, Total As Double, Serie As String, TiempoEntrega As String, CvePresupuestoIngreso As Integer, EntregaDirecta As Integer, SATClaveProdServ As String, SATClaveUM As String, CveContratoDetalle As Integer, CveVentaDetalle As Integer, CveMovimientoDetallePedido As Integer, CveOrdenCompraDetalle As Integer, - CveVentaDetalleRemision As Integer, CveVentaDetalleCotizacion As Integer, Optional CveTamaño As Integer = -1) + CveVentaDetalleRemision As Integer, CveVentaDetalleCotizacion As Integer, Optional CveTamaño As Integer = -1, Optional CveVentaDetalleRNC As Integer = -1) Dim Row As DataRow = Nothing Row = TmpDT.NewRow() @@ -24422,6 +24645,7 @@ Partial Class Ventas Row("CveVentaDetalleCotizacion") = CveVentaDetalleCotizacion Row("CveTamaño") = CveTamaño + Row("CveVentaDetalleRNC") = CveVentaDetalleRNC TmpDT.Rows.Add(Row) End Sub @@ -25469,7 +25693,8 @@ Partial Class Ventas If Not ObjVentas.AddVentaDetalle(CveVenta, Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDouble, Row("CveUM").ToString().ToEntero(), Row("PU").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("ImporteIVA").ToString().ToDouble, Math.Round((Row("Total").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)) * (1 + Row("PorcentajeIVA").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)))), 6), Row("Obs").ToString(), Row("Descuento").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("TipoDescuento").ToString().ToEntero(), Row("CveSubProyecto").ToString().ToEntero(), Row("CvePresupuestoIngreso").ToString().ToEntero(), - PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, IEPS:=Row("ImporteIEPS").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().ToDouble, TiempoEntrega:=Row("TiempoEntrega").ToString()) Then + PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, IEPS:=Row("ImporteIEPS").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().ToDouble, TiempoEntrega:=Row("TiempoEntrega").ToString(), + PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString().ToDecimal, ImporteRetIVA:=Row("ImporteRetIVA").ToString().ToDecimal) Then MensajeError = "Ocurrió un error al guardar las partidas de la cotización" OcurrioError = True Exit For @@ -27237,6 +27462,8 @@ Partial Class Ventas #Region "D E S C U E N T O S X R E M I S I O N D E N O T A D E C R E D I T O" Protected Sub BtnAplicarRemisionNC_Click(sender As Object, e As EventArgs) + Me.AplicaRNCXDetalle = False + If ListaRemisionesNC Is Nothing Then ListaRemisionesNC = New List(Of Modelos.Factura) Else @@ -27250,69 +27477,139 @@ Partial Class Ventas End If Dim TotalRemNCAplicado As Decimal = 0 - For Each GvRow As GridViewRow In GvRemisionesNC.Rows - If GvRow.RowType = DataControlRowType.DataRow Then - If GvRow.FCCheckBox("ChkAplicar").Checked Then - Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa) - RemNC.TotalRemNCAplicado = GvRow.FCTextBox("TxtImporte").Text.ToDecimal() - TotalRemNCAplicado += RemNC.TotalRemNCAplicado - If RemNC.TotalRemNCAplicado <= 0 Then - Alert($"Debe asignar un importe en la siguiente remisión: {RemNC.SerieFolio}", TipoMensaje.MsgAdvertencia) - ListaRemisionesNC.Clear() - Exit Sub + If ChkMostarProductosRNC.Checked Then + + Me.AplicaRNCXDetalle = True + + For Each GvRow As GridViewRow In GvRemisionesNCDetalle.Rows + If GvRow.RowType = DataControlRowType.DataRow Then + If GvRow.FCCheckBox("ChkAplicar").Checked Then + Dim Rows = TmpDTRNCDetalle.Select($"CveVentaDetalleRNC = {GvRow.DataKey("CveVentaDetalleRNC").ToEntero()}") + For Each row In Rows + row("Cantidad") = GvRow.FCTextBox("TxtCantidadRNC").Text.ToEntero() + TmpDTRNCDetalleSelecciondas.Rows.Add(row.ItemArray) + Next End If - - ListaRemisionesNC.Add(RemNC) - End If - End If - Next - - 'SI TIENE ALGUN AJUSTE O GARANTIA - If ListaRemisionesNC.Any(Function(RNC) RNC.Num2 = 1) Then - For Each RNC In ListaRemisionesNC.Where(Function(x) x.Num2 = 1) - Dim Salir As Boolean = False - Using ObjAcum As New ClsAcumuladores - If ObjAcum.GetGarantiasDetalle(RNC.CveVenta) Then - 'SI ES GARANTIA TOTAL - If ObjAcum.DtResultados.MAX("PorcentajeAjuste") = "1" Then - DdlNCPS.SelectedValueExist(443174) - DdlNCPS.Enabled = False - Salir = True - Else - DdlNCPS.SelectedValueExist(443173) - DdlNCPS.Enabled = False - End If - End If - End Using - - If Salir Then - Exit For End If Next + + For Each Dr As DataRow In TmpDTRNCDetalleSelecciondas.FiltraParametros("", DistinctColumns:={"CveVenta"}).Rows + Dim RemNC As New Modelos.Factura(UsuarioActual, Dr("CveVenta").ToString().ToEntero(), UsuarioActual.CveEmpresa) + + Dim TotalRNC As Decimal = 0 + For Each GvRow As GridViewRow In GvRemisionesNCDetalle.Rows + If GvRow.RowType = DataControlRowType.DataRow Then + + If GvRow.FCCheckBox("ChkAplicar").Checked AndAlso GvRow.DataKey("CveVenta").ToEntero() = Dr("CveVenta").ToString().ToEntero() Then + + Dim Cantidad As Decimal = GvRow.FCTextBox("TxtCantidadRNC").Text.ToDecimal() + Dim PU = GvRow.DataKey("PU").ToDecimal() + Dim PorcentajeIVA As Decimal = GvRow.DataKey("PorcentajeIVA").ToDecimal() + + Dim TotalCalculableImpuestos As Decimal = (Cantidad * PU) + Dim ImporteIVA As Decimal = (TotalCalculableImpuestos * PorcentajeIVA).RoundSQL(2) + + Dim TotalRNCDetalle As Decimal = (TotalCalculableImpuestos + ImporteIVA) + + TotalRNC += TotalRNCDetalle + + End If + + End If + Next + + RemNC.TotalRemNCAplicado = TotalRNC + 'MARCA LA VENTA QUE FUE USADA PARA EL FILTRO + RemNC.Num3 = DdlVentaUsado.SelectedValue.ToEntero() + TotalRemNCAplicado += RemNC.TotalRemNCAplicado + + If RemNC.TotalRemNCAplicado <= 0 Then + Alert($"Debe asignar un importe en la siguiente remisión: {RemNC.SerieFolio}", TipoMensaje.MsgAdvertencia) + ListaRemisionesNC.Clear() + Exit Sub + End If + + ListaRemisionesNC.Add(RemNC) + Next + Else - DdlNCPS.Enabled = True - End If + For Each GvRow As GridViewRow In GvRemisionesNC.Rows + If GvRow.RowType = DataControlRowType.DataRow Then + If GvRow.FCCheckBox("ChkAplicar").Checked Then + Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa) + RemNC.TotalRemNCAplicado = GvRow.FCTextBox("TxtImporte").Text.ToDecimal() + 'MARCA LA VENTA QUE FUE USADA PARA EL FILTRO + RemNC.Num3 = DdlVentaUsado.SelectedValue.ToEntero() + TotalRemNCAplicado += RemNC.TotalRemNCAplicado - For Each GvRow As GridViewRow In GvRemisionesNCBon.Rows - If GvRow.RowType = DataControlRowType.DataRow Then - If GvRow.FCCheckBox("ChkAplicar").Checked Then - Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa) - RemNC.TotalRemNCAplicado = GvRow.FCTextBox("TxtImporte").Text.ToDecimal() - RemNC.CveVentaRNCCargo = GvRow.DataKey("CveVentaRNCCargo").ToEntero() - TotalRemNCAplicado += RemNC.TotalRemNCAplicado + If RemNC.TotalRemNCAplicado <= 0 Then + Alert($"Debe asignar un importe en la siguiente remisión: {RemNC.SerieFolio}", TipoMensaje.MsgAdvertencia) + ListaRemisionesNC.Clear() + Exit Sub + End If - If RemNC.TotalRemNCAplicado <= 0 Then - Alert($"Debe asignar un importe en la siguiente remisión: {RemNC.SerieFolio}", TipoMensaje.MsgAdvertencia) - ListaNCBonificacion.Clear() - Exit Sub + ListaRemisionesNC.Add(RemNC) + End If + End If + Next + + 'SI TIENE ALGUN AJUSTE O GARANTIA + If ListaRemisionesNC.Any(Function(RNC) RNC.Num2 = 1) Then + For Each RNC In ListaRemisionesNC.Where(Function(x) x.Num2 = 1) + Dim Salir As Boolean = False + + Dim ArrayNC As String() = UsuarioActual.Empresa.Funcionalidad(591).Split(",".ToCharArray()) + Dim NCAjuste As Integer = -1 + Dim NCGarantiaTotal As Integer = -1 + If ArrayNC.Length > 2 Then + NCAjuste = ArrayNC(1).ToEntero() + NCGarantiaTotal = ArrayNC(2).ToEntero() End If - ListaNCBonificacion.Add(RemNC) - End If + Using ObjAcum As New ClsAcumuladores + If ObjAcum.GetGarantiasDetalle(RNC.CveVenta) Then + 'SI ES GARANTIA TOTAL + If ObjAcum.DtResultados.MAX("PorcentajeAjuste") = "1" Then + DdlNCPS.SelectedValueExist(NCGarantiaTotal) + DdlNCPS.Enabled = False + Salir = True + Else + DdlNCPS.SelectedValueExist(NCAjuste) + DdlNCPS.Enabled = False + End If + End If + End Using + + If Salir Then + Exit For + End If + Next + Else + DdlNCPS.Enabled = True End If - Next + + + For Each GvRow As GridViewRow In GvRemisionesNCBon.Rows + If GvRow.RowType = DataControlRowType.DataRow Then + If GvRow.FCCheckBox("ChkAplicar").Checked Then + Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa) + RemNC.TotalRemNCAplicado = GvRow.FCTextBox("TxtImporte").Text.ToDecimal() + RemNC.CveVentaRNCCargo = GvRow.DataKey("CveVentaRNCCargo").ToEntero() + TotalRemNCAplicado += RemNC.TotalRemNCAplicado + + If RemNC.TotalRemNCAplicado <= 0 Then + Alert($"Debe asignar un importe en la siguiente remisión: {RemNC.SerieFolio}", TipoMensaje.MsgAdvertencia) + ListaNCBonificacion.Clear() + Exit Sub + End If + + ListaNCBonificacion.Add(RemNC) + End If + End If + Next + End If TxtImportesRemisionesNC.Text = TotalRemNCAplicado.FormatoNumero TxtNCImporte.Text = TotalRemNCAplicado.FormatoNumero @@ -27332,6 +27629,12 @@ Partial Class Ventas Dim CveSATNC = "84111506" Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:=CveSATNC, AplicaParaVenta:=1).Rows(0) + Dim ArrayNC As String() = UsuarioActual.Empresa.Funcionalidad(591).Split(",".ToCharArray()) + If ArrayNC.Length > 0 Then + Dim CvePSNC As Integer = ArrayNC(0).ToEntero() + DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSNC, AplicaParaVenta:=1).Rows(0) + End If + If DrPS Is Nothing Then Alert("Ocurrió un error al cargar la información del Producto. Por favor vuelva a intentar.", TipoMensaje.MsgError) Exit Sub @@ -27374,14 +27677,22 @@ Partial Class Ventas If ListaNCDesc.Any(Function(RNC) RNC.Num2 = 1) Then For Each RNC In ListaRemisionesNC.Where(Function(x) x.Num2 = 1) Dim Salir As Boolean = False + + Dim NCAjuste As Integer = -1 + Dim NCGarantiaTotal As Integer = -1 + If ArrayNC.Length > 2 Then + NCAjuste = ArrayNC(1).ToEntero() + NCGarantiaTotal = ArrayNC(2).ToEntero() + End If + Using ObjAcum As New ClsAcumuladores If ObjAcum.GetGarantiasDetalle(RNC.CveVenta) Then 'SI ES GARANTIA TOTAL If ObjAcum.DtResultados.MAX("PorcentajeAjuste") = "1" Then - DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=443174, AplicaParaVenta:=1).Rows(0) + DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=NCGarantiaTotal, AplicaParaVenta:=1).Rows(0) Salir = True Else - DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=443173, AplicaParaVenta:=1).Rows(0) + DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=NCAjuste, AplicaParaVenta:=1).Rows(0) End If End If End Using @@ -27501,7 +27812,7 @@ Partial Class Ventas #End Region Protected Sub BtnModalAplicarRemisionesNC_Click(sender As Object, e As EventArgs) - CargaRNC() + ChkMostarProductosRNC_CheckedChanged(ChkMostarProductosRNC, EventArgs.Empty) RegistraScript("$('#ModalAplicarRemisionesNC').modal({backdrop: 'static', keyboard: false });") End Sub @@ -28098,4 +28409,5 @@ Partial Class Ventas Public ImporteBonificacion As Decimal = 0 Public IVABonificacion As Decimal = 0 End Class + End Class \ No newline at end of file