From c38b78d3168bdef440066f59097c42d7c6e77ca8 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 9 Apr 2025 22:50:50 -0700 Subject: [PATCH 1/9] --Validacion anticipos --- App_Code/Modelos.vb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 53c73fd47..ed6c388c2 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -3604,7 +3604,7 @@ Namespace Modelos Exit Select End If - If ObjFactura.TipoDocto.Contiene("Ing", "Egs", "Ant") AndAlso ValorMultiplicador = -1 Then + If ObjFactura.TipoDocto.Contiene("Ing", "Egs") AndAlso ValorMultiplicador = -1 Then For Each row2 As DataRow In ObjFactura.DtAnticipos.Rows If row2("CveConceptoContable").ToString().ToEntero = 11 Then importeMovimiento = row2("Importe").ToString().ToDecimal * ValorMultiplicador '- ((row2.FCTextBox("TxtAnticipo" & row2.RowIndex).Text.ToDecimal / row2.DataKey("TotalAnticipo").ToDecimal) * row2.DataKey("IVAAnticipo").ToDecimal) @@ -5732,8 +5732,15 @@ Namespace Modelos Return Retorno End If - If ObjFactura.TipoDocto = "Ant" AndAlso ObjFactura.SaldoAmortizado > 0 Then - Retorno.Mensaje = "La factura no se puede cancelar debido a que el anticipo ha sido amortizado." + 'If ObjFactura.TipoDocto = "Ant" AndAlso ObjFactura.SaldoAmortizado > 0 Then + ' Retorno.Mensaje = "La factura no se puede cancelar debido a que el anticipo ha sido amortizado." + ' Retorno.TipoMensaje = TipoMensaje.MsgAdvertencia + + ' Return Retorno + 'End If + + If ObjFactura.TipoDocto = "Ant" AndAlso ObjFactura.SaldoAnticipo.RoundSQL(2) <> ObjFactura.SubTotal.RoundSQL(2) Then + Retorno.Mensaje = "La factura no se puede cancelar debido a que el anticipo ha sido aplicado." Retorno.TipoMensaje = TipoMensaje.MsgAdvertencia Return Retorno From 4f050de68a88edd3fbb9e1cb026055c435f3be61 Mon Sep 17 00:00:00 2001 From: Jorge Luis caudillo esparza Date: Fri, 11 Apr 2025 10:45:20 -0700 Subject: [PATCH 2/9] ajustes movtospermanente y excel personalizado --- Nomina/Nomina.aspx.cs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Nomina/Nomina.aspx.cs b/Nomina/Nomina.aspx.cs index 98a36cbb9..c69d515b8 100644 --- a/Nomina/Nomina.aspx.cs +++ b/Nomina/Nomina.aspx.cs @@ -5192,18 +5192,19 @@ public partial class Nomina_Nomina2 : ClsPaginas } iniciotipe = column; + int finPercepciones = iniciotipe; + column++; + TitleRange(libro, "Incapacidad", filainicio + 2, column, filainicio + 2, column+2, false, false, PercborderColor); + TitleRange(libro, "Perm. Faltas", filainicio + 3, column, filainicio + 3, column, false, false, PercborderColor); + //column++; + //TitleRange(libro, "Permisos", filainicio + 3, column, filainicio + 3, column, false, false, colororangeblue); - column++; - TitleRange(libro, "Asistencias", filainicio + 2, column, filainicio + 2, column+2, false, false, colororangeblue); - TitleRange(libro, "Incapacidad", filainicio + 3, column, filainicio + 3, column, false, false, colororangeblue); - column++; - TitleRange(libro, "Permisos", filainicio + 3, column, filainicio + 3, column, false, false, colororangeblue); - column++; - TitleRange(libro, "Faltas", filainicio + 3, column, filainicio + 3, column, false, false, colororangeblue); - column++; - Titlecell(libro, "", filainicio + 4, column, true, true, dedcborderColor); + //column++; + //TitleRange(libro, "Faltas", filainicio + 3, column, filainicio + 3, column, false, false, colororangeblue); + //column++; + //Titlecell(libro, "", filainicio + 4, column, true, true, dedcborderColor); libro.Column(column).Width = 15; if (dtConceptos.FiltraParametros("Tipo ='D'").Rows.Count > 0) { @@ -5397,12 +5398,12 @@ public partial class Nomina_Nomina2 : ClsPaginas } + //column++; + //Titlecell(libro, erow["DiasIncapacidad"], Fila, column, false, false, dedcborderColor); column++; - Titlecell(libro, erow["DiasIncapacidad"], Fila, column, false, false, dedcborderColor); - column++; - Titlecell(libro, "0", Fila, column, false, false, dedcborderColor); - column++; - Titlecell(libro, erow["DiasFaltados"], Fila, column, false, false, dedcborderColor); + Titlecell(libro, "", Fila, column, false, false, PercborderColor); + //column++; + //Titlecell(libro, erow["DiasFaltados"], Fila, column, false, false, dedcborderColor); if (dtConceptos.FiltraParametros("Tipo ='D'").Rows.Count > 0) { From 87cff03df1584aa12946570b2efcd6949ea82103 Mon Sep 17 00:00:00 2001 From: rakcsle Date: Sat, 12 Apr 2025 10:29:10 -0700 Subject: [PATCH 3/9] Precios venta manifiesto ajustes, nom 043 ajustes --- Agropecuaria/RepPreciosVentaManifiesto.aspx | 9 +- .../RepPreciosVentaManifiesto.aspx.vb | 11 +- App_Code/ClsPaginas.vb | 5 +- Ashx/E158.ashx | 11 -- .../Grales/Formatos/CartaPorteTimbrado.rdlc | 100 ++++-------------- Inventarios/RecepcionAlmacen.aspx.vb | 2 +- 6 files changed, 37 insertions(+), 101 deletions(-) diff --git a/Agropecuaria/RepPreciosVentaManifiesto.aspx b/Agropecuaria/RepPreciosVentaManifiesto.aspx index 7aa2415ec..ef0b88763 100644 --- a/Agropecuaria/RepPreciosVentaManifiesto.aspx +++ b/Agropecuaria/RepPreciosVentaManifiesto.aspx @@ -128,7 +128,7 @@ font-size: 12px;
@@ -139,12 +139,11 @@ font-size: 12px; + - - - - + + diff --git a/Agropecuaria/RepPreciosVentaManifiesto.aspx.vb b/Agropecuaria/RepPreciosVentaManifiesto.aspx.vb index e413df747..f3b8abb5b 100644 --- a/Agropecuaria/RepPreciosVentaManifiesto.aspx.vb +++ b/Agropecuaria/RepPreciosVentaManifiesto.aspx.vb @@ -25,10 +25,10 @@ Partial Class Agrupecuaria_RepPreciosVentaManifiesto If Not IsPostBack Then If UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario.Contiene(77, 21) Then Response.Redirect("/Inicio.aspx") - txtFechaI.Text = $"01/{Now.Month.ToString("0#")}/{Now.Year}" + txtFechaI.Text = Now.AddDays(-1).ToString("dd/MM/yyyy") txtFechaF.Text = Now.ToString("dd/MM/yyyy") - TxtModalFechaInicio.Text = $"01/{Now.Month.ToString("0#")}/{Now.Year}" + TxtModalFechaInicio.Text = Now.AddDays(-1).ToString("dd/MM/yyyy") TxtModalFechaFin.Text = Now.ToString("dd/MM/yyyy") CargaCombos() @@ -120,6 +120,13 @@ Partial Class Agrupecuaria_RepPreciosVentaManifiesto #Region " GV DATOS - ROW DATABOUND " Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + Dim Dif As Decimal = e.Row.DataKey("Diferencia").ToDecimal + If Dif < 0 Then + e.Row.Cells(11).ForeColor = Drawing.Color.Red + e.Row.Cells(12).ForeColor = Drawing.Color.Red + End If + End If End Sub #End Region diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 2f9873a89..c82c5ba22 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -6224,6 +6224,7 @@ Public Class ClsPaginas Dim ConfATR2 As String = "" Dim ObjInv As New ClsGenerales Dim TelDestino As String = "" + Dim NombreUsuario As String = "" 'Persona que timbro If ObjInv.GetGralTimbre(CveTimbre, "-1", MinFecha, MaxFecha, -1, UsuarioActual.CveEmpresa, -1) Then If ObjInv.DtResultados.Rows.Count > 0 Then @@ -6233,6 +6234,7 @@ Public Class ClsPaginas Telefono = Dr("FiguraTelefono").ToString TipoDocto = Dr("TipoDocto").ToString TelDestino = Dr("TelDestino").ToString + NombreUsuario = Dr("NombreUsuario").ToString If UsuarioActual.CveEmpresa = 13 Then PermisoSCTR1 = Dr("PermisoSCTR1").ToString @@ -6629,6 +6631,7 @@ Public Class ClsPaginas params.Add(New ReportParameter("FechaImpresion", NowADS().ToDateTime.ToShortDateString)) params.Add(New ReportParameter("DomicilioFiscal", $"{UsuarioActual.Empresa.Direccion}, {UsuarioActual.Empresa.Colonia}, {UsuarioActual.Empresa.Localidad}, {UsuarioActual.Empresa.Estado}, Tel. {Telefono}")) params.Add(New ReportParameter("SerieFolio", SerieFolio)) + params.Add(New ReportParameter("NombreUsuario", NombreUsuario)) params.Add(New ReportParameter("RFC", UsuarioActual.Empresa.RFC)) params.Add(New ReportParameter("DomicilioExpedicion", LugarExpedicion)) 'CLIENTE @@ -11140,7 +11143,7 @@ Public Class ClsPaginas PaginaDict.Add("/Contabilidad/OCDetalleAlmacen.aspx".ToUpper(), -1) PaginaDict.Add("/Contabilidad/RepBalanceGeneralHorizontal.aspx".ToUpper(), -1) PaginaDict.Add("/Agropecuaria/CierreCultivo.aspx".ToUpper(), 1326) - PaginaDict.Add("/Agropecuaria/RepPreciosVentaManifiesto.aspx".ToUpper(), -1) + PaginaDict.Add("/Agropecuaria/RepPreciosVentaManifiesto.aspx".ToUpper(), 1353) PaginaDict.Add("/Inventarios/RepRSCO.aspx".ToUpper(), 1328) PaginaDict.Add("/testApi.aspx".ToUpper(), -1) diff --git a/Ashx/E158.ashx b/Ashx/E158.ashx index cc6b92bc6..6f4d581b9 100644 --- a/Ashx/E158.ashx +++ b/Ashx/E158.ashx @@ -209,17 +209,6 @@ Public Class E158 : Implements IHttpHandler, IReadOnlySessionState ObjVentas.Dispose() - 'For Each dRow As DataRow In DTresp.Rows - - 'Next - - 'Dim ObjVentas As New ClsVentas - - 'If ObjVentas.AddPreciosVentaManifiesto() Then - - 'End If - - 'ObjVentas.Dispose() 'DTresp.WriteXml("C:\temp\GrowerService\Sales.xml", XmlWriteMode.WriteSchema) diff --git a/Empresas/Grales/Formatos/CartaPorteTimbrado.rdlc b/Empresas/Grales/Formatos/CartaPorteTimbrado.rdlc index 38000e5c8..df258447e 100644 --- a/Empresas/Grales/Formatos/CartaPorteTimbrado.rdlc +++ b/Empresas/Grales/Formatos/CartaPorteTimbrado.rdlc @@ -1091,13 +1091,13 @@ 2.54796cm - 4.20919cm + 4.01711cm - 2.24876cm + 2.73018cm - 6.34152cm + 6.40233cm @@ -1258,7 +1258,7 @@ @@ -1538,7 +1538,7 @@ - 1.68927cm + 1.39994cm true @@ -1596,7 +1596,7 @@ 10.58305cm 0.44227cm 1.12062cm - 19.07303cm + 19.13385cm 3 - - true - true - - - - - =Parameters!SerieFolio.Value - - - - - - - SerieFolio - 0.67478cm - 15.20438cm - 0.6cm - 3.97474cm - 12 - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - - - - - =Parameters!FechaCertificacion.Value - - - - - - - SerieFolio - 1.45117cm - 15.20438cm - 0.6cm - 3.97474cm - 13 - - - 2pt - 2pt - 2pt - 2pt - - true 47.03985cm @@ -8183,6 +8115,12 @@ Se ha recibido el número arriba indicado de bultos/contenedores/remolques/autot true ReportParameter1 + + String + true + true + ReportParameter1 + Function PageNumber() As String Return Me.Report.Globals!OverallPageNumber diff --git a/Inventarios/RecepcionAlmacen.aspx.vb b/Inventarios/RecepcionAlmacen.aspx.vb index ef8415673..067f4e1d6 100644 --- a/Inventarios/RecepcionAlmacen.aspx.vb +++ b/Inventarios/RecepcionAlmacen.aspx.vb @@ -3790,7 +3790,7 @@ Partial Class Inventarios_RecepcionAlmacen End If If CveTipoFechaVencimiento = 2 Then - If Not objCompras.UpdateFechaVencimientoCompra(CveCompra, TxtFecha.Text.ToDate, UsuarioActual.CveEmpresa) Then + If Not objCompras.UpdateFechaVencimientoCompra(CveCompra, TxtFecha.Text.ToDate, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then ErrorProceso = True End If End If From 5bec46a5c9326d3a44d40dce9fe2f8e985fb987d Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Sat, 12 Apr 2025 11:50:02 -0700 Subject: [PATCH 4/9] --FIX sobrante faltante --- Ventas/PVCobranza.aspx | 17 ++++++++++++++--- Ventas/PVCobranza.aspx.vb | 11 +++++++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Ventas/PVCobranza.aspx b/Ventas/PVCobranza.aspx index 1178e920e..74235e10c 100644 --- a/Ventas/PVCobranza.aspx +++ b/Ventas/PVCobranza.aspx @@ -706,7 +706,7 @@
$ - +
@@ -1591,7 +1591,7 @@ } else { $get("TxtFaltante").value = FormatoNumero(cambio); $get("ChkSobFaltante").checked = true; - $get("TxtCambio").value = FormatoNumero(cambio); + $get("TxtCambio").value = ""; } } else { @@ -1617,15 +1617,26 @@ $('#C_LblDiferenciaCajaBloqueo').val(FormatoNumero(total)); } + function ValidaSobranteFaltante() { + if (ToDouble($get("TxtFaltante").value) > 1) { + alert("El sobrante/faltante no debe ser mayor a 1"); + $get("TxtFaltante").value = ""; + $get("ChkSobFaltante").checked = false; + } else { + $get("ChkSobFaltante").checked = true; + } + } + function CargaSobranteFaltante() { $('#ChkSobFaltante').change(function () { if (this.checked == true) { if (ToDouble($get("TxtCambio").value) > 1) { alert("El sobrante/faltante no debe ser mayor a 1") + $get("ChkSobFaltante").checked = false; } else { $get("TxtFaltante").value = $get("TxtCambio").value; } - + } else { $get("TxtFaltante").value = ""; diff --git a/Ventas/PVCobranza.aspx.vb b/Ventas/PVCobranza.aspx.vb index efa42fdd2..a9228656f 100644 --- a/Ventas/PVCobranza.aspx.vb +++ b/Ventas/PVCobranza.aspx.vb @@ -1601,7 +1601,6 @@ Partial Class Ventas_PVCobranza Dim Importe = GvRowAnticipo.FCTextBox(String.Format("TxtAnticipo{0}", GvRowAnticipo.RowIndex)).Text.ToDecimal() Dim CveConceptoContable = GvRowAnticipo.DataKey("CveConceptoContable").ToEntero() - Dim FolioFiscal = GvRowAnticipo.DataKey("FolioFiscal") Dim Descuentos As Decimal = GvRowAnticipo.DataKey("Descuentos").ToDecimal() Dim TotalAnticipo As Decimal = GvRowAnticipo.DataKey("TotalAnticipo").ToDecimal() @@ -1612,8 +1611,10 @@ Partial Class Ventas_PVCobranza Dim Folio = GvRowAnticipo.DataKey("Folio") Dim Tipo = GvRowAnticipo.DataKey("Tipo") - DtAnticipos.Rows.Add(CveVenta, Importe, CveConceptoContable, CveIE, FolioFiscal, Descuentos, TotalAnticipo, SubTotalAnticipo, CveMoneda, Fecha, TipoCambioPago, Folio, Tipo) + + ObjNC.Observaciones = $"Folio: {GvRowAnticipo.DataKey("Folio")}" + End If ObjNC.EsNCAmortizacion = True @@ -1708,12 +1709,14 @@ Partial Class Ventas_PVCobranza 'METER LO QUE FALTA COMO GASTO If (ImporteBancos.RoundSQL(2) + Math.Abs(SobranteFaltante)) = ImporteAbonoVenta.RoundSQL(2) Then Pago.OtroGastoIngreso = SobranteFaltante.ToString().ToDecimal() - 'LIMPIAR SOBRANTE/FALTANTE - SobranteFaltante = 0 + 'SUMAR AL PAGO If ImporteBancos < ImporteAbonoVenta Then ImporteBancos += Math.Abs(SobranteFaltante) End If + + 'LIMPIAR SOBRANTE/FALTANTE + SobranteFaltante = 0 End If End If From 2b7f38ebe9bf92f53ebd45ec256f2174cf0660dd Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Sat, 12 Apr 2025 11:53:29 -0700 Subject: [PATCH 5/9] --FIX cancelacion Ant jam --- App_Code/Modelos.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index ed6c388c2..c3f3ea8fe 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -5739,7 +5739,7 @@ Namespace Modelos ' Return Retorno 'End If - If ObjFactura.TipoDocto = "Ant" AndAlso ObjFactura.SaldoAnticipo.RoundSQL(2) <> ObjFactura.SubTotal.RoundSQL(2) Then + If UsuarioActual.CveEmpresa <> 119 AndAlso ObjFactura.TipoDocto = "Ant" AndAlso ObjFactura.SaldoAnticipo.RoundSQL(2) <> ObjFactura.SubTotal.RoundSQL(2) Then Retorno.Mensaje = "La factura no se puede cancelar debido a que el anticipo ha sido aplicado." Retorno.TipoMensaje = TipoMensaje.MsgAdvertencia From 86b999d5217eb12ccb424670229dfd92cca3406b Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Sat, 12 Apr 2025 11:54:05 -0700 Subject: [PATCH 6/9] --FIX informacion completa --- Ventas/Clientes.aspx.vb | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/Ventas/Clientes.aspx.vb b/Ventas/Clientes.aspx.vb index 3a92c0b96..4dbe7f213 100644 --- a/Ventas/Clientes.aspx.vb +++ b/Ventas/Clientes.aspx.vb @@ -2591,22 +2591,27 @@ Partial Class Clientes InformacionCompleta = False End If End If - If TxtContacto.Text.Trim() = "" Then InformacionCompleta = False + If TxtTelefono.Text.Trim() = "" Then InformacionCompleta = False If TxtEmail.Text.Trim() = "" Then InformacionCompleta = False - If TxtRepresentanteLegal.Text.Trim() = "" Then InformacionCompleta = False - 'si es el concepto de pagaré - Dim tPagare As Integer = 0 - For Each dRow As GridViewRow In GvDocumentosCliente.Rows - Dim CveDocumentacion As Integer = dRow.DataKey("CveDocumentacion").ToEntero() - If CveDocumentacion = 265 Then tPagare = 1 - Next - If tPagare = 0 Then InformacionCompleta = False - tPagare = 0 'valida que cuando menos tenga una cuenta - For Each dRow As GridViewRow In GvBancosCuentas.Rows - tPagare = 1 - Next - If tPagare = 0 Then InformacionCompleta = False + + 'SOLO VALIDA EN CLIENTES FRENCUENTE + If DdlTipoCliente.SelectedValue = "1" Then + If TxtContacto.Text.Trim() = "" Then InformacionCompleta = False + If TxtRepresentanteLegal.Text.Trim() = "" Then InformacionCompleta = False + 'si es el concepto de pagaré + Dim tPagare As Integer = 0 + For Each dRow As GridViewRow In GvDocumentosCliente.Rows + Dim CveDocumentacion As Integer = dRow.DataKey("CveDocumentacion").ToEntero() + If CveDocumentacion = 265 Then tPagare = 1 + Next + If tPagare = 0 Then InformacionCompleta = False + tPagare = 0 'valida que cuando menos tenga una cuenta + For Each dRow As GridViewRow In GvBancosCuentas.Rows + tPagare = 1 + Next + If tPagare = 0 Then InformacionCompleta = False + End If 'If DivInfoCompleta.Visible Then ' InformacionCompleta = ChkInformacionCompleta.Checked From 6025f707970541c81a4424149d652bb3e8d4d14f Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Sat, 12 Apr 2025 11:55:54 -0700 Subject: [PATCH 7/9] --FIX aplicacion de anticipos --- Ventas/Ventas.aspx.vb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index c7fcb1d25..377bcd8c7 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -5254,7 +5254,7 @@ Partial Class Ventas If TienePermiso <> "" Then ' si tiene acceso en el subproyecto 'LkNotaCredito.Visible = UsuarioActual.TienePermisoProceso(175) If UsuarioActual.TienePermisoProceso(264) Then - InicializaAplicaDevolucion(TmpDT) + InicializaAplicaDevolucion(TmpDT, DbRowVenta("Fecha").ToString().ToDateTime()) End If End If @@ -32875,7 +32875,7 @@ Partial Class Ventas #End Region #Region " APLICA DEVOLUCION " - Private Sub InicializaAplicaDevolucion(DtDetalle As DataTable) + Private Sub InicializaAplicaDevolucion(DtDetalle As DataTable, FechaVenta As DateTime) 'If Not UsuarioActual.CveUsuario = 100 Then ' If Not UsuarioActual.CveEmpresa.Contiene(72, 80, 119, 140, 141, 146) Then ' Exit Sub @@ -32887,7 +32887,17 @@ Partial Class Ventas Exit Sub End If - LBAplicaDevolucion.Visible = True + If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then + If FechaVenta.ToShortDateString.ToDate < Now.ToShortDateString.ToDate Then + LBAplicaDevolucion.Visible = True + Else + LBAplicaDevolucion.Visible = False + End If + Else + LBAplicaDevolucion.Visible = True + End If + + 'SOLO APLICA DEVOLUCION SI TIENE MOVIMIENTOS DE ALMACEN 'If VentaSaldoAlmacen < 0 Then From a0d69ddc5e4e32a2697a1b76e68baf84295453a9 Mon Sep 17 00:00:00 2001 From: Luis Quijada Date: Sat, 12 Apr 2025 14:58:24 -0700 Subject: [PATCH 8/9] Cambios Finalizacion de OP --- App_Code/ClsOP.vb | 11 +- OP/OP.aspx | 117 +++++++++++--- OP/OP.aspx.vb | 384 ++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 426 insertions(+), 86 deletions(-) diff --git a/App_Code/ClsOP.vb b/App_Code/ClsOP.vb index eb34c60ee..624bb0a8a 100644 --- a/App_Code/ClsOP.vb +++ b/App_Code/ClsOP.vb @@ -481,15 +481,16 @@ Public Class ClsOP Return Retorno End Function - Public Function GetEstatusOP(CveEmpresa As Integer, Optional CveEstatusOP As Integer = -1, Optional TipoEstatus As Integer = -1, Optional Estatus As Integer = -1) As Boolean + Public Function GetEstatusOP(CveEmpresa As Integer, Optional CveEstatusOP As Integer = -1, Optional TipoEstatus As Integer = -1, Optional Estatus As Integer = -1, Optional CveUsuario As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_OP_EstatusOPGet") With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveEstatusOP", SqlDbType.Int).Value = CveEstatusOP - .Add("@TipoEstatus", SqlDbType.Int).Value = TipoEstatus - .Add("@Estatus", SqlDbType.Int).Value = Estatus + .Add("@cveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@cveEstatusOP", SqlDbType.Int).Value = CveEstatusOP + .Add("@tipoEstatus", SqlDbType.Int).Value = TipoEstatus + .Add("@estatus", SqlDbType.Int).Value = Estatus + .Add("@cveUsuario", SqlDbType.Int).Value = CveUsuario End With Try SqlAdapter.Fill(Data) diff --git a/OP/OP.aspx b/OP/OP.aspx index 7ca37ef2a..4547e62b8 100644 --- a/OP/OP.aspx +++ b/OP/OP.aspx @@ -279,6 +279,36 @@ padding: 5px; margin-top: 10px; } + + .quantity-control { + position: relative; + display: flex; + align-items: center; + width: 120px; + } + + .quantity-input { + width: 70px !important; + padding-right: 30px; + } + + .quantity-buttons { + position: absolute; + right: 0; + display: flex; + flex-direction: column; + gap: 2px; + } + + .btn-quantity { + padding: 0; + width: 22px; + height: 18px; + line-height: 1; + border: 1px solid #ddd; + background: #f8f9fa; + cursor: pointer; + } @@ -466,7 +496,8 @@
Productos
+ CssClass="table table-striped table-hover" GridLines="None" Width="100%" + OnRowDataBound="GvProductos_RowDataBound"> @@ -754,67 +785,115 @@
+ + diff --git a/OP/OP.aspx.vb b/OP/OP.aspx.vb index 3053d6962..6db555ecf 100644 --- a/OP/OP.aspx.vb +++ b/OP/OP.aspx.vb @@ -41,7 +41,15 @@ Partial Class OP_OP Private Property DtMO As DataTable Get - Return DirectCast(ViewState("DtMO"), DataTable) + If ViewState("DtMO") Is Nothing Then + DtMO = New DataTable() + DtMO.Columns.Add("CvePS", GetType(Integer)) ' Producto asociado + DtMO.Columns.Add("CvePuesto", GetType(Integer)) + DtMO.Columns.Add("Puesto", GetType(String)) + DtMO.Columns.Add("CostoHora", GetType(Decimal)) + DtMO.Columns.Add("Total", GetType(Decimal)) + End If + Return CType(ViewState("DtMO"), DataTable) End Get Set(value As DataTable) ViewState("DtMO") = value @@ -50,13 +58,31 @@ Partial Class OP_OP Private Property DtCI As DataTable Get - Return DirectCast(ViewState("DtCI"), DataTable) + If ViewState("DtCI") Is Nothing Then + DtCI = New DataTable() + DtCI.Columns.Add("CvePS", GetType(Integer)) ' Producto asociado + DtCI.Columns.Add("CvePSMateriaPrima", GetType(Integer)) + DtCI.Columns.Add("productoMateriaPrima", GetType(String)) + DtCI.Columns.Add("Cantidad", GetType(Decimal)) + DtCI.Columns.Add("PU", GetType(Decimal)) + DtCI.Columns.Add("Total", GetType(Decimal)) + End If + Return CType(ViewState("DtCI"), DataTable) End Get Set(value As DataTable) ViewState("DtCI") = value End Set End Property + Private Property TipoEstatus As Integer + Get + Return ViewState("TipoEstatus").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("TipoEstatus") = value + End Set + End Property + Private Property DtMPAgregados As DataTable Get If ViewState("DtMPAgregados") Is Nothing Then @@ -74,12 +100,27 @@ Partial Class OP_OP End Set End Property + Private Property DtDevoluciones As DataTable + Get + If ViewState("DtDevoluciones") Is Nothing Then + DtDevoluciones = New DataTable() + DtDevoluciones.Columns.Add("CvePS", GetType(Integer)) + DtDevoluciones.Columns.Add("Devolucion", GetType(Decimal)) + DtDevoluciones.Columns.Add("CveAlmacenDevolucion", GetType(Integer)) + End If + Return CType(ViewState("DtDevoluciones"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtDevoluciones") = value + End Set + End Property #End Region Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then CveOP = If(Request("CveOP") <> "", Request("CveOP").ToString.ToEntero, "-1".ToEntero) + TipoEstatus = -1 CreaPS() SetValues() End If @@ -106,6 +147,7 @@ Partial Class OP_OP DtMP.Columns.Add("UnidadMedida", GetType(String)) DtMP.Columns.Add("Cantidad", GetType(Decimal)) DtMP.Columns.Add("Surtido", GetType(Decimal)) + 'DtMP.Columns.Add("CvePSProducto", GetType(Integer)) 'DtMP.Columns.Add("CveAlmacenDestino", GetType(Integer)) DtMO = New DataTable() @@ -115,15 +157,17 @@ Partial Class OP_OP DtMO.Columns.Add("CvePuesto", GetType(Integer)) DtMO.Columns.Add("Puesto", GetType(String)) DtMO.Columns.Add("Cantidad", GetType(Decimal)) + DtMO.Columns.Add("CostoHora", GetType(Decimal)) + DtMO.Columns.Add("Total", GetType(Decimal)) + DtCI = New DataTable() DtCI.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI DtCI.Columns.Add("Clave", GetType(Integer)) - 'DtCI.Columns.Add("CveUM", GetType(Integer)) - 'DtCI.Columns.Add("CvePSMateriaPrima", GetType(Integer)) - 'DtCI.Columns.Add("CveUMMateriaPrima", GetType(Integer)) DtCI.Columns.Add("productoMateriaPrima", GetType(String)) DtCI.Columns.Add("Cantidad", GetType(Decimal)) + DtCI.Columns.Add("PU", GetType(Decimal)) + DtCI.Columns.Add("Total", GetType(Decimal)) End Sub @@ -133,24 +177,65 @@ Partial Class OP_OP CargarClientes() CargarCentrosDeCosto(DdlProyecto, DdlSubProyecto, LblProyecto, LblSubProyecto, divProyecto:=DivProyecto, VisualizacionReporte:=1) CargarProductos() + CargaDatos() - If CveOP = -1 Then - - DdlClientes.Enabled = True - DdlProyecto.Enabled = True - DdlSubProyecto.Enabled = True - DdlPS.Enabled = True - LnkSolicitarMP.Visible = False - BtnSimularMP.Visible = True - BtnFinalizarOP.Visible = False + If TipoEstatus = 3 Then + DeshabilitarControles() ' Deshabilita todos los controles relevantes Else - DdlClientes.Enabled = False - DdlPS.Enabled = False - LnkSolicitarMP.Visible = False - BtnSimularMP.Visible = False - BtnFinalizarOP.Visible = True - CargaDatos() + If CveOP = -1 Then ' Nueva OP + DdlClientes.Enabled = True + DdlProyecto.Enabled = True + DdlSubProyecto.Enabled = True + DdlPS.Enabled = True + TxtEstatus.Enabled = True ' Estatus no editable + LnkSolicitarMP.Visible = False + BtnSimularMP.Visible = True + BtnFinalizarOP.Visible = False + Else ' OP existente no finalizada + If TipoEstatus <> 3 Then + DdlClientes.Enabled = True + DdlProyecto.Enabled = True + DdlSubProyecto.Enabled = True + DdlPS.Enabled = True + TxtDescripcion.Enabled = True + Txtfecha.Enabled = True + TxtEstatus.Enabled = True ' Estatus no editable + BtnAgregarProducto.Enabled = True + BtnSimularMP.Visible = False + BtnGuardarOP.Enabled = True + BtnFinalizarOP.Visible = True + imgCalendarioF.Enabled = True + LnkSolicitarMP.Visible = True + End If + End If End If + + UpOP.Update() + UpGvDatosOP.Update() + End Sub + + Private Sub DeshabilitarControles() + ' Deshabilitar DropDownLists + DdlClientes.Enabled = False + DdlProyecto.Enabled = False + DdlSubProyecto.Enabled = False + DdlPS.Enabled = False + + ' Deshabilitar TextBox y Date + TxtDescripcion.Enabled = False + Txtfecha.Enabled = False + imgCalendarioF.Enabled = False + TxtEstatus.Enabled = False + + ' Ocultar Botones + BtnAgregarProducto.Visible = False + BtnSimularMP.Visible = False + BtnGuardarOP.Visible = False + BtnFinalizarOP.Visible = False + LnkSolicitarMP.Visible = False + + UpOP.Update() + UpGvDatosOP.Update() End Sub Private Sub CargaDatos() @@ -169,6 +254,7 @@ Partial Class OP_OP DdlPS.txtValue.Value = dr("CvePS").ToString Txtfecha.Text = dr("Fecha").ToString TxtDescripcion.Text = dr("Descripcion").ToString + TipoEstatus = dr("TipoEstatus").ToString.ToEntero If ObjOP.GetProductosOP(CveOP, UsuarioActual.CveEmpresa) Then @@ -221,7 +307,7 @@ Partial Class OP_OP Dim newRow As DataRow = DtCI.NewRow() newRow("Tipo") = "CI" newRow("productoMateriaPrima") = rowCI("producto").ToString - newRow("Cantidad") = rowCI("Cantidad").ToString.ToDecimal + newRow("Costo") = rowCI("Costo").ToString.ToDecimal DtCI.Rows.Add(newRow) Next @@ -292,6 +378,7 @@ Partial Class OP_OP rowMP("PSCodigo") = drMP("productoMateriaPrima").ToString() rowMP("UnidadMedida") = drMP("UnidadMedidaMateriaPrima").ToString() rowMP("Cantidad") = drMP("Cantidad").ToString().ToDecimal() + 'rowMP("CvePSProducto") = CvePS rowMP("Surtido") = 0 DtMP.Rows.Add(rowMP) Next @@ -306,6 +393,8 @@ Partial Class OP_OP rowMO("Clave") = CvePS rowMO("Puesto") = drMO("Puesto").ToString() rowMO("Cantidad") = drMO("Cantidad").ToString().ToDecimal() + rowMO("CostoHora") = drMO("precioHora").ToString.ToDecimal() + rowMO("Total") = drMO("Cantidad").ToString().ToDecimal() * drMO("precioHora").ToString().ToDecimal() DtMO.Rows.Add(rowMO) Next End If @@ -321,6 +410,8 @@ Partial Class OP_OP 'rowCI("CvePSMateriaPrima") = drCI("CvePSMateriaPrima").ToString().ToEntero() rowCI("productoMateriaPrima") = drCI("productoMateriaPrima").ToString() rowCI("Cantidad") = drCI("Cantidad").ToString().ToDecimal() + rowCI("PU") = drCI("ImporteCostoIndirecto").ToString().ToDecimal() + rowCI("Total") = rowCI("Cantidad").ToString().ToDecimal() * rowCI("PU").ToString().ToDecimal() DtCI.Rows.Add(rowCI) Next End If @@ -329,6 +420,12 @@ Partial Class OP_OP End Sub Protected Sub BtnEliminarProducto_Click(sender As Object, e As EventArgs) + + ' Verificar si la OP está finalizada + If TxtEstatus.Text = "Finalizada" Then + Alert("No se pueden eliminar productos de una OP finalizada.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If Dim btnEliminar As LinkButton = DirectCast(sender, LinkButton) Dim CveProducto As Integer = btnEliminar.CommandArgument.ToEntero() @@ -361,6 +458,13 @@ Partial Class OP_OP Next End Sub + Protected Sub GvProductos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvProductos.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + Dim btnEliminar As LinkButton = DirectCast(e.Row.FindControl("BtnEliminar"), LinkButton) + btnEliminar.Visible = (TipoEstatus <> 3) + End If + End Sub + Protected Sub LnkSolicitarMP_Click(sender As Object, e As EventArgs) ' Cargar almacenes DdlAlmacenOrigenMP.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 1") @@ -560,16 +664,16 @@ Partial Class OP_OP Dim MensajeExistencia As New StringBuilder MensajeExistencia.Append("No hay la existencia suficiente de los siguientes productos:
") - '✅ 1. Validar existencias de MP + For Each row As GridViewRow In GvMPAgregados.Rows - '✅ Obtener claves CORRECTAS de la materia prima + Dim CveMP As Integer = GvMPAgregados.DataKeys(row.RowIndex)("CvePSMateriaPrima").ToString().ToEntero() Dim CveUMMP As Integer = GvMPAgregados.DataKeys(row.RowIndex)("CveUMMateriaPrima").ToString().ToEntero() Dim CantidadSolicitada As Decimal = DtMP.Rows(row.RowIndex)("Cantidad").ToString().ToDecimal() - 'DtMP.Rows(row.RowIndex)("CveAlmacenDestino") = DdlAlmacenDestinoMP.SelectedValue.ToEntero() - '✅ Verificar existencias + + Dim Existencia As Decimal = ObjInventario.GetExistenciasPS( CvePS:=CveMP, CveUnidadMedida:=CveUMMP, @@ -596,7 +700,7 @@ Partial Class OP_OP Exit Sub End If - '✅ 2. Crear traspaso si todo está correcto + ObjInventario.IniciaTransacSQL() Dim TieneError As Boolean = False @@ -618,10 +722,10 @@ Partial Class OP_OP TieneError = True End If - '✅ 3. Agregar detalles del traspaso + If Not TieneError Then For Each row As GridViewRow In GvMPAgregados.Rows - '✅ Usar claves de MATERIA PRIMA (CvePSMateriaPrima y CveUMMateriaPrima) + Dim CveMP As Integer = GvMPAgregados.DataKeys(row.RowIndex)("CvePSMateriaPrima").ToString().ToEntero() Dim CveUMMP As Integer = GvMPAgregados.DataKeys(row.RowIndex)("CveUMMateriaPrima").ToString().ToEntero() Dim Cantidad As Decimal = DtMP.Rows(row.RowIndex)("Cantidad").ToString().ToDecimal() @@ -629,8 +733,8 @@ Partial Class OP_OP If Not ObjInventario.AddTrasladoSolicitudDetalle( CveTraspasoSolicitud, Cantidad, - CveUMMP, '✅ Unidad de medida de la MP - CveMP, '✅ Clave de la MP + CveUMMP, + CveMP, 0, "", -1, "-1", "-1", MinFecha ) Then TieneError = True @@ -639,7 +743,7 @@ Partial Class OP_OP Next End If - '✅ 4. Confirmar o cancelar transacción + If Not TieneError Then ObjInventario.Commit() Alert($"Solicitud de Traspaso guardada. Folio: {FolioSolicitud}", TipoMensaje.MsgInformacion) @@ -786,18 +890,35 @@ Partial Class OP_OP End Sub Protected Sub DdlAlmacenOrigenMP_SelectedIndexChanged(sender As Object, e As EventArgs) - ' ✅ Mantener siempre el almacén de producción (tipo 28) en destino + DdlAlmacenDestinoMP.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 28") DdlAlmacenDestinoMP.DataBind() - ' ✅ Opcional: Seleccionar el primer almacén de producción por defecto + If DdlAlmacenDestinoMP.Items.Count > 0 Then DdlAlmacenDestinoMP.SelectedIndex = 0 End If End Sub -#Region "Eventos de Botones" + Protected Sub GvProductoTerminado_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + Dim originalQty As Decimal = Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Cantidad")) + Dim txtCantidad As TextBox = DirectCast(e.Row.FindControl("TxtCantidadPT"), TextBox) + txtCantidad.Attributes("data-original") = originalQty.ToString("0") + End If + End Sub + Protected Sub GvMPUtilizada_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + Dim originalQty As Decimal = Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Cantidad")) + Dim txtDevolucion As TextBox = DirectCast(e.Row.FindControl("TxtDevolucionMP"), TextBox) + txtDevolucion.Attributes("data-original") = originalQty.ToString("0") + End If + End Sub + + + +#Region "Finalizar" Protected Sub BtnFinalizarOP_Click(sender As Object, e As EventArgs) If CveOP = -1 Then Exit Sub @@ -811,6 +932,11 @@ Partial Class OP_OP DdlAlmacenTerminado.DataBind() DdlAlmacenTerminado.Items.Insert(0, New ListItem("Seleccionar almacén", "-1")) + ' Almacén de Devoluciones (Tipo 1) + DdlAlmacenDevolucion.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 1") + DdlAlmacenDevolucion.DataBind() + DdlAlmacenDevolucion.Items.Insert(0, New ListItem("Seleccionar almacén", "-1")) + ' 3. Cargar GridViews GvProductoTerminado.DataSource = DtPS.FiltraParametros("Tipo = 'Producto'") GvProductoTerminado.DataBind() @@ -823,15 +949,42 @@ Partial Class OP_OP End Sub Protected Sub BtnGuardarFinalizarOP_Click(sender As Object, e As EventArgs) + Dim EstatusFinalizar As String = GlobalDTOPEstatus(UsuarioActual.CveEmpresa).FiltroPrimeroValor("EstatusOP", "TipoEstatus=3") + Dim CveEstatusFinalizar As Integer = GlobalDTOPEstatus(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveEstatusOP", "TipoEstatus=3").ToEntero() + If Not CveEstatusFinalizar > 0 Then + Alert("No se encontró el estatus de finalización de la OP.", TipoMensaje.MsgError) + Exit Sub + End If + If DdlAlmacenOrigenSalidaMP.SelectedValue = "-1" OrElse DdlAlmacenTerminado.SelectedValue = "-1" Then Alert("Selecciona ambos almacenes.", TipoMensaje.MsgAdvertencia) Exit Sub End If - ' Dim TotalCantidad As Decimal = DtMovimientos.SUMD("Cantidad") - 'Inicia la transacción + For Each row As GridViewRow In GvProductoTerminado.Rows + Dim txtCantidad As TextBox = DirectCast(row.FindControl("TxtCantidadPT"), TextBox) + Dim cantidadIngresada As Decimal = txtCantidad.Text.ToDecimal() + Dim cantidadOriginal As Decimal = txtCantidad.Attributes("data-original").ToDecimal() - Dim CveMovimientoSalida As Integer = 0 + If cantidadIngresada > cantidadOriginal Then + Alert("La cantidad del producto terminado no puede superar lo solicitado.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + Next + + + For Each row As GridViewRow In GvMPUtilizada.Rows + Dim txtDevolucion As TextBox = DirectCast(row.FindControl("TxtDevolucionMP"), TextBox) + Dim devolucionIngresada As Decimal = txtDevolucion.Text.ToDecimal() + Dim cantidadOriginal As Decimal = txtDevolucion.Attributes("data-original").ToDecimal() + + If devolucionIngresada > cantidadOriginal Then + Alert("La devolución no puede superar la cantidad de materia prima solicitada.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + Next + + Dim CveMovimientoSalida As Integer = 1 Dim CveMovimientoEntrada As Integer = 0 Dim IDPoliza As Integer = 0 Dim FolioSalida As Integer = 0 @@ -844,8 +997,13 @@ Partial Class OP_OP Dim ErrorMovInv As Boolean = False Dim TextoError As String = "" Dim TipoMovimientoSalida As Integer = 8 + Dim TipoMovimientoDev As Integer = 33 Dim CveConceptoEntrada As Integer = 9 Dim TotalCostoMP As Decimal = 0 + 'Dim TotalDevoluciones As Decimal = 0 + Dim CveMovimientoDev As Integer = 0 + Dim CostoDevoluciones As Decimal = 0 + Dim ObjInventario As New ClsInventarios() @@ -855,16 +1013,102 @@ Partial Class OP_OP Try CveMovimientoSalida = ObjInventario.AddMovimiento(DdlAlmacenOrigenSalidaMP.SelectedValue.ToEntero(), TipoMovimientoSalida, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="Finalización OP #" & LblFolio.Text, Modulo:="OP/FinalizarOPSalida") - + FolioEntrada = ObjInventario.Folio + Dim DtMPAlmacen As DataTable = Nothing If CveMovimientoSalida > 0 Then - For Each rowMP As DataRow In DtMP.Select("Tipo = 'MP'") - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, rowMP("Cantidad").ToString.ToDecimal(), rowMP("CveUMMateriaPrima").ToString.ToEntero(), rowMP("CvePSMateriaPrima").ToString.ToEntero(), 1) Then - ErrorMovInv = True : TextoError = "x" : Exit For + For Each rowMP As DataRow In DtMP.Select("Tipo = 'MP'") + Dim CvePS As Integer = rowMP("CvePSMateriaPrima").ToString.ToEntero + Dim CveUM As Integer = rowMP("CveUMMateriaPrima").ToString.ToEntero + Dim Cantidad As Decimal = rowMP("Cantidad").ToString.ToDecimal + + ' Registrar detalle + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Cantidad, CveUM, CvePS, 0) Then + ErrorMovInv = True + Exit For End If Next - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - TotalCostoMP = ObjInventario.DtResultados.SUMD("Total") + + If Not ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then + Throw New Exception("Error al cargar detalles del inventario") + End If + DtMPAlmacen = ObjInventario.DtResultados.Copy() + + ' 5. Calcular TotalCostoMP (ya está actualizado) + TotalCostoMP = ObjInventario.DtResultados.SUMD("Total") + + Dim CostosPorProducto As New Dictionary(Of Integer, Decimal) + + ' 1. Recorrer cada Producto Terminado en la OP + For Each rowProducto As DataRow In DtPS.Select("Tipo = 'Producto'") + Dim CvePSProducto As Integer = rowProducto("Clave").ToString.ToEntero() + Dim CantidadProducto As Decimal = rowProducto("Cantidad").ToString.ToDecimal() + Dim TotalMPProducto As Decimal = 0 + Dim TotalMOProducto As Decimal = 0 + Dim TotalCIProducto As Decimal = 0 + + ' 2. Calcular Costo de Materias Primas por Producto + For Each rowMP As DataRow In DtMP.Select($"Clave = {CvePSProducto}") + Dim CvePSMP As Integer = rowMP("CvePSMateriaPrima").ToString.ToEntero() + Dim CveUMMP As Integer = rowMP("CveUMMateriaPrima").ToString.ToEntero() + Dim PU As Decimal = DtMPAlmacen.FiltroPrimeroValor("PU", $"CvePS = {CvePSMP} AND CveUM = {CveUMMP}").ToDecimal() + TotalMPProducto += rowMP("Cantidad").ToString().ToDecimal() * PU + Next + + ' 3. Calcular Mano de Obra por Producto + For Each rowMO As DataRow In DtMO.Select($"Clave = {CvePSProducto}") + TotalMOProducto += rowMO("Total").ToString.ToDecimal() + Next + + ' 4. Calcular Costos Indirectos por Producto + For Each rowCI As DataRow In DtCI.Select($"Clave = {CvePSProducto}") + TotalCIProducto += rowCI("Total").ToString.ToDecimal() + Next + + ' 5. Sumar Total por Producto (MP + MO + CI) + Dim TotalProducto As Decimal = TotalMPProducto + TotalMOProducto + TotalCIProducto + CostosPorProducto.Add(CvePSProducto, TotalProducto) + Next + + ' 2. PROCESAR DEVOLUCIONES SI EXISTEN + If Not ErrorMovInv Then + Dim TotalDevoluciones As Decimal = GvMPUtilizada.Rows.Cast(Of GridViewRow)().Sum(Function(row) DirectCast(row.FindControl("TxtDevolucionMP"), TextBox).Text.ToDecimal()) + + If TotalDevoluciones > 0 Then + If DdlAlmacenDevolucion.SelectedValue = "-1" Then + Alert("Seleccione almacén para devoluciones", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + CveMovimientoDev = ObjInventario.AddMovimiento(DdlAlmacenDevolucion.SelectedValue.ToEntero(), TipoMovimientoDev, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=$"Devolución OP #{LblFolio.Text}", Modulo:="OP/Devoluciones", CveMovimientoRelacionado:=CveMovimientoSalida) + + + If CveMovimientoDev > 0 Then + For Each row As GridViewRow In GvMPUtilizada.Rows + Dim Devolucion As Decimal = row.FCTextBox("TxtDevolucionMP").Text.ToDecimal() + If Devolucion > 0 Then + Dim CvePS As Integer = row.DataKey("CvePSMateriaPrima").ToEntero 'GvMPUtilizada.DataKeys(row.RowIndex)("CvePSMateriaPrima").ToString.ToEntero() + Dim CveUM As Integer = row.DataKey("CveUMMateriaPrima").ToEntero 'GvMPUtilizada.DataKeys(row.RowIndex)("CveUMMateriaPrima").ToString.ToEntero() + + + Dim PU As Decimal = DtMPAlmacen.FiltroPrimeroValor("PU", $"CvePS = {CvePS} AND CveUM = {CveUM}").ToDecimal() + + If Not ObjInventario.AddMovimientoDetalle( + CveMovimientoDev, + Devolucion, + CveUM, + CvePS, + PU + ) Then + ErrorMovInv = True + End If + + CostoDevoluciones += Devolucion * PU + End If + Next + End If + End If + End If If Not ErrorMovInv Then @@ -872,8 +1116,9 @@ Partial Class OP_OP End If If CveMovimientoEntrada > 0 AndAlso Not ErrorMovInv Then - Dim CantidadPT As Decimal = DtPS.AsEnumerable().Sum(Function(row) Convert.ToDecimal(row("Cantidad"))) - Dim PU_PT As Decimal = If(CantidadPT > 0, TotalCostoMP / CantidadPT, 1) + Dim CostoPTAjustado As Decimal = TotalCostoMP - CostoDevoluciones + Dim CantidadPT As Decimal = DtPS.AsEnumerable().Sum(Function(r) r.Field(Of Decimal)("Cantidad")) + Dim PU_PT As Decimal = If(CantidadPT > 0, CostoPTAjustado / CantidadPT, 0) For Each rowPT As DataRow In DtPS.Select("Tipo = 'Producto'") If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, rowPT("Cantidad").ToString.ToDecimal(), rowPT("CveUM").ToString.ToEntero(), rowPT("Clave").ToString.ToEntero(), PU_PT) Then @@ -889,24 +1134,24 @@ Partial Class OP_OP ErrorMovInv = True End If - If Not ErrorMovInv AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TotalCostoMP, TotalCostoMP, 68, "Producción PT OP #" & LblFolio.Text, "Producción PT OP #" & LblFolio.Text, CveMovimientoAlmacen:=CveMovimientoEntrada) Then + If Not ErrorMovInv AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, CostoPTAjustado, CostoPTAjustado, 68, "Producción PT OP #" & LblFolio.Text, "Producción PT OP #" & LblFolio.Text, CveMovimientoAlmacen:=CveMovimientoEntrada) Then ErrorMovInv = True End If - If Not ErrorMovInv Then - If Not ObjOP.UpdateEstatusOP(CveOP, 3, UsuarioActual.CveEmpresa) Then - ErrorMovInv = True : TextoError = "Error al actualizar estatus de la OP" - End If - End If + + + ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, CostoDevoluciones, CostoDevoluciones, 95, "", $"OP #{LblFolio.Text}", CveMovimientoAlmacen:=CveMovimientoDev) + + 'If Not ErrorMovInv Then - ' If Not ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual) Then - ' ErrorMovInv = True : TextoError = "Error en validación de póliza" - ' ElseIf ObjConta.ValorPolizaDescuadre > 0 Then - ' ErrorMovInv = True : TextoError = "Descuadre en póliza contable" - ' End If + 'If Not ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual) Then + 'ErrorMovInv = True : TextoError = "Error en validación de póliza" + 'ElseIf ObjConta.ValorPolizaDescuadre > 0 Then + ' ErrorMovInv = True : TextoError = "Descuadre en póliza contable" + 'End If 'End If End If End If @@ -914,16 +1159,32 @@ Partial Class OP_OP If Not ErrorMovInv Then - ObjInventario.Commit() - Alert($"Orden de producción finalizada. -
{ObjInventario.Folio} ", TipoMensaje.MsgInformacion) + If ObjOP.UpdateEstatusOP(CveOP, CveEstatusFinalizar, UsuarioActual.CveEmpresa) Then + ObjInventario.Commit() + TxtEstatus.Text = EstatusFinalizar + DeshabilitarControles() + UpOP.Update() + UpGvDatosOP.Update() + Alert("Orden de producción finalizada.
" & "" & FolioEntrada & "", + TipoMensaje.MsgInformacion) + + + + RegistraScript("$('#DVModalFinalizarOP').modal('hide');") + + + Else + ObjInventario.RollBack() + Alert("Error al actualizar el estatus.", TipoMensaje.MsgError) + End If + Else ObjInventario.RollBack() Alert($"Error contable: {TextoError}", TipoMensaje.MsgError) End If - RegistraScript("$('#DVModalFinalizarOP').modal('hide');") - CargaDatos() + + Catch ex As Exception ObjInventario.RollBack() @@ -933,7 +1194,6 @@ Partial Class OP_OP ObjConta.Dispose() End Try - End Sub #End Region End Class From d345089468540514bd199a5bc8bdab7d259d2994 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Sat, 12 Apr 2025 16:31:02 -0700 Subject: [PATCH 9/9] --FIX impresion de saldos aplicados --- Compras/PopUpVerFactura.aspx.vb | 76 +- Empresas/189/Formatos/SaldoAntNCDev.rdlc | 1168 ---------------------- Ventas/PVCobranza.aspx.vb | 35 +- 3 files changed, 54 insertions(+), 1225 deletions(-) delete mode 100644 Empresas/189/Formatos/SaldoAntNCDev.rdlc diff --git a/Compras/PopUpVerFactura.aspx.vb b/Compras/PopUpVerFactura.aspx.vb index a71ab3f41..3ebde3353 100644 --- a/Compras/PopUpVerFactura.aspx.vb +++ b/Compras/PopUpVerFactura.aspx.vb @@ -1587,19 +1587,18 @@ Partial Class PopUpVerFactura Dim CVEVENTA As Integer = UrlParametros("CVEVENTA").ToString.ToEntero Dim CVECLIENTE As Integer = UrlParametros("CVECLIENTE").ToString.ToEntero Dim MONTO As Decimal = UrlParametros("MONTO").ToString.ToDecimal + Dim TIPO As String = UrlParametros("TIPO").ToString If CVECLIENTE > 0 AndAlso (CVEIE > 0 Or CVEVENTA > 0) Then - ImprimirSaldosAmortizacion(CVEVENTAAMORTIZADA, CVEIE, CVEVENTA, CVECLIENTE, MONTO) + ImprimirSaldosAmortizacion(TIPO, CVEVENTAAMORTIZADA, CVEIE, CVEVENTA, CVECLIENTE, MONTO) End If End If End Sub - Private Sub ImprimirSaldosAmortizacion(CveVentaAmortizada As Integer, CveIE As Integer, CveVenta As Integer, CveCliente As Integer, Monto As Decimal) + Private Sub ImprimirSaldosAmortizacion(Tipo As String, CveVentaAmortizada As Integer, CveIE As Integer, CveVenta As Integer, CveCliente As Integer, Monto As Decimal) - - Dim ObjMovtos As New ClsMovimientos() Dim SaldoAntNCDev As Decimal = 0 Dim DatosSaldoAntNCDev As New DataTable Dim TipoDocto As String = "" @@ -1607,36 +1606,22 @@ Partial Class PopUpVerFactura Dim Saldo As Decimal = 0D Dim DTNCVinculadas As New DataTable - + Dim ObjMovtos As New ClsMovimientos() If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente) Then - DatosSaldoAntNCDev = ObjMovtos.DtResultados + If Tipo.Contiene("NC", "Ant") Then + DatosSaldoAntNCDev = ObjMovtos.DtResultados.FiltraParametros($"Tipo='{Tipo}' AND CveVenta={CveVenta}") + ElseIf Tipo.Contiene("IxC") Then + DatosSaldoAntNCDev = ObjMovtos.DtResultados.FiltraParametros($"Tipo='{Tipo}' AND CveIE={CveIE}") + End If End If ObjMovtos.Dispose() If DatosSaldoAntNCDev IsNot Nothing AndAlso DatosSaldoAntNCDev.Rows.Count > 0 Then - SaldoAntNCDev = If(CveVenta > 0, - DatosSaldoAntNCDev.FiltroPrimeroValor("Saldo", $"CveVenta={CveVenta}").ToDecimal, - DatosSaldoAntNCDev.FiltroPrimeroValor("Saldo", $"CveIE={CveIE}").ToDecimal) - - TipoDocto = If(CveVenta > 0, - DatosSaldoAntNCDev.FiltroPrimeroValor("Tipo", $"CveVenta={CveVenta}"), - DatosSaldoAntNCDev.FiltroPrimeroValor("Tipo", $"CveIE={CveIE}")) - - - - - If CveIE > 0 Then - CveVenta = DatosSaldoAntNCDev.FiltroPrimeroValor("CveVenta", $"CveIE={CveIE}").ToEntero - Folio = DatosSaldoAntNCDev.FiltroPrimeroValor("Folio", $"CveIE={CveIE}") - Saldo = DatosSaldoAntNCDev.FiltroPrimeroValor("Saldo", $"CveIE={CveIE}").ToDecimal - Else - Folio = DatosSaldoAntNCDev.FiltroPrimeroValor("Folio", $"CveVenta={CveVenta}") - Saldo = DatosSaldoAntNCDev.FiltroPrimeroValor("Saldo", $"CveVenta={CveVenta}").ToDecimal - End If - - - + SaldoAntNCDev = DatosSaldoAntNCDev.FiltroPrimeroValor("Saldo").ToDecimal + TipoDocto = DatosSaldoAntNCDev.FiltroPrimeroValor("Tipo") + Folio = DatosSaldoAntNCDev.FiltroPrimeroValor("Folio") + Saldo = DatosSaldoAntNCDev.FiltroPrimeroValor("Saldo").ToDecimal End If @@ -1651,30 +1636,53 @@ Partial Class PopUpVerFactura ObjVentas.Dispose() End If + If TipoDocto.Contiene("IxC") Then + + DTNCVinculadas = New DataTable() + DTNCVinculadas.Columns.Add(New DataColumn("SerieFolioEstatus", GetType(String))) + DTNCVinculadas.Columns.Add(New DataColumn("FechaAplicado", GetType(String))) + DTNCVinculadas.Columns.Add(New DataColumn("Moneda", GetType(String))) + DTNCVinculadas.Columns.Add(New DataColumn("TotalNC", GetType(String))) + Dim DtIxC As DataTable = Nothing + Dim ObjVentas As New ClsVentas + If ObjVentas.GetRepAnticiposNCIXCDetalle(CveCliente, -1, MinFecha, MaxFecha, UsuarioActual.CveEmpresa, -1, 3, -1, MinFecha, MaxFecha, TipoCambio:=1, TCEspecifico:=-1) Then + DtIxC = ObjVentas.DtResultados.FiltraParametros($"CveIE={CveIE} AND TipoColumna ='Aplicación'") + End If + ObjVentas.Dispose() + + If DtIxC IsNot Nothing Then + For Each RowIxC As DataRow In DtIxC.Rows + Dim Row As DataRow = DTNCVinculadas.NewRow + Row("SerieFolioEstatus") = RowIxC("SerieFolioAmortizacion") + Row("FechaAplicado") = RowIxC("FechaAmortizacion") + Row("Moneda") = RowIxC("MonedaAmortizacion") + Row("TotalNC") = RowIxC("ImporteAmortizacion") + DTNCVinculadas.Rows.Add(Row) + Next + End If + End If + If DTNCVinculadas IsNot Nothing Then Dim params As New List(Of ReportParameter) + params.Add(New ReportParameter("Tipo", Tipo)) + Dim ObjVentas As New ClsVentas If ObjVentas.GetVenta(CveVentaAmortizada, UsuarioActual.CveEmpresa) Then Dim DbRowVenta = ObjVentas.DtResultados.Copy().FiltroPrimero("") If DbRowVenta IsNot Nothing Then - params.Add(New ReportParameter("SerieFolio", DbRowVenta("SerieFolio").ToString)) + params.Add(New ReportParameter("SerieFolio", Folio)) params.Add(New ReportParameter("Moneda", DbRowVenta("Moneda").ToString)) params.Add(New ReportParameter("Cliente", DbRowVenta("ClienteNombre").ToString)) - End If End If ObjVentas.Dispose() - - Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png") - - params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) params.Add(New ReportParameter("FechaImpresion", NowADS().ToString)) diff --git a/Empresas/189/Formatos/SaldoAntNCDev.rdlc b/Empresas/189/Formatos/SaldoAntNCDev.rdlc deleted file mode 100644 index e09e5fbaa..000000000 --- a/Empresas/189/Formatos/SaldoAntNCDev.rdlc +++ /dev/null @@ -1,1168 +0,0 @@ - - - 0 - - - - System.Data.DataSet - /* Local Connection */ - - f55ecc33-47ff-4fc5-a233-35ea9bb1f578 - - - - - - DataSet - /* Local Query */ - - - - SerieFolio - System.String - - - SerieFolioEstatus - System.String - - - FechaAplicado - System.String - - - Importe - System.Double - - - TotalNC - System.Double - - - Moneda - System.String - - - - DataSet - C:\Users\Caudillo\Documents\Visual Studio 2013\WebSites\WebSite9\App_Code\DataSet.xsd - DataTable1 - - - - - - - - - - - - - - - - - - true - true - - - - - Folio - - - - - - - Textbox28 - - - - LightGrey - - - LightGrey - - - LightGrey - - - - - LightGrey - 1pt - - - - - - - - - - - 3.42604cm - - - 2.43119cm - - - 3.94465cm - - - - - 0.44125cm - - - - - true - true - - - - - =Fields!FechaAplicado.Value - - - - - - - FechaAplicado - - - =IIF(Fields!TotalNC.Value < 0, "#e7505a","White") - 0.5pt - - - - - - - - true - true - - - - - =Fields!Moneda.Value - - - - - - - Moneda - - - =IIF(Fields!TotalNC.Value < 0, "#e7505a","White") - 0.5pt - - - - - - - - true - true - - - - - =Fields!TotalNC.Value - - - - - - - TotalNC - - - =IIF(Fields!TotalNC.Value < 0, "#e7505a","White") - 0.5pt - - - - - - - - - - - - - 0.44125cm - - - true - true - - - - - Fecha - - - - - - - Textbox19 - - - LightGrey - 1pt - - - - - - - - 0.44125cm - - - true - true - - - - - Moneda - - - - - - - Textbox21 - - - LightGrey - 1pt - - - - - - - - 0.44125cm - - - true - true - - - - - Importe - - - - - - - Textbox23 - - - LightGrey - 1pt - - - - - - - - - - - - - 6.69369cm - - - true - true - - - - - =Fields!SerieFolioEstatus.Value - - - - - - - SerieFolioEstatus - - - =IIF(Fields!TotalNC.Value < 0, "#e7505a","White") - 0.5pt - - - - - - - - true - true - DataSet1 - 0.12375cm - 0.25664cm - 0.8825cm - 16.49557cm - - - - - - 0.39616in - - - - - - - Textbox1 - 3.8144cm - 0.6cm - 13.0693cm - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Aplicaciones de facturas - - - - - - - Textbox2 - 0.63528cm - 3.77912cm - 0.52945cm - 13.0693cm - 1 - - - 2pt - 2pt - 2pt - 2pt - - - - External - =Parameters!LogoPath.Value - FitProportional - 0.06614cm - 2.22362cm - 3.00743cm - 2 - - - - - - true - true - - - - - Cliente: - - - - - - - - - true - true - - - - - =Parameters!Cliente.Value - - - - - - true - true - - - - - Factura: - - - - - - - - - true - true - - - - - =Parameters!SerieFolio.Value - - - - - - true - true - - - - - Monto: - - - - - - - - - true - true - - - - - =Parameters!Monto.Value - - - - - - true - true - - - - - Saldo: - - - - - - - - - true - true - - - - - =Parameters!Saldo.Value - - - - - - true - true - - - - - Aplicaciones de facturas: - - - - - - - - - true - true - - - - - Folio: - - - - - - - - - true - true - - - - - =Parameters!Folio.Value - - - - - - true - true - - - - - Fecha: - - - - - - - - - true - true - - - - - =Parameters!FechaImpresion.Value - - - - - - true - true - - - - - Moneda: - - - - - - - - - true - true - - - - - =Parameters!Moneda.Value - - - - - - - - - - - 0.48291cm - true - true - - - true - true - - - - - ="Página " & Globals.PageNumber & " de " & Globals.TotalPages - - - - - - - Textbox3 - 0.08291cm - 18.6093cm - 0.4cm - 2.06587cm - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Usuario: - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - =Parameters!UsuarioImprimio.Value - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Fecha Impresión: - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - =Parameters!FechaImpresion.Value - - - - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - 29.7cm - 21cm - 0.1cm - 0.1cm - 1cm - 0.5cm - 0.13cm -