diff --git a/Ventas/Clientes.aspx b/Ventas/Clientes.aspx index 97e44ab27..72c2b3aba 100644 --- a/Ventas/Clientes.aspx +++ b/Ventas/Clientes.aspx @@ -1643,20 +1643,20 @@
-
+
- Parametros + Parametros
- -
- + +
+
- +
@@ -1674,15 +1674,16 @@
- -
- - - - +
+ +
+ + + + +
-
@@ -1781,7 +1782,7 @@
- +
@@ -1789,7 +1790,7 @@
- +
@@ -1819,7 +1820,7 @@
- +
@@ -1835,25 +1836,25 @@
-
- +
-
-
-
- - -
-
+ +
-
- - +
+ + +
- +
+
+ + +
+
- +
@@ -1876,54 +1877,61 @@
- +
-
- -
- - - - - - +
+
+
+ + + + +
+ +
-
-
- - - - - - +
+
+
+ + + + +
+ +
-
-
- - - - +
+
+ +
+ + + + +
- - +
-
-
- - - - - - +
+
+
+ + + + +
+ +
@@ -1931,7 +1939,7 @@
- + @@ -1939,7 +1947,7 @@
- + @@ -1948,12 +1956,6 @@ - <%-- - - - - - --%>
@@ -1974,13 +1976,13 @@
-
- +
- +
@@ -1991,8 +1993,16 @@
+ Pago múltiples facturas Pagar múltiples facturas +   - + + " + style="display: inline-block; margin-right: -20px; width: 150px;" /> + " + style="margin-top: -3px; float: inherit;" class="btn btn-circle btn-sm label-info"> + @@ -2003,11 +2013,7 @@
-
-
- Pago múltiples facturas Pagar múltiples facturas      - -
+ <%--
-
+
--%>
@@ -2068,7 +2074,7 @@ - + @@ -2086,10 +2092,7 @@
-
- -
@@ -2102,6 +2105,11 @@ + " + style="display: inline-block; margin-right: -20px; width: 150px;" /> + " + style="margin-top: -3px; float: inherit;" class="btn btn-circle btn-sm label-info"> @@ -2111,15 +2119,7 @@
-
-
- " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> -
- -
-
- +
diff --git a/Ventas/Clientes.aspx.vb b/Ventas/Clientes.aspx.vb index ebaf93626..759929266 100644 --- a/Ventas/Clientes.aspx.vb +++ b/Ventas/Clientes.aspx.vb @@ -513,7 +513,7 @@ Partial Class Clientes Set(value As Integer) ViewState("CveLineaAdicional") = value End Set - End Property + End Property Private Property FechaIngLineaAdicional As DateTime Get If ViewState("FechaIngLineaAdicional") Is Nothing Then @@ -526,13 +526,13 @@ Partial Class Clientes Set(value As DateTime) ViewState("FechaIngLineaAdicional") = value End Set - End Property - - - - + End Property + + + + #End Region - + #Region "Documentacion" Private Property DTDocumentacion As DataTable Get @@ -2964,14 +2964,14 @@ Partial Class Clientes #Region "G R I D V I E W S" Protected Sub GVHistorial_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVHistorial.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then - Dim HLSendMail As HtmlAnchor = DirectCast(e.Row.FindControl("HLSendMail"), HtmlAnchor) - 'Dim HLRemision As HtmlAnchor = DirectCast(e.Row.FindControl("HLRemision"), HtmlAnchor) - + Dim HLSendMail As HtmlAnchor = DirectCast(e.Row.FindControl("HLSendMail"), HtmlAnchor) + 'Dim HLRemision As HtmlAnchor = DirectCast(e.Row.FindControl("HLRemision"), HtmlAnchor) + If e.Row.RowIndex = 0 Then e.Row.BackColor = Drawing.Color.LightGray HLSendMail.Visible = False 'HLRemision.Visible = False - End If + End If Dim Liga As String = String.Format("< a class=""Texto"" href=""/Ventas/Ventas.aspx?CveVenta={0}"">", e.Row.DBCampo("CveVenta")) HLSendMail.HRef = String.Format("javascript:(function mail(){{$get('HdnTipoDocto').value='{0}';$get('HdnCveVenta').value='{1}';$get('HdnFolioVenta').value='{2}';$get('TxtParaMail').value='{3}';$get('HdnSerieFolio').value='{4}';$get('HdnSubProyecto').value='{5}';$('#ModalDivMail').modal();void(0);}})();", e.Row.DBCampo("TipoDocto"), e.Row.DBCampo("CveVenta"), e.Row.DBCampo("folio"), e.Row.DBCampo("Correo"), e.Row.DBCampo("SerieFolio"), e.Row.DBCampo("SubProyecto")) e.Row.FCLiteral("LtlFactura").Text = String.Format("{1}", e.Row.DBCampo("CveVenta"), e.Row.DBCampo("Folio")) @@ -2992,8 +2992,8 @@ Partial Class Clientes e.Row.Cells(7).Width = Unit.Pixel(90) e.Row.Cells(8).Width = Unit.Pixel(80) e.Row.Cells(9).Width = Unit.Pixel(70) - End If - + End If + If e.Row.DBCampo("Saldo").ToDouble < 0 Then e.Row.Cells(6).ForeColor = Drawing.Color.Red If e.Row.DBCampo("DiasVencidos").ToDouble > 0 AndAlso CType(sender, GridView).ID = "GvCxC" Then e.Row.Cells(4).ForeColor = Drawing.Color.Red If e.Row.DBCampo("Original").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlSaldoOriginal"), Literal).Text = "" @@ -4239,23 +4239,23 @@ Partial Class Clientes Try Dim File As Byte() If Archivo.Exists Then - Dim ArchivoSti As New System.IO.FileInfo(String.Format("{0}Formatos/RepClientesCxC.mrt", UsuarioActual.Empresa.Ruta)) - If ArchivoSti.Exists Then - Dim listass As New List(Of ReportParameter) - For Each item As CrystalParametro In lista - listass.Add(New ReportParameter(item.Nombre, item.Valor.ToString())) - Next - - Dim lrds As New List(Of ReportDataSource) - Dim rds As New ReportDataSource - rds.Name = "Datos" - rds.Value = DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha") - lrds.Add(rds) - - File = StreamBytesStimulsoft("Facturas", $"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.mrt", lrds, listass, NombreArchivo:="Estado de cuenta", Formato:=Formato) - Else - File = ImprimirPDFCrystal($"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.rpt", DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato) - End If + Dim ArchivoSti As New System.IO.FileInfo(String.Format("{0}Formatos/RepClientesCxC.mrt", UsuarioActual.Empresa.Ruta)) + If ArchivoSti.Exists Then + Dim listass As New List(Of ReportParameter) + For Each item As CrystalParametro In lista + listass.Add(New ReportParameter(item.Nombre, item.Valor.ToString())) + Next + + Dim lrds As New List(Of ReportDataSource) + Dim rds As New ReportDataSource + rds.Name = "Datos" + rds.Value = DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha") + lrds.Add(rds) + + File = StreamBytesStimulsoft("Facturas", $"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.mrt", lrds, listass, NombreArchivo:="Estado de cuenta", Formato:=Formato) + Else + File = ImprimirPDFCrystal($"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.rpt", DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato) + End If Else File = ImprimirPDFCrystal(Server.MapPath("~/Empresas/Grales/Formatos/RepClientesCxC.rpt"), DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato) End If @@ -4300,8 +4300,8 @@ Partial Class Clientes Dim listass As New List(Of ReportParameter) For Each item As CrystalParametro In lista listass.Add(New ReportParameter(item.Nombre, item.Valor.ToString())) - Next - ImprimirPDFStimulsoft($"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.mrt", DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), listass, "Estado de cuenta", Formato) + Next + ImprimirPDFStimulsoft($"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.mrt", DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), listass, "Estado de cuenta", Formato) Else ImprimirbytesPDF(ImprimirPDFCrystal($"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.rpt", DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato), "Estado de cuenta", Formato) End If @@ -4353,8 +4353,8 @@ Partial Class Clientes Dim listass As New List(Of ReportParameter) For Each item As CrystalParametro In lista listass.Add(New ReportParameter(item.Nombre, item.Valor.ToString())) - Next - ImprimirPDFStimulsoft($"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.mrt", DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), listass, "Estado de cuenta", Formato) + Next + ImprimirPDFStimulsoft($"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.mrt", DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), listass, "Estado de cuenta", Formato) Else ImprimirbytesPDF(ImprimirPDFCrystal($"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.rpt", DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato), "Estado de cuenta", Formato) End If @@ -4362,56 +4362,6 @@ Partial Class Clientes ImprimirbytesPDF(ImprimirPDFCrystal(Server.MapPath("~/Empresas/Grales/Formatos/RepClientesCxC.rpt"), DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato), "Estado de cuenta", Formato) End If End If - End Sub - - Public Sub ImprimirExcelStimulsoft(RutaReporte As String, DtDatos As DataTable, Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional RDSName As String = "Datos", Optional Content_Disposition As String = "attachment") - Dim lrds As New List(Of ReportDataSource) - Dim rds As New ReportDataSource - rds.Name = RDSName - rds.Value = DtDatos - lrds.Add(rds) - - ImprimirbytesExcel(StreamBytesStimulsoft("Facturas", RutaReporte, lrds, Parametros, NombreArchivo:=NombreArchivo, Formato:="EXCEL"), NombreArchivo, "EXCEL", Content_Disposition:=Content_Disposition) - End Sub - Public Sub ImprimirbytesExcel(bytes As Byte(), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional Descarga As Boolean = False, Optional Content_Disposition As String = "attachment") - 'limpio ReportViwer - Dim mimeType As String = Nothing - Dim extension As String = Nothing - - 'If Descarga Then - ' Try - ' bytes = bytes - ' File.WriteAllBytes(String.Format("{0}PDF/whatever.gif", UsuarioActual.Empresa.Ruta), img) - ' Catch ex As Exception - ' If UsuarioActual.CveRol = 1 Then - ' Alert(ex.Message, TipoMensaje.MsgAdvertencia) - ' Else - ' Alert("Ocurrió un error al generar la descarga. Favor de contactar a soporte tecnico cod'IMPDFclspag'", TipoMensaje.MsgAdvertencia) - ' End If - ' End Try - 'End If - - Try - bytes = bytes - Response.Buffer = True - Response.Clear() - Response.ContentType = "application/vnd.ms-excel" - Response.ClearHeaders() - Response.AddHeader("content-disposition", String.Format("{0}; filename=""{1}.{2}""", Content_Disposition, NombreArchivo, If(Formato = "PDF", "pdf", "xlsx"))) - Response.BinaryWrite(bytes) ' create the file - Response.Flush() ' send it to the client to download - bytes = Nothing - HttpContext.Current.Response.SuppressContent = True - HttpContext.Current.ApplicationInstance.CompleteRequest() - 'HttpContext.Current.Response.End() - Catch ex As Exception - - If UsuarioActual.CveRol = 1 Then - Alert($"Error: {ex.Message} | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))}", TipoMensaje.MsgAdvertencia) - Else - Alert("Ocurrió un error al generar la descarga. Favor de contactar a soporte tecnico cod:'IMPDFclspag'", TipoMensaje.MsgAdvertencia) - End If - End Try End Sub Private Sub MandaCorreoEstadoCuenta(CveUsuario As Integer, CveEmpresa As Integer, CveCliente As Integer, File As Byte(), Para As String, Asunto As String, Body As String, Optional GuardarBitacora As Boolean = False) @@ -7125,9 +7075,13 @@ Partial Class Clientes DdlIncoterm.DataBind() DdlClavePedimento.Items.Clear() - DdlClavePedimento.DataSource = GlobalDTClavePedimento() + Using ObjGrales As New ClsGenerales + If ObjGrales.GetSATClavePedimento() Then + DdlClavePedimento.DataSource = GlobalDTClavePedimento() + DdlClavePedimento.DataBind() + End If + End Using DdlClavePedimento.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlClavePedimento.DataBind() DdlMotivoTraslado.Items.Clear() DdlMotivoTraslado.DataSource = GlobalDTSATMotivoTraslado() @@ -9964,7 +9918,7 @@ Partial Class Clientes Alert("Puntuación Inicializada") End If Acum.Dispose() - End Sub + End Sub #End Region Protected Sub DdlTipoRetencion_SelectedIndexChanged(sender As Object, e As EventArgs) If UsuarioActual.Empresa.Funcionalidad(579) = "1" Then @@ -10506,11 +10460,16 @@ Partial Class Clientes ' Exit Sub 'End If + If DdlTipoLineaAdicionalModal.SelectedValue.ToEntero() <= 0 Then + Alert("Debe seleccionar el tipo de linea adicional", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + Dim ObjVentas As New ClsVentas - If CveLineaAdicional > 0 Then - - If DdlTipoLineaAdicionalModal.SelectedValue = "2" Then - TxtFechaVencimientoLineaAdicionalModal.Text = FechaIngLineaAdicional.AddDays(TxtDiasVencimientoLineaAdicionalModal.Text.ToEntero()).ToString("dd/MM/yyyy") + If CveLineaAdicional > 0 Then + + If DdlTipoLineaAdicionalModal.SelectedValue = "2" Then + TxtFechaVencimientoLineaAdicionalModal.Text = FechaIngLineaAdicional.AddDays(TxtDiasVencimientoLineaAdicionalModal.Text.ToEntero()).ToString("dd/MM/yyyy") End If If Not ObjVentas.UpdateLineasAdicionales(CveLineaAdicional, TxtLineaAdicionalModal.Text, CveCliente, DdlProveedorLineaAdicionalModal.SelectedValue.ToEntero, DdlTipoLineaAdicionalModal.SelectedValue.ToEntero, TxtImporteLineaAdicionalModal.Text.ToDecimal, @@ -10520,9 +10479,9 @@ Partial Class Clientes Else Alert("Linea Adicional Actualizada Correctamente") End If - Else - If DdlTipoLineaAdicionalModal.SelectedValue = "2" Then - TxtFechaVencimientoLineaAdicionalModal.Text = Now.AddDays(TxtDiasVencimientoLineaAdicionalModal.Text.ToEntero()).ToString("dd/MM/yyyy") + Else + If DdlTipoLineaAdicionalModal.SelectedValue = "2" Then + TxtFechaVencimientoLineaAdicionalModal.Text = Now.AddDays(TxtDiasVencimientoLineaAdicionalModal.Text.ToEntero()).ToString("dd/MM/yyyy") End If If Not ObjVentas.AddLineasAdicionales(TxtLineaAdicionalModal.Text, CveCliente, DdlProveedorLineaAdicionalModal.SelectedValue.ToEntero, DdlTipoLineaAdicionalModal.SelectedValue.ToEntero, TxtImporteLineaAdicionalModal.Text.ToDecimal, @@ -10551,7 +10510,7 @@ Partial Class Clientes CveLineaAdicional = GvRow.DataKey("CveLineaAdicional").ToEntero - FechaIngLineaAdicional = GvRow.DataKey("FechaIng").ToDateTime() + FechaIngLineaAdicional = GvRow.DataKey("FechaIng").ToDateTime() TxtLineaAdicionalModal.Text = GvRow.DataKey("LineaAdicional") DdlProveedorLineaAdicionalModal.txtText.Value = GvRow.DataKey("Proveedor") DdlProveedorLineaAdicionalModal.txtValue.Value = GvRow.DataKey("CveProveedor") @@ -10596,7 +10555,7 @@ Partial Class Clientes Protected Sub DdlTipoLineaAdicionalModal_SelectedIndexChanged(sender As Object, e As EventArgs) DvLineaAdicionalDiasVenciemientoModal.Visible = If(DdlTipoLineaAdicionalModal.SelectedValue.ToEntero = 2, True, False) - DvFechaVencimiento.Visible = If(DdlTipoLineaAdicionalModal.SelectedValue.ToEntero = 2, False, True) + DvFechaVencimiento.Visible = If(DdlTipoLineaAdicionalModal.SelectedValue.ToEntero = 2, False, True) UpLineaAdicionalmodal.Update() End Sub diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 6f69118b0..81acbd393 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -2280,6 +2280,14 @@ Partial Class Ventas ViewState("SaldoLineaAdicional") = value End Set End Property + Private Property SaldoIngresosLineaAdicional As Decimal + Get + Return (IfNull(ViewState("SaldoIngresosLineaAdicional"), "0", ViewState("SaldoIngresosLineaAdicional"))).ToString().ToDecimal() + End Get + Set(value As Decimal) + ViewState("SaldoIngresosLineaAdicional") = value + End Set + End Property Private Property CveCategoriaLineaAdicional As Integer Get @@ -2298,6 +2306,14 @@ Partial Class Ventas ViewState("CveMonedaLineaAdicional") = value End Set End Property + Private Property HabilitoFacturacionIngresoLineaAdicional As Boolean + Get + Return If(IsNothing(ViewState("HabilitoFacturacionIngresoLineaAdicional")), False, CType(ViewState("HabilitoFacturacionIngresoLineaAdicional"), Boolean)) + End Get + Set(value As Boolean) + ViewState("HabilitoFacturacionIngresoLineaAdicional") = value + End Set + End Property #End Region @@ -8839,6 +8855,11 @@ Partial Class Ventas Exit Sub End If + If DdlLineaAdicional.SelectedValue.ToEntero() > 0 AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem") Then + Alert("No se puede seleccionar una linea adicional de crédito si no se genera una remisón.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + 'SI TIENE ANTICIPOS Y ESTA AMORTIZADO AL 100% EL DOCUMENTO (SALDO = 0) | NO VALIDA PU DEL CONCEPTO If Not (LblAmortizacion.Text.ToDouble > 0 And TxtTotal.Text.ToDouble <= 0) Then If Not DdlTipoComprobante.SelectedValue.Contiene("Ped", "Ant", "DPe") Then @@ -9057,18 +9078,6 @@ Partial Class Ventas Alert("El saldo de la linea adicional debe ser mayor a cero", TipoMensaje.MsgAdvertencia) Exit Sub End If - - 'VERIFICA QUE LA MONEDA DE LA LINEA ADICIONAL SEA LA MISMA QUE LA VENTA - If Me.CveMonedaLineaAdicional <> DdlMoneda.SelectedValue.ToEntero() Then - Alert("La moneda de la linea adicional de crédito debe ser la misma que la factura.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - 'VERIFICA QUE EL SALDO DISPONIBLE SEA MENOR AL IMPORTE - If Me.SaldoLineaAdicional <= TxtTotal.Text.ToDecimal() Then - Alert("El saldo de la linea adicional debe ser mayor o igual al de la factura", TipoMensaje.MsgAdvertencia) - Exit Sub - End If End If @@ -9406,6 +9415,30 @@ Partial Class Ventas Exit Sub End If + If UsuarioActual.Empresa.Funcionalidad(705) = "1" AndAlso DdlLineaAdicional.SelectedValue.ToEntero() > 0 Then + 'VERIFICA QUE LA MONEDA DE LA LINEA ADICIONAL SEA LA MISMA QUE LA VENTA + If Me.CveMonedaLineaAdicional <> ObjFactura.CveMoneda Then + Alert("La moneda de la linea adicional de crédito debe ser la misma que la factura.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + 'VERIFICA QUE EL SALDO DISPONIBLE SEA MENOR AL IMPORTE + If ObjFactura.TipoDocto = "Rem" AndAlso Me.SaldoLineaAdicional <= ObjFactura.Total Then + Alert("El saldo de la linea adicional debe ser mayor o igual al de la remisión", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If ObjFactura.TipoDocto = "Ing" AndAlso (DtRemisionesPS Is Nothing OrElse DtRemisionesPS.Rows.Count = 0) Then + Alert("No se puede generar un ingreso con una linea adicional de credito si este no viene de una remisión", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If ObjFactura.TipoDocto = "Ing" AndAlso Me.SaldoIngresosLineaAdicional <= ObjFactura.Total Then + Alert("El saldo de la linea adicional debe ser mayor o igual al de la factura", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + 'If Not CveEmpresaCRM > 0 Then ' If ObjFactura.Cliente.AplicaComercioExterior Then ' If Not ValidaComercioExterior() Then @@ -18659,28 +18692,40 @@ Partial Class Ventas End Sub Private Sub CalculaLineasAdicionales() - If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem") AndAlso UsuarioActual.Empresa.Funcionalidad(705) = "1" Then + If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "PA") AndAlso UsuarioActual.Empresa.Funcionalidad(705) = "1" Then DdlLineaAdicional.DataSource = Nothing Using ObjVentas As New ClsVentas + 'SI ES VENTA EXISTENTE , SI SE VA EDITAR SOLO MOSTRAR LAS CON SALDO, FECHA DE VENCIMIENTO VIGENTE O LA LINEA ACTUAL If CveVenta > 0 Then - If ObjVentas.GetLineasAdicionalesSaldo(-1, CveCliente, -1, DdlMoneda.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa, ConSaldo:=-1, FechaVencimientoConsulta:=MinFecha) Then + If ObjVentas.GetLineasAdicionalesSaldo(-1, CveCliente, -1, -1, UsuarioActual.CveEmpresa, ConSaldo:=-1, FechaVencimientoConsulta:=MinFecha) Then If ObjVentas.DtResultados.Rows.Count > 0 Then TrLineaAdicional.Visible = True DdlLineaAdicional.DataSource = ObjVentas.DtResultados.FiltraParametros($"(Saldo > 0 AND FechaVencimiento <= '{Now.ToString("dd/MM/yyyy")}') OR CveLineaAdicional = {Me.CveLineaAdicionalVenta}") End If End If Else - If ObjVentas.GetLineasAdicionalesSaldo(-1, CveCliente, -1, DdlMoneda.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa, ConSaldo:=1, FechaVencimientoConsulta:=Now) Then - If ObjVentas.DtResultados.Rows.Count > 0 Then - TrLineaAdicional.Visible = True - DdlLineaAdicional.DataSource = ObjVentas.DtResultados + 'SI SE ESTA FACTURANDO UNA REMISION DEBE SELECCIONAR LA LINEA ADICIONAL DE ESTA + If Me.CveLineaAdicionalVenta > 0 Then + If ObjVentas.GetLineasAdicionalesSaldo(Me.CveLineaAdicionalVenta, CveCliente, -1, -1, UsuarioActual.CveEmpresa, ConSaldo:=-1, FechaVencimientoConsulta:=MinFecha) Then + If ObjVentas.DtResultados.Rows.Count > 0 Then + TrLineaAdicional.Visible = True + DdlLineaAdicional.DataSource = ObjVentas.DtResultados + End If + End If + Else + If ObjVentas.GetLineasAdicionalesSaldo(-1, CveCliente, -1, -1, UsuarioActual.CveEmpresa, ConSaldo:=1, FechaVencimientoConsulta:=Now) Then + If ObjVentas.DtResultados.Rows.Count > 0 Then + TrLineaAdicional.Visible = True + DdlLineaAdicional.DataSource = ObjVentas.DtResultados + End If End If End If End If End Using DdlLineaAdicional.DataBind() + DdlLineaAdicional.Items.Insert(0, New ListItem("Seleccione", "-1")) If Me.CveLineaAdicionalVenta > 0 Then @@ -31616,6 +31661,13 @@ Partial Class Ventas DdlMoneda.SelectedValue = GlobalDTMonedas.FiltroPrimeroValor("CveMoneda", $"Abreviatura = '{dtSeleccionadas.FiltroPrimeroValor("Abreviatura")}'") DdlMoneda.Enabled = False CambiaMoneda() + + If UsuarioActual.Empresa.Funcionalidad(705) = "1" Then + Me.CveLineaAdicionalVenta = dtSeleccionadas.FiltroPrimeroValor("CveLineaAdicional", "CveLineaAdicional > 0").ToEntero() + CalculaLineasAdicionales() + End If + + DdlUsoCFDI.SelectedValueExist(dtSeleccionadas.FiltroPrimeroValor("CveUsoCFDI")) DdlMetodoPago33.SelectedValueExist(dtSeleccionadas.FiltroPrimeroValor("CveMetodoPago")) CargaFormaPago(DdlMetodoPago33.SelectedValue.ToEntero()) @@ -36097,42 +36149,76 @@ Partial Class Ventas RBLPago.Enabled = False Using ObjVentas As New ClsVentas - If ObjVentas.GetLineasAdicionalesSaldo(DdlLineaAdicional.SelectedValue.ToEntero(), CveCliente, -1, DdlMoneda.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa, FechaVencimientoConsulta:=MinFecha) Then + If ObjVentas.GetLineasAdicionalesSaldo(DdlLineaAdicional.SelectedValue.ToEntero(), CveCliente, -1, -1, UsuarioActual.CveEmpresa, FechaVencimientoConsulta:=MinFecha) Then If ObjVentas.DtResultados.Rows.Count > 0 Then Dim RowLinea As DataRow = ObjVentas.DtResultados.Rows(0) If RowLinea IsNot Nothing Then - TxtFechaPago.Text = RowLinea("FechaVencimiento").ToString().ToDateTime().ToString("dd/MM/yyyy") + If CveVenta <= 0 Then + TxtFechaPago.Text = RowLinea("FechaVencimiento").ToString().ToDateTime().ToString("dd/MM/yyyy") - 'AL FACTURAR CON LINEA ADICIONAL TIPO PO, SE SUMARÁN LOS DIAS DE VENCIMIENTO A LA FECHA ACTUAL - If RowLinea("TipoLinea").ToString() = "2" Then - TxtFechaPago.Text = Now.AddDays(RowLinea("DiasVencimiento").ToString().ToEntero()).ToString("dd/MM/yyyy") - TxtFechaPago.Enabled = False - imgCalendario.Visible = False + 'AL FACTURAR CON LINEA ADICIONAL TIPO PO, SE SUMARÁN LOS DIAS DE VENCIMIENTO A LA FECHA ACTUAL + If RowLinea("TipoLinea").ToString() = "2" Then + TxtFechaPago.Text = Now.AddDays(RowLinea("DiasVencimiento").ToString().ToEntero()).ToString("dd/MM/yyyy") + TxtFechaPago.Enabled = False + imgCalendario.Visible = False + End If + + TxtOrdenCompra.Text = RowLinea("LineaAdicionalComercializador").ToString() End If Me.CveCategoriaLineaAdicional = RowLinea("CveCategoria").ToString().ToEntero() Me.CveMonedaLineaAdicional = RowLinea("CveMoneda").ToString().ToEntero() Me.SaldoLineaAdicional = RowLinea("Saldo").ToString().ToDecimal() + Me.SaldoIngresosLineaAdicional = RowLinea("SaldoIngresos").ToString().ToDecimal() + + If CveVenta <= 0 Then + If DdlTipoComprobante.SelectedValue.Contiene("PA") Then + 'SI NO TIENE LA OPCION DE FACTURAR LA PERMITE + If DdlTipoComprobante.Items.FindByValue("Rem") Is Nothing Then + DdlTipoComprobante.Items.Insert(0, New ListItem("Remisión", "Rem")) + HabilitoFacturacionIngresoLineaAdicional = True + End If + DdlTipoComprobante.SelectedValueExist("Rem") + End If + End If + End If Else Alert("No se pudieron obtener datos de la linea adicional", TipoMensaje.MsgAdvertencia) Me.SaldoLineaAdicional = 0 + Me.SaldoIngresosLineaAdicional = 0 Me.CveCategoriaLineaAdicional = 0 End If Else Alert("No se pudieron obtener datos de la linea adicional", TipoMensaje.MsgAdvertencia) Me.SaldoLineaAdicional = 0 + Me.SaldoIngresosLineaAdicional = 0 Me.CveCategoriaLineaAdicional = 0 End If End Using Else Me.SaldoLineaAdicional = 0 + Me.SaldoIngresosLineaAdicional = 0 Me.CveCategoriaLineaAdicional = 0 - TxtFechaPago.Text = Now.ToString("dd/MM/yyyy") + + If CveVenta <= 0 Then + TxtFechaPago.Text = Now.ToString("dd/MM/yyyy") + TxtOrdenCompra.Text = "" + + 'SI SE HABILITO LA FACTURACION DESDE LA LINEA ADICIONAL DEBE QUITARLO + If HabilitoFacturacionIngresoLineaAdicional Then + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem")) + DdlTipoComprobante.SelectedValueExist("PA") + + UpParametros.Update() + End If + End If + End If UpParametros.Update() UPCondicionesPago.Update() + UPObservaciones.Update() End Sub Protected Sub LnkUpdateLineaAdicional_Click(sender As Object, e As EventArgs) 'VALIDAR LINEAS ADICIONALES