Agregando formulario de ajuste
This commit is contained in:
@@ -23,6 +23,14 @@ Partial Class Inventarios_RecepcionUsados
|
||||
ViewState("DtMovimientos") = value
|
||||
End Set
|
||||
End Property
|
||||
Private Property ConsecutivoVenta As Integer
|
||||
Get
|
||||
Return ViewState("ConsecutivoVenta").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("ConsecutivoVenta") = value
|
||||
End Set
|
||||
End Property
|
||||
Public Property DtTamaños() As DataTable
|
||||
Get
|
||||
Return CType(ViewState("DtTamaños"), DataTable)
|
||||
@@ -285,7 +293,22 @@ Partial Class Inventarios_RecepcionUsados
|
||||
ViewState("ObjFactura") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property IndexAjuste As Integer
|
||||
Get
|
||||
Return ViewState("IndexAjuste").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("IndexAjuste") = value
|
||||
End Set
|
||||
End Property
|
||||
Private Property TmpDTAjustes As DataTable
|
||||
Get
|
||||
Return If(IsNothing(ViewState("TmpDTAjustes")), Nothing, CType(ViewState("TmpDTAjustes"), DataTable))
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("TmpDTAjustes") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
#End Region
|
||||
|
||||
@@ -364,8 +387,6 @@ Partial Class Inventarios_RecepcionUsados
|
||||
CargaTamaños()
|
||||
'DdlProducto2.setEsWebService(True)
|
||||
'DdlProducto2.Attributes.Add("data-metodo", "getpsusados")
|
||||
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
@@ -2382,4 +2403,204 @@ Partial Class Inventarios_RecepcionUsados
|
||||
objAcum.Dispose()
|
||||
End Sub
|
||||
|
||||
#Region "Ajustes"
|
||||
Public Sub OnRblUsadosAjuste_Change(sender As Object, e As EventArgs)
|
||||
If RblUsadosAjuste.SelectedValue = "1" Then
|
||||
CargaAjuste()
|
||||
DivAjuste.Visible = True
|
||||
Else
|
||||
DivAjuste.Visible = False
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub CargaAjuste()
|
||||
CreaDTmpDTAjustes()
|
||||
CargaPSAjuste()
|
||||
CargaBCIAjuste()
|
||||
CargaFolioAjuste()
|
||||
CargaTipoDefecto()
|
||||
CargaTipoDeUso()
|
||||
TxtFechaAjuste.Text = Today.ToString("d")
|
||||
End Sub
|
||||
Private Sub CreaDTmpDTAjustes()
|
||||
TmpDTAjustes = New DataTable
|
||||
TmpDTAjustes.Columns.Add("CveFolioGarantia", GetType(Integer))
|
||||
TmpDTAjustes.Columns.Add("CveTipoUso", GetType(Integer))
|
||||
TmpDTAjustes.Columns.Add("CveTipoDefecto", GetType(Integer))
|
||||
TmpDTAjustes.Columns.Add("CodigoEnsamble", GetType(String))
|
||||
TmpDTAjustes.Columns.Add("CodigoLinea", GetType(String))
|
||||
TmpDTAjustes.Columns.Add("CodigoInspeccion", GetType(String))
|
||||
TmpDTAjustes.Columns.Add("Consecutivo", GetType(String))
|
||||
TmpDTAjustes.Columns.Add("ConsecutivoVenta", GetType(Integer))
|
||||
TmpDTAjustes.Columns.Add("FechaAjuste", GetType(Date))
|
||||
TmpDTAjustes.Columns.Add("Meses", GetType(String))
|
||||
TmpDTAjustes.Columns.Add("PorcentajeAjuste", GetType(Double))
|
||||
TmpDTAjustes.Columns.Add("NumPoliza", GetType(String))
|
||||
TmpDTAjustes.Columns.Add("Importe", GetType(Double))
|
||||
TmpDTAjustes.Columns.Add("CvePS", GetType(Integer))
|
||||
TmpDTAjustes.Columns.Add("PS", GetType(String))
|
||||
TmpDTAjustes.Columns.Add("Cantidad", GetType(Decimal))
|
||||
TmpDTAjustes.Columns.Add("CveUM", GetType(Integer))
|
||||
TmpDTAjustes.Columns.Add("CveVentaDetalle", GetType(Integer))
|
||||
TmpDTAjustes.Columns.Add("CveVenta", GetType(Integer))
|
||||
TmpDTAjustes.Columns.Add("PUFactura", GetType(Double))
|
||||
End Sub
|
||||
Private Sub CargaAjusteDetalle()
|
||||
Dim Dr As DataRow = Nothing
|
||||
IndexAjuste = 0
|
||||
For Each Dr2 As DataRow In TmpDTAjustes.Rows
|
||||
If Dr2("ConsecutivoVenta").ToString.ToEntero = ConsecutivoVenta Then
|
||||
Dr = Dr2
|
||||
Exit For
|
||||
End If
|
||||
IndexAjuste += 1
|
||||
Next
|
||||
If Dr IsNot Nothing Then
|
||||
IndexAjuste = TmpDTAjustes.Rows.IndexOf(Dr)
|
||||
DdlFolioGarantia.SelectedValueExist(Dr("CveFolioGarantia").ToString)
|
||||
TxtConsecutivoAjuste.Text = Dr("Consecutivo").ToString
|
||||
TxtCodEnsamble.Text = Dr("CodigoEnsamble").ToString
|
||||
DdlTipoUso.SelectedValueExist(Dr("CveTipoUso").ToString)
|
||||
TxtCodLinea.Text = Dr("CodigoLinea").ToString
|
||||
TxtCodInspeccion.Text = Dr("CodigoInspeccion").ToString
|
||||
TxtMesesUso.Text = Dr("Meses").ToString
|
||||
DdlTipoDefecto.SelectedValueExist(Dr("CveTipoDefecto").ToString)
|
||||
TxtPorcentajeAjuste.Text = Dr("PorcentajeAjuste").ToString
|
||||
TxtPoliza.Text = Dr("NumPoliza").ToString
|
||||
TxtImporteAjuste.Text = Dr("Importe").ToString
|
||||
'DdlFacturas.SelectedValueExist(Dr("CveVenta").ToString)
|
||||
CargaPSAjuste()
|
||||
DdlPSAjuste.SelectedValue = (Dr("CvePS").ToString)
|
||||
TxtFechaAjuste.Text = Dr("FechaAjuste").ToString.ToDate.ToShortDateString
|
||||
txtPrecio.Text = Dr("PUFactura").ToString.ToDecimal.FormatoNumero(2)
|
||||
txtPrecio.Enabled = Not Dr("CveVenta").ToString.ToEntero > 0
|
||||
End If
|
||||
End Sub
|
||||
Private Sub CargaPSAjuste()
|
||||
DdlPSAjuste.setEsWebService(True)
|
||||
End Sub
|
||||
|
||||
Protected Sub DdlPSAjuste_selectedindexchange(sender As Object, e As EventArgs)
|
||||
If DdlPSAjuste.SelectedValue.ToEntero > 0 Then
|
||||
Dim CvePSParametro As Integer = DdlPSAjuste.SelectedValue.ToEntero
|
||||
Dim PrecioSugerido As Decimal = 0
|
||||
Dim drPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSParametro).FiltroPrimero("")
|
||||
|
||||
If drPS IsNot Nothing Then
|
||||
PrecioSugerido = drPS("Precio").ToString.ToDecimal
|
||||
End If
|
||||
|
||||
TxtPUFactura.Text = PrecioSugerido.FormatoNumero(2)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub CargaBCIAjuste()
|
||||
Dim ObjGral As New ClsGenerales
|
||||
If ObjGral.BCIUsadoGet(UsuarioActual.CveEmpresa) Then
|
||||
DdlBCIAjuste.DataSource = ObjGral.DtResultados
|
||||
DdlBCIAjuste.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
||||
End If
|
||||
ObjGral.Dispose()
|
||||
DdlBCIAjuste.DataBind()
|
||||
End Sub
|
||||
|
||||
Private Sub CargaFolioAjuste()
|
||||
Dim ObjAcum As New ClsAcumuladores
|
||||
If ObjAcum.FoliosGarantiaGet(-1, UsuarioActual.CveEmpresa) Then
|
||||
DdlFolioGarantia.DataSource = ObjAcum.DtResultados
|
||||
DdlFolioGarantia.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
||||
End If
|
||||
ObjAcum.Dispose()
|
||||
DdlFolioGarantia.DataBind()
|
||||
End Sub
|
||||
|
||||
Protected Sub DdlFolioGarantia_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlFolioGarantia.SelectedIndexChanged
|
||||
Dim ObjAcumuladores As New ClsAcumuladores
|
||||
If ObjAcumuladores.GetNuevoConsecutivoFolio(DdlFolioGarantia.SelectedValue.ToEntero) Then
|
||||
Dim resultado As String = ObjAcumuladores.DtResultados.FiltroPrimeroValor("NuevoConsecutivo")
|
||||
TxtConsecutivoAjuste.Text = resultado
|
||||
UpAjuste.Update()
|
||||
End If
|
||||
ObjAcumuladores.Dispose()
|
||||
End Sub
|
||||
|
||||
Protected Sub CargaTipoDeUso()
|
||||
DdlTipoUso.DataSource = GlobalDTAcumTiposUso.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa}")
|
||||
DdlTipoUso.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
||||
DdlTipoUso.DataBind
|
||||
End Sub
|
||||
|
||||
Protected Sub DdlTipoUso_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||
CalculaPorcentajeAjuste()
|
||||
End Sub
|
||||
|
||||
Protected Sub CargaTipoDefecto()
|
||||
DdlTipoDefecto.DataSource = GlobalDTAcumTiposDefecto.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa}")
|
||||
DdlTipoDefecto.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
||||
DdlTipoDefecto.DataBind
|
||||
End Sub
|
||||
Private Sub CalculaPorcentajeAjuste()
|
||||
Try
|
||||
If DdlTipoUso.SelectedValue.ToEntero > 0 AndAlso DdlPSAjuste.SelectedValue.ToEntero > 0 AndAlso TxtMesesUso.Text <> "" Then
|
||||
Dim CveMarca As Integer = -1
|
||||
|
||||
CveMarca = GlobalDTPS(UsuarioActual.CveEmpresa, DdlPSAjuste.SelectedValue.ToEntero).FiltroPrimeroValor("CveMarca", "").ToEntero
|
||||
|
||||
Dim ObjAcum As New ClsAcumuladores
|
||||
If ObjAcum.GarantiasMesesGet(-1, UsuarioActual.CveEmpresa, CveMarca, DdlTipoUso.SelectedValue.ToEntero, TxtMesesUso.Text.ToEntero) Then
|
||||
If ObjAcum.DtResultados.Rows.Count > 0 Then
|
||||
TxtPorcentajeAjuste.Text = (ObjAcum.DtResultados.Rows(0)("Valor").ToString.ToDouble / 100).ToString
|
||||
|
||||
TxtImporteAjuste.Text = (TxtPorcentajeAjuste.Text.ToDecimal * TxtPUFactura.Text.ToDecimal).FormatoNumero
|
||||
|
||||
Dim CargoVendido As Decimal = 0
|
||||
Dim CargoGarantia As Decimal = 0
|
||||
Dim CveTamaño As Integer = 0
|
||||
|
||||
If DdlPSAjuste.SelectedValue.ToEntero > 0 Then
|
||||
Dim Dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, DdlPSAjuste.SelectedValue.ToEntero).FiltroPrimero("")
|
||||
If Dr IsNot Nothing Then
|
||||
CargoGarantia = Dr("Cargo").ToString.ToDecimal
|
||||
End If
|
||||
End If
|
||||
|
||||
If DdlPSAjuste.SelectedValue.ToEntero > 0 Then
|
||||
Dim Dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, DdlPSAjuste.SelectedValue.ToEntero).FiltroPrimero("")
|
||||
If Dr IsNot Nothing Then
|
||||
CveTamaño = Dr("CveTamaño").ToString.ToEntero
|
||||
End If
|
||||
End If
|
||||
|
||||
Dim DrCargo As DataRow = GlobalDTAcumTamaños.FiltroPrimero($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveTamaño = {CveTamaño}")
|
||||
If DrCargo IsNot Nothing Then
|
||||
|
||||
CargoVendido = DrCargo("Cargo").ToString.ToDecimal
|
||||
|
||||
End If
|
||||
|
||||
'el ajuste no puede ser mayor al precio de lo vendido de nuevo
|
||||
If (txtPrecio.Text.ToDouble - ((TxtPUFactura.Text.ToDouble - TxtImporteAjuste.Text.ToDouble) - (CargoVendido - CargoGarantia))) < 0 Then
|
||||
|
||||
TxtImporteAjuste.Text = "0.00"
|
||||
CargoGarantia = CargoVendido
|
||||
End If
|
||||
TxtImporteAjuste.ToolTip = $"La diferencia de ajuste fue: {(txtPrecio.Text.ToDouble - TxtImporteAjuste.Text.ToDouble).FormatoNumero()}. La diferencia de tamaños fue: {(CargoVendido - CargoGarantia).FormatoNumero}."
|
||||
TxtImporteAjuste.Text = ((TxtPUFactura.Text.ToDouble - TxtImporteAjuste.Text.ToDouble) - (CargoVendido - CargoGarantia)).FormatoNumero
|
||||
|
||||
Else
|
||||
'cuando no está registrada, no da ajuste
|
||||
TxtImporteAjuste.ToolTip = "El producto no tiene ajuste en ese periodo"
|
||||
TxtImporteAjuste.Text = "0.00"
|
||||
End If
|
||||
End If
|
||||
ObjAcum.Dispose()
|
||||
End If
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al recalcular el costo", ex)
|
||||
End Try
|
||||
|
||||
UpAjuste.Update()
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user