From a1fcf204bc56d914ef4f3a5c9ffd300f1fbbc8e2 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Sun, 10 Dec 2023 00:07:14 -0700 Subject: [PATCH] --SMS, Unificacion y facturacion de pedidos --- App_Code/Modelos.vb | 8 +- Inventarios/PopUpExistenciasAlmacen.aspx.vb | 6 +- Ventas/ActualizarPrecios.aspx.vb | 2 +- Ventas/Clientes.aspx.vb | 2 +- Ventas/Ventas.aspx.vb | 709 +++++++++++++++----- 5 files changed, 534 insertions(+), 193 deletions(-) diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 04d428c97..1eb41ee06 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -5646,8 +5646,6 @@ Namespace Modelos Case "Ing" Filtro = "CveConcepto IN (3, 40)" FiltroDevAlmacen = "CveConcepto IN (18, 41)" - Case "Ped" - Filtro = "CveConcepto IN (3, 40)" Case "Dev" Filtro = "CveConcepto = 18" Case Else @@ -5703,7 +5701,7 @@ Namespace Modelos If Not ErrorCancelar AndAlso RealizarDevolucionAlmacen Then 'REALIZA DEVOLUCION A LAS SALIDAS PENDIENTES - If ObjFactura.TipoDocto <> "Rem" Then + If Not ObjFactura.TipoDocto.Contiene("Rem", "Ped") Then For Each RowMovimiento As DataRow In DtSalidas.Rows Dim CveConceptoMovimiento As Integer = -1 Dim CveAlmacenMovimiento As Integer = -1 @@ -6014,8 +6012,8 @@ Namespace Modelos End If - 'CANCELACION DE MOVIMIENTOS DE REMISION - If Not ErrorCancelar AndAlso ObjFactura.TipoDocto = "Rem" AndAlso RealizarDevolucionAlmacen AndAlso ObjFactura.SaldoAlmacen <> 0 Then + 'CANCELACION DE MOVIMIENTOS DE REMISION, PEDIDOS + If Not ErrorCancelar AndAlso ObjFactura.TipoDocto.Contiene("Rem", "Ped") AndAlso RealizarDevolucionAlmacen AndAlso ObjFactura.SaldoAlmacen <> 0 Then Dim CveMovimientoUsado As Integer = -1 Dim CveAlmacenUsado As Integer = 0 Dim CveAlmacenGeneral As Integer = 0 diff --git a/Inventarios/PopUpExistenciasAlmacen.aspx.vb b/Inventarios/PopUpExistenciasAlmacen.aspx.vb index 682c9b961..ab8440fba 100644 --- a/Inventarios/PopUpExistenciasAlmacen.aspx.vb +++ b/Inventarios/PopUpExistenciasAlmacen.aspx.vb @@ -46,7 +46,7 @@ Partial Class Inventarios_Default DivSucursal.Visible = True End If - If UsuarioActual.CveEmpresa.Contiene(186) Then + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then LtPrecioPS.Visible = True DivListasPrecios.Visible = True DivListasPreciosRow2.Visible = True @@ -89,7 +89,7 @@ Partial Class Inventarios_Default Dim Txt As String = IfNull(Request("Txt"), "").ToString If Txt <> "" Then LblTitulo.Text = String.Format("Búsqueda de {0}", Txt) - If UsuarioActual.CveEmpresa = 186 Then + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then CargaListasPrecios() End If @@ -167,7 +167,7 @@ Partial Class Inventarios_Default CvePrecioLista = -2 End If - If UsuarioActual.CveEmpresa = 186 Then + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then If DdlPrecioLista.SelectedValue.ToEntero() > 0 Then CvePrecioLista = DdlPrecioLista.SelectedValue.ToEntero() Else diff --git a/Ventas/ActualizarPrecios.aspx.vb b/Ventas/ActualizarPrecios.aspx.vb index 8f07e50cd..4a470b8f7 100644 --- a/Ventas/ActualizarPrecios.aspx.vb +++ b/Ventas/ActualizarPrecios.aspx.vb @@ -87,7 +87,7 @@ Partial Class Ventas_ActualizarPrecios Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then - If UsuarioActual.CveEmpresa = 186 Then + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then LblModalidad.Visible = True DivModalidad.Visible = True End If diff --git a/Ventas/Clientes.aspx.vb b/Ventas/Clientes.aspx.vb index ddc383873..c51dc5e46 100644 --- a/Ventas/Clientes.aspx.vb +++ b/Ventas/Clientes.aspx.vb @@ -1212,7 +1212,7 @@ Partial Class Clientes DivPrecioLista.Visible = False End If - If UsuarioActual.CveEmpresa = 186 Then + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then DivCrearPrecioLista.Visible = True End If diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index efd0ba201..70041a999 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -433,12 +433,12 @@ Partial Class Ventas ViewState("DtRemisionesTmpDT") = value End Set End Property - Private Property DtPedidos2TmpDT As DataTable + Private Property DtPedidosTmpDT As DataTable Get - Return If(IsNothing(ViewState("DtPedidos2TmpDT")), Nothing, CType(ViewState("DtPedidos2TmpDT"), DataTable)) + Return If(IsNothing(ViewState("DtPedidosTmpDT")), Nothing, CType(ViewState("DtPedidosTmpDT"), DataTable)) End Get Set(value As DataTable) - ViewState("DtPedidos2TmpDT") = value + ViewState("DtPedidosTmpDT") = value End Set End Property Private Property DtRemConceptosSurtidos As DataTable @@ -449,6 +449,15 @@ Partial Class Ventas ViewState("DtRemConceptosSurtidos") = value End Set End Property + + Private Property DtPedidosConceptosSurtidos As DataTable + Get + Return If(IsNothing(ViewState("DtPedidosConceptosSurtidos")), Nothing, CType(ViewState("DtPedidosConceptosSurtidos"), DataTable)) + End Get + Set(value As DataTable) + ViewState("DtPedidosConceptosSurtidos") = value + End Set + End Property Private Property HuboCambioRemi As Boolean Get Return If(IsNothing(ViewState("HuboCambioRemi")), False, CType(ViewState("HuboCambioRemi"), Boolean)) @@ -1057,15 +1066,6 @@ Partial Class Ventas ViewState("CvePedido") = value End Set End Property - Private Property CvePedido2 As Integer - Get - Return ViewState("CvePedido2").ToString().ToEntero() - End Get - - Set(value As Integer) - ViewState("CvePedido2") = value - End Set - End Property Private Property TipoContrato As Integer Get Return ViewState("TipoContrato").ToString().ToEntero() @@ -1890,12 +1890,12 @@ Partial Class Ventas ViewState("DtPedidos2") = value End Set End Property - Private Property DtPedidos2PS As DataTable + Private Property DtPedidosPS As DataTable Get - Return CType(ViewState("DtPedidos2PS"), DataTable) + Return CType(ViewState("DtPedidosPS"), DataTable) End Get Set(value As DataTable) - ViewState("DtPedidos2PS") = value + ViewState("DtPedidosPS") = value End Set End Property @@ -2363,7 +2363,6 @@ Partial Class Ventas ViewState("NuevaFactura") = -1 ViewState("CveDevolucion") = -1 ViewState("CvePedido") = -1 - ViewState("CvePedido2") = -1 ViewState("TipoContrato") = -1 ViewState("CveVenta") = -1 ViewState("CveCliente") = -1 @@ -2469,9 +2468,6 @@ Partial Class Ventas TxtFechaFPedido.Text = NowADS().ToShortDateString TxtFechaFOC.Text = NowADS().ToShortDateString - If UsuarioActual.TienePermisoProceso(177) Then - DdlTipoComprobante.Items.Insert(4, New ListItem("Pedido de Contrato", "Ped")) - End If TrSinExistencia.Visible = UsuarioActual.TienePermisoProceso(276) @@ -2485,7 +2481,7 @@ Partial Class Ventas LnkAgregarCliente.Visible = False End If - DdlTipoComprobante.Items.Insert(DdlTipoComprobante.Items.Count, New ListItem("Pedido", "Pd2")) + DdlTipoComprobante.Items.Insert(DdlTipoComprobante.Items.Count, New ListItem("Pedido", "Ped")) If UsuarioActual.Empresa.Funcionalidad(344).ToString() = "1" Then DdlTipoComprobante.Items.Insert(DdlTipoComprobante.Items.Count, New ListItem("NC de Remisión", "RNC")) @@ -2982,19 +2978,6 @@ Partial Class Ventas UpParametros.Update() End If - 'Modalidad Devolucion Pedido **REVISAR SI SE USA - If Request("CveContrato") IsNot Nothing AndAlso IsNumeric(Request("CveContrato")) AndAlso Request("CveContrato").ToEntero() > 0 AndAlso Request("CvePedido") IsNot Nothing AndAlso IsNumeric(Request("CvePedido")) AndAlso Request("CvePedido").ToEntero() > 0 AndAlso Request("Tipo") IsNot Nothing AndAlso IsNumeric(Request("Tipo")) AndAlso Request("Tipo").ToEntero() = 2 Then - CveContrato = Request("CveContrato").ToEntero() - CvePedido = Request("CvePedido").ToEntero() - TipoContrato = Request("Tipo").ToEntero() - - ''REQUIERE DEVOLUCION - 'DdlDevolucionAlmacen.SelectedValue = "1" - 'DdlDevolucionAlmacen.Enabled = False - 'UpInvDev.Update() - - CargarPedidoUrl() - End If 'MODALIDAD DEVOLUCION PEDIDO NUEVO If Request("DevPed") IsNot Nothing AndAlso IsNumeric(Request("DevPed")) AndAlso Request("DevPed").ToEntero() > 0 AndAlso Request("MovInv") IsNot Nothing AndAlso IsNumeric(Request("MovInv")) AndAlso Request("MovInv").ToEntero() > 0 Then @@ -3197,7 +3180,7 @@ Partial Class Ventas ChkEnviarFactura.Visible = False LblEnviarMail.Visible = False Else - If DdlTipoComprobante.SelectedValue.Contiene("Rem", "PeC", "PA", "Pd2") Then + If DdlTipoComprobante.SelectedValue.Contiene("Rem", "PeC", "PA", "Ped") Then 'ENVIO DE FACTURA ChkEnviarFactura.Checked = False ChkEnviarFactura.Visible = True @@ -4799,7 +4782,7 @@ Partial Class Ventas LblAlertRefacInv.Visible = True End If - If DdlTipoComprobante.SelectedValue.Contiene("Egs", "Ing", "Ant", "Dev", "Rem", "DPe", "RNC", "Pd2", "Cot") AndAlso Not CveEstatus.Contiene(4, 5, 10, 12, 13, 20, 23) Then + If DdlTipoComprobante.SelectedValue.Contiene("Egs", "Ing", "Ant", "Dev", "Rem", "DPe", "RNC", "Ped", "Cot") AndAlso Not CveEstatus.Contiene(4, 5, 10, 12, 13, 20, 23) Then If UsuarioActual.TienePermisoProceso(159) Then Dim TienePermiso As String = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, -1).FiltroPrimeroValor("CveSubProyecto", String.Format("CveSubProyecto = {0}", DbRowVenta("CveSubProyecto"))) If TienePermiso <> "" Then @@ -5005,6 +4988,18 @@ Partial Class Ventas HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) Case "Ped" DdlTipoComprobante.Items.Insert(0, New ListItem("Pedido", "Ped")) + CvePedido = CveVenta + If UsuarioActual.Empresa.Funcionalidad(595) = "1" Then + If DdlTipoComprobante.Items.FindByValue("PA") Is Nothing Then + BtnGeneraAutorizacion.Visible = If(CveEstatus <> 21, True, False) + End If + End If + + 'If UsuarioActual.TienePermisoProceso(199) Then + ' BtnGenerarRemision.Visible = If(CveEstatus <> 21, True, False) + 'Else + ' BtnGenerarRemision.Visible = False + 'End If Case "DPe" DdlTipoComprobante.Items.Insert(5, New ListItem("Devolución de perdido", "DPe")) Case "PeC" @@ -5018,14 +5013,6 @@ Partial Class Ventas CvePedidoA = CveVenta DiasCredito = DbRowVenta("DiasCredito").ToString().ToEntero() EsDiasCreditoFijo = CBool(DbRowVenta("EsDiasCreditoFijo").ToString()) - Case "Pd2" - CvePedido2 = CveVenta - BtnGeneraAutorizacion.Visible = If(CveEstatus <> 21, True, False) - If UsuarioActual.TienePermisoProceso(199) Then - BtnGenerarRemision.Visible = If(CveEstatus <> 21, True, False) - Else - BtnGenerarRemision.Visible = False - End If End Select DdlTipoComprobante.SelectedValue = DbRowVenta("TipoDocto").ToString() @@ -5094,7 +5081,7 @@ Partial Class Ventas DdlMoneda.SelectedValue = DbRowVenta("CveMoneda").ToString() CambiaMoneda() - If DbRowVenta("TipoDocto").ToString() = "Pd2" Then + If DbRowVenta("TipoDocto").ToString() = "Ped" Then 'CANTIDAD FACTURADA If TmpDT.SUM("CantidadFacturadaPed2") > 0 Then GvPS.Columns(7).Visible = True @@ -5217,20 +5204,6 @@ Partial Class Ventas TxtRetIVA.Text = DbRowVenta("RetIVA").ToString().FormatoNumero(2) TxtCorreoNotificaciones.Text = DbRowVenta("CorreoNotificacion").ToString() - If DbRowVenta("CveProcedimiento").ToString().ToEntero > 0 Then - DdlProcedimientoObservaciones.SelectedValueExist(DbRowVenta("CveProcedimiento").ToString()) - DdlProcedimientoObservaciones.Enabled = False - TrObsProcedimiento1.Visible = True - TrObsProcedimiento2.Visible = True - End If - - If DbRowVenta("CveMedico").ToString().ToEntero > 0 Then - DdlMedicoObservaciones.SelectedValueExist(DbRowVenta("CveMedico").ToString()) - DdlMedicoObservaciones.Enabled = False - TrObsMedico1.Visible = True - TrObsMedico2.Visible = True - End If - If TxtRetIVA.Text.ToDecimal() > 0 Then TrRetIVA.Style.Add("display", "") UsuarioActual.Empresa.MostrarRetIVA = True @@ -5709,7 +5682,7 @@ Partial Class Ventas End If - If DbRowVenta("TipoDocto").ToString().Contiene("Cot", "Pd2") Then + If DbRowVenta("TipoDocto").ToString().Contiene("Cot") Then 'CANTIDAD FACTURADA If TmpDT.SUM("CantidadFacturadaCot") > 0 Then GvPS.Columns(7).Visible = True @@ -5736,6 +5709,34 @@ Partial Class Ventas VerificarBtnFacturarCotizacion(DbRowVenta("CveVendedor").ToString().ToEntero()) End If + + If DbRowVenta("TipoDocto").ToString().Contiene("Ped") Then + 'ACTIVA BOTONERA | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR + If TmpDT.SUM("CantidadFacturadaPed2") < TmpDT.SUM("Cantidad") Then + BtnsFacturar.Visible = True + + 'bloquear la facturación de remisiones que no estén surtidas + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then + If TmpDT.SUM("Cantidad") <> TmpDT.SUM("CantidadInventario") Then 'que ya esté surtida totalmente + BtnsFacturar.Visible = False + End If + End If + + LBFacturarAnticipo.Visible = False + + 'ACTIVA CONVERSION DE MONEDA + If DdlMoneda.SelectedValue.ToEntero() = 1 Then + TrConversionDolares.Visible = True + ChkConvertirDolares.Enabled = Not UsuarioActual.TienePermisoProceso(324) + TxtTipoCambioDlls.Enabled = True + Else + TrConversionTipoCambio.Visible = True + ChkConvertirDoctoPesos.Enabled = Not UsuarioActual.TienePermisoProceso(324) + TxtTipoCambio.Enabled = True + End If + End If + End If + If UsuarioActual.Empresa.Funcionalidad(280) = "1" Then RblPaqueteria.SelectedValue = If(DbRowVenta("FormaPaqueteria").ToString = "", "1", DbRowVenta("FormaPaqueteria").ToString) RblPaqueteria.Enabled = False @@ -6403,7 +6404,7 @@ Partial Class Ventas ChkEnviarFactura.Visible = False LblEnviarMail.Visible = False Else - If DdlTipoComprobante.SelectedValue.Contiene("Rem", "PeC", "PA", "Pd2") Then + If DdlTipoComprobante.SelectedValue.Contiene("Rem", "PeC", "PA", "Ped") Then 'ENVIO DE FACTURA ChkEnviarFactura.Checked = False ChkEnviarFactura.Visible = True @@ -7438,7 +7439,7 @@ Partial Class Ventas 'VERIFICAR RESTRICCIONES DEL CLIENTE If Not UsuarioActual.Empresa.Funcionalidad(702).ToEntero() > 0 Then - If (DdlTipoComprobante.SelectedValue = "Cot" AndAlso CveVenta > 0 AndAlso RBLPago.SelectedValue = "2") Then + If (DdlTipoComprobante.SelectedValue = "Cot" AndAlso CveVenta > 0 AndAlso RBLPago.SelectedValue = "2") Then Dim Vta As New ClsVentas Dim Opcion As Integer = Vta.ObtenerClienteLimitesVenta(CveCliente, UsuarioActual.CveEmpresa) Dim OpcionMsg As String = String.Format("El Cliente se encuentra bloqueado por la siguiente razón:

{0}", Vta.SerieVenta) @@ -7488,8 +7489,8 @@ Partial Class Ventas 'Puede hacer pedido If CveVenta <= 0 Then If Not UsuarioActual.TienePermisoProceso(177) Then - If DdlTipoComprobante.Items.FindByValue("Pd2") IsNot Nothing Then - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Pd2")) + If DdlTipoComprobante.Items.FindByValue("Ped") IsNot Nothing Then + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ped")) End If End If End If @@ -7500,7 +7501,7 @@ Partial Class Ventas ChkEnviarFactura.Visible = False LblEnviarMail.Visible = False Else - If DdlTipoComprobante.SelectedValue.Contiene("Rem", "PeC", "PA", "Pd2") Then + If DdlTipoComprobante.SelectedValue.Contiene("Rem", "PeC", "PA", "Ped") Then 'ENVIO DE FACTURA ChkEnviarFactura.Checked = False ChkEnviarFactura.Visible = True @@ -7774,11 +7775,6 @@ Partial Class Ventas DdlMedicoModal.DataSource = GlobalDTMedicos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ") DdlMedicoModal.DataBind() - - - DdlMedicoObservaciones.DataSource = GlobalDTMedicos(UsuarioActual.CveEmpresa) - DdlMedicoObservaciones.DataBind() - End Sub Private Sub CargaMedicos() @@ -7788,9 +7784,6 @@ Partial Class Ventas DdlProcedimientoModal.DataSource = GlobalDTProcedimientos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ") DdlProcedimientoModal.DataBind() - DdlProcedimientoObservaciones.DataSource = GlobalDTProcedimientos(UsuarioActual.CveEmpresa) - DdlProcedimientoObservaciones.DataBind() - End Sub Private Sub CargaDdlClientes() @@ -8196,7 +8189,7 @@ Partial Class Ventas Select Case e.Row.DBCampo("TipoDocto") Case "Cot" e.Row.FCLiteral("LtCantidadFacturada").Text = e.Row.DBCampo("CantidadFacturadaCot").ToDecimal.ToString("#,##0.##") - Case "Pd2" + Case "Ped" e.Row.FCLiteral("LtCantidadFacturada").Text = e.Row.DBCampo("CantidadFacturadaPed2").ToDecimal.ToString("#,##0.##") End Select @@ -8899,7 +8892,7 @@ Partial Class Ventas Private Sub EmitirImprimir(Optional TipoDoctoViejo As String = "") DtRemisionesTmpDT = TmpDT.Copy - DtPedidos2TmpDT = TmpDT.Copy + DtPedidosTmpDT = TmpDT.Copy DtCotizacionTmpDT = TmpDT.Copy DtOCTmpDT = TmpDT.Copy TmpDTError = TmpDT.Copy @@ -10106,11 +10099,11 @@ Partial Class Ventas Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1" AutoConta = AutocontaMatriz(AutoConta) - If DdlTipoComprobante.SelectedValue.Contiene("Rem", "RNC", "Cot", "Ped", "Pd2", "PA") Then + If DdlTipoComprobante.SelectedValue.Contiene("Rem", "RNC", "Cot", "Ped", "PA") Then AutoConta = False End If - If UsuarioActual.CveEmpresa = 119 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ant", "Rem", "RNC", "Cot", "Ped", "Pd2", "PA", "Egs", "Dev") Then + If UsuarioActual.CveEmpresa = 119 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ant", "Rem", "RNC", "Cot", "Ped", "PA", "Egs", "Dev") Then AutoConta = False End If @@ -10129,7 +10122,7 @@ Partial Class Ventas OnError("Ocurrió un error al contabilizar la factura", ex) End Try - If ObjFactura.CveVenta > 0 AndAlso ErrorList.Count = 0 AndAlso (SeGuardoPrePoliza Or ObjFactura.TipoDocto.Contiene("Ped", "Cot", "DPe", "PeC", "PA", "Pd2")) Then + If ObjFactura.CveVenta > 0 AndAlso ErrorList.Count = 0 AndAlso (SeGuardoPrePoliza Or ObjFactura.TipoDocto.Contiene("Ped", "Cot", "DPe", "PeC", "PA")) Then ObjVentas.Commit() ObjFactura.DtDetalle = TmpDT 'actualiza por cambios de pedimentos. @@ -10201,7 +10194,7 @@ Partial Class Ventas Dim MsgCancelacionRefacturacion As Modelos.Factura.MCancelacionVentaMensaje = Nothing 'TIMBRADO Y CASO ESPECIAL NOTA DE CREDITO - If (TipoDoctoDevolucion = "" OrElse Not TipoDoctoDevolucion.Contiene("Rem", "RNC", "Cot", "Ped", "DPe", "PA", "Pd2")) Then + If (TipoDoctoDevolucion = "" OrElse Not TipoDoctoDevolucion.Contiene("Rem", "RNC", "Cot", "Ped", "DPe", "PA", "Ped")) Then Dim DebeTimbrar As Boolean = True If UsuarioActual.CveEmpresa.Contiene(1, 72, 80) Then @@ -10362,7 +10355,7 @@ Partial Class Ventas End If 'DESCARGA PDF - If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant", "Egs", "Dev", "Pd2") Then + If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant", "Egs", "Dev", "Ped") Then 'If Not ImprimeAlert Then Dim ArchivoIngPyMe As New System.IO.FileInfo(String.Format("{0}Formatos/Factura.mrt", UsuarioActual.Empresa.Ruta)) @@ -11538,7 +11531,7 @@ Partial Class Ventas ObjFactura.Entrega = Entrega ObjFactura.Vigencia = TxtFechaVencimientoCotizacion.Text.ToDate - ObjFactura.CveVentaPadre = If(CveDevolucion > 0, CveDevolucion, If(CvePedido2 > 0, CvePedido2, CvePedido)) + ObjFactura.CveVentaPadre = If(CveDevolucion > 0, CveDevolucion, If(CvePedido > 0, CvePedido, CvePedido)) If DtVentasNC IsNot Nothing AndAlso DtVentasNC.Rows.Count > 0 Then ObjFactura.CveVentaPadre = DtVentasNC.Rows(0)("CveVenta").ToString().ToEntero() ObjFactura.SerieFolioPadre = DtVentasNC.Rows(0)("FolioFiscal").ToString() @@ -13103,6 +13096,19 @@ Partial Class Ventas ErrorList.Add("Ocurrió un error al seleccionar el almacen de entrega por adelantado de la sucursal.") End If End If + + 'ASIGNA EL VALOR DEL ALMACEN AL PEDIDO + If factura.TipoDocto = "Ped" Then + If CveAlmacenTraspasoDestino <= 0 Then + CveAlmacenTraspasoDestino = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $"CveTipoAlmacen = 10 AND CveSubProyecto = {DdlSubProyectoDatos.SelectedValue}").ToString().ToEntero() + End If + + 'SI LA SUCURSAL NO TIENE ENTREGA POR ADELANTADO + If CveAlmacenTraspasoDestino <= 0 Then + ErrorList.Add("Ocurrió un error al seleccionar el almacen de entrega por adelantado de la sucursal.") + End If + End If + Dim TotalImpuestoLocal As Double = 0 If GvImpuestosLocales2.Rows.Count > 0 Then For Each gvr As GridViewRow In GvImpuestosLocales2.Rows @@ -13292,11 +13298,11 @@ Partial Class Ventas 'Se agregan los PS For Each Row As DataRow In TmpDTDetalle.Rows - If Not ObjVentas.AddVentaDetalle(ObjVentas.CveVenta, Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().todecimal, Row("CveUM").ToString().ToEntero(), - Row("PU").ToString().todecimal(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Row("ImporteIVA").ToString().todecimal, Math.Round((Row("Total").ToString().todecimal(If(factura.ConvertirPesos, factura.TipoCambio, 1)) * (1 + Row("PorcentajeIVA").ToString().todecimal(If(factura.ConvertirPesos, factura.TipoCambio, 1)))), 6), - Row("Obs").ToString(), Row("Descuento").ToString().todecimal(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Row("TipoDescuento").ToString().ToEntero(), Row("CveSubProyecto").ToString().ToEntero(), Row("CvePresupuestoIngreso").ToString().ToEntero(), TiempoEntrega:=Row("TiempoEntrega").ToString(), CveVentaDetallePadre:=Row("CveVentaDetalle").ToString().ToEntero(), - CveContratoDetalle:=Row("CveContratoDetalle").ToString().ToEntero(), CvePromocionDetalle:=Row("CvePromocionDetalle").ToString().ToEntero(), IEPS:=Row("ImporteIEPS").ToString().todecimal, CveMovimientoDetallePedido:=Row("CveMovimientoDetallePedido").ToString().ToEntero(), ImporteRetIVA:=Row("ImporteRetIVA").ToString().todecimal, ImporteRetISR:=Row("ImporteRetISR").ToString().todecimal, - PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().todecimal, PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString().todecimal, PorcentajeRetISR:=Row("PorcentajeRetISR").ToString().todecimal, CuentaPredial:=Row("CuentaPredial").ToString(), CvePrecioLista:=Row("CvePrecioLista").ToString().ToEntero(), CveActivoFijo:=Row("CveActivoFijo").ToString().ToEntero(), NumTurnos:=Row("NumTurnos").ToString().ToDecimal()) Then + If Not ObjVentas.AddVentaDetalle(ObjVentas.CveVenta, Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDecimal, Row("CveUM").ToString().ToEntero(), + Row("PU").ToString().ToDecimal(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Row("ImporteIVA").ToString().ToDecimal, Math.Round((Row("Total").ToString().ToDecimal(If(factura.ConvertirPesos, factura.TipoCambio, 1)) * (1 + Row("PorcentajeIVA").ToString().ToDecimal(If(factura.ConvertirPesos, factura.TipoCambio, 1)))), 6), + Row("Obs").ToString(), Row("Descuento").ToString().ToDecimal(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Row("TipoDescuento").ToString().ToEntero(), Row("CveSubProyecto").ToString().ToEntero(), Row("CvePresupuestoIngreso").ToString().ToEntero(), TiempoEntrega:=Row("TiempoEntrega").ToString(), CveVentaDetallePadre:=Row("CveVentaDetalle").ToString().ToEntero(), + CveContratoDetalle:=Row("CveContratoDetalle").ToString().ToEntero(), CvePromocionDetalle:=Row("CvePromocionDetalle").ToString().ToEntero(), IEPS:=Row("ImporteIEPS").ToString().ToDecimal, CveMovimientoDetallePedido:=Row("CveMovimientoDetallePedido").ToString().ToEntero(), ImporteRetIVA:=Row("ImporteRetIVA").ToString().ToDecimal, ImporteRetISR:=Row("ImporteRetISR").ToString().ToDecimal, + PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().ToDecimal, PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString().ToDecimal, PorcentajeRetISR:=Row("PorcentajeRetISR").ToString().ToDecimal, CuentaPredial:=Row("CuentaPredial").ToString(), CvePrecioLista:=Row("CvePrecioLista").ToString().ToEntero(), CveActivoFijo:=Row("CveActivoFijo").ToString().ToEntero(), NumTurnos:=Row("NumTurnos").ToString().ToDecimal()) Then ErrorList.Add("Ocurrió un error al agregar un Producto o Servicio a la Factura.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") Exit For Else @@ -13513,8 +13519,8 @@ Partial Class Ventas 'End If 'Pedido2' - If ObjVentas.CveVenta > 0 And CvePedido2 > 0 And DdlTipoComprobante.SelectedValue.Contiene("Rem", "PA") Then - If Not ObjCliente.UpdateEstatusPedido(CvePedido2, 21, -1, UsuarioActual.CveUsuario) Then + If ObjVentas.CveVenta > 0 And CvePedido > 0 And DdlTipoComprobante.SelectedValue.Contiene("Rem", "PA") Then + If Not ObjCliente.UpdateEstatusPedido(CvePedido, 21, -1, UsuarioActual.CveUsuario) Then ErrorList.Add("Ocurrió un error al actualizar el estatus del pedido2") End If End If @@ -13663,17 +13669,17 @@ Partial Class Ventas If ErrorList.Count = 0 Then 'Agregamos los pedidos2 a la tabla - If DtPedidos2PS IsNot Nothing AndAlso DtPedidos2PS.Rows.Count > 0 AndAlso ErrorList.Count = 0 Then + If DtPedidosPS IsNot Nothing AndAlso DtPedidosPS.Rows.Count > 0 AndAlso ErrorList.Count = 0 Then Dim CveVentaDetalle As Integer = 0 Dim CveVentaDetallePadre As Integer = 0 Dim Cantidad As Decimal = 0 Dim CvePS As Integer = 0 Dim PU As Decimal = 0 - For Each row As DataRow In DtPedidos2PS.Rows - Cantidad = DtPedidos2TmpDT.FiltroPrimeroValor("Cantidad", $"CveVentaDetallePedido2={row("CveVentaDetalle")}").ToDecimal - CvePS = DtPedidos2TmpDT.FiltroPrimeroValor("CvePS", $"CveVentaDetallePedido2={row("CveVentaDetalle")}").ToEntero() - PU = DtPedidos2TmpDT.FiltroPrimeroValor("PU", $"CveVentaDetallePedido2={row("CveVentaDetalle")}").ToDecimal + For Each row As DataRow In DtPedidosPS.Rows + Cantidad = DtPedidosTmpDT.FiltroPrimeroValor("Cantidad", $"CveVentaDetallePedido2={row("CveVentaDetalle")}").ToDecimal + CvePS = DtPedidosTmpDT.FiltroPrimeroValor("CvePS", $"CveVentaDetallePedido2={row("CveVentaDetalle")}").ToEntero() + PU = DtPedidosTmpDT.FiltroPrimeroValor("PU", $"CveVentaDetallePedido2={row("CveVentaDetalle")}").ToDecimal CveVentaDetalle = TmpDTDetalle.FiltroPrimeroValor("CveVentaDetalle", $"CveVentaDetallePedido2={row("CveVentaDetalle")}").ToEntero() CveVentaDetallePadre = row("CveVentaDetalle").ToString().ToEntero() @@ -13823,7 +13829,7 @@ Partial Class Ventas End If Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1" - If UsuarioActual.CveEmpresa = 119 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ant", "Rem", "RNC", "Cot", "Ped", "Pd2", "PA", "Egs", "Dev") Then + If UsuarioActual.CveEmpresa = 119 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ant", "Rem", "RNC", "Cot", "Ped", "PA", "Egs", "Dev") Then AutoConta = False End If @@ -14983,6 +14989,14 @@ Partial Class Ventas Next End If + If DtPedidosPS IsNot Nothing AndAlso factura.TipoDocto = "Ing" Then + If Not TraspasoAlmacenPedido(ObjInventario, ObjVentas, Me.CvePedido, ObjConta, True, 9, TmpDTDetalle) Then + OcurrioError = True + ErrorList.Add("Ocurrió un error al verificar inventario de pedidos.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") + ModExtensiones.GuardaLog("Ocurrió un error al verificar inventario de pedidos.Revise su factura y cualquier detalle comuníquese a Soporte Técnico") + End If + End If + 'EN ECONOLLANTAS DEBE REALIZAR SIEMPRE LA SALIDA DE ALMACEN If UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso UsuarioActual.Empresa.Funcionalidad(567) = "1" AndAlso factura.TipoDocto.Contiene("Ing", "Egs", "Rem") Then For Each GvRow As GridViewRow In GvInv.Rows @@ -15086,7 +15100,7 @@ Partial Class Ventas End If End If - Dim CveSeccionAlmacen As Integer = -3 + Dim CveSeccionAlmacen As Integer = -3 'If AplicaSeccion Then CveSeccionAlmacen = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, CveAlmacen, CveProducto).FiltroPrimeroValor("CveSeccionAlmacen", "").ToEntero If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Cantidad, CveUnidad, CveProducto, PU, -1, Serie:=Dr("Serie").ToString(), CveSeccionAlmacen:=CveSeccionAlmacen, CveVentaDetalle:=Dr("CveVentaDetalle").ToString().ToEntero()) Then @@ -17027,7 +17041,7 @@ Partial Class Ventas End If End If - If DdlTipoComprobante.SelectedValue.Contiene("Rem", "PeC", "PA", "Pd2") Then + If DdlTipoComprobante.SelectedValue.Contiene("Rem", "PeC", "PA", "Ped") Then 'ENTREGA POR ADELANTADO If UsuarioActual.Empresa.Funcionalidad(145) = "1" And Not DdlTipoComprobante.SelectedValue.Contiene("PA") Then 'If UsuarioActual.CveEmpresa.Contiene(4, 72, 80, 119) Then @@ -17075,7 +17089,7 @@ Partial Class Ventas If CveVenta > 0 AndAlso EnviarCorreoCliente Then ChkEnviarFactura.Checked = EnviarCorreoCliente End If - If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "PA", "Pd2") AndAlso (ReceptorRFC = "XAXX010101000" Or LblRFC.Text = "XAXX010101000") Then + If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "PA", "Ped") AndAlso (ReceptorRFC = "XAXX010101000" Or LblRFC.Text = "XAXX010101000") Then TrDireccion.Visible = False TrCiudad.Visible = False TrRFC.Visible = False @@ -19073,8 +19087,8 @@ Partial Class Ventas 'Puede hacer pedido If Me.CveVenta <= 0 Then If Not UsuarioActual.TienePermisoProceso(177) Then - If DdlTipoComprobante.Items.FindByValue("Pd2") IsNot Nothing Then - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Pd2")) + If DdlTipoComprobante.Items.FindByValue("Ped") IsNot Nothing Then + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ped")) End If End If End If @@ -19619,7 +19633,7 @@ Partial Class Ventas ElseIf DdlTipoComprobante.SelectedValue = "Rem" Then BtnEmitirImprimir.Text = "Registrar" 'TdReferencia.Style.Add("display", "none") - ElseIf DdlTipoComprobante.SelectedValue.Contiene("Ped", "PeC", "PA", "Pd2") Then + ElseIf DdlTipoComprobante.SelectedValue.Contiene("Ped", "PeC", "PA") Then BtnEmitirImprimir.Text = "Registrar" 'TdReferencia.Style.Add("display", "none") ElseIf DdlTipoComprobante.SelectedValue = "Cot" Then @@ -19956,6 +19970,204 @@ Partial Class Ventas Return MovDTCuadrados End Function + + Private Function TraspasoAlmacenPedido(ByRef ObjInventario As ClsInventarios, ByRef ObjVentas As ClsVentas, CvePedido As Integer, ByRef ObjConta As ClsContabilidad, ConSalida As Boolean, ConceptoMovimiento As Integer, TmpDTDetalle As DataTable) As Boolean + Dim OcurrioError As Boolean = False + Try + Dim DtMovimientos As DataTable + Dim DtMovimientosDetalles As DataTable + DtRemConceptosSurtidos = Nothing + + Dim TieneMovimientosServicioDomicilio As Boolean = False + Dim TieneMovimientosSinCosto As Boolean = False + Dim TieneMovimientosContrato As Boolean = False + + 'Obtenemos los movimientos detalle + If ObjInventario.GetInv_Mov(CvePedido, UsuarioActual.CveEmpresa) Then + + If ObjInventario.DtResultados.Rows.Count > 0 Then + + DtMovimientos = ObjInventario.DtResultados.FiltraParametros("", DistinctColumns:={"CveMovimiento"}) + + DtMovimientosDetalles = ObjInventario.DtResultados.FiltraParametros("CvePS > 0") + + 'VALIDAR SI TIENE PRODUCTOS POR TRASPASAR + If DtMovimientos.Rows.Count > 0 Then + Dim GeneroMovimientoAlmacen As Boolean = False + + TieneMovimientosServicioDomicilio = DtMovimientosDetalles.COUNT("CveTipoAlmacen", "CveTipoAlmacen=29") > 0 + + TieneMovimientosSinCosto = DtMovimientosDetalles.COUNT("CveTipoAlmacen", "CveTipoAlmacen=26") > 0 + + TieneMovimientosContrato = DtMovimientosDetalles.COUNT("CveTipoAlmacen", "CveTipoAlmacen IN (11)") > 0 + + For Each dr As DataRow In DtMovimientos.Rows + + 'VERIFICA SI YA SE GENERARON LAS SALIDAS DE ALMACEN NECESARIAS + If DtPedidosConceptosSurtidos IsNot Nothing Then + If DtPedidosConceptosSurtidos.SUMD("Surtido") = DtPedidosConceptosSurtidos.SUMD("Cantidad") Then + Exit For + End If + End If + + 'Obtenemos los Movimientos de salida + If ObjInventario.GetMovimientos(dr("CveMovimiento").ToString().ToEntero(), ConceptoMovimiento, -1, UsuarioActual.CveEmpresa) Then + + If ObjInventario.DtResultados.Rows.Count > 0 AndAlso DtMovimientosDetalles.Rows.Count > 0 Then + Dim RowMovimiento As DataRow = ObjInventario.DtResultados(0) + + Dim CveAlmacenSalida As Integer = RowMovimiento("CveAlmacen").ToString().ToEntero() + Dim CveAlmacenEntrada As Integer = RowMovimiento("CveAlmacenRelacionado").ToString().ToEntero() + Dim CveMoneda As Integer = RowMovimiento("CveMoneda").ToString().ToEntero() + Dim CveTipoAlmacen As Integer = RowMovimiento("CveTipoAlmacen").ToString().ToEntero() + + If (CveAlmacenEntrada > 0 AndAlso CveTipoAlmacen <> 1) Then + + Dim MovDetalle As New DataTable + Dim AplicaMovimientoDetalleEntrada As Boolean = False + + MovDetalle = CuadrarFacturaMovimientosPedido(ObjVentas, CvePedido, DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")} AND (SaldoAlmacen > 0 AND CantidadDisponible > 0)")) + + If ErrorList.Count = 0 AndAlso MovDetalle.Rows.Count > 0 Then + + 'SALIDA DEFINITIVA DEL SISTEMA + Dim CveConceptoSalidaAlmacen As Integer = 40 + Dim CveAlmacenParaSalida As Integer = CveAlmacenSalida + AplicaMovimientoDetalleEntrada = True + + 'Le damos salida normal + If ConSalida AndAlso Not OcurrioError Then + + If Not OcurrioError Then + Dim CveMovimientoSalidaAlmacen As Integer = GenerarMovimientoAlmacenPedido(ObjInventario, MovDetalle, CveAlmacenParaSalida, CveConceptoSalidaAlmacen, CveMoneda, ObjFactura.CveVenta, AplicaMovimientoDetalleEntrada:=AplicaMovimientoDetalleEntrada, MovimientoPrePoliza:=True, ObjConta:=ObjConta) + GeneroMovimientoAlmacen = CveMovimientoSalidaAlmacen > 0 + + If Not GeneroMovimientoAlmacen Then + OcurrioError = True + Exit For + End If + End If + + End If + End If + + MovDetalle.Dispose() + + If OcurrioError Then + Exit For + End If + End If + End If + End If + If OcurrioError Then + Exit For + 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 DtPedidosConceptosSurtidos IsNot Nothing Then + If DtPedidosConceptosSurtidos.SUMD("Surtido") <> DtPedidosConceptosSurtidos.SUMD("Cantidad") Then + OcurrioError = True + Alert("Lo facturado no coincide con lo surtido en inventario", TipoMensaje.MsgAdvertencia) + End If + End If + + End If + + End If + Else + OcurrioError = True + End If + + 'LIMPIAR EL DT DE CONCEPTOS SURTIDOS + If DtPedidosConceptosSurtidos IsNot Nothing Then + DtPedidosConceptosSurtidos.Clear() + DtPedidosConceptosSurtidos = 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 CuadrarFacturaMovimientosPedido(ByRef ObjVentas As ClsVentas, CvePedido 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 DtPedidosConceptosSurtidos Is Nothing Then + Dim DtDetallePedido As DataTable = Nothing + Dim StrCveVentasDetalle As New StringBuilder() + + If ObjVentas.GetVentaDetalle(CvePedido) Then + DtDetallePedido = ObjVentas.DtResultados.FiltraParametros("", DistinctColumns:={"CveVenta", "CveVentaDetalle"}) + End If + + For Each RowDetalle As DataRow In DtDetallePedido.Rows + StrCveVentasDetalle.AppendFormat("{0},", RowDetalle("CveVentaDetalle")) + Next + + If StrCveVentasDetalle.Length > 0 Then + StrCveVentasDetalle.Remove(StrCveVentasDetalle.Length - 1, 1) + End If + + If DtDetallePedido IsNot Nothing Then + + DtPedidosConceptosSurtidos = New DataTable + DtPedidosConceptosSurtidos.Columns.Add("CvePedido", GetType(Integer)) + DtPedidosConceptosSurtidos.Columns.Add("CveVentaDetalle", GetType(Integer)) + DtPedidosConceptosSurtidos.Columns.Add("Cantidad", GetType(Decimal)) + DtPedidosConceptosSurtidos.Columns.Add("Surtido", GetType(Decimal)) + + 'VERIFICA SOLO LOS QUE SON TIPO PRODUCTOS + For Each dr As DataRow In DtPedidosPS.FiltraParametros($"CveTipoPS = 2 AND CveVentaDetalle IN ({StrCveVentasDetalle.ToString()})").Rows + Dim dtr As DataRow = DtPedidosConceptosSurtidos.NewRow + dtr("CvePedido") = CvePedido + dtr("CveVentaDetalle") = dr("CveVentaDetalle") + dtr("Cantidad") = dr("Cantidad") + dtr("Surtido") = 0 + DtPedidosConceptosSurtidos.Rows.Add(dtr) + Next + End If + + End If + + For Each dr As DataRow In MovDetalle.Rows + Dim rowSurtidos As DataRow = DtPedidosConceptosSurtidos.FiltroPrimero($"CveVentaDetalle={dr("CveVentaDetalle")}") + Dim rowSurtidosP As DataRow = DtPedidosConceptosSurtidos.Select($"CveVentaDetalle={dr("CveVentaDetalle")}").FirstOrDefault + Dim Indice As Integer = DtPedidosConceptosSurtidos.Rows.IndexOf(rowSurtidosP) + + 'Si no se ha terminado de surtir agregamos el movimiento + If Indice >= 0 Then + ' rowSurtidos("Surtido").ToString().ToDouble < rowSurtidos("Cantidad").ToString().ToDouble AndAlso (dr("CantidadDisponible").ToString().ToDouble - rowSurtidos("Surtido").ToString().ToDouble > 0 Or dr("Serie").ToString() <> "") + If rowSurtidos("Surtido").ToString().ToDecimal < rowSurtidos("Cantidad").ToString().ToDecimal Then + Dim CantidadSurtida As Decimal = If(dr("CantidadDisponible").ToString().ToDecimal < rowSurtidos("Cantidad").ToString().ToDouble, dr("CantidadDisponible").ToString().ToDecimal, rowSurtidos("Cantidad").ToString().ToDecimal) + + 'SI LA CANTIDAD SURTIDA SUPERA LO REQUERIDO, TOMA SOLO LO NECESARIO PARA COMPLETAR + If (rowSurtidos("Surtido").ToString().ToDecimal + CantidadSurtida) > rowSurtidos("Cantidad").ToString().ToDecimal Then + CantidadSurtida = (rowSurtidos("Cantidad").ToString().ToDecimal - rowSurtidos("Surtido").ToString().ToDecimal) + End If + + MovDTCuadrados.ImportRow(dr) + MovDTCuadrados(MovDTCuadrados.Rows.Count - 1)("Cantidad") = CantidadSurtida + DtPedidosConceptosSurtidos(Indice)("Surtido") = rowSurtidos("Surtido").ToString().ToDecimal + CantidadSurtida + End If + Else + ErrorList.Add("Ocurrió un error al traspasar el inventario de la remisión") + Exit For + End If + Next + + Return MovDTCuadrados + End Function Private Function SalidaEntradaAlmacen(ByRef ObjInventario As ClsInventarios, CveRemision As Integer, ByRef ObjConta As ClsContabilidad) As Boolean Dim OcurrioError As Boolean = False Dim DtMovimientos As DataTable @@ -20222,7 +20434,7 @@ Partial Class Ventas AutoConta = AutocontaMatriz(AutoConta) - If UsuarioActual.CveEmpresa = 119 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ant", "Rem", "RNC", "Cot", "Ped", "Pd2", "PA", "Egs", "Dev") Then + If UsuarioActual.CveEmpresa = 119 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ant", "Rem", "RNC", "Cot", "Ped", "PA", "Egs", "Dev") Then AutoConta = False End If @@ -20460,6 +20672,172 @@ Partial Class Ventas Return Not OcurrioError End Function + Private Function GenerarMovimientoAlmacenPedido(ByRef ObjInventario As ClsInventarios, DtMovDetalle As DataTable, CveAlmacen As Integer, ConceptoEntrada As Integer, CveMoneda As Integer, CveVenta As Integer, Optional MovimientoPrePoliza As Boolean = True, + Optional ByRef ObjConta As ClsContabilidad = Nothing, Optional CveMovimientoRelacionado As Integer = -1, Optional AplicaMovimientoDetalleEntrada As Boolean = False, + Optional CveAlmacenDestino As Integer = -1) As Integer + Dim OcurrioError As Boolean = False + Dim ContadorMovtosDetalles As Integer = 0 + Dim CveMovimientoInventario As Integer = ObjInventario.AddMovimiento(CveAlmacen, ConceptoEntrada, CveMoneda, NowADS(), -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, -1, -1, + CveMovimientoRelacionado:=CveMovimientoRelacionado, CveAlmacenDestino:=CveAlmacenDestino, Modulo:="Vta/P1") + + If CveMovimientoInventario > 0 Then + + 'Agregamos los detalles + For Each MovDet As DataRow In DtMovDetalle.Rows + + Dim Cantidad As Decimal = 0 + Dim CantidadPedido As Decimal = DtPedidosTmpDT.FiltroPrimeroValor("Cantidad", $"CveVentaDetallePedido2={MovDet("CveVentaDetalle").ToString()}").ToDecimal + Dim CantidadInventario As Decimal = MovDet("Cantidad").ToString().ToDecimal + + If CantidadInventario >= CantidadPedido Then + Cantidad = CantidadPedido + Else + Cantidad = CantidadInventario + End If + + Dim CveUnidad As Integer = MovDet("CveUM").ToString().ToEntero() + Dim PU As Decimal = MovDet("PU").ToString().ToDecimal + Dim CveProducto As Integer = MovDet("CvePS").ToString().ToEntero() + Dim Serie As String = MovDet("Serie").ToString() + Dim Lote As String = MovDet("Lote").ToString() + Dim FechaCaducidad As Date = MovDet("FechaCaducidad").ToString.ToDate + Dim CveSeccionAlmacen As Integer = -3 'SE DEBE CALCULAR LA SECCION EL EN TRIGGER DE INVENTARIOS + Dim Consec As Integer = DtPedidosTmpDT.FiltroPrimeroValor("Consec", $"CveVentaDetalle = {MovDet("CveVentaDetalle").ToString()}").ToEntero() + + 'COMIENZA: VENTADETALLE + 'CUANDO SEA SALIDA VA POR LA VENTA DETALLE DE LA FACTURA DE LA REMISION - OJO!! SOLO FUNCIONA HASTA ORITA QUE SE HACE SALIDA SOLO CUANDO SE FACTURA LA REMISION + Dim CveVentaDetalle As Integer = If(ConceptoEntrada.Contiene(3, 40), TmpDT.FiltroPrimeroValor("CveVentaDetalle", $"Consec={Consec}").ToEntero(), MovDet("CveVentaDetalle").ToString().ToEntero()) + Dim CveVentaDetallePedido As Integer = -1 + If ConceptoEntrada = 40 AndAlso MovDet("CveVentaDetalle").ToString().ToEntero() > 0 Then + CveVentaDetallePedido = MovDet("CveVentaDetalle").ToString().ToEntero() + End If + + 'CUANDO LA VENTADETALLE NO TENGA VALOR DEBE MARCAR ERROR, NUEVA RESTRICCION DE ALMACEN + If CveVentaDetalle < 0 Then + Alert("no se encontro la venta detalle. Por favor comuniquese con atención SIG.", TipoMensaje.ToastError) + OcurrioError = True + Exit For + End If + 'TERMINA: VENTADETALLE + + If Cantidad < 0 Then + Alert("Ocurrió un Error al generar los movimientos de almacén. Por favor comuniquese con atención SIG.", TipoMensaje.MsgError) + OcurrioError = True + Exit For + End If + + 'CUANDO SEA REMISION FACTURADA DEBE RELACIONAR LOS NUEVOS MOVIMIENTOS POR EL DETALLE + Dim CveMovimientoDetalleEntrada As Integer = -1 + If AplicaMovimientoDetalleEntrada Then + CveMovimientoDetalleEntrada = MovDet("CveMovimientoDetalle").ToString().ToEntero() + End If + + If ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Cantidad, CveUnidad, CveProducto, PU, -1, CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad, CveVentaDetalle:=CveVentaDetalle, CveMovimientoDetalleEntrada:=CveMovimientoDetalleEntrada, CveVentaDetalleRemision:=CveVentaDetallePedido) Then + ContadorMovtosDetalles += 1 + Else + OcurrioError = True + Exit For + End If + Next + + 'Agregamos las PrePolizas + If Not OcurrioError Then + If MovimientoPrePoliza AndAlso CveMovimientoInventario > 0 Then + 'OcurrioError = Not GeneraPrePolizaMovimientoAlmacen(ObjInventario, ObjConta, ObjContPaq, ObjFactura, ObjFactura.CvePrePoliza, CveMovimientoInventario, CveAlmacen) + Dim CveSubProyectoPrePoliza As Integer = ObjFactura.CveSubProyecto + If CveAlmacen > 0 Then + Dim CveSubProyectoAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=CveAlmacen).FiltroPrimeroValor("CveSubProyecto").ToString().ToEntero() + If CveSubProyectoAlmacen > 0 Then + CveSubProyectoPrePoliza = CveSubProyectoAlmacen + End If + End If + + If ObjInventario.GetMovimientosDetalle(CveMovimientoInventario, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then + Dim DtCostos As DataTable = ObjInventario.DtResultados.Copy + Dim DtCostosDistinct As DataTable = ObjInventario.DtResultados.FiltraParametros("", "", {"CveClasificacion"}) + Dim ValorInventario As Decimal + Dim TotalCostoAcumulado As Decimal = 0D + Dim Cont As Integer = 1 + Dim TotalCosto As Decimal = DtCostos.SUMD("Total").RoundSQL + Dim TipoMovto69 As Boolean = False + + 'SI ES MOVIMIENTO DE ENTRADA CAMBIAR LA NATURALEZA DEL MOVIMIENTO + If ConceptoEntrada.Contiene(9) Then + TipoMovto69 = True + End If + + For Each RowInv As DataRow In DtCostosDistinct.Rows + ValorInventario = DtCostos.SUMD("Total", String.Format("CveClasificacion = {0}", RowInv("CveClasificacion"))).RoundSQL + TotalCostoAcumulado += ValorInventario + + 'cuando es el último movimiento y hay diferencias en los importes + If Cont = DtCostosDistinct.Rows.Count AndAlso TotalCosto <> TotalCostoAcumulado Then + ValorInventario = ValorInventario + (TotalCosto - TotalCostoAcumulado) + End If + + Try + Dim CveSubProyecto69 As Integer = CveSubProyectoPrePoliza + If UsuarioActual.CveEmpresa = 119 Then + CveSubProyecto69 = ObjFactura.CveSubProyecto + End If + + 'If ValorInventario <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovto69, ValorInventario, ValorInventario, 69, ObjFactura.SerieFolio, ObjFactura.SerieFolio, CveVenta:=CveVenta, CveCliente:=ObjFactura.CveCliente, CveClasificacion:=RowInv("CveClasificacion").ToString().ToEntero(), CveMovimientoAlmacen:=CveMovimientoInventario, CveSubProyecto:=CveSubProyecto69) Then + OcurrioError = True + Exit For + End If + 'End If + Catch ex As Exception + OcurrioError = True + ModExtensiones.GuardaLog("Error inesperado (15147)." + ex.ToString()) + Alert("Error inesperado (15147). Por favor comuniquese con atención SIG.", TipoMensaje.ToastError) + End Try + Cont += 1 + Next + + If Not OcurrioError Then + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovto69, TotalCosto, TotalCosto, 68, ObjFactura.SerieFolio, ObjFactura.SerieFolio, CveVenta:=CveVenta, CveCliente:=ObjFactura.CveCliente, CveMovimientoAlmacen:=CveMovimientoInventario, CveSubProyecto:=CveSubProyectoPrePoliza) Then + OcurrioError = True + End If + End If + + If Not OcurrioError AndAlso UsuarioActual.CveEmpresa = 119 Then + If ObjInventario.GetVentasPedimento(CveVenta, UsuarioActual.CveEmpresa) Then + Dim dttped As DataTable = ObjInventario.DtResultados + + For Each drt As DataRow In dttped.FiltraParametros("Pedimento <> ''").Rows + ObjInventario.UpdateVentasDetalleNumeroPedimento(CveVenta, drt("CveVentaDetalle").ToString.ToEntero, drt("Pedimento").ToString) + Dim dtr As DataRow() = TmpDT.Select($"CveVentaDetalle ={drt("CveVentaDetalle")}") + If dtr IsNot Nothing Then 'actualizamos los datos temporales para timbrar + dtr(0)("NumeroPedimento") = drt("Pedimento").ToString + End If + Next + End If + End If + Else + OcurrioError = True + End If + End If + End If + + 'VALIDA QUE SE HALLAN AGREGADO DETALLES AL MOVIMIENTO + If ContadorMovtosDetalles = 0 Then + OcurrioError = True + End If + Else + OcurrioError = True + End If + + If OcurrioError Then + Return -1 + Else + Return CveMovimientoInventario + End If + 'Return Not OcurrioError + + End Function + + Private Function SalidaAlmacenMateriales(ByRef ObjInventario As ClsInventarios, CveOS As Integer, ByRef ObjConta As ClsContabilidad, ConSalida As Boolean, ConceptoMovimiento As Integer) As Boolean Dim TieneError As Boolean = False Dim CveMovimientoSalida As Integer = 0 @@ -22805,12 +23183,12 @@ Partial Class Ventas 'SI TIENE UN ANTICIPO RELACIONADO O VIENE DE UNA REFACTURACION If RowVentas IsNot Nothing Then - If RowVentas("TipoDocto").ToString().Contiene("Ing", "Ant") AndAlso DdlTipoComprobante.SelectedValue = "Ing" Then + If RowVentas("TipoDocto").ToString().Contiene("Ing", "Ant", "Ped") AndAlso DdlTipoComprobante.SelectedValue = "Ing" Then CargaInventario(Me.CveVenta) End If End If Else - If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Dev", "RNC") Then + If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Dev", "RNC", "Ped") Then CargaInventario(Me.CveVenta) End If End If @@ -23566,7 +23944,7 @@ Partial Class Ventas Private Sub LbCancelarDocumento_Click(sender As Object, e As EventArgs) Handles LbCancelarDocumento.Click Dim SaldoAlmacen As Decimal = 0 - If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Dev") Then + If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Dev", "Ped") Then Dim PermiteCancelar As Boolean = True Using ObjVentas As New ClsVentas @@ -23604,6 +23982,14 @@ Partial Class Ventas ChkDevAlm.Enabled = False End If + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then + DivDevAlm.Visible = True + TieneAlmacen = True + + ChkDevAlm.Checked = True + ChkDevAlm.Enabled = False + End If + If (CveVenta > 0 AndAlso DdlTipoComprobante.SelectedValue <> "Cot") AndAlso Not AplicaDevolucion Then Using ObjInv As New ClsInventarios If ObjInv.GetInv_Mov(Me.CveVenta, UsuarioActual.CveEmpresa) AndAlso ObjInv.DtResultados.Rows.Count > 0 Then @@ -23642,7 +24028,7 @@ Partial Class Ventas Dim SWatch As New Stopwatch SWatch.Start() - Dim Vigencia As timbrado.AcuseCancelacionSAT = Timbrado.VerificarVigenciaSAT(FolioFiscal, UsuarioActual.Empresa.RFC, RFCReceptor, TotalT.ToString(), True) + Dim Vigencia As Timbrado.AcuseCancelacionSAT = Timbrado.VerificarVigenciaSAT(FolioFiscal, UsuarioActual.Empresa.RFC, RFCReceptor, TotalT.ToString(), True) SWatch.Stop() @@ -23744,14 +24130,14 @@ Partial Class Ventas RegistraScript("$('#ModalCancelarDocumento').modal();") UpCancelarDocumento.Update() sb.Clear() - ElseIf DdlTipoComprobante.SelectedValue.Contiene("Pd2") Then - Dim ObjVentas As New ClsVentas - If ObjVentas.UpdateEstatusVenta(CveVenta, 22, UsuarioActual.CveEmpresa) Then - Dim redirectString As String = String.Format("document.location.href=""/Ventas/Ventas.aspx?CveVenta={0}""", CveVenta) - Alert("Pedido cancelado.", JSBtnAceptar:=redirectString) - ', "document.location.href=""/Ventas/Ventas.aspx?CveVenta=" & CveVenta - End If - ObjVentas.Dispose() + 'ElseIf DdlTipoComprobante.SelectedValue.Contiene("Ped") Then + ' Dim ObjVentas As New ClsVentas + ' If ObjVentas.UpdateEstatusVenta(CveVenta, 22, UsuarioActual.CveEmpresa) Then + ' Dim redirectString As String = String.Format("document.location.href=""/Ventas/Ventas.aspx?CveVenta={0}""", CveVenta) + ' Alert("Pedido cancelado.", JSBtnAceptar:=redirectString) + ' ', "document.location.href=""/Ventas/Ventas.aspx?CveVenta=" & CveVenta + ' End If + ' ObjVentas.Dispose() ElseIf DdlTipoComprobante.SelectedValue.Contiene("RNC") Then LblCancelarDocumento.Text = "¿Desea cancelar la remisión de nota de crédito?
" Dim sbExtra As New StringBuilder @@ -23985,6 +24371,10 @@ Partial Class Ventas ChkDevAlm.Checked = True End If + If UsuarioActual.Empresa.Funcionalidad(578) = "1" AndAlso ObjFacturaCancelacion.TipoDocto = "Ped" Then + ChkDevAlm.Checked = True + End If + resp = ObjFacturaCancelacion.CancelarFactura(ChkDevAlm.Checked, ListaRemisionesCancelar, CveMotivoCancelacion:=DdlMotivoCancelacion.SelectedValue.ToEntero(), Motivo:=TxtMotivoCancelacion.Text.Trim(), CveEstadoCancelacion:=Me.CveEstadoCancelacion) strMensaje.Append(resp.Mensaje) Dim DtBonificaciones As DataTable = Nothing @@ -29892,10 +30282,10 @@ Partial Class Ventas 'RE-INSERTA DETALLES For Each Row As DataRow In TmpDT.Rows - If Not ObjVentas.AddVentaDetalle(CveVenta, Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().todecimal, Row("CveUM").ToString().ToEntero(), - Row("PU").ToString().todecimal(), Row("ImporteIVA").ToString().todecimal, Math.Round((Row("Total").ToString().todecimal() * (1 + Row("PorcentajeIVA").ToString().todecimal())), 6), - Row("Obs").ToString(), Row("Descuento").ToString().todecimal(), Row("TipoDescuento").ToString().ToEntero(), Row("CveSubProyecto").ToString().ToEntero(), Row("CvePresupuestoIngreso").ToString().ToEntero(), - PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, IEPS:=Row("ImporteIEPS").ToString().todecimal(), PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().todecimal, TiempoEntrega:=Row("TiempoEntrega").ToString(), + If Not ObjVentas.AddVentaDetalle(CveVenta, Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDecimal, Row("CveUM").ToString().ToEntero(), + Row("PU").ToString().ToDecimal(), Row("ImporteIVA").ToString().ToDecimal, Math.Round((Row("Total").ToString().ToDecimal() * (1 + Row("PorcentajeIVA").ToString().ToDecimal())), 6), + Row("Obs").ToString(), Row("Descuento").ToString().ToDecimal(), Row("TipoDescuento").ToString().ToEntero(), Row("CveSubProyecto").ToString().ToEntero(), Row("CvePresupuestoIngreso").ToString().ToEntero(), + PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, IEPS:=Row("ImporteIEPS").ToString().ToDecimal(), PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().ToDecimal, TiempoEntrega:=Row("TiempoEntrega").ToString(), PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString().ToDecimal, ImporteRetIVA:=Row("ImporteRetIVA").ToString().ToDecimal) Then MensajeError = "Ocurrió un error al guardar las partidas de la cotización" OcurrioError = True @@ -31189,12 +31579,12 @@ Partial Class Ventas Dim ObjVentas As New ClsVentas If ObjVentas.GetVentasPedidos2Totales(CveCliente, Cves.ToString(), If(ChkMostrarProductosPedido2.Checked, 2, 1)) Then - DtPedidos2PS = ObjVentas.DtResultados + DtPedidosPS = ObjVentas.DtResultados End If ObjVentas.Dispose() Cves.Clear() - If Not AgregaPSPedido2() Then + If Not AgregaPSPedido() Then Alert("Ocurrió un error validar las partidas de los pedidos seleccionadas. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) Exit Sub End If @@ -31266,11 +31656,16 @@ Partial Class Ventas Next End If End Sub - Private Function AgregaPSPedido2() As Boolean - If DtPedidos2PS IsNot Nothing Then + Private Function AgregaPSPedido(Optional FacturarPedidoActual As Boolean = False) As Boolean + If DtPedidosPS IsNot Nothing Then Dim tCantidad As Decimal = 0 - For Each Dr As DataRow In DtPedidos2PS.Select() - tCantidad = If(ChkMostrarProductosPedido2.Checked, GvPedidos2SinFacturarPS.Rows(IndiceGVDataKey(GvPedidos2SinFacturarPS, "CveVentaDetalle", $"{Dr("CveVentaDetalle")}")).FCTextBox("TxtCantidadPedido2").Text, Dr("Cantidad")).ToString().ToDecimal + For Each Dr As DataRow In DtPedidosPS.Select() + If Not FacturarPedidoActual Then + tCantidad = If(ChkMostrarProductosPedido2.Checked, GvPedidos2SinFacturarPS.Rows(IndiceGVDataKey(GvPedidos2SinFacturarPS, "CveVentaDetalle", $"{Dr("CveVentaDetalle")}")).FCTextBox("TxtCantidadPedido2").Text, Dr("Cantidad")).ToString().ToDecimal + Else + tCantidad = Dr("Cantidad").ToString().ToDecimal() + End If + AgregarProductoServicio(tCantidad, Dr("CveUM").ToString().ToEntero(), Dr("UM").ToString(), Dr("CveClasificacion").ToString().ToEntero(), Dr("Clasificacion").ToString(), Dr("CvePS").ToString().ToEntero(), Dr("PS").ToString(), Dr("Obs").ToString(), Dr("PU").ToString().ToDecimal, Dr("Descuento").ToString().ToDecimal, Dr("CveProyecto").ToString().ToEntero(), Dr("Proyecto").ToString(), Dr("CveSubProyecto").ToString().ToEntero(), Dr("SubProyecto").ToString(), @@ -31288,6 +31683,8 @@ Partial Class Ventas #Region " PEDIDOS2 - FACTURAR " Private Function PreparaFacturarPedido() As Boolean + Dim FacturarPedidoActual = If(CveVenta > 0, True, False) + 'LIMPIAMOS TmpDT.Rows.Clear() TxtSubTotal.Text = "0.00" @@ -31302,17 +31699,17 @@ Partial Class Ventas Dim ObjVentas As New ClsVentas If ObjVentas.GetVentasPedidos2Totales(CveCliente, CveVenta.ToString(), 1) Then - DtPedidos2PS = ObjVentas.DtResultados + DtPedidosPS = ObjVentas.DtResultados End If ObjVentas.Dispose() - If Not AgregaPSPedido2() Then + If Not AgregaPSPedido(FacturarPedidoActual) Then Alert("Ocurrió un error validar las partidas de los pedidos seleccionadas. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) Return False End If If TmpDT.Rows.Count = 0 Then - Alert("No hay conceptos por facturar de esta cotización o ha sido cambiada su información. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Alert("No hay conceptos por facturar de este pedido o ha sido cambiada su información. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) Return False End If @@ -31327,59 +31724,6 @@ Partial Class Ventas #Region " CREAR APARTIR DE " Protected Sub BtnCrearApartirDe_Click(sender As Object, e As System.EventArgs) Handles BtnCrearApartirDe.Click - ''[IPP-2Novimebre2018] COMENTADO POR SER UNA FUNCIONALIDAD SUPER RARA! LA REEMPLAZA EL EDITAR COTIZACION - ''Cuando es Cotizacion, actualiza la original - 'If DdlTipoComprobante.SelectedValue = "Cot" AndAlso BtnCrearApartirDe.Text = "Guardar Cambios" Then - ' Dim OcurrioError As Boolean = False - ' Dim ObjVentas As New ClsVentas - ' ObjVentas.IniciaTransacSQL() - - ' 'Elimino los movimientos del detalle de Ventas (Conceptos) - ' If Not ObjVentas.RemoveVentasDetalle(CveVenta) Then OcurrioError = True - - ' 'Actualizo los parametros de la venta - ' If Not ObjVentas.UpdateVentas(TxtSubTotal.Text.Replace(",", "").ToDouble, LblDescuentos.Text.ToDouble, TxtIVA.Text.ToDouble, TxtIEPS.Text.ToDouble, TxtTotal.Text.ToDouble, - ' DdlMoneda.SelectedValue.ToEntero(), TxtTipoCambio.Text.Trim.ToDouble, TxtFecha.Text.Trim.ToDate, TxtObsFact.Text.Trim, UsuarioActual.CveEmpresa, CveVenta, DdlMetodoPago.SelectedValue.ToEntero(), - ' DdlFormaPago.SelectedValue.ToEntero(), TxtNumCtaPago.Text.Trim, AtencionA:=TxtAtencionA.Text.Trim, CveMetodoPago33:=DdlMetodoPago33.SelectedValue.ToEntero(), CveFormaPago33:=DdlFormaPago33.SelectedValue.ToEntero()) Then - ' OcurrioError = True - ' End If - - ' 'Cargo de nueva cuenta el detalle de Ventas (Conceptos) - ' For Each Row As DataRow In TmpDT.Rows - ' If Not ObjVentas.AddVentaDetalle(CveVenta, Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDouble, Row("CveUM").ToString().ToEntero(), - ' Row("PU").ToString().ToDouble, Row("IVA").ToString().ToDouble, Math.Round((Row("Total").ToString().ToDouble * (1 + Row("IVA").ToString().ToDouble)), 6), - ' Row("Obs").ToString(), Row("Descuento").ToString().ToDouble, Row("TipoDescuento").ToString().ToEntero(), Row("CveSubProyecto").ToString().ToEntero(), Row("CvePresupuestoIngreso").ToString().ToEntero(), IEPS:=Row("IEPS").ToString().ToDouble) Then - ' OcurrioError = True - ' Exit For - ' End If - ' Next - - ' If OcurrioError Then - ' ObjVentas.RollBack() - ' Alert("Ocurrió un error al guardar los cambios. Por favor intente de nuevo.", TipoMensaje.MsgError) - ' Else - ' '/Ventas/Ventas.aspx?CveVenta={0}&Tipo=Cot - ' Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Ventas/Ventas.aspx?CveVenta=" & CveVenta & "&&Tipo=Cot"";") - - ' BtnCrearApartirDe.Text = "Editar" - ' ObjVentas.Commit() - - ' ' GeneraPDFCot(TxtFecha.Text.Trim.ToDate, DTPS, VentaFolio, False, False) - ' End If - - ' ObjVentas.Dispose() - ' Exit Sub - 'End If - - ''[IPP-2Novimebre2018] COMENTADO POR SER UNA FUNCIONALIDAD SUPER RARA! LA REEMPLAZA EL EDITAR COTIZACION - 'If DdlTipoComprobante.SelectedValue = "Cot" Then - ' BtnCrearApartirDe.Text = "Guardar Cambios" - ' DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Egs")) - ' DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Dev")) - ' DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Pd2")) - 'Else - ' BtnCrearApartirDe.Visible = False - 'End If Dim FolioOriginal As String = TxtFolio.Text @@ -31664,7 +32008,7 @@ Partial Class Ventas #Region " GENERAR REMISION " Private Sub BtnGenerarRemision_Click(sender As Object, e As EventArgs) Handles BtnGenerarRemision.Click - If DdlTipoComprobante.SelectedValue.Contiene("Cot", "PA", "Pd2") Then 'CUANDO ES COTIZACION O PEDIDOA O PEDIDO2 SE HARA REMISION + If DdlTipoComprobante.SelectedValue.Contiene("Cot", "PA", "Ped") Then 'CUANDO ES COTIZACION O PEDIDOA O PEDIDO2 SE HARA REMISION EraCotizacion = If(DdlTipoComprobante.SelectedValue = "Cot", 1, 0) 'DdlTipoComprobante.SelectedValue = "Rem" EmitirDocumentoNuevo("Rem") @@ -31675,8 +32019,7 @@ Partial Class Ventas #Region "GENERAR AUTORIZACIÓN" Protected Sub BtnGeneraAutorizacion_Click(sender As Object, e As EventArgs) - If DdlTipoComprobante.SelectedValue.Contiene("Pd2") Then - + If DdlTipoComprobante.SelectedValue.Contiene("Ped") Then EmitirDocumentoNuevo("PA") End If End Sub @@ -31795,9 +32138,9 @@ Partial Class Ventas End If 'CARGA LO PENDIENTE POR FACTURAR DE PEDIDO2 - If DdlTipoComprobante.SelectedValue = "Pd2" Then + If DdlTipoComprobante.SelectedValue = "Ped" Then If Not PreparaFacturarPedido() Then - DdlTipoComprobante.SelectedValue = "Pd2" + DdlTipoComprobante.SelectedValue = "Ped" Exit Sub End If End If