Cambios Poliza virtual

This commit is contained in:
2021-04-21 18:04:53 -07:00
parent b6cfdba876
commit 7a92c4a95a
3 changed files with 260 additions and 44 deletions

View File

@@ -875,6 +875,23 @@ Public Class ClsAcumuladores
End Try
Return Retorno
End Function
Public Function UpdatePolizaVirtual(CvePolizaVirtual As Integer, CveMarca As Integer, FechaUsado As DateTime) As Boolean
Dim Retorno As Boolean = False
SqlDataAdapter("PA_Vta_PolizaVirtualUpdate")
With SqlAdapter.SelectCommand.Parameters
.Add("@CvePolizaVirtual", SqlDbType.Int).Value = CvePolizaVirtual
.Add("@CveMarca", SqlDbType.Int).Value = CveMarca
.Add("@FechaUsado", SqlDbType.DateTime).Value = FechaUsado
End With
Try
SqlAdapter.Fill(Data)
Retorno = True
Catch ex As SqlException
OnError("Ocurrió un al actualizar el envio de la poliza virtual. ", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
End Try
Return Retorno
End Function
Public Function UpdateEnvioPolizaVirutal(CvePolizaVirtual As Integer, Envio As Boolean, FechaEnvio As DateTime, CodigoUnico As String) As Boolean
Dim Retorno As Boolean = False
SqlDataAdapter("PA_Vta_PolizaVirtualEnvioUpdate")

View File

@@ -335,6 +335,45 @@
</asp:GridView>
</div>
</div>
<div id="DivRecepcionApartado" runat="server" visible="false" class="portlet light xspadding bordered">
<div class="portlet-title">
<div class="caption font-green">
<i class="icon-pin font-green"></i>
<span class="caption-subject bold uppercase">Apartado Usado</span>
</div>
<div class="actions">
<div class="btn-group">
</div>
</div>
<div class="tools">
</div>
</div>
<div class="portlet-body">
<div class="row">
<div class="col-md-8">
<div class="form-group form-md-line-input input-iconright">
<asp:DropDownList ID="DdlMarcaRem" CssClass="form-control input-sm select2me" runat="server" DataTextField="Marca" DataValueField="CveMarca" Width="100%">
<asp:ListItem Selected="True" Text="Seleccione la Marca" Value="-1"></asp:ListItem>
</asp:DropDownList>
<label for="<%= DdlMarcaRem.ClientID.ToString()%>">Marca:</label>
</div>
</div>
<div class="col-md-4">
<label for="<%= TxtFechaAjuste.ClientID.ToString()%>">Fecha Vigencia:</label>
<div class="input-group input-sm input-small date date-picker " data-date-format="dd/mm/yyyy" style="width: 120px !important; padding: 0px;">
<asp:TextBox ID="TxtFechaVigencia" CssClass="form-control input-sm ADSMaskDate" Width="100%" runat="server"></asp:TextBox>
<span class="input-group-btn ">
<asp:LinkButton ID="LnkFechaVigencia" class="btn default " Text=" <i class='fa fa-calendar'></i>" runat="server"></asp:LinkButton>
</span>
<ajax:MaskedEditExtender ID="MEEFechaVigencia" runat="server" TargetControlID="TxtFechaVigencia" Mask="99/99/9999" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"></ajax:MaskedEditExtender>
<ajax:CalendarExtender runat="server" ID="CEFechaVigencia" TargetControlID="TxtFechaVigencia" PopupButtonID="LnkFechaVigencia" PopupPosition="BottomRight" Enabled="True" Format="dd/MM/yyyy"></ajax:CalendarExtender>
<asp:RequiredFieldValidator ID="RFVFechaVigencia" runat="server" ControlToValidate="TxtFechaVigencia" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Fecha Vigencia''</b> es necesario, por favor ingréselo." ValidationGroup="GrpGuardar"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCEFechaVigencia" runat="server" HighlightCssClass="vco" TargetControlID="RFVFechaVigencia"></ajax:ValidatorCalloutExtender>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="DivAjuste" runat="server" visible="false" class="col-md-6">
<asp:UpdatePanel ID="UpAjuste" runat="server" class="portlet light xspadding bordered" UpdateMode="Conditional">

View File

@@ -317,6 +317,15 @@ Partial Class Inventarios_RecepcionUsados
ViewState("DtPorcentajeMarcas") = value
End Set
End Property
Private Property TmpDTPolizaVirtual As DataTable
Get
Return If(IsNothing(ViewState("TmpDTPolizaVirtual")), Nothing, CType(ViewState("TmpDTPolizaVirtual"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTPolizaVirtual") = value
End Set
End Property
#End Region
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
@@ -1125,57 +1134,76 @@ Partial Class Inventarios_RecepcionUsados
Recibio:=TxtResponsable.Text.Trim, CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal, DepartamentoEntrega:=TxtDepartamentoEntrega.Text,
PedidoContrato:=TxtPedidoContrato.Text, CveProveedor:=tCveProveedor, Modulo:="RU/G")
If CveMovimiento <= 0 Then
Mensaje = "Error al guardar los movimientos"
ErrorMovInv = True
Else
FolioInv = ObjInventario.Folio.ToString()
Mensaje = "Error al guardar los movimientos"
ErrorMovInv = True
Else
FolioInv = ObjInventario.Folio.ToString()
For Each Dr As DataRow In DtMovimientos.Rows
For Each Dr As DataRow In DtMovimientos.Rows
If CveConcepto = 42 AndAlso DdlMoneda.SelectedValue.ToEntero = 2 Then
ImporteConcepto = Dr("PU").ToString.ToDecimal * GlobalTipoCambio(TxtFecha.Text.ToDate).ToDecimal
Else
ImporteConcepto = Dr("PU").ToString.ToDecimal
End If
If CveConcepto = 42 AndAlso DdlMoneda.SelectedValue.ToEntero = 2 Then
ImporteConcepto = Dr("PU").ToString.ToDecimal * GlobalTipoCambio(TxtFecha.Text.ToDate).ToDecimal
Else
ImporteConcepto = Dr("PU").ToString.ToDecimal
End If
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, CveAF:=Dr("CveAF").ToString.ToEntero, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, Observaciones:=Dr("Observaciones").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
Mensaje = "Error al guardar los movimientos"
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, CveAF:=Dr("CveAF").ToString.ToEntero, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, Observaciones:=Dr("Observaciones").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
Mensaje = "Error al guardar los movimientos"
ErrorMovInv = True
Exit For
End If
If CveVenta > 0 AndAlso Not ObjVentas.UpdateVentaUsadoRecibido(CveVenta, Dr("CvePS").ToString.ToEntero, True, CveMovimiento) Then
Mensaje = "Error al actualizar el recibo de los usados"
ErrorMovInv = True
Exit For
End If
'si es selectedvalue = 42, es entrada ,3 -salida
Dim CveConceptoUsados As Integer = If(RBLOpcion.SelectedValue.ToEntero = 42, 1, 2)
If EsDistribuidor AndAlso RBLOpcion.SelectedValue.ToEntero = 42 AndAlso Dr("CveTamaño").ToString.ToEntero > 0 Then
If Not ObjAcum.DistribuidorMovtosAdd(DdlClientes.SelectedValue.ToEntero, Dr("Cantidad").ToString.ToEntero(), Dr("CveTamaño").ToString.ToEntero, CveConceptoUsados, CveVenta, UsuarioActual.CveUsuario,
UsuarioActual.CveEmpresa, 0, Dr("Observaciones").ToString, CveMovimiento:=CveMovimiento) Then
Mensaje = "Error al guardar Movimientos de distribuidor"
ErrorMovInv = True
Exit For
End If
If CveVenta > 0 AndAlso Not ObjVentas.UpdateVentaUsadoRecibido(CveVenta, Dr("CvePS").ToString.ToEntero, True, CveMovimiento) Then
Mensaje = "Error al actualizar el recibo de los usados"
ErrorMovInv = True
Exit For
End If
End If
Next
'si es selectedvalue = 42, es entrada ,3 -salida
Dim CveConceptoUsados As Integer = If(RBLOpcion.SelectedValue.ToEntero = 42, 1, 2)
'ACTUALIZA LA POLIZA VIRTUAL DEL LA REMISION
'If Not ErrorMovInv AndAlso ObjFactura.TipoDocto = "Rem" Then
' If ObjAcum.GetPolizasVirtuales(ObjFactura.CveVenta) Then
' Dim DtPoliza As DataTable = ObjAcum.DtResultados.Copy()
' For Each RowPoliza As DataRow In DtPoliza.Rows
' If Not ObjAcum.UpdatePolizaVirtual(RowPoliza("CvePolizaVirtual").ToString().ToEntero, DdlMarcaRem.SelectedValue.ToEntero(), TxtFechaVigencia.Text.ToDateTime()) Then
' Mensaje = "Error al guardar la póliza virtual"
' ErrorMovInv = True
' Exit For
' End If
' Next
If EsDistribuidor AndAlso RBLOpcion.SelectedValue.ToEntero = 42 AndAlso Dr("CveTamaño").ToString.ToEntero > 0 Then
' DtPoliza.Dispose()
' Else
' Mensaje = "Error al obtener la póliza virtual"
' ErrorMovInv = True
' End If
'End If
If Not ObjAcum.DistribuidorMovtosAdd(DdlClientes.SelectedValue.ToEntero, Dr("Cantidad").ToString.ToEntero(), Dr("CveTamaño").ToString.ToEntero, CveConceptoUsados, CveVenta, UsuarioActual.CveUsuario,
UsuarioActual.CveEmpresa, 0, Dr("Observaciones").ToString, CveMovimiento:=CveMovimiento) Then
Mensaje = "Error al guardar Movimientos de distribuidor"
ErrorMovInv = True
Exit For
End If
End If
Next
'GENERA LA PREPOLIZA DE ALMACEN VS EL CONCEPTO DE RNC
'If Not ErrorMovInv Then
' ErrorMovInv = Not GeneraPrePoliza(CveMovimiento, ObjInventario, ObjConta, True)
'End If
End If
'GENERA LA PREPOLIZA DE ALMACEN VS EL CONCEPTO DE RNC
'If Not ErrorMovInv Then
' ErrorMovInv = Not GeneraPrePoliza(CveMovimiento, ObjInventario, ObjConta, True)
'End If
End If
End If
If Not ErrorMovInv Then
If Not ErrorMovInv Then
If Resp IsNot Nothing Then
For Each mensaje2 As String In Resp.Mensajes
Msg.AppendFormat("<br>{0}", mensaje2)
@@ -1473,6 +1501,13 @@ Partial Class Inventarios_RecepcionUsados
GvM.DataSource = DtTemp
GvM.DataBind()
'If TmpDTPolizaVirtual IsNot Nothing AndAlso RblUsadosAjuste.SelectedValue = "2" Then
' TmpDTPolizaVirtual.Clear()
' For Each Row As DataRow In DtTemp.Rows
' AddPolizaVirtual(Row("CvePS").ToString().ToEntero())
' Next
'End If
EscondeColumnasGVM(DtTemp)
End Sub
Private Sub EscondeColumnasGVM(DtTemp As DataTable)
@@ -2076,6 +2111,14 @@ Partial Class Inventarios_RecepcionUsados
DdlClientes.SelectedValueExist(CveCliente)
End If
If Me.ObjFactura IsNot Nothing Then
Me.ObjFactura.Dispose()
Me.ObjFactura = Nothing
End If
Me.ObjFactura = New Modelos.Factura(UsuarioActual, CveRemisionRecibida, UsuarioActual.CveEmpresa, DirectorioServidor:=ModExtensiones.DirectorioBaseEmpresas)
'SI ES DISTRIBUIDOR VAMOS A GENERAR LA REMISION DE NOTA DE CREDITO
If EsDistribuidor Then
DivCliente.Visible = True
@@ -2087,13 +2130,6 @@ Partial Class Inventarios_RecepcionUsados
Me.ObjRemisionNC = Nothing
End If
If Me.ObjFactura IsNot Nothing Then
Me.ObjFactura.Dispose()
Me.ObjFactura = Nothing
End If
Me.ObjFactura = New Modelos.Factura(UsuarioActual, CveRemisionRecibida, UsuarioActual.CveEmpresa, DirectorioServidor:=ModExtensiones.DirectorioBaseEmpresas)
If Me.ObjFactura IsNot Nothing Then
'CreaRemisionNC(ObjFactura.CveCliente, ObjFactura.CveSubProyecto, ObjFactura.CveMoneda)
DivTotal.Visible = True
@@ -2102,12 +2138,17 @@ Partial Class Inventarios_RecepcionUsados
'DivCliente.Visible = False
'DivFactura.Visible = False
End If
If ObjVentas.GetVentasUsadosDetalle(CveRemisionRecibida) Then
DtUsados = ObjVentas.DtResultados.Copy()
End If
ObjVentas.Dispose()
If DtUsados IsNot Nothing Then
'DivRecepcionApartado.Visible = True
For Each RowUsado As DataRow In DtUsados.Rows
Dim CvePS = RowUsado("CvePS").ToString().ToEntero()
@@ -2271,6 +2312,10 @@ Partial Class Inventarios_RecepcionUsados
Me.ObjRemisionNC.PedidoContrato = ""
Me.ObjRemisionNC.ObservacionesAlmacen = ""
'If TmpDTPolizaVirtual IsNot Nothing Then
' Me.ObjRemisionNC.DtPolizasVirtuales = TmpDTPolizaVirtual
'End If
End Sub
Private Function AddPSRNC(ByRef TmpDT As DataTable, Cantidad As Decimal, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, CvePS As Integer, PS As String, Obs As String,
@@ -3087,6 +3132,10 @@ Partial Class Inventarios_RecepcionUsados
ObjPS.Dispose()
GuardaAjuste()
'If TmpDTPolizaVirtual Is Nothing Then
' CreaDTmpDTPolizaVirtual()
'End If
End Sub
Protected Sub CargarDescuento()
@@ -3251,15 +3300,126 @@ Partial Class Inventarios_RecepcionUsados
Using ObjMarcas As New ClsProductosServicios
If ObjMarcas.GetMarcas(UsuarioActual.CveEmpresa) Then
DdlMarcaPSAjuste.DataSource = ObjMarcas.DtResultados
DdlMarcaRem.DataSource = ObjMarcas.DtResultados
End If
End Using
DdlMarcaPSAjuste.DataBind()
DdlMarcaRem.DataBind()
DdlMarcaPSAjuste.Items.Insert(0, New ListItem("Todas", "-1"))
DdlMarcaRem.Items.Insert(0, New ListItem("Todas", "-1"))
UpAjuste.Update()
End Sub
#Region "P O L I Z A - V I R T U A L"
Private Sub CreaDTmpDTPolizaVirtual()
TmpDTPolizaVirtual = New DataTable
TmpDTPolizaVirtual.Columns.Add("CvePS", GetType(Integer))
TmpDTPolizaVirtual.Columns.Add("Cantidad", GetType(Decimal))
TmpDTPolizaVirtual.Columns.Add("PU", GetType(Decimal))
TmpDTPolizaVirtual.Columns.Add("Descuento", GetType(Decimal))
TmpDTPolizaVirtual.Columns.Add("Total", GetType(Decimal))
TmpDTPolizaVirtual.Columns.Add("CveVentaDetalle", GetType(Integer))
TmpDTPolizaVirtual.Columns.Add("TipoServicio", GetType(Integer))
TmpDTPolizaVirtual.Columns.Add("TipoPoliza", GetType(Integer))
TmpDTPolizaVirtual.Columns.Add("CveModeloAuto", GetType(Integer))
TmpDTPolizaVirtual.Columns.Add("AnioVehiculo", GetType(Integer))
TmpDTPolizaVirtual.Columns.Add("TieneUsado", GetType(Boolean))
TmpDTPolizaVirtual.Columns.Add("FechaUsado", GetType(DateTime))
TmpDTPolizaVirtual.Columns.Add("CvePSUsado", GetType(Integer))
TmpDTPolizaVirtual.Columns.Add("CveBCIUsado", GetType(Integer))
End Sub
Private Function AddPolizaVirtual(CvePS As Integer) As Boolean
Dim Retorno As Boolean = True
'If Modalidad = "U" Then
' If TmpDTPolizaVirtual.Rows.Count > 0 Then
' Dim Elimino As Boolean = False
' For Each RowPoliza As DataRow In TmpDTPolizaVirtual.Rows
' If RowPoliza("CvePS").ToString().ToEntero() = CvePS Then
' RowPoliza.Delete()
' Elimino = True
' Exit For
' End If
' Next
' If Elimino Then
' TmpDTRecepcionUsados.AcceptChanges()
' End If
' End If
'End If
Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
If DrPS IsNot Nothing Then
'SOLO DEBE AGREGAR POLIZA VIRTUAL SI ES ACUMULADOR
If Not DrPS("CveClasificacion").ToString().ToEntero().Contiene(20520, 20522, 20513, 20511, 20521, 20512, 20514, 20229) Then
Return Retorno
End If
Else
Retorno = False
Return Retorno
End If
Dim Cantidad As Decimal = 1
Dim PU As Decimal = txtPrecio.Text.ToDecimal()
Dim Descuento As Decimal = 0
Dim ImporteAjuste As Decimal = TxtImporteAjuste.Text.ToDecimal().RoundSQL(2)
Dim Total As Decimal = ((Cantidad * PU) - Descuento).RoundSQL(2)
Dim TipoServicio As Integer = -1
Dim FechaUsado As DateTime = If(TxtFechaAjuste.Text.ToDateTime() < MinFecha, Now, TxtFechaAjuste.Text.ToDateTime())
Dim CveModeloAuto As Integer = -1
Dim AnioVehiculo As Integer = 0
Dim TipoPoliza As Integer = 1 'VENTA
If Total = ImporteAjuste Then
TipoPoliza = 3 'GARANTIA
Else
TipoPoliza = 2 'AJUSTE
End If
'Dim TieneUsado As Boolean = GvRecepcionUsados.Rows.Cast(Of GridViewRow).Any(Function(GvRow) GvRow.RowType = DataControlRowType.DataRow AndAlso GvRow.FCTextBox("TxtCantidad").Text.ToDecimal() > 0)
Dim CvePSUsado As Integer = -1
Dim CveBCIUsado As Integer = -1
'If TieneUsado Then
' For Each GvRow As GridViewRow In GvRecepcionUsados.Rows
' If GvRow.RowType = DataControlRowType.DataRow Then
' If GvRow.FCTextBox("TxtCantidad").Text.ToDecimal() > 0 Then
' CvePSUsado = GvRow.DataKey("CvePSCargo").ToEntero()
' CveBCIUsado = GvRow.FCDropDownList("DdlBCIUsado").SelectedValue.ToEntero()
' Exit For
' End If
' End If
' Next
'End If
Dim Row As DataRow = TmpDTPolizaVirtual.NewRow()
Row("CvePS") = CvePS
Row("Cantidad") = Cantidad
Row("PU") = PU
Row("Descuento") = Descuento
Row("Total") = Total
Row("CveVentaDetalle") = -1
Row("TipoServicio") = TipoServicio
Row("TipoPoliza") = TipoPoliza
Row("CveModeloAuto") = CveModeloAuto
Row("AnioVehiculo") = AnioVehiculo
Row("TieneUsado") = 1
Row("FechaUsado") = FechaUsado
Row("CvePSUsado") = CvePSUsado
Row("CveBCIUsado") = CveBCIUsado
TmpDTPolizaVirtual.Rows.Add(Row)
Return Retorno
End Function
#End Region
Partial Class MFolioGarantiaMensaje
Public Property CvePS As Integer