diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index f532a44af..767ffd089 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -799,6 +799,22 @@ Public Class ClsVentas Return Retorno End Function + Public Function UpdateIxCAnticipoAutorizado(CveIE As Integer, Autorizado As Boolean) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_IxCAnticipoAutorizadoUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveIE", SqlDbType.Int).Value = CveIE + .Add("@Autorizado", SqlDbType.Bit).Value = Autorizado + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el estatus del anticipo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + Public Function UpdateFechaVencimientoVenta(CveVenta As Integer, FechaVencimiento As Date) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_VentasFechaVencimientoUpdate") diff --git a/Bancos/DepositosCaja.aspx b/Bancos/DepositosCaja.aspx index 8dc66da28..0b3a38715 100644 --- a/Bancos/DepositosCaja.aspx +++ b/Bancos/DepositosCaja.aspx @@ -243,7 +243,7 @@ -
+
@@ -273,7 +273,7 @@
-
+
diff --git a/Bancos/DepositosCaja.aspx.vb b/Bancos/DepositosCaja.aspx.vb index 34dea6f3a..d0ab743c1 100644 --- a/Bancos/DepositosCaja.aspx.vb +++ b/Bancos/DepositosCaja.aspx.vb @@ -45,12 +45,15 @@ Partial Class Bancos_DepositosCaja 'HplImprimirPDF.NavigateUrl = $"/Compras/PopUpVerFactura.aspx?P={StrEncriptPrueba}" If UsuarioActual.CveEmpresa = 189 Then - If DdlTipoPago.Items.FindByValue("-1") IsNot Nothing Then - DdlTipoPago.Items.Remove(DdlTipoPago.Items.FindByValue("-1")) - End If + If DdlTipoPago.Items.FindByValue("-1") IsNot Nothing Then + DdlTipoPago.Items.Remove(DdlTipoPago.Items.FindByValue("-1")) End If - End If + DivDescuentocheck.Visible = False + DivIntercheck.Visible = False + End If + + End If End Sub Private Sub CargaCuentas() @@ -509,7 +512,7 @@ Partial Class Bancos_DepositosCaja FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim().ToDate, MaxFecha).AddDays(1) If ObjMovtos.GetRemisionesCobranza(UsuarioActual.CveEmpresa, DdlSubProyectos.SelectedValue.ToEntero, FechaI, FechaF) Then - Dim dtt As DataTable = ObjMovtos.DtResultados.FiltraParametros($"CveVenta > 0 AND (CveUsuarioCobranza IS NULL OR CveUsuarioCobranza = {UsuarioActual.CveUsuario}) AND TipoDocto IN ('Ing','Rem')") + Dim dtt As DataTable = ObjMovtos.DtResultados.FiltraParametros($"CveVenta > 0 AND (CveUsuarioCobranza IS NULL OR CveUsuarioCobranza = {UsuarioActual.CveUsuario}) AND TipoDocto IN ('Ing','Rem') AND RemisionEspecial = 0") 'Dim Dtta As DataTable = dtt.FiltraParametros($"CveUsuarioCobranza = {UsuarioActual.CveUsuario} ") 'If Dtta IsNot Nothing AndAlso Dtta.Rows.Count > 0 Then dtt = Dtta diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 1cc208d54..9c813819a 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -1428,7 +1428,7 @@ Partial Class Compras_Compras End If Next - If HayDifIEPS Then Alert("El porcentaje de IEPS del producto no coincide con el especificado.", TipoMensaje.MsgAdvertencia) + 'If HayDifIEPS Then Alert("El porcentaje de IEPS del producto no coincide con el especificado.", TipoMensaje.MsgAdvertencia) If UsuarioActual.Empresa.Funcionalidad(562).ToEntero > 0 Then CargaGastosServicios(UsuarioActual.Empresa.Funcionalidad(562).ToEntero) @@ -1986,13 +1986,14 @@ Partial Class Compras_Compras End If End If Next - If EmisorRegimenFiscal = "626" AndAlso Not RetISRResico AndAlso EmisorRFC.Length = 13 Then 'solo para personas físicas + + If EmisorRegimenFiscal = "626" AndAlso Not RetISRResico AndAlso EmisorRFC.Length = 13 AndAlso UsuarioActual.CveEmpresa.Contiene(119, 158) Then 'solo para personas físicas SbValRet.Append(" La factura no tiene especificado una retención de ISR, ya que el proveedor es Resico.
") BtnGuardar.Enabled = False End If If SbValRet.ToString.Trim.Length > 0 Then - Alert(SbValRet.ToString, TipoMensaje.MsgAdvertencia) + Alert("El porcentaje de IEPS del producto no coincide con el especificado.

" & SbValRet.ToString, TipoMensaje.MsgAdvertencia) End If Else @@ -8055,10 +8056,10 @@ Partial Class Compras_Compras If (TmpDT.Rows(IndiceUltimo)("IVA").ToString.ToDecimal + DiferenciaIVas) < 0 Then - Dim AjusteteDividido As Decimal = Math.Abs(DiferenciaIVas) / CantidadRegistroConIVA + Dim AjusteteDividido As Decimal = DiferenciaIVas / CantidadRegistroConIVA For Each dRow As DataRow In TmpDT.Rows - dRow("IVA") = dRow("IVA").ToString.ToDecimal - AjusteteDividido + dRow("IVA") = dRow("IVA").ToString.ToDecimal + AjusteteDividido Next Else diff --git a/Compras/eFacturas.aspx.vb b/Compras/eFacturas.aspx.vb index 284a817cc..0634a389f 100644 --- a/Compras/eFacturas.aspx.vb +++ b/Compras/eFacturas.aspx.vb @@ -1584,58 +1584,73 @@ Partial Class Compras_eFacturas Dim FiInfo As New FileInfo(comprmido) - Using stream As Stream = System.IO.File.OpenRead(FiInfo.FullName) - Try - Dim reader = ReaderFactory.Open(stream) + Try + Using stream As Stream = System.IO.File.OpenRead(FiInfo.FullName) + Try + Dim reader = ReaderFactory.Open(stream) - Dim Multiparte As Boolean = False - If Path.GetExtension(FiInfo.FullName.ToUpper()) = ".RAR" And FiInfo.FullName.ToUpper().Contains(".PART") Then - 'SI ES .RAR, PUEDE SER MULTI PART Y PUEDE TRONAR - Using archive As RarArchive = RarArchive.Open(FiInfo.FullName) - If archive.IsMultipartVolume() Then - Multiparte = True - End If - End Using - End If - - Dim PdfList As New List(Of String) - If Not Multiparte Then - 'puede tronar si el archivo es multiparte - While reader.MoveToNextEntry() - If Not reader.Entry.IsDirectory Then - 'Si es un archivo XML, lo leo y lo guardo - - Dim nombreArchivo As String = "" - - If reader.Entry.FilePath.Contains("/") Then - nombreArchivo = reader.Entry.FilePath.Substring(reader.Entry.FilePath.LastIndexOf("/") + 1) - Else - nombreArchivo = reader.Entry.FilePath + Dim Multiparte As Boolean = False + If Path.GetExtension(FiInfo.FullName.ToUpper()) = ".RAR" And FiInfo.FullName.ToUpper().Contains(".PART") Then + 'SI ES .RAR, PUEDE SER MULTI PART Y PUEDE TRONAR + Using archive As RarArchive = RarArchive.Open(FiInfo.FullName) + If archive.IsMultipartVolume() Then + Multiparte = True End If + End Using + End If - If Path.GetExtension(reader.Entry.FilePath.ToUpper()) = ".XML" Then - reader.WriteEntryToDirectory(String.Format("{0}Temp\Facturas", UsuarioActual.Empresa.Ruta), ExtractOptions.None Or ExtractOptions.Overwrite) - ListXML.Add(String.Format("{0}Temp\Facturas\{1}", UsuarioActual.Empresa.Ruta, nombreArchivo)) + Dim PdfList As New List(Of String) + If Not Multiparte Then + 'puede tronar si el archivo es multiparte + While reader.MoveToNextEntry() + If Not reader.Entry.IsDirectory Then + 'Si es un archivo XML, lo leo y lo guardo + + Dim nombreArchivo As String = "" + + If reader.Entry.FilePath.Contains("/") Then + nombreArchivo = reader.Entry.FilePath.Substring(reader.Entry.FilePath.LastIndexOf("/") + 1) + Else + nombreArchivo = reader.Entry.FilePath + End If + + If Path.GetExtension(reader.Entry.FilePath.ToUpper()) = ".XML" Then + reader.WriteEntryToDirectory(String.Format("{0}Temp\Facturas", UsuarioActual.Empresa.Ruta), ExtractOptions.None Or ExtractOptions.Overwrite) + ListXML.Add(String.Format("{0}Temp\Facturas\{1}", UsuarioActual.Empresa.Ruta, nombreArchivo)) + End If + If Path.GetExtension(reader.Entry.FilePath.ToUpper()) = ".PDF" Then + 'este sale de un error al leer el pdf, como lo estoy recorriendo de una vez lo guardo y lo vinculo, si la coincidencia es por nombre o número de folio + 'string RFCEmisor = BuscaFactura(System.IO.Path.GetFileNameWithoutExtension(reader.Entry.FilePath).ToUpper(), Arreglo, True); + 'if (!string.IsNullOrEmpty(RFCEmisor)) + ' { + 'If Not Directory.Exists(String.Format("{0}{1}", Temporal, RFCEmisor)) Then Directory.CreateDirectory(String.Format("{0}{1}", Temporal, RFCEmisor)) + + 'reader.WriteEntryToDirectory(String.Format("{0}{1}", Temporal, ""), ExtractOptions.None Or ExtractOptions.Overwrite) + reader.WriteEntryToDirectory(String.Format("{0}{1}", String.Format("{0}Temp\Facturas", UsuarioActual.Empresa.Ruta), ""), ExtractOptions.None Or ExtractOptions.Overwrite) + ListPDF.Add(String.Format("{0}Temp\Facturas\{1}", UsuarioActual.Empresa.Ruta, nombreArchivo)) + + End If End If - If Path.GetExtension(reader.Entry.FilePath.ToUpper()) = ".PDF" Then - 'este sale de un error al leer el pdf, como lo estoy recorriendo de una vez lo guardo y lo vinculo, si la coincidencia es por nombre o número de folio - 'string RFCEmisor = BuscaFactura(System.IO.Path.GetFileNameWithoutExtension(reader.Entry.FilePath).ToUpper(), Arreglo, True); - 'if (!string.IsNullOrEmpty(RFCEmisor)) - ' { - 'If Not Directory.Exists(String.Format("{0}{1}", Temporal, RFCEmisor)) Then Directory.CreateDirectory(String.Format("{0}{1}", Temporal, RFCEmisor)) + End While + End If + Catch ex As Exception + GuardaLogAD("'ERROR :" & ex.Message, eFacturasLog) + End Try + End Using + Catch ex As Exception + If UsuarioActual.CveRol = 1 Then + Alert($"Error al procesar archivo: {FiInfo.FullName} Error:{ex.Message} stackTrace: {ex.StackTrace}", TipoMensaje.MsgAdvertencia) + GuardaLogAD($"Error al procesar archivo: {FiInfo.FullName} Error:{ex.Message} stackTrace: {ex.StackTrace}") + Else + Alert("Se presento un error al procesar las solcictudes. comuniquese con soporte tecnico.", TipoMensaje.MsgAdvertencia) + GuardaLogAD($"Error al procesar archivo: {FiInfo.FullName} Error:{ex.Message} stackTrace: {ex.StackTrace}") + End If + + Exit Sub + End Try + - 'reader.WriteEntryToDirectory(String.Format("{0}{1}", Temporal, ""), ExtractOptions.None Or ExtractOptions.Overwrite) - reader.WriteEntryToDirectory(String.Format("{0}{1}", String.Format("{0}Temp\Facturas", UsuarioActual.Empresa.Ruta), ""), ExtractOptions.None Or ExtractOptions.Overwrite) - ListPDF.Add(String.Format("{0}Temp\Facturas\{1}", UsuarioActual.Empresa.Ruta, nombreArchivo)) - End If - End If - End While - End If - Catch ex As Exception - GuardaLogAD("'ERROR :" & ex.Message, eFacturasLog) - End Try - End Using Next @@ -1726,6 +1741,7 @@ Partial Class Compras_eFacturas For Each s As String In ListComprimidos Try File.Delete(s) + GuardaLogAD("") Catch ex As Exception End Try Next @@ -2853,11 +2869,14 @@ Partial Class Compras_eFacturas Dim TipoMensaje As ModExtensiones.TipoMensaje = ModExtensiones.TipoMensaje.MsgInformacion - Dim ListComprimidos As New List(Of String) - Dim ListXML As New List(Of String) - Dim ListPDF As New List(Of String) + For Each GvRow As GridViewRow In GVSolicitudesPendientes.Rows + + Dim ListComprimidos As New List(Of String) + Dim ListXML As New List(Of String) + Dim ListPDF As New List(Of String) + Dim CveSolicitudActual As Integer = GvRow.DataKey("CveSolicitud").ToEntero() Dim idSolicitud As String = GvRow.DataKey("idSolicitud").Trim() Dim CveTipoSolicitud As Integer = GvRow.DataKey("CveTipoSolicitud").ToEntero() @@ -2872,6 +2891,7 @@ Partial Class Compras_eFacturas Dim ResultadoSolicitudOK As Boolean = False Dim api As New GeneralesAPIeFacturas(If(EsProduccion, "http://localhost:4001/", "http://localhost:60281/")) + Dim Verificar As Boolean = True If idSolicitud.Length = 0 Then @@ -2938,6 +2958,7 @@ Partial Class Compras_eFacturas If File.Exists(destFile) Then ListComprimidos.Add(destFile) + 'GuardaLogAD($"eFacturas Solicitudes SAT Archivo copiado a {destFile}") Else sbArchivosFaltantes.AppendFormat("
Folio: {0} Archivo: {1}", Folio, fileName) End If diff --git a/Empresas/141/Formatos/Cotizacion.rdlc b/Empresas/141/Formatos/Cotizacion.rdlc index cfa5d036f..a3d62ba51 100644 --- a/Empresas/141/Formatos/Cotizacion.rdlc +++ b/Empresas/141/Formatos/Cotizacion.rdlc @@ -3533,6 +3533,8 @@ String + true + true ReportParameter1 diff --git a/Empresas/186/Formatos/Salidas.rdlc b/Empresas/186/Formatos/Salidas.rdlc index 0beebcd74..4caa30b19 100644 --- a/Empresas/186/Formatos/Salidas.rdlc +++ b/Empresas/186/Formatos/Salidas.rdlc @@ -738,7 +738,7 @@ CIUDAD DE MEXICO Textbox6 0.93835cm - 4.49034cm + 4.52562cm 1.56146cm 10.79062cm 1 diff --git a/Inventarios/Kardex.aspx.vb b/Inventarios/Kardex.aspx.vb index 111ac769d..f1af82c39 100644 --- a/Inventarios/Kardex.aspx.vb +++ b/Inventarios/Kardex.aspx.vb @@ -807,9 +807,10 @@ Partial Class Inventarios_Kardex Protected Sub ddlProducto2_selectedindexchange(sender As Object, e As EventArgs) LnkKPIVerComportamiento.Visible = False - If ddlProducto2.SelectedValue.ToEntero > 0 Then + If ddlProducto2.SelectedValue.ToEntero > 0 And UsuarioActual.CveRol = 1 Then LnkKPIVerComportamiento.Visible = True End If UpAcciones.Update() End Sub + End Class diff --git a/OC/OC.aspx.vb b/OC/OC.aspx.vb index fc461f901..a07691dee 100644 --- a/OC/OC.aspx.vb +++ b/OC/OC.aspx.vb @@ -1016,13 +1016,12 @@ Partial Class OC_OC LblPrioridad.Text = "Sucursal" DdlPrioridad.Visible = False DdlSubProyectoGral.Visible = True - End If - - If UsuarioActual.CveRol = 1 Then TrDescuentoEscalonado.Visible = True TrDescuentoProntoPago.Visible = True End If + + If UsuarioActual.Empresa.CveEmpresa = 189 AndAlso CveOrdenCompra <> Nothing AndAlso CveOrdenCompra > 0 Then BtnEdicionMasiva.Visible = True End If diff --git a/RH/Personal.aspx b/RH/Personal.aspx index 410822d28..0033345cd 100644 --- a/RH/Personal.aspx +++ b/RH/Personal.aspx @@ -4079,8 +4079,12 @@ + + +
+ @@ -4149,7 +4153,9 @@ - + <%----%> + @@ -4161,6 +4167,7 @@ --%> +
diff --git a/RH/Personal.aspx.vb b/RH/Personal.aspx.vb index 241a39359..bba66e78a 100644 --- a/RH/Personal.aspx.vb +++ b/RH/Personal.aspx.vb @@ -7,6 +7,7 @@ Imports System.Data Imports Microsoft.Reporting.WebForms Imports System.Globalization Imports System.Data.SqlTypes +Imports DocumentFormat.OpenXml.Drawing.Diagrams Partial Class RH_Personal Inherits ClsPaginas @@ -4357,6 +4358,7 @@ Partial Class RH_Personal objRH.Dispose() End Sub + Protected Sub GvDocumentosFirma_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDocumentosFirma.RowDataBound @@ -4364,7 +4366,8 @@ Partial Class RH_Personal Dim Adjunto As String = e.Row.DBCampo("Adjunto").ToString() Dim ImgDownLoadFormato As LinkButton = e.Row.FCLinkButton("ImgDownLoadFormato") - Dim ImgDownLoad As Literal = e.Row.FCLiteral("ImgDownLoad") + + Dim ImgDownLoad As LinkButton = e.Row.FCLinkButton("ImgDownLoad") Dim ImgRequired As Literal = e.Row.FCLiteral("ImgRequired") Dim txtFechaLimite As TextBox = e.Row.FCTextBox("TxtFechaLimite") Dim requerido As Boolean = If(e.Row.DBCampo("Requerido").ToUpper = "TRUE", True, False) @@ -4417,14 +4420,18 @@ Partial Class RH_Personal If File.Exists(linkDescargaArchivo) Then ImgDownLoad.Visible = True - If extencion.Length > 0 Then - ImgDownLoad.Text = String.Format(" ", linkDescarga, CvePersonal & Documentacion & "." & extencion) - Else - ImgDownLoad.Text = String.Format(" ", linkDescarga, CvePersonal & Documentacion) - End If + ScriptManager.GetCurrent(Me).RegisterPostBackControl(ImgDownLoad) + + 'If extencion.Length > 0 Then + ' ImgDownLoad.Text = String.Format(" ", linkDescarga, CvePersonal & Documentacion & "." & extencion) + 'Else + ' ImgDownLoad.Text = String.Format(" ", linkDescarga, CvePersonal & Documentacion) + 'End If + Else ImgDownLoad.Visible = False End If + Else ImgDownLoad.Visible = False End If @@ -4438,6 +4445,35 @@ Partial Class RH_Personal End If End Sub + + Protected Sub ImgDownLoad_Click(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + + Dim Adjunto As String = GvRow.DataKey("Adjunto").ToString() + Dim ArchivoPath As String = UsuarioActual.Empresa.Ruta & "Personal/" & CvePersonal & "/" & Adjunto + + DescargarArchivo(ArchivoPath) + + End Sub + + Protected Sub DescargarArchivo(rutaArchivo As String) + + If System.IO.File.Exists(rutaArchivo) Then + + Dim nombreArchivo As String = System.IO.Path.GetFileName(rutaArchivo) + Response.Clear() + Response.ContentType = "application/octet-stream" + Response.AddHeader("Content-Disposition", "attachment; filename=" & nombreArchivo) + Response.AddHeader("Content-Length", New System.IO.FileInfo(rutaArchivo).Length.ToString()) + Response.WriteFile(rutaArchivo) + Response.End() + + Else + + End If + End Sub + Public Sub DownLoadFormato_ClickDocumentacion(sender As Object, e As EventArgs) Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) @@ -8160,5 +8196,7 @@ Partial Class RH_Personal args.IsValid = retorno End Sub + + End Class diff --git a/Ventas/Clientes.aspx.vb b/Ventas/Clientes.aspx.vb index b91f6aae5..07edc6ac6 100644 --- a/Ventas/Clientes.aspx.vb +++ b/Ventas/Clientes.aspx.vb @@ -935,6 +935,39 @@ Partial Class Clientes If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then DivAseguradora.Visible = True + End If + + 'PROCESOS PARA OCULTAR OPCIONES + If TabAnticipos.Visible Then + TabAnticipos.Visible = Not UsuarioActual.TienePermisoProceso(391) + End If + + If TabComplementos.Visible Then + TabComplementos.Visible = Not UsuarioActual.TienePermisoProceso(392) + End If + + If TabOtros.Visible Then + TabOtros.Visible = Not UsuarioActual.TienePermisoProceso(393) + End If + + If TabUsuarios.Visible Then + TabUsuarios.Visible = Not UsuarioActual.TienePermisoProceso(394) + End If + + If TabContratos.Visible Then + TabContratos.Visible = Not UsuarioActual.TienePermisoProceso(395) + End If + + If TabSistema.Visible Then + TabSistema.Visible = Not UsuarioActual.TienePermisoProceso(396) + End If + + If TabDocumentacion.Visible Then + TabDocumentacion.Visible = Not UsuarioActual.TienePermisoProceso(397) + End If + + If TabRH.Visible Then + TabRH.Visible = Not UsuarioActual.TienePermisoProceso(398) End If End If @@ -1746,10 +1779,11 @@ Partial Class Clientes ElseIf UsuarioActual.Empresa.TipoContabilidad = 2 Then divCuentas.Visible = False divCuentasContp.Visible = True - End If - - - 'Ocultamos la mayoria de informacion si es no-frecuente + End If + + + + 'Ocultamos la mayoria de informacion si es no-frecuente If ObjClientes.TipoCliente = 2 Then If UsuarioActual.CveEmpresa <> 141 Then TabFiscalContable.Visible = False @@ -1769,7 +1803,8 @@ Partial Class Clientes 'DivPortletBitacora.Visible = False BtnEliminar.Visible = False - End If + End If + TxtCorreoEntregaCompras.Text = ObjClientes.DtResultados(0)("CorreoEntregaCompras").ToString() TxtCorreoEntregaAlmacen.Text = ObjClientes.DtResultados(0)("CorreoEntregaAlmacen").ToString() @@ -1803,11 +1838,11 @@ Partial Class Clientes TxtRepresentanteLegal.Text = ObjClientes.RepresentanteLegal End If + UpActivacionPortal.Update() UpModalPersonaFisica.Update() ObjClientes.Dispose() - watch.Stop() ' Alert(watch.ElapsedMilliseconds.ToString()) @@ -2992,7 +3027,17 @@ Partial Class Clientes If UsuarioActual.Empresa.Funcionalidad(185) = "1" AndAlso UsuarioActual.TienePermisoProceso(379) AndAlso CType(sender, GridView).ID = "GVAnticipos" Then - If e.Row.DBCampo("CveVenta").ToString().ToEntero() > 0 AndAlso e.Row.DBCampo("Tipo").ToString() = "Ant" Then + If e.Row.DBCampo("CveVenta").ToString().ToEntero() > 0 AndAlso e.Row.DBCampo("Tipo").ToString().Contiene("NC", "Ant") Then + If Not CBool(e.Row.DBCampo("AnticipoAutorizado")) Then + e.Row.FCLinkButton("LnkAutorizar").Visible = True + e.Row.FCLinkButton("LnkCancelar").Visible = False + Else + e.Row.FCLinkButton("LnkAutorizar").Visible = False + e.Row.FCLinkButton("LnkCancelar").Visible = True + End If + End If + + If e.Row.DBCampo("CveIE").ToString().ToEntero() > 0 AndAlso e.Row.DBCampo("Tipo").ToString().Contiene("IxC") Then If Not CBool(e.Row.DBCampo("AnticipoAutorizado")) Then e.Row.FCLinkButton("LnkAutorizar").Visible = True e.Row.FCLinkButton("LnkCancelar").Visible = False @@ -10744,14 +10789,23 @@ Partial Class Clientes Protected Sub LnkAutorizarAnticipo_Click(sender As Object, e As EventArgs) Dim GvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) Dim CveVenta As Integer = GvRow.DataKey("CveVenta").ToEntero() - If CveVenta > 0 Then + Dim CveIE As Integer = GvRow.DataKey("CveIE").ToEntero() + + If CveVenta > 0 OrElse CveIE > 0 Then Using ObjVentas As New ClsVentas - If ObjVentas.UpdateVentaAnticipoAutorizado(CveVenta, True) Then - Alert("El anticipo se autorizó correctamente") + If GvRow.DataKey("Tipo").Contiene("NC", "Ant") Then + If ObjVentas.UpdateVentaAnticipoAutorizado(CveVenta, True) Then + Alert("El anticipo se autorizó correctamente") + End If + ElseIf GvRow.DataKey("Tipo").Contiene("IxC") Then + If ObjVentas.UpdateIxCAnticipoAutorizado(CveIE, True) Then + Alert("El anticipo se autorizó correctamente") + End If End If End Using - CargaAnticipos() End If + + CargaAnticipos() End Sub Protected Sub LnkCancelarAnticipo_Click(sender As Object, e As EventArgs) diff --git a/Ventas/PVCobranza.aspx.vb b/Ventas/PVCobranza.aspx.vb index eb276ac57..dc5681eff 100644 --- a/Ventas/PVCobranza.aspx.vb +++ b/Ventas/PVCobranza.aspx.vb @@ -203,6 +203,9 @@ Partial Class Ventas_PVCobranza LkbEstadodeCaja.Visible = True LkbIngreso.Visible = True LkbRetiro.Visible = True + If UsuarioActual.CveEmpresa = 189 Then + LkbRetiro.Visible = False + End If UpTurno.Visible = True End If @@ -343,6 +346,11 @@ Partial Class Ventas_PVCobranza 'e.Row.CssClass = "blue-madison" End If + If e.Row.DBCampo("RemisionEspecial") = "1" Then + e.Row.BackColor = Drawing.ColorTranslator.FromHtml("#e9edef") + e.Row.ToolTip = "Remisión especial" + End If + If e.Row.DBCampo("TipoEntrega") = "2" OrElse e.Row.DBCampo("AplicaImpresionPorAnt") = "1" Then e.Row.FCLinkButton("LnkImprimir").Visible = True ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FCLinkButton("LnkImprimir")) @@ -831,6 +839,9 @@ Partial Class Ventas_PVCobranza DtAnticipos.Columns.Add("TotalAnticipo", GetType(Decimal)) DtAnticipos.Columns.Add("SubTotalAnticipo", GetType(Decimal)) DtAnticipos.Columns.Add("CveMoneda", GetType(Decimal)) + DtAnticipos.Columns.Add("Fecha", GetType(DateTime)) + DtAnticipos.Columns.Add("TipoCambioPago", GetType(Decimal)) + DtAnticipos.Columns.Add("Folio", GetType(String)) For Each GvRow As GridViewRow In GVAnticipos.Rows If GvRow.FCCheckBox("Chk" & GvRow.RowIndex) IsNot Nothing AndAlso GvRow.FCCheckBox("Chk" & GvRow.RowIndex).Checked Then @@ -844,8 +855,11 @@ Partial Class Ventas_PVCobranza Dim TotalAnticipo As Decimal = GvRow.DataKey("TotalAnticipo").ToDecimal() Dim SubTotalAnticipo As Decimal = GvRow.DataKey("SubTotalAnticipo").ToDecimal() Dim CveMoneda As Integer = GvRow.DataKey("CveMoneda").ToEntero() + Dim Fecha As DateTime = GvRow.DataKey("Fecha").ToDateTime() + Dim TipoCambioPago As Decimal = GvRow.DataKey("TipoCambioPago").ToDecimal() + Dim Folio = GvRow.DataKey("Folio") - DtAnticipos.Rows.Add(CveVenta, Importe, CveConceptoContable, CveIE, FolioFiscal, Descuentos, TotalAnticipo, SubTotalAnticipo, CveMoneda) + DtAnticipos.Rows.Add(CveVenta, Importe, CveConceptoContable, CveIE, FolioFiscal, Descuentos, TotalAnticipo, SubTotalAnticipo, CveMoneda, Fecha, TipoCambioPago, Folio) End If Next @@ -968,6 +982,9 @@ Partial Class Ventas_PVCobranza DtAnticipos.Columns.Add("TotalAnticipo", GetType(Decimal)) DtAnticipos.Columns.Add("SubTotalAnticipo", GetType(Decimal)) DtAnticipos.Columns.Add("CveMoneda", GetType(Decimal)) + DtAnticipos.Columns.Add("Fecha", GetType(DateTime)) + DtAnticipos.Columns.Add("TipoCambioPago", GetType(Decimal)) + DtAnticipos.Columns.Add("Folio", GetType(String)) For Each GvRow As GridViewRow In GVAnticipos.Rows If GvRow.FCCheckBox("Chk" & GvRow.RowIndex) IsNot Nothing AndAlso GvRow.FCCheckBox("Chk" & GvRow.RowIndex).Checked Then @@ -981,8 +998,11 @@ Partial Class Ventas_PVCobranza Dim TotalAnticipo As Decimal = GvRow.DataKey("TotalAnticipo").ToDecimal() Dim SubTotalAnticipo As Decimal = GvRow.DataKey("SubTotalAnticipo").ToDecimal() Dim CveMoneda As Integer = GvRow.DataKey("CveMoneda").ToEntero() + Dim Fecha As DateTime = GvRow.DataKey("Fecha").ToDateTime() + Dim TipoCambioPago As Decimal = GvRow.DataKey("TipoCambioPago").ToDecimal() + Dim Folio = GvRow.DataKey("Folio") - DtAnticipos.Rows.Add(CveVenta, Importe, CveConceptoContable, CveIE, FolioFiscal, Descuentos, TotalAnticipo, SubTotalAnticipo, CveMoneda) + DtAnticipos.Rows.Add(CveVenta, Importe, CveConceptoContable, CveIE, FolioFiscal, Descuentos, TotalAnticipo, SubTotalAnticipo, CveMoneda, Fecha, TipoCambioPago, Folio) End If Next @@ -1019,38 +1039,44 @@ Partial Class Ventas_PVCobranza ObjFactura.Timbre.CFDIRelacionados.UUID.Clear() If HdnTipoAmortizacion.Value = "2" Then Dim Anticipos = ListaAnticiposAplicados.Where(Function(Obj) Obj.Tipo = "Ant") - For Each Ant As Modelos.MAnticipoRelacionado In Anticipos - ObjFactura.Timbre.CFDIRelacionados.UUID.Add(Ant.FolioFiscal) - Next + If Anticipos IsNot Nothing AndAlso Anticipos.Count() > 0 Then + For Each Ant As Modelos.MAnticipoRelacionado In Anticipos + ObjFactura.Timbre.CFDIRelacionados.UUID.Add(Ant.FolioFiscal) + Next - ObjFactura.Timbre.CFDIRelacionados.TipoRelacion = "07" - ObjFactura.Timbre.CFDIRelacionados.TipoRelacionTexto = "07-CFDI por aplicación de anticipo" + ObjFactura.Timbre.CFDIRelacionados.TipoRelacion = "07" + ObjFactura.Timbre.CFDIRelacionados.TipoRelacionTexto = "07-CFDI por aplicación de anticipo" - 'AJUSTAR NC - If ObjNC IsNot Nothing Then - ObjNC.Timbre.CFDIRelacionados.UUID.Clear() + 'AJUSTAR NC + If ObjNC IsNot Nothing Then + ObjNC.Timbre.CFDIRelacionados.UUID.Clear() - ObjNC.Timbre.CFDIRelacionados.TipoRelacion = "07" - ObjNC.Timbre.CFDIRelacionados.TipoRelacionTexto = "07-CFDI por aplicación de anticipo" + ObjNC.Timbre.CFDIRelacionados.TipoRelacion = "07" + ObjNC.Timbre.CFDIRelacionados.TipoRelacionTexto = "07-CFDI por aplicación de anticipo" + End If End If + End If 'DEVOLUCIONES DE OTRA VENTA, APLICADAS EN UNA NUEVA If HdnTipoAmortizacion.Value = "4" Then Dim DevolucionesNC = ListaAnticiposAplicados.Where(Function(Obj) Obj.Tipo = "NC") - For Each Ant As Modelos.MAnticipoRelacionado In DevolucionesNC - ObjFactura.Timbre.CFDIRelacionados.UUID.Add(Ant.FolioFiscal) - Next + If DevolucionesNC IsNot Nothing AndAlso DevolucionesNC.Count() > 0 Then + For Each Ant As Modelos.MAnticipoRelacionado In DevolucionesNC + ObjFactura.Timbre.CFDIRelacionados.UUID.Add(Ant.FolioFiscal) + Next - 'TEMPORAL- DEBE SER TIPO RELACION "01 - Nota de crédito de los documentos relacionados" - Dim CveTipoRelacion As Integer = 1 + 'TEMPORAL- DEBE SER TIPO RELACION "01 - Nota de crédito de los documentos relacionados" + Dim CveTipoRelacion As Integer = 1 - ObjFactura.CveTipoRelacion = CveTipoRelacion + ObjFactura.CveTipoRelacion = CveTipoRelacion - Dim RowTipoRelacion As DataRow = GlobalDTVtaTiposRelacion().FiltroPrimero($"CveTipoRelacion = {CveTipoRelacion}") + Dim RowTipoRelacion As DataRow = GlobalDTVtaTiposRelacion().FiltroPrimero($"CveTipoRelacion = {CveTipoRelacion}") - ObjFactura.Timbre.CFDIRelacionados.TipoRelacion = RowTipoRelacion("SATClaveTipoRelacion").ToString() - ObjFactura.Timbre.CFDIRelacionados.TipoRelacionTexto = RowTipoRelacion("SATTipoRelacion").ToString() + ObjFactura.Timbre.CFDIRelacionados.TipoRelacion = RowTipoRelacion("SATClaveTipoRelacion").ToString() + ObjFactura.Timbre.CFDIRelacionados.TipoRelacionTexto = RowTipoRelacion("SATTipoRelacion").ToString() + + End If End If @@ -1187,22 +1213,58 @@ Partial Class Ventas_PVCobranza ObjPVenta.Dispose() End Sub + + Private Function ValidaCobranza() As Boolean + Dim Respuesta As Boolean = False + + If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then + + Dim ObjMovtos As New ClsMovimientos() + Dim FechaI, FechaF As Date + FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim().ToDate, MinFecha) + FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim().ToDate, MaxFecha).AddDays(1) + + If ObjMovtos.GetRemisionesCobranza(UsuarioActual.CveEmpresa, DdlSubProyecto.SelectedValue.ToEntero(), FechaI, FechaF) Then + Dim dtt As DataTable = ObjMovtos.DtResultados.FiltraParametros($"CveVenta > 0 AND (CveUsuarioCobranza IS NULL OR CveUsuarioCobranza = {UsuarioActual.CveUsuario}) AND TipoDocto IN ('Ing','Rem') AND RemisionEspecial = 0") + 'Dim Dtta As DataTable = dtt.FiltraParametros($"CveUsuarioCobranza = {UsuarioActual.CveUsuario} ") + 'If Dtta IsNot Nothing AndAlso Dtta.Rows.Count > 0 Then dtt = Dtta + + If dtt.Rows.Count = 0 Then + Respuesta = True + Else + Respuesta = False + Alert("No se puede realizar el cerrar el turno, ya que hay cobros pendientes por aplicar.", TipoMensaje.MsgAdvertencia) + End If + + Else + Alert("Error al consultarcobros pendientes.", TipoMensaje.MsgAdvertencia) + Respuesta = False + End If + ObjMovtos.Dispose() + Else + Respuesta = True + End If + + Return Respuesta + End Function + Private Sub BtnCerrarTurno_Click(sender As Object, e As EventArgs) Handles BtnCerrarTurno.Click 'validar. ' que no existan movimientos pendientes de pago. ' que no halla facturas pendientes de cancelación. ' no facturar remisiones de días anteriores - - Dim ObjPVenta As New ClsPuntoVenta - If TxtEfectivoEnCaja.Text.Trim <> "" Then - If ObjPVenta.UpdateFinalizadoVtaCortes(CveCorte, TxtEfectivoEnCaja.Text.ToDouble, LblDiferenciaCaja.Text.ToDouble, NowADS(), UsuarioActual.CveEmpresa) Then - RegistraScript($"window.location.href = '/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=CORT&CVECORTE={0}&FORMATO={1}", CveCorte, "PDF"))}'", "Imprimir") - Dim Liga As String = "document.location.href=""/Ventas/PVCobranza.aspx"";" - Alert("Se ha cerrado el turno correctamente.", TipoMensaje.MsgInformacion, Liga) + If ValidaCobranza() Then + Dim ObjPVenta As New ClsPuntoVenta + If TxtEfectivoEnCaja.Text.Trim <> "" Then + If ObjPVenta.UpdateFinalizadoVtaCortes(CveCorte, TxtEfectivoEnCaja.Text.ToDouble, LblDiferenciaCaja.Text.ToDouble, NowADS(), UsuarioActual.CveEmpresa) Then + RegistraScript($"window.location.href = '/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=CORT&CVECORTE={0}&FORMATO={1}", CveCorte, "PDF"))}'", "Imprimir") + Dim Liga As String = "document.location.href=""/Ventas/PVCobranza.aspx"";" + Alert("Se ha cerrado el turno correctamente.", TipoMensaje.MsgInformacion, Liga) + End If End If + ObjPVenta.Dispose() End If - ObjPVenta.Dispose() End Sub Private Sub BtnCerrarBloqueo_Click(sender As Object, e As EventArgs) Handles BtnCerrarBloqueo.Click Dim ObjPVenta As New ClsPuntoVenta @@ -1239,6 +1301,10 @@ Partial Class Ventas_PVCobranza ObjPVenta.Dispose() + If UsuarioActual.CveEmpresa = 189 Then + LkbRetiro.Visible = False + End If + RegistraScript("$('#DivCorteDeCaja').hide();") UpTurno.Update() @@ -1702,16 +1768,34 @@ Partial Class Ventas_PVCobranza Dim ObjProceso As New ClsSisProcesos If ObjProceso.GetUsuariosconProceso(379, UsuarioActual.CveEmpresa) Then 'proceso para autorizar - dtt = ObjProceso.DtResultados.Copy() + dtt = ObjProceso.DtResultados.FiltraParametros("", DistinctColumns:={"CveUsuario", "Celular"}) End If ObjProceso.Dispose() + Dim NombreCliente As String = "" + If gvr.DataKey("CveCliente").ToEntero() > 0 Then + NombreCliente = GlobalDTCliente(UsuarioActual.CveEmpresa, CveCliente:=gvr.DataKey("CveCliente").ToEntero()).FiltroPrimeroValor("NombreComercial") + End If + + Dim EnvioMsg As Boolean = False + If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then For Each dr As DataRow In dtt.Rows - ClsSisNotificaciones.EnviarAlerta("Solicitud de Anticipo", $"Solicitud de activación de anticipo Folio: {Folio}
Ir Activar", dr("CveUsuario").ToString, Tipo:=TipoNotificacion.ToastInformacionB) + Dim NumeroTelefono = "526621143532" + 'If EsProduccion Then + ' NumeroTelefono = String.Format("52{0}", dr("Celular").ToString()) + 'End If + EnvioMsg = ModExtensiones.EnviarNotificacionWhatsApp2(NumeroTelefono, "", $"Solicitud de activación de anticipo.\\nFolio: {Folio}.\\nCliente: {NombreCliente}.") + 'ClsSisNotificaciones.EnviarAlerta("Solicitud de Anticipo", $"Solicitud de activación de anticipo Folio: {Folio}
Ir Activar", dr("CveUsuario").ToString, Tipo:=TipoNotificacion.ToastInformacionB) Next End If + If EnvioMsg Then + Alert("Se envió una solicitud de autorización") + Else + Alert("No se envió la solicitud de autorización", TipoMensaje.MsgAdvertencia) + End If + UpAnticipos.Update() End Sub @@ -1806,7 +1890,7 @@ Partial Class Ventas_PVCobranza End If If UsuarioActual.Empresa.Funcionalidad(185) = "1" Then - If e.Row.DBCampo("Tipo").ToString().Contiene("Ant", "IxC") AndAlso Not CBool(e.Row.DBCampo("AnticipoAutorizado")) Then + If e.Row.DBCampo("Tipo").ToString().Contiene("NC", "Ant", "IxC") AndAlso Not CBool(e.Row.DBCampo("AnticipoAutorizado")) Then e.Row.FCCheckBox("Chk" & e.Row.RowIndex).Enabled = False e.Row.FCCheckBox("Chk" & e.Row.RowIndex).ToolTip = "Anticipo Bloqueado" e.Row.FCLinkButton("LnkSolicitarActivarAnticipo").Visible = True diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index f24257320..dca78cecb 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -865,6 +865,16 @@ + + + +
Remisión Especial:  + + + + + +
Sin existencia:  diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 21210923a..4f24501ba 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -2582,1043 +2582,1047 @@ Partial Class Ventas End If If UsuarioActual.Empresa.Funcionalidad(595) = "2" Then - LnkSolicitarCredito.Visible = True + LnkSolicitarCredito.Visible = True + End If + + DdlSATPS.setEsWebService(True) : DdlSATPS.Attributes.Add("data-metodo", "getpssat") + DivPSSAT.Visible = True + + SetValues() + CvePresupuesto = 0 + + 'MODALIDADES + If Request("Op") IsNot Nothing AndAlso Request("Op").ToString() <> "" Then + Opcion = Request("Op").ToString() + LblTitulo.Text = "Registro de Cotizaciones" + TrTipo.Visible = False + TabAlmacen.Visible = False + TabDetalleVentas.Visible = False + TabVentaAF.Visible = False + TabE.Visible = False + TabComplementos.Visible = False + divcondicionespago.Visible = UsuarioActual.Empresa.CvePlataforma = 1 'SI ES PLATAFORMA ERP SIEMPRE VSIBLE ESTE PORLET + ImgAntiPend.Visible = False + TrObsAlmacen.Visible = False + TrTxtObsAlmacen.Visible = False + TrPedido.Visible = False + TrOC.Visible = False + DdlTipoComprobante.SelectedValue = "Op" + Else + Opcion = "Ing" + DdlTipoComprobante.SelectedValue = "Ing" + End If + 'DdlTipoComprobante.Attributes.Add("onChange", "ActivaReferencia(this)") + TxtFecha.Text = NowADS().ToShortDateString() + TxtFechaEjecucion.Text = NowADS().ToShortDateString + LblUsuario.Text = UsuarioActual.Usuario + LblFechaRegistro.Text = NowADS().ToShortDateString() + + ImgDescPU.Attributes.Add("onclick", "javascript:$('#ModalDescuento').modal(); $get('LblTitulo1').style.display = ''; $get('LblTitulo2').style.display = 'none'; $get('LblTituloTipo1').style.display = ''; $get('LblTituloTipo2').style.display = 'none'; $get('HdnTipoDescuento').value = '0'; $get('LblPrecio1').style.display = ''; $get('LblTotalPS1').style.display = 'none'; $get('LblSubTotal1').style.display = 'none'; $get('LblAmort').style.display = 'none'; $get('BtnAplicarDescP').style.display = ''; $get('BtnAplicarDescG').style.display = 'none'; $get('TrMotivoDescuento').style.display = '';") + ImgDescConcepto.Attributes.Add("onclick", "javascript:$('#ModalDescuento').modal(); $get('LblTitulo1').style.display = ''; $get('LblTitulo2').style.display = 'none'; $get('LblTituloTipo1').style.display = ''; $get('LblTituloTipo2').style.display = 'none'; $get('HdnTipoDescuento').value = '1'; $get('LblPrecio1').style.display = 'none'; $get('LblTotalPS1').style.display = ''; $get('LblSubTotal1').style.display = 'none'; $get('LblAmort').style.display = 'none'; $get('BtnAplicarDescP').style.display = ''; $get('BtnAplicarDescG').style.display = 'none'; $get('TrMotivoDescuento').style.display = '';") + ImgDescTotal.Visible = False + + ImgDescTotal.Attributes.Add("onclick", "javascript:$('#ModalDescuento').modal(); $get('LblTitulo1').style.display = ''; $get('LblTitulo2').style.display = 'none'; $get('LblTituloTipo1').style.display = ''; $get('LblTituloTipo2').style.display = 'none'; $get('HdnTipoDescuento').value = '2'; $get('LblPrecio1').style.display = 'none'; $get('LblTotalPS1').style.display = 'none'; $get('LblSubTotal1').style.display = ''; $get('LblAmort').style.display = 'none'; $get('BtnAplicarDescP').style.display = 'none'; $get('BtnAplicarDescG').style.display = ''; $get('TrMotivoDescuento').style.display = '';") + 'ImgAntiPend.Attributes.Add("onclick", "$get('HdnTipoDescuento').value = '3'; MuestraAnticipos();") + ImgOtrosConceptos.Attributes.Add("onclick", "javascript:$('#ModalOtrosConceptos').modal();") + 'LkbAgregarComplementos.Attributes.Add("onclick", "javascript:$('#ModalComplementos').modal();") + 'ImgCerrar.Attributes.Add("OnClick", "$('#DivAnticipos').hide();") + 'LkbEstadodeCaja.Attributes.Add("OnClick", "MuestraEstadoCaja();") + 'LkbIngreso.Attributes.Add("OnClick", "MuestraIngresoEgreso(1);") + 'LkbRetiro.Attributes.Add("OnClick", "MuestraIngresoEgreso(0);") + TxtImporteEfectivo.Attributes.Add("onKeyUp", "CalculaTotalPagoContado();") + TxtImporteCredito.Attributes.Add("onKeyUp", "CalculaTotalPagoContado();") + TxtImporteDebito.Attributes.Add("onKeyUp", "CalculaTotalPagoContado();") + TxtImporteCheque.Attributes.Add("onKeyUp", "CalculaTotalPagoContado();") + TxtImporteTransferencia.Attributes.Add("onKeyUp", "CalculaTotalPagoContado();") + TxtImporteOtrosContado.Attributes.Add("onKeyUp", "CalculaTotalPagoContado();") + + TxtEfectivoEnCaja.Attributes.Add("onKeyUp", "CalculaDiferencia();") + TxtEfectivoCajaBloqueo.Attributes.Add("onKeyUp", "CalculaDiferenciaBloqueo();") + + 'ImgCerrarTerminoCorte.Attributes.Add("OnClick", "$('#DivTerminarCorte').hide();") + 'ImgCerrarIE.Attributes.Add("OnClick", "$('#DivIngresoEgreso').hide();")DdlTipoComprobante + 'ImgCerrarEstadoCaja.Attributes.Add("OnClick", "$('#DivEstadoCaja').hide();") + TabAlmacen.Enabled = UsuarioActual.Empresa.UsaInventarios + TxtPorDescP.Attributes.Add("onKeyUp", "CalculaDescuento();") + TxtDescP.Attributes.Add("onKeyUp", "CalculaDescuento();") + TxtPorPS.Attributes.Add("onKeyUp", "CalculaDescPS();") + + CreaDTmpC() + CreaDTmpF() + CreaDTDocumentosRelacionados() + CargaDdlSubProyectos() + 'CargaProyecto() + CargaSucursales() + + CargaClasificaciones() + CargaPS(-1, DdlPS) + CargaPS(-1, DdlPSMercancia) + CargaPS(-1, DdlPSFlete) + 'CargaPSRemision(-1, DdlPSRemision) + + CreaDTVentas() + CargaMetodosPago() + 'CargaFormaPago(-1) + CargaUsoCFDI() + CargaMotivosCancelacion() + CargaTiposRelacion() + CargaMonedas() + CargaVendedores() + CargarAlmacenes() + If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then + CargaFormaEntrega() + 'DdlClasificacion.Visible = False + 'ltlbr.Visible = False + End If + + CargaCuentasTerminal() + 'CargaDdlNCPS() + 'CargarCamiones() + + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then + CargaMedicos() + CargaProcedimientos() + CargaDdlClientesSucursal() + End If + + + 'SI USUARIO USA AMORTIZACIÓN CONTABLE, se carga las tablas para usarlas mas adelante + If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaAC Then + + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem")) + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Cot")) + DdlTipoComprobante.Items.Add(New ListItem("Compromisos", "Com")) + DdlTipoComprobante.Items.Add(New ListItem("Orden Pago", "OP")) + + Dim AC As New ClsAC + If AC.GetPresupuestoIngresos(-1, NowADS().Year, True, UsuarioActual.CveEmpresa) Then + DdlFuenteRecaudacion.DataSource = AC.DtResultados() + DTPresupuestoIngresos = AC.DtResultados() + ViewState("DTFuenteRecaudacion") = AC.DtResultados() + 'GenerarPolizasAC() End If + AC.Dispose() + 'columna de Fuente de recaudacion + GvPS.Columns(21).Visible = True + nomostrar.Visible = True + nomostrar2.Visible = True + 'GvPS.Width = 1250 + DdlFuenteRecaudacion.DataBind() + Else + TFuenteRecaudacion.Visible = False + End If - DdlSATPS.setEsWebService(True) : DdlSATPS.Attributes.Add("data-metodo", "getpssat") - DivPSSAT.Visible = True + 'Carga cliente + If Request("CveCliente") IsNot Nothing AndAlso IsNumeric(Request("CveCliente")) AndAlso Request("CveCliente").ToEntero() > 0 AndAlso Request("CveFactura") Is Nothing Then + ViewState("CveCliente") = Request("CveCliente") + HdnCveCliente.Value = Request("CveCliente") + CargaCliente(CveCliente) + VerificarContrato(True) + Else + ViewState("CveCliente") = -1 + HdnCveCliente.Value = "-1" - SetValues() - CvePresupuesto = 0 - - 'MODALIDADES - If Request("Op") IsNot Nothing AndAlso Request("Op").ToString() <> "" Then - Opcion = Request("Op").ToString() - LblTitulo.Text = "Registro de Cotizaciones" - TrTipo.Visible = False - TabAlmacen.Visible = False - TabDetalleVentas.Visible = False - TabVentaAF.Visible = False - TabE.Visible = False - TabComplementos.Visible = False - divcondicionespago.Visible = UsuarioActual.Empresa.CvePlataforma = 1 'SI ES PLATAFORMA ERP SIEMPRE VSIBLE ESTE PORLET - ImgAntiPend.Visible = False - TrObsAlmacen.Visible = False - TrTxtObsAlmacen.Visible = False - TrPedido.Visible = False - TrOC.Visible = False - DdlTipoComprobante.SelectedValue = "Op" - Else - Opcion = "Ing" - DdlTipoComprobante.SelectedValue = "Ing" + 'SI TIENE UN CLIENTE POR DEFECTO DEBE CARGARLO AL INICIAR + If UsuarioActual.Empresa.Funcionalidad(714).ToEntero() > 0 Then + ViewState("CveCliente") = UsuarioActual.Empresa.Funcionalidad(714).ToEntero() + HdnCveCliente.Value = UsuarioActual.Empresa.Funcionalidad(714) + RBLPago.SelectedValue = "2" + RBLPago_SelectedIndexChanged(RBLPago, EventArgs.Empty) + CargaCliente(CveCliente) End If - 'DdlTipoComprobante.Attributes.Add("onChange", "ActivaReferencia(this)") - TxtFecha.Text = NowADS().ToShortDateString() - TxtFechaEjecucion.Text = NowADS().ToShortDateString - LblUsuario.Text = UsuarioActual.Usuario - LblFechaRegistro.Text = NowADS().ToShortDateString() - - ImgDescPU.Attributes.Add("onclick", "javascript:$('#ModalDescuento').modal(); $get('LblTitulo1').style.display = ''; $get('LblTitulo2').style.display = 'none'; $get('LblTituloTipo1').style.display = ''; $get('LblTituloTipo2').style.display = 'none'; $get('HdnTipoDescuento').value = '0'; $get('LblPrecio1').style.display = ''; $get('LblTotalPS1').style.display = 'none'; $get('LblSubTotal1').style.display = 'none'; $get('LblAmort').style.display = 'none'; $get('BtnAplicarDescP').style.display = ''; $get('BtnAplicarDescG').style.display = 'none'; $get('TrMotivoDescuento').style.display = '';") - ImgDescConcepto.Attributes.Add("onclick", "javascript:$('#ModalDescuento').modal(); $get('LblTitulo1').style.display = ''; $get('LblTitulo2').style.display = 'none'; $get('LblTituloTipo1').style.display = ''; $get('LblTituloTipo2').style.display = 'none'; $get('HdnTipoDescuento').value = '1'; $get('LblPrecio1').style.display = 'none'; $get('LblTotalPS1').style.display = ''; $get('LblSubTotal1').style.display = 'none'; $get('LblAmort').style.display = 'none'; $get('BtnAplicarDescP').style.display = ''; $get('BtnAplicarDescG').style.display = 'none'; $get('TrMotivoDescuento').style.display = '';") - ImgDescTotal.Visible = False - - ImgDescTotal.Attributes.Add("onclick", "javascript:$('#ModalDescuento').modal(); $get('LblTitulo1').style.display = ''; $get('LblTitulo2').style.display = 'none'; $get('LblTituloTipo1').style.display = ''; $get('LblTituloTipo2').style.display = 'none'; $get('HdnTipoDescuento').value = '2'; $get('LblPrecio1').style.display = 'none'; $get('LblTotalPS1').style.display = 'none'; $get('LblSubTotal1').style.display = ''; $get('LblAmort').style.display = 'none'; $get('BtnAplicarDescP').style.display = 'none'; $get('BtnAplicarDescG').style.display = ''; $get('TrMotivoDescuento').style.display = '';") - 'ImgAntiPend.Attributes.Add("onclick", "$get('HdnTipoDescuento').value = '3'; MuestraAnticipos();") - ImgOtrosConceptos.Attributes.Add("onclick", "javascript:$('#ModalOtrosConceptos').modal();") - 'LkbAgregarComplementos.Attributes.Add("onclick", "javascript:$('#ModalComplementos').modal();") - 'ImgCerrar.Attributes.Add("OnClick", "$('#DivAnticipos').hide();") - 'LkbEstadodeCaja.Attributes.Add("OnClick", "MuestraEstadoCaja();") - 'LkbIngreso.Attributes.Add("OnClick", "MuestraIngresoEgreso(1);") - 'LkbRetiro.Attributes.Add("OnClick", "MuestraIngresoEgreso(0);") - TxtImporteEfectivo.Attributes.Add("onKeyUp", "CalculaTotalPagoContado();") - TxtImporteCredito.Attributes.Add("onKeyUp", "CalculaTotalPagoContado();") - TxtImporteDebito.Attributes.Add("onKeyUp", "CalculaTotalPagoContado();") - TxtImporteCheque.Attributes.Add("onKeyUp", "CalculaTotalPagoContado();") - TxtImporteTransferencia.Attributes.Add("onKeyUp", "CalculaTotalPagoContado();") - TxtImporteOtrosContado.Attributes.Add("onKeyUp", "CalculaTotalPagoContado();") - - TxtEfectivoEnCaja.Attributes.Add("onKeyUp", "CalculaDiferencia();") - TxtEfectivoCajaBloqueo.Attributes.Add("onKeyUp", "CalculaDiferenciaBloqueo();") - - 'ImgCerrarTerminoCorte.Attributes.Add("OnClick", "$('#DivTerminarCorte').hide();") - 'ImgCerrarIE.Attributes.Add("OnClick", "$('#DivIngresoEgreso').hide();")DdlTipoComprobante - 'ImgCerrarEstadoCaja.Attributes.Add("OnClick", "$('#DivEstadoCaja').hide();") - TabAlmacen.Enabled = UsuarioActual.Empresa.UsaInventarios - TxtPorDescP.Attributes.Add("onKeyUp", "CalculaDescuento();") - TxtDescP.Attributes.Add("onKeyUp", "CalculaDescuento();") - TxtPorPS.Attributes.Add("onKeyUp", "CalculaDescPS();") - - CreaDTmpC() - CreaDTmpF() - CreaDTDocumentosRelacionados() - CargaDdlSubProyectos() - 'CargaProyecto() - CargaSucursales() - - CargaClasificaciones() - CargaPS(-1, DdlPS) - CargaPS(-1, DdlPSMercancia) - CargaPS(-1, DdlPSFlete) - 'CargaPSRemision(-1, DdlPSRemision) - - CreaDTVentas() - CargaMetodosPago() - 'CargaFormaPago(-1) - CargaUsoCFDI() - CargaMotivosCancelacion() - CargaTiposRelacion() - CargaMonedas() - CargaVendedores() - CargarAlmacenes() - If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then - CargaFormaEntrega() - 'DdlClasificacion.Visible = False - 'ltlbr.Visible = False - End If - - CargaCuentasTerminal() - 'CargaDdlNCPS() - 'CargarCamiones() If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then - CargaMedicos() - CargaProcedimientos() - CargaDdlClientesSucursal() - End If + 'SI ES COTIZACION CARGAR CLIENTE PUBLICO GENERAL + If Opcion = "Cot" Then + Dim CveClientePG As Integer = -1 + If UsuarioActual.CveEmpresa = 186 Then + CveClientePG = 1151377 + ViewState("CveCliente") = CveClientePG + HdnCveCliente.Value = CveClientePG.ToString() + CargaCliente(CveCliente) - - 'SI USUARIO USA AMORTIZACIÓN CONTABLE, se carga las tablas para usarlas mas adelante - If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaAC Then - - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem")) - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Cot")) - DdlTipoComprobante.Items.Add(New ListItem("Compromisos", "Com")) - DdlTipoComprobante.Items.Add(New ListItem("Orden Pago", "OP")) - - Dim AC As New ClsAC - If AC.GetPresupuestoIngresos(-1, NowADS().Year, True, UsuarioActual.CveEmpresa) Then - DdlFuenteRecaudacion.DataSource = AC.DtResultados() - DTPresupuestoIngresos = AC.DtResultados() - ViewState("DTFuenteRecaudacion") = AC.DtResultados() - 'GenerarPolizasAC() - End If - AC.Dispose() - 'columna de Fuente de recaudacion - GvPS.Columns(21).Visible = True - nomostrar.Visible = True - nomostrar2.Visible = True - 'GvPS.Width = 1250 - DdlFuenteRecaudacion.DataBind() - Else - TFuenteRecaudacion.Visible = False - End If - - 'Carga cliente - If Request("CveCliente") IsNot Nothing AndAlso IsNumeric(Request("CveCliente")) AndAlso Request("CveCliente").ToEntero() > 0 AndAlso Request("CveFactura") Is Nothing Then - ViewState("CveCliente") = Request("CveCliente") - HdnCveCliente.Value = Request("CveCliente") - CargaCliente(CveCliente) - VerificarContrato(True) - Else - ViewState("CveCliente") = -1 - HdnCveCliente.Value = "-1" - - 'SI TIENE UN CLIENTE POR DEFECTO DEBE CARGARLO AL INICIAR - If UsuarioActual.Empresa.Funcionalidad(714).ToEntero() > 0 Then - ViewState("CveCliente") = UsuarioActual.Empresa.Funcionalidad(714).ToEntero() - HdnCveCliente.Value = UsuarioActual.Empresa.Funcionalidad(714) - RBLPago.SelectedValue = "2" - RBLPago_SelectedIndexChanged(RBLPago, EventArgs.Empty) - CargaCliente(CveCliente) - End If - - If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then - 'SI ES COTIZACION CARGAR CLIENTE PUBLICO GENERAL - If Opcion = "Cot" Then - Dim CveClientePG As Integer = -1 - If UsuarioActual.CveEmpresa = 186 Then - CveClientePG = 1151377 - ViewState("CveCliente") = CveClientePG - HdnCveCliente.Value = CveClientePG.ToString() - CargaCliente(CveCliente) - - TrVentasMedicas2.Visible = False - TrVentasMedicas3.Visible = False - End If + TrVentasMedicas2.Visible = False + TrVentasMedicas3.Visible = False End If End If - End If - 'Carga empresa CRM - If Request("CveEmpresaCRM") IsNot Nothing AndAlso IsNumeric(Request("CveEmpresaCRM")) AndAlso Request("CveEmpresaCRM").ToEntero() > 0 Then - ViewState("CveEmpresaCRM") = Request("CveEmpresaCRM") - CargaEmpresaCRM(CveEmpresaCRM) - Else - ViewState("CveEmpresaCRM") = -1 + End If + + 'Carga empresa CRM + If Request("CveEmpresaCRM") IsNot Nothing AndAlso IsNumeric(Request("CveEmpresaCRM")) AndAlso Request("CveEmpresaCRM").ToEntero() > 0 Then + ViewState("CveEmpresaCRM") = Request("CveEmpresaCRM") + CargaEmpresaCRM(CveEmpresaCRM) + Else + ViewState("CveEmpresaCRM") = -1 + End If + + If Request("CveAcercamientoCRM") IsNot Nothing AndAlso IsNumeric(Request("CveAcercamientoCRM")) AndAlso Request("CveAcercamientoCRM").ToEntero() > 0 Then + ViewState("CveAcercamientoCRM") = Request("CveAcercamientoCRM") + + Dim cRMService As ICRMService = New CRMService(System.Configuration.ConfigurationManager.ConnectionStrings("Conexion").ConnectionString) + Dim AcercamientoModel As New RequestAcercamiento(UsuarioActual.CveEmpresa, CveAcercamientoCRM) + Dim objAcercamiento = cRMService.GetAceracamientoCRM(AcercamientoModel) + + If objAcercamiento.Result.Count > 0 Then + CorreoContactoCRM = objAcercamiento.Result(0).CorreoContacto End If - If Request("CveAcercamientoCRM") IsNot Nothing AndAlso IsNumeric(Request("CveAcercamientoCRM")) AndAlso Request("CveAcercamientoCRM").ToEntero() > 0 Then - ViewState("CveAcercamientoCRM") = Request("CveAcercamientoCRM") + Else + ViewState("CveAcercamientoCRM") = -1 + End If - Dim cRMService As ICRMService = New CRMService(System.Configuration.ConfigurationManager.ConnectionStrings("Conexion").ConnectionString) - Dim AcercamientoModel As New RequestAcercamiento(UsuarioActual.CveEmpresa, CveAcercamientoCRM) - Dim objAcercamiento = cRMService.GetAceracamientoCRM(AcercamientoModel) + 'mensaje de confirmación al guardar + BtnEmitirImprimir.OnClientClick = $"ValidaGuardar({ If(ImprimeNombreSucursal = True, 1, 0)},{If(HdnTieneAnticipos.Value = "1", 1, 0)});" + BtnEmitirImprimir.Attributes.Add("data-toggle", "confirmation") + BtnEmitirImprimir.Attributes.Add("data-popout", "true") + BtnEmitirImprimir.Attributes.Add("data-original-title", "confirmar") + BtnEmitirImprimir.Attributes.Add("data-btn-ok-label", "Guardar") + BtnEmitirImprimir.Attributes.Add("data-html", "true") - If objAcercamiento.Result.Count > 0 Then - CorreoContactoCRM = objAcercamiento.Result(0).CorreoContacto + If UsuarioActual.CveEmpresa.Contiene(126) Then ' cuando la empresa se relaciona a ua orden de producción, Citrus Game + TrOP.Visible = True + CargaOrdenProduccion() + End If + + 'MUESTRA EL MODAL PARA PODER RELACIONAR FACTURAS + If UsuarioActual.TienePermisoProceso(321) Then + LnkFacturasRelacionadas.Visible = True + End If + + If Request("CveOrdenProduccion") IsNot Nothing AndAlso IsNumeric(Request("CveOrdenProduccion")) AndAlso Request("CveOrdenProduccion").ToEntero() > 0 Then + DdlSubProyectoDatos.SelectedValueExist(11954) + Using ObjVentas As New ClsNominas + + If ObjVentas.ManifiestoForVtaGet(UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, "", -Request("CveOrdenProduccion").ToEntero()) Then + TmpDT = ObjVentas.DtResultados + TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) + TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer)) + TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer)) + TmpDT.Columns.Add("TieneProntoPago", GetType(String)) + TmpDT.Columns.Add("ImporteProntoPago", GetType(Decimal)) + TmpDT.Columns.Add("CveMarca", GetType(Integer)) + TmpDT.Columns.Add("CvePrecioLista", GetType(Integer)) + TmpDT.Columns.Add("PrecioLista", GetType(String)) + TmpDT.Columns.Add("CveActivoFijo", GetType(Integer)) + TmpDT.Columns.Add("AFDepreciacion", GetType(Decimal)) + TmpDT.Columns.Add("AFValorInicial", GetType(Decimal)) + TmpDT.Columns.Add("NumTurnos", GetType(Decimal)) + TmpDT.Columns("NumTurnos").DefaultValue = 0D + TmpDT.Columns.Add("NumeroPedimento", GetType(String)) + TmpDT.Columns.Add("CodigoAlterno", GetType(String)) + TmpDT.Columns.Add("PSAlterno", GetType(String)) + TmpDT.Columns.Add("Costo", GetType(Decimal)) + TmpDT.Columns("Costo").DefaultValue = 0D + + GvPS.DataSource = ObjVentas.DtResultados + GvPS.DataBind() + + End If + End Using + End If + + + If Request("CveManifiesto") IsNot Nothing AndAlso IsNumeric(Request("CveManifiesto")) AndAlso Request("CveManifiesto").ToEntero() > 0 Then + Using ObjCGame As New ClsCGame() + + If ObjCGame.ManifiestoGet(Request("CveManifiesto").ToEntero(), -1, -1, -1, -1, -1, -1, -1, -1, UsuarioActual.CveEmpresa, "-1", "-1") AndAlso ObjCGame.DtResultados.Rows.Count > 0 Then + DdlSubProyectoDatos.SelectedValueExist(ObjCGame.DtResultados.Rows(0)("CveSubProyecto").ToString()) End If - Else - ViewState("CveAcercamientoCRM") = -1 - End If + If ObjCGame.ManifiestoForVtaGet(UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, Request("CveManifiesto").ToEntero()) Then + GvPS.DataSource = ObjCGame.DtResultados + TmpDT = ObjCGame.DtResultados + TmpDT.Columns.Add("Costo", GetType(Decimal)) + TmpDT.Columns("Costo").DefaultValue = 0D - 'mensaje de confirmación al guardar - BtnEmitirImprimir.OnClientClick = $"ValidaGuardar({ If(ImprimeNombreSucursal = True, 1, 0)},{If(HdnTieneAnticipos.Value = "1", 1, 0)});" - BtnEmitirImprimir.Attributes.Add("data-toggle", "confirmation") - BtnEmitirImprimir.Attributes.Add("data-popout", "true") - BtnEmitirImprimir.Attributes.Add("data-original-title", "confirmar") - BtnEmitirImprimir.Attributes.Add("data-btn-ok-label", "Guardar") - BtnEmitirImprimir.Attributes.Add("data-html", "true") - - If UsuarioActual.CveEmpresa.Contiene(126) Then ' cuando la empresa se relaciona a ua orden de producción, Citrus Game - TrOP.Visible = True - CargaOrdenProduccion() - End If - - 'MUESTRA EL MODAL PARA PODER RELACIONAR FACTURAS - If UsuarioActual.TienePermisoProceso(321) Then - LnkFacturasRelacionadas.Visible = True - End If - - If Request("CveOrdenProduccion") IsNot Nothing AndAlso IsNumeric(Request("CveOrdenProduccion")) AndAlso Request("CveOrdenProduccion").ToEntero() > 0 Then - DdlSubProyectoDatos.SelectedValueExist(11954) - Using ObjVentas As New ClsNominas - - If ObjVentas.ManifiestoForVtaGet(UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, "", -Request("CveOrdenProduccion").ToEntero()) Then - TmpDT = ObjVentas.DtResultados - TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) - TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer)) - TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer)) - TmpDT.Columns.Add("TieneProntoPago", GetType(String)) - TmpDT.Columns.Add("ImporteProntoPago", GetType(Decimal)) - TmpDT.Columns.Add("CveMarca", GetType(Integer)) - TmpDT.Columns.Add("CvePrecioLista", GetType(Integer)) - TmpDT.Columns.Add("PrecioLista", GetType(String)) - TmpDT.Columns.Add("CveActivoFijo", GetType(Integer)) - TmpDT.Columns.Add("AFDepreciacion", GetType(Decimal)) - TmpDT.Columns.Add("AFValorInicial", GetType(Decimal)) - TmpDT.Columns.Add("NumTurnos", GetType(Decimal)) - TmpDT.Columns("NumTurnos").DefaultValue = 0D - TmpDT.Columns.Add("NumeroPedimento", GetType(String)) - TmpDT.Columns.Add("CodigoAlterno", GetType(String)) - TmpDT.Columns.Add("PSAlterno", GetType(String)) - TmpDT.Columns.Add("Costo", GetType(Decimal)) - TmpDT.Columns("Costo").DefaultValue = 0D - - GvPS.DataSource = ObjVentas.DtResultados - GvPS.DataBind() - - End If - End Using - End If - - - If Request("CveManifiesto") IsNot Nothing AndAlso IsNumeric(Request("CveManifiesto")) AndAlso Request("CveManifiesto").ToEntero() > 0 Then - Using ObjCGame As New ClsCGame() - - If ObjCGame.ManifiestoGet(Request("CveManifiesto").ToEntero(), -1, -1, -1, -1, -1, -1, -1, -1, UsuarioActual.CveEmpresa, "-1", "-1") AndAlso ObjCGame.DtResultados.Rows.Count > 0 Then - DdlSubProyectoDatos.SelectedValueExist(ObjCGame.DtResultados.Rows(0)("CveSubProyecto").ToString()) - End If - - If ObjCGame.ManifiestoForVtaGet(UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, Request("CveManifiesto").ToEntero()) Then - GvPS.DataSource = ObjCGame.DtResultados - TmpDT = ObjCGame.DtResultados - TmpDT.Columns.Add("Costo", GetType(Decimal)) - TmpDT.Columns("Costo").DefaultValue = 0D - - GvPS.DataBind() - End If - - End Using - - If TmpDT IsNot Nothing Then - DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2") - TabAlmacen.Visible = True - DivAlmacen.Visible = True - CargaGVInv(DtInv) + GvPS.DataBind() End If + End Using - If AplicaComercioExterior Then + If TmpDT IsNot Nothing Then + DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2") + TabAlmacen.Visible = True + DivAlmacen.Visible = True + CargaGVInv(DtInv) + End If + + + If AplicaComercioExterior Then + CargaGvComercioExterior() + End If + End If + + If Request("CveEmbarqueManifiesto") IsNot Nothing AndAlso IsNumeric(Request("CveEmbarqueManifiesto")) AndAlso Request("CveEmbarqueManifiesto").ToEntero() > 0 Then + DdlMoneda.SelectedValueExist(2) + CambiaMoneda() + Using ObjVentas As New ClsNominas + If ObjVentas.EmbarqueManifiestoGet(-1, -1, -1, Request("CveEmbarqueManifiesto").ToString().ToEntero()) And ObjVentas.DtResultados.Rows.Count > 0 Then + DdlSubProyectoDatos.SelectedValueExist(ObjVentas.DtResultados.Rows(0)("CveSubProyecto").ToString()) + End If + If ObjVentas.ManifiestoForVtaGet(UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, "", Request("CveEmbarqueManifiesto").ToEntero()) Then + TmpDT = ObjVentas.DtResultados + TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) + TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer)) + TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer)) + TmpDT.Columns.Add("TieneProntoPago", GetType(String)) + TmpDT.Columns.Add("ImporteProntoPago", GetType(Decimal)) + TmpDT.Columns.Add("CveMarca", GetType(Integer)) + TmpDT.Columns.Add("CvePrecioLista", GetType(Integer)) + TmpDT.Columns.Add("PrecioLista", GetType(String)) + TmpDT.Columns.Add("CveActivoFijo", GetType(Integer)) + TmpDT.Columns.Add("AFDepreciacion", GetType(Decimal)) + TmpDT.Columns.Add("AFValorInicial", GetType(Decimal)) + TmpDT.Columns.Add("NumTurnos", GetType(Decimal)) + TmpDT.Columns("NumTurnos").DefaultValue = 0D + TmpDT.Columns.Add("NumeroPedimento", GetType(String)) + TmpDT.Columns.Add("CodigoAlterno", GetType(String)) + TmpDT.Columns.Add("PSAlterno", GetType(String)) + TmpDT.Columns.Add("Costo", GetType(Decimal)) + TmpDT.Columns("Costo").DefaultValue = 0D + GvPS.DataSource = ObjVentas.DtResultados + GvPS.DataBind() + + End If + End Using + End If + + 'Carga Venta + If Request("CveVenta") IsNot Nothing AndAlso IsNumeric(Request("CveVenta")) AndAlso Request("CveVenta").ToEntero() > 0 Then + ViewState("CveVenta") = Request("CveVenta") + + If CargaVenta() Then + If UsuarioActual.TienePermisoProceso(321) Then + CargaRelacionadasPendientes() + End If + + DdlSubProyectoDatos.Enabled = False + BtnEmitirImprimir.Visible = False + BtnCrearApartirDe.Visible = True + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then BtnCrearApartirDe.Visible = False + + If DdlTipoComprobante.SelectedValue = "Ped" Then + BtnPermisoEditarRemision.Text = "Editar Pedido" + BtnEditarRemision.Text = "Actualizar Pedido" + End If + + DivFechaAnticipoCliente.Visible = True + TxtFechaAnticipoCliente.Text = NowADS().ToShortDateString + + ImgAddObs.Visible = True + CargaEventoBitacora() + ConfiguraTipoDocto() + TrFolioFiscal.Visible = True + + 'PERMISO PARA CANCELAR PEDIDO + 'If GvInv.Rows.Count = 0 Then + ' If DdlTipoComprobante.SelectedValue.Contiene("Ped") And Not CveEstatus = 14 Then + ' If UsuarioActual.TienePermisoProceso(186) Then + ' LBCancelarPedido.Visible = True + ' End If + ' End If + 'End If + + 'CARGA GV DE COMERCIO EXTERIOR SI NO ESTA TIMBRADA + If LblSeTimbro.Text = "No" Then CargaGvComercioExterior() End If + + 'HABILITA IMPRESION DE FORMATO CICOVISA + If UsuarioActual.CveEmpresa = 72 And CveCliente = 70381 And DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem") Then + LnkImprimirFormatoCicovisa.Visible = True + End If + 'HABILITA IMPRESION DE FORMATO TELCEL + If UsuarioActual.CveEmpresa = 72 And CveCliente = 70869 And DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem") Then + LnkImprimirFormatoTelcel.Visible = True + End If + + If DdlTipoComprobante.SelectedValue = "Ing" Then + CargaVentaCortePorte(Me.CveVenta) + End If + + HlEvento.Visible = True + HlEvento.NavigateUrl = "/OI/PopUpAgenda.aspx?CveTipoEvento=2&CveVenta=" & CveVenta & "&TB_iframe=true&height=370&width=600;" + + ''SOLO SISTEMA DEBE VER ESTA OPCION + If UsuarioActual.CveUsuario = 100 Then + LnkCancelarSoloCFDI.Visible = True + End If + End If - If Request("CveEmbarqueManifiesto") IsNot Nothing AndAlso IsNumeric(Request("CveEmbarqueManifiesto")) AndAlso Request("CveEmbarqueManifiesto").ToEntero() > 0 Then - DdlMoneda.SelectedValueExist(2) - CambiaMoneda() - Using ObjVentas As New ClsNominas - If ObjVentas.EmbarqueManifiestoGet(-1, -1, -1, Request("CveEmbarqueManifiesto").ToString().ToEntero()) And ObjVentas.DtResultados.Rows.Count > 0 Then - DdlSubProyectoDatos.SelectedValueExist(ObjVentas.DtResultados.Rows(0)("CveSubProyecto").ToString()) - End If - If ObjVentas.ManifiestoForVtaGet(UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, "", Request("CveEmbarqueManifiesto").ToEntero()) Then - TmpDT = ObjVentas.DtResultados - TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) - TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer)) - TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer)) - TmpDT.Columns.Add("TieneProntoPago", GetType(String)) - TmpDT.Columns.Add("ImporteProntoPago", GetType(Decimal)) - TmpDT.Columns.Add("CveMarca", GetType(Integer)) - TmpDT.Columns.Add("CvePrecioLista", GetType(Integer)) - TmpDT.Columns.Add("PrecioLista", GetType(String)) - TmpDT.Columns.Add("CveActivoFijo", GetType(Integer)) - TmpDT.Columns.Add("AFDepreciacion", GetType(Decimal)) - TmpDT.Columns.Add("AFValorInicial", GetType(Decimal)) - TmpDT.Columns.Add("NumTurnos", GetType(Decimal)) - TmpDT.Columns("NumTurnos").DefaultValue = 0D - TmpDT.Columns.Add("NumeroPedimento", GetType(String)) - TmpDT.Columns.Add("CodigoAlterno", GetType(String)) - TmpDT.Columns.Add("PSAlterno", GetType(String)) - TmpDT.Columns.Add("Costo", GetType(Decimal)) - TmpDT.Columns("Costo").DefaultValue = 0D - GvPS.DataSource = ObjVentas.DtResultados - GvPS.DataBind() + Else + TxtFechaOS.Text = NowADS().ToDateTime.ToString("yyyy-MM-dd HH:mm").Replace(" ", "T") + + If Request("CveOS") IsNot Nothing AndAlso IsNumeric(Request("CveOS")) AndAlso Request("CveOS").ToEntero() > 0 Then + ViewState("CveOS") = Request("CveOS") + CargaOS(CveOS) + Else + + 'SI ES VENTA NUEVA, NO RECARGAR TAB DE ALMACEN + If CveVenta <= 0 Then + 'REMOVER EVENTO PARA RECARGAR ALMACEN + HdnCargarInventario.Value = "False" + 'spanAlmacen.Attributes.Remove("onclick") + UpParametros.Update() + End If + + 'Modalidad Devoluciones y Refacturacion + If Request("CveDevolucion") IsNot Nothing AndAlso IsNumeric(Request("CveDevolucion")) AndAlso Request("CveDevolucion").ToEntero() > 0 Then + ViewState("CveDevolucion") = Request("CveDevolucion") + ViewState("CveVenta") = Request("CveDevolucion") + ViewState("NuevaFactura") = Request("NuevaFactura") + + trNCFactura.Visible = True + DdlNCFactura.DataSource = Nothing + DdlNCFactura.DataBind() + CargaNC(IfNull(Request("CveDevolucion"), "-1").ToString().ToEntero()) + DdlNCFactura.SelectedValueExist(CveDevolucion) + + If NuevaFactura = 0 Then + LbAgregar.Visible = False + If DdlTipoComprobante.SelectedValue = "Ing" Then + DdlTipoComprobante.Items.Insert(0, New ListItem("Devolucion", "Dev")) + DdlTipoComprobante.SelectedValue = "Dev" + ElseIf DdlTipoComprobante.SelectedValue = "Ant" Then + DdlTipoComprobante.SelectedValueExist("Egs") + End If + DdlTipoComprobante.Enabled = False + CargaFolios() + + DdlUsoCFDI.Enabled = True + DdlUsoCFDI.SelectedValueExist("2") + DdlMetodoPago33.Enabled = True + DdlMetodoPago33.SelectedValueExist("1") + DdlFormaPago33.Enabled = True + DdlFormaPago33.SelectedValueExist("20") End If - End Using - End If - 'Carga Venta - If Request("CveVenta") IsNot Nothing AndAlso IsNumeric(Request("CveVenta")) AndAlso Request("CveVenta").ToEntero() > 0 Then - ViewState("CveVenta") = Request("CveVenta") + If NuevaFactura = 1 Then + TrTipoRelacion.Visible = True + DdlTiposRelacion.SelectedValueExist("4") + + Dim ObjInv As New ClsInventarios + If ObjInv.GetInv_Mov(CveVenta, UsuarioActual.CveEmpresa) Then + If ObjInv.DtResultados.Rows.Count > 0 Then + TieneAlmacen = True + End If + End If + ObjInv.Dispose() + - If CargaVenta() Then - If UsuarioActual.TienePermisoProceso(321) Then - CargaRelacionadasPendientes() End If + 'regenrea el tipo de cambio + CargaNuevaFactura(Nothing) + CambiaMoneda() - DdlSubProyectoDatos.Enabled = False - BtnEmitirImprimir.Visible = False - BtnCrearApartirDe.Visible = True - If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then BtnCrearApartirDe.Visible = False + 'NOTA DE CREDITO + If NuevaFactura = 2 Then + DdlTipoComprobante.Items.Insert(0, New ListItem("Nota de Crédito", "Egs")) + DdlTipoComprobante.SelectedValue = "Egs" + DdlTipoComprobante.Enabled = False + CargaFolios() - If DdlTipoComprobante.SelectedValue = "Ped" Then - BtnPermisoEditarRemision.Text = "Editar Pedido" - BtnEditarRemision.Text = "Actualizar Pedido" - End If - - DivFechaAnticipoCliente.Visible = True - TxtFechaAnticipoCliente.Text = NowADS().ToShortDateString - - ImgAddObs.Visible = True - CargaEventoBitacora() - ConfiguraTipoDocto() - TrFolioFiscal.Visible = True - - 'PERMISO PARA CANCELAR PEDIDO - 'If GvInv.Rows.Count = 0 Then - ' If DdlTipoComprobante.SelectedValue.Contiene("Ped") And Not CveEstatus = 14 Then - ' If UsuarioActual.TienePermisoProceso(186) Then - ' LBCancelarPedido.Visible = True - ' End If - ' End If - 'End If - - 'CARGA GV DE COMERCIO EXTERIOR SI NO ESTA TIMBRADA - If LblSeTimbro.Text = "No" Then - CargaGvComercioExterior() - End If - - 'HABILITA IMPRESION DE FORMATO CICOVISA - If UsuarioActual.CveEmpresa = 72 And CveCliente = 70381 And DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem") Then - LnkImprimirFormatoCicovisa.Visible = True - End If - 'HABILITA IMPRESION DE FORMATO TELCEL - If UsuarioActual.CveEmpresa = 72 And CveCliente = 70869 And DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem") Then - LnkImprimirFormatoTelcel.Visible = True - End If - - If DdlTipoComprobante.SelectedValue = "Ing" Then - CargaVentaCortePorte(Me.CveVenta) - End If - - HlEvento.Visible = True - HlEvento.NavigateUrl = "/OI/PopUpAgenda.aspx?CveTipoEvento=2&CveVenta=" & CveVenta & "&TB_iframe=true&height=370&width=600;" - - ''SOLO SISTEMA DEBE VER ESTA OPCION - If UsuarioActual.CveUsuario = 100 Then - LnkCancelarSoloCFDI.Visible = True + DdlUsoCFDI.Enabled = True + DdlUsoCFDI.SelectedValueExist("2") + DdlMetodoPago33.Enabled = True + DdlMetodoPago33.SelectedValueExist("1") + DdlFormaPago33.Enabled = True + DdlFormaPago33.SelectedValueExist("20") + TrTipoRelacion.Visible = True + DdlTiposRelacion.SelectedValueExist("1") End If End If - Else - TxtFechaOS.Text = NowADS().ToDateTime.ToString("yyyy-MM-dd HH:mm").Replace(" ", "T") - - If Request("CveOS") IsNot Nothing AndAlso IsNumeric(Request("CveOS")) AndAlso Request("CveOS").ToEntero() > 0 Then - ViewState("CveOS") = Request("CveOS") - CargaOS(CveOS) - Else - - 'SI ES VENTA NUEVA, NO RECARGAR TAB DE ALMACEN - If CveVenta <= 0 Then - 'REMOVER EVENTO PARA RECARGAR ALMACEN - HdnCargarInventario.Value = "False" - 'spanAlmacen.Attributes.Remove("onclick") - UpParametros.Update() - End If - - 'Modalidad Devoluciones y Refacturacion - If Request("CveDevolucion") IsNot Nothing AndAlso IsNumeric(Request("CveDevolucion")) AndAlso Request("CveDevolucion").ToEntero() > 0 Then - ViewState("CveDevolucion") = Request("CveDevolucion") - ViewState("CveVenta") = Request("CveDevolucion") - ViewState("NuevaFactura") = Request("NuevaFactura") - - trNCFactura.Visible = True - DdlNCFactura.DataSource = Nothing - DdlNCFactura.DataBind() - CargaNC(IfNull(Request("CveDevolucion"), "-1").ToString().ToEntero()) - DdlNCFactura.SelectedValueExist(CveDevolucion) - - If NuevaFactura = 0 Then - LbAgregar.Visible = False - If DdlTipoComprobante.SelectedValue = "Ing" Then - DdlTipoComprobante.Items.Insert(0, New ListItem("Devolucion", "Dev")) - DdlTipoComprobante.SelectedValue = "Dev" - ElseIf DdlTipoComprobante.SelectedValue = "Ant" Then - DdlTipoComprobante.SelectedValueExist("Egs") - End If - DdlTipoComprobante.Enabled = False - CargaFolios() - - DdlUsoCFDI.Enabled = True - DdlUsoCFDI.SelectedValueExist("2") - DdlMetodoPago33.Enabled = True - DdlMetodoPago33.SelectedValueExist("1") - DdlFormaPago33.Enabled = True - DdlFormaPago33.SelectedValueExist("20") - - End If - - If NuevaFactura = 1 Then - TrTipoRelacion.Visible = True - DdlTiposRelacion.SelectedValueExist("4") - - Dim ObjInv As New ClsInventarios - If ObjInv.GetInv_Mov(CveVenta, UsuarioActual.CveEmpresa) Then - If ObjInv.DtResultados.Rows.Count > 0 Then - TieneAlmacen = True - End If - End If - ObjInv.Dispose() - - - End If - 'regenrea el tipo de cambio - CargaNuevaFactura(Nothing) - CambiaMoneda() - - 'NOTA DE CREDITO - If NuevaFactura = 2 Then - DdlTipoComprobante.Items.Insert(0, New ListItem("Nota de Crédito", "Egs")) - DdlTipoComprobante.SelectedValue = "Egs" - DdlTipoComprobante.Enabled = False - CargaFolios() - - DdlUsoCFDI.Enabled = True - DdlUsoCFDI.SelectedValueExist("2") - DdlMetodoPago33.Enabled = True - DdlMetodoPago33.SelectedValueExist("1") - DdlFormaPago33.Enabled = True - DdlFormaPago33.SelectedValueExist("20") - TrTipoRelacion.Visible = True - DdlTiposRelacion.SelectedValueExist("1") - End If - - End If - - 'ENTREGA POR ADELANTADO - If DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ped", "PeC") Then - If UsuarioActual.Empresa.Funcionalidad(145) = "1" Then - RequiereAlmacenDestino = True - - If DdlTipoComprobante.SelectedValue.Contiene("Ped", "PeC") Then - TrAlmacenAsignado.Visible = True - TrAlmacenOrigen.Visible = True - End If - - Dim CveAlmacenDestino As Integer = DtContratos.FiltroPrimeroValor("CveAlmacenDestino", $"CveContrato = {If(DdlContratosModal.Items.Count > 0, DdlContratosModal.SelectedValue, "0")}").ToEntero() - If CveAlmacenDestino > 0 Then - DdlAlmacenAsignado.Items.Clear() - DdlAlmacenAsignado.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoAlmacen:=-1).FiltraParametros($"CveSubProyecto = {DdlSubProyectoDatos.SelectedValue.ToEntero()} And CveTipoAlmacen In (4,10)") - DdlAlmacenAsignado.DataBind() - DdlAlmacenAsignado.Items.Insert(0, New ListItem(DtContratos.FiltroPrimeroValor("Almacen", $"CveContrato = {DdlContratosModal.SelectedValue}"), CveAlmacenDestino.ToString())) - DdlAlmacenAsignado.SelectedValue = CveAlmacenDestino.ToString() - Else - DdlAlmacenAsignado.Items.Clear() - DdlAlmacenAsignado.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoAlmacen:=-1).FiltraParametros($"CveSubProyecto = {DdlSubProyectoDatos.SelectedValue.ToEntero()} AND CveTipoAlmacen IN (10)") - DdlAlmacenAsignado.DataBind() - End If - UpParametros.Update() - Else - RequiereAlmacenDestino = False - TrAlmacenAsignado.Visible = False - TrAlmacenOrigen.Visible = False - End If - - 'ENVIO DE FACTURA - ChkEnviarFactura.Checked = False - ChkEnviarFactura.Visible = True - LblEnviarMail.Visible = True - - End If - - 'Modalidad Contrato - If Request("CveContrato") IsNot Nothing AndAlso IsNumeric(Request("CveContrato")) AndAlso Request("CveContrato").ToEntero() > 0 AndAlso Request("Tipo") IsNot Nothing AndAlso IsNumeric(Request("Tipo")) AndAlso Request("Tipo").Contiene("0", "1") Then + 'ENTREGA POR ADELANTADO + If DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ped", "PeC") Then + If UsuarioActual.Empresa.Funcionalidad(145) = "1" Then + RequiereAlmacenDestino = True If DdlTipoComprobante.SelectedValue.Contiene("Ped", "PeC") Then TrAlmacenAsignado.Visible = True TrAlmacenOrigen.Visible = True End If - UPCondicionesPago.Visible = False - RequiereAlmacenDestino = True - CveContrato = Request("CveContrato").ToEntero() - TipoContrato = Request("Tipo").ToEntero() - - 'DESACTIVA CAMBIO DE CLIENTE - HlCliente.Attributes.Remove("class") - HlCliente.Attributes.Add("class", "Texto disabled") - TxtCodigo.ReadOnly = True - - CargarContratoUrl() + Dim CveAlmacenDestino As Integer = DtContratos.FiltroPrimeroValor("CveAlmacenDestino", $"CveContrato = {If(DdlContratosModal.Items.Count > 0, DdlContratosModal.SelectedValue, "0")}").ToEntero() + If CveAlmacenDestino > 0 Then + DdlAlmacenAsignado.Items.Clear() + DdlAlmacenAsignado.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoAlmacen:=-1).FiltraParametros($"CveSubProyecto = {DdlSubProyectoDatos.SelectedValue.ToEntero()} And CveTipoAlmacen In (4,10)") + DdlAlmacenAsignado.DataBind() + DdlAlmacenAsignado.Items.Insert(0, New ListItem(DtContratos.FiltroPrimeroValor("Almacen", $"CveContrato = {DdlContratosModal.SelectedValue}"), CveAlmacenDestino.ToString())) + DdlAlmacenAsignado.SelectedValue = CveAlmacenDestino.ToString() + Else + DdlAlmacenAsignado.Items.Clear() + DdlAlmacenAsignado.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoAlmacen:=-1).FiltraParametros($"CveSubProyecto = {DdlSubProyectoDatos.SelectedValue.ToEntero()} AND CveTipoAlmacen IN (10)") + DdlAlmacenAsignado.DataBind() + End If UpParametros.Update() + Else + RequiereAlmacenDestino = False + TrAlmacenAsignado.Visible = False + TrAlmacenOrigen.Visible = False End If - 'Modalidad CveCicloComercial - If Request("CveCicloComercial") IsNot Nothing AndAlso IsNumeric(Request("CveCicloComercial")) AndAlso Request("CveCicloComercial").ToEntero() > 0 Then - ViewState("CveCicloComercial") = Request("CveCicloComercial").ToEntero() - CargaCicloComercialURL() - UpParametros.Update() - 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 - ViewState("CveVenta") = Request("DevPed") - ViewState("MovInv") = Request("MovInv") - ViewState("CveMovimientoDetalle") = IfNull(Request("CveMovimientoDetalle"), "-1").ToString().ToEntero() - DdlTipoComprobante.Items.Insert(5, New ListItem("Devolución de perdido", "DPe")) - DdlTipoComprobante.SelectedValue = "DPe" - DdlTipoComprobante.Enabled = False - CargaFacturaDevolucionPedido() - CargaFolios() - If CveContrato > 0 Then - CargaNotificacionContrato() - End If - End If - - 'Modalidad Cotizacion - If Opcion = "Cot" Then - DdlTipoComprobante.SelectedValueExist(Opcion) - DdlTipoComprobante.Enabled = False - - DdlTipoComprobante_SelectedIndexChanged(sender, Nothing) - 'Carga CvePresupuesto - If Request("CvePresupuesto") IsNot Nothing AndAlso IsNumeric(Request("CvePresupuesto")) AndAlso Request("CvePresupuesto").ToEntero() > 0 Then - CvePresupuesto = Request("CvePresupuesto").ToEntero() - 'DdlEstatus.Enabled = False - End If - - If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then - LnkAgregarCliente.Visible = True - ChkEnviarFactura.Checked = False - ChkEnviarFactura.Enabled = False - End If - - End If - CargaEstatusFactura(Opcion) - - If Opcion = "Ing" Then - ObtenerFechaVencimientoCER() - 'DdlEstatus.Enabled = False - If UsuarioActual.Empresa.TipoFacturacion = "CBB" Then - 'DdlEstatus.SelectedValue = "3" - CveEstatus = 3 - ElseIf UsuarioActual.Empresa.TipoFacturacion = "CFDi" Then - 'DdlEstatus.SelectedValue = "2" - CveEstatus = 2 - End If - End If - BtnAdjuntar.Visible = True - End If - End If - - 'CARGA PARA FACTURAR - ViewState("CveRemision") = IfNull(Request("CveRemision").ToEntero(), 0) - ViewState("CveCotizacion") = IfNull(Request("CveCotizacion").ToEntero(), 0) - - 'If ViewState("CveCotizacion").ToString().ToEntero() > 0 Then - ' EsCreaApartirDe = True - 'End If - - If ViewState("CveRemision").ToString().ToEntero() > 0 Or ViewState("CveCotizacion").ToString().ToEntero() > 0 Then - 'ViewState("CveRemision") = Request("CveRemision") - 'Dim CveRemision As Integer = ViewState("CveRemision").ToString().ToEntero() - - CargaVenta() - - 'DdlSucursal.Enabled = False - BtnCrearApartirDe.Visible = True - If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then - BtnCrearApartirDe.Visible = False - End If - 'DdlEstatus.Enabled = True - - ImgAddObs.Visible = True - CargaEventoBitacora() - - DdlTipoComprobante.Enabled = False - DdlTipoComprobante.SelectedValue = "Ing" - - CargaEstatusFactura() - 'DdlEstatus.SelectedValueExist("2") - - ConfiguraTipoDocto() - - - BtnEmitirImprimir.Text = "Facturar" - BtnEmitirImprimir.Visible = True - - UpnTools.Update() - - TxtFecha.Text = NowADS().ToShortDateString - - '' Si esta cancelado el compromiso no se puede editar el estatus - 'If DdlEstatus.SelectedValue = "9" Then - ' DdlEstatus.Enabled = False - 'End If - - 'CargaDetalle de Almacen - 'InventarioMov() - - If ViewState("CveCotizacion").ToString().ToEntero() > 0 Then - - CargaCotizaciones() - - If DtCotizaciones IsNot Nothing Then - For Each Row As DataRow In DtCotizaciones.Select($"CveVenta={ViewState("CveCotizacion").ToString().ToEntero()}") - Row("Aplicado") = True - Next - End If - - CargarCotizacionesAFacturar() - End If - - End If - - If Not ExFolioFactura Then SetPermisos() - If CveVenta < 1 Then CargaFolios() - - - If CveVenta <= 0 AndAlso UsuarioActual.Empresa.Funcionalidad(360) = "1" Then - CargaListasPrecios() - End If - - If CveVenta <= 0 AndAlso UsuarioActual.CveEmpresa.Contiene(7, 122) Then - TxtCantidad.Width = New Unit("100%") - DivNumTurnos.Visible = True - End If - - If CveVenta <= 0 AndAlso UsuarioActual.Empresa.Funcionalidad(716) = "1" Then - UpImagen.Visible = True - UpImagen.Update() - End If - - 'SELECCIONA VENDEDOR DEL USUARIO CUANDO SEA VENTA NUEVA Y SIN CLIENTE - 'If UsuarioActual.CveVendedor > 0 Then - ' If CveVenta = -1 AndAlso Not DdlVendedor.SelectedValue.ToEntero() > 0 Then DdlVendedor.SelectedValueExist(UsuarioActual.CveVendedor.ToString()) - ' If DdlVendedor.SelectedValue.ToEntero() > 0 AndAlso Not UsuarioActual.TienePermisoProceso(161) Then - ' DdlVendedor.Enabled = False - ' End If - ' 'multiples vendedores visible - ' If UsuarioActual.TienePermisoProceso(153) Then - ' DdlVendedor.Enabled = True - ' End If - 'End If - - If UsuarioActual.Empresa.Funcionalidad(301) = "1" Then - TxtFecha.Enabled = True - ImgFecha.Visible = True - Else - TxtFecha.Enabled = False - ImgFecha.Visible = False - CEFecha.Enabled = False - End If - - CargarCodigo() - InicializaImprimirNew() - - 'RegistraScript("FnSuma()") - TxtSubTotal.Attributes.Add("onKeyUp", "FnSuma()") - TxtIVA.Attributes.Add("onKeyUp", "FnSuma()") - TxtIEPS.Attributes.Add("onKeyUp", "FnSuma()") - TxtRetIVA.Attributes.Add("onKeyUp", "FnSuma()") - TxtRetISR.Attributes.Add("onKeyUp", "FnSuma()") - - 'Cortes de Caja - If UsuarioActual.TienePermisoProceso(160) Then - CargaCorteCaja() - End If - '********************************** - - 'Complementos de Timbrado - 'Dim ObjVenta As New ClsVentas - 'If ObjVenta.GetVentaComplementos() Then - ' RblComplementos.DataSource = ObjVenta.DtResultados - ' RblComplementos.DataBind() - ' UpComplementos.Update() - 'End If - 'ObjVenta.Dispose() - RblComplementos.DataSource = GlobalDTVtaComplementoCFDI - RblComplementos.DataBind() - - CargaFormatoSucursal() - - InicializaDevolucionAlmacen() - 'CargaOtrosConceptos() - CargaFacturaOC() - - 'SELECCIONA SUCURSAL DEL USUARIO CUANDO SEA VENTA NUEVA Y SIN CLIENTE - If Not (CveCliente > 0 Or CveVenta > 0) Then - DdlSubProyectoDatos.SelectedValueExist(UsuarioActual.CveSubProyecto) - DdlSubProyectoEjecucion.SelectedValueExist(UsuarioActual.CveSubProyecto) - DdlSubProyectoCobranza.SelectedValueExist(UsuarioActual.CveSubProyecto) - If UsuarioActual.TienePermisoProceso(152) Then - DdlSubProyectoDatos.Enabled = False - End If - CambiaSucursal() - UpParametros.Update() - UpDetalle.Update() - End If - - 'CUANDO SEA COTIZACION Y SEA COMPUPROVEEDORES (EMPRESA 72) NO DEBE ENVIAR CORREO AL CLIENTE - EnviarCorreoCliente = True - - If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso DdlTipoComprobante.SelectedValue = "Cot" Then - EnviarCorreoCliente = False - ChkEnviarFactura.Enabled = False - End If - - If UsuarioActual.CveEmpresa = 72 AndAlso DdlTipoComprobante.SelectedValue = "Cot" Then - ChkEnviarFactura.Checked = False - ChkEnviarFactura.Visible = False - LblEnviarMail.Visible = False - Else - If DdlTipoComprobante.SelectedValue.Contiene("Rem", "PeC", "PA", "Ped") Then 'ENVIO DE FACTURA ChkEnviarFactura.Checked = False ChkEnviarFactura.Visible = True LblEnviarMail.Visible = True - If CveVenta > 0 AndAlso EnviarCorreoCliente Then ChkEnviarFactura.Checked = EnviarCorreoCliente - Else - ChkEnviarFactura.Checked = EnviarCorreoCliente - ChkEnviarFactura.Visible = True - LblEnviarMail.Visible = True End If - End If + 'Modalidad Contrato + If Request("CveContrato") IsNot Nothing AndAlso IsNumeric(Request("CveContrato")) AndAlso Request("CveContrato").ToEntero() > 0 AndAlso Request("Tipo") IsNot Nothing AndAlso IsNumeric(Request("Tipo")) AndAlso Request("Tipo").Contiene("0", "1") Then - CargarCentrosDeCosto(DdlProyecto, DdlSubProyecto, LblProyectoHeader, LblSubProyecto, AplicaTodos:="") - DdlSubProyecto.SelectedValueExist(DdlSubProyectoDatos.SelectedValue) - BrSubProyecto.Visible = DdlProyecto.Visible - - If UsuarioActual.CveEmpresa.Contiene(172, 173) Then - LnkAddVenta.Visible = True - End If - - 'MOSTRAR LA OPCION DE AGREGAR PS EN BDH - If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso CveVenta <= 0 Then - ImgOtrosConceptos.Visible = False - TrFormaEntrega.Visible = False - TabDetalleVentas.Visible = False - 'TabE.Visible = False - LnkOCs.Visible = False - GvPS.Columns(ColumnaSubProyecto).Visible = False - DdlSubProyecto.Visible = False - TrEdit.Visible = True - - ThProyecto.Visible = False - For Each Gvr As GridViewRow In GvPS.Rows - Gvr.FCLinkButton("imgE").Visible = False - Next - LnkAddVenta.Visible = True - End If - - If UsuarioActual.Empresa.CvePlataforma = 2 Then - ImgOtrosConceptos.Visible = False - TrFormaEntrega.Visible = False - TabDetalleVentas.Visible = False - TabE.Visible = False - LnkOCs.Visible = False - GvPS.Columns(8).Visible = False - DdlSubProyecto.Visible = False - TrEdit.Visible = False - - ThProyecto.Visible = False - For Each Gvr As GridViewRow In GvPS.Rows - Gvr.FCLinkButton("imgE").Visible = False - Next - LnkAddVenta.Visible = True - End If - - TabVentaAF.Visible = (UsuarioActual.CveRol = 1) - DivAgregarAF.Visible = (CveVenta <= 0 AndAlso UsuarioActual.CveRol = 1) - - If DivAgregarAF.Visible Then - CargaDatosAF() - End If - - 'CARGA VALORES INICIALES PARA AGREGAR PS DESDE MODAL - 'CargaMetodosPSModal() - - 'CARGA VALORES DE ORDEN DE PRODUCCION - Dim CveOrdenProduccion As Integer = IfNull(Request("CveOrdenProduccion"), "-1").ToString().ToEntero() - If CveOrdenProduccion > 0 And Not CveVenta > 0 Then - DdlOrdenProduccion.SelectedValueExist(CveOrdenProduccion) - If DdlOrdenProduccion.SelectedValue.ToEntero() > 0 Then - DdlTipoComprobante.SelectedValue = "Rem" - DdlMoneda.SelectedValue = "2" - Dim ObjCGame As New ClsCGame - If ObjCGame.GetAvance(DdlOrdenProduccion.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa) Then - For Each dt As DataRow In ObjCGame.DtResultados.Rows - If dt("Avance").ToString().ToEntero() > 0 Then - AgregarProductoServicio(dt("Avance").ToString().ToDecimal, 29472, "No Aplica", 19588, "Ingresos por comercializadora", 308366, "Ventas", dt("Datos").ToString(), dt("PU").ToString().ToDecimal, 0, - DdlProyecto.SelectedValue.ToEntero(), DdlProyecto.SelectedItem.Text, DdlSubProyecto.SelectedValue.ToEntero(), DdlSubProyecto.SelectedItem.Text) - 'AddPS(dt("Avance").ToString().ToDouble, 29472, "No Aplica", 19588, "Ingresos por comercializadora", 308366, "Ventas", dt("Datos").ToString(), dt("PU").ToString().ToDouble, 0, 0, 0, 1, 0, True, - ' "", DdlProyecto.SelectedValue.ToEntero(), DdlProyecto.SelectedItem.Text, DdlSubProyecto.SelectedValue.ToEntero(), DdlSubProyecto.SelectedItem.Text, 2, HdnTipoInv.Value.ToEntero()) - End If - Next - GvPS.DataSource = TmpDT + If DdlTipoComprobante.SelectedValue.Contiene("Ped", "PeC") Then + TrAlmacenAsignado.Visible = True + TrAlmacenOrigen.Visible = True End If - If ObjCGame.GetFlete(UsuarioActual.CveEmpresa) Then - TxtObsFact.Text = String.Format("Chofer: {0}; Remolque: {1}; Scat: {2};", ObjCGame.DtResultados.FiltraParametros(String.Format("CveOrdenProduccion = {0}", CveOrdenProduccion))(0)("Chofer"), ObjCGame.DtResultados.FiltraParametros(String.Format("CveOrdenProduccion = {0}", CveOrdenProduccion))(0)("CodigoDescripcionRemolque"), ObjCGame.DtResultados.FiltraParametros(String.Format("CveOrdenProduccion = {0}", CveOrdenProduccion))(0)("Scat")) - End If - ObjCGame.Dispose() - GvPS.DataBind() - UPObservaciones.Update() - UpPS.Update() + + UPCondicionesPago.Visible = False + RequiereAlmacenDestino = True + CveContrato = Request("CveContrato").ToEntero() + TipoContrato = Request("Tipo").ToEntero() + + 'DESACTIVA CAMBIO DE CLIENTE + HlCliente.Attributes.Remove("class") + HlCliente.Attributes.Add("class", "Texto disabled") + TxtCodigo.ReadOnly = True + + CargarContratoUrl() + UpParametros.Update() + End If + + 'Modalidad CveCicloComercial + If Request("CveCicloComercial") IsNot Nothing AndAlso IsNumeric(Request("CveCicloComercial")) AndAlso Request("CveCicloComercial").ToEntero() > 0 Then + ViewState("CveCicloComercial") = Request("CveCicloComercial").ToEntero() + CargaCicloComercialURL() + UpParametros.Update() + 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 + ViewState("CveVenta") = Request("DevPed") + ViewState("MovInv") = Request("MovInv") + ViewState("CveMovimientoDetalle") = IfNull(Request("CveMovimientoDetalle"), "-1").ToString().ToEntero() + DdlTipoComprobante.Items.Insert(5, New ListItem("Devolución de perdido", "DPe")) + DdlTipoComprobante.SelectedValue = "DPe" + DdlTipoComprobante.Enabled = False + CargaFacturaDevolucionPedido() CargaFolios() - End If - End If - - - If Request("CveVenta") IsNot Nothing AndAlso IsNumeric(Request("CveVenta")) AndAlso Request("CveVenta").ToEntero() = -1 AndAlso UsuarioActual.CveTipoDocumento.Length = 3 Then - CargaDdlSubProyectos() - UpParametros.Update() - DdlTipoComprobante.SelectedValueExist(UsuarioActual.CveTipoDocumento) - CambiaTipoDocto() - LimpiaEscondeContado() - End If - - InicializaAplicarNC() - - 'If CveCliente > 0 Then - ' CargaRestriccionesCreditoCliente(CveVenta:=Me.CveVenta) - 'End If - - If Not CveVenta > 0 AndAlso UsuarioActual.Empresa.Funcionalidad(403).ToString() = "1" Then - If (DdlTipoComprobante.Items.FindByValue("Ing") IsNot Nothing) Then - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing")) - End If - End If - - - 'rmf.2020.09.30, codigo de prueba - If UsuarioActual.CveEmpresa = 1 Then - DivMesesSinIntereses.Visible = True - DivDdlCuentaTarjetaCredito.Attributes.Add("class", "col-md-4") - DivContadoOtros.Visible = True - End If - - If UsuarioActual.Empresa.Funcionalidad(558).ToEntero() = 1 Then - - DivMesesSinIntereses.Visible = True - DivDdlCuentaTarjetaCredito.Attributes.Add("class", "col-md-4") - DivContadoOtros.Visible = True - TrKilometraje.Visible = True - TrPedido.Visible = False - ' TrKilometrajeTxt.Visible = True - End If - LtlTareaNueva.Text = String.Format(" Tarea", CveVenta) - - 'SI ESTA CARGANDO UNA REFACTURACION. VALIDAR QUE LA FACTURA ANTERIOR ESTE CANCELADA - If Me.ObjFacturaNC IsNot Nothing Then - - If Me.CveDevolucion > 0 AndAlso Me.NuevaFactura = 1 Then - Dim TipoEstatus As Integer = GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.ObjFacturaNC.CveEstatusFactura}").ToEntero() - If TipoEstatus <> 5 Then - 'ESTATUS DE CANCELACION PENDIENTE - If Not Me.ObjFacturaNC.CveEstatusFactura = 23 Then - Alert($"El documento de tipo '{Me.ObjFacturaNC.TipodeComprobante}' a refacturar no ha sido marcado como 'Cancelación pendiente'. Favor de verificar el documento", TipoMensaje.MsgAdvertencia) - BtnEmitirImprimir.Visible = False - UpFacturar.Update() - End If - End If - End If - End If - - 'VALIDA ESTATUS CLIENTE - SOLO SE PUEDE USAR EL CLIENTE PARA COTIZAR EN CASO DE ESTAR INACTIVO - If Not CveVenta > 0 AndAlso Not BtnEmitirImprimir.Visible AndAlso Request("Op") IsNot Nothing AndAlso Request("Op").ToString() <> "" Then - If DdlTipoComprobante.SelectedValue.Contiene("Cot") Then - BtnEmitirImprimir.Visible = True - TrVistaPrevia.Visible = True - End If - End If - - If Request("CveCotizacion") IsNot Nothing AndAlso IfNull(Request("CveCotizacion"), 0).ToString().ToEntero() > 0 Then - If UsuarioActual.Empresa.Funcionalidad(135).Contiene("1", "2") Then - 'VERIFICA SI NO ESTA AUTORIZADA - If CveEstatusCotizacion <> 8 Then - BtnEmitirImprimir.Enabled = False - BtnEmitirImprimir.Visible = False - Alert("La cotización no esta autorizada", TipoMensaje.MsgAdvertencia) + If CveContrato > 0 Then + CargaNotificacionContrato() End If End If - End If + 'Modalidad Cotizacion + If Opcion = "Cot" Then + DdlTipoComprobante.SelectedValueExist(Opcion) + DdlTipoComprobante.Enabled = False - 'QUITAR ESTAS OPCIONES SI LA FACTURA VA SER CANCELADA O ESTA CANCELADA - If CveEstatus.Contiene(4, 5, 12, 13, 20, 23) Then - LBNotaCredito.Visible = False - LnkAplicarRNCDevolucion.Visible = False - HLPagar.Visible = False - HLSaldarVenta.Visible = False - LnkFacturasRelacionadas.Visible = False - End If + DdlTipoComprobante_SelectedIndexChanged(sender, Nothing) + 'Carga CvePresupuesto + If Request("CvePresupuesto") IsNot Nothing AndAlso IsNumeric(Request("CvePresupuesto")) AndAlso Request("CvePresupuesto").ToEntero() > 0 Then + CvePresupuesto = Request("CvePresupuesto").ToEntero() + 'DdlEstatus.Enabled = False + End If + + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + LnkAgregarCliente.Visible = True + ChkEnviarFactura.Checked = False + ChkEnviarFactura.Enabled = False + End If - ''EN REALIDAD SE OCUPAN ESTAS COSAS DENTRO DEL POSTABCK ??? - If Not CveVenta > 0 Then - 'LbDescargarExcel.Visible = True - If DdlTipoComprobante.SelectedValue = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(382) = "1" Then - HLCargaCotizaciones.Visible = True - HlAgregarExcel.Visible = False - Else - HLCargaCotizaciones.Visible = False - HlAgregarExcel.Visible = True End If - End If + CargaEstatusFactura(Opcion) - If DdlTipoComprobante.SelectedValue.Contiene("Rem") AndAlso UsuarioActual.Empresa.Funcionalidad(109) <> "1" Then - ' IPP 15 Julio 2017 - ERA FALSE + If Opcion = "Ing" Then + ObtenerFechaVencimientoCER() + 'DdlEstatus.Enabled = False + If UsuarioActual.Empresa.TipoFacturacion = "CBB" Then + 'DdlEstatus.SelectedValue = "3" + CveEstatus = 3 + ElseIf UsuarioActual.Empresa.TipoFacturacion = "CFDi" Then + 'DdlEstatus.SelectedValue = "2" + CveEstatus = 2 + End If + End If + BtnAdjuntar.Visible = True + End If + End If + + 'CARGA PARA FACTURAR + ViewState("CveRemision") = IfNull(Request("CveRemision").ToEntero(), 0) + ViewState("CveCotizacion") = IfNull(Request("CveCotizacion").ToEntero(), 0) + + 'If ViewState("CveCotizacion").ToString().ToEntero() > 0 Then + ' EsCreaApartirDe = True + 'End If + + If ViewState("CveRemision").ToString().ToEntero() > 0 Or ViewState("CveCotizacion").ToString().ToEntero() > 0 Then + 'ViewState("CveRemision") = Request("CveRemision") + 'Dim CveRemision As Integer = ViewState("CveRemision").ToString().ToEntero() + + CargaVenta() + + 'DdlSucursal.Enabled = False + BtnCrearApartirDe.Visible = True + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + BtnCrearApartirDe.Visible = False + End If + 'DdlEstatus.Enabled = True + + ImgAddObs.Visible = True + CargaEventoBitacora() + + DdlTipoComprobante.Enabled = False + DdlTipoComprobante.SelectedValue = "Ing" + + CargaEstatusFactura() + 'DdlEstatus.SelectedValueExist("2") + If UsuarioActual.Empresa.CveEmpresa = 189 Then ImgAntiPend.Visible = False - UpPS.Update() End If + ConfiguraTipoDocto() - If UsuarioActual.Empresa.Funcionalidad(517) <> "" Then - TxtFolio.Enabled = False - TxtFecha.Enabled = False - If LblSeTimbro.Text = "No" And DdlTipoComprobante.SelectedValue.Contiene("Ing", "Egs", "Dev", "Ant") Then - TxtFecha.Text = NowADS().ToShortDateString - End If - ImgFecha.Visible = False - End If - BloqueaCondicionesPago() + BtnEmitirImprimir.Text = "Facturar" + BtnEmitirImprimir.Visible = True - BloqueaClasificaciones() + UpnTools.Update() - 'NO PERMITIR AGREGAR PS DESDE VENTAS EN ECONOLLANTAS - If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then - BtnModalAddPS.Enabled = False - End If + TxtFecha.Text = NowADS().ToShortDateString - MostrarOpcionesPaqueteria() - - 'If ViewState("CveCotizacion").ToString().ToEntero() > 0 Then - - 'If Not AjustarTotalCotizacionFacturada(ViewState("CveCotizacion").ToString().ToEntero(), TxtTotal.Text.ToDecimal) Then - ' BtnEmitirImprimir.Visible = True - ' Alert("Ocurrió un error al ajustar el importe", TipoMensaje.MsgError) + '' Si esta cancelado el compromiso no se puede editar el estatus + 'If DdlEstatus.SelectedValue = "9" Then + ' DdlEstatus.Enabled = False 'End If - 'End If + 'CargaDetalle de Almacen + 'InventarioMov() - If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then - trRotacion.Visible = True - trRotacionlbl.Visible = True - trAlineacion.Visible = True - trAlineacionlbl.Visible = True + If ViewState("CveCotizacion").ToString().ToEntero() > 0 Then - Dim FechaRotaAlinea As Date = TxtFecha.Text.ToDate - LblRotacion.Text = FechaRotaAlinea.AddMonths(6).ToShortDateString - LblAlineacion.Text = FechaRotaAlinea.AddMonths(6).ToShortDateString + CargaCotizaciones() - If Me.CveVenta > 0 AndAlso DdlTipoComprobante.SelectedValue = "Cot" Then - HplDownPDF.Visible = False + If DtCotizaciones IsNot Nothing Then + For Each Row As DataRow In DtCotizaciones.Select($"CveVenta={ViewState("CveCotizacion").ToString().ToEntero()}") + Row("Aplicado") = True + Next End If - DdlPS.Attributes.Remove("data-cvesubproyecto") - DdlPS.Attributes.Add("data-cvesubproyecto", DdlSubProyectoDatos.SelectedValue) - - UpPS.Update() - UPObservaciones.Update() - End If - - If UsuarioActual.Empresa.Funcionalidad(163) = "1" Then - TrDescripcionVenta.Visible = True - If CveVenta <= 0 Then - TxtDescripcionVenta.Enabled = True - End If - End If - - If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then - If CveVenta <= 0 Then - EsVentaMedica = True - CargaTiposVenta() - If CveCliente > 0 Then - SeleccionarClienteSucursal(CveCliente:=CveCliente) - End If - End If - If CveVenta >= 0 Then - HLFAgregarOS.Visible = True - HLFAgregarOS.NavigateUrl = $"/OS/OrdenesServicios.aspx?CveVenta={CveVenta}" - End If - - TxtPrecio.Enabled = False - If UsuarioActual.CveUsuario = 3986 Then - TxtPrecio.Enabled = True - End If - 'ocultar la columna de subproyecto - GvPS.Columns(ColumnaSubProyecto).Visible = False - ThProyecto.Visible = False - ThProyecto2.Visible = False - - TxtCantidad.Text = "1" - TxtCantidad.Focus() - End If - - If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then - LnkAgregarCliente.Visible = True - 'ocultar la columna de subproyecto - GvPS.Columns(ColumnaSubProyecto).Visible = False - ThProyecto.Visible = False - ThProyecto2.Visible = False - TrDescripcionVenta.Visible = False - - If CveVenta <= 0 Then - TxtCantidad.Text = "1" - TxtCantidad.Focus() - RegistraScript("abrirDdlPS();", "A1") - End If - UpPS.Update() - + CargarCotizacionesAFacturar() End If End If + If Not ExFolioFactura Then SetPermisos() + If CveVenta < 1 Then CargaFolios() + + + If CveVenta <= 0 AndAlso UsuarioActual.Empresa.Funcionalidad(360) = "1" Then + CargaListasPrecios() + End If + + If CveVenta <= 0 AndAlso UsuarioActual.CveEmpresa.Contiene(7, 122) Then + TxtCantidad.Width = New Unit("100%") + DivNumTurnos.Visible = True + End If + + If CveVenta <= 0 AndAlso UsuarioActual.Empresa.Funcionalidad(716) = "1" Then + UpImagen.Visible = True + UpImagen.Update() + End If + + 'SELECCIONA VENDEDOR DEL USUARIO CUANDO SEA VENTA NUEVA Y SIN CLIENTE + 'If UsuarioActual.CveVendedor > 0 Then + ' If CveVenta = -1 AndAlso Not DdlVendedor.SelectedValue.ToEntero() > 0 Then DdlVendedor.SelectedValueExist(UsuarioActual.CveVendedor.ToString()) + ' If DdlVendedor.SelectedValue.ToEntero() > 0 AndAlso Not UsuarioActual.TienePermisoProceso(161) Then + ' DdlVendedor.Enabled = False + ' End If + ' 'multiples vendedores visible + ' If UsuarioActual.TienePermisoProceso(153) Then + ' DdlVendedor.Enabled = True + ' End If + 'End If + + If UsuarioActual.Empresa.Funcionalidad(301) = "1" Then + TxtFecha.Enabled = True + ImgFecha.Visible = True + Else + TxtFecha.Enabled = False + ImgFecha.Visible = False + CEFecha.Enabled = False + End If + + CargarCodigo() + InicializaImprimirNew() + + 'RegistraScript("FnSuma()") + TxtSubTotal.Attributes.Add("onKeyUp", "FnSuma()") + TxtIVA.Attributes.Add("onKeyUp", "FnSuma()") + TxtIEPS.Attributes.Add("onKeyUp", "FnSuma()") + TxtRetIVA.Attributes.Add("onKeyUp", "FnSuma()") + TxtRetISR.Attributes.Add("onKeyUp", "FnSuma()") + + 'Cortes de Caja + If UsuarioActual.TienePermisoProceso(160) Then + CargaCorteCaja() + End If + '********************************** + + 'Complementos de Timbrado + 'Dim ObjVenta As New ClsVentas + 'If ObjVenta.GetVentaComplementos() Then + ' RblComplementos.DataSource = ObjVenta.DtResultados + ' RblComplementos.DataBind() + ' UpComplementos.Update() + 'End If + 'ObjVenta.Dispose() + RblComplementos.DataSource = GlobalDTVtaComplementoCFDI + RblComplementos.DataBind() + + CargaFormatoSucursal() + + InicializaDevolucionAlmacen() + 'CargaOtrosConceptos() + CargaFacturaOC() + + 'SELECCIONA SUCURSAL DEL USUARIO CUANDO SEA VENTA NUEVA Y SIN CLIENTE + If Not (CveCliente > 0 Or CveVenta > 0) Then + DdlSubProyectoDatos.SelectedValueExist(UsuarioActual.CveSubProyecto) + DdlSubProyectoEjecucion.SelectedValueExist(UsuarioActual.CveSubProyecto) + DdlSubProyectoCobranza.SelectedValueExist(UsuarioActual.CveSubProyecto) + If UsuarioActual.TienePermisoProceso(152) Then + DdlSubProyectoDatos.Enabled = False + End If + CambiaSucursal() + UpParametros.Update() + UpDetalle.Update() + End If + + 'CUANDO SEA COTIZACION Y SEA COMPUPROVEEDORES (EMPRESA 72) NO DEBE ENVIAR CORREO AL CLIENTE + EnviarCorreoCliente = True + + If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso DdlTipoComprobante.SelectedValue = "Cot" Then + EnviarCorreoCliente = False + ChkEnviarFactura.Enabled = False + End If + + If UsuarioActual.CveEmpresa = 72 AndAlso DdlTipoComprobante.SelectedValue = "Cot" Then + ChkEnviarFactura.Checked = False + ChkEnviarFactura.Visible = False + LblEnviarMail.Visible = False + Else + If DdlTipoComprobante.SelectedValue.Contiene("Rem", "PeC", "PA", "Ped") Then + 'ENVIO DE FACTURA + ChkEnviarFactura.Checked = False + ChkEnviarFactura.Visible = True + LblEnviarMail.Visible = True + + If CveVenta > 0 AndAlso EnviarCorreoCliente Then ChkEnviarFactura.Checked = EnviarCorreoCliente + Else + ChkEnviarFactura.Checked = EnviarCorreoCliente + ChkEnviarFactura.Visible = True + LblEnviarMail.Visible = True + End If + + End If + + CargarCentrosDeCosto(DdlProyecto, DdlSubProyecto, LblProyectoHeader, LblSubProyecto, AplicaTodos:="") + DdlSubProyecto.SelectedValueExist(DdlSubProyectoDatos.SelectedValue) + BrSubProyecto.Visible = DdlProyecto.Visible + + If UsuarioActual.CveEmpresa.Contiene(172, 173) Then + LnkAddVenta.Visible = True + End If + + 'MOSTRAR LA OPCION DE AGREGAR PS EN BDH + If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso CveVenta <= 0 Then + ImgOtrosConceptos.Visible = False + TrFormaEntrega.Visible = False + TabDetalleVentas.Visible = False + 'TabE.Visible = False + LnkOCs.Visible = False + GvPS.Columns(ColumnaSubProyecto).Visible = False + DdlSubProyecto.Visible = False + TrEdit.Visible = True + + ThProyecto.Visible = False + For Each Gvr As GridViewRow In GvPS.Rows + Gvr.FCLinkButton("imgE").Visible = False + Next + LnkAddVenta.Visible = True + End If + + If UsuarioActual.Empresa.CvePlataforma = 2 Then + ImgOtrosConceptos.Visible = False + TrFormaEntrega.Visible = False + TabDetalleVentas.Visible = False + TabE.Visible = False + LnkOCs.Visible = False + GvPS.Columns(8).Visible = False + DdlSubProyecto.Visible = False + TrEdit.Visible = False + + ThProyecto.Visible = False + For Each Gvr As GridViewRow In GvPS.Rows + Gvr.FCLinkButton("imgE").Visible = False + Next + LnkAddVenta.Visible = True + End If + + TabVentaAF.Visible = (UsuarioActual.CveRol = 1) + DivAgregarAF.Visible = (CveVenta <= 0 AndAlso UsuarioActual.CveRol = 1) + + If DivAgregarAF.Visible Then + CargaDatosAF() + End If + + 'CARGA VALORES INICIALES PARA AGREGAR PS DESDE MODAL + 'CargaMetodosPSModal() + + 'CARGA VALORES DE ORDEN DE PRODUCCION + Dim CveOrdenProduccion As Integer = IfNull(Request("CveOrdenProduccion"), "-1").ToString().ToEntero() + If CveOrdenProduccion > 0 And Not CveVenta > 0 Then + DdlOrdenProduccion.SelectedValueExist(CveOrdenProduccion) + If DdlOrdenProduccion.SelectedValue.ToEntero() > 0 Then + DdlTipoComprobante.SelectedValue = "Rem" + DdlMoneda.SelectedValue = "2" + Dim ObjCGame As New ClsCGame + If ObjCGame.GetAvance(DdlOrdenProduccion.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa) Then + For Each dt As DataRow In ObjCGame.DtResultados.Rows + If dt("Avance").ToString().ToEntero() > 0 Then + AgregarProductoServicio(dt("Avance").ToString().ToDecimal, 29472, "No Aplica", 19588, "Ingresos por comercializadora", 308366, "Ventas", dt("Datos").ToString(), dt("PU").ToString().ToDecimal, 0, + DdlProyecto.SelectedValue.ToEntero(), DdlProyecto.SelectedItem.Text, DdlSubProyecto.SelectedValue.ToEntero(), DdlSubProyecto.SelectedItem.Text) + 'AddPS(dt("Avance").ToString().ToDouble, 29472, "No Aplica", 19588, "Ingresos por comercializadora", 308366, "Ventas", dt("Datos").ToString(), dt("PU").ToString().ToDouble, 0, 0, 0, 1, 0, True, + ' "", DdlProyecto.SelectedValue.ToEntero(), DdlProyecto.SelectedItem.Text, DdlSubProyecto.SelectedValue.ToEntero(), DdlSubProyecto.SelectedItem.Text, 2, HdnTipoInv.Value.ToEntero()) + End If + Next + GvPS.DataSource = TmpDT + End If + If ObjCGame.GetFlete(UsuarioActual.CveEmpresa) Then + TxtObsFact.Text = String.Format("Chofer: {0}; Remolque: {1}; Scat: {2};", ObjCGame.DtResultados.FiltraParametros(String.Format("CveOrdenProduccion = {0}", CveOrdenProduccion))(0)("Chofer"), ObjCGame.DtResultados.FiltraParametros(String.Format("CveOrdenProduccion = {0}", CveOrdenProduccion))(0)("CodigoDescripcionRemolque"), ObjCGame.DtResultados.FiltraParametros(String.Format("CveOrdenProduccion = {0}", CveOrdenProduccion))(0)("Scat")) + End If + ObjCGame.Dispose() + GvPS.DataBind() + UPObservaciones.Update() + UpPS.Update() + CargaFolios() + End If + End If + + + If Request("CveVenta") IsNot Nothing AndAlso IsNumeric(Request("CveVenta")) AndAlso Request("CveVenta").ToEntero() = -1 AndAlso UsuarioActual.CveTipoDocumento.Length = 3 Then + CargaDdlSubProyectos() + UpParametros.Update() + DdlTipoComprobante.SelectedValueExist(UsuarioActual.CveTipoDocumento) + CambiaTipoDocto() + LimpiaEscondeContado() + End If + + InicializaAplicarNC() + + 'If CveCliente > 0 Then + ' CargaRestriccionesCreditoCliente(CveVenta:=Me.CveVenta) + 'End If + + If Not CveVenta > 0 AndAlso UsuarioActual.Empresa.Funcionalidad(403).ToString() = "1" Then + If (DdlTipoComprobante.Items.FindByValue("Ing") IsNot Nothing) Then + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing")) + End If + End If + + + 'rmf.2020.09.30, codigo de prueba + If UsuarioActual.CveEmpresa = 1 Then + DivMesesSinIntereses.Visible = True + DivDdlCuentaTarjetaCredito.Attributes.Add("class", "col-md-4") + DivContadoOtros.Visible = True + End If + + If UsuarioActual.Empresa.Funcionalidad(558).ToEntero() = 1 Then + + DivMesesSinIntereses.Visible = True + DivDdlCuentaTarjetaCredito.Attributes.Add("class", "col-md-4") + DivContadoOtros.Visible = True + TrKilometraje.Visible = True + TrPedido.Visible = False + ' TrKilometrajeTxt.Visible = True + End If + LtlTareaNueva.Text = String.Format(" Tarea", CveVenta) + + 'SI ESTA CARGANDO UNA REFACTURACION. VALIDAR QUE LA FACTURA ANTERIOR ESTE CANCELADA + If Me.ObjFacturaNC IsNot Nothing Then + + If Me.CveDevolucion > 0 AndAlso Me.NuevaFactura = 1 Then + Dim TipoEstatus As Integer = GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.ObjFacturaNC.CveEstatusFactura}").ToEntero() + If TipoEstatus <> 5 Then + 'ESTATUS DE CANCELACION PENDIENTE + If Not Me.ObjFacturaNC.CveEstatusFactura = 23 Then + Alert($"El documento de tipo '{Me.ObjFacturaNC.TipodeComprobante}' a refacturar no ha sido marcado como 'Cancelación pendiente'. Favor de verificar el documento", TipoMensaje.MsgAdvertencia) + BtnEmitirImprimir.Visible = False + UpFacturar.Update() + End If + End If + End If + End If + + 'VALIDA ESTATUS CLIENTE - SOLO SE PUEDE USAR EL CLIENTE PARA COTIZAR EN CASO DE ESTAR INACTIVO + If Not CveVenta > 0 AndAlso Not BtnEmitirImprimir.Visible AndAlso Request("Op") IsNot Nothing AndAlso Request("Op").ToString() <> "" Then + If DdlTipoComprobante.SelectedValue.Contiene("Cot") Then + BtnEmitirImprimir.Visible = True + TrVistaPrevia.Visible = True + End If + End If + + If Request("CveCotizacion") IsNot Nothing AndAlso IfNull(Request("CveCotizacion"), 0).ToString().ToEntero() > 0 Then + If UsuarioActual.Empresa.Funcionalidad(135).Contiene("1", "2") Then + 'VERIFICA SI NO ESTA AUTORIZADA + If CveEstatusCotizacion <> 8 Then + BtnEmitirImprimir.Enabled = False + BtnEmitirImprimir.Visible = False + Alert("La cotización no esta autorizada", TipoMensaje.MsgAdvertencia) + End If + End If + + End If + + 'QUITAR ESTAS OPCIONES SI LA FACTURA VA SER CANCELADA O ESTA CANCELADA + If CveEstatus.Contiene(4, 5, 12, 13, 20, 23) Then + LBNotaCredito.Visible = False + LnkAplicarRNCDevolucion.Visible = False + HLPagar.Visible = False + HLSaldarVenta.Visible = False + LnkFacturasRelacionadas.Visible = False + End If + + ''EN REALIDAD SE OCUPAN ESTAS COSAS DENTRO DEL POSTABCK ??? + If Not CveVenta > 0 Then + 'LbDescargarExcel.Visible = True + If DdlTipoComprobante.SelectedValue = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(382) = "1" Then + HLCargaCotizaciones.Visible = True + HlAgregarExcel.Visible = False + Else + HLCargaCotizaciones.Visible = False + HlAgregarExcel.Visible = True + End If + End If + + If DdlTipoComprobante.SelectedValue.Contiene("Rem") AndAlso UsuarioActual.Empresa.Funcionalidad(109) <> "1" Then + ' IPP 15 Julio 2017 - ERA FALSE + ImgAntiPend.Visible = False + UpPS.Update() + End If + + If UsuarioActual.Empresa.Funcionalidad(517) <> "" Then + TxtFolio.Enabled = False + TxtFecha.Enabled = False + If LblSeTimbro.Text = "No" And DdlTipoComprobante.SelectedValue.Contiene("Ing", "Egs", "Dev", "Ant") Then + TxtFecha.Text = NowADS().ToShortDateString + End If + ImgFecha.Visible = False + End If + + BloqueaCondicionesPago() + + BloqueaClasificaciones() + + 'NO PERMITIR AGREGAR PS DESDE VENTAS EN ECONOLLANTAS + If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then + BtnModalAddPS.Enabled = False + End If + + MostrarOpcionesPaqueteria() + + 'If ViewState("CveCotizacion").ToString().ToEntero() > 0 Then + + 'If Not AjustarTotalCotizacionFacturada(ViewState("CveCotizacion").ToString().ToEntero(), TxtTotal.Text.ToDecimal) Then + ' BtnEmitirImprimir.Visible = True + ' Alert("Ocurrió un error al ajustar el importe", TipoMensaje.MsgError) + 'End If + + 'End If + + If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then + trRotacion.Visible = True + trRotacionlbl.Visible = True + trAlineacion.Visible = True + trAlineacionlbl.Visible = True + + Dim FechaRotaAlinea As Date = TxtFecha.Text.ToDate + LblRotacion.Text = FechaRotaAlinea.AddMonths(6).ToShortDateString + LblAlineacion.Text = FechaRotaAlinea.AddMonths(6).ToShortDateString + + If Me.CveVenta > 0 AndAlso DdlTipoComprobante.SelectedValue = "Cot" Then + HplDownPDF.Visible = False + End If + + DdlPS.Attributes.Remove("data-cvesubproyecto") + DdlPS.Attributes.Add("data-cvesubproyecto", DdlSubProyectoDatos.SelectedValue) + + UpPS.Update() + UPObservaciones.Update() + End If + + If UsuarioActual.Empresa.Funcionalidad(163) = "1" Then + TrDescripcionVenta.Visible = True + If CveVenta <= 0 Then + TxtDescripcionVenta.Enabled = True + End If + End If + + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then + If CveVenta <= 0 Then + EsVentaMedica = True + CargaTiposVenta() + If CveCliente > 0 Then + SeleccionarClienteSucursal(CveCliente:=CveCliente) + End If + End If + If CveVenta >= 0 Then + HLFAgregarOS.Visible = True + HLFAgregarOS.NavigateUrl = $"/OS/OrdenesServicios.aspx?CveVenta={CveVenta}" + End If + + TxtPrecio.Enabled = False + If UsuarioActual.CveUsuario = 3986 Then + TxtPrecio.Enabled = True + End If + 'ocultar la columna de subproyecto + GvPS.Columns(ColumnaSubProyecto).Visible = False + ThProyecto.Visible = False + ThProyecto2.Visible = False + + TxtCantidad.Text = "1" + TxtCantidad.Focus() + End If + + If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then + LnkAgregarCliente.Visible = True + 'ocultar la columna de subproyecto + GvPS.Columns(ColumnaSubProyecto).Visible = False + ThProyecto.Visible = False + ThProyecto2.Visible = False + TrDescripcionVenta.Visible = False + + If CveVenta <= 0 Then + TxtCantidad.Text = "1" + TxtCantidad.Focus() + RegistraScript("abrirDdlPS();", "A1") + End If + UpPS.Update() + + End If + + End If + + End If + End Sub #Region "Bloqueo Pantalla" @@ -5242,6 +5246,15 @@ Partial Class Ventas DiasCredito = DbRowVenta("DiasCredito").ToString().ToEntero() EsDiasCreditoFijo = CBool(DbRowVenta("EsDiasCreditoFijo").ToString()) + If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then + If DbRowVenta("Num2").ToString().ToEntero() = 2000 Then + ChkRemEspecial.Checked = True + ChkRemEspecial.Enabled = False + TxtFech2.Text = DbRowVenta("Fech2").ToString() + TrRemEspecial.Visible = UsuarioActual.TienePermisoProceso(390) + End If + End If + 'If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then ' Dim TienePermiso As String = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, -1).FiltroPrimeroValor("CveSubProyecto", String.Format("CveSubProyecto = {0}", DbRowVenta("CveSubProyecto"))) ' If TienePermiso <> "" Then ' si tiene acceso en el subproyecto @@ -6656,10 +6669,14 @@ Partial Class Ventas DdlTipoRelacionARelacionar.Items.Insert(0, New ListItem("-", "-1")) End Sub Private Sub CargaFormaEntrega() - TrFormaEntrega.Visible = True - DdlFormaEntrega.DataSource = GlobalDTVtaCondicionesEntrega(UsuarioActual.CveEmpresa) - DdlFormaEntrega.DataBind() - DdlFormaEntrega.Items.Insert(0, New ListItem("Seleccione", "-1")) + If GlobalDTVtaCondicionesEntrega(UsuarioActual.CveEmpresa).Rows.Count > 0 Then + TrFormaEntrega.Visible = True + DdlFormaEntrega.DataSource = GlobalDTVtaCondicionesEntrega(UsuarioActual.CveEmpresa) + DdlFormaEntrega.DataBind() + DdlFormaEntrega.Items.Insert(0, New ListItem("Seleccione", "-1")) + Else + TrFormaEntrega.Visible = False + End If End Sub Private Sub CargaGestionCobranza() @@ -12437,6 +12454,15 @@ Partial Class Ventas End If End If + 'VALOR PARA REMISIONES ESPECIALES + If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then + If ObjFactura.TipoDocto = "Rem" AndAlso ChkRemEspecial.Checked Then + ObjFactura.Num2 = 2000 + 'FECHA DE VIGENCIA PARA REMISION ESPECIAL + ObjFactura.Fech2 = DateTime.Now.AddDays(1).Date + End If + End If + If divcondicionespago.Visible Then ObjFactura.FechaPago = TxtFechaPago.Text.ToDate Else @@ -18565,6 +18591,10 @@ Partial Class Ventas TrAntEspecial.Visible = DdlTipoComprobante.SelectedValue = "Ant" End If + If UsuarioActual.Empresa.Funcionalidad(382) = "1" AndAlso DdlTipoComprobante.SelectedValue = "Rem" Then + TrRemEspecial.Visible = UsuarioActual.TienePermisoProceso(390) + End If + 'REINICIALIZA VALORES DE ENTREGA POR ADELANTADO RequiereAlmacenDestino = False TrAlmacenAsignado.Visible = False @@ -18712,6 +18742,7 @@ Partial Class Ventas ImgAntiPend.Visible = True End If + If ImgAntiPend.Visible Then If Me.TmpDTAnticiposNCIxCCliente IsNot Nothing Then Dim DtMovtos As DataTable = Me.TmpDTAnticiposNCIxCCliente.FiltraParametros($"Saldo > 0 And SaldoSubtotal > 0 {If(CveVenta < 0, $"AND Tipo IN('NC','RNC','IxC','Ant') ", "")}")