diff --git a/App_Code/ClsInventarios.vb b/App_Code/ClsInventarios.vb index 139002853..286840260 100644 --- a/App_Code/ClsInventarios.vb +++ b/App_Code/ClsInventarios.vb @@ -2607,7 +2607,8 @@ Public Class ClsInventarios #Region "I N V E N T A R I O - F I S I C O - D E T A L L E" - Public Function UpdateInventarioFisicoDetalles(CveInventarioFisicoDetalle As Integer, CvePS As Integer, CveUM As Integer, Cantidad As Double) As Boolean + Public Function UpdateInventarioFisicoDetalles(CveInventarioFisicoDetalle As Integer, CvePS As Integer, CveUM As Integer, Cantidad As Double, Optional Serie As String = "-1", + Optional Lote As String = "-1", Optional FechaCaducidad As Date = MinFecha) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Inv_InventarioFisicoDetalleUpdate") @@ -2617,6 +2618,9 @@ Public Class ClsInventarios .Add("@CveUM", SqlDbType.Int).Value = CveUM .Add("@Cantidad", SqlDbType.Money).Value = Cantidad .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@Serie", SqlDbType.VarChar).Value = Serie + .Add("@Lote", SqlDbType.NVarChar).Value = Lote + .Add("@FechaCaducidad", SqlDbType.Date).Value = FechaCaducidad End With Try diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index 576c9b935..cc953d4a8 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -5170,7 +5170,7 @@ Public Class ClsVentas #End Region - Public Function AddAutorizacionLimite(CveEmpresa As Integer, CveCliente As Integer, CveVendedor As Integer, Importe As Decimal, CveEstatus As Integer, CveUsuario As Integer, TipoAutorizacion As Integer, TipoDocumento As String) As Boolean + Public Function AddAutorizacionLimite(CveEmpresa As Integer, CveCliente As Integer, CveVendedor As Integer, Importe As Decimal, CveEstatus As Integer, CveUsuario As Integer, TipoAutorizacion As Integer, TipoDocumento As String, Optional DiasVencidos As Integer = 0) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_AutorizacionLimitesAdd") With SqlAdapter.SelectCommand.Parameters @@ -5182,6 +5182,7 @@ Public Class ClsVentas .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario .Add("@TipoAutorizacion", SqlDbType.Int).Value = TipoAutorizacion .Add("@TipoDocumento", SqlDbType.VarChar).Value = TipoDocumento + .Add("@DiasVencidos", SqlDbType.Int).Value = DiasVencidos End With Try SqlAdapter.Fill(Data) diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 4c47d5360..7550600b4 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -10283,6 +10283,7 @@ Partial Class Compras_Compras (row1("CveTipoGasto").ToString.ToEntero <> row2("CveTipoGasto").ToString.ToEntero) Or (row1("Total").ToString.ToDouble <> row2("Total").ToString.ToDouble) Or (row1("NoDeducible").ToString <> row2("NoDeducible").ToString) Or + (row1("CveActivoFijo").ToString.ToEntero <> row2("CveActivoFijo").ToString.ToEntero) Or (row1("CvePS").ToString.ToEntero <> row2("CvePS").ToString.ToEntero) Then Return False End If diff --git a/Contratos/ContratoObra.aspx b/Contratos/ContratoObra.aspx index fa300e10a..62d582d06 100644 --- a/Contratos/ContratoObra.aspx +++ b/Contratos/ContratoObra.aspx @@ -365,11 +365,13 @@
- -
- -
- + + +
+ +
+
+
-
- +
-
-
diff --git a/Contratos/ContratoObra.aspx.vb b/Contratos/ContratoObra.aspx.vb index ae481a310..811096536 100644 --- a/Contratos/ContratoObra.aspx.vb +++ b/Contratos/ContratoObra.aspx.vb @@ -735,8 +735,9 @@ Partial Class Contratos_ContratoObra TxtNumeroLicitacion.Text = ObjContratos.NumeroLicitacion TipoContrato = ObjContratos.CveContratoTipo CveTipoContrato = ObjContratos.DtResultados.Rows(0)("CveContratoTipo").ToString.ToEntero - TxtCorreoNotificacion.Text = ObjContratos.DtResultados.Rows(0)("CorreoNotificacionPedDev").ToString - DdlCliente.ddl.SelectedValueExist(ObjContratos.CveCliente) + TxtCorreoNotificacion.Text = ObjContratos.DtResultados.Rows(0)("CorreoNotificacionPedDev").ToString + DdlCliente.SelectedValue = ObjContratos.CveCliente.ToString + DdlCliente.SelectedText = ObjContratos.NombreComercial.ToString If ObjContratos.CveProveedor > 0 Then ' TrProveedor.Visible = True @@ -744,8 +745,9 @@ Partial Class Contratos_ContratoObra CargaContratista() DdlContratista.SelectedValue = ObjContratos.CveProveedor.ToString Else - cargaClientes() - DdlCliente.ddl.SelectedValueExist(ObjContratos.CveCliente) + cargaClientes() + DdlCliente.SelectedValue = ObjContratos.CveCliente.ToString + UpCliente.Update() UpGral.Update() CargaSucursalCliente() DdlSucursalCliente.SelectedValue = ObjContratos.CveSucursalCliente.ToString diff --git a/Inventarios/InventarioFisico.aspx b/Inventarios/InventarioFisico.aspx index 9c038e2fb..0c82738ba 100644 --- a/Inventarios/InventarioFisico.aspx +++ b/Inventarios/InventarioFisico.aspx @@ -166,7 +166,7 @@
- + @@ -211,7 +211,7 @@
- + @@ -258,10 +258,10 @@
- + - - + + @@ -302,7 +302,7 @@
- + @@ -349,7 +349,7 @@
- + @@ -394,7 +394,7 @@
- + diff --git a/Inventarios/InventarioFisicoDetalle.aspx b/Inventarios/InventarioFisicoDetalle.aspx index bd93252e6..dcc4ec481 100644 --- a/Inventarios/InventarioFisicoDetalle.aspx +++ b/Inventarios/InventarioFisicoDetalle.aspx @@ -83,6 +83,15 @@ .SinColor th { background-color: white; } + + .divmodal{ + width: 500px; + } + .center { + float: none; + margin-left: auto; + margin-right: auto; + } @@ -106,6 +115,7 @@
  • Imprimir EXCEL
  • + @@ -113,7 +123,9 @@ - +
  • + Descargar productos +
  • Inventario Físico Detalle @@ -357,7 +369,7 @@ " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info">
    - + @@ -368,6 +380,11 @@ + + + + + @@ -381,6 +398,55 @@ + + diff --git a/Inventarios/InventarioFisicoDetalle.aspx.vb b/Inventarios/InventarioFisicoDetalle.aspx.vb index e7afad4c4..e71d42996 100644 --- a/Inventarios/InventarioFisicoDetalle.aspx.vb +++ b/Inventarios/InventarioFisicoDetalle.aspx.vb @@ -3,6 +3,7 @@ Option Explicit On Imports System.Data Imports Extensiones +Imports GemBox.Spreadsheet Imports Microsoft.Reporting.WebForms Partial Class Inventarios_InventarioFisicoDetalle @@ -49,6 +50,7 @@ Partial Class Inventarios_InventarioFisicoDetalle End Set End Property + #End Region Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load @@ -153,7 +155,14 @@ Partial Class Inventarios_InventarioFisicoDetalle CveAlmacenesStr.AppendFormat("{0},", dr("CveAlmacen")) Next End If - LblAlmacenes.Text = str.ToString + If str.ToString.Length > 500 Then + LblAlmacenes.Text = str.ToString.Substring(0, 500) + LblAlmacenes.ToolTip = str.ToString + Else + LblAlmacenes.Text = str.ToString + End If + str.Clear() + CveAlmacenes = CveAlmacenesStr.ToString.Substring(0, CveAlmacenesStr.Length - 1) End If @@ -165,12 +174,24 @@ Partial Class Inventarios_InventarioFisicoDetalle For Each dr As DataRow In dt.FiltraParametros("Incluye = 1").Rows str.AppendFormat("{0},", dr("Clasificacion")) Next - LblClasif.Text = str.ToString + If str.ToString.Length > 500 Then + LblClasif.Text = str.ToString.Substring(0, 29) + LblClasif.ToolTip = str.ToString + Else + LblClasif.Text = str.ToString + End If str.Clear() For Each dr As DataRow In dt.FiltraParametros("Incluye = 0").Rows str.AppendFormat("{0},", dr("Clasificacion")) - Next - LblClasificacionesExcluidas.Text = str.ToString + Next + If str.ToString.Length > 500 Then + LblClasificacionesExcluidas.Text = str.ToString.Substring(0, 500) + LblClasificacionesExcluidas.ToolTip = str.ToString + Else + LblClasificacionesExcluidas.Text = str.ToString + End If + str.Clear() + End If End If @@ -182,13 +203,26 @@ Partial Class Inventarios_InventarioFisicoDetalle For Each dr As DataRow In dt.FiltraParametros("Incluye = 1").Rows str.AppendFormat("{0},", dr("CodigoPS")) - Next - LblProductos.Text = str.ToString + Next + If str.ToString.Length > 500 Then + LblProductos.Text = str.ToString.Substring(0, 500) + LblProductos.ToolTip = str.ToString + + Else + LblProductos.Text = str.ToString + End If str.Clear() For Each dr As DataRow In dt.FiltraParametros("Incluye = 0").Rows str.AppendFormat("{0},", dr("CodigoPS")) - Next - LblProductosExcluidos.Text = str.ToString + Next + If str.ToString.Length > 500 Then + LblProductosExcluidos.Text = str.ToString.Substring(0, 500) + LblProductosExcluidos.ToolTip = str.ToString + Else + LblProductosExcluidos.Text = str.ToString + End If + str.Clear() + End If End If @@ -200,8 +234,13 @@ Partial Class Inventarios_InventarioFisicoDetalle For Each dr As DataRow In dt.FiltraParametros("Incluye = 1").Rows str.AppendFormat("{0},", dr("RazonSocial")) - Next - LblProveedores.Text = str.ToString + Next + If str.ToString.Length > 500 Then + LblProveedores.Text = str.ToString.Substring(0, 500) + LblProveedores.ToolTip = str.ToString + Else + LblProveedores.Text = str.ToString + End If str.Clear() End If @@ -566,7 +605,6 @@ Partial Class Inventarios_InventarioFisicoDetalle Private Sub LnkExcel_Click(sender As Object, e As EventArgs) Handles LnkExcel.Click Impimir(Formato:="EXCEL") End Sub - Protected Sub Impimir(Optional Formato As String = "PDF", Optional Agrupar As Boolean = False) Dim DtDatos As New DataTable Dim ObjInventario As New ClsInventarios() @@ -607,6 +645,86 @@ Partial Class Inventarios_InventarioFisicoDetalle End If End Sub + Private Sub LnkExcelUniverso_Click(sender As Object, e As EventArgs) Handles LnkExcelUniverso.Click + Dim IncluyePS, ExcluyePS, IncluyeClasificacion, ExcluyeClasificacion, IncluyeProveedor As New StringBuilder + Dim ObjInventario As New ClsInventarios + + If ObjInventario.GetInventarioFisicoDetallesClasificacion(CveInventarioFisico, UsuarioActual.CveEmpresa) Then + Dim dt As DataTable = ObjInventario.DtResultados + If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then + For Each dr As DataRow In dt.FiltraParametros("Incluye = 1").Rows + IncluyeClasificacion.AppendFormat("{0},", dr("CveClasificacion")) + Next + For Each dr As DataRow In dt.FiltraParametros("Incluye = 0").Rows + ExcluyeClasificacion.AppendFormat("{0},", dr("CveClasificacion")) + Next + End If + + End If + + If ObjInventario.GetInventarioFisicoDetallesProductosServicios(CveInventarioFisico, UsuarioActual.CveEmpresa) Then + Dim dt As DataTable = ObjInventario.DtResultados + If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then + For Each dr As DataRow In dt.FiltraParametros("Incluye = 1").Rows + IncluyePS.AppendFormat("{0},", dr("CvePS")) + Next + For Each dr As DataRow In dt.FiltraParametros("Incluye = 0").Rows + ExcluyePS.AppendFormat("{0},", dr("CvePS")) + Next + End If + + End If + + If ObjInventario.GetInventarioFisicoDetallesProveedores(CveInventarioFisico, UsuarioActual.CveEmpresa) Then + Dim dt As DataTable = ObjInventario.DtResultados + Dim str As New StringBuilder + If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then + For Each dr As DataRow In dt.FiltraParametros("Incluye = 1").Rows + IncluyeProveedor.AppendFormat("{0},", dr("CveProveedor")) + Next + End If + End If + Dim dtPS As DataTable = GlobalDTPS(UsuarioActual.CveEmpresa) + If IncluyePS.ToString <> "" Then + dtPS = dtPS.FiltraParametros(String.Format("CvePS IN ({0})", IncluyePS.ToString.TrimEnd(","))) + End If + If ExcluyePS.ToString <> "" Then + dtPS = dtPS.FiltraParametros(String.Format("CvePS NOT IN ({0})", ExcluyePS.ToString.TrimEnd(","))) + End If + If IncluyeClasificacion.ToString <> "" Then + dtPS = dtPS.FiltraParametros(String.Format("CveClasificacion IN ({0})", IncluyeClasificacion.ToString.TrimEnd(","))) + End If + If ExcluyeClasificacion.ToString <> "" Then + dtPS = dtPS.FiltraParametros(String.Format("CveClasificacion NOT IN ({0})", ExcluyeClasificacion.ToString.TrimEnd(","))) + End If + If IncluyeProveedor.ToString <> "" Then + dtPS = dtPS.FiltraParametros(String.Format("CveProveedorCompra IN ({0})", IncluyeProveedor.ToString.TrimEnd(","))) + End If + dtPS = dtPS.FiltraParametros("", "PS", {"Codigo", "PS", "Clasificacion", "ProveedorCompra"}) + Dim NombreArchivo As String + SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet) + Dim workbook As New ExcelFile() + Dim worksheet = workbook.Worksheets.Add("Productos") + worksheet.InsertDataTable(dtPS, New InsertDataTableOptions() With + { + .ColumnHeaders = True, + .StartRow = 0, + .StartColumn = 0 + }) + + 'worksheet.Columns("B").Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(217, 217, 217), SpreadsheetColor.FromArgb(255, 255, 255)) + 'worksheet.Columns("C").Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(217, 217, 217), SpreadsheetColor.FromArgb(255, 255, 255)) + 'worksheet.Columns("Q").Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(217, 217, 217), SpreadsheetColor.FromArgb(255, 255, 255)) + worksheet.Rows(0).Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(217, 217, 217), SpreadsheetColor.FromArgb(255, 255, 255)) + + Dim columnCount = worksheet.CalculateMaxUsedColumns() + For i = 0 To columnCount + worksheet.Columns(i).AutoFit(1, worksheet.Rows(0), worksheet.Rows(worksheet.Rows.Count - 1)) + Next + + NombreArchivo = "Productos" + workbook.Save(Response, $"{NombreArchivo}.xlsx", SaveOptions.XlsxDefault) + End Sub #End Region Protected Sub BtnBuscarCodVarras_Click(sender As Object, e As EventArgs) @@ -647,4 +765,68 @@ Partial Class Inventarios_InventarioFisicoDetalle ' UPAgregarPro.Update() 'End Sub + + Protected Sub LnkEditar_Click(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + LimpiarModal() + HfCveInventarioFisicoDetalle.Value = GvRow.DataKey("CveInventarioFisicoDetalle").ToString + + HfCvePS.Value = GvRow.DataKey("CvePS").ToString + HfCveUM.Value = GvRow.DataKey("CveUnidadMedida").ToString + + TxtSerieLote.Text = GvRow.DataKey("SerieLote").ToString + TxtLoteEdit.Text = GvRow.DataKey("Lote").ToString + TxtFechaCaducida.Text = GvRow.DataKey("FechaCaducidad").ToString + TxtCantidad.Text = GvRow.DataKey("Cantidad").ToString + UpEditarPS.Update() + + RegistraScript("$('#ModalEditarPS').modal('show')") + End Sub + + + Private Sub LimpiarModal() + HfCveInventarioFisicoDetalle.Value = "" + HfCvePS.Value = "" + HfCveUM.Value = "" + TxtSerieLote.Text = "" + TxtLoteEdit.Text = "" + TxtFechaCaducida.Text = "" + TxtCantidad.Text = "" + + End Sub + + Protected Sub BtnGuadarEditarPS_Click(sender As Object, e As EventArgs) + Dim objInventario As New ClsInventarios + If Not TxtCantidad.Text.ToEntero > 0 Then + Alert("La cantidad debe ser mayor a 0", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + Dim serie As String = IIf(TxtSerieLote.Text.ToString = "", "-1", TxtSerieLote.Text.ToString) + Dim Lote As String = IIf(TxtLoteEdit.Text.ToString = "", "-1", TxtLoteEdit.Text.ToString) + Dim FechaCaducida As Date = IIf(TxtFechaCaducida.Text.ToString = "", MinFecha, TxtFechaCaducida.Text.ToString.ToDate) + + If objInventario.UpdateInventarioFisicoDetalles(HfCveInventarioFisicoDetalle.Value.ToEntero, HfCvePS.Value.ToEntero, HfCveUM.Value.ToEntero, TxtCantidad.Text.ToEntero, serie, Lote, FechaCaducida) Then + If objInventario.GetInventarioFisicoDetalle(CveInventarioFisico, ddlUsuario.SelectedValue.ToString.ToEntero) Then + GvIFD.DataSource = objInventario.DtResultados + End If + + GvIFD.DataBind() + + If (GvIFD.Rows.Count > 0) Then + GvIFD.UseAccessibleHeader = True + GvIFD.HeaderRow.TableSection = TableRowSection.TableHeader + RegistraScript("OrdenarGV();") + End If + + UPPInventario.Update() + UPAgregarPro.Update() + RegistraScript("$('#ModalEditarPS').modal('hide')") + Alert("Se modico el producto correctamente", TipoMensaje.MsgInformacion) + Else + Alert("Ocurrio un error al actuliazar", TipoMensaje.MsgError) + End If + + objInventario.Dispose() + End Sub End Class diff --git a/Inventarios/RepAnomalias.aspx.vb b/Inventarios/RepAnomalias.aspx.vb index b51f996f6..9f2c54546 100644 --- a/Inventarios/RepAnomalias.aspx.vb +++ b/Inventarios/RepAnomalias.aspx.vb @@ -148,8 +148,8 @@ Partial Class Inventarios_RepAnomalias End If Inventario.Dispose() - If Not String.IsNullOrWhiteSpace(UsuarioActual.Empresa.Funcionalidad(147)) Then GvS.Columns(7).HeaderText = UsuarioActual.Empresa.Funcionalidad(147) - If Not String.IsNullOrWhiteSpace(UsuarioActual.Empresa.Funcionalidad(147)) Then GvF.Columns(7).HeaderText = UsuarioActual.Empresa.Funcionalidad(147) + If Not String.IsNullOrWhiteSpace(UsuarioActual.Empresa.Funcionalidad(147)) Then GvS.Columns(8).HeaderText = UsuarioActual.Empresa.Funcionalidad(147) + If Not String.IsNullOrWhiteSpace(UsuarioActual.Empresa.Funcionalidad(147)) Then GvF.Columns(8).HeaderText = UsuarioActual.Empresa.Funcionalidad(147) GvS.DataSource = dt.FiltraParametros("Diferencia < 0") @@ -295,10 +295,10 @@ Partial Class Inventarios_RepAnomalias #End Region Private Sub BanderaSerieLoteCad(Gv As GridView, resultado As DataTable) - 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 + Gv.Columns(5).Visible = resultado.MAX("CveSeccionAlmacen").ToEntero > 0 + Gv.Columns(6).Visible = resultado.MAX("Serie") <> "" + Gv.Columns(7).Visible = resultado.MAX("Lote") <> "" + Gv.Columns(8).Visible = resultado.MAX("FechaCaducidad").ToDate > MinFecha End Sub Private Sub LnkCrear_Click(sender As Object, e As EventArgs) Handles LnkCrear.Click diff --git a/Nomina/Nomina.aspx.cs b/Nomina/Nomina.aspx.cs index 2e63ddb18..5fb57800d 100644 --- a/Nomina/Nomina.aspx.cs +++ b/Nomina/Nomina.aspx.cs @@ -2055,7 +2055,7 @@ public partial class Nomina_Nomina2 : ClsPaginas && (dtempleadosConceptos.COUNT("CveConcepto", string.Format("CveConcepto={0} AND CvePersonal ={1} AND Estatus =2", CveConcepto, SRCvePersonal)) == 0) ) { - if(!row["CveSistema"].ToString().ToEntero().Contiene(new int[] { 20,21,112,202, 203 })) + if(!row["CveSistema"].ToString().ToEntero().Contiene(new int[] { 20,21,112,202, 203,204,205,206,207,50,51 })) { BorradoLogico = 1; } diff --git a/Site.master.vb b/Site.master.vb index d187dbef2..5f9de4168 100644 --- a/Site.master.vb +++ b/Site.master.vb @@ -365,7 +365,7 @@ Partial Class Site For Each drN As DataRow In Nietos LinkNieto = drN("LIGA").ToString() If (drH("IsAngular").ToString() = "1") Then - LinkNieto = String.Format("{1}:4200{0}", drN("LIGA"), strdomain) + LinkNieto = String.Format("{1}:84{0}", drN("LIGA"), strdomain) End If If CveModulo = drN("CveModulo").ToString().ToEntero Then CveModuloPadreSeleccionado = CveModuloPadre : CveModuloHijoSeleccionado = CveModuloHijo diff --git a/Ventas/CatAutorizacionLimites.aspx b/Ventas/CatAutorizacionLimites.aspx index 905fde3d2..ea70c8c36 100644 --- a/Ventas/CatAutorizacionLimites.aspx +++ b/Ventas/CatAutorizacionLimites.aspx @@ -48,6 +48,7 @@
  • Cliente: +
  • Vendedor: @@ -73,6 +74,7 @@ + @@ -141,12 +143,23 @@ <%----%> - + - +
  • +
    + +
    + + + + + + +
    +
    @@ -7322,12 +7323,13 @@
    -
    -
    - " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    +
    +
    -
    +
    +
    +
    @@ -7359,19 +7361,37 @@
    - <%--
    -
    - - - - - - -
    Saldo Maximo Utilizable.: -   -
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    -
    --%> +
    @@ -7566,6 +7586,17 @@
    +
    + +
    + + + + + + +
    +
    @@ -7737,6 +7768,74 @@ } + } + + function CalculaSaldoRNCChkDetalleBonificacion(TxtCantidad, CantidadPendiente, ImporteTotal, Chk) { + //ImportesRNCCargo + let Importe = 0; + if (Chk.checked) { + let SaldoMaximoUtilizable = 999999999; + let ImportesAsignados = 0; + + $('.ImportesRNCDetalleBonificacion').each(function () { + + if (Chk.id != $(this).find("td").eq(0).find(":checkbox").attr('id')) { + let seleccionado = $(this).find("td").eq(0).find(":checkbox").is(':checked'); + + if (seleccionado) { + let cantidad = ToDouble($(this).find("td").eq(1).find(":text").val()); + let porcentajeIVA = ToDouble($(this).find("td").eq(0).find(":hidden").val()); + let precio = ToDouble($(this).find("td").eq(5).find(":hidden").val()); + + let totalcalculableImpuestos = (cantidad * precio); + let iva = ToDouble((totalcalculableImpuestos * porcentajeIVA).toFixed(2)); + + ImportesAsignados += totalcalculableImpuestos + iva; + } + } + + }); + + Importe = SaldoMaximoUtilizable - ImportesAsignados; + + if (Importe > 0) { + + } else { + if (SaldoMaximoUtilizable > 0) { + Importe = 0; + Chk.checked = false; + } else { + Importe = 0; + } + } + + } else { + Importe = 0; + } + + Importe = ToDouble(Importe.toFixed(2)); + + if (Importe > 0) { + + let pu = (ImporteTotal / CantidadPendiente); + + if (pu > 0) { + const cantidadSugerida = (Importe / pu); + if (cantidadSugerida > CantidadPendiente) { + TxtCantidad.value = CantidadPendiente.toString(); + }else { + TxtCantidad.value = cantidadSugerida.toString(); + } + + }else { + TxtCantidad.value = "0"; + } + + }else { + TxtCantidad.value = "0"; + } + + } function LimitaSaldoRNCChk(TxtImporte, Saldo) { diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 71af12c8d..b7f318e2b 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -160,6 +160,25 @@ Partial Class Ventas ViewState("TmpDTRNCDetalleSelecciondas") = value End Set End Property + + Private Property TmpDTRNCBonificacionDetalle As DataTable + Get + Return If(IsNothing(ViewState("TmpDTRNCBonificacionDetalle")), Nothing, CType(ViewState("TmpDTRNCBonificacionDetalle"), DataTable)) + End Get + Set(value As DataTable) + ViewState("TmpDTRNCBonificacionDetalle") = value + End Set + End Property + + Private Property TmpDTRNCBonificacionDetalleSeleccionadas As DataTable + Get + Return If(IsNothing(ViewState("TmpDTRNCBonificacionDetalleSeleccionadas")), Nothing, CType(ViewState("TmpDTRNCBonificacionDetalleSeleccionadas"), DataTable)) + End Get + Set(value As DataTable) + ViewState("TmpDTRNCBonificacionDetalleSeleccionadas") = value + End Set + End Property + Private Property TmpDTError As DataTable Get Return If(IsNothing(ViewState("TmpDTError")), Nothing, CType(ViewState("TmpDTError"), DataTable)) @@ -1839,6 +1858,15 @@ Partial Class Ventas ViewState("TieneDiasVencidos") = value End Set End Property + + Private Property DiasVencidosCliente As Integer + Get + Return IfNull(ViewState("DiasVencidosCliente"), "0", ViewState("DiasVencidosCliente")).ToString().ToEntero() + End Get + Set(value As Integer) + ViewState("DiasVencidosCliente") = value + End Set + End Property Private Property VentaSaldoAlmacen As Decimal Get Return ViewState("VentaSaldoAlmacen").ToString().ToDecimal @@ -1923,6 +1951,14 @@ Partial Class Ventas ViewState("AplicaRNCXDetalle") = value End Set End Property + Private Property AplicaRNCBonificacionXDetalle As Boolean + Get + Return CBool(IfNull(ViewState("AplicaRNCBonificacionXDetalle"), "False", ViewState("AplicaRNCBonificacionXDetalle"))) + End Get + Set(value As Boolean) + ViewState("AplicaRNCBonificacionXDetalle") = value + End Set + End Property Private Property AplicaRelacionManual As Boolean Get Return CBool(IfNull(ViewState("AplicaRelacionManual"), "False", ViewState("AplicaRelacionManual"))) @@ -5518,6 +5554,7 @@ Partial Class Ventas ClienteEsDistribuidor = Boolean.Parse(ObjCliente.DtResultados.Rows(0)("EsDistribuidor").ToString()) TieneDiasVencidos = Boolean.Parse(ObjCliente.DtResultados.Rows(0)("TieneDiasVencidos").ToString()) + DiasVencidosCliente = ObjCliente.DtResultados.Rows(0)("DiasVencidosCliente").ToString().ToEntero() If EstatusCliente = False And Not DdlTipoComprobante.SelectedValue.Contiene("Cot", "DPe") And (CveVenta <= 0 Or EsCreaApartirDe) Then Alert("El Cliente seleccionado no esta activo", TipoMensaje.MsgAdvertencia) @@ -5926,7 +5963,7 @@ Partial Class Ventas DivVentasUsados.Visible = True Dim ObjClientes As New ClsClientes - If ObjClientes.GetHistorialVentas(CveCliente, CveClienteSucursal:=-1, TipoDocto:="Ing", CveEstatusFactura:=-1, FechaI:=Now.AddMonths(-1)) Then + If ObjClientes.GetHistorialVentas(CveCliente, CveClienteSucursal:=-1, TipoDocto:="Ing", CveEstatusFactura:=-1) Then DdlVentaUsado.DataSource = ObjClientes.DtResultados.FiltraParametros("UsadoMarcado = 0") End If ObjClientes.Dispose() @@ -7809,6 +7846,7 @@ Partial Class Ventas Dim TipoDocumentoAutorizacion As String = "" Dim ImporteAutorizacion As Decimal = 0 Dim TipoAutorizacion As Integer = 0 + Dim DiasVencidosAutorizacion As Integer = 0 Dim CveVendedor As Integer = DdlVendedor.SelectedValue.ToEntero() Dim ObjVentas As New ClsVentas Try @@ -7826,6 +7864,7 @@ Partial Class Ventas ImporteAutorizacion = RowAutorizacion("Importe").ToString().ToDecimal() CveAutorizacion = RowAutorizacion("CveAutorizacion").ToString().ToEntero() TipoAutorizacion = RowAutorizacion("TipoAutorizacion").ToString().ToEntero() + DiasVencidosAutorizacion = RowAutorizacion("DiasVencidos").ToString().ToEntero() End If End If @@ -7849,6 +7888,14 @@ Partial Class Ventas End If End If + 'If TipoAutorizacion = 2 Then + ' If DiasVencidosCliente > DiasVencidosAutorizacion Then + ' CveAutorizacion = -1 + ' Alert($"El crédito no esta autorizado. Los días vencidos del cliente son mayores a lo autorizado", TipoMensaje.MsgAdvertencia) + ' Exit Sub + ' End If + 'End If + 'SI NO SE ENCONTRO NINGUA AUTORIZACION If TipoAutorizacion = 0 Then If TieneDiasVencidos Then @@ -16601,7 +16648,7 @@ Partial Class Ventas Private Function CalcularDescuentos(CvePS As Integer, Cantidad As Decimal, PU As Decimal) As Descuentos Dim Descuento As Decimal = HdnDescuento.Value.ToDecimal - If UsuarioActual.Empresa.Funcionalidad(572) = "1" AndAlso Not TbDescuentosRNC.Visible Then + If UsuarioActual.Empresa.Funcionalidad(572) = "1" AndAlso UsuarioActual.TienePermisoProceso(328) AndAlso Not TbDescuentosRNC.Visible Then TbDescuentosRNC.Visible = True End If @@ -18058,10 +18105,10 @@ Partial Class Ventas TotalSubTotalRef = TotalSubTotal - TotalDescuentos End If - If TotalAmortizacion > 0 AndAlso TotalSubTotalRef = TotalAmortizacion Then ' si se amortizó completa la factura, debe de limpiar los impuestos + If TotalAmortizacion > 0 AndAlso TotalSubTotalRef = TotalAmortizacion Then ' si se amortizó completa la factura, debe de limpiar los impuestos PorcentajeRetIVA If DdlTipoAmortizacionAnticipo.SelectedValue.Contiene("3") Then For Each dr As DataRow In TmpDT.Rows - dr("ImporteIVA") = 0 : dr("ImporteIEPS") = 0 : dr("ImporteRetIVA") = 0 : dr("ImporteRetISR") = 0 : dr("PorcentajeIVA") = 0 : dr("IVA") = 0 + dr("ImporteIVA") = 0 : dr("ImporteIEPS") = 0 : dr("PorcentajeIEPS") = 0 : dr("ImporteRetIVA") = 0 : dr("PorcentajeRetIVA") = 0 : dr("ImporteRetISR") = 0 : dr("PorcentajeIVA") = 0 : dr("IVA") = 0 Next If TmpDTImpuestos IsNot Nothing Then @@ -24983,8 +25030,12 @@ Partial Class Ventas End Sub Private Sub CargaCxC() + Dim CveClienteSucursal As Integer = -1 + If DdlSucursalCliente.SelectedValue.ToEntero() > 0 Then + CveClienteSucursal = DdlSucursalCliente.SelectedValue.ToEntero() + End If Dim ObjMovtos As New ClsMovimientos() - If ObjMovtos.GetCxCClienteDetalle(ViewState("CveCliente").ToString().ToEntero(), "-1", "-1", -1, -1, UsuarioActual.CveEmpresa, DdlSucursalCliente.SelectedValue.ToEntero()) Then + If ObjMovtos.GetCxCClienteDetalle(ViewState("CveCliente").ToString().ToEntero(), "-1", "-1", -1, -1, UsuarioActual.CveEmpresa, CveClienteSucursal:=CveClienteSucursal) Then Dim DtTemporal As DataTable = ObjMovtos.DtResultados.FiltraParametros("TipoDocto NOT IN ('RNC','Rem') AND Tipo = 'Act' AND CveVenta > 0", "Moneda, OrdenVencimiento, FechaVencimiento") GvCxC.DataSource = DtTemporal End If @@ -25036,7 +25087,16 @@ Partial Class Ventas Case "2" 'BONIFICACIONES DivRNCCargoDesc.Visible = False DivRNCBonDesc.Visible = True - CargaRNCDesc(True, False) + If ChkMostarProductosRNCDesBonificacion.Checked Then + DivRNCBonDescTotal.Visible = False + DivRNCBonDescDetalle.Visible = True + CargaRNCDetalleDescBonificacion() + Else + DivRNCBonDescTotal.Visible = True + DivRNCBonDescDetalle.Visible = False + CargaRNCDesc(True, False) + End If + Case "3" 'AJUSTE/GARANTIAS LtlCargoDesc.Text = "AJUSTES/GARANTIAS" DivRNCCargoDesc.Visible = True @@ -25073,6 +25133,13 @@ Partial Class Ventas UpModalRemisionesNC.Update() End Sub + + Protected Sub ChkMostarProductosRNCDesBonificacion_CheckedChanged(sender As Object, e As EventArgs) + + RblRNCTipoDesc_SelectedIndexChanged(RblRNCTipo, EventArgs.Empty) + + UpModalRemisionesNC.Update() + End Sub Private Sub CargaRNC(Optional CveVentaUsado As Integer = -1, Optional CargarBonificaciones As Boolean = False, Optional CargarSoloGarantias As Boolean = False) Dim DtNC As DataTable = Nothing @@ -25273,6 +25340,37 @@ Partial Class Ventas UpDescNC.Update() End Sub + Private Sub CargaRNCDetalleDescBonificacion() + Dim DtNC As DataTable = Nothing + + Dim ObjMovtos As New ClsMovimientos() + If ObjMovtos.GetRemisionesNCCliente(CveCliente, True, CveMoneda:=-1, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero()) Then + Me.TmpDTRNCBonificacionDetalle = ObjMovtos.DtResultados.Copy() + End If + ObjMovtos.Dispose() + + Me.TmpDTRNCBonificacionDetalle.Columns.Add(New DataColumn("CveVentaDetalleNCGenerada", GetType(Integer))) + + Me.TmpDTRNCBonificacionDetalleSeleccionadas = Nothing + Me.TmpDTRNCBonificacionDetalleSeleccionadas = TmpDTRNCBonificacionDetalle.Clone() + Me.TmpDTRNCBonificacionDetalleSeleccionadas.Clear() + + GvDescNCBonDetalle.DataSource = TmpDTRNCBonificacionDetalle.FiltraParametros("TipoRNC = 2") + GvDescNCBonDetalle.DataBind() + + 'Dim SaldoMaximoUsados As Decimal = Me.TmpDT.SUM("Total", "EsCargo = True").ToDecimal() + Me.TmpDT.SUM("ImporteIVA", "EsCargo = True").ToDecimal() + + 'If SaldoMaximoUsados > 0 Then + ' HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString() + ' LblSaldoMaximoUsados.Text = String.Format("{0:N2}", SaldoMaximoUsados) + 'Else + ' HdnSaldoMaximoUsados.Value = "0" + ' LblSaldoMaximoUsados.Text = "0" + 'End If + + UpDescNC.Update() + End Sub + Private Sub CargaBonificaciones(CveVentaRNCCargo As Integer, AplicarRNC As Boolean) If TmpDTRNCBonificacionesSeleccionadas Is Nothing Then TmpDTRNCBonificacionesSeleccionadas = Me.TmpDTRNCBonificacionesCliente.Clone() @@ -25391,110 +25489,99 @@ Partial Class Ventas Private Sub CargaBonificacionesDesc(CvesVentaRNCCargo As String, AplicarRNC As Boolean) - If TmpDTRNCBonificacionesSeleccionadas Is Nothing Then - TmpDTRNCBonificacionesSeleccionadas = Me.TmpDTRNCBonificacionesCliente.Clone() + + If ChkMostarProductosRNCDesBonificacion.Checked Then + DivRNCBonDescTotal.Visible = False + DivRNCBonDescDetalle.Visible = True + CargaRNCDetalleDescBonificacion() Else - TmpDTRNCBonificacionesSeleccionadas.Clear() - End If + DivRNCBonDescTotal.Visible = True + DivRNCBonDescDetalle.Visible = False - Dim ListaVentasRNCCargos As String() = {} + If TmpDTRNCBonificacionesSeleccionadas Is Nothing Then + TmpDTRNCBonificacionesSeleccionadas = Me.TmpDTRNCBonificacionesCliente.Clone() + Else + TmpDTRNCBonificacionesSeleccionadas.Clear() + End If - If CvesVentaRNCCargo <> "-1" OrElse Not String.IsNullOrEmpty(CvesVentaRNCCargo) Then - ListaVentasRNCCargos = CvesVentaRNCCargo.Split(","c) - End If + Dim ListaVentasRNCCargos As String() = {} - Dim ListaBon As New List(Of VentasBonificaciones) - Dim DtBon As DataTable = Nothing - Dim SbFiltro As New StringBuilder() - SbFiltro.Append("CveVenta IN(") + If CvesVentaRNCCargo <> "-1" OrElse Not String.IsNullOrEmpty(CvesVentaRNCCargo) Then + ListaVentasRNCCargos = CvesVentaRNCCargo.Split(","c) + End If - Using ObjAcum As New ClsAcumuladores - For Each CveVentaRNC As String In ListaVentasRNCCargos - If ObjAcum.DistribuidorMovtosGet(CveCliente, UsuarioActual.CveEmpresa, CveVentaRNCCargo:=CveVentaRNC.ToEntero()) Then - Dim DtDist = ObjAcum.DtResultados.Copy() + Dim ListaBon As New List(Of VentasBonificaciones) + Dim DtBon As DataTable = Nothing + Dim SbFiltro As New StringBuilder() + SbFiltro.Append("CveVenta IN(") - If DtBon Is Nothing Then - DtBon = DtDist.Clone() + Using ObjAcum As New ClsAcumuladores + For Each CveVentaRNC As String In ListaVentasRNCCargos + If ObjAcum.DistribuidorMovtosGet(CveCliente, UsuarioActual.CveEmpresa, CveVentaRNCCargo:=CveVentaRNC.ToEntero()) Then + Dim DtDist = ObjAcum.DtResultados.Copy() + + If DtBon Is Nothing Then + DtBon = DtDist.Clone() + End If + + DtBon.Merge(DtDist) End If + Next + End Using - DtBon.Merge(DtDist) - End If - Next - End Using + If DtBon IsNot Nothing Then + Dim queryBonificacion = From dr In DtBon + Group By CveVentaBonificacion = dr("CveVentaBonificacion").ToString().ToEntero, CveVentaRNCCargo = dr("CveVentaRNCCargo").ToString().ToEntero + Into x = Group + Select New With { + .CveVentaRNCCargo = CveVentaRNCCargo, + .CveVentaBonificacion = CveVentaBonificacion, + .ImporteBonificacion = x.Sum(Function(s) s("ImporteBonificacion").ToString().ToDecimal), + .IVABonificacion = x.Sum(Function(s) s("IVABonificacion").ToString().ToDecimal) + } - If DtBon IsNot Nothing Then - Dim queryBonificacion = From dr In DtBon - Group By CveVentaBonificacion = dr("CveVentaBonificacion").ToString().ToEntero, CveVentaRNCCargo = dr("CveVentaRNCCargo").ToString().ToEntero - Into x = Group - Select New With { - .CveVentaRNCCargo = CveVentaRNCCargo, - .CveVentaBonificacion = CveVentaBonificacion, - .ImporteBonificacion = x.Sum(Function(s) s("ImporteBonificacion").ToString().ToDecimal), - .IVABonificacion = x.Sum(Function(s) s("IVABonificacion").ToString().ToDecimal) - } + For Each bon In queryBonificacion + SbFiltro.AppendFormat("'{0}',", bon.CveVentaBonificacion) + ListaBon.Add(New VentasBonificaciones() With {.CveVentaRNCCargo = bon.CveVentaRNCCargo, .CveVentaBonificacion = bon.CveVentaBonificacion, .ImporteBonificacion = bon.ImporteBonificacion, .IVABonificacion = bon.IVABonificacion}) + Next - For Each bon In queryBonificacion - SbFiltro.AppendFormat("'{0}',", bon.CveVentaBonificacion) - ListaBon.Add(New VentasBonificaciones() With {.CveVentaRNCCargo = bon.CveVentaRNCCargo, .CveVentaBonificacion = bon.CveVentaBonificacion, .ImporteBonificacion = bon.ImporteBonificacion, .IVABonificacion = bon.IVABonificacion}) - Next + SbFiltro.Remove(SbFiltro.Length - 1, 1) + SbFiltro.Append(")") + End If - SbFiltro.Remove(SbFiltro.Length - 1, 1) - SbFiltro.Append(")") - End If + If ListaBon.Count > 0 Then + Dim Bonificaciones = Me.TmpDTRNCBonificacionesCliente.Select(SbFiltro.ToString()) - If ListaBon.Count > 0 Then - Dim Bonificaciones = Me.TmpDTRNCBonificacionesCliente.Select(SbFiltro.ToString()) + For Each RowBonificacion As DataRow In Bonificaciones + Dim RNCBonificacion = ListaBon.Where(Function(x) x.CveVentaBonificacion = RowBonificacion("CveVenta").ToString().ToEntero()) - For Each RowBonificacion As DataRow In Bonificaciones - Dim RNCBonificacion = ListaBon.Where(Function(x) x.CveVentaBonificacion = RowBonificacion("CveVenta").ToString().ToEntero()) + RowBonificacion("ImporteBonificacion") = RNCBonificacion.Sum(Function(x) x.ImporteBonificacion) + RowBonificacion("IVABonificacion") = RNCBonificacion.Sum(Function(x) x.IVABonificacion) + RowBonificacion("CveVentaRNCCargo") = RNCBonificacion(0).CveVentaRNCCargo - RowBonificacion("ImporteBonificacion") = RNCBonificacion.Sum(Function(x) x.ImporteBonificacion) - RowBonificacion("IVABonificacion") = RNCBonificacion.Sum(Function(x) x.IVABonificacion) - RowBonificacion("CveVentaRNCCargo") = RNCBonificacion(0).CveVentaRNCCargo + If AplicarRNC Then + TmpDTRNCBonificacionesSeleccionadas.Rows.Add(RowBonificacion.ItemArray) + Else + For Each RowEliminar In Me.TmpDTRNCBonificacionesSeleccionadas.Select(SbFiltro.ToString()) + RowEliminar.Delete() + Next + End If + Next - If AplicarRNC Then - TmpDTRNCBonificacionesSeleccionadas.Rows.Add(RowBonificacion.ItemArray) - Else - For Each RowEliminar In Me.TmpDTRNCBonificacionesSeleccionadas.Select(SbFiltro.ToString()) - RowEliminar.Delete() - Next - End If - Next + End If + + 'VERIFICA SI TIENE BONIFICACIONES PARA AGREGARLAS + If TmpDTRNCBonificacionesSeleccionadas IsNot Nothing AndAlso TmpDTRNCBonificacionesSeleccionadas.Rows.Count > 0 Then + DivRNCBonDesc.Visible = True + Else + DivRNCBonDesc.Visible = False + End If + + GvDescNCBonificaciones.DataSource = TmpDTRNCBonificacionesSeleccionadas + GvDescNCBonificaciones.DataBind() End If - 'VERIFICA SI TIENE BONIFICACIONES PARA AGREGARLAS - If TmpDTRNCBonificacionesSeleccionadas IsNot Nothing AndAlso TmpDTRNCBonificacionesSeleccionadas.Rows.Count > 0 Then - DivRNCBonDesc.Visible = True - Else - DivRNCBonDesc.Visible = False - End If - - GvDescNCBonificaciones.DataSource = TmpDTRNCBonificacionesSeleccionadas - GvDescNCBonificaciones.DataBind() - - 'SI ES CREDITO - 'If RBLPago.SelectedValue = "1" Then - ' Dim ImporteUsados As Decimal = Me.TmpDTRNCBonificacionesSeleccionadas.SUM("ImporteBonificacion").ToDecimal() + Me.TmpDTRNCBonificacionesSeleccionadas.SUM("IVABonificacion").ToDecimal() - ' HdnSMUBonDesc.Value = ImporteUsados.ToString() - ' LblSaldoMaximoBonificacion.Text = String.Format("{0:N2}", ImporteUsados) - ' 'SI ES CONTADO - 'ElseIf RBLPago.SelectedValue = "2" Then - ' Dim ImporteUsados As Decimal = 0 - - ' For Each Row As DataRow In Me.TmpDT.FiltraParametros("EsCargo = True").Rows - ' Dim PUBonificacion As Decimal = GlobalDTAcumTamaños().FiltroPrimeroValor("Bonificacion", $"CvePSCargo={Row("CvePS")}").ToDecimal() - - ' Dim TotalBonificacion As Decimal = (Row("Cantidad").ToString().ToDecimal() * PUBonificacion) - ' Dim IVABonificacion As Decimal = (TotalBonificacion * Row("PorcentajeIVA").ToString().ToDecimal()).RoundSQL(2) - - ' ImporteUsados += TotalBonificacion + IVABonificacion - ' Next - ' HdnSMUBonDesc.Value = ImporteUsados.ToString() - ' LblSaldoMaximoBonificacion.Text = String.Format("{0:N2}", ImporteUsados) - - 'End If - UpDescNC.Update() End Sub @@ -25520,6 +25607,22 @@ Partial Class Ventas End If End If End Sub + + Protected Sub GvDescNCBonDetalle_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDescNCBonDetalle.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 + Else + e.Row.CssClass = "ImportesRNCDetalle" + e.Row.FCCheckBox("ChkAplicar").Attributes.Add("onclick", $"CalculaSaldoRNCChkDetalleBonificacion({e.Row.FCTextBox("TxtCantidadRNC").ClientID},{e.Row.DBCampo("CantidadPendiente").ToDouble},{e.Row.DBCampo("Total").ToDouble}, this);") + 'e.Row.FCTextBox("TxtImporte").Attributes.Add("onkeyup", $"LimitaSaldoRNCChk({e.Row.FCTextBox("TxtImporte").ClientID},{e.Row.DBCampo("Saldo").ToDouble});") + + End If + End If + End Sub Protected Sub GvRNCDevoluciones_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvRNCDevoluciones.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then e.Row.FCCheckBox("ChkAplicar").Attributes.Add("onclick", $"CalculaSaldoRNCBonChkDesc({e.Row.FCTextBox("TxtImporte").ClientID},{e.Row.DBCampo("Saldo").ToDouble}, this);") @@ -25848,13 +25951,21 @@ Partial Class Ventas NCBonificacion = ArrayNC(4).ToEntero() End If + Dim DrBonRef As DataRow = Nothing + 'EN LA NC DE BONIFICACION EL CONCEPTO DEBE SER SIEMPRE 'BONIFICACION POR USADO' Dim DrPSBonificacion = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=NCBonificacion).FiltroPrimero("") If DrPSBonificacion IsNot Nothing Then - CrearDTNCBonificacionDesc(DtImpuestosBonificacion, TmpDTDescNC, DrPSBonificacion, CveProyecto, Proyecto, CveSubProyecto, SubProyecto) + DrBonRef = DrPSBonificacion Else + DrBonRef = DrPS Alert("No se encontró el concepto de BONIFICACION POR USADO", TipoMensaje.MsgAdvertencia) - CrearDTNCBonificacionDesc(DtImpuestosBonificacion, TmpDTDescNC, DrPS, CveProyecto, Proyecto, CveSubProyecto, SubProyecto) + End If + + If AplicaRNCBonificacionXDetalle Then + CrearDTNCBonificacionDescDetalle(ListaNCBonificacion, TmpDTDescNC, DrBonRef, CveProyecto, Proyecto, CveSubProyecto, SubProyecto) + Else + CrearDTNCBonificacionDesc(DtImpuestosBonificacion, TmpDTDescNC, DrBonRef, CveProyecto, Proyecto, CveSubProyecto, SubProyecto) End If Else @@ -26313,6 +26424,93 @@ Partial Class Ventas Next End If End Sub + Private Sub CrearDTNCBonificacionDescDetalle(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) + + TmpDTDescNCBonificacion = TmpDTCargo.Clone() + TmpDTDescNCBonificacion.Clear() + + For Each RNC In ListaNC + Dim UltimoRenglonRNC As Integer = 1 + Dim TotalAcumuladoRNC As Decimal = 0 + Dim Terminar As Boolean = False + + For Each RowUsado As DataRow In Me.TmpDTRNCBonificacionDetalleSeleccionadas.FiltraParametros($"CveVenta={RNC.CveVenta}", Orderby:="PU").Rows + + Dim Cantidad As Decimal = RowUsado("Cantidad").ToString().ToDecimal() + + Dim CvePSCargo As Integer = RowUsado("CvePS").ToString().ToEntero() + Dim Obs = "" + 'SI ES ACUMULADOR LAS OBSERVACIOENS DEBEN SER EL NOMBRE DEL ACUMULADOR + If GlobalDTAcumTamaños().FiltroPrimero($"CvePSCargo = {CvePSCargo}") IsNot Nothing Then + Obs = RowUsado("CodigoPS").ToString() + 'Else + ' Obs = RowUsado("Obs").ToString() + End If + + 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 EL IMPORTE ES MAYOR REALIZA EL AJUSTE + If TotalAcumuladoRNC > RNC.TotalRemNCAplicado Then + Terminar = True + 'RESTA LO SUMANDO DEL ACUMULADO + TotalAcumuladoRNC -= (TotalCalculableImpuestos + ImporteIVA + ImporteIEPS - ImporteRetIVA - ImporteRetISR) + + Dim Diferencia As Decimal = RNC.TotalRemNCAplicado - TotalAcumuladoRNC + + Dim TotalPartida As Decimal = (TotalCalculableImpuestos + ImporteIVA + ImporteIEPS - ImporteRetIVA - ImporteRetISR) + + Dim PorcentajePorAplicar As Decimal = (Diferencia / TotalPartida) + + Cantidad = Cantidad * PorcentajePorAplicar + + TotalCalculableImpuestos = (Cantidad * ImportePU) + ImporteIVA = (TotalCalculableImpuestos * RowUsado("PorcentajeIVA").ToString().ToDecimal).RoundSQL(2) + + + ImporteTotal = TotalCalculableImpuestos + + TotalAcumuladoRNC += (TotalCalculableImpuestos + ImporteIVA + ImporteIEPS - ImporteRetIVA - ImporteRetISR) + End If + + 'SI ES EL ULTIMO REGLON REALIZA UN AJUSTE + If UltimoRenglonRNC = Me.TmpDTRNCBonificacionDetalleSeleccionadas.FiltraParametros($"CveVenta={RNC.CveVenta}").Rows.Count OrElse Terminar 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(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, Cantidad, ImportePU, RowUsado("PorcentajeIVA").ToString().ToDecimal, ImporteIVA, 0, ImporteRetIVA, + 0, ImporteRetISR, 0, ImporteIEPS, -1, 0, ImporteTotal, "", "", -1, -1, + DrPS("SATClavePS").ToString(), DrPS("SATClaveUnidadMedida").ToString(), -1, -1, -1, -1, -1, -1, CveVentaDetalleRNC:=RowUsado("CveVentaDetalleRNC").ToString().ToEntero()) + + If Terminar Then + Exit For + End If + Next + + Next + End Sub Private Sub CrearDTNCDevolucion(ListaNC As List(Of Modelos.Factura), ByRef TmpDTCargo As DataTable, CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String) For Each RNC In ListaNC @@ -29811,6 +30009,7 @@ 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 + Me.AplicaRNCBonificacionXDetalle = False If ListaRemisionesNC Is Nothing Then ListaRemisionesNC = New List(Of Modelos.Factura) @@ -30009,6 +30208,7 @@ Partial Class Ventas Protected Sub BtnAplicarDesc_Click(sender As Object, e As EventArgs) Try Me.AplicaRNCXDetalle = False + Me.AplicaRNCBonificacionXDetalle = False Dim DrPS As DataRow = Nothing Dim ArrayNC As String() = UsuarioActual.Empresa.Funcionalidad(591).Split(",".ToCharArray()) @@ -30197,34 +30397,98 @@ Partial Class Ventas Exit Sub End If - For Each GvRow As GridViewRow In GvDescNCBonificaciones.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 + 'BONIFICACIONES + If ChkMostarProductosRNCDesBonificacion.Checked Then - If RemNC.TotalRemNCAplicado <= 0 Then - Alert($"Debe asignar un importe en la siguiente remisión: {RemNC.SerieFolio}", TipoMensaje.MsgAdvertencia) - ListaNCBonificacion.Clear() - Exit Sub + TmpDTRNCBonificacionDetalleSeleccionadas.Clear() + Me.AplicaRNCBonificacionXDetalle = True + + For Each GvRow As GridViewRow In GvDescNCBonDetalle.Rows + If GvRow.RowType = DataControlRowType.DataRow Then + If GvRow.FCCheckBox("ChkAplicar").Checked Then + Dim Rows = TmpDTRNCBonificacionDetalle.Select($"CveVentaDetalleRNC = {GvRow.DataKey("CveVentaDetalleRNC").ToEntero()}") + For Each row In Rows + row("Cantidad") = GvRow.FCTextBox("TxtCantidadRNC").Text.ToDecimal() + + Dim TotalCalculableImpuestos As Decimal = row("Cantidad").ToString().ToDecimal() * row("PU").ToString().ToDecimal() + Dim IVA As Decimal = (TotalCalculableImpuestos * row("PorcentajeIVA").ToString().ToDecimal()).RoundSQL() + + row("IVA") = IVA + row("Total") = (TotalCalculableImpuestos + IVA).RoundSQL + + TmpDTRNCBonificacionDetalleSeleccionadas.Rows.Add(row.ItemArray) + Next End If - - ListaNCBonificacion.Add(RemNC) End If - End If - Next + Next - 'Dim LimiteBonficaciones As Decimal = LblSaldoMaximoBonificacion.Text.Trim().ToDecimal() + Dim TerminarCiclo As Boolean = False - ''VERIFICA EL LIMITE DE LOS USADOS - 'If ListaNCBonificacion.Sum(Function(x) x.TotalRemNCAplicado) > LimiteBonficaciones Then - ' Alert($"La suma de las remisiones de nota de crédito de tipo 'Bonificación' no debe superar el limite.
    Total RNC: {ListaNCBonificacion.Sum(Function(x) x.TotalRemNCAplicado):N2}.
    Total Usados: {LimiteUsados:N2}", TipoMensaje.MsgAdvertencia) - ' ListaNCDesc.Clear() - ' ListaNCBonificacion.Clear() - ' Exit Sub - 'End If + For Each Dr As DataRow In TmpDTRNCBonificacionDetalleSeleccionadas.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 GvDescNCBonDetalle.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 + + If RemNC.CveVentaRNCCargo <= 0 Then + RemNC.CveVentaRNCCargo = GvRow.DataKey("CveVenta").ToEntero() + End If + + End If + + End If + Next + + RemNC.TotalRemNCAplicado = TotalRNC + 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) + + If TerminarCiclo Then + Exit For + End If + Next + + Else + For Each GvRow As GridViewRow In GvDescNCBonificaciones.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 ElseIf RblRNCTipoDesc.SelectedValue.Contiene("2") Then @@ -31094,6 +31358,9 @@ Partial Class Ventas DtVentasNC.Rows.Add(Drt) DtVentasNC.AcceptChanges() + ObjFacturaProntoPago.DtVentasRelacionadas = New DataTable + ObjFacturaProntoPago.DtVentasRelacionadas.Columns.Add("CveVenta", GetType(Integer)) + ObjFacturaProntoPago.DtVentasNC = DtVentasNC Resp = ObjFacturaProntoPago.EmitirFactura(False, Transac:=SqlTransaccion, ObjContPaqTransac:=ObjConta) @@ -31589,8 +31856,17 @@ Partial Class Ventas UpModalSolicitud.Update() End Sub Protected Sub BtnSolicitarCredito_Click(sender As Object, e As EventArgs) Handles BtnSolicitarCredito.Click + Dim DiasVencidos As Integer = 0 + Dim CveEstatus As Integer = 0 + Dim TipoDocto As String = DdlTipoDocto.SelectedValue + Dim CveTipoAutorizacion As Integer = DdlTipoAutorizacion.SelectedValue.ToEntero() + + If CveTipoAutorizacion = 2 Then + DiasVencidos = TxtDiasVencidos.Text.ToEntero() + End If + Dim ObjPS As New ClsVentas - If ObjPS.AddAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, DdlVendedor.SelectedValue.ToEntero(), TxtImporteSolicitud.Text.ToDecimal(), 0, UsuarioActual.CveUsuario, DdlTipoAutorizacion.SelectedValue.ToEntero(), TipoDocumento:=DdlTipoDocto.SelectedValue) Then + If ObjPS.AddAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, DdlVendedor.SelectedValue.ToEntero(), TxtImporteSolicitud.Text.ToDecimal(), CveEstatus, UsuarioActual.CveUsuario, CveTipoAutorizacion, TipoDocumento:=DdlTipoDocto.SelectedValue, DiasVencidos:=DiasVencidos) Then RegistraScript("$('#DivModalSolicitarCredito').modal('hide')") Alert("La autorización se agregó correctamente.", TipoMensaje.MsgInformacion) End If @@ -31599,6 +31875,7 @@ Partial Class Ventas End Sub Protected Sub DdlTipoAutorizacion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoAutorizacion.SelectedIndexChanged DivImporteSolicitud.Visible = DdlTipoAutorizacion.SelectedValue.ToEntero() = 1 + DivDiasVencidos.Visible = DdlTipoAutorizacion.SelectedValue.ToEntero() = 2 UpModalSolicitud.Update() End Sub 'Protected Sub DdlTipoDocto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoDocto.SelectedIndexChanged diff --git a/vwd.webinfo b/vwd.webinfo index a4b7678ae..5384d515a 100644 --- a/vwd.webinfo +++ b/vwd.webinfo @@ -276,6 +276,8 @@ + +