-
This commit is contained in:
@@ -6432,6 +6432,7 @@ Partial Class PV
|
||||
CreaDTmpDTRecepcionUsados()
|
||||
CreaDTmpDTPolizaVirtual()
|
||||
DdlDistribuidor.setEsWebService(True)
|
||||
DdlDistribuidor.ddlWS.Attributes.Add("data-esdistribuidor", "1")
|
||||
DivChkAjuste.Visible = True
|
||||
|
||||
UpAjuste.Update()
|
||||
|
||||
@@ -1834,6 +1834,15 @@ Partial Class Ventas
|
||||
ViewState("CveEstatus") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property CveEstatusCotizacion As Integer
|
||||
Get
|
||||
Return (IfNull(ViewState("CveEstatusCotizacion"), "-1", ViewState("CveEstatusCotizacion"))).ToString().ToEntero()
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveEstatusCotizacion") = value
|
||||
End Set
|
||||
End Property
|
||||
Private Property DiasCredito As Integer
|
||||
Get
|
||||
Return ViewState("DiasCredito").ToString().ToEntero()
|
||||
@@ -2939,6 +2948,18 @@ Partial Class Ventas
|
||||
End If
|
||||
End If
|
||||
|
||||
If Request("CveCotizacion") IsNot Nothing AndAlso IfNull(Request("CveCotizacion"), 0).ToString().ToEntero() > 0 Then
|
||||
If UsuarioActual.Empresa.Funcionalidad(135).Contiene("1", "2") Then
|
||||
'VERIFICA SI NO ESTA AUTORIZADA
|
||||
If CveEstatusCotizacion <> 8 Then
|
||||
BtnEmitirImprimir.Enabled = False
|
||||
BtnEmitirImprimir.Visible = False
|
||||
Alert("La cotización no esta autorizada", TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
''EN REALIDAD SE OCUPAN ESTAS COSAS DENTRO DEL POSTABCK ???
|
||||
@@ -4431,6 +4452,8 @@ Partial Class Ventas
|
||||
' BtnGenerarRemision.Visible = If(CveEstatus = 10, False, True)
|
||||
' BtnsFacturar.Visible = True
|
||||
'End If
|
||||
ElseIf DbRowVenta("TipoDocto").ToString() = "Cot" AndAlso CveCotizacion > 0 Then
|
||||
CveEstatusCotizacion = DbRowVenta("CveEstatusFactura").ToString().ToEntero()
|
||||
End If
|
||||
|
||||
|
||||
@@ -8212,33 +8235,56 @@ Partial Class Ventas
|
||||
If Not ObjInventario.ActualizarEsDevolucionVenta(ObjFactura.CveVenta, 2) Then
|
||||
ErrorList.Add("No se pudo Cancelar el movimiento de almacen de la Factura")
|
||||
End If
|
||||
End If
|
||||
|
||||
'MARCAR VENTA ANTERIOR
|
||||
If Not ObjInventario.ActualizarEsDevolucionVenta(CveDevolucion, 2) Then
|
||||
ErrorList.Add("No se pudo Cancelar el movimiento de almacen de la Factura")
|
||||
End If
|
||||
|
||||
'MARCA LO PENDIENTE A NIVEL DETALLE
|
||||
Dim DtMovDetalles As DataTable = Nothing
|
||||
If ObjInventario.GetSaldoVentaDetalle(CveDevolucion, UsuarioActual.CveEmpresa) Then
|
||||
DtMovDetalles = ObjInventario.DtResultados.Copy()
|
||||
'MARCAR VENTA ANTERIOR
|
||||
If Not ObjInventario.ActualizarEsDevolucionVenta(CveDevolucion, 2) Then
|
||||
ErrorList.Add("No se pudo Cancelar el movimiento de almacen de la Factura")
|
||||
End If
|
||||
Else
|
||||
ErrorList.Add("No se pudo verificar los movimientos de almacen de la factura")
|
||||
End If
|
||||
'MARCA LO PENDIENTE A NIVEL DETALLE
|
||||
Dim DtMovDetalles As DataTable = Nothing
|
||||
If ObjInventario.GetSaldoVentaDetalle(CveDevolucion, UsuarioActual.CveEmpresa) Then
|
||||
DtMovDetalles = ObjInventario.DtResultados.Copy()
|
||||
Else
|
||||
ErrorList.Add("No se pudo verificar los movimientos de almacen de la factura")
|
||||
End If
|
||||
|
||||
If DtMovDetalles IsNot Nothing Then
|
||||
For Each Row As DataRow In DtMovDetalles.Rows
|
||||
Dim SaldoAlmacen As Decimal = Row("SaldoAlmacen").ToString().ToDecimal()
|
||||
If SaldoAlmacen < 0 Then
|
||||
If Not ObjInventario.UpdateEstatusAlmacen(Row("CveVentaDetalleNueva").ToString().ToEntero(), 1) Then
|
||||
ErrorList.Add("No se pudo actualizar el movimiento de almacen de la factura")
|
||||
'MARCAR VENTA ANTERIOR
|
||||
If Not ObjInventario.ActualizarEsDevolucionVenta(CveDevolucion, 2) Then
|
||||
ErrorList.Add("No se pudo Cancelar el movimiento de almacen de la Factura")
|
||||
End If
|
||||
|
||||
If DtMovDetalles IsNot Nothing Then
|
||||
|
||||
Dim CantidadTotal As Decimal = 0
|
||||
Dim TotalSalida As Decimal = 0
|
||||
|
||||
For Each Row As DataRow In DtMovDetalles.Rows
|
||||
Dim Cantidad As Decimal = Row("Cantidad").ToString().ToDecimal()
|
||||
Dim SaldoAlmacen As Decimal = Row("SaldoAlmacen").ToString().ToDecimal()
|
||||
Cantidad += Cantidad
|
||||
|
||||
If SaldoAlmacen < 0 AndAlso Cantidad = Math.Abs(SaldoAlmacen) Then
|
||||
TotalSalida += Math.Abs(SaldoAlmacen)
|
||||
If Not ObjInventario.UpdateEstatusAlmacen(Row("CveVentaDetalleNueva").ToString().ToEntero(), 1) Then
|
||||
ErrorList.Add("No se pudo actualizar el movimiento de almacen de la factura")
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
'SI SE VERIFICA QUE TODO ESTA SURTIDO, SE MARCA TODA LA FACTURA
|
||||
If CantidadTotal = Total Then
|
||||
If Not ObjInventario.ActualizarEsDevolucionVenta(ObjFactura.CveVenta, 2) Then
|
||||
ErrorList.Add("No se pudo Cancelar el movimiento de almacen de la Factura")
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
DtMovDetalles.Dispose()
|
||||
|
||||
End If
|
||||
|
||||
DtMovDetalles.Dispose()
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
@@ -11605,7 +11651,7 @@ Partial Class Ventas
|
||||
'INVENTARIOS
|
||||
If ErrorList.Count = 0 Then
|
||||
If Not EsNCAmortizacion AndAlso Not NCDescuento Then
|
||||
If GuardarVentaInventarios(ObjInventario, ObjConta, factura) Then
|
||||
If GuardarVentaInventarios(ObjInventario, ObjVentas, ObjConta, factura) Then
|
||||
ErrorList.Add("Ocurrio un error al Guardar Inventario")
|
||||
End If
|
||||
End If
|
||||
@@ -13232,7 +13278,7 @@ Partial Class Ventas
|
||||
End Try
|
||||
|
||||
End Function
|
||||
Private Function GuardarVentaInventarios(ObjInventario As ClsInventarios, ObjConta As ClsContabilidad, factura As Modelos.Factura) As Boolean
|
||||
Private Function GuardarVentaInventarios(ObjInventario As ClsInventarios, ObjVentas As ClsVentas, ObjConta As ClsContabilidad, factura As Modelos.Factura) As Boolean
|
||||
Dim OcurrioError As Boolean = False
|
||||
Try
|
||||
|
||||
@@ -13241,7 +13287,7 @@ Partial Class Ventas
|
||||
If RemisionesLista.Count > 0 AndAlso factura.TipoDocto.Contiene("Ing", "Rem") Then
|
||||
For Each CveRemision As Integer In RemisionesLista
|
||||
'El almacen general es el Primer Almacen de Material en la Sucursal
|
||||
If Not TraspasoAlmacen(ObjInventario, CveRemision, ObjConta, True, 9) Then
|
||||
If Not TraspasoAlmacen(ObjInventario, ObjVentas, CveRemision, ObjConta, True, 9) Then
|
||||
OcurrioError = True
|
||||
Exit For
|
||||
End If
|
||||
@@ -18072,8 +18118,12 @@ Partial Class Ventas
|
||||
If Not UsuarioActual.TienePermisoProceso(60) Then
|
||||
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing"))
|
||||
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant"))
|
||||
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Egs"))
|
||||
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Dev"))
|
||||
If Not UsuarioActual.TienePermisoProceso(175) Then
|
||||
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Egs"))
|
||||
End If
|
||||
If Not UsuarioActual.TienePermisoProceso(264) Then
|
||||
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Dev"))
|
||||
End If
|
||||
End If
|
||||
|
||||
'Puede remisionar
|
||||
@@ -18667,7 +18717,7 @@ Partial Class Ventas
|
||||
gvr.FCDropDownList("DdlUnidadMedida").DataBind()
|
||||
|
||||
End Sub
|
||||
Private Function TraspasoAlmacen(ByRef ObjInventario As ClsInventarios, CveRemision As Integer, ByRef ObjConta As ClsContabilidad, ConSalida As Boolean, ConceptoMovimiento As Integer) As Boolean
|
||||
Private Function TraspasoAlmacen(ByRef ObjInventario As ClsInventarios, ByRef ObjVentas As ClsVentas, CveRemision As Integer, ByRef ObjConta As ClsContabilidad, ConSalida As Boolean, ConceptoMovimiento As Integer) As Boolean
|
||||
Dim OcurrioError As Boolean = False
|
||||
Try
|
||||
Dim DtMovimientos As DataTable
|
||||
@@ -18749,9 +18799,9 @@ Partial Class Ventas
|
||||
MovDetalle = DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")}")
|
||||
Else
|
||||
If TieneMovimientosContrato Then
|
||||
MovDetalle = CuadrarFacturaMovimientos(DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")}"))
|
||||
MovDetalle = CuadrarFacturaMovimientos(ObjVentas, CveRemision, DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")}"))
|
||||
Else
|
||||
MovDetalle = CuadrarFacturaMovimientos(DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")} AND (TieneSalidaxFactura IS NULL OR SaldoAlmacen > 0)"))
|
||||
MovDetalle = CuadrarFacturaMovimientos(ObjVentas, CveRemision, DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")} AND (TieneSalidaxFactura IS NULL OR SaldoAlmacen > 0)"))
|
||||
End If
|
||||
|
||||
End If
|
||||
@@ -18763,26 +18813,12 @@ Partial Class Ventas
|
||||
Dim CveMovimientoSalidaPorTraspaso As Integer = -1
|
||||
Dim CveConceptoSalidaAlmacen As Integer = 3
|
||||
Dim CveAlmacenParaSalida As Integer = CveAlmacenEntrada
|
||||
|
||||
'SALIDA DEFINITIVA DEL SISTEMA
|
||||
If UsuarioActual.Empresa.Funcionalidad(575) = "1" Then
|
||||
CveConceptoSalidaAlmacen = 40
|
||||
CveAlmacenParaSalida = CveAlmacenSalida
|
||||
AplicaMovimientoDetalleEntrada = True
|
||||
''Le damos salida normal
|
||||
'If ConSalida Then
|
||||
' GeneroMovimientoAlmacen = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenSalida, 40, CveMoneda, CveVenta, AplicaMovimientoDetalleEntrada:=AplicaMovimientoDetalleEntrada, MovimientoPrePoliza:=True, ObjConta:=ObjConta) > 0
|
||||
|
||||
' If Not GeneroMovimientoAlmacen Then
|
||||
' OcurrioError = True
|
||||
' Exit For
|
||||
' End If
|
||||
|
||||
' If UsuarioActual.Empresa.Funcionalidad(573) = "1" Then
|
||||
' If Not GeneroMovimientoAlmacen Then
|
||||
' OcurrioError = Not GenerarMovimientoAlmacenVirtual(CveRemision, ObjInventario, ObjFactura)
|
||||
' End If
|
||||
' End If
|
||||
'End If
|
||||
Else
|
||||
'Le damos salida de apartado por traspaso
|
||||
CveMovimientoSalidaPorTraspaso = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenSalida, 8, CveMoneda, CveRemision, AplicaMovimientoDetalleEntrada:=AplicaMovimientoDetalleEntrada)
|
||||
@@ -18822,19 +18858,10 @@ Partial Class Ventas
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
Else
|
||||
OcurrioError = True
|
||||
Alert("Error traspaso almacen(sin Movtos. Detalle). Por favor comuniquese con atención SIG.", TipoMensaje.ToastError)
|
||||
End If
|
||||
|
||||
MovDetalle.Dispose()
|
||||
|
||||
'VERIFICA QUE SE HAYA GENERADO MOVIMIENTO DE ALMACEN
|
||||
If Not OcurrioError Then
|
||||
OcurrioError = Not GeneroMovimientoAlmacen
|
||||
End If
|
||||
|
||||
If OcurrioError Then
|
||||
Exit For
|
||||
End If
|
||||
@@ -18843,12 +18870,6 @@ Partial Class Ventas
|
||||
|
||||
End If
|
||||
|
||||
ElseIf ObjInventario.GetMovimientos(dr("CveMovimiento").ToString().ToEntero(), 3, -1, UsuarioActual.CveEmpresa) Then
|
||||
'Esquema viejo, evitamos que aparezca por surtir
|
||||
If Not ObjInventario.ActualizarEsDevolucionVenta(ObjFactura.CveVenta, 2) Then
|
||||
OcurrioError = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
|
||||
If OcurrioError Then
|
||||
@@ -18856,6 +18877,24 @@ Partial Class Ventas
|
||||
End If
|
||||
Next
|
||||
|
||||
'VERIFICA QUE SE HAYA GENERADO MOVIMIENTO DE ALMACEN
|
||||
If Not OcurrioError Then
|
||||
OcurrioError = Not GeneroMovimientoAlmacen
|
||||
End If
|
||||
|
||||
'VERIFICA SI YA SE GENERARON LAS SALIDAS DE ALMACEN NECESARIAS
|
||||
If Not OcurrioError AndAlso RemisionesLista.Count > 0 AndAlso DtRemConceptosSurtidos IsNot Nothing Then
|
||||
If DtRemConceptosSurtidos.SUMD("Surtido") <> DtRemConceptosSurtidos.SUMD("Cantidad") Then
|
||||
OcurrioError = True
|
||||
End If
|
||||
End If
|
||||
|
||||
If Not OcurrioError AndAlso ConSalida Then
|
||||
'Esquema viejo, evitamos que aparezca por surtir
|
||||
If Not ObjInventario.ActualizarEsDevolucionVenta(ObjFactura.CveVenta, 2) Then
|
||||
OcurrioError = True
|
||||
End If
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
@@ -18864,31 +18903,59 @@ Partial Class Ventas
|
||||
OcurrioError = True
|
||||
End If
|
||||
|
||||
'LIMPIAR EL DT DE CONCEPTOS SURTIDOS
|
||||
If DtRemConceptosSurtidos IsNot Nothing Then
|
||||
DtRemConceptosSurtidos.Clear()
|
||||
DtRemConceptosSurtidos = Nothing
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
OcurrioError = True
|
||||
OnError("Ocurrió un error al realizar el traspaso", ex)
|
||||
End Try
|
||||
Return Not OcurrioError
|
||||
End Function
|
||||
Private Function CuadrarFacturaMovimientos(MovDetalle As DataTable) As DataTable
|
||||
Private Function CuadrarFacturaMovimientos(ByRef ObjVentas As ClsVentas, CveRemision As Integer, MovDetalle As DataTable) As DataTable
|
||||
Dim MovDTCuadrados As New DataTable
|
||||
MovDTCuadrados = MovDetalle.Clone
|
||||
MovDTCuadrados.Clear()
|
||||
|
||||
'Llenamos el DT solo si es primera llamada
|
||||
If DtRemConceptosSurtidos Is Nothing Then
|
||||
DtRemConceptosSurtidos = New DataTable
|
||||
DtRemConceptosSurtidos.Columns.Add("CveVentaDetalle", GetType(Integer))
|
||||
DtRemConceptosSurtidos.Columns.Add("Cantidad", GetType(Decimal))
|
||||
DtRemConceptosSurtidos.Columns.Add("Surtido", GetType(Decimal))
|
||||
Dim DtDetalleRemision As DataTable = Nothing
|
||||
Dim StrCveVentasDetalle As New StringBuilder()
|
||||
|
||||
For Each dr As DataRow In DtRemisionesTmpDT.Rows
|
||||
Dim dtr As DataRow = DtRemConceptosSurtidos.NewRow
|
||||
dtr("CveVentaDetalle") = dr("CveVentaDetalle")
|
||||
dtr("Cantidad") = dr("Cantidad")
|
||||
dtr("Surtido") = 0
|
||||
DtRemConceptosSurtidos.Rows.Add(dtr)
|
||||
If ObjVentas.GetVentaDetalle(CveRemision) Then
|
||||
DtDetalleRemision = ObjVentas.DtResultados.FiltraParametros("", DistinctColumns:={"CveVenta", "CveVentaDetalle"})
|
||||
End If
|
||||
|
||||
For Each RowDetalle As DataRow In DtDetalleRemision.Rows
|
||||
StrCveVentasDetalle.AppendFormat("{0},", RowDetalle("CveVentaDetalle"))
|
||||
Next
|
||||
|
||||
If StrCveVentasDetalle.Length > 0 Then
|
||||
StrCveVentasDetalle.Remove(StrCveVentasDetalle.Length - 1, 1)
|
||||
End If
|
||||
|
||||
If DtDetalleRemision IsNot Nothing Then
|
||||
|
||||
DtRemConceptosSurtidos = New DataTable
|
||||
DtRemConceptosSurtidos.Columns.Add("CveRemision", GetType(Integer))
|
||||
DtRemConceptosSurtidos.Columns.Add("CveVentaDetalle", GetType(Integer))
|
||||
DtRemConceptosSurtidos.Columns.Add("Cantidad", GetType(Decimal))
|
||||
DtRemConceptosSurtidos.Columns.Add("Surtido", GetType(Decimal))
|
||||
|
||||
'VERIFICA SOLO LOS QUE SON TIPO PRODUCTOS
|
||||
For Each dr As DataRow In DtRemisionesTmpDT.FiltraParametros($"CveTipoPS = 2 AND CveVentaDetalle IN ({StrCveVentasDetalle.ToString()})").Rows
|
||||
Dim dtr As DataRow = DtRemConceptosSurtidos.NewRow
|
||||
dtr("CveRemision") = CveRemision
|
||||
dtr("CveVentaDetalle") = dr("CveVentaDetalle")
|
||||
dtr("Cantidad") = dr("Cantidad")
|
||||
dtr("Surtido") = 0
|
||||
DtRemConceptosSurtidos.Rows.Add(dtr)
|
||||
Next
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
For Each dr As DataRow In MovDetalle.Rows
|
||||
@@ -29635,6 +29702,9 @@ Partial Class Ventas
|
||||
LbAgregar.Enabled = True
|
||||
LnkAgregarPyME.Enabled = True
|
||||
|
||||
ImgDescPU.Attributes.Add("onclick", "javascript:$('#ModalDescuento').modal(); $get('LblTitulo1').style.display = ''; $get('LblTitulo2').style.display = 'none'; $get('LblTituloTipo1').style.display = ''; $get('LblTituloTipo2').style.display = 'none'; $get('HdnTipoDescuento').value = '0'; $get('LblPrecio1').style.display = ''; $get('LblTotalPS1').style.display = 'none'; $get('LblSubTotal1').style.display = 'none'; $get('LblAmort').style.display = 'none'; $get('BtnAplicarDescP').style.display = ''; $get('BtnAplicarDescG').style.display = 'none'; $get('TrMotivoDescuento').style.display = '';")
|
||||
ImgDescConcepto.Attributes.Add("onclick", "javascript:$('#ModalDescuento').modal(); $get('LblTitulo1').style.display = ''; $get('LblTitulo2').style.display = 'none'; $get('LblTituloTipo1').style.display = ''; $get('LblTituloTipo2').style.display = 'none'; $get('HdnTipoDescuento').value = '1'; $get('LblPrecio1').style.display = 'none'; $get('LblTotalPS1').style.display = ''; $get('LblSubTotal1').style.display = 'none'; $get('LblAmort').style.display = 'none'; $get('BtnAplicarDescP').style.display = ''; $get('BtnAplicarDescG').style.display = 'none'; $get('TrMotivoDescuento').style.display = '';")
|
||||
ImgDescTotal.Visible = False
|
||||
ImgDescTotal.Attributes.Add("onclick", "javascript:$('#ModalDescuento').modal(); $get('LblTitulo1').style.display = ''; $get('LblTitulo2').style.display = 'none'; $get('LblTituloTipo1').style.display = ''; $get('LblTituloTipo2').style.display = 'none'; $get('HdnTipoDescuento').value = '2'; $get('LblPrecio1').style.display = 'none'; $get('LblTotalPS1').style.display = 'none'; $get('LblSubTotal1').style.display = ''; $get('LblAmort').style.display = 'none'; $get('BtnAplicarDescP').style.display = 'none'; $get('BtnAplicarDescG').style.display = ''; $get('TrMotivoDescuento').style.display = '';")
|
||||
|
||||
TxtMotivoDescuento.Enabled = True
|
||||
|
||||
Reference in New Issue
Block a user