diff --git a/App_Code/ClsOC.vb b/App_Code/ClsOC.vb index 463101747..0cbe50889 100644 --- a/App_Code/ClsOC.vb +++ b/App_Code/ClsOC.vb @@ -1230,7 +1230,7 @@ Public Class ClsOC pObservacion As String, pCveUsuario As Integer, Optional pCveOrdenCompraPadre As Integer = -1, Optional CvePresupuestoEgreso As Integer = -1, Optional Descuento As Double = 0, Optional IEPSPS As Double = 0, Optional IEPSPSIVA As Double = 0, Optional IVA As Double = 0, Optional RetIVA As Double = 0, Optional RetISR As Double = 0, Optional Total As Double = 0, Optional CveContratoDetalle As Integer = -1, Optional IVAPorcentaje As Double = 0, Optional RetIVAPorcentaje As Double = 0, Optional RetISRPorcentaje As Double = 0, Optional IEPSPSPorcentaje As Double = 0, - Optional IEPSPSIVAPorcentaje As Double = 0) As Boolean + Optional IEPSPSIVAPorcentaje As Double = 0, Optional CveVentaDetalleCotizacion As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_OC_OrdenesCompraDetalleAdd") @@ -1259,7 +1259,8 @@ Public Class ClsOC .Add("@RetIVAPorcentaje", SqlDbType.Float).Value = RetIVAPorcentaje .Add("@RetISRPorcentaje", SqlDbType.Float).Value = RetISRPorcentaje .Add("@IEPSPSPorcentaje", SqlDbType.Float).Value = IEPSPSPorcentaje - .Add("@IEPSPSIVAPorcentaje", SqlDbType.Float).Value = IEPSPSIVAPorcentaje + .Add("@IEPSPSIVAPorcentaje", SqlDbType.Float).Value = IEPSPSIVAPorcentaje + .Add("@CveVentaDetalleCotizacion", SqlDbType.Int).Value = CveVentaDetalleCotizacion End With Try diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index 7334abade..04e7b8bb6 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -179,6 +179,25 @@ Public Class ClsVentas Return Retorno End Function + Public Function GetVentasCotizacionesOC(CveVenta As Integer, CveOC As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasCotizacionesOCGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveOC", SqlDbType.Int).Value = CveOC + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los datos de la cotizacion, VentaTerminal.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function Public Function GetVentas(CveEmpresa As Integer, TipoDocto As String, Serie As String, Folio As Integer, Codigo As String, CveCliente As Integer, CveSubProyecto As Integer, CveEstatus As Integer, CveUsuario As Integer, FechaI As String, FechaF As String, FolioFiscal As String, Optional CveClienteSucursal As Integer = -1, Optional CvePS As Integer = -1, Optional PedidoContrato As String = "-1", Optional OrdenCompra As String = "-1", Optional CveUsuarioConsulta As Integer = -1, Optional ClienteRFC As String = "-1", @@ -3934,7 +3953,7 @@ Public Class ClsVentas Return retorno End Function - Public Function RepIngresosDetalle(CveEmpresa As Integer, FechaInicio As Date, FechaFin As Date, TipoDocto As String, CveSubProyecto As Integer, CveConceptoContable As Integer, CveCuenta As Integer) As Boolean + Public Function RepIngresosDetalle(CveEmpresa As Integer, FechaInicio As Date, FechaFin As Date, TipoDocto As String, CveSubProyecto As Integer, CveConceptoContable As Integer, CveCuenta As Integer, TipoAmortizacion As Integer) As Boolean Dim retorno As Boolean = False DataAdapter("PA_Ventas_RepIngresosDetalle", CommandType.StoredProcedure) With SqlAdapter.SelectCommand.Parameters @@ -3945,6 +3964,7 @@ Public Class ClsVentas .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + .Add("@TipoAmortizacion", SqlDbType.Int).Value = TipoAmortizacion End With Try SqlAdapter.Fill(Data) diff --git a/OC/OC.aspx.vb b/OC/OC.aspx.vb index 4e74dad9d..f1b7bf225 100644 --- a/OC/OC.aspx.vb +++ b/OC/OC.aspx.vb @@ -534,6 +534,18 @@ Partial Class OC End If End If + Dim DtOCGeneradas As DataTable = Nothing + If ObjVentas.GetVentasCotizacionesOC(Me.CveVenta, -1, UsuarioActual.CveEmpresa) Then + DtOCGeneradas = ObjVentas.DtResultados.Copy() + End If + + If DtOCGeneradas IsNot Nothing AndAlso DtOCGeneradas.Rows.Count > 0 Then + ObjVentas.Dispose() + BtnGuardar.Enabled = False + Alert("Ya existe una OC con esta cotización", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + CargaClasificacionesPopUp(CveCotizacion) ObjVentas.Dispose() End If @@ -971,6 +983,8 @@ Partial Class OC DtDetalle.Columns.Add("CveContratoDetalle", GetType(Integer)) DtDetalle.Columns.Add("CantidadNoEditable", GetType(Double)) + DtDetalle.Columns.Add("CveVentaDetalleCotizacion", GetType(Integer)) + 'DtDetalle.Columns.Add("CveOrdenCompraDetalle", GetType(Integer)) ' DtDetalle.Columns.Add("ClasificacionOG", GetType(String)) @@ -1040,6 +1054,10 @@ Partial Class OC dr("CveTipoGasto") = -1 dr("CveClasificacionOG") = -1 + If UsuarioActual.Empresa.Funcionalidad(583) = "1" Then + dr("CveVentaDetalleCotizacion") = RowV("CveVentaDetalle") + End If + DtDetalle.Rows.Add(dr) Next @@ -2318,7 +2336,7 @@ Partial Class OC Dim OCBitacora As New ClsOIEventos(OC.IniciaTransacSQL()) Dim ObjInventarios As New ClsInventarios(OC.IniciaTransacSQL()) Dim ObjConta As New ClsContabilidad(OC.IniciaTransacSQL()) - + Dim ObjVentas As New ClsVentas(OC.IniciaTransacSQL()) Dim Conta As ClsContPAQi = Nothing If (UsuarioActual.Empresa.UsaAC AndAlso VerificaPresupuesto) Or UsuarioActual.Empresa.Funcionalidad(200) = "1" Then Conta = New ClsContPAQi(UsuarioActual.Empresa) @@ -2361,7 +2379,12 @@ Partial Class OC CveOrdenCompraPadre = OC.CveOrdenCompra If CveOrdenCompraPadre > 0 Then For Each dr As DataRow In DtDetalle.Rows - If Not OC.AddOrdenCompraDetalle(CveOrdenCompraPadre, dr("Cantidad").ToString.ToDouble(), dr("CveUnidadMedida").ToString.ToEntero, dr("CvePS").ToString.ToEntero, dr("Importe").ToString.ToDouble, dr("CveSubProyecto").ToString.ToEntero(), dr("CveActivoFijo").ToString.ToEntero, dr("Observacion").ToString, UsuarioActual.CveUsuario, Descuento:=dr("Descuento").ToString.ToDouble, IEPSPS:=dr("IEPSPS").ToString.ToDouble, IEPSPSIVA:=dr("IEPSPSIVA").ToString.ToDouble, IVA:=dr("IVA").ToString.ToDouble, RetIVA:=dr("RetIVA").ToString.ToDouble, RetISR:=dr("RetISR").ToString.ToDouble, Total:=dr("Total").ToString.ToDouble, CveContratoDetalle:=dr("CveContratoDetalle").ToString.ToEntero, IVAPorcentaje:=dr("IVAPorcentaje").ToString.ToDouble, RetIVAPorcentaje:=dr("RetIVAPorcentaje").ToString.ToDouble, RetISRPorcentaje:=dr("RetISRPorcentaje").ToString.ToDouble, IEPSPSPorcentaje:=dr("IEPSPSPorcentaje").ToString.ToDouble, IEPSPSIVAPorcentaje:=dr("IEPSPSIVAPorcentaje").ToString.ToDouble) Then + If Not OC.AddOrdenCompraDetalle(CveOrdenCompraPadre, dr("Cantidad").ToString.ToDouble(), dr("CveUnidadMedida").ToString.ToEntero, dr("CvePS").ToString.ToEntero, dr("Importe").ToString.ToDouble, + dr("CveSubProyecto").ToString.ToEntero(), dr("CveActivoFijo").ToString.ToEntero, dr("Observacion").ToString, UsuarioActual.CveUsuario, Descuento:=dr("Descuento").ToString.ToDouble, + IEPSPS:=dr("IEPSPS").ToString.ToDouble, IEPSPSIVA:=dr("IEPSPSIVA").ToString.ToDouble, IVA:=dr("IVA").ToString.ToDouble, RetIVA:=dr("RetIVA").ToString.ToDouble, + RetISR:=dr("RetISR").ToString.ToDouble, Total:=dr("Total").ToString.ToDouble, CveContratoDetalle:=dr("CveContratoDetalle").ToString.ToEntero, IVAPorcentaje:=dr("IVAPorcentaje").ToString.ToDouble, + RetIVAPorcentaje:=dr("RetIVAPorcentaje").ToString.ToDouble, RetISRPorcentaje:=dr("RetISRPorcentaje").ToString.ToDouble, IEPSPSPorcentaje:=dr("IEPSPSPorcentaje").ToString.ToDouble, + IEPSPSIVAPorcentaje:=dr("IEPSPSIVAPorcentaje").ToString.ToDouble) Then TieneError = True Exit For End If @@ -2435,11 +2458,20 @@ Partial Class OC For Each dr As DataRow In DtDetalle.Rows - If Not OC.AddOrdenCompraDetalle(CveOrdenCompra, dr("Cantidad").ToString.ToDouble(), dr("CveUnidadMedida").ToString.ToEntero, dr("CvePS").ToString.ToEntero, dr("Importe").ToString.ToDouble, dr("CveSubProyecto").ToString.ToEntero(), dr("CveActivoFijo").ToString.ToEntero, dr("Observacion").ToString, UsuarioActual.CveUsuario, CvePresupuestoEgreso:=dr("CvePresupuestoEgreso").ToString.ToEntero, pCveOrdenCompraPadre:=CveOrdenCompraPadre, Descuento:=dr("Descuento").ToString.ToDouble, IEPSPS:=dr("IEPSPS").ToString.ToDouble, IEPSPSIVA:=dr("IEPSPSIVA").ToString.ToDouble, IVA:=dr("IVA").ToString.ToDouble, RetIVA:=dr("RetIVA").ToString.ToDouble, RetISR:=dr("RetISR").ToString.ToDouble, Total:=dr("Total").ToString.ToDouble, CveContratoDetalle:=dr("CveContratoDetalle").ToString.ToEntero, IVAPorcentaje:=dr("IVAPorcentaje").ToString.ToDouble, RetIVAPorcentaje:=dr("RetIVAPorcentaje").ToString.ToDouble, RetISRPorcentaje:=dr("RetISRPorcentaje").ToString.ToDouble, IEPSPSPorcentaje:=dr("IEPSPSPorcentaje").ToString.ToDouble, IEPSPSIVAPorcentaje:=dr("IEPSPSIVAPorcentaje").ToString.ToDouble) Then + If Not OC.AddOrdenCompraDetalle(CveOrdenCompra, dr("Cantidad").ToString.ToDouble(), dr("CveUnidadMedida").ToString.ToEntero, dr("CvePS").ToString.ToEntero, dr("Importe").ToString.ToDouble, dr("CveSubProyecto").ToString.ToEntero(), dr("CveActivoFijo").ToString.ToEntero, + dr("Observacion").ToString, UsuarioActual.CveUsuario, CvePresupuestoEgreso:=dr("CvePresupuestoEgreso").ToString.ToEntero, pCveOrdenCompraPadre:=CveOrdenCompraPadre, Descuento:=dr("Descuento").ToString.ToDouble, IEPSPS:=dr("IEPSPS").ToString.ToDouble, + IEPSPSIVA:=dr("IEPSPSIVA").ToString.ToDouble, IVA:=dr("IVA").ToString.ToDouble, RetIVA:=dr("RetIVA").ToString.ToDouble, RetISR:=dr("RetISR").ToString.ToDouble, Total:=dr("Total").ToString.ToDouble, CveContratoDetalle:=dr("CveContratoDetalle").ToString.ToEntero, + IVAPorcentaje:=dr("IVAPorcentaje").ToString.ToDouble, RetIVAPorcentaje:=dr("RetIVAPorcentaje").ToString.ToDouble, RetISRPorcentaje:=dr("RetISRPorcentaje").ToString.ToDouble, IEPSPSPorcentaje:=dr("IEPSPSPorcentaje").ToString.ToDouble, + IEPSPSIVAPorcentaje:=dr("IEPSPSIVAPorcentaje").ToString.ToDouble, CveVentaDetalleCotizacion:=dr("CveVentaDetalleCotizacion").ToString().ToEntero()) Then TieneError = True Exit For End If Next + + If Not TieneError AndAlso UsuarioActual.Empresa.Funcionalidad(583) = "1" Then + TieneError = Not ActualizarCotizacion(ObjVentas) + End If + Else TieneError = True End If @@ -2887,6 +2919,7 @@ Partial Class OC Else 'TERMINA TODO POR SI OCURRIÓ ALGO RARO If OC IsNot Nothing Then OC.Dispose() + If ObjVentas IsNot Nothing Then ObjVentas.Dispose() If Conta IsNot Nothing Then Conta.Dispose() 'MANDA CORREOS SI EL ESTATUS ES MAYOR A 0 @@ -5043,7 +5076,7 @@ Partial Class OC End Function #End Region -#Region " COTIZACIONES " +#Region "C O T I Z A C I O N E S" Protected Sub VerificaSiRequiereCotizacion() If TipoOC = "REQ" Then If ChkCotizacion.Checked Then @@ -5083,6 +5116,32 @@ Partial Class OC VerificaCotizacionesGanadoras() End If End Sub + + Protected Function ActualizarCotizacion(ByRef ObjVentas As ClsVentas) As Boolean + Dim OcurrioError As Boolean = False + Try + Dim PorcentajeGanancia As Decimal = 0.1D + For Each Row As DataRow In DtDetalle.Rows + Dim CvePS As Integer = Row("CvePS").ToString.ToEntero + Dim DrPS = GlobalDTPS(CveEmpresaActual, CvePS:=CvePS).FiltroPrimero("") + + Dim Cantidad As Decimal = Row("Cantidad").ToString.ToDecimal + Dim PU As Decimal = Row("Importe").ToString.ToDecimal() + (Row("Importe").ToString.ToDecimal() * PorcentajeGanancia) + Dim IEPSPS As Decimal = DrPS("IEPSPorcentaje").ToString.ToDecimal + Dim ImporteIEPS As Decimal = ((Cantidad * PU) * IEPSPS).RoundSQL(2) + + If Not ObjVentas.UpdateVentaDetalleRemision(Row("CveVentaDetalleCotizacion").ToString.ToEntero, CvePS, Cantidad, PU, ImporteIEPS, "", UsuarioActual.CveUsuario) Then + OcurrioError = True + Exit For + End If + Next + Catch ex As Exception + OcurrioError = True + OnError("Ocurrió un error al guardar la cotización", ex) + End Try + + Return Not OcurrioError + End Function #End Region Private Function notienepresupuesto() As Boolean @@ -7544,4 +7603,5 @@ Partial Class OC End Sub #End Region + End Class diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 40b64fa71..840c535f4 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -308,6 +308,9 @@ <%----%> Saldar +
  • + Generar Orden de Compra +
  • @@ -3541,7 +3544,7 @@
    + DataKeyNames="ISTotal,Saldo,CveIE,Folio,Tipo,CveVenta,CveConceptoContable,CveConceptoContableAmor, TotalAnticipo, SubTotalAnticipo, IVAAnticipo, ImpuestosLocalesAnticipo, SubTotalAmortizacion, SubTotal, Original, IVA, RetIVA, RetISR, IdCtaContableNC,FolioFiscal, CveClasificacionNC, IdCtaContableNCSIG, TipoCambio,TipoCambioPago,TipoCambioHoy, CveMoneda,Fecha,SaldoSubTotal"> diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index d5fb792ac..4713b0e7e 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -3543,6 +3543,7 @@ Partial Class Ventas ' LbCancelarDocumentoManual.Visible = True 'End If + If Not CveEstatus.Contiene(4, 5, 12, 13, 20) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Egs", "Ant") AndAlso 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 @@ -4362,6 +4363,19 @@ Partial Class Ventas CargaCodigoUnico() + 'SI ES COTIZACION PUEDE GENERAR UNA OC PARA MODIFICAR LOS IMPORTES + If DdlTipoComprobante.SelectedValue = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(583) = "1" Then + Dim DtOCGeneradas As DataTable = Nothing + If ObjVentas.GetVentasCotizacionesOC(Me.CveVenta, -1, UsuarioActual.CveEmpresa) Then + DtOCGeneradas = ObjVentas.DtResultados.Copy() + End If + If DtOCGeneradas IsNot Nothing AndAlso DtOCGeneradas.Rows.Count > 0 Then + LtGenerarOC.Visible = False + Else + LtGenerarOC.Visible = True + End If + End If + UpPS.Update() UpContado.Update() UpEstatus.Update() @@ -11670,7 +11684,7 @@ Partial Class Ventas If e.Row.DBCampo("Tipo").ToString = "NC" And e.Row.DataKey("CveVenta").ToString.ToEntero > 0 Then If e.Row.DBCampo("CveMoneda").ToString.ToEntero = 2 Then - tipoCambio = e.Row.DataKey("TipoCambio").ToString.ToDecimal + tipoCambio = e.Row.DBCampo("TipoCambioHoy").ToString.ToDecimal Else tipoCambio = GlobalTipoCambio(e.Row.DataKey("Fecha").ToString.ToDate).ToDecimal End If @@ -11703,7 +11717,7 @@ Partial Class Ventas maxsaldo = total End If - e.Row.FCLiteral("MonedaVenta").Text = saldo.FormatoNumero(4) + e.Row.FCLiteral("MonedaVenta").Text = saldo.FormatoNumero(2) e.Row.FCCheckBox("Chk" & e.Row.RowIndex).Attributes.Add("onclick", String.Format("chkAnt(this,{0},{1});", e.Row.FCTextBox("TxtAnticipo" & e.Row.RowIndex).ClientID, saldo)) e.Row.FCTextBox("TxtAnticipo" & e.Row.RowIndex).Attributes.Add("onKeyUp", String.Format("FnCambiaAnt({0},this,{1});", e.Row.FCCheckBox("Chk" & e.Row.RowIndex).ClientID, saldo)) e.Row.FCTextBox("TxtTC" & e.Row.RowIndex).Attributes.Add("onKeyUp", String.Format("CambioTipoMoneda({0},{1},{2},{3},{4});", e.Row.FCCheckBox("Chk" & e.Row.RowIndex).ClientID, e.Row.DataKey("Saldo"), e.Row.FCTextBox("TxtAnticipo" & e.Row.RowIndex).ClientID, e.Row.FCTextBox("TxtTC" & e.Row.RowIndex).ClientID, e.Row.DataKey("CveMoneda"))) @@ -11874,7 +11888,7 @@ Partial Class Ventas tipoCambioVentaValuacion = If(TxtFecha.Text.ToDate < FechaUltimaFluctuacion, TipoCambioFluctuacion, TxtTipoCambio.Text.ToDecimal) PorcentajePago = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal / gvr.DataKey("Original").ToDecimal ElseIf DdlMoneda.SelectedValue.ToEntero = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then 'SI LA VENTA VIENE EN PESOS Y SE VA A PAGAR EN DOLARES - tipoCambioPago = gvr.DataKey("TipoCambio").ToDecimal() ' gvr.FCTextBox("TxtTC" & gvr.RowIndex).Text.ToDecimal + tipoCambioPago = gvr.DataKey("TipoCambioHoy").ToDecimal() ' gvr.FCTextBox("TxtTC" & gvr.RowIndex).Text.ToDecimal tipoCambioVenta = 1 tipoCambioVentaValuacion = If(TxtFecha.Text.ToDate < FechaUltimaFluctuacion, TipoCambioFluctuacion, TxtTipoCambio.Text.ToDecimal) PorcentajePago = (gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal) / gvr.DataKey("Original").ToDecimal @@ -24658,4 +24672,7 @@ Partial Class Ventas ' Return File 'End Function + Protected Sub LnkGenerarOC_Click(sender As Object, e As EventArgs) + Response.Redirect($"~/OC/OC.aspx?CveCotizacion={Me.CveVenta}&Tipo=OC") + End Sub End Class \ No newline at end of file