--FIX varios

This commit is contained in:
2025-01-08 17:53:22 -07:00
parent 2c919582cf
commit befcb41bea

View File

@@ -10,7 +10,6 @@ Imports System.Security.Cryptography.X509Certificates
Imports ADSNetLibrary.SIGAPI.Models.CRM.Request Imports ADSNetLibrary.SIGAPI.Models.CRM.Request
Imports ADSNetLibrary.SIGAPI.Services.CRM Imports ADSNetLibrary.SIGAPI.Services.CRM
Imports ADSTimbrado Imports ADSTimbrado
Imports com.itextpdf.text.pdf.languages
Imports Extensiones Imports Extensiones
Imports Microsoft.Reporting.WebForms Imports Microsoft.Reporting.WebForms
Imports Modelos Imports Modelos
@@ -8287,7 +8286,7 @@ Partial Class Ventas
End If End If
'SOLO HABILITAR PARA GENERAR NOTAS DE CREDITO 'SOLO HABILITAR PARA GENERAR NOTAS DE CREDITO
If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso ClienteEsDistribuidor AndAlso Not PermiteCredito AndAlso Not LnkSolicitarCredito.Visible Then If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso Not PermiteCredito AndAlso Not LnkSolicitarCredito.Visible Then
LnkSolicitarCredito.Visible = True LnkSolicitarCredito.Visible = True
If DdlSolCreditoTipoDocto.Items.FindByValue("Ing") IsNot Nothing Then If DdlSolCreditoTipoDocto.Items.FindByValue("Ing") IsNot Nothing Then
@@ -9039,9 +9038,21 @@ Partial Class Ventas
Protected Sub GvPS_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GvPS.RowEditing Protected Sub GvPS_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GvPS.RowEditing
GvPS.EditIndex = e.NewEditIndex GvPS.EditIndex = e.NewEditIndex
GvPS.DataSource = TmpDT GvPS.DataSource = TmpDT
DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2")
GvPS.DataBind() GvPS.DataBind()
If GvPS.Columns(21).Visible Then
For Each GvRow As GridViewRow In GvPS.Rows
If GvRow.RowType = DataControlRowType.Header Then
GvRow.FCLinkButton("LnkOrdenarGvPS").Visible = False
End If
If GvRow.RowType = DataControlRowType.DataRow Then
GvRow.FCTextBox("TxtOrden").Visible = False
End If
Next
End If
If UsuarioActual.TienePermisoProceso(253) Then If UsuarioActual.TienePermisoProceso(253) Then
GvPS.Rows(e.NewEditIndex).FCTextBox("TxtPrecio").Enabled = True GvPS.Rows(e.NewEditIndex).FCTextBox("TxtPrecio").Enabled = True
End If End If
@@ -9128,9 +9139,27 @@ Partial Class Ventas
End Sub End Sub
Protected Sub GvPS_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvPS.RowCancelingEdit Protected Sub GvPS_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvPS.RowCancelingEdit
GvPS.EditIndex = -1 GvPS.EditIndex = -1
GvPS.DataSource = TmpDT
OrdenarPS()
If GvPS.Columns(21).Visible Then
For Each GvRow As GridViewRow In GvPS.Rows
If GvRow.RowType = DataControlRowType.Header Then
GvRow.FCLinkButton("LnkOrdenarGvPS").Visible = True
End If
If GvRow.RowType = DataControlRowType.DataRow Then
GvRow.FCTextBox("TxtOrden").Visible = True
End If
Next
End If
DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2") DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2")
GvPS.DataBind() CargaGVInv(DtInv)
UpPS.Update()
End Sub End Sub
Protected Sub GvPS_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvPS.RowUpdating Protected Sub GvPS_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvPS.RowUpdating
@@ -9203,6 +9232,7 @@ Partial Class Ventas
'eliminar y cargar el ps *** 'eliminar y cargar el ps ***
Dim ConsecutivoActual As Integer = TmpDT.Rows(e.RowIndex)("Consec").ToString().ToEntero() Dim ConsecutivoActual As Integer = TmpDT.Rows(e.RowIndex)("Consec").ToString().ToEntero()
Dim OrdenOriginal As Integer = TmpDT.Rows(e.RowIndex)("Orden").ToString().ToEntero()
If DtPromociones IsNot Nothing AndAlso DtPromociones.Rows.Count > 0 Then If DtPromociones IsNot Nothing AndAlso DtPromociones.Rows.Count > 0 Then
ObjDescuento = CalcularDescuentos(CvePSNuevo, Cantidad, PU) ObjDescuento = CalcularDescuentos(CvePSNuevo, Cantidad, PU)
@@ -9261,14 +9291,14 @@ Partial Class Ventas
CveProyecto, Proyecto, CveProyecto, Proyecto,
CveSubProyecto, SubProyecto, CveSubProyecto, SubProyecto,
CuentaPredial:=CuentaPredial, CveVentaDetalle:=GvPS.Rows(e.RowIndex).DataKey("CveVentaDetalle").ToString().ToEntero(), SeActualiza:=True, CvePromocionDetalle:=ObjDescuento.CvePromocionDetalle, CuentaPredial:=CuentaPredial, CveVentaDetalle:=GvPS.Rows(e.RowIndex).DataKey("CveVentaDetalle").ToString().ToEntero(), SeActualiza:=True, CvePromocionDetalle:=ObjDescuento.CvePromocionDetalle,
ObjDescuento:=ObjDescuento, NumTurnos:=NumTurnos, CvePrecioLista:=CvePrecioLista, PrecioLista:=PrecioLista, ConsecutivoManual:=ConsecutivoActual) ObjDescuento:=ObjDescuento, NumTurnos:=NumTurnos, CvePrecioLista:=CvePrecioLista, PrecioLista:=PrecioLista, ConsecutivoManual:=ConsecutivoActual, OrdenManual:=OrdenOriginal)
' TmpDT.Rows(e.RowIndex)("CveUM") = Ddl.SelectedValue ' TmpDT.Rows(e.RowIndex)("CveUM") = Ddl.SelectedValue
' TmpDT.Rows(e.RowIndex)("UM") = Ddl.SelectedItem.Text ' TmpDT.Rows(e.RowIndex)("UM") = Ddl.SelectedItem.Text
GvPS.EditIndex = -1 GvPS.EditIndex = -1
GvPS.DataSource = TmpDT OrdenarPS(False)
DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2") DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2")
GvPS.DataBind()
CargaGVInv(DtInv) CargaGVInv(DtInv)
If UsuarioActual.Empresa.Funcionalidad(533).ToEntero() > 0 Then If UsuarioActual.Empresa.Funcionalidad(533).ToEntero() > 0 Then
@@ -9399,13 +9429,13 @@ Partial Class Ventas
CalculaPSPromocionFiltrosLubricantes(TmpDT.Rows(e.RowIndex)) CalculaPSPromocionFiltrosLubricantes(TmpDT.Rows(e.RowIndex))
DrPS = Nothing DrPS = Nothing
GvPS.EditIndex = -1 GvPS.EditIndex = -1
GvPS.DataSource = TmpDT OrdenarPS(False)
DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2") DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2")
GvPS.DataBind()
CargaGVInv(DtInv) CargaGVInv(DtInv)
CalculaUsados() CalculaUsados()
End If End If
@@ -9425,6 +9455,18 @@ Partial Class Ventas
'JJMQ 20160506: Se agrego para la validacion de pago de contado. 'JJMQ 20160506: Se agrego para la validacion de pago de contado.
'CVImporteContado.ValueToCompare = TxtTotal.Text.Replace(",", "") 'CVImporteContado.ValueToCompare = TxtTotal.Text.Replace(",", "")
If GvPS.Columns(21).Visible Then
For Each GvRow As GridViewRow In GvPS.Rows
If GvRow.RowType = DataControlRowType.Header Then
GvRow.FCLinkButton("LnkOrdenarGvPS").Visible = True
End If
If GvRow.RowType = DataControlRowType.DataRow Then
GvRow.FCTextBox("TxtOrden").Visible = True
End If
Next
End If
UpPS.Update() UpPS.Update()
UpContado.Update() UpContado.Update()
@@ -20113,6 +20155,8 @@ Partial Class Ventas
TxtCantidad.Text = "1" TxtCantidad.Text = "1"
End If End If
OrdenarPS()
UpPS.Update() UpPS.Update()
Catch ex As Exception Catch ex As Exception
OnError("Ocurrió un error al agregar el producto", ex) OnError("Ocurrió un error al agregar el producto", ex)
@@ -20358,7 +20402,7 @@ Partial Class Ventas
Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0, Optional SeActualiza As Boolean = False, Optional CvePromocionDetalle As Integer = -1, Optional EsCargo As Boolean = False, Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0, Optional SeActualiza As Boolean = False, Optional CvePromocionDetalle As Integer = -1, Optional EsCargo As Boolean = False,
Optional ImporteProntoPago As Decimal = 0, Optional ByRef ObjDescuento As Modelos.VentaDescuentos = Nothing, Optional CvePrecioLista As Integer = -1, Optional PrecioLista As String = "", Optional ImporteProntoPago As Decimal = 0, Optional ByRef ObjDescuento As Modelos.VentaDescuentos = Nothing, Optional CvePrecioLista As Integer = -1, Optional PrecioLista As String = "",
Optional CveActivoFijo As Integer = -1, Optional AFDepreciacion As Decimal = 0D, Optional AFValorInicial As Decimal = 0D, Optional NumTurnos As Decimal = 0D, Optional CantidadConversion As Decimal = 0, Optional CveActivoFijo As Integer = -1, Optional AFDepreciacion As Decimal = 0D, Optional AFValorInicial As Decimal = 0D, Optional NumTurnos As Decimal = 0D, Optional CantidadConversion As Decimal = 0,
Optional Costo As Decimal = 0, Optional PorcentajeIVAFijo As Decimal = -1, Optional ConsecutivoManual As Integer = 0) As Boolean Optional Costo As Decimal = 0, Optional PorcentajeIVAFijo As Decimal = -1, Optional ConsecutivoManual As Integer = 0, Optional OrdenManual As Integer = 0) As Boolean
Dim Retorno As Boolean = False Dim Retorno As Boolean = False
Try Try
@@ -20402,17 +20446,17 @@ Partial Class Ventas
Row("Serie") = Serie Row("Serie") = Serie
Row("TiempoEntrega") = TiempoEntrega Row("TiempoEntrega") = TiempoEntrega
If ConsecutivoManual > 0 Then If OrdenManual > 0 Then
Row("Orden") = ConsecutivoManual Row("Orden") = OrdenManual
Else Else
If Modalidad = "U" Then If Modalidad = "U" Then
Row("Orden") = Index Row("Orden") = Index
Else Else
Dim ConsecutivoActual As Integer = TmpDT.MAX("Consec").ToEntero() Dim OrdenActual As Integer = TmpDT.MAX("Orden").ToEntero()
If ConsecutivoActual < 0 Then If OrdenActual < 0 Then
ConsecutivoActual = 0 OrdenActual = 0
End If End If
Row("Orden") = ConsecutivoActual + 1 Row("Orden") = OrdenActual + 1
End If End If
End If End If
@@ -21328,7 +21372,7 @@ Partial Class Ventas
ConfiguraTipoDocto() ConfiguraTipoDocto()
End If End If
End Sub End Sub
Private Sub CalculaTotalesVenta(Optional RecalculaImpuestosLocales As Boolean = True, Optional NCDescuento As Boolean = False, Optional ValidarDescuentos As Boolean = False, Optional RecalcularTotalOriginal As Boolean = True) Private Sub CalculaTotalesVenta(Optional RecalculaImpuestosLocales As Boolean = True, Optional NCDescuento As Boolean = False, Optional ValidarDescuentos As Boolean = False, Optional RecalcularTotalOriginal As Boolean = True, Optional Reordenar As Boolean = False)
Dim TotalSubTotal As Decimal = TmpDT.SUMD("TotalImporte") Dim TotalSubTotal As Decimal = TmpDT.SUMD("TotalImporte")
Dim TotalSubTotalRef As Decimal = TotalSubTotal Dim TotalSubTotalRef As Decimal = TotalSubTotal
@@ -21454,11 +21498,15 @@ Partial Class Ventas
Alert($"Los siguientes conceptos hace falta especificar clave SAT <br/><br/> {MensajeCveSAT.ToString()}", TipoMensaje.MsgAdvertencia) Alert($"Los siguientes conceptos hace falta especificar clave SAT <br/><br/> {MensajeCveSAT.ToString()}", TipoMensaje.MsgAdvertencia)
MensajeCveSAT.Clear() MensajeCveSAT.Clear()
End If End If
If Reordenar Then
Dim view As DataView = New DataView(TmpDT) Dim view As DataView = New DataView(TmpDT)
view.Sort = "Consec" view.Sort = "Orden"
GvPS.DataSource = view GvPS.DataSource = view
GvPS.DataBind() GvPS.DataBind()
Else
GvPS.DataSource = TmpDT
GvPS.DataBind()
End If
'RECARGA GV INVENTARIO 'RECARGA GV INVENTARIO
If (Not CveVenta > 0 Or DdlTipoComprobante.SelectedValue = "Cot") OrElse (UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso EsCreaApartirDe) Then If (Not CveVenta > 0 Or DdlTipoComprobante.SelectedValue = "Cot") OrElse (UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso EsCreaApartirDe) Then
@@ -23888,6 +23936,12 @@ Partial Class Ventas
LiCalcularPromociones.Visible = True LiCalcularPromociones.Visible = True
End If End If
'NO PERMITE EDITAR FECHA DEL PAGO
If Not UsuarioActual.TienePermisoProceso(260) Then
TxtFechaPago.Enabled = False
imgCalendario.Visible = False
End If
TxtAtencionA.Enabled = True TxtAtencionA.Enabled = True
UpCliente.Update() UpCliente.Update()
@@ -26322,22 +26376,34 @@ Partial Class Ventas
DdlPS_SelectedIndexChanged(Nothing, Nothing) DdlPS_SelectedIndexChanged(Nothing, Nothing)
End If End If
End Sub End Sub
Protected Sub OrdenarGvPS(ByVal sender As Object, ByVal e As EventArgs)
For Each row As GridViewRow In GvPS.Rows Private Sub OrdenarPS(Optional Reeordenar As Boolean = True)
TmpDT.Rows(row.RowIndex)("Orden") = row.FCTextBox("TxtOrden").Text.ToEntero()
Next
Dim resultados = From OrdenDT In TmpDT If Reeordenar Then
Order By OrdenDT("Orden").ToString().ToEntero() For Each row As GridViewRow In GvPS.Rows
Select OrdenDT TmpDT.Rows(row.RowIndex)("Orden") = row.FCTextBox("TxtOrden").Text.ToEntero()
TmpDT = resultados.CopyToDataTable Next
CalculaTotalesVenta()
TmpDT.AcceptChanges()
End If
'Dim resultados = From OrdenDT In TmpDT
' Order By OrdenDT("Orden").ToString().ToEntero()
' Select OrdenDT
'TmpDT = resultados.CopyToDataTable
TmpDT = TmpDT.FiltraParametros("", "Orden").Copy()
TmpDT.AcceptChanges()
GvPS.DataSource = TmpDT GvPS.DataSource = TmpDT
GvPS.DataBind() GvPS.DataBind()
UpPS.Update() End Sub
Protected Sub OrdenarGvPS(ByVal sender As Object, ByVal e As EventArgs)
OrdenarPS()
CalculaTotalesVenta()
UpPS.Update()
End Sub End Sub
Private Sub LkCotizacionAutorizar_Click(sender As Object, e As EventArgs) Handles LkCotizacionAutorizar.Click Private Sub LkCotizacionAutorizar_Click(sender As Object, e As EventArgs) Handles LkCotizacionAutorizar.Click
EsSupervisor = True EsSupervisor = True
@@ -33046,6 +33112,12 @@ Partial Class Ventas
LiCalcularPromociones.Visible = True LiCalcularPromociones.Visible = True
End If End If
'NO PERMITE EDITAR FECHA DEL PAGO
If Not UsuarioActual.TienePermisoProceso(260) Then
TxtFechaPago.Enabled = False
imgCalendario.Visible = False
End If
UpPS.Update() UpPS.Update()
UPPDescuento.Update() UPPDescuento.Update()
UPObservaciones.Update() UPObservaciones.Update()
@@ -34885,6 +34957,8 @@ Partial Class Ventas
CargaListasPrecios() CargaListasPrecios()
End If End If
'BloqueaCondicionesPago()
BtnEditar.Visible = False BtnEditar.Visible = False
BtnEmitir.Visible = False BtnEmitir.Visible = False
BtnPermisoEditarCotizacion.Visible = False BtnPermisoEditarCotizacion.Visible = False
@@ -36641,6 +36715,12 @@ Partial Class Ventas
End If End If
End If End If
'NO PERMITE EDITAR FECHA DEL PAGO
If Not UsuarioActual.TienePermisoProceso(260) Then
TxtFechaPago.Enabled = False
imgCalendario.Visible = False
End If
UpCliente.Update() UpCliente.Update()
UpParametros.Update() UpParametros.Update()
UPObservaciones.Update() UPObservaciones.Update()
@@ -39890,7 +39970,7 @@ Partial Class Ventas
RegistraScript("MuestraAnticipos();", "AE") RegistraScript("MuestraAnticipos();", "AE")
End Sub End Sub
Private Sub RecalculaPrecios(ByRef RecalculoPromociones As Boolean, Optional ForzarRecalculo As Boolean = False) Private Sub RecalculaPrecios(ByRef RecalculoPromociones As Boolean, Optional AplicarPromociones As Boolean = False)
Dim PuedeRecalcular As Boolean = False Dim PuedeRecalcular As Boolean = False
If CveVenta <= 0 OrElse EsCreaApartirDe OrElse (ModalidadEdicion AndAlso Not DdlTipoComprobante.SelectedValue = "Cot") Then If CveVenta <= 0 OrElse EsCreaApartirDe OrElse (ModalidadEdicion AndAlso Not DdlTipoComprobante.SelectedValue = "Cot") Then
@@ -39902,7 +39982,7 @@ Partial Class Ventas
PuedeRecalcular = False PuedeRecalcular = False
End If End If
If ForzarRecalculo Then If AplicarPromociones Then
PuedeRecalcular = True PuedeRecalcular = True
End If End If
@@ -39912,7 +39992,18 @@ Partial Class Ventas
Dim CveClasificacion As Integer = Row("CveClasificacion").ToString().ToEntero Dim CveClasificacion As Integer = Row("CveClasificacion").ToString().ToEntero
Dim CvePS As Integer = Row("CvePS").ToString().ToEntero Dim CvePS As Integer = Row("CvePS").ToString().ToEntero
Dim ObjPrecioSugerido As Modelos.MPrecioSugerido = CalculaPrecioSugerido(CvePS, CveClasificacion) Dim CvePrecioListaSugerido As Integer = -1
Dim ObjPrecioSugerido As Modelos.MPrecioSugerido = Nothing
If AplicarPromociones Then
ObjPrecioSugerido = New Modelos.MPrecioSugerido()
ObjPrecioSugerido.PrecioSugerido = Row("PU").ToString().ToDecimal()
ObjPrecioSugerido.CvePrecioLista = Row("CvePrecioLista").ToString().ToEntero()
Else
ObjPrecioSugerido = CalculaPrecioSugerido(CvePS, CveClasificacion)
End If
If ObjPrecioSugerido.PrecioSugerido > 0 Then If ObjPrecioSugerido.PrecioSugerido > 0 Then
Dim PU As Decimal = ObjPrecioSugerido.PrecioSugerido.RoundSQL(6) Dim PU As Decimal = ObjPrecioSugerido.PrecioSugerido.RoundSQL(6)
@@ -39921,6 +40012,11 @@ Partial Class Ventas
PU = ObjDescuento.PU PU = ObjDescuento.PU
End If End If
'SI NO TIENE PROMOCION, NO MODIFICAR NADA
If AplicarPromociones AndAlso ObjDescuento.CvePromocionDetalle <= 0 Then
Continue For
End If
Row("PU") = PU Row("PU") = PU
Dim TotalCalculableImpuestos As Decimal = ((Cantidad * PU) - (ObjDescuento.ImporteDescuento)) Dim TotalCalculableImpuestos As Decimal = ((Cantidad * PU) - (ObjDescuento.ImporteDescuento))
@@ -40387,12 +40483,12 @@ Partial Class Ventas
Protected Sub LnkCalcularPromociones_Click(sender As Object, e As EventArgs) Protected Sub LnkCalcularPromociones_Click(sender As Object, e As EventArgs)
Dim Recalculo As Boolean = False Dim Recalculo As Boolean = False
RecalculaPrecios(Recalculo, ForzarRecalculo:=True) RecalculaPrecios(Recalculo, AplicarPromociones:=True)
If Recalculo Then If Recalculo Then
Alert("Se han recalculado los precios y promociones en base a las condiciones actuales") Alert("Se han recalculado los precios y promociones en base a las condiciones actuales")
Else Else
Alert("No se han encontrado cambios para los precios y promociones") Alert("No se han encontrado cambios para las promociones")
End If End If
End Sub End Sub