diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index c691aaab8..9d6b88538 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -1599,7 +1599,7 @@
- Salida Almacen +
diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 0fae9f162..62b4161d8 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -6245,7 +6245,7 @@ Partial Class Ventas End If - If CveVenta > 0 And DdlTipoComprobante.SelectedValue <> "Cot" Then + If (CveVenta > 0 And DdlTipoComprobante.SelectedValue <> "Cot") AndAlso Not AplicaDevolucion Then If e.Row.DBCampo("CveConcepto").ToEntero = 3 Then CveAlmacenDevolucion = e.Row.DBCampo("CveAlmacen").ToEntero e.Row.FCCheckBox("cbInv").Visible = False End If @@ -10997,9 +10997,9 @@ Partial Class Ventas Dim OcurrioError As Boolean = False Try - If UsuarioActual.Empresa.UsaInventarios AndAlso factura.TipoDocto.Contiene("Ing", "Egs", "Rem") Then + If UsuarioActual.Empresa.UsaInventarios AndAlso factura.TipoDocto.Contiene("Ing", "Egs", "Rem", "Dev") Then - If RemisionesLista.Count > 0 Then + If RemisionesLista.Count > 0 AndAlso factura.TipoDocto.Contiene("Ing", "Egs", "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 @@ -11011,8 +11011,28 @@ Partial Class Ventas If GvInv.Rows.Cast(Of GridViewRow)().Count(Function(gvr) gvr.FCCheckBox("cbInv").Checked) > 0 Then + Dim Filtro As String = "" + Select Case factura.TipoDocto + Case "Ing", "Ped" + Filtro = "CveConcepto IN (3,40)" + Case "Dev" + Filtro = "CveConcepto IN (3,40)" + Case Else + Filtro = "CveConcepto = 9" + End Select + + Dim DtExistencias As DataTable = Nothing + If ObjInventario.GetInv_Mov(Me.CveVentaDevolucion, UsuarioActual.CveEmpresa) Then + DtExistencias = ObjInventario.DtResultados.FiltraParametros($"CvePS Is Not NULL AND {Filtro}") + End If + + Dim CveConceptoAlmacen As Integer = 3 + If factura.TipoDocto = "Dev" Then + CveConceptoAlmacen = 18 + End If + Dim CveAlmacen = ddlAlmacen.SelectedValue.ToEntero - Dim CveMovimientoInventario As Integer = ObjInventario.AddMovimiento(CveAlmacen, 3, factura.CveMoneda, factura.Fecha, -1, factura.CveUsuario, factura.CveEmpresa, -1, factura.CveVenta, -1, -1, Modulo:="Vta/E1") + Dim CveMovimientoInventario As Integer = ObjInventario.AddMovimiento(CveAlmacen, CveConceptoAlmacen, factura.CveMoneda, factura.Fecha, -1, factura.CveUsuario, factura.CveEmpresa, -1, factura.CveVenta, -1, -1, Modulo:="Vta/E1") If CveMovimientoInventario <= 0 Then OcurrioError = True @@ -11024,8 +11044,7 @@ Partial Class Ventas Dim CveUnidad As Integer Dim CveProducto As Integer Dim Existencia As Double - 'Dim Pu As Double - 'DtInv.Clone() + Dim PU As Decimal = 0 Dim DtEquivalencias As DataTable @@ -11042,7 +11061,7 @@ Partial Class Ventas Exit For End If - If UsuarioActual.CveEmpresa.Contiene({72, 80, 119}) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing") AndAlso Dr("EntregaDirecta").ToString.ToEntero < 1 Then + If CveConceptoAlmacen = 3 AndAlso UsuarioActual.CveEmpresa.Contiene({72, 80, 119}) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing") AndAlso Dr("EntregaDirecta").ToString.ToEntero < 1 Then Existencia = ObjInventario.GetExistenciasPS(CveProducto, CveUnidad, UsuarioActual.CveEmpresa, CveAlmacen, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero, CveVendedor:=DdlVendedor.SelectedValue.ToEntero, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeAdelantado:=1, RestringirAlmacenes:=1, ExcluyeApartados:=1) If Existencia < Cantidad Then OcurrioError = True @@ -11066,7 +11085,17 @@ Partial Class Ventas End If If CveProducto > 0 Then - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Cantidad, CveUnidad, CveProducto, 0, -1, SerieLote:=Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then + 'SI ES ENTRADA DEBE TENER EL COSTO DE LA SALIDA + If CveConceptoAlmacen.Contiene(18) Then + PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero}").ToString.ToDecimal + If PU <= 0 Then + ErrorList.Add("Ocurrió un error al obtener el costo.
") + OcurrioError = True + Exit For + End If + End If + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Cantidad, CveUnidad, CveProducto, PU, -1, SerieLote:=Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then OcurrioError = True ErrorList.Add("Ocurrió un error al agregar los Movimientos de salida al Inventario.
") Exit For @@ -11078,6 +11107,7 @@ Partial Class Ventas End If End If + PU = 0 i = i + 1 Next @@ -11086,6 +11116,15 @@ Partial Class Ventas Dim DtCostos As DataTable = Nothing Dim ValorInventario As Decimal = 0 Dim TotalCosto As Decimal = 0 + + Dim TipoMovto68 As Boolean = True + Dim TipoMovto69 As Boolean = False + + If CveConceptoAlmacen.Contiene(18) Then + TipoMovto68 = False + TipoMovto69 = True + End If + If ObjInventario.GetMovimientosDetalle(CveMovimientoInventario, UsuarioActual.CveEmpresa) Then DtCostos = ObjInventario.DtResultados TotalCosto = DtCostos.SUMD("Total").RoundSQL @@ -11110,7 +11149,7 @@ Partial Class Ventas CveCuenta = GlobalDTClasificaciones(factura.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero If ValorInventario <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, False, ValorInventario, factura.SerieFolio, 69, factura.SerieFolio, factura.Fecha, IdCtaContable, -1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, CveSubProyecto:=factura.CveSubProyecto, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=ValorInventario, CveCuenta:=CveCuenta) Then + If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, TipoMovto69, ValorInventario, factura.SerieFolio, 69, factura.SerieFolio, factura.Fecha, IdCtaContable, -1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, CveSubProyecto:=factura.CveSubProyecto, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=ValorInventario, CveCuenta:=CveCuenta) Then OcurrioError = True End If End If @@ -11120,15 +11159,16 @@ Partial Class Ventas IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", CveAlmacen)).ToEntero If TotalCosto <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, True, TotalCosto, factura.SerieFolio, 68, factura.SerieFolio, factura.Fecha, IdCtaContable, -1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=TotalCosto, CveCuenta:=CveCuenta, CveSubProyecto:=factura.CveSubProyecto) Then + If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, TipoMovto68, TotalCosto, factura.SerieFolio, 68, factura.SerieFolio, factura.Fecha, IdCtaContable, -1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=TotalCosto, CveCuenta:=CveCuenta, CveSubProyecto:=factura.CveSubProyecto) Then OcurrioError = True End If End If - factura.Inv_CveMovimiento = CveMovimientoInventario - factura.Inv_ValorInventario = ValorInventario + End If + factura.Inv_CveMovimiento = CveMovimientoInventario + factura.Inv_ValorInventario = ValorInventario End If End If @@ -17651,17 +17691,17 @@ Partial Class Ventas End Sub Private Function ValidaPagosContado() As Boolean Dim Retorno = False + Dim Total As Decimal = TxtTotal.Text.ToDecimal() 'SI LA VENTA ES NUEVA VALIDAR TAMBIEN LOS PAGOS DE CONTADO If UsuarioActual.CveEmpresa = 141 AndAlso CveVenta <= 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant") Then - If Not PermiteCredito AndAlso (DtPagos Is Nothing OrElse DtPagos.Rows.Count = 0) Then + If Not PermiteCredito AndAlso (DtPagos Is Nothing OrElse DtPagos.Rows.Count = 0) AndAlso Total > 0 Then Alert("Es necesario especificar un pago.", TipoMensaje.MsgAdvertencia) Retorno = True Return Retorno End If - If Not PermiteCredito AndAlso DtPagos IsNot Nothing AndAlso DtPagos.Rows.Count > 0 Then - Dim Total As Decimal = TxtTotal.Text.ToDecimal() + If Not PermiteCredito AndAlso (DtPagos IsNot Nothing AndAlso DtPagos.Rows.Count > 0) AndAlso Total > 0 Then Dim TotalPago As Decimal = DtPagos.SUM("Importe").ToDecimal() If TotalPago < Total Then @@ -17682,8 +17722,8 @@ Partial Class Ventas If UsuarioActual.CveEmpresa = 141 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant") Then - If Not PermiteCredito AndAlso DtPagos IsNot Nothing AndAlso DtPagos.Rows.Count > 0 Then - Dim Total As Decimal = TxtTotal.Text.ToDecimal() + If Not PermiteCredito AndAlso DtPagos IsNot Nothing AndAlso DtPagos.Rows.Count > 0 AndAlso Total > 0 Then + Dim TotalPago As Decimal = DtPagos.SUM("Importe").ToDecimal() If TotalPago < Total Then @@ -22200,47 +22240,34 @@ Partial Class Ventas 'AGREGAR LOS USADOS EN LA DEVOLUCION CalculaUsados(DtUsados) - 'If DtUsados IsNot Nothing AndAlso DtUsados.Rows.Count > 0 Then - ' Dim DtPSVenta As DataTable = TmpDT.Copy() - ' For Each Row As DataRow In DtPSVenta.Rows - ' Dim RowCargo As DataRow = DTTamanios.FiltroPrimero($"CveTamaño = { Row("CveTamaño").ToString.ToEntero } ") - ' If RowCargo IsNot Nothing Then - ' Dim CvePSCargo As Integer = RowCargo("CvePSCargo").ToString.ToEntero - - ' For Each RowUsado As DataRow In DtUsados.FiltraParametros($"CvePS = {CvePSCargo}").Rows - ' 'If drow("CvePS").ToString.ToEntero = drow2("CvePSCargo").ToString.ToEntero Then - ' 'End If - ' Dim Cantidad As Decimal = RowUsado("Cantidad").ToString().ToDecimal() - ' Dim Descuento As Decimal = Cantidad * RowUsado("Descuento").ToString.ToDecimal / RowUsado("Cantidad").ToString.ToDecimal - ' Dim PU As Decimal = RowUsado("PU").ToString().ToDecimal() - ' Dim Total As Decimal = (Cantidad * PU) - ' Dim TotalImpuestos As Decimal = (Cantidad * PU) - Descuento - ' Dim ImporteIVA As Decimal = TotalImpuestos * RowUsado("PorcentajeIVA").ToString.ToDecimal - ' Dim ImporteRetIVA As Decimal = TotalImpuestos * RowUsado("PorcentajeRetIVA").ToString.ToDecimal - ' Dim ImporteRetISR As Decimal = TotalImpuestos * RowUsado("PorcentajeRetISR").ToString.ToDecimal - ' Dim ImporteIEPS As Decimal = TotalImpuestos * RowUsado("PorcentajeIEPS").ToString.ToDecimal - - ' AgregaTempDT(TmpDT, RowUsado("CvePS").ToString.ToEntero, RowUsado("PS").ToString, RowUsado("Codigo").ToString, RowUsado("CodigoPS").ToString, - ' RowUsado("CveTipoPS").ToString.ToEntero, RowUsado("CveTipoInvPS").ToString.ToEntero, - ' RowUsado("CveUM").ToString.ToEntero, RowUsado("UM").ToString, RowUsado("CveClasificacion").ToString.ToEntero, - ' RowUsado("Clasificacion").ToString, RowUsado("CveProyecto").ToString.ToEntero, RowUsado("Proyecto").ToString, - ' RowUsado("CveSubProyecto").ToString.ToEntero, RowUsado("SubProyecto").ToString, - ' RowUsado("Obs").ToString, Cantidad, PU, RowUsado("PorcentajeIVA").ToString.ToDecimal, ImporteIVA, - ' RowUsado("PorcentajeRetIVA").ToString.ToDecimal, ImporteRetIVA, - ' RowUsado("PorcentajeRetISR").ToString.ToDecimal, ImporteRetISR, RowUsado("PorcentajeIEPS").ToString.ToDecimal, - ' ImporteIEPS, -1, Descuento, Total, "", "", -1, -1, - ' RowUsado("SATClaveProdServ").ToString, RowUsado("SATClaveUM").ToString, -1, RowUsado("CveVentaDetalle").ToString.ToEntero, -1, -1, -1, -1) - ' Next - ' End If - - ' Next - 'End If TrTipoRelacion.Visible = True DdlTiposRelacion.SelectedValueExist("3") LimpiaDocumentoDEV() + If UsuarioActual.Empresa.Funcionalidad(567) = "1" Then + DivAlmacen.Visible = True + LltSalidaAlmacen.Text = "Devolución Almacen" + + Dim DTAlmacen As DataTable + ddlAlmacen.Items.Clear() + DTAlmacen = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa).FiltraParametros($"CveSubProyecto = {DdlSubProyectoDatos.SelectedValue.ToEntero}") + ddlAlmacen.DataSource = DTAlmacen + If DTAlmacen Is Nothing Or DTAlmacen.Rows.Count = 0 Then + ddlAlmacen.Items.Insert(0, New ListItem(" Seleccione ", "-1")) + ddlAlmacen.SelectedValue = "-1" + End If + ddlAlmacen.DataBind() + If GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa).FiltraParametros($"CveSubProyecto = {DdlSubProyectoDatos.SelectedValue.ToEntero}").Rows.Count > 0 Then + ddlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen) + End If + GvInv.Columns(0).Visible = True + DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2") + CargaGVInv(DtInv) + + End If + CambiaTipoDocto() CargaNC(CveVenta) CalculaTotalesVenta() @@ -24243,15 +24270,15 @@ Partial Class Ventas Dim Retorno As Boolean = True If UsuarioActual.CveEmpresa = 141 Then - If Not PermiteCredito AndAlso (DtPagos Is Nothing OrElse DtPagos.Rows.Count = 0) Then + Dim Total As Decimal = TxtTotal.Text.ToDecimal() + + If Not PermiteCredito AndAlso ((DtPagos Is Nothing OrElse DtPagos.Rows.Count = 0) AndAlso Total > 0) Then Alert("Es necesario especificar un pago.", TipoMensaje.MsgAdvertencia) Retorno = False Return Retorno End If - If Not PermiteCredito AndAlso DtPagos IsNot Nothing AndAlso DtPagos.Rows.Count > 0 Then - - Dim Total As Decimal = TxtTotal.Text.ToDecimal() + If Not PermiteCredito AndAlso DtPagos IsNot Nothing AndAlso DtPagos.Rows.Count > 0 AndAlso Total > 0 Then Dim TotalPago As Decimal = DtPagos.SUM("Importe").ToDecimal() If TotalPago < Total Then