E140. asignar polizas virtuales por consecutivo

This commit is contained in:
2022-02-28 18:04:36 -07:00
parent 2e3056d510
commit 1079e2014e
3 changed files with 83 additions and 43 deletions

View File

@@ -1559,8 +1559,8 @@ Namespace Modelos
End If
If DtPolizasVirtuales IsNot Nothing Then
If DtPolizasVirtuales.Select($"CvePS={Row("CvePS").ToString.ToEntero}").Length > 0 Then
Dim RowPoliza As DataRow = DtPolizasVirtuales.Select($"CvePS={Row("CvePS").ToString.ToEntero}")(0)
If DtPolizasVirtuales.Select($"Consec = {Row("Consec").ToString()} AND CvePS={Row("CvePS").ToString.ToEntero}").Length > 0 Then
Dim RowPoliza As DataRow = DtPolizasVirtuales.Select($"Consec = {Row("Consec").ToString()} AND CvePS={Row("CvePS").ToString.ToEntero}")(0)
RowPoliza("CveVentaDetalle") = ObjVentas.CveVentaDetalle
End If
End If
@@ -1620,7 +1620,7 @@ Namespace Modelos
'POLIZA VIRTUAL
If factura.DtPolizasVirtuales IsNot Nothing AndAlso factura.DtPolizasVirtuales.Rows.Count > 0 Then
If Not GuardarPolizasVirtuales(ObjVentas.IniciaTransacSQL(), ObjFactura:=factura) Then
If Not GuardarPolizasVirtuales(ObjAcum, ObjFactura:=factura) Then
ErrorList.Add("Ocurrió un error al actualizar el distribuidor.")
End If
End If
@@ -2220,13 +2220,11 @@ Namespace Modelos
Return CveMovimiento
End Function
Private Function GuardarPolizasVirtuales(SqlTransaccion As SqlClient.SqlTransaction, ObjFactura As Modelos.Factura) As Boolean
Private Function GuardarPolizasVirtuales(ByRef ObjAcum As ClsAcumuladores, ObjFactura As Modelos.Factura) As Boolean
Dim Resultado As Boolean = True
If UsuarioActual.Empresa.Funcionalidad(531).ToEntero > 0 AndAlso ObjFactura.TipoDocto.Contiene("Rem") Then
Dim ObjAcum As New ClsAcumuladores(SqlTransaccion)
For Each drow As DataRow In ObjFactura.DtPolizasVirtuales.Rows
If ObjAcum.AddPolizaVirtual(ObjFactura.CveVenta, drow("CveVentaDetalle").ToString().ToEntero(), drow("CvePS").ToString.ToEntero, drow("Cantidad").ToString.ToDecimal, drow("PU").ToString.ToDecimal, drow("Descuento").ToString.ToDecimal,
drow("Total").ToString.ToDecimal, drow("TipoServicio").ToString.ToEntero, drow("TipoPoliza").ToString.ToEntero, drow("CveModeloAuto").ToString.ToEntero, drow("AnioVehiculo").ToString.ToEntero, CBool(drow("TieneUsado").ToString),

View File

@@ -2872,7 +2872,7 @@
<label>Año:</label>
<br />
<asp:TextBox ID="TxtAnioVehiculo" type="number" runat="server" Height="100%" Width="100%" CssClass="form-control" ></asp:TextBox>
<asp:CustomValidator ID="CVAnio" runat="server" ClientValidationFunction="ValidaAnioVehiculo" ValidateEmptyText="true" ControlToValidate="TxtAnioVehiculo" Display="Dynamic" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Año''</b> es necesario, por favor ingréselo." ValidationGroup="GrpAddVenta"></asp:CustomValidator>
<asp:CustomValidator ID="CVAnio" runat="server" ClientValidationFunction="ValidaAnioVehiculo" ValidateEmptyText="true" ControlToValidate="TxtAnioVehiculo" Display="Dynamic" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Año''</b> esta vacío o no tiene el formato correcto, por favor ingréselo." ValidationGroup="GrpAddVenta"></asp:CustomValidator>
</div>
</div>
<div class="row">
@@ -3281,7 +3281,19 @@
//VALIDA SOLO SI SE SELECCIONO UN USADO
var cveUsado = ToDouble($get("C_DdlRecepcionUsados").value);
if (cveUsado > 0) {
args.IsValid = (ToDouble(args.Value) > 0);
var anio = ToDouble(args.Value);
if (anio > 0) {
var valido = true;
if (anio < 1900) {
valido = false;
}
if (anio.toString().length != 4) {
valido = false;
}
args.IsValid = valido;
} else {
args.IsValid = false;
}
} else {
args.IsValid = true;
}

View File

@@ -3430,27 +3430,27 @@ Partial Class PV
If Retorno IsNot Nothing AndAlso Retorno.CveVenta > 0 Then
If ObjFactura.TipoDocto = "Rem" Then
If ObjAcum.GetPolizasVirtuales(Retorno.CveVenta) Then
Dim DtPoliza As DataTable = ObjAcum.DtResultados.Copy()
'If ObjFactura.TipoDocto = "Rem" Then
' If ObjAcum.GetPolizasVirtuales(Retorno.CveVenta) Then
' Dim DtPoliza As DataTable = ObjAcum.DtResultados.Copy()
For Each Row As DataRow In ObjFactura.DtPolizasVirtuales.Rows
Dim CvePolizaVirtual As Integer = DtPoliza.FiltroPrimeroValor("CvePolizaVirtual", $"CveVentaDetalle={Row("CveVentaDetalle")}").ToEntero()
' For Each Row As DataRow In ObjFactura.DtPolizasVirtuales.Rows
' Dim CvePolizaVirtual As Integer = DtPoliza.FiltroPrimeroValor("CvePolizaVirtual", $"CveVentaDetalle={Row("CveVentaDetalle")}").ToEntero()
If Not ObjAcum.UpdatePolizaVirtual(CvePolizaVirtual, Row("CveMarcaUsado").ToString().ToEntero(), Row("FechaUsado").ToString().ToDateTime()) Then
SbAlert.Append("Error al guardar la póliza virtual")
TieneError = True
Exit For
End If
Next
' If Not ObjAcum.UpdatePolizaVirtual(CvePolizaVirtual, Row("CveMarcaUsado").ToString().ToEntero(), Row("FechaUsado").ToString().ToDateTime()) Then
' SbAlert.Append("Error al guardar la póliza virtual")
' TieneError = True
' Exit For
' End If
' Next
DtPoliza.Dispose()
Else
SbAlert.Append("Error al obtener la póliza virtual")
TieneError = True
End If
' DtPoliza.Dispose()
' Else
' SbAlert.Append("Error al obtener la póliza virtual")
' TieneError = True
' End If
End If
'End If
If ObjAcum.GetGarantiasDetalle(Retorno.CveVenta) Then
Dim RowGarantia As DataRow = ObjAcum.DtResultados.FiltroPrimero("")
@@ -4790,6 +4790,9 @@ Partial Class PV
DdlRecepcionUsados.SelectedValueExist("-1")
DivRecepcionUsados.Visible = False
DdlMarca.SelectedValueExist("-1")
TxtFechaVigencia.Text = Now.ToString("dd/MM/yyyy")
LimpiaAjuste()
UPPDescuento.Update()
@@ -5295,7 +5298,7 @@ Partial Class PV
divagregrarotrops.Visible = False
Ajuste()
AddPolizaVirtual(DdlPS.SelectedValue.ToEntero())
'AddPolizaVirtual(DdlPS.SelectedValue.ToEntero())
'BUSCA EN TMPDT LOS DATOS DE USADOS
If TmpDT.Rows.Count > 0 AndAlso TmpDTRecepcionUsados IsNot Nothing AndAlso TmpDTRecepcionUsados.Rows.Count > 0 Then
@@ -5334,11 +5337,29 @@ Partial Class PV
Exit Sub
End If
If String.IsNullOrEmpty(TxtAnioVehiculo.Text.Trim()) Then
Alert("El campo año esta vacío.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If TxtAnioVehiculo.Text.ToDecimal() < 1900 Then
Alert("El campo año debe ser mayor a 1900.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
Else
If Not String.IsNullOrEmpty(TxtAnioVehiculo.Text.Trim()) Then
If TxtAnioVehiculo.Text.ToDecimal() < 1900 Then
Alert("El año del vehiculo del vehículo no tiene el formato correcto.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
End If
If AgregarPS() Then
If ChkAjuste.Checked Then GuardaAjuste()
AddPolizaVirtual(DdlPS.SelectedValue.ToEntero())
CalculaTotalesVenta()
If ChkAgregar.Checked = True And Modalidad = "A" Then
@@ -5404,17 +5425,19 @@ Partial Class PV
CveProyecto, Proyecto, DdlSubProyectoDatos.SelectedValue.ToEntero, DdlSubProyectoDatos.SelectedItem.Text,
Serie:="", TiempoEntrega:="", CuentaPredial:="", RegeneraIEPS:=ClienteDesglosaIEPS, CveVentaDetalle:=CveVentaDetalle, EsCargo:=EsCargo)
Dim ListaPSCargo As List(Of MConceptoUsado) = Nothing
If CveVentaDetalle <= 0 AndAlso Not EsCargo Then
Dim ListaPSCargo = CalculaUsados(Consec)
If ListaPSCargo.Count > 0 Then
CalculaRecepcionUsados(CvePS, ListaPSCargo, Cantidad, Consec)
End If
ListaPSCargo = CalculaUsados(Consec)
ElseIf CveVentaDetalle > 0 AndAlso Not EsCargo Then
EliminarUsados()
Dim ListaPSCargo = CalculaUsados(Consec, LimpiarUsados:=False)
If ListaPSCargo.Count > 0 Then
CalculaRecepcionUsados(CvePS, ListaPSCargo, Cantidad, Consec)
End If
ListaPSCargo = CalculaUsados(Consec, LimpiarUsados:=False)
End If
If ListaPSCargo IsNot Nothing AndAlso ListaPSCargo.Count > 0 Then
CalculaRecepcionUsados(CvePS, ListaPSCargo, Cantidad, Consec)
For Each Usado As MConceptoUsado In ListaPSCargo
AddPolizaVirtual(DdlPS.SelectedValue.ToEntero(), Usado.Consecutivo)
Next
End If
Return True
@@ -7386,6 +7409,7 @@ Partial Class PV
#Region "P O L I Z A - V I R T U A L"
Private Sub CreaDTmpDTPolizaVirtual()
TmpDTPolizaVirtual = New DataTable
TmpDTPolizaVirtual.Columns.Add("Consec", GetType(Integer))
TmpDTPolizaVirtual.Columns.Add("CvePS", GetType(Integer))
TmpDTPolizaVirtual.Columns.Add("Cantidad", GetType(Decimal))
TmpDTPolizaVirtual.Columns.Add("PU", GetType(Decimal))
@@ -7402,14 +7426,14 @@ Partial Class PV
TmpDTPolizaVirtual.Columns.Add("CveBCIUsado", GetType(Integer))
TmpDTPolizaVirtual.Columns.Add("CveMarcaUsado", GetType(Integer))
End Sub
Private Function AddPolizaVirtual(CvePS As Integer) As Boolean
Private Function AddPolizaVirtual(CvePS As Integer, Consec 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
If RowPoliza("Consec").ToString().ToEntero() = Consec AndAlso RowPoliza("CvePS").ToString().ToEntero() = CvePS Then
RowPoliza.Delete()
Elimino = True
Exit For
@@ -7475,6 +7499,8 @@ Partial Class PV
End If
Dim Row As DataRow = TmpDTPolizaVirtual.NewRow()
Row("Consec") = Consec
Row("CvePS") = CvePS
Row("Cantidad") = Cantidad
Row("PU") = PU
@@ -7524,7 +7550,7 @@ Partial Class PV
EmitirImprimirNew()
End Sub
Private Sub CalculaRecepcionUsados(CvePS As Integer, ListaPSCargo As List(Of Integer), CantidadUsado As Decimal, ConsecPSPadre As Integer)
Private Sub CalculaRecepcionUsados(CvePS As Integer, ListaPSCargo As List(Of MConceptoUsado), CantidadUsado As Decimal, ConsecPSPadre As Integer)
If Modalidad = "U" Then
If TmpDTRecepcionUsados.Rows.Count > 0 Then
@@ -7600,8 +7626,8 @@ Partial Class PV
End If
Dim StrCargos As New StringBuilder
For Each CvePSCargo As Integer In ListaPSCargo
StrCargos.AppendFormat(" {0},", CvePSCargo)
For Each Usado As MConceptoUsado In ListaPSCargo
StrCargos.AppendFormat(" {0},", Usado.CvePS)
Next
StrCargos.Remove(StrCargos.Length - 1, 1)
@@ -7718,12 +7744,16 @@ Partial Class PV
CalculaTotalesVenta()
End Sub
Private Function CalculaUsados(Consec As Integer, Optional LimpiarUsados As Boolean = True) As List(Of Integer)
Public Class MConceptoUsado
Public Property Consecutivo As Integer
Public Property CvePS As Integer
End Class
Private Function CalculaUsados(Consec As Integer, Optional LimpiarUsados As Boolean = True) As List(Of MConceptoUsado)
If Modalidad = "U" AndAlso LimpiarUsados Then
EliminarUsados(Consec)
End If
Dim ListaPScargo As New List(Of Integer)
Dim ListaPScargo As New List(Of MConceptoUsado)
Dim DTTamanios As DataTable = GlobalDTAcumTamaños()
Dim DTCvePSCostos = DTTamanios.FiltraParametros("", "", {"CvePSCargo"})
@@ -7828,7 +7858,7 @@ Partial Class PV
drowPsTamaños("PS").ToString, "", drowPsTamaños("PU").ToString.ToDecimal, 0, -1, "", drowPsTamaños("CveSubProyecto").ToString.ToEntero,
drowPsTamaños("SubProyecto").ToString, EsCargo:=True, ConsecPSPadre:=drowPsTamaños("ConsecPSPadre").ToString.ToEntero, EliminarDB:=CBool(drowPsTamaños("EliminarDB").ToString()))
If Consec > 0 Then
ListaPScargo.Add(drowPsTamaños("CvePS").ToString.ToEntero)
ListaPScargo.Add(New MConceptoUsado() With {.Consecutivo = Consec, .CvePS = drowPsTamaños("CvePS").ToString.ToEntero})
End If
End If
Next