Optimizacion de carga de factura en modelos, validacion de recepcion de usados
This commit is contained in:
@@ -379,7 +379,7 @@ Namespace Modelos
|
|||||||
End If
|
End If
|
||||||
Timbre = New CFDITimbre
|
Timbre = New CFDITimbre
|
||||||
End Sub
|
End Sub
|
||||||
Public Sub New(UsuarioActual As Usuario, CveVenta As Integer, CveEmpresa As Integer, Optional DirectorioServidor As String = "", Optional EsCancelacion As Boolean = False)
|
Public Sub New(UsuarioActual As Usuario, CveVenta As Integer, CveEmpresa As Integer, Optional DirectorioServidor As String = "", Optional EsCancelacion As Boolean = False, Optional CargaDTDetalle As Boolean = True, Optional CargaDatosCliente As Boolean = True, Optional CargaDatosRelacionados As Boolean = True)
|
||||||
Me.UsuarioActual = UsuarioActual
|
Me.UsuarioActual = UsuarioActual
|
||||||
Me.CveVenta = CveVenta
|
Me.CveVenta = CveVenta
|
||||||
Me.CveEmpresa = CveEmpresa
|
Me.CveEmpresa = CveEmpresa
|
||||||
@@ -397,9 +397,12 @@ Namespace Modelos
|
|||||||
|
|
||||||
SetMetodoPago()
|
SetMetodoPago()
|
||||||
SetMoneda()
|
SetMoneda()
|
||||||
SetSubProyecto()
|
|
||||||
SetSubProyectoMatriz()
|
If Me.CveSubProyecto > 0 Then
|
||||||
SetCliente()
|
SetSubProyecto()
|
||||||
|
SetSubProyectoMatriz()
|
||||||
|
End If
|
||||||
|
|
||||||
If ObjVentas.DtResultados.Rows(0)("IEPS").ToString.ToDecimal <= 0 Then
|
If ObjVentas.DtResultados.Rows(0)("IEPS").ToString.ToDecimal <= 0 Then
|
||||||
Me.VentaDesglosaIEPS = False
|
Me.VentaDesglosaIEPS = False
|
||||||
Else
|
Else
|
||||||
@@ -408,11 +411,23 @@ Namespace Modelos
|
|||||||
SetTotales(ObjVentas.DtResultados, ObjVentas)
|
SetTotales(ObjVentas.DtResultados, ObjVentas)
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
If ObjVentas.GetVentaDetalle(CveVenta) Then
|
|
||||||
Me.DtDetalle = ObjVentas.DtResultados.Copy()
|
If CargaDTDetalle Then
|
||||||
|
If ObjVentas.GetVentaDetalle(CveVenta) Then
|
||||||
|
Me.DtDetalle = ObjVentas.DtResultados.Copy()
|
||||||
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
ObjVentas.Dispose()
|
ObjVentas.Dispose()
|
||||||
IniciaValoresVentas(EsCancelacion)
|
|
||||||
|
If CargaDatosCliente Then
|
||||||
|
SetCliente()
|
||||||
|
End If
|
||||||
|
|
||||||
|
If CargaDatosRelacionados Then
|
||||||
|
IniciaValoresVentas(EsCancelacion)
|
||||||
|
End If
|
||||||
|
|
||||||
If String.IsNullOrEmpty(DirectorioServidor) Then
|
If String.IsNullOrEmpty(DirectorioServidor) Then
|
||||||
DirectorioServidor = ModExtensiones.DirectorioBaseEmpresas
|
DirectorioServidor = ModExtensiones.DirectorioBaseEmpresas
|
||||||
End If
|
End If
|
||||||
@@ -6620,7 +6635,7 @@ Namespace Modelos
|
|||||||
Public Property ObservacionesAlmacen As String
|
Public Property ObservacionesAlmacen As String
|
||||||
Public Property CveOC As Integer = -1
|
Public Property CveOC As Integer = -1
|
||||||
Public Property CveCuentaTerminal As Integer = -1
|
Public Property CveCuentaTerminal As Integer = -1
|
||||||
Public Property ClienteEsDistribuidor As Boolean = False
|
Public Property EsDistribuidor As Boolean = False
|
||||||
Public Property AplicaGastoContrato As Boolean = False
|
Public Property AplicaGastoContrato As Boolean = False
|
||||||
Public Property FacturaDevolucion As Modelos.Factura
|
Public Property FacturaDevolucion As Modelos.Factura
|
||||||
Public Property CveOrdenProduccion As Integer = -1
|
Public Property CveOrdenProduccion As Integer = -1
|
||||||
@@ -7046,7 +7061,7 @@ Namespace Modelos
|
|||||||
|
|
||||||
Public Sub SetSubProyecto()
|
Public Sub SetSubProyecto()
|
||||||
If CveSubProyecto > 0 AndAlso UsuarioActual IsNot Nothing Then
|
If CveSubProyecto > 0 AndAlso UsuarioActual IsNot Nothing Then
|
||||||
SubProyecto = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero($"CveSubProyecto = {CveSubProyecto}"))
|
SubProyecto = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1, CveSubProyecto:=CveSubProyecto, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero(""))
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
Public Sub SetSubProyectoMatriz()
|
Public Sub SetSubProyectoMatriz()
|
||||||
|
|||||||
@@ -613,7 +613,7 @@ Partial Class Inventarios_RecepcionUsados
|
|||||||
CargaPS()
|
CargaPS()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub CargaAlmacen(Optional CveSubProyecto As Integer = -1, Optional TipoAlmacen As Integer = 22)
|
Private Sub CargaAlmacen(Optional CveSubProyecto As Integer = -1, Optional TipoAlmacen As Integer = 22, Optional BloquearAlmacen As Boolean = False)
|
||||||
DdlAlmacen.Items.Clear()
|
DdlAlmacen.Items.Clear()
|
||||||
'Llenar el dropdownlist de almacén
|
'Llenar el dropdownlist de almacén
|
||||||
Dim dt As DataTable = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoAlmacen:=TipoAlmacen)
|
Dim dt As DataTable = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoAlmacen:=TipoAlmacen)
|
||||||
@@ -633,6 +633,9 @@ Partial Class Inventarios_RecepcionUsados
|
|||||||
Dim CveAlmacen As Integer = dt.FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto = {CveSubProyecto}").ToEntero()
|
Dim CveAlmacen As Integer = dt.FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto = {CveSubProyecto}").ToEntero()
|
||||||
If CveAlmacen > 0 Then
|
If CveAlmacen > 0 Then
|
||||||
DdlAlmacen.SelectedValueExist(CveAlmacen)
|
DdlAlmacen.SelectedValueExist(CveAlmacen)
|
||||||
|
If BloquearAlmacen Then
|
||||||
|
DdlAlmacen.Enabled = False
|
||||||
|
End If
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
@@ -766,10 +769,13 @@ Partial Class Inventarios_RecepcionUsados
|
|||||||
TmpDTAjustes.Rows.Clear()
|
TmpDTAjustes.Rows.Clear()
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
RblUsadosAjuste.Enabled = True
|
||||||
|
|
||||||
CveRemisionRecibida = -1
|
CveRemisionRecibida = -1
|
||||||
EsDistribuidor = False
|
EsDistribuidor = False
|
||||||
DdlClientes.SelectedValueExist("-1")
|
InicializaClientes(True)
|
||||||
DdlClientes_SelectedIndexChanged(DdlClientes, EventArgs.Empty)
|
DdlClientes.Enabled = True
|
||||||
|
ChkClientesTodos.Enabled = True
|
||||||
|
|
||||||
SiguienteFolio()
|
SiguienteFolio()
|
||||||
|
|
||||||
@@ -2024,15 +2030,17 @@ Partial Class Inventarios_RecepcionUsados
|
|||||||
Protected Sub DdlClientes_SelectedIndexChanged(sender As Object, e As EventArgs)
|
Protected Sub DdlClientes_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||||
CambiaCliente()
|
CambiaCliente()
|
||||||
End Sub
|
End Sub
|
||||||
Private Sub CambiaCliente()
|
Private Sub CambiaCliente(Optional CargaSucursales As Boolean = True, Optional CargaFacturas As Boolean = True)
|
||||||
DivClienteSucursal.Visible = False
|
|
||||||
DdlClientesSucursales.Items.Clear()
|
|
||||||
|
|
||||||
If DdlClientes.SelectedValue.ToEntero > 0 Then
|
If DdlClientes.SelectedValue.ToEntero > 0 Then
|
||||||
Me.EsDistribuidor = CBool(GlobalDTCliente(UsuarioActual.CveEmpresa, CveCliente:=DdlClientes.SelectedValue.ToEntero()).FiltroPrimeroValor("EsDistribuidor", ""))
|
Me.EsDistribuidor = CBool(GlobalDTCliente(UsuarioActual.CveEmpresa, CveCliente:=DdlClientes.SelectedValue.ToEntero()).FiltroPrimeroValor("EsDistribuidor", ""))
|
||||||
|
If CargaSucursales Then
|
||||||
CargaSucursalesCliente()
|
DivClienteSucursal.Visible = False
|
||||||
CargaFacturasCliente()
|
DdlClientesSucursales.Items.Clear()
|
||||||
|
CargaSucursalesCliente()
|
||||||
|
End If
|
||||||
|
If CargaFacturas Then
|
||||||
|
CargaFacturasCliente()
|
||||||
|
End If
|
||||||
End If
|
End If
|
||||||
UpGenerales.Update()
|
UpGenerales.Update()
|
||||||
End Sub
|
End Sub
|
||||||
@@ -2250,7 +2258,12 @@ Partial Class Inventarios_RecepcionUsados
|
|||||||
Me.CveRemisionRecibida = -1
|
Me.CveRemisionRecibida = -1
|
||||||
Me.CveRemisionRecibida = CType(CType(sender, LinkButton).NamingContainer, GridViewRow).DataKey("CveVenta").ToEntero()
|
Me.CveRemisionRecibida = CType(CType(sender, LinkButton).NamingContainer, GridViewRow).DataKey("CveVenta").ToEntero()
|
||||||
|
|
||||||
RecibirRemision()
|
If Me.CveRemisionRecibida > 0 Then
|
||||||
|
RecibirRemision()
|
||||||
|
Else
|
||||||
|
Alert("No se pudo recibir la remisión", TipoMensaje.MsgError)
|
||||||
|
End If
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub RecibirRemision()
|
Private Sub RecibirRemision()
|
||||||
@@ -2261,7 +2274,7 @@ Partial Class Inventarios_RecepcionUsados
|
|||||||
Me.ObjFactura = Nothing
|
Me.ObjFactura = Nothing
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Me.ObjFactura = New Modelos.Factura(UsuarioActual, CveRemisionRecibida, UsuarioActual.CveEmpresa, DirectorioServidor:=ModExtensiones.DirectorioBaseEmpresas)
|
Me.ObjFactura = New Modelos.Factura(UsuarioActual, CveRemisionRecibida, UsuarioActual.CveEmpresa, DirectorioServidor:=ModExtensiones.DirectorioBaseEmpresas, CargaDatosCliente:=False, CargaDatosRelacionados:=False)
|
||||||
|
|
||||||
If Me.ObjFactura IsNot Nothing Then
|
If Me.ObjFactura IsNot Nothing Then
|
||||||
|
|
||||||
@@ -2271,28 +2284,15 @@ Partial Class Inventarios_RecepcionUsados
|
|||||||
Dim DtUsados As DataTable = Nothing
|
Dim DtUsados As DataTable = Nothing
|
||||||
Dim CveCliente As Integer = -1
|
Dim CveCliente As Integer = -1
|
||||||
|
|
||||||
|
EsDistribuidor = ObjFactura.EsDistribuidor
|
||||||
|
CveCliente = Me.ObjFactura.CveCliente
|
||||||
|
|
||||||
Dim ObjVentas As New ClsVentas
|
Dim ObjVentas As New ClsVentas
|
||||||
If ObjVentas.GetVenta(CveRemisionRecibida, UsuarioActual.CveEmpresa) AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then
|
|
||||||
EsDistribuidor = CBool(ObjVentas.DtResultados.Rows(0)("EsDistribuidor").ToString())
|
|
||||||
CveCliente = ObjVentas.DtResultados.Rows(0)("CveCliente").ToString().ToEntero()
|
|
||||||
End If
|
|
||||||
|
|
||||||
If ObjVentas.GetVentasUsadosDetalle(CveRemisionRecibida) Then
|
If ObjVentas.GetVentasUsadosDetalle(CveRemisionRecibida) Then
|
||||||
DtUsados = ObjVentas.DtResultados.Copy()
|
DtUsados = ObjVentas.DtResultados.Copy()
|
||||||
End If
|
End If
|
||||||
|
|
||||||
'RELACIONA LA VENTA DETALLA DE LA REMISION
|
|
||||||
If DtUsados IsNot Nothing Then
|
|
||||||
DtUsados.Columns.Add(New DataColumn("CveVentaDetalle", GetType(Integer)))
|
|
||||||
For Each RowUsado As DataRow In DtUsados.Rows
|
|
||||||
Dim CveVentaDetalle As Integer = Me.ObjFactura.DtDetalle.FiltroPrimeroValor("CveVentaDetalle", $"EsCargo = 1 AND Cantidad = {RowUsado("Cantidad")} AND CvePS = {RowUsado("CvePS")}").ToEntero()
|
|
||||||
If CveVentaDetalle > 0 Then
|
|
||||||
RowUsado("CveVentaDetalle") = CveVentaDetalle
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
|
|
||||||
End If
|
|
||||||
|
|
||||||
Dim RecepcionValida As Boolean = True
|
Dim RecepcionValida As Boolean = True
|
||||||
|
|
||||||
If ObjVentas.GetVentasUsados(ObjFactura.CveVenta, ObjFactura.CveSubProyecto, ObjFactura.Fecha, UsuarioActual.CveEmpresa, ServicioDomicilio:=ObjFactura.ServicioDomicilio) Then
|
If ObjVentas.GetVentasUsados(ObjFactura.CveVenta, ObjFactura.CveSubProyecto, ObjFactura.Fecha, UsuarioActual.CveEmpresa, ServicioDomicilio:=ObjFactura.ServicioDomicilio) Then
|
||||||
@@ -2312,22 +2312,38 @@ Partial Class Inventarios_RecepcionUsados
|
|||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
'RELACIONA LA VENTA DETALLA DE LA REMISION
|
||||||
|
If DtUsados IsNot Nothing Then
|
||||||
|
DtUsados.Columns.Add(New DataColumn("CveVentaDetalle", GetType(Integer)))
|
||||||
|
For Each RowUsado As DataRow In DtUsados.Rows
|
||||||
|
Dim CveVentaDetalle As Integer = Me.ObjFactura.DtDetalle.FiltroPrimeroValor("CveVentaDetalle", $"EsCargo = 1 AND Cantidad = {RowUsado("Cantidad")} AND CvePS = {RowUsado("CvePS")}").ToEntero()
|
||||||
|
If CveVentaDetalle > 0 Then
|
||||||
|
RowUsado("CveVentaDetalle") = CveVentaDetalle
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
|
||||||
If ObjFactura.CveSubProyecto > 0 Then
|
If ObjFactura.CveSubProyecto > 0 Then
|
||||||
CargaAlmacen(CveSubProyecto:=ObjFactura.CveSubProyecto)
|
CargaAlmacen(CveSubProyecto:=ObjFactura.CveSubProyecto, BloquearAlmacen:=True)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If CveCliente > 0 Then
|
If CveCliente > 0 Then
|
||||||
|
DivCliente.Visible = True
|
||||||
|
|
||||||
DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveCliente = {0}", CveCliente))
|
DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveCliente = {0}", CveCliente))
|
||||||
DdlClientes.DataBind()
|
DdlClientes.DataBind()
|
||||||
|
|
||||||
DdlClientes.SelectedValueExist(CveCliente)
|
DdlClientes.SelectedValueExist(CveCliente)
|
||||||
|
CambiaCliente(False, False)
|
||||||
|
|
||||||
|
DdlClientes.Enabled = False
|
||||||
|
ChkClientesTodos.Enabled = False
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
RblUsadosAjuste.Enabled = False
|
||||||
|
|
||||||
'SI ES DISTRIBUIDOR VAMOS A GENERAR LA REMISION DE NOTA DE CREDITO
|
'SI ES DISTRIBUIDOR VAMOS A GENERAR LA REMISION DE NOTA DE CREDITO
|
||||||
If EsDistribuidor Then
|
If EsDistribuidor Then
|
||||||
DivCliente.Visible = True
|
|
||||||
DdlClientes.SelectedValueExist(CveCliente)
|
|
||||||
DdlClientes_SelectedIndexChanged(DdlClientes, EventArgs.Empty)
|
|
||||||
|
|
||||||
If Me.ObjRemisionNC IsNot Nothing Then
|
If Me.ObjRemisionNC IsNot Nothing Then
|
||||||
Me.ObjRemisionNC.Dispose()
|
Me.ObjRemisionNC.Dispose()
|
||||||
Me.ObjRemisionNC = Nothing
|
Me.ObjRemisionNC = Nothing
|
||||||
@@ -2337,9 +2353,6 @@ Partial Class Inventarios_RecepcionUsados
|
|||||||
'CreaRemisionNC(ObjFactura.CveCliente, ObjFactura.CveSubProyecto, ObjFactura.CveMoneda)
|
'CreaRemisionNC(ObjFactura.CveCliente, ObjFactura.CveSubProyecto, ObjFactura.CveMoneda)
|
||||||
DivTotal.Visible = True
|
DivTotal.Visible = True
|
||||||
End If
|
End If
|
||||||
Else
|
|
||||||
'DivCliente.Visible = False
|
|
||||||
'DivFactura.Visible = False
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If DtUsados IsNot Nothing Then
|
If DtUsados IsNot Nothing Then
|
||||||
|
|||||||
Reference in New Issue
Block a user