diff --git a/AF/AF.aspx b/AF/AF.aspx index 2234d7bf7..33c02cd41 100644 --- a/AF/AF.aspx +++ b/AF/AF.aspx @@ -154,6 +154,21 @@ +
+
+ +
+ +
+
+ + +
+
+
+ +
+
@@ -179,20 +194,7 @@
-
-
- -
- -
-
- - -
-
-
- -
+
diff --git a/AF/CatAF.aspx b/AF/CatAF.aspx index 34ad4ee76..b32f78b85 100644 --- a/AF/CatAF.aspx +++ b/AF/CatAF.aspx @@ -72,7 +72,7 @@ -
+
@@ -131,7 +131,8 @@
Cliente:
- + <%----%> +
Grupo:
@@ -209,7 +210,8 @@ - + <%----%> + diff --git a/AF/CatAF.aspx.vb b/AF/CatAF.aspx.vb index a9dac3d27..239c3235c 100644 --- a/AF/CatAF.aspx.vb +++ b/AF/CatAF.aspx.vb @@ -95,9 +95,20 @@ Partial Class AF_CatAF 'DdlProyecto.DataBind() 'DdlProyecto.Items.Insert(0, New ListItem("Todos", "-1")) - DdlCliente.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa) - DdlCliente.DataBind() - DdlCliente.Items.Insert(0, New ListItem("Todos", "-1")) + 'DdlCliente.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa) + 'DdlCliente.DataBind() + 'DdlCliente.Items.Insert(0, New ListItem("Todos", "-1")) + + 'CargaClientes + Dim EsWS As Boolean = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False) + If EsWS Then + DdlClientes.setEsWebService(True) + Else + DdlClientes.setEsWebService(False) + DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) + DdlClientes.DataBind() + DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1")) + End If CargarTipoActivoFijo() CargaGrupos() @@ -234,7 +245,8 @@ Partial Class AF_CatAF If intContador > 0 Then strSQL1.AppendFormat(" group by CveActivoFijo having count(*)={0}", intContador) - If ObjAF.GetActivosFijos(-1, UsuarioActual.CveEmpresa, Codigo, Descripcion, DdlTipoActivo.SelectedValue.ToEntero, DdlSubTipoActivo.SelectedValue.ToEntero, NoSerie, Año, CvePersonaResponsable, DdlProyecto.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, DdlEstatus.SelectedValue.ToEntero, strSQL1.ToString, -1, CveGrupo:=DdlGrupo.SelectedValue.ToEntero) Then + Dim Cvecliente As Integer = If(DdlClientes.SelectedValue.ToEntero > 0, DdlClientes.SelectedValue.ToEntero, -1) + If ObjAF.GetActivosFijos(-1, UsuarioActual.CveEmpresa, Codigo, Descripcion, DdlTipoActivo.SelectedValue.ToEntero, DdlSubTipoActivo.SelectedValue.ToEntero, NoSerie, Año, CvePersonaResponsable, DdlProyecto.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, DdlEstatus.SelectedValue.ToEntero, strSQL1.ToString, CveCliente:=CveCliente, CveGrupo:=DdlGrupo.SelectedValue.ToEntero) Then If ObjAF.DtResultados.Rows.Count > 0 Then DtActivosFijos = ObjAF.DtResultados 'GvDatos.DataSource = ObjAF.DtResultados diff --git a/AF/CatModelos.aspx.vb b/AF/CatModelos.aspx.vb index 10b5fe558..30134ec70 100644 --- a/AF/CatModelos.aspx.vb +++ b/AF/CatModelos.aspx.vb @@ -3,10 +3,11 @@ Option Strict On Imports System.Data Imports System.Linq +Imports CFDi Imports Extensiones Partial Class AF_CatModelos - Inherits ClsPaginas + Inherits ClsPaginas #Region " PROPIEDADES" @@ -71,7 +72,13 @@ Partial Class AF_CatModelos CargaDatos() ObjAF.Dispose() UpDatos.Update() + RegarGlobalDT() End Sub + + Private Sub RegarGlobalDT() + GlobalDTModeloActivoFijo(UsuarioActual.CveEmpresa, -1) = Nothing + End Sub + Public Sub Edit_Click(sender As Object, e As EventArgs) Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) HdnModalidad.Value = "U" @@ -101,6 +108,7 @@ Partial Class AF_CatModelos End If ObjAF.Dispose() UpDatos.Update() + RegarGlobalDT() End Sub Private Sub GvModelo_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvModelos.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then diff --git a/Acumuladores/RepRecolecciones.aspx.vb b/Acumuladores/RepRecolecciones.aspx.vb index 0fd8d43d1..aa2843c47 100644 --- a/Acumuladores/RepRecolecciones.aspx.vb +++ b/Acumuladores/RepRecolecciones.aspx.vb @@ -62,7 +62,7 @@ Partial Class Acumuladores_RepRecolecciones CargarCentrosDeCosto(Nothing, DdlSubProyecto, Nothing, LblSubProyecto) DdlAlmacenOrigen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (4)") DdlAlmacenOrigen.DataBind() - DdlAlmacenDestino.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (22) and Almacen like '%sado%'") + DdlAlmacenDestino.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (22) and Almacen like '%sado%' and CveAlmacen IN (449,616,628)") ' alm,. matriz,nav,obr recep sados DdlAlmacenDestino.DataBind() End Sub diff --git a/App_Code/ClsBancos.vb b/App_Code/ClsBancos.vb index be580aea7..77940930c 100644 --- a/App_Code/ClsBancos.vb +++ b/App_Code/ClsBancos.vb @@ -1704,6 +1704,30 @@ Public Class ClsBancos Return Retorno End Function + + Public Function UpdateBancosIECobranza(CveIE As Integer, CveTipoTransaccion As Integer, Folio As String, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Banc_IECobranzaUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveIE", SqlDbType.Int).Value = CveIE + .Add("@CveTipoTransaccion", SqlDbType.Int).Value = CveTipoTransaccion + .Add("@Folio", SqlDbType.VarChar).Value = Folio + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el tipo cambio del IE.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetUsuariosConcilio(CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False diff --git a/App_Code/ClsClientes.vb b/App_Code/ClsClientes.vb index bd5384c25..e3d47be18 100644 --- a/App_Code/ClsClientes.vb +++ b/App_Code/ClsClientes.vb @@ -3,11 +3,8 @@ Option Strict On Imports System.Data Imports System.Data.SqlClient -Imports AjaxControlToolkit Imports Extensiones -Imports iText.StyledXmlParser.Css.Resolve.Shorthand.Impl -Imports Modelos -Imports Stimulsoft.Report.Func + Public Class ClsClientes Implements IDisposable @@ -980,13 +977,13 @@ Public Class ClsClientes Return Retorno End Function - - Public Function GetSucursales(CveCliente As Integer, Optional CveClienteSucursal As Integer = -1) As Boolean + Public Function GetSucursales(CveCliente As Integer, Optional CveClienteSucursal As Integer = -1, Optional CveEmpresa As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_SucursalClienteGet") SqlAdapter.SelectCommand.Parameters.Add("@CveCliente", SqlDbType.Int).Value = CveCliente SqlAdapter.SelectCommand.Parameters.Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal + SqlAdapter.SelectCommand.Parameters.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa Try SqlAdapter.Fill(Data) Retorno = True @@ -2159,7 +2156,7 @@ Public Class ClsClientes #End Region #Region "A P L I C A C I O N" - Public Function AddClienteApp(Cliente As MCliente) As Boolean + Public Function AddClienteApp(Cliente As Modelos.MCliente) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_ClientesAppAdd") diff --git a/App_Code/ClsCompProveedores.vb b/App_Code/ClsCompProveedores.vb index 2d5d2f14d..51cb4c675 100644 --- a/App_Code/ClsCompProveedores.vb +++ b/App_Code/ClsCompProveedores.vb @@ -65,6 +65,7 @@ Public Class ClsCompProveedores Public Property Situacion As String = "" Public Property DIOTNacionalidad As String Public Property CveRegimenFiscal As Integer = -1 + Public Property PorcentajeProntoPago As Decimal = 0D Public ReadOnly Property DtResultados() As DataTable Get @@ -300,6 +301,7 @@ Public Class ClsCompProveedores Me.Situacion = Data.Rows(0)("Situacion").ToString Me.DIOTNacionalidad = Data.Rows(0)("DIOTNacionalidad").ToString Me.CveRegimenFiscal = Data.Rows(0)("CveRegimenFiscal").ToString.ToEntero + Me.PorcentajeProntoPago = Data.Rows(0)("PorcentajeProntoPago").ToString.ToDecimal End If @@ -317,7 +319,7 @@ Public Class ClsCompProveedores CveProveedorClasificacion As Integer, CveUsuarioResponsable As Integer, NotificarA As String, CorreoCobranza As String, FolioDuplicado As Boolean, CveUsuario As Integer, CveEmpresa As Integer, Optional CveTipoProveedor As Integer = 1, Optional CveMonedaPreferente As Integer = 1, Optional UsaLimiteCredito As Boolean = False, Optional DIOTCveTipoTercero As Integer = -1, Optional DIOTCveTipoOperacion As Integer = -1, Optional DIOTNumeroIDFiscal As String = "", Optional AplicarEvaluacion As Boolean = False, Optional FechaEvaluacion As String = "-1", Optional CicloEvaluacion As Integer = -1, Optional DIOTCvePais As Integer = -1, Optional CveUsuarioEvaluador As Integer = -1, Optional CP As Integer = 0, Optional DIOTNacionalidad As String = "", - Optional CveConfianzaProveedor As Integer = -1, Optional CveRegimenFiscal As Integer = -1) As Boolean + Optional CveConfianzaProveedor As Integer = -1, Optional CveRegimenFiscal As Integer = -1, Optional PorcentajeProntoPago As Decimal = 0) As Boolean Dim Retorno As Boolean = False @@ -367,6 +369,7 @@ Public Class ClsCompProveedores .Add("@CveUsuarioEvaluador", SqlDbType.Int).Value = CveUsuarioEvaluador .Add("@CveConfianzaProveedor", SqlDbType.Int).Value = CveConfianzaProveedor .Add("@CveRegimenFiscal", SqlDbType.TinyInt).Value = CveRegimenFiscal + .Add("@PorcentajeProntoPago", SqlDbType.Decimal).Value = PorcentajeProntoPago .Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue End With @@ -402,7 +405,7 @@ Public Class ClsCompProveedores CveProveedorClasificacion As Integer, CveUsuarioResponsable As Integer, Estatus As Boolean, NotificarA As String, CorreoCobranza As String, FolioDuplicado As Boolean, CveProveedor As Integer, Optional CveTipoProveedor As Integer = 1, Optional CveMonedaPreferente As Integer = 1, Optional UsaLimiteCredito As Boolean = False, Optional DIOTCveTipoTercero As Integer = -1, Optional DIOTCveTipoOperacion As Integer = -1, Optional DIOTNumeroIDFiscal As String = "", Optional CveUsuarioModifico As Integer = -1, Optional AplicarEvaluacion As Boolean = False, Optional FechaEvaluacion As String = "-1", Optional CicloEvaluacion As Integer = -1, Optional DIOTCvePais As Integer = -1, Optional CveUsuarioEvaluador As Integer = -1, Optional CP As Integer = 0, Optional DIOTNacionalidad As String = "", - Optional CveConfianzaProveedor As Integer = -1, Optional CveRegimenFiscal As Integer = -1) As Boolean + Optional CveConfianzaProveedor As Integer = -1, Optional CveRegimenFiscal As Integer = -1, Optional PorcentajeProntoPago As Decimal = 0) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Comp_ProveedorUpdate") @@ -455,6 +458,7 @@ Public Class ClsCompProveedores .Add("@CveConfianzaProveedor", SqlDbType.Int).Value = CveConfianzaProveedor .Add("@CveRegimenFiscal", SqlDbType.TinyInt).Value = CveRegimenFiscal + .Add("@PorcentajeProntoPago", SqlDbType.Decimal).Value = PorcentajeProntoPago ''Proveedores '.Add("@IdCtaContProveedores", SqlDbType.Int).Value = IdCtaContProveedores diff --git a/App_Code/ClsCompraManager.vb b/App_Code/ClsCompraManager.vb new file mode 100644 index 000000000..fcdc08bc1 --- /dev/null +++ b/App_Code/ClsCompraManager.vb @@ -0,0 +1,1865 @@ +Imports System.Data +Imports System.IO +Imports System.Xml +Imports ClsPaginas +Imports Extensiones +Imports Microsoft.VisualBasic + +Public Class ClsCompraManager + + Enum EnumCargaCompra + DesdeXML + DesdeArchivo + SinXML + End Enum + Public Enum EnumCFDIVersion + v32 + V33 + V40 + End Enum + + Public Enum EnumTipoCompra + Sin_definir = -1 + Gasto_con_almacen = 10 + Activo_Fijo = 1 + 'Costo_Indirecto = 2 + Almacen = 3 + Almacen_con_costo_indirecto = 8 + Costo_Indirecto = 4 + Importación = 5 + NC_Con_Productos = 6 + Apoyo_Logístico = 9 + NC_Por_Devolución = 11 + Garantia = 12 + End Enum + + + Public Enum EnumModalidadAccionPS + Agregar + Actualizar + End Enum + + Public Property CveCompra As Integer = -1 + Public Property CveProveedor As Integer + Public Property CveTipoConceptoProveedor As Integer + Public Property CveMoneda As Integer + Public Property Fecha As Date + Public ReadOnly Property SerieFolio As String + Get + If Serie.Length > 0 Then + Return $"{Serie}-{Folio}" + Else + Return $"{Folio}" + End If + End Get + End Property + + Public Property Serie As String = "" + Public Property Folio As String = "" + Public Property FolioSecundario As String = "" + Public Property Descripcion As String = "" + Public Property CFDIVersion As EnumCFDIVersion = EnumCFDIVersion.V40 + Public Property ProveedorNombre As String = "" + Public Property EsImportacion As Boolean = False + Public Property TC As Decimal = 1 + Public Property SubTotal As Decimal = 0D + Public Property SubTotal2 As Decimal = 0D + Public Property Descuento As Decimal = 0D + Public Property Total As Decimal = 0D + Public Property Moneda As String = "" + Public Property TipoComprobante As String + Public Property TipoCambio As Decimal = 1 + Public Property CompraNoDeducible As Integer = 0 + Public Property IVA As Decimal = 0D + Public Property IVADeducible As Decimal = 0D + Public Property IVANoDeducible As Decimal = 0 + Public Property IEPS As Decimal = 0D + Public Property RetIVA As Decimal = 0D + Public Property RetISR As Decimal = 0D + Public Property PorcentajeIVA As Decimal = 0 + Public Property PorcentajeISR As Decimal = 0 + Public Property CveRetIVAConcepto As Integer = -1 + Public Property CveRetISRConcepto As Integer = -1 + Public Property CveSubProyecto As Integer = -1 + Public Property UsuarioActual As Usuario + Public ReadOnly Property ConceptoPrePolizaIVA As ConceptosRetenciones + Get + Dim Ret As New ConceptosRetenciones + If EsImportacion Then + Ret.CveConceptoAcreditable = 288 + Ret.CveConceptoxAcreditar = 287 + Else + Ret.CveConceptoAcreditable = 19 + Ret.CveConceptoxAcreditar = 14 + End If + Return Ret + End Get + End Property + Public ReadOnly Property ConceptoPrePolizaRetIVA As ConceptosRetenciones + Get + Dim Ret As New ConceptosRetenciones + Dim Funcionalidad, FuncionalidadxAcred As Integer + If CveRetIVAConcepto = 1 Then + Funcionalidad = 308 : FuncionalidadxAcred = 307 + Ret.CveConceptoAcreditable = 22 + Ret.CveConceptoxAcreditar = 15 + ElseIf CveRetIVAConcepto = 2 Then + Funcionalidad = 310 : FuncionalidadxAcred = 309 + Ret.CveConceptoAcreditable = 184 + Ret.CveConceptoxAcreditar = 183 + ElseIf CveRetIVAConcepto = 3 Then + Funcionalidad = 312 : FuncionalidadxAcred = 311 + Ret.CveConceptoAcreditable = 186 + Ret.CveConceptoxAcreditar = 185 + ElseIf CveRetIVAConcepto = 4 Then + Funcionalidad = 314 : FuncionalidadxAcred = 313 + Ret.CveConceptoAcreditable = 249 + Ret.CveConceptoxAcreditar = 248 + ElseIf CveRetIVAConcepto = 5 Then + Funcionalidad = 578 : FuncionalidadxAcred = 578 + Ret.CveConceptoAcreditable = 286 + Ret.CveConceptoxAcreditar = 285 + ElseIf CveRetIVAConcepto = 6 Then + Funcionalidad = 578 : FuncionalidadxAcred = 578 + Ret.CveConceptoAcreditable = 333 + Ret.CveConceptoxAcreditar = 334 + End If + Return Ret + End Get + End Property + Public ReadOnly Property ConceptoPrePolizaRetISR As ConceptosRetenciones + Get + Dim Ret As New ConceptosRetenciones + Dim Funcionalidad, FuncionalidadxAcred As Integer + If CveRetISRConcepto = 1 Then + Funcionalidad = 316 : FuncionalidadxAcred = 315 + Ret.CveConceptoAcreditable = 23 + Ret.CveConceptoxAcreditar = 16 + ElseIf CveRetISRConcepto = 2 Then + Funcionalidad = 318 : FuncionalidadxAcred = 317 + Ret.CveConceptoAcreditable = 244 + Ret.CveConceptoxAcreditar = 243 + ElseIf CveRetISRConcepto = 3 Then + Funcionalidad = 349 : FuncionalidadxAcred = 348 + Ret.CveConceptoAcreditable = 328 + Ret.CveConceptoxAcreditar = 327 + End If + Return Ret + End Get + End Property + + Public Property CveMetodoPago As Integer + Public Property MetodoPago As String + Public Property DocumentosRelacionadosUUIDSList As List(Of String) = New List(Of String) + Public ReadOnly Property DocumentosRelacionadosUUIDSString As String + Get + Return GeneraStringDoctosRelacionados() + End Get + End Property + + Public Property DocumentosRelacionadosAnticiposUUIDList As List(Of String) = New List(Of String) + Public Property TieneAnticiposXML As Boolean = False + Public Property EmisorRFC As String + Public Property ReceptorRFC As String + Public Property UUID As String = "" + Public Property TotalRetenciones As Decimal = 0D + Public Property RetencionIVA As Decimal = 0D + Public Property RetencionISR As Decimal = 0D + Public Property SumaTotalRetenciones As Decimal = 0D + Public Property TotalTraslados As Decimal = 0D + Public Property TrasladoIVA As Decimal = 0D + Public Property TrasladoIEPS As Decimal = 0D + Public Property SumaTotalTraslados As Decimal = 0D + Public Property OtrosImpuestos As Decimal = 0D + Private Property OtrosImpuestosRetenciones As Decimal = 0D + Public Property Amortizacion As Decimal = 0D + Public Property FechaPago As Date 'FIX ME corregir usando fecha interna calculada por los dias de credito del proveedor + Public Property AplicaNotaCredito As Boolean = False + Public Property XMlStr As String + Public Property XMLCargaExistosa As Boolean = True + Public Property Observaciones As String = "" + Public Property CveEstatusFactura As Integer = 1 + Public Property CvePrePoliza As Integer = -1 + Public Property Redondeo As Decimal = 0 + Public Property IdPoliza As Integer = -1 + Public Property CveCajaChica As Integer = -1 + Public Property CvePersonal As Integer = -1 + Public Property NumeroReembolso As String = "" + Public Property CveProveedorSucursal As Integer = -1 + Public Property AplicoPromocion As Boolean = False + Public Property CveConceptoContableAlmacen As Integer = -1 + Public Property NoDeducible As Integer = 0 + Public Property CveTipoCompra As Integer = 1 + Public Property TotalOriginal As Decimal = 0D + Public Property CveTipoConcepto As Integer = 1 'FIX ME Esto tiene que ver con el CveTipoProveedor 1 y 3 es CveTipoConcepto 1 y 2 es CveTipoConcepto 2 + Public Property CveSubProyectoPrincipal As Integer = -1 + Public Property CveFactura As Integer = -1 + Public Property CveFolioGarantia As Integer = -1 + Public Property TmpDT As DataTable = New DataTable + Public Property SubTotalConceptos As Decimal = 0D + + Private Errores As StringBuilder = New StringBuilder + + Public ReadOnly Property MensajeError As String + Get + Return Errores.ToString() + End Get + End Property + + Public Property CompraSaldo As Decimal = 0D + Public Property SubTotalOriginal As Decimal = 0D + Public Property SubTotal2Original As Double = 0D + Public Property IVAOriginal As Decimal = 0D + Public Property RetIVAOriginal As Decimal = 0D + Public Property RetISROriginal As Decimal = 0D + Public Property Proyecto As String = "" + Public Property CveProyecto As Integer = -1 + Public Property SubProyecto As String = "" + Public Property TipoCompra As EnumTipoCompra = EnumTipoCompra.Sin_definir + Private Property DTTiposGastos() As DataTable + Public Property CveTipoProveedor As Integer = -1 + Public Property IEPSGasto As Boolean = False + Public Property OtrosImpuestosGasto As Boolean = False + Public Property OCVinculada As Boolean = False + Public Property NumNoDed As Integer = 0 + Public Property CveTipoPoliza As Integer = -1 + Public Property NombreProveedor As Object + Public Property CveCreditoDetalle As Integer = -1 + Public Property CveIE As Integer = -1 + Public Property CveCompraAmortizacion As Integer = -1 + + Public Sub New(XmlFuente As String, OpcionCarga As EnumCargaCompra, DTTiposGastos As DataTable, UsuarioActual As Usuario) + + Errores = New StringBuilder + + Me.DTTiposGastos = DTTiposGastos + Me.UsuarioActual = UsuarioActual + + If OpcionCarga = EnumCargaCompra.DesdeArchivo Then + CargaDesdeArchivo(XmlFuente) + Else + CargaDesdeString(XmlFuente) + End If + + End Sub + + Private Sub CargaDesdeArchivo(XmlFuenteRuta As String) + + Dim XMLDoc As New XmlDocument + + If IO.File.Exists(XmlFuenteRuta) Then + XMlStr = File.ReadAllText(XmlFuenteRuta).Replace("<br>", "").Replace("<", "").Replace("o;?", "") + Try + XMLDoc.LoadXml(XMlStr) + XMLCargaExistosa = True + Catch ex As Exception + Try + Dim oReader As New StreamReader(XmlFuenteRuta, Encoding.GetEncoding("ISO-8859-1")) + XMLDoc.Load(oReader) + oReader.Dispose() + XMLCargaExistosa = True + Catch ex2 As Exception + GuardaLog("Error al intentar leer el XML del SAT. Error:" & ex2.ToString()) + Errores.AppendLine("Error al intentar leer el XML. Error:" & ex2.ToString()) + XMLCargaExistosa = False + End Try + End Try + End If + + If XMLCargaExistosa Then + CargaComprobanteXML(XMLDoc) + End If + + End Sub + Private Sub CargaDesdeString(XmlFuente As String) + XMlStr = XmlFuente.Replace("<br>", "").Replace("<", "").Replace("o;?", "") + Dim XMLDoc As New XmlDocument + Try + XMLDoc.LoadXml(XMlStr) + XMLCargaExistosa = True + Catch ex As Exception + GuardaLog("Error al intentar leer . Error:" & ex.ToString()) + Errores.AppendLine("Error al intentar leer el XML. Error:" & ex.ToString()) + XMLCargaExistosa = False + End Try + + If XMLCargaExistosa Then + CargaComprobanteXML(XMLDoc) + End If + + End Sub + + Private Sub CargaComprobanteXML(XMLDoc As XmlDocument) + Dim nodo As XmlNode = XMLDoc.DocumentElement + + Serie = ValorXML(nodo, "serie") + + Dim StrCFDIVerion As String = ValorXML(nodo, "version") + + If StrCFDIVerion = "3.2" Then + CFDIVersion = EnumCFDIVersion.v32 + ElseIf StrCFDIVerion = "3.3" Then + CFDIVersion = EnumCFDIVersion.V33 + ElseIf StrCFDIVerion = "4.0" Then + CFDIVersion = EnumCFDIVersion.V40 + Else + GuardaLog($"CFDI Versión {StrCFDIVerion} no soportada") + Errores.AppendLine($"CFDI Versión {StrCFDIVerion} no soportada") + XMLCargaExistosa = False + Exit Sub + End If + + Folio = ValorXML(nodo, "folio") + Fecha = ValorXML(nodo, "fecha").ToDate + SubTotal = ValorXML(nodo, "subTotal").ToDecimal + Total = ValorXML(nodo, "total").ToDecimal + Descuento = ValorXML(nodo, "descuento").ToDecimal + Moneda = ValorXML(nodo, "Moneda") + + CveMoneda = GlobalDTMonedas().FiltroPrimeroValor("CveMoneda", $" AbreviaturaSAT = '{Moneda}' ").ToEntero + If Not CveMoneda > 0 Then + GuardaLog($"Moneda {Moneda} no se obtuvo la clabe") + Errores.AppendLine($"Moneda {Moneda} no se obtuvo la clabe") + XMLCargaExistosa = False + Exit Sub + End If + + TipoComprobante = ValorXML(nodo, "tipoDeComprobante") + TipoCambio = ValorXML(nodo, "TipoCambio", "1").ToDecimal + + If CFDIVersion = EnumCFDIVersion.V33 Or CFDIVersion = EnumCFDIVersion.V40 Then + Dim drm As DataRow = GlobalDTVtaMetodoPago.FiltroPrimero(String.Format("ClaveMetodoPagoSAT = '{0}'", ValorXML(nodo, "MetodoPago"))) + If drm IsNot Nothing Then + CveMetodoPago = drm("CveMetodoPago").ToString.ToEntero + MetodoPago = drm("MetodoPagoSAT").ToString + End If + End If + + Dim namespaces As New XmlNamespaceManager(XMLDoc.NameTable) + Dim Prefijo As String = If(XMLDoc.DocumentElement.Prefix = "", "cfd", XMLDoc.DocumentElement.Prefix) + Dim cfdVer As String = "" + + If CFDIVersion = EnumCFDIVersion.v32 Then + Prefijo = "cfd" + cfdVer = "http://www.sat.gob.mx/cfd/2" + ElseIf CFDIVersion = EnumCFDIVersion.V33 Then + cfdVer = "http://www.sat.gob.mx/cfd/3" + Else ' se considera que es la version 4.0 + cfdVer = "http://www.sat.gob.mx/cfd/4" + End If + namespaces.AddNamespace(Prefijo, cfdVer) + namespaces.AddNamespace("aerolineas", "http://www.sat.gob.mx/aerolineas") + namespaces.AddNamespace("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital") + namespaces.AddNamespace("implocal", "http://www.sat.gob.mx/implocal") + namespaces.AddNamespace("registrofiscal", "http://www.sat.gob.mx/registrofiscal") + + If TipoComprobante.ToUpper = "E" AndAlso (CFDIVersion = EnumCFDIVersion.V33 OrElse CFDIVersion = EnumCFDIVersion.V40) Then + Dim UUIDS As String = "" + + Dim UUIDSLista As New List(Of String) + Dim nodeCFDIRelacionados As XmlNode + nodeCFDIRelacionados = XMLDoc.SelectSingleNode(String.Format("//{0}:CfdiRelacionados", Prefijo), namespaces) + + If nodeCFDIRelacionados IsNot Nothing Then + For Each CFDIRelacionados As XmlNode In nodeCFDIRelacionados + UUIDSLista.Add("" & CFDIRelacionados.Attributes("UUID").Value.ToString & "") + Next + End If + DocumentosRelacionadosUUIDSList = UUIDSLista + + End If + + Dim node As XmlNode + node = XMLDoc.SelectSingleNode(String.Format("//{0}:Emisor", Prefijo), namespaces) + + If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then + EmisorRFC = ValorXML(node, "RFC") + End If + + node = XMLDoc.SelectSingleNode(String.Format("//{0}:Receptor", Prefijo), namespaces) + + If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then + ReceptorRFC = ValorXML(node, "RFC") + End If + + If UsuarioActual.CveEmpresa.Contiene(119, 7) Then + node = XMLDoc.SelectSingleNode(String.Format("//{0}:CfdiRelacionados", Prefijo), namespaces) + If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then + If ValorXML(node, "TipoRelacion").ToString.Contiene("07") Then + Dim nodeDocumentosRelacionados As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:CfdiRelacionado", Prefijo), namespaces) + For Each documento As XmlNode In nodeDocumentosRelacionados + If documento.Attributes("UUID").Value <> "" Then + DocumentosRelacionadosAnticiposUUIDList.Add(documento.Attributes("UUID").Value) + End If + TieneAnticiposXML = True + Next + End If + End If + End If + + node = XMLDoc.SelectSingleNode(String.Format("//{0}:Impuestos", Prefijo), namespaces) + If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then + Dim nodeRetenciones As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:Comprobante/{0}:Impuestos/{0}:Retenciones/{0}:Retencion", Prefijo), namespaces) + + TotalRetenciones = ValorXML(node, "totalImpuestosRetenidos", "0").ToDecimal + + If CFDIVersion = EnumCFDIVersion.V33 OrElse CFDIVersion = EnumCFDIVersion.V40 Then + + For Each retencion As XmlNode In nodeRetenciones + If retencion.Attributes("Impuesto").Value = "002" Then RetencionIVA += retencion.Attributes("Importe").Value.ToDecimal + If retencion.Attributes("Impuesto").Value = "001" Then RetencionISR += retencion.Attributes("Importe").Value.ToDecimal + Next + + Else + + For Each retencion As XmlNode In nodeRetenciones + If retencion.Attributes("impuesto").Value = "IVA" Then RetencionIVA += retencion.Attributes("importe").Value.ToDecimal + If retencion.Attributes("impuesto").Value = "ISR" Then RetencionISR += retencion.Attributes("importe").Value.ToDecimal + Next + End If + SumaTotalRetenciones += RetencionIVA + SumaTotalRetenciones += RetencionISR + + TotalTraslados = ValorXML(node, "totalImpuestosTrasladados", "0").ToDecimal + Dim nodeTraslados As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:Comprobante/{0}:Impuestos/{0}:Traslados/{0}:Traslado", Prefijo), namespaces) + + If CFDIVersion = EnumCFDIVersion.V33 OrElse CFDIVersion = EnumCFDIVersion.V40 Then + + For Each traslado As XmlNode In nodeTraslados + + If traslado.Attributes("Importe") IsNot Nothing Then + If traslado.Attributes("Impuesto").Value = "002" Then TrasladoIVA += traslado.Attributes("Importe").Value.ToDecimal + If traslado.Attributes("Impuesto").Value = "003" Then TrasladoIEPS += traslado.Attributes("Importe").Value.ToDecimal + End If + Next + Else + + For Each traslado As XmlNode In nodeTraslados + If traslado.Attributes("Importe") IsNot Nothing Then + If traslado.Attributes("impuesto").Value = "IVA" Then TrasladoIVA += traslado.Attributes("importe").Value.ToDecimal + + If traslado.Attributes("impuesto").Value = "IEPS" Then TrasladoIEPS += traslado.Attributes("importe").Value.ToDecimal + End If + Next + End If + + SumaTotalTraslados += TrasladoIVA + SumaTotalTraslados += TrasladoIEPS + End If + + Dim nodeComp As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Complemento", Prefijo), namespaces) + If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then + + Dim nodeTFD As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:TimbreFiscalDigital", "tfd"), namespaces) + + UUID = ValorXML(nodeTFD, "UUID", "") + + Dim nodeRF As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:CFDIRegistroFiscal ", "registrofiscal"), namespaces) + If nodeRF IsNot Nothing Then + Folio = ValorXML(nodeRF, "folio").TrimStart("0"c) + End If + + node = node.SelectSingleNode(String.Format("//{0}:ImpuestosLocales", "implocal"), namespaces) + + If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then + OtrosImpuestos = ValorXML(node, "TotaldeTraslados", "0").ToDecimal + '2022.06.04-- se quitan los datos de retenciones de impuestos locales, generan conflicto. RMF + 'OtrosImpuestosRetenciones = ValorXML(node, "TotaldeRetenciones", "0").ToDecimal + End If + End If + + + If XMLCargaExistosa Then + If Not ValidateUUID(UUID) Then + GuardaLog($"UUID Invalido {UUID} .") + Errores.AppendLine($"UUID Invalido {UUID} .") + XMLCargaExistosa = False + End If + End If + + +#Region "DETALLES" + + Dim ObjeFacturas As New ClsCompras + Dim AjustaUltimoConcepto As Boolean = False + + Dim nodeconceptos As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Conceptos", Prefijo), namespaces) + Dim XML As String = Replace(nodeconceptos.OuterXml, "", "") 'salto de linea html + XML = XML.Replace("<br>", "") + XML = XML.Replace("<", "") + + XML = XML.Replace("&", "") 'adicional, si hay otros + + If ObjeFacturas.GetFacturasComparacionXML(StrCFDIVerion, XML, UsuarioActual.CveEmpresa) Then + TmpDT = ObjeFacturas.DtResultados + TmpDT.Columns.Add("CveSATPSActualizado") + SubTotalConceptos = TmpDT.SUMD("Total").RoundSQL + + If Not TmpDT.Columns.Contains("Amortizacion") Then + TmpDT.Columns.Add("Amortizacion", GetType(Decimal)) + End If + 'VALIDA QUE EL XML SI VIENE CON EL CODIGO SAT 01010101 + Dim ProductosCodigoSATNoPermitidos As New StringBuilder("") + For Each drr As DataRow In TmpDT.FiltraParametros("ClaveProdServ = '01010101'").Rows + ProductosCodigoSATNoPermitidos.AppendFormat("{0}
", drr("PS")) + Next + + If ProductosCodigoSATNoPermitidos.ToString.Length > 0 Then + Errores.AppendLine($"El comprobante contiene productos con código SAT '01010101', revise los productos:

{ProductosCodigoSATNoPermitidos.ToString}") + + End If + Else + GuardaLog($"Error al cargar detalles GetFacturasComparacionXML.") + Errores.AppendLine($"Error al cargar detalles GetFacturasComparacionXML.") + XMLCargaExistosa = False + End If + + ObjeFacturas.Dispose() + + If CFDIVersion = EnumCFDIVersion.V33 OrElse CFDIVersion = EnumCFDIVersion.V40 Then + If Not TmpDT.Columns.Contains("Amortizacion") Then + TmpDT.Columns.Add("Amortizacion", GetType(Decimal)) + End If + TmpDT.AcceptChanges() + ValidacionesTotalesXml() + End If + + Me.PorcentajeIVA = TmpDT.MAX("IVAPorcentaje").ToDecimal + +#End Region + End Sub + + Public Function ConfiguraRegistroRapidoReembolso(CvePS As Integer, CveSubProyecto As Integer, CveCajaChica As Integer, CvePersonal As Integer, CveRetIVAConcepto As Integer, CveRetISRConcepto As Integer, NumeroReembolso As String) As Boolean + + Dim respuesta As Boolean = True + Me.CveSubProyecto = CveSubProyecto + Me.CveSubProyectoPrincipal = CveSubProyecto + Me.CveCajaChica = CveCajaChica + Me.CvePersonal = CvePersonal + Me.CveRetIVAConcepto = CveRetIVAConcepto + Me.CveRetISRConcepto = CveRetISRConcepto + Me.CveTipoPoliza = 3 + Me.NumeroReembolso = NumeroReembolso + + Dim dRowSubProyecto As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("") + + If dRowSubProyecto IsNot Nothing Then + Me.Proyecto = dRowSubProyecto("Proyecto").ToString + Me.CveProyecto = (dRowSubProyecto("CveProyecto").ToString).ToEntero + Me.SubProyecto = dRowSubProyecto("SubProyecto").ToString + Else + Errores.AppendLine($"Error al cargar el Sub Proyecto CveSubProyecto: {CveSubProyecto}") + Return False + End If + + Dim DTIndex As DataTable = TmpDT.FiltraParametros("", DistinctColumns:={"Consec"}) + + For Each dRowIndex As DataRow In DTIndex.Rows + If Not UpdatePSReembolso(dRowIndex("Consec").ToString.ToEntero, CvePS) Then + respuesta = False + End If + Next + + If respuesta AndAlso IEPS > 0 Then + If Not AgregaIEPSReembolso(CvePS:=CvePS) Then + respuesta = False + Else + IEPS = 0 + End If + End If + + If Not AjustesValidacion() Then + respuesta = False + End If + + Return respuesta + + End Function + Public Function ConfiguraRegistroRapidoRemNC(CvePS As Integer, CveSubProyecto As Integer, CveCajaChica As Integer, CvePersonal As Integer, CveRetIVAConcepto As Integer, CveRetISRConcepto As Integer, NumeroReembolso As String) As Boolean + + Dim respuesta As Boolean = True + Me.CveSubProyecto = CveSubProyecto + Me.CveSubProyectoPrincipal = CveSubProyecto + Me.CveCajaChica = CveCajaChica + Me.CvePersonal = CvePersonal + Me.CveRetIVAConcepto = CveRetIVAConcepto + Me.CveRetISRConcepto = CveRetISRConcepto + Me.CveTipoPoliza = 3 + Me.NumeroReembolso = NumeroReembolso + + Dim dRowSubProyecto As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("") + + If dRowSubProyecto IsNot Nothing Then + Me.Proyecto = dRowSubProyecto("Proyecto").ToString + Me.CveProyecto = (dRowSubProyecto("CveProyecto").ToString).ToEntero + Me.SubProyecto = dRowSubProyecto("SubProyecto").ToString + Else + Errores.AppendLine($"Error al cargar el Sub Proyecto CveSubProyecto: {CveSubProyecto}") + Return False + End If + + Dim DTIndex As DataTable = TmpDT.FiltraParametros("", DistinctColumns:={"Consec"}) + + For Each dRowIndex As DataRow In DTIndex.Rows + If Not UpdatePSReembolso(dRowIndex("Consec").ToString.ToEntero, CvePS) Then + respuesta = False + End If + Next + + If respuesta AndAlso IEPS > 0 Then + If Not AgregaIEPSReembolso(CvePS:=CvePS) Then + respuesta = False + Else + IEPS = 0 + End If + End If + + If Not AjustesValidacion() Then + respuesta = False + End If + + Return respuesta + + End Function + + Private Function AjustesValidacion() As Boolean + Dim respuesta As Boolean = True + 'VALIDA IMPORTES + If Not ValidaTotalesGuardar() Then + respuesta = False + End If + + If Not AjustaCombustibles() Then + respuesta = False + End If + + If Not AjustaIVA() Then + respuesta = False + End If + + If Not AjustaRetIVA() Then + respuesta = False + End If + + If Not AjustaRetISR() Then + respuesta = False + End If + + Return respuesta + + End Function + + Private Function ValidaTotalesGuardar() As Boolean + Dim EsValido As Boolean = True + + 'VALIDA IMPORTES + 'VALIDA TOTAL CON LOS IMPORTES TOTALES + Dim TempSubTotal, TempDescuentos, TempIVA, TempSubTotal2, TempRetIVA, TempRetISR, TempTotal, DifTotales, TempIEPS As Decimal + + Dim Amortizacion As Decimal = 0 + Dim TieneAmortizacion As Boolean = False + If DocumentosRelacionadosAnticiposUUIDList IsNot Nothing AndAlso DocumentosRelacionadosAnticiposUUIDList.Count > 0 Then 'Fix me + ' AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 Then + 'TieneAmortizacion = True + End If + + 'If CveCompra < 0 AndAlso Not TieneAmortizacion Then + ' LblAmortizacion.Text = "0.00" + 'End If + + 'If UsuarioActual.CveEmpresa = 119 AndAlso TieneAmortizacion Then + ' Amortizacion = LblAmortizacion.Text.Trim.ToDecimal + ' TxtSubTotal.Text = (TxtSubTotal.Text.ToDouble + Amortizacion).ToString + 'End If + + + TempSubTotal = SubTotal + SubTotalOriginal = SubTotal + SubTotal2Original = SubTotal2 + TempDescuentos = Descuento + Amortizacion + TempSubTotal2 = TempSubTotal - TempDescuentos + TempIVA = IVA + TempIEPS = IEPS + TempRetIVA = RetIVA + TempRetISR = RetISR + TempTotal = Math.Round(TempSubTotal2 + TempIVA + TempIEPS - TempRetIVA - TempRetISR + OtrosImpuestos - Amortizacion, 2) + DifTotales = Total - TempTotal + Dim DiferenciaPermitida As Decimal = 0.6D + + If Math.Abs(DifTotales) > DiferenciaPermitida Then + Errores.AppendLine($"Los importes de los conceptos (Productos/Servicios) no cuadran con el total. Por favor verifique y vuelva a intentar.[{Math.Abs(DifTotales) - DiferenciaPermitida}]") + EsValido = False + ElseIf DifTotales <> 0 Then + SubTotal2 = (SubTotal2 + DifTotales) + SubTotal = (SubTotal + DifTotales) + SubTotalOriginal = SubTotal + SubTotal2Original = SubTotal2 + End If + + Dim DiferenciaSubtotales As Decimal = 0 + If CveCompra > 0 Or CveFactura > 0 Or OCVinculada Then + + If SubTotalOriginal = Nothing Then + SubTotalOriginal = 0 + End If + + If SubTotal2Original = Nothing Then + SubTotal2Original = 0 + End If + + DiferenciaSubtotales = SubTotal2Original.ToString.ToDecimal - TmpDT.SUM("Total").ToString.ToDecimal + '[IPP] PARCHE: Factura TELMEX para APH 12/ENERO/2018 + If CveFactura = 286290 Then + DiferenciaSubtotales += Descuento + End If + If Math.Abs(DiferenciaSubtotales) > 1 And Not CompraNoDeducible = 1 Then 'EsNoDeducible + Errores.AppendLine("Los importes de los conceptos (Productos/Servicios) no cuadran con el total. Por favor verifique y vuelva a intentar.") + EsValido = False + Else + AjustaImporteUltimoConcepto(DiferenciaSubtotales) + End If + Else + DiferenciaSubtotales = (SubTotal2 - TmpDT.SUMD("Total")).ToString.ToDecimal + If Math.Abs(DiferenciaSubtotales) > 1 Then + Errores.AppendLine("Los importes de los conceptos (Productos/Servicios) no cuadran con el total. Por favor verifique y vuelva a intentar.") + EsValido = False + Else + AjustaImporteUltimoConcepto(DiferenciaSubtotales) + End If + End If + + Return EsValido + End Function + + + + Private Function AjustaCombustibles() As Boolean + + Dim Respuesta As Boolean = False + + Dim IVADetalles As Decimal = TmpDT.SUMD("IVA", " IVA > 0 ") + Dim DiferenciaIVas As Decimal = IVA - IVADetalles + + + If Not TmpDT.Columns.Contains("AplicaIEPS") Then + TmpDT.Columns.Add(New DataColumn("AplicaIEPS", GetType(Boolean))) + End If + + If Not TmpDT.Columns.Contains("IEPSGrabaIVA") Then + TmpDT.Columns.Add(New DataColumn("IEPSGrabaIVA", GetType(Boolean))) + End If + + For Each dRow As DataRow In TmpDT.Rows + Dim DttPS As DataTable = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=dRow("CvePS").ToString.ToEntero) + If DttPS IsNot Nothing AndAlso DttPS.Rows.Count > 0 Then + Dim DrPS As DataRow = DttPS.Rows(0) + dRow("AplicaIEPS") = Boolean.Parse(DrPS("AplicaIEPS").ToString) + dRow("IEPSGrabaIVA") = Boolean.Parse(DrPS("IEPSGrabaIVA").ToString) + Else + dRow("AplicaIEPS") = False + dRow("IEPSGrabaIVA") = False + End If + Next + + Dim DTConsulta As New DataTable + DTConsulta = TmpDT.FiltraParametros(" AplicaIEPS = 'True' AND IEPSGrabaIVA = 'False' AND IVA > 0 ") + + If DTConsulta.Rows.Count > 0 Then + + Dim IndiceContador As Integer = 0 + Dim IndiceUltimo As Integer = 0 + Dim CantidadRegistroConIVA As Decimal + + For Each dRow As DataRow In TmpDT.Rows + If Boolean.Parse(dRow("AplicaIEPS").ToString) And Boolean.Parse(dRow("IEPSGrabaIVA").ToString) = False And dRow("IVA").ToString.ToDecimal > 0 Then + IndiceUltimo = IndiceContador + CantidadRegistroConIVA = CantidadRegistroConIVA + 1 + End If + IndiceContador = IndiceContador + 1 + Next + + IVADetalles = TmpDT.SUMD("IVA", " IVA > 0 ") + DiferenciaIVas = IVA - IVADetalles + + If Math.Abs(DiferenciaIVas) > 0.01D Then + + If (TmpDT.Rows(IndiceUltimo)("IVA").ToString.ToDecimal + DiferenciaIVas) < 0 Then + + Dim AjusteteDividido As Decimal = Math.Abs(DiferenciaIVas) / CantidadRegistroConIVA + + For Each dRow As DataRow In TmpDT.Rows + If Boolean.Parse(dRow("AplicaIEPS").ToString) And Boolean.Parse(dRow("IEPSGrabaIVA").ToString) = False And dRow("IVA").ToString.ToDecimal > 0 Then + dRow("IVA") = dRow("IVA").ToString.ToDecimal - AjusteteDividido + End If + Next + Else + TmpDT.Rows(IndiceUltimo)("IVA") = TmpDT.Rows(IndiceUltimo)("IVA").ToString.ToDecimal + DiferenciaIVas + End If + TmpDT.AcceptChanges() + End If + + End If + + 'Revalidacion de ajuste + IVADetalles = TmpDT.SUMD("IVA", " IVA > 0 ") + DiferenciaIVas = IVA - IVADetalles + + If Math.Abs(DiferenciaIVas) > 0.01D Then + Respuesta = False + If IVADetalles > 0 Then + + For Each dRow As DataRow In TmpDT.Rows + If dRow("IVA").ToString.ToDecimal > 0 Then + dRow("IVA") = dRow("IVA").ToString.ToDecimal + DiferenciaIVas + TmpDT.AcceptChanges() + Respuesta = True + Exit For + End If + Next + Else + Alert("Los productos especificados en el listado no tienen asignado impuesto IVA, favor de realizar la corrección en el producto que aplique el impuesto.", TipoMensaje.MsgAdvertencia) + Respuesta = False + End If + Else + Respuesta = True + End If + + If Respuesta Then + + Dim IEPSPSDetalles As Decimal = TmpDT.SUMD("IEPSPS", " IEPSPS > 0 ") + Dim DiferenciaIEPSPS As Decimal = IEPS - IEPSPSDetalles + + Dim DTConsultaIEPSPS As New DataTable + DTConsultaIEPSPS = TmpDT.FiltraParametros(" AplicaIEPS = 'True'") + Dim IndiceContador As Integer = 0 + Dim IndicePrimero As Integer = 0 + + For Each dRow As DataRow In TmpDT.Rows + If Boolean.Parse(dRow("AplicaIEPS").ToString) And dRow("IEPSPS").ToString.ToDecimal > 0 Then + IndicePrimero = IndiceContador + Exit For + End If + IndiceContador = IndiceContador + 1 + Next + If DiferenciaIEPSPS.RoundSQL(2) <> 0 Then + + TmpDT.Rows(IndicePrimero)("IEPSPS") = TmpDT.Rows(IndicePrimero)("IEPSPS").ToString.ToDecimal + DiferenciaIEPSPS + TmpDT.AcceptChanges() + End If + + For Each dRow As DataRow In TmpDT.Rows + If dRow("IEPSPSPorcentaje").ToString.ToDecimal > 0 AndAlso dRow("IEPSPS").ToString.ToDecimal = 0 Then + dRow("IEPSPSPorcentaje") = 0 + End If + Next + TmpDT.AcceptChanges() + End If + + Return Respuesta + + End Function + + + Private Function AjustaIVA() As Boolean + + Dim Respuesta As Boolean = False + + Dim IVADetalles As Decimal = TmpDT.SUMD("IVA", " IVA > 0 ") + Dim DiferenciaIVas As Decimal = IVA - IVADetalles + + If Math.Abs(DiferenciaIVas) > 0 Then + If Math.Abs(DiferenciaIVas) <= 0.05 Then + + Dim DTConsulta As New DataTable + DTConsulta = TmpDT.FiltraParametros(" IVA > 0 ") + + If DTConsulta.Rows.Count > 0 Then + + Dim IndiceContador As Integer = 0 + Dim IndiceUltimo As Integer = 0 + Dim CantidadRegistroConIVA As Decimal + + For Each dRow As DataRow In TmpDT.Rows + If dRow("IVA").ToString.ToDecimal > 0 Then + IndiceUltimo = IndiceContador + CantidadRegistroConIVA = CantidadRegistroConIVA + 1 + End If + IndiceContador = IndiceContador + 1 + Next + + IVADetalles = TmpDT.SUMD("IVA", " IVA > 0 ") + DiferenciaIVas = IVA - IVADetalles + + If Math.Abs(DiferenciaIVas) > 0.0D Then + + If (TmpDT.Rows(IndiceUltimo)("IVA").ToString.ToDecimal + DiferenciaIVas) < 0 Then + + Dim AjusteteDividido As Decimal = Math.Abs(DiferenciaIVas) / CantidadRegistroConIVA + + For Each dRow As DataRow In TmpDT.Rows + dRow("IVA") = dRow("IVA").ToString.ToDecimal - AjusteteDividido + Next + Else + TmpDT.Rows(IndiceUltimo)("IVA") = TmpDT.Rows(IndiceUltimo)("IVA").ToString.ToDecimal + DiferenciaIVas + End If + TmpDT.AcceptChanges() + End If + End If + + 'Revalidacion de ajuste + IVADetalles = TmpDT.SUMD("IVA", " IVA > 0 ") + DiferenciaIVas = IVA - IVADetalles + + If Math.Abs(DiferenciaIVas) > 0.01D Then + Respuesta = False + If IVADetalles > 0 Then + + For Each dRow As DataRow In TmpDT.Rows + If dRow("IVA").ToString.ToDecimal > 0 Then + dRow("IVA") = dRow("IVA").ToString.ToDecimal + DiferenciaIVas + TmpDT.AcceptChanges() + Respuesta = True + Exit For + End If + Next + + Else + Errores.AppendLine("Los productos especificados en el listado no tienen asignado impuesto IVA, favor de realizar la corrección en el producto que aplique el impuesto.") + Respuesta = False + End If + Else + Respuesta = True + End If + + Else + Errores.AppendLine($"existe una diferencia de {DiferenciaIVas} entre el IVA de la compra y los detalles.") + Respuesta = False + End If + Else + Respuesta = True + End If + + Return Respuesta + + End Function + + Private Function AjustaRetIVA() As Boolean + + Dim Respuesta As Boolean = False + + Dim RetIVADetalles As Decimal = TmpDT.SUMD("RetIVA", " RetIVA > 0 ") + Dim DiferenciaRetIVA As Decimal = RetIVA - RetIVADetalles + + If Math.Abs(DiferenciaRetIVA) > 0 Then + If Math.Abs(DiferenciaRetIVA) <= 0.05 Then + + Dim DTConsulta As New DataTable + DTConsulta = TmpDT.FiltraParametros(" RetIVA > 0 ") + + If DTConsulta.Rows.Count > 0 Then + + Dim IndiceContador As Integer = 0 + Dim IndiceUltimo As Integer = 0 + Dim CantidadRegistroConRetIVA As Decimal + + For Each dRow As DataRow In TmpDT.Rows + If dRow("RetIVA").ToString.ToDecimal > 0 Then + IndiceUltimo = IndiceContador + CantidadRegistroConRetIVA = CantidadRegistroConRetIVA + 1 + End If + IndiceContador = IndiceContador + 1 + Next + + RetIVADetalles = TmpDT.SUMD("RetIVA", " RetIVA > 0 ") + DiferenciaRetIVA = RetIVA - RetIVADetalles + + If Math.Abs(DiferenciaRetIVA) > 0.0D Then + + If (TmpDT.Rows(IndiceUltimo)("RetIVA").ToString.ToDecimal + DiferenciaRetIVA) < 0 Then + + Dim AjusteteDividido As Decimal = Math.Abs(DiferenciaRetIVA) / CantidadRegistroConRetIVA + + For Each dRow As DataRow In TmpDT.Rows + dRow("RetIVA") = dRow("RetIVA").ToString.ToDecimal - AjusteteDividido + Next + + Else + TmpDT.Rows(IndiceUltimo)("RetIVA") = TmpDT.Rows(IndiceUltimo)("RetIVA").ToString.ToDecimal + DiferenciaRetIVA + End If + + TmpDT.AcceptChanges() + + End If + + End If + + 'Revalidacion de ajuste + RetIVADetalles = TmpDT.SUMD("RetIVA", " RetIVA > 0 ") + DiferenciaRetIVA = RetIVA - RetIVADetalles + + If Math.Abs(DiferenciaRetIVA) > 0.01D Then + Respuesta = False + If RetIVADetalles > 0 Then + + For Each dRow As DataRow In TmpDT.Rows + If dRow("RetIVA").ToString.ToDecimal > 0 Then + dRow("RetIVA") = dRow("RetIVA").ToString.ToDecimal + DiferenciaRetIVA + TmpDT.AcceptChanges() + Respuesta = True + Exit For + End If + Next + + Else + Errores.AppendLine("Los productos especificados en el listado no tienen asignado impuesto RetIVA, favor de realizar la corrección en el producto que aplique el impuesto.") + Respuesta = False + End If + Else + Respuesta = True + End If + + Else + Errores.AppendLine($"existe una diferencia de {DiferenciaRetIVA} entre el RetIVA de la compra y los detalles.") + End If + Else + Respuesta = True + + End If + + Return Respuesta + + End Function + + Private Function AjustaRetISR() As Boolean + + Dim Respuesta As Boolean = False + + Dim RetISRDetalles As Decimal = TmpDT.SUMD("RetISR", " RetISR > 0 ") + Dim DiferenciaRetISR As Decimal = RetISR - RetISRDetalles + + If Math.Abs(DiferenciaRetISR) > 0 Then + If Math.Abs(DiferenciaRetISR) <= 0.05 Then + + Dim DTConsulta As New DataTable + DTConsulta = TmpDT.FiltraParametros(" RetISR > 0 ") + + If DTConsulta.Rows.Count > 0 Then + + Dim IndiceContador As Integer = 0 + Dim IndiceUltimo As Integer = 0 + Dim CantidadRegistroConRetISR As Decimal + + For Each dRow As DataRow In TmpDT.Rows + If dRow("RetISR").ToString.ToDecimal > 0 Then + IndiceUltimo = IndiceContador + CantidadRegistroConRetISR = CantidadRegistroConRetISR + 1 + End If + IndiceContador = IndiceContador + 1 + Next + + RetISRDetalles = TmpDT.SUMD("RetISR", " RetISR > 0 ") + DiferenciaRetISR = RetISR - RetISRDetalles + + If Math.Abs(DiferenciaRetISR) > 0.0D Then + + If (TmpDT.Rows(IndiceUltimo)("RetISR").ToString.ToDecimal + DiferenciaRetISR) < 0 Then + + Dim AjusteteDividido As Decimal = Math.Abs(DiferenciaRetISR) / CantidadRegistroConRetISR + + For Each dRow As DataRow In TmpDT.Rows + dRow("RetISR") = dRow("RetISR").ToString.ToDecimal - AjusteteDividido + Next + + Else + TmpDT.Rows(IndiceUltimo)("RetISR") = TmpDT.Rows(IndiceUltimo)("RetISR").ToString.ToDecimal + DiferenciaRetISR + End If + + TmpDT.AcceptChanges() + + End If + + End If + + 'Revalidacion de ajuste + RetISRDetalles = TmpDT.SUMD("RetISR", " RetISR > 0 ") + DiferenciaRetISR = RetISR - RetISRDetalles + + If Math.Abs(DiferenciaRetISR) > 0.01D Then + Respuesta = False + If RetISRDetalles > 0 Then + + For Each dRow As DataRow In TmpDT.Rows + If dRow("RetISR").ToString.ToDecimal > 0 Then + dRow("RetISR") = dRow("RetISR").ToString.ToDecimal + DiferenciaRetISR + TmpDT.AcceptChanges() + Respuesta = True + Exit For + End If + Next + + Else + Errores.AppendLine("Los productos especificados en el listado no tienen asignado impuesto RetISR, favor de realizar la corrección en el producto que aplique el impuesto.") + Respuesta = False + End If + Else + Respuesta = True + End If + + Else + Errores.AppendLine($"existe una diferencia de {DiferenciaRetISR} entre el RetISR de la compra y los detalles.") + Respuesta = False + End If + Else + Respuesta = True + End If + + Return Respuesta + + End Function + + Private Function AgregaIEPSReembolso(CvePS As Integer) As Boolean + + Dim respuesta As Boolean = True + + If IEPSGasto Or OtrosImpuestosGasto Then + + 'AGREGA IEPS COMO CONCEPTO + If IEPSGasto Then + AgregarConceptoIEPS(TrasladoIEPS, CvePS) + For Each Dr As DataRow In TmpDT.Rows + Dr("IEPSPS") = 0 + Dr("IEPSPSPorcentaje") = 0 + Next + TmpDT.AcceptChanges() + End If + 'AGREGA OTROS IMPUESTOS COMO CONCEPTO + If OtrosImpuestosGasto Then + AgregarConceptoIEPS(OtrosImpuestos, CvePS) + End If + Else + respuesta = False + Errores.AppendLine("Debe seleccionar al menos un impuesto. ") + End If + CalculaTotales() + + Return respuesta + + End Function + + + Private Sub AgregarConceptoIEPS(IEPS As Decimal, CvePS1 As Integer) + Dim SubTotalR As Decimal = TmpDT.SUM("Total").ToString.ToDecimal + + Dim PSS As DataTable = GlobalDTPS(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CvePS = {0} ", CvePS1), "PS") + Dim PSS2 As DataTable = TmpDT.FiltraParametros(String.Format("CvePS = {0} ", CvePS1), "PS") + + If PSS.Rows.Count > 0 Or PSS2.Rows.Count > 0 Then + Dim CveUM As Integer = 0 + Dim UM As String = "" + Dim CveClasificacion As Integer = 0 + Dim Clasificacion As String = "" + Dim CvePS As Integer = 0 + Dim PS As String = "" + Dim CveTipoPS As Integer = 0 + + If PSS.Rows.Count > 0 Then + CveUM = PSS.Rows(0)("CveUM").ToString.ToEntero + UM = PSS.Rows(0)("UnidadMedida").ToString + CveClasificacion = PSS.Rows(0)("CveClasificacion").ToString.ToEntero + Clasificacion = PSS.Rows(0)("Clasificacion").ToString + CvePS = PSS.Rows(0)("CvePS").ToString.ToEntero + PS = PSS.Rows(0)("PS").ToString + CveTipoPS = PSS.Rows(0)("CveTipoPS").ToString.ToEntero + End If + + Dim Cantidad As Decimal = 1 + Dim CveSubProyectoContrato As String = "-1" + Dim CveProyecto As String = "-1" + Dim SubProyecto As String = "SE" + Dim Proyecto As String = "SE" + Dim Obs As String = "" + Dim PU As Decimal = IEPS + Dim Total As Decimal = Cantidad * PU + Dim IVA As Decimal = 0 + Dim Descuento As Decimal = 0 + + If PSS2.Rows.Count > 0 Then + CveUM = PSS2.Rows(0)("CveUM").ToString.ToEntero + UM = PSS2.Rows(0)("UM").ToString + CveClasificacion = PSS2.Rows(0)("CveClasificacion").ToString.ToEntero + Clasificacion = PSS2.Rows(0)("Clasificacion").ToString + CvePS = PSS2.Rows(0)("CvePS").ToString.ToEntero + PS = PSS2.Rows(0)("PS").ToString + CveTipoPS = PSS2.Rows(0)("CveTipoPS").ToString.ToEntero + + CveSubProyectoContrato = PSS2.Rows(0)("CveSubProyecto").ToString + CveProyecto = PSS2.Rows(0)("CveProyecto").ToString + SubProyecto = PSS2.Rows(0)("SubProyecto").ToString + Proyecto = PSS2.Rows(0)("Proyecto").ToString + Obs = PSS2.Rows(0)("Obs").ToString + + Dim CveTipoGasto As Integer = PSS2.Rows(0)("CveTipoGasto").ToString.ToEntero + Dim TipoGasto As String = PSS2.Rows(0)("TipoGasto").ToString + + AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, 0, 0, 0, 0, Descuento, TCalculaTotales:=False, CveTipoGasto:=CveTipoGasto, + TipoGasto:=TipoGasto, ModalidadAccionPS:=EnumModalidadAccionPS.Agregar) + + Else + AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, 0, 0, 0, 0, Descuento, TCalculaTotales:=False) + End If + End If + + Dim SubTotalIEPS As Decimal = TmpDT.SUMD("Total") + + Me.SubTotal = Math.Round(SubTotalIEPS, 2) + Me.SubTotalConceptos = Math.Round(SubTotalIEPS, 2) + + PSS.Dispose() + End Sub + + Private Function AddPS(Cantidad As Decimal, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, CvePS As Integer, PS As String, CveTipoPS As Integer, CveSubProyectoContrato As String, SubProyecto As String, Proyecto As String, CveProyecto As String, + Obs As String, PU As Decimal, Total As Decimal, IVA As Decimal, RetIVA As Decimal, RetISR As Decimal, IEPSPS As Decimal, IEPSPSIVA As Decimal, Descuento As Decimal, Optional CveOrdenCompraDetalle As Integer = -1, Optional TCalculaTotales As Boolean = True, + Optional PSCodigo As String = "-", Optional PSDescripcion As String = "-", Optional CantidadF As Double = -1, Optional EntregaDirecta As Integer = -1, Optional OtrosGastos As Decimal = 0, + Optional CveSATPS As Integer = -1, Optional CargaXml As Boolean = False, Optional CveTipoGasto As Integer = -1, Optional TipoGasto As String = "", Optional PorcentajeIVA As Decimal = 0, + Optional PorcentajeIEPS As Decimal = 0, Optional PorcentajeRetIVA As Decimal = 0, Optional PorcentajeRetISR As Decimal = 0, Optional NoDeducible As Boolean = False, Optional CveContratoDetalle As Integer = -1, Optional CveCultivoCuadroDetalle As Integer = -1, + Optional CveSATPSActualizado As Boolean = False, Optional TemporadaCuadro As String = "", Optional ModalidadAccionPS As EnumModalidadAccionPS = EnumModalidadAccionPS.Agregar, Optional Con As Integer = -1, + Optional CveProgramaOperativo As Integer = -1, Optional CveUnidadAdministrativa As Integer = -1, Optional CveFuenteFinanciamiento As Integer = -1, Optional CveTipoGastoAC As Integer = -1, Optional CveClasificacionOG As Integer = -1) As Integer + + Dim Row As DataRow = Nothing + + Row = TmpDT.NewRow() + Dim Retorno As Integer = 0 + Dim CveContrato As Integer = -1 + Dim CveSubProyecto As Integer = -1 + Dim Valores As String() + + ''CONTRATOS + If CveSubProyectoContrato.Contains("|"c) Then + Valores = CveSubProyectoContrato.Split("|"c) + CveContrato = Valores(1).ToEntero + CveSubProyecto = Valores(0).ToEntero + Else + CveSubProyecto = CveSubProyectoContrato.ToEntero + End If + + 'DR PS + Dim DrPS As DataRow = Nothing + If CvePS > 0 Then + DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).Rows(0) + End If + + If DrPS IsNot Nothing Then + Row("PSCodigo") = If(PSCodigo = "", DrPS("PSCodigo").ToString, PSCodigo) + Row("CveMetodoInventario") = DrPS("Inv_CveMetodoInventario").ToString.ToEntero + + If CveTipoCompra = EnumTipoCompra.Garantia AndAlso DrPS("AplicaSerie").ToString = "True" Then + Row("CveMetodoInventario") = "1" + End If + + Else + Row("PSCodigo") = PSCodigo + Row("CveMetodoInventario") = 0 + End If + + If ModalidadAccionPS = EnumModalidadAccionPS.Actualizar Then + Row("Consec") = Con + Else + Row("Consec") = TmpDT.Rows.Count + 1 + End If + + If (CFDIVersion = EnumCFDIVersion.V33 Or CFDIVersion = EnumCFDIVersion.V40) And CveSATPS > 0 Then + Dim DrPSSAT As DataRow = Nothing + If CargaXml Then + DrPSSAT = GlobalDTPSATPS("-1", CveSATPS.ToString).FiltroPrimero("") + Else + DrPSSAT = GlobalDTPSATPS("-1", CveSATPS.ToString).FiltroPrimero("") + End If + If DrPSSAT IsNot Nothing Then + Row("SATClaveProductoServicio") = DrPSSAT("SATClaveProductoServicio").ToString + Row("CveSATPS") = DrPSSAT("CveSATPS").ToString + If CveSATPSActualizado Then + Row("CveSATPSActualizado") = 1 + Else + Row("CveSATPSActualizado") = 0 + End If + End If + End If + + Try + If (DrPS("CvePSCargo").ToString <> "") Then 'si es un producto de usado. que se registre contablemente como alamcen(como producto) + CveTipoPS = 2 + End If + Catch ex As Exception + + End Try + + Dim DecimalesPermitidos As Integer = 6 + + Row("CveConcepto") = TmpDT.Rows.Count + 1 + Row("Cantidad") = Math.Round(Cantidad, DecimalesPermitidos) + Row("CantidadF") = If(CantidadF = -1, Math.Round(Cantidad, DecimalesPermitidos), Math.Round(CantidadF, DecimalesPermitidos)) + Row("CveUM") = CveUM + Row("UM") = UM + Row("CveClasificacion") = CveClasificacion + Row("CveClasificacionActualizar") = CveClasificacion + Row("Clasificacion") = Clasificacion + Row("CvePS") = CvePS + Row("PS") = PS + Row("CveTipoPS") = CveTipoPS + + Row("PSDescripcion") = PSDescripcion + Row("CveSubProyecto") = CveSubProyecto.ToEntero + Row("CveProyecto") = CveProyecto.ToEntero + Row("CveContrato") = CveContrato.ToEntero + Row("SubProyecto") = If(SubProyecto = "Seleccione", "Sin Sub Proyecto", SubProyecto) + Row("Proyecto") = If(Proyecto = "Seleccione", "Sin Proyecto", Proyecto) + Row("CveActivoFijo") = -1 + Row("Obs") = Obs + Row("CveActivoFijo") = -1 + Row("CodAF") = "-1" + Row("TipoAF") = -1 + Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle + Row("EntregaDirecta") = EntregaDirecta + + Row("NoDeducible") = NoDeducible + + + Total = Math.Round(PU, DecimalesPermitidos) * Cantidad - Descuento + Row("PU") = Math.Round(PU, DecimalesPermitidos) + If CargaXml And (CFDIVersion = EnumCFDIVersion.V33 Or CFDIVersion = EnumCFDIVersion.V40) Then + + If CveFactura > 0 And IVA = 0 Then + Row("IVA") = 0 + Row("IVAPorcentaje") = 0 + Else + Row("IVA") = Math.Round(IVA, DecimalesPermitidos) + Row("IVAPorcentaje") = PorcentajeIVA + End If + + Row("RetIVA") = Math.Round(RetIVA, DecimalesPermitidos) + Row("RetIVAPorcentaje") = PorcentajeRetIVA + Row("RetISR") = Math.Round(RetISR, DecimalesPermitidos) + Row("RetISRPorcentaje") = PorcentajeRetISR + Row("IEPSPS") = Math.Round(IEPSPS, DecimalesPermitidos) + Row("IEPSPSPorcentaje") = PorcentajeIEPS + Else + 'If DdlIVA.SelectedValue.ToDouble = 0 Then Row("IVA") = 0 Else Row("IVA") = Math.Round(IVA * Total, DecimalesPermitidos) + + If CveFactura > 0 And IVA = 0 Then + Row("IVA") = 0 + Row("IVAPorcentaje") = 0 + Else + Row("IVA") = (IVA * Total).RoundSQL + Row("IVAPorcentaje") = IVA + End If + + Row("RetIVA") = (RetIVA * Total).RoundSQL + Row("RetIVAPorcentaje") = RetIVA + Row("RetISR") = (RetISR * Total).RoundSQL + Row("RetISRPorcentaje") = RetISR + Row("IEPSPS") = (IEPSPS * Total).RoundSQL + Row("IEPSPSPorcentaje") = IEPSPS + End If + + Row("ImporteConImpuestos") = (Row("Cantidad").ToString.ToDecimal * Row("PU").ToString.ToDecimal) + Row("IVA").ToString.ToDecimal + Row("IEPSPS").ToString.ToDecimal - (Row("RetIVA").ToString.ToDecimal + Row("RetISR").ToString.ToDecimal) + Row("ImporteSinImpuestos") = Row("Cantidad").ToString.ToDecimal * Row("PU").ToString.ToDecimal + + Row("IEPSPSIVA") = Math.Round(IEPSPSIVA * Total, DecimalesPermitidos) + Row("IEPSPSIVAPorcentaje") = IEPSPSIVA + Row("Descuento") = Math.Round(Descuento, DecimalesPermitidos) + Row("OtrosGastos") = Math.Round(OtrosGastos, DecimalesPermitidos) + Row("Total") = Math.Round(Total, DecimalesPermitidos) + + Row("CveTipoGasto") = CveTipoGasto + Row("TipoGasto") = If(CveTipoGasto > 0, TipoGasto, "") + + Row("CveContratoDetalle") = CveContratoDetalle + + Row("CveCultivoCuadroDetalle") = CveCultivoCuadroDetalle + Row("TemporadaCuadro") = TemporadaCuadro + + If UsuarioActual.Empresa.UsaAC Then + Row("CveProgramaOperativo") = CveProgramaOperativo + Row("CveUnidadAdministrativa") = CveUnidadAdministrativa + Row("CveFuenteFinanciamiento") = CveFuenteFinanciamiento + Row("CveTipoGastoAC") = CveTipoGastoAC + Row("CveClasificacionOG") = CveClasificacionOG + End If + 'Esta parte es para validar cuando la factura tenga ieps en o se asignara el ieps como una partida ya no se considere + If (CveFactura > 0 Or CveCompra > 0) And IEPS = 0 Then + Row("IEPSPS") = 0 + Row("IEPSPSPorcentaje") = 0 + End If + TmpDT.Rows.Add(Row) + TmpDT.Rows.IndexOf(Row) + + If TCalculaTotales Then + CalculaTotales(True) + End If + + Return Retorno + End Function + + Private Sub CalculaTotales(Optional CalculaIVA As Boolean = False, Optional EsNoDeducible As Boolean = False) + 'VARIABLES DE CALCULO + Dim LocalSubTotal, LocalDescuentos, LocalAmortizacion, LocalIVA, LocalSubTotal2, LocalRetIVA, LocalRetISR, LocalIEPSPS, LocalTotal, LocalSubTotalIVA, LocalSubTotalIEPSIVA As Decimal + + 'HACEMOS CALCULOS + LocalSubTotalIVA = TmpDT.SUMD("IVA") + LocalSubTotalIEPSIVA = TmpDT.SUMD("IEPSPSIVA") + LocalSubTotal = (TmpDT.SUMD("Total") + TmpDT.SUMD("Descuento")).RoundSQL(8) + LocalRetIVA = TmpDT.SUMD("RetIVA") + LocalRetISR = TmpDT.SUMD("RetISR") + LocalIEPSPS = TmpDT.SUMD("IEPSPS") + + If CveCompra > 0 AndAlso CveFactura > 0 Then + LocalIVA = IVA + Else + LocalIVA = If(TmpDT.SUM("IVA") > 0, LocalSubTotalIVA + LocalSubTotalIEPSIVA, 0) + End If + + LocalDescuentos = TmpDT.SUMD("Descuento") + + If Not CveCompra > 0 Then + LocalAmortizacion = Me.Amortizacion + End If + + 'RETENCIONES + Dim Retenciones As Decimal = 0 + Retenciones = LocalRetIVA + Retenciones += LocalRetISR + + + LocalSubTotal2 = LocalSubTotal - LocalDescuentos + LocalTotal = LocalSubTotal2 + LocalIVA + LocalIEPSPS - Retenciones + + 'ASIGNAMOS VALORES A VISTA + If CveCompra > 0 Or CveFactura > 0 Or Me.OCVinculada Then + SubTotal = LocalSubTotal + SubTotal2 = LocalSubTotal2 + Descuento = LocalDescuentos + + If EsNoDeducible Then + IVA = LocalIVA + RetIVA = LocalRetIVA + RetISR = LocalRetISR + IEPS = LocalIEPSPS + End If + + Total = LocalTotal + Else + SubTotal = LocalSubTotal + SubTotal2 = LocalSubTotal2 + IVA = LocalIVA + Descuento = LocalDescuentos + RetIVA = LocalRetIVA + RetISR = LocalRetISR + IEPS = LocalIEPSPS + Total = LocalTotal + 'VALORES PROPIEDAD + CompraSaldo = LocalTotal + + End If + Me.NumNoDed = TmpDT.COUNT("CvePS", "NoDeducible = True ") + + End Sub + + Private Function UpdatePSReembolso(Index As Integer, CvePS As Integer) As Boolean + + Dim Respuesta As Boolean = True + + Dim DrPS As DataRow = Nothing + Try + DrPS = TmpDT.Select($"Consec = {Index}")(0) + If DrPS Is Nothing Then + Errores.AppendLine($"No se encontrol el producto con index {Index}") + Return False + End If + Catch ex As Exception + Errores.AppendLine($"No se encontrol el producto con index {Index}") + Return False + End Try + + 'DATOS GENERALES + DrPS("Obs") = "" + DrPS("Proyecto") = Proyecto + DrPS("CveProyecto") = CveProyecto + DrPS("SubProyecto") = SubProyecto + DrPS("CveSubProyecto") = CveSubProyecto + DrPS("CveContratoDetalle") = -1 + + 'IMPORTES - [CANTIDAD Y PRECIO] + Dim Cantidad As Double = DrPS("Cantidad").ToString.ToDouble + Dim PU As Double = DrPS("PU").ToString.ToDouble + Dim Descuento As Double = DrPS("Descuento").ToString.ToDouble + Dim Total As Double = (Cantidad * PU) - Descuento + DrPS("NoDeducible") = NoDeducible + + Dim PSRow As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") + If PSRow IsNot Nothing Then + Dim CveTipoPS As Integer = PSRow("CveTipoPS").ToString.ToEntero + If PSRow("CvePSCargo").ToString <> "" Then 'si es un producto de usado. que se registre contablemente como alamcen(como producto) + CveTipoPS = 2 + End If + + DrPS("CveClasificacion") = PSRow("CveClasificacion").ToString + DrPS("Clasificacion") = PSRow("Clasificacion").ToString + DrPS("CvePS") = CvePS + DrPS("PS") = PSRow("PS").ToString + DrPS("CveTipoPS") = CveTipoPS + DrPS("CveSATPS") = PSRow("CveSATPS").ToString.ToEntero + DrPS("SATClaveProductoServicio") = PSRow("SATClaveProductoServicio").ToString + DrPS("CveSATPSActualizado") = 0 + + DrPS("CveUM") = PSRow("CveUnidadMedida").ToString.ToEntero + DrPS("UM") = PSRow("UnidadMedida").ToString + + Dim DrTipoGasto As DataRow = Me.DTTiposGastos.FiltroPrimero("") + + DrPS("CveTipoGasto") = DrTipoGasto("CveTipoGasto") + DrPS("TipoGasto") = DrTipoGasto("TipoGasto") + + If UsuarioActual.Empresa.Funcionalidad(562).ToEntero > 0 Then + DrPS("AplicaCostoIndirecto") = "0" + End If + + DrPS("CveCultivoCuadroDetalle") = -1 + DrPS("TemporadaCuadro") = "" + + Else + Errores.AppendLine($"No se encontrol el producto con CvePS {CvePS}") + Respuesta = False + End If + TmpDT.AcceptChanges() + Return Respuesta + End Function + + Private Sub ValidacionesTotalesXml() + + If Not TmpDT.Columns.Contains("Amortizacion") Then + TmpDT.Columns.Add("Amortizacion", GetType(Decimal)) + End If + + Dim Msg As String = "" + Dim SubtotalTemp As Decimal = TmpDT.SUMD("Total") + Math.Round(TmpDT.SUM("Descuento") + Math.Round(TmpDT.SUM("Amortizacion")), 2) + Dim DescuentosTemp As Decimal = TmpDT.SUMD("Descuento") + Dim Subtotal2Temp As Decimal = TmpDT.SUMD("Total") + Dim IVATemp As Decimal = TmpDT.SUMD("IVA") + Dim IEPSTemp As Decimal = TmpDT.SUMD("IEPSPS") + Dim RetIVATemp As Decimal = TmpDT.SUMD("RetIVA") + Dim RetISRTemp As Decimal = TmpDT.SUMD("RetISR") + Dim TotalTemp As Decimal = Subtotal2Temp - RetIVATemp - RetISRTemp + Math.Round(IVATemp, 6) + IEPSTemp + OtrosImpuestos - OtrosImpuestosRetenciones + + If Math.Abs(Math.Round(DescuentosTemp, 6) - Math.Round(Descuento, 6)) > 0.01 Then + Msg &= String.Format("- Los descuentos del detalle no coinciden con el descuento general
") + End If + + If Math.Abs(Math.Round(IVATemp, 6) - Math.Round(TrasladoIVA, 6)) > 0.01 Then + Msg &= String.Format("- Los IVAS del detalle no coinciden con el IVA general
") + End If + + If Math.Abs(Math.Round(IEPSTemp, 6) - Math.Round(TrasladoIEPS, 6)) > 0.01 Then + Msg &= String.Format("- Los IEPS del detalle no coinciden con el IEPS general
") + End If + + If Math.Abs(Math.Round(RetIVATemp, 6) - Math.Round(RetencionIVA, 6)) > 0.01 Then + Msg &= String.Format("- Los RetIVA del detalle no coinciden con el RetIVA general
") + End If + + If Math.Abs(Math.Round(RetISRTemp, 6) - Math.Round(RetencionISR, 6)) > 0.01 Then + Msg &= String.Format("- Las RetISR del detalle no coinciden con el RetIVA general
") + End If + + If Math.Abs(Math.Round(TotalTemp, 2) - Math.Round(Total, 2)) > 0.01 Then + Msg &= String.Format("- El total generado por los detalles no coincide con el total general
({0}-{1})", Math.Round(TotalTemp, 2), Math.Round(Total, 2)) + End If + + If Msg <> "" Then + Errores.AppendLine($" El comprobante XML presenta las siguientes inconsistencias:{Msg}. ") + Else + + DescuentosTemp = Descuento + IVATemp = TrasladoIVA + TotalTemp = Total + RetIVATemp = RetencionIVA + RetISRTemp = RetencionISR + IEPSTemp = TrasladoIEPS + End If + + Me.SubTotal = SubtotalTemp + Me.Descuento = DescuentosTemp + Me.SubTotal2 = Subtotal2Temp + Me.IVA = IVATemp + Me.Total = TotalTemp + Me.RetIVA = RetIVATemp + Me.RetISR = RetISRTemp + Me.IEPS = IEPSTemp + CompraSaldo = TotalTemp + + AsignaValoresOriginales(SubtotalTemp, Subtotal2Temp, IVATemp, RetIVATemp, RetISRTemp, Total) + + End Sub + + Private Sub AsignaValoresOriginales(SubTotal As Decimal, SubTotal2 As Double, IVA As Decimal, RetIVA As Decimal, RetISR As Decimal, Total As Decimal) + SubTotalOriginal = SubTotal + SubTotal2Original = SubTotal2 + IVAOriginal = IVA + RetIVAOriginal = RetIVA + RetISROriginal = RetISR + TotalOriginal = Total + End Sub + + Private Sub AjustaImporteUltimoConcepto(ImporteAjuste As Decimal, Optional EsCarga As Boolean = False) + + If ImporteAjuste = 0 Then Exit Sub + + Dim Amortizacion As Decimal = 0 + + If TmpDT.Rows.Count > 0 Then ' si hay movimientos y si esta afectando al total, que se haga el ajuste + Dim Indice As Integer = If(TmpDT.Rows(TmpDT.Rows.Count - 1)("CvePS").ToString = UsuarioActual.Empresa.Funcionalidad(112).ToString, TmpDT.Rows.Count - 2, TmpDT.Rows.Count - 1) + Dim tPU As Decimal + + If TmpDT.Rows(Indice)("Cantidad").ToString.ToDecimal > 0 Then + tPU = ImporteAjuste / TmpDT.Rows(Indice)("Cantidad").ToString.ToDecimal + Else + tPU = 0 + End If + + If TmpDT.Rows(Indice)("PU").ToString.ToDecimal + tPU < 0 Then 'si es negativo, que tome el dato anterior + Indice = Indice - 1 + If TmpDT.Rows(Indice)("Cantidad").ToString.ToDecimal > 0 Then + tPU = ImporteAjuste / TmpDT.Rows(Indice)("Cantidad").ToString.ToDecimal + Else + tPU = 0 + End If + End If + + TmpDT.Rows(Indice)("PU") = TmpDT.Rows(Indice)("PU").ToString.ToDecimal + tPU + TmpDT.Rows(Indice)("Total") = TmpDT.Rows(Indice)("Total").ToString.ToDecimal + ImporteAjuste + TmpDT.Rows(Indice)("IEPSPS") = (TmpDT.Rows(Indice)("Total").ToString.ToDecimal() * TmpDT.Rows(Indice)("IEPSPSPorcentaje").ToString.ToDecimal()).RoundAD(2) + TmpDT.Rows(Indice)("IVA") = (TmpDT.Rows(Indice)("PU").ToString.ToDecimal * TmpDT.Rows(Indice)("Cantidad").ToString.ToDecimal - TmpDT.Rows(Indice)("Descuento").ToString.ToDecimal) * TmpDT.Rows(Indice)("IVAPorcentaje").ToString.ToDecimal + TmpDT.AcceptChanges() + End If + + SubTotal = TmpDT.SUMD("Total") + If Not EsCarga Then + Descuento = TmpDT.SUMD("Descuento") + End If + + SubTotalConceptos = SubTotal + + End Sub + + Public Function ValidateUUID(ByVal uuid As String) As Boolean + Dim pattern As String = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" + Dim regex As New Regex(pattern) + Return regex.IsMatch(uuid) + End Function + Private Function GeneraStringDoctosRelacionados() As String + + Dim DoctosRelacionados As String = "-1" + Dim listaUUIDSRelacionados As New List(Of String) + + If DocumentosRelacionadosUUIDSList.Count > 0 Then + For Each s As String In DocumentosRelacionadosUUIDSList + If s.Trim.Length > 0 Then + listaUUIDSRelacionados.Add(s.Trim) + End If + Next + End If + + If listaUUIDSRelacionados.Count > 0 Then + DoctosRelacionados = String.Join(",", listaUUIDSRelacionados.ToArray()) + End If + + Return DoctosRelacionados + End Function + Private Function ValorXML(n As XmlNode, Campo As String, Optional Retorno As String = "") As String + Dim o As XmlNode = n.Attributes.Cast(Of XmlAttribute)().SingleOrDefault(Function(a) String.Compare(a.Name, Campo, True) = 0) + If o Is Nothing Then + Return Retorno + Else + Return o.Value + End If + End Function + + Public Function AddCompra() As Boolean + + If Not AjustesValidacion() Then Return False + + Dim respuesta As Boolean = True + Dim ObjCompras As New ClsCompras + Dim ObjConta As New ClsContabilidad(ObjCompras.IniciaTransacSQL()) + + If Not AddPrepolizaCabecera(ObjConta) Then + respuesta = False + End If + + If respuesta AndAlso ObjCompras.AddCompra(If(Me.TipoComprobante = "I", "Fac", "NC"), Me.Descripcion, Me.Serie, Me.Folio, Me.FolioSecundario, Me.CveProveedor, Me.SubTotal, Me.Descuento, + Me.Amortizacion, Me.IVA, Me.RetIVA, Me.RetISR, Me.IEPS, Me.OtrosImpuestos, + Me.Redondeo, Me.Total, Me.Fecha, Me.CveMoneda, Me.TipoCambio, If(Me.FechaPago = Nothing, Me.Fecha, Me.FechaPago), Me.AplicaNotaCredito, Me.Observaciones, Me.CveEstatusFactura, + Me.CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Me.IdPoliza, CveCajaChica:=Me.CveCajaChica, CvePersonal:=Me.CvePersonal, NumeroReembolso:=Me.NumeroReembolso, CveProveedorSucursal:=Me.CveProveedorSucursal, + AplicoPromocion:=Me.AplicoPromocion, PorcentajeIVA:=Me.PorcentajeIVA, CveMetodoPago:=Me.CveMetodoPago, CveRetIVAConcepto:=Me.CveRetIVAConcepto, + CveConceptoContableAlmacen:=Me.CveConceptoContableAlmacen, + CveRetISRConcepto:=Me.CveRetISRConcepto, NoDeducible:=Me.NoDeducible, CveTipoCompra:=Me.CveTipoCompra, TotalOriginal:=Me.TotalOriginal, CveTipoConcepto:=Me.CveTipoConcepto, + EsImportacion:=Me.EsImportacion, CveFactura:=Me.CveFactura, CveSubProyecto:=Me.CveSubProyectoPrincipal, DoctosRelacionados:=Me.DocumentosRelacionadosUUIDSString, CveFolioGarantia:=Me.CveFolioGarantia) Then + Me.CveCompra = ObjCompras.CveCompra + Else + respuesta = False + End If + + If respuesta AndAlso Me.CveCompra > 0 Then + + For Each Row As DataRow In Me.TmpDT.Rows + + Dim TipoRecepcion As Integer = -1 + Dim Referencia As String = "" + Dim EsNoDeducible As Boolean = False + Dim CveAF As Integer = If(Row("CveActivoFijo").ToString.ToEntero > 0 AndAlso Row("TipoAF").ToString.ToEntero = 1, Row("CveActivoFijo").ToString.ToEntero, -1) + Dim CveAFC As Integer = If(Row("CveActivoFijo").ToString.ToEntero > 0 AndAlso Row("TipoAF").ToString.ToEntero = 2, Row("CveActivoFijo").ToString.ToEntero, -1) + + If Not ObjCompras.AddCompraDetalle(Me.CveCompra, Row("CveUM").ToString.ToEntero, Row("CvePS").ToString.ToEntero, Row("CveSubProyecto").ToString.ToEntero, -1, CveAF, + Row("Cantidad").ToString.ToDecimal, Row("PU").ToString.ToDecimal, Row("IVA").ToString.ToDecimal, Row("Total").ToString.ToDecimal, Row("Descuento").ToString.ToDecimal, + Row("Obs").ToString, Row("CveOrdenCompraDetalle").ToString.ToEntero, TipoRecepcion, Row("CveContrato").ToString.ToEntero, Row("CvePresupuestoEgreso").ToString.ToEntero, + AplicaCostoIndirecto:=Row("AplicaCostoIndirecto").ToString.ToEntero, EstatusAlmacen:=Row("EntregaDirecta").ToString.ToEntero, CvePersonal:=CvePersonal, + CveTipoGasto:=Row("CveTipoGasto").ToString.ToEntero, AF_Medida:=Row("AFMedida").ToString.ToEntero, AF_TipoMantenimiento:=Row("AFTipoMantenimiento").ToString.ToEntero, Referencia:=Referencia, OtrosGastos:=Row("OtrosGastos").ToString.ToDecimal, + RetIVA:=Row("RetIVA").ToString.ToDecimal, RetISR:=Row("RetISR").ToString.ToDecimal, IEPSPS:=Row("IEPSPS").ToString.ToDecimal.RoundSQL, IEPSPSIVA:=Row("IEPSPSIVA").ToString.ToDecimal, + IVAPorcentaje:=Row("IVAPorcentaje").ToString.ToDecimal, RetIVAPorcentaje:=Row("RetIVAPorcentaje").ToString.ToDecimal, RetISRPorcentaje:=Row("RetISRPorcentaje").ToString.ToDecimal, + IEPSPSPorcentaje:=Row("IEPSPSPorcentaje").ToString.ToDecimal, IEPSPSIVAPorcentaje:=Row("IEPSPSIVAPorcentaje").ToString.ToDecimal, NoDeducible:=If((Row("NoDeducible").ToString().ToUpper().Contiene("TRUE", "1")) AndAlso EsNoDeducible, True, False), + CveContratoDetalle:=Row("CveContratoDetalle").ToString.ToEntero, CveCultivoCuadroDetalle:=Row("CveCultivoCuadroDetalle").ToString.ToEntero, CveActivoFijoCompra:=CveAFC) Then + + respuesta = False + Exit For + End If + Next + End If + + If respuesta Then + If Not AddPrePolizaDetalles(ObjConta) Then respuesta = False + End If + + If respuesta AndAlso ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual, 4) Then + If ObjConta.ValorPolizaDescuadre > 0 Then + Errores.AppendLine($"eFacturas/Compras-Guardar | Error{ObjConta.MensajePolizaDescuadre} Diferencia{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}.") + GuardaLogAD($"eFacturas/Compras-Guardar | Error{ObjConta.MensajePolizaDescuadre} Diferencia{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") + respuesta = False + End If + End If + + If respuesta Then + If Not ObjCompras.UpdateCompraFactura(Me.CveCompra, Me.CveFactura, Me.Serie, Me.Folio) Then respuesta = False + End If + + If respuesta Then + ObjCompras.Commit() + Else + ObjCompras.RollBack() + End If + + ObjCompras.Dispose() + ObjConta.Dispose() + + Return respuesta + End Function + + Private Function AddPrepolizaCabecera(ByRef ObjConta As ClsContabilidad) As Boolean + + Dim respuesta As Boolean = False + Dim ConceptoPoliza As String = String.Format("{0} - {1} - {2}", NombreProveedor, SerieFolio, "") + Me.CvePrePoliza = ObjConta.AddPrePolizas("eFacturas/Registrar", 1, Me.Total, Me.Total, Me.CveMoneda, Me.Fecha, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, "", CveTipoPoliza:=Me.CveTipoPoliza) + respuesta = If(Me.CvePrePoliza > 0, True, False) + + Return respuesta + End Function + + Private Function AddPrePolizaDetalles(ByRef ObjConta As ClsContabilidad) As Boolean + Dim respuesta As Boolean = True + Dim Concepto As String = $"{Me.NombreProveedor} {Me.SerieFolio}" + Dim Referencia As String = Me.SerieFolio + Dim importeMovimiento As Decimal + Dim importeMN As Decimal + '6 + For Each RowDetalle As DataRow In TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2", "", {"CveClasificacion", "CveSubProyecto"}).Rows + + importeMovimiento = TmpDT.SUMD("Total", $" CveClasificacion = {RowDetalle("CveClasificacion").ToString} AND CveSubProyecto = {RowDetalle("CveSubProyecto").ToString}") + importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL + + If importeMN <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, importeMN, 6, Referencia, Concepto, CveCompra:=CveCompra, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=Me.CveCreditoDetalle, ImporteME:=If(TipoCambio = 1, 0, importeMovimiento), TipoCambio:=TipoCambio, + CveClasificacion:=RowDetalle("CveClasificacion").ToString().ToEntero(), CveSubProyecto:=RowDetalle("CveSubProyecto").ToString().ToEntero(), Contabilizable:=True) Then + respuesta = False + Exit For + End If + End If + Next + '14 + If respuesta AndAlso Me.IVA > 0 Then + importeMovimiento = Me.IVA + importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, importeMN, 14, Referencia, Concepto, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=Me.PorcentajeIVA, Contabilizable:=True) Then + respuesta = False + End If + End If + '25 + If respuesta AndAlso Me.IEPS > 0 Then + importeMovimiento = Me.IEPS + importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, importeMN, 25, Referencia, Concepto, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=0, Contabilizable:=True) Then + respuesta = False + End If + End If + ' + If respuesta AndAlso Me.RetIVA > 0 Then + importeMovimiento = Me.RetIVA + importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL + Dim ret As ConceptosRetenciones = ConceptoPrePolizaRetIVA + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, importeMN, ret.CveConceptoxAcreditar, Referencia, Concepto, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=0, Contabilizable:=True) Then + respuesta = False + End If + End If + ' + If respuesta AndAlso Me.RetISR > 0 Then + importeMovimiento = Me.RetISR + importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL + Dim ret As ConceptosRetenciones = ConceptoPrePolizaRetISR + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, importeMN, ret.CveConceptoxAcreditar, Referencia, Concepto, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=0, Contabilizable:=True) Then + respuesta = False + End If + End If + '5 + If respuesta Then + importeMovimiento = Me.Total + importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL + Dim ConPreP As ConceptosTipoSaldo = ObtenerCveConceptoPrePoliza(1, Me.CveMoneda, False, Me.CveTipoConceptoProveedor) + Dim ImporteME As Decimal = importeMovimiento + Dim UsaComplementaria As Boolean = True + If Me.CveMoneda > 1 Then ImporteME = importeMovimiento + + If UsuarioActual.CveEmpresa.Contiene(13, 83) Then 'caso excepcional de complementarias + UsaComplementaria = False + importeMN = importeMovimiento * Me.TipoCambio + Else + importeMN = importeMovimiento + End If + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, importeMN, ConPreP.CveConcepto, Referencia, Concepto, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=0, Contabilizable:=True) Then + respuesta = False + End If + If respuesta AndAlso Me.CveMoneda > 1 AndAlso UsaComplementaria Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, (importeMovimiento * Me.TipoCambio - importeMovimiento).RoundSQL, ConPreP.CveConceptoComplementario, Referencia, Concepto, CveCompra:=Me.CveCompra, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=Me.CvePersonal, CveCompraAmortizacion:=Me.CveCompraAmortizacion, TipoCambio:=Me.TipoCambio, TipoCambioPago:=1, ImporteME:=ImporteME, CveSubProyecto:=Me.CveSubProyecto) Then + respuesta = False + End If + End If + End If + + Return respuesta + End Function + +End Class \ No newline at end of file diff --git a/App_Code/ClsCompras.vb b/App_Code/ClsCompras.vb index 6c8520fef..c3f151af4 100644 --- a/App_Code/ClsCompras.vb +++ b/App_Code/ClsCompras.vb @@ -1630,7 +1630,7 @@ Public Class ClsCompras #Region "N O T A S - C R E D I T O" - Public Function GetNotasCreditoRep(CveProveedor As Integer, Opcion As Integer, FechaI As String, FechaF As String, CveEmpresa As Integer) As Boolean + Public Function GetNotasCreditoRep(CveProveedor As Integer, Opcion As Integer, FechaI As String, FechaF As String, CveEmpresa As Integer, Optional TipoReporte As Integer = 1) As Boolean Dim Retorno As Boolean = False @@ -1642,6 +1642,8 @@ Public Class ClsCompras .Add("@FechaI", SqlDbType.VarChar).Value = FechaI .Add("@FechaF", SqlDbType.VarChar).Value = FechaF .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@TipoReporte", SqlDbType.Int).Value = TipoReporte + End With Try @@ -1656,6 +1658,9 @@ Public Class ClsCompras #End Region + + + #Region "F A C T U R A S " Public Function GetFacturas(CveFactura As Integer, Folio As String, FechaFacturaI As Date, FechaFacturaF As Date, RFC As String, Proveedor As String, FueValidado As Integer, CveResponsable As Integer, CveProveedorClasificacion As Integer, CveTipoProveedor As Integer, TipoComprobante As String, CveEmpresa As Integer, Optional Opcion As Integer = 1) As Boolean @@ -2010,6 +2015,25 @@ Public Class ClsCompras Return Retorno End Function + Public Function GetComprasPagos(CveCompra As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Comp_ComprasPagosGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCompra", SqlDbType.Int).Value = CveCompra + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al refacturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function RefacturacionPoliza(IdPoliza As Integer, CvePrePoliza As Integer, CveCompra As Integer) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Comp_RefacturacionPoliza") diff --git a/App_Code/ClsContabilidad.vb b/App_Code/ClsContabilidad.vb index 03a863762..86a7d6533 100644 --- a/App_Code/ClsContabilidad.vb +++ b/App_Code/ClsContabilidad.vb @@ -1776,7 +1776,7 @@ Public Class ClsContabilidad SqlAdapter.Fill(Data) Retorno = True Catch ex As Exception - OnError("Ocurrió un error al obtener lod datos de Concepto Contables.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + OnError("Ocurrió un error al obtener los datos de Concepto Contables.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) End Try Return Retorno @@ -1893,7 +1893,7 @@ Public Class ClsContabilidad SqlAdapter.Fill(Data) Retorno = True Catch ex As Exception - OnError("Ocurrió un error al obtener lod datos de Concepto Contables.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + OnError("Ocurrió un error al obtener los datos de Concepto Contables.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) End Try Return Retorno diff --git a/App_Code/ClsContratos.vb b/App_Code/ClsContratos.vb index 4846346b8..60795a215 100644 --- a/App_Code/ClsContratos.vb +++ b/App_Code/ClsContratos.vb @@ -420,7 +420,7 @@ Public Class ClsContratos Public Function UpdateContratos(CveContrato As Integer, NumeroContrato As String, DescripcionContrato As String, NumeroLicitacion As String, CveProveedor As Integer, CveCliente As Integer, CveProspecto As Integer, FechaInicial As DateTime, FechaFinal As DateTime, Ubicacion As String, Responsable As String, CveSubProyecto As Integer, PorIVA As Double, PorAnticipo As Double, PorAmortizacionAnticipo As Double, PorGarantia As Double, Archivo As String, Geom As String, CveContratoPadre As Integer, CveUsuario As Integer, CveEmpresa As Integer, EsPresupuestal As Boolean, Minimo As Double, Maximo As Double, Importe As Double, CveMoneda As Integer, ModalidadDetalle As Integer, - Optional CveContratosEstatus As Integer = -1, Optional CveContratoTipo As Integer = -1, Optional TipoCambio As Double = 1.0, Optional CveSucursalCliente As Integer = -1, Optional CveAlmacenOrigen As Integer = -1, Optional CveAlmacenDestino As Integer = -1, Optional PorcentajeComision As Integer = -1, + Optional CveContratosEstatus As Integer = -1, Optional CveContratoTipo As Integer = -1, Optional TipoCambio As Double = -1, Optional CveSucursalCliente As Integer = -1, Optional CveAlmacenOrigen As Integer = -1, Optional CveAlmacenDestino As Integer = -1, Optional PorcentajeComision As Integer = -1, Optional TipoGarantia As Integer = -1, Optional Folio As Integer = -1, Optional FechaVenc As Date = Nothing, Optional EstatusFianza As Integer = -1, Optional CveContratoPlantilla As Integer = -1, Optional CveCuentaEquipo As Integer = -1, Optional CveVendedor As Integer = -1, Optional Observaciones As String = "", Optional CveDireccionEnvio As Integer = -1, Optional AplicaImpuestosLocales As Boolean = False, Optional CorreoNotificacionPedDev As String = "", Optional FacturacionCicilica As Boolean = False, Optional FacturacionCiclicaAutomatico As Boolean = False, Optional DiaMesFacturacion As Integer = 1, Optional CvePeriodo As Integer = -1, Optional ObservacionesGenerales As String = "", Optional CveTipoAF As Integer = Nothing, Optional CveChofer As Integer = Nothing, Optional CveChofer2 As Integer = Nothing, Optional CveAF As Integer = Nothing, Optional CantidadPasajeros As Integer = Nothing, Optional CvePartida As Integer = Nothing, Optional CveDestino As Integer = Nothing, Optional CveMasivo As Integer = Nothing) As Boolean @@ -450,8 +450,8 @@ Public Class ClsContratos .Add("@CveContratoPadre", SqlDbType.Int).Value = CveContratoPadre .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@EsPresupuestal", SqlDbType.Int).Value = EsPresupuestal - .Add("@CveContratoTipo", SqlDbType.SmallInt).Value = CveContratoTipo + .Add("@EsPresupuestal", SqlDbType.Bit).Value = EsPresupuestal + .Add("@CveContratoTipo", SqlDbType.Int).Value = CveContratoTipo .Add("@ImporteMin", SqlDbType.Money).Value = Minimo .Add("@ImporteMax", SqlDbType.Money).Value = Maximo .Add("@Importe", SqlDbType.Money).Value = Importe @@ -471,7 +471,7 @@ Public Class ClsContratos .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones .Add("@CveDireccionEnvio", SqlDbType.Int).Value = CveDireccionEnvio - .Add("@AplicaImpuestosLocales", SqlDbType.Bit).Value = If(AplicaImpuestosLocales, 1, 0) + .Add("@AplicaImpuestosLocales", SqlDbType.Bit).Value = AplicaImpuestosLocales .Add("@CorreoNotificacionPedDev", SqlDbType.VarChar).Value = CorreoNotificacionPedDev .Add("@FacturacionCicilica", SqlDbType.Bit).Value = FacturacionCicilica .Add("@FacturacionCiclicaAutomatico", SqlDbType.Bit).Value = FacturacionCiclicaAutomatico @@ -3197,6 +3197,27 @@ Public Class ClsContratos OnError("Ocurrió un error al obtener el reporte de presupuestos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) End Try + Return Retorno + End Function + + + Public Function GetPresupuestosResumen(CveEmpresa As Integer, CveSubProyecto As Integer, Opcion As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Con_PresupuestosResumenGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@Opcion", SqlDbType.Int).Value = Opcion + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el resumen de presupuestos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno End Function Public Function GetPresupuestosMensualRep(CvePresupuesto As Integer, CveTipoGasto As Integer, Agrupador As Integer, FechaI As Date, FechaF As Date, CveEmpresa As Integer, CveProyecto As Integer, CveSubProyecto As Integer, CveUsuarioConsulta As Integer, CveAgrupador As Integer) As Boolean diff --git a/App_Code/ClsInventarios.vb b/App_Code/ClsInventarios.vb index fd07547a1..e5334119c 100644 --- a/App_Code/ClsInventarios.vb +++ b/App_Code/ClsInventarios.vb @@ -1062,6 +1062,8 @@ Public Class ClsInventarios Catch Ex1 As SqlException If Ex1.Message.Contains("UK_Inv_MovimientosFolio") Then Me.OnError("El Folio ya se encuentra registrado.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + ElseIf Ex1.Message.Contains("50016") Then + Me.OnError("No se puede registrar salida con entradas posteriores.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) Else Me.OnError("Ocurrió un error al guardar el movimiento.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) End If diff --git a/App_Code/ClsMovimientos.vb b/App_Code/ClsMovimientos.vb index 45e272faa..90f9a5b12 100644 --- a/App_Code/ClsMovimientos.vb +++ b/App_Code/ClsMovimientos.vb @@ -274,6 +274,7 @@ Public Class ClsMovimientos End With Try + SqlAdapter.SelectCommand.CommandTimeout = 0 SqlAdapter.Fill(Data) Retorno = True Catch ex As Exception diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 487f2a677..3fc7edff6 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -19,6 +19,8 @@ Imports Newtonsoft.Json.Linq Public Class ClsPaginas Inherits System.Web.UI.Page Public Const CveUsuarioAsistencia As Integer = 100 + Public Const LigaVerificacionSAT As String = "https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx" + Public Const LigaVerificacionSATCCP As String = "https://verificacfdi.facturaelectronica.sat.gob.mx/verificaccp/default.aspx" Public Const ContraseñaPredeterminada As String = "-acceso-" Public Const ContraseñaPredeterminadaEncriptada As String = "aQDyjiv2NgoTct4c84VnLQ==" ' "-acceso-" Private Shared EncryptKey() As Byte = {} @@ -111,6 +113,18 @@ Public Class ClsPaginas Return If(tHora <> 0, Now.ToUniversalTime.AddMinutes(tHora), Now) End Function + Public Shared Function GeneraQRSAT(RFCEmisor As String, RFCReceptor As String, Total As Decimal, UUID As String, Optional Sellocfdi As String = "", Optional RutaGuardado As String = "") As Byte() + + 'Dim RutaCBB As String = $"{UsuarioActual.Empresa.Ruta}CBB\{ObjCFDITimbre.Comprobante.SerieFolio}.jpg" + Dim qrCode As New GoFac.QrCode() + Dim Cadena As String = $"{LigaVerificacionSAT}?re={RFCEmisor}&rr={RFCReceptor}&tt={String.Format("{0,12:F6}", Total).Trim()}&id={UUID}" + If Sellocfdi <> "" Then Cadena = Cadena & $"&fe={Sellocfdi.Substring(Sellocfdi.Length - 8, 8)}" + Dim bCBB As Byte() = qrCode.GenerarQrCode(Cadena) + If RutaGuardado <> "" Then File.WriteAllBytes(RutaGuardado, bCBB) + Return bCBB + End Function + + #End Region @@ -1233,9 +1247,9 @@ Public Class ClsPaginas End If If EsPersonaFisica <> -1 Then Dim Tipo As New StringBuilder - If EsPersonaFisica = 1 Then Tipo.Append("AplicaPersonaFisica = 1") Else Tipo.Append("AplicaPersonaMoral = 1") + If EsPersonaFisica = 1 Then Tipo.Append("AplicaPersonaFisica = 1 ") Else Tipo.Append("AplicaPersonaMoral = 1 ") If RegimenFiscalReceptor <> "-1" Then - Tipo.AppendFormat("AND RegimenFiscalReceptor LIKE '%{0}%'", RegimenFiscalReceptor) + Tipo.AppendFormat(" AND RegimenFiscalReceptor LIKE '%{0}%'", RegimenFiscalReceptor) End If Dim Dv As New DataView(DirectCast(HttpContext.Current.Application(AppNombre), DataTable), Tipo.ToString(), " UsoCFDIDescripcion", DataViewRowState.CurrentRows) GlobalDTSATUsosCFDI = Dv.ToTable @@ -2231,6 +2245,31 @@ Public Class ClsPaginas Application(AppNombre) = value End Set End Property + + Public Shared Property GlobalDTClientesSucursales(CveEmpresa As Integer, Optional CveCliente As Integer = -1) As DataTable + Get + Dim AppNombre As String = $"GlobalDTClientesSucursales-{CveEmpresa}" + If HttpContext.Current.Application(AppNombre) Is Nothing Then + Dim ObjClientes As New ClsClientes + If ObjClientes.GetSucursales(-1, -1, CveEmpresa) Then HttpContext.Current.Application(AppNombre) = ObjClientes.DtResultados.Copy() + ObjClientes.Dispose() + End If + Dim filtros As New List(Of String) + + If CveCliente >= 0 Then filtros.Add($"CveCliente = {CveCliente}") + If filtros.Count > 0 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application(AppNombre), DataTable), String.Join(" AND ", filtros), "", DataViewRowState.CurrentRows) + GlobalDTClientesSucursales = Dv.ToTable + Dv.Dispose() + Else + GlobalDTClientesSucursales = DirectCast(HttpContext.Current.Application(AppNombre), DataTable) + End If + End Get + Set(value As DataTable) + Dim AppNombre As String = $"GlobalDTClientesSucursales-{CveEmpresa}" + HttpContext.Current.Application(AppNombre) = value + End Set + End Property Public Shared Property GlobalDTEstatusOrdenServicios(CveEmpresa As Integer) As DataTable Get Dim AppNombre As String = $"GlobalDTEstatusOrdenServicios-{CveEmpresa}" @@ -5448,6 +5487,11 @@ Public Class ClsPaginas Vta = ObjVentas.DtResultados.Rows(0).DataRowToObject(Of Modelos.Factura) PathArchivo = String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio) + + If EsTicket Then + PathArchivo = String.Format("{0}PDF\{1}\{2}_Ticket.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio) + End If + Dim Archivo As New System.IO.FileInfo(PathArchivo) 'SI EL ARCHIVO NO EXISTE O SE VA REGENERA EL PDF, SE DEBEN LLENAR LOS DATOS @@ -6300,31 +6344,15 @@ Public Class ClsPaginas CadenaOriginal = "||1.0|" + FolioFiscal + "|" + FechaCertificacion.ToString("yyyy-MM-dd") + "T" + FechaCertificacion.ToString("HH:mm:ss") + "|" + SelloCFDi + "|" + NoSerieCertificado + "||" End If - If Not ImagenCBB.Exists Then - Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() - CBB.GenerarCBB(UsuarioActual.Empresa.RFC, ClienteRFC, Total, FolioFiscal, RutaCBB) - End If - - + If Not ImagenCBB.Exists Then GeneraQRSAT(UsuarioActual.Empresa.RFC, ClienteRFC, Total, FolioFiscal, RutaGuardado:=RutaCBB) ImagenCBB = New System.IO.FileInfo(RutaCBB) - If ImagenCBB.Exists Then ImgCBB = String.Format("file://{0}", ImagenCBB.FullName) Else ImgCBB = "" End If - - - 'FIXME OICCHECAR DESPUES DE SINCRONIZAR TIMBRADO - 'If Not ImagenCCP.Exists Then - ' Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() - ' CBB.GenerarCBB(UsuarioActual.Empresa.RFC, ClienteRFC, Total, FolioFiscal, RutaCBB) - 'End If - - ImagenCCP = New System.IO.FileInfo(RutaCCP) - If ImagenCCP.Exists Then ImgCCP = String.Format("file://{0}", ImagenCCP.FullName) Else @@ -6751,9 +6779,6 @@ Public Class ClsPaginas End If 'Si no tiene CBB, SE GENERA If (Not ImagenCBB.Exists OrElse RegenerarQR) AndAlso Vta.FolioFiscal <> "" Then - 'Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() - 'CBB.GenerarCBB(UsuarioActual.Empresa.RFC, RFCReceptor, Vta.Total, Vta.FolioFiscal, RutaCBB) - Dim LigaVerificacionSAT As String = "https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx" Try Dim qrCode As New GoFac.QrCode() Dim bCBB As Byte() = qrCode.GenerarQrCode($"{LigaVerificacionSAT}?re={UsuarioActual.Empresa.RFC}&rr={RFCReceptor}&tt={String.Format("{0,12:F6}", Vta.Total).Trim()}&id={Vta.FolioFiscal}&fe={Vta.SelloCFDi.Substring(Vta.SelloCFDi.Length - 8, 8)}") @@ -7448,25 +7473,31 @@ Public Class ClsPaginas params.Add(New ReportParameter("RegimenFiscalEmpresa", String.Format("{0} - {1}", UsuarioActual.Empresa.CodigoRegimenFiscal, UsuarioActual.Empresa.RegimenFiscal))) End If End If + + Dim RutaPDF As String = String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio) + If EsTicket Then + RutaPDF = String.Format("{0}PDF\{1}\{2}_Ticket.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio) + End If + If Not UsarStimul Then Dim Archivo As New System.IO.FileInfo(RutaFormato) If Archivo.Exists Then retorno = StreamPDF(RutaFormato, lrds, params, NombreArchivo, "PDF", MR:=Nothing, SubReportData:=SubReportData) - Dim ArchivoPDF As New System.IO.FileInfo(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio)) + Dim ArchivoPDF As New System.IO.FileInfo(RutaPDF) If Guardar Then If Not ArchivoPDF.Exists Then Try DirectoryExistsCreate(String.Format("{0}PDF", UsuarioActual.Empresa.Ruta)) DirectoryExistsCreate(String.Format("{0}PDF\{1}", UsuarioActual.Empresa.Ruta, Vta.TipoDocto)) - File.WriteAllBytes(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio), retorno) + File.WriteAllBytes(RutaPDF, retorno) Catch ex As Exception Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia) End Try Else Try ArchivoPDF.Delete() - File.WriteAllBytes(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio), retorno) + File.WriteAllBytes(RutaPDF, retorno) Catch ex As Exception Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia) End Try @@ -7485,20 +7516,20 @@ Public Class ClsPaginas retorno = StreamBytesStimul("Facturas", RutaFormato, lrds, params, NombreArchivo:=NombreArchivo, Formato:="PDF") If UsuarioActual.Empresa.Funcionalidad(707) = "1" Then - Dim ArchivoPDF As New System.IO.FileInfo(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio)) + Dim ArchivoPDF As New System.IO.FileInfo(RutaPDF) If Guardar Then If Not ArchivoPDF.Exists Then Try DirectoryExistsCreate(String.Format("{0}PDF", UsuarioActual.Empresa.Ruta)) DirectoryExistsCreate(String.Format("{0}PDF\{1}", UsuarioActual.Empresa.Ruta, Vta.TipoDocto)) - File.WriteAllBytes(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio), retorno) + File.WriteAllBytes(RutaPDF, retorno) Catch ex As Exception Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia) End Try Else Try ArchivoPDF.Delete() - File.WriteAllBytes(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio), retorno) + File.WriteAllBytes(RutaPDF, retorno) Catch ex As Exception Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia) End Try @@ -8245,9 +8276,8 @@ Public Class ClsPaginas End If 'Si no tiene CBB, SE GENERA If Not ImagenCBB.Exists Then - Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() If ObjPersonal.GetPersonal(CvePersonal, CveEmpresa) Then - CBB.GenerarCBB(UsuarioActual.Empresa.RFC, ObjPersonal.RFC, ObjNomina.Total.ToString.ToDecimal, FolioFiscal, RutaCBB) + GeneraQRSAT(UsuarioActual.Empresa.RFC, ObjPersonal.RFC, ObjNomina.Total.ToString.ToDecimal, FolioFiscal, RutaGuardado:=RutaCBB) End If End If ImgCBB = String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/Nomina/{4}.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, ObjNomina.SerieFolio) @@ -8329,10 +8359,9 @@ Public Class ClsPaginas RptParametro.Add(New ReportParameter("Unidad", "ACT")) RptParametro.Add(New ReportParameter("Descripcion", "PAGO DE NÓMINA")) RptParametro.Add(New ReportParameter("Total", If(indemnizacion, ajusteindemnizacion, ObjNomina.Total - ajusteindemnizacion).ToString())) - Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() - cQr = CBB.GenerarCBBBytes(UsuarioActual.Empresa.RFC, ObjPersonal.RFC, ObjNomina.Total.ToString().ToDecimal(), FolioFiscal) RptParametro.Add(New ReportParameter("ImporteLetra", ObjNomina.Total.ToString.ToDecimal.Texto2Letras)) RptParametro.Add(New ReportParameter("Clave", "84111505")) + cQr = GeneraQRSAT(UsuarioActual.Empresa.RFC, ObjPersonal.RFC, ObjNomina.Total.ToString().ToDecimal(), FolioFiscal) Else TieneError = True End If @@ -8739,8 +8768,7 @@ Public Class ClsPaginas End If Dim CadenaOriginal As String = $"||1.0| {FolioFiscal} | {FechaCertificacion.ToDate.ToShortDateString} T {FechaCertificacion.ToDateTime.ToShortTimeString} | {SelloCFDi} | {NoSerieCertificado} ||" If Not File.Exists(ImagenCBB) AndAlso FolioFiscal <> "" Then - Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() - CBB.GenerarCBB(UsuarioActual.Empresa.RFC, RFCOrdenante, 1, FolioFiscal, ImagenCBB) + GeneraQRSAT(UsuarioActual.Empresa.RFC, RFCOrdenante, 1, FolioFiscal, RutaGuardado:=ImagenCBB) End If ' PARAMETROS DEL REPORTE @@ -9287,7 +9315,7 @@ Public Class ClsPaginas #End Region #Region "P A G O D E V E N T A S " - Public Shared Function AplicaPrePolizaPagoVenta(VentaActual As Venta, Pago As VentaPago, CvePrePoliza As Integer, ByRef ObjConta As ClsContabilidad) As Boolean + Public Shared Function AplicaPrePolizaPagoVenta(VentaActual As Venta, Pago As VentaPago, CvePrePoliza As Integer, ByRef ObjConta As ClsContabilidad, Optional AplicarConceptoAplicacion As Boolean = True) As Boolean Dim ErrorMovtos As Boolean = False Dim PorcentajePago As Decimal = Pago.ImportePagoVenta / VentaActual.Total Dim ImporteMovimiento As Decimal = 0 @@ -9409,7 +9437,7 @@ Public Class ClsPaginas End If 'concepto pago - If Pago.TipoPago = "B" AndAlso Not ErrorMovtos Then ' B A N C O S + If Pago.TipoPago = "B" AndAlso Not ErrorMovtos AndAlso AplicarConceptoAplicacion Then ' B A N C O S Concepto = String.Format("{0} NC:{1}", VentaActual.ClienteNombre, Pago.Referencia) If Pago.CveMonedaPago > 1 Then 'Agregamos la Extranjera @@ -9421,9 +9449,8 @@ Public Class ClsPaginas If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Pago.ImportePago, Pago.ImportePago, 30, Pago.Referencia, Concepto, CveVenta:=Pago.CveVentaAmortizacion, CveVentaAmortizacion:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal) Then ErrorMovtos = True End If End If - If Pago.TipoPago = "A" AndAlso Not ErrorMovtos Then ' A N T I C I P O + If Pago.TipoPago = "A" AndAlso Not ErrorMovtos AndAlso AplicarConceptoAplicacion Then ' A N T I C I P O Concepto = String.Format("{0} Ant:{1}", VentaActual.ClienteNombre, Pago.Referencia) - Dim Ret As New ConceptosRetenciones 'Dim ConPreP As ConceptosTipoSaldo = ObtenerCveConceptoPrePoliza(6, VentaActual.CveMoneda, True, 1) If Pago.CveMonedaPago > 1 Then 'Agregamos la Extranjera @@ -9435,9 +9462,8 @@ Public Class ClsPaginas If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Pago.ImportePago, Pago.ImportePago, 11, Pago.Referencia, Concepto, CveVenta:=Pago.CveVentaAmortizacion, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambioPago:=Pago.TCPago) Then ErrorMovtos = True End If End If - If Pago.TipoPago = "NC" AndAlso Not ErrorMovtos Then ' N O T A D E C R E D I T O + If Pago.TipoPago = "NC" AndAlso Not ErrorMovtos AndAlso AplicarConceptoAplicacion Then ' N O T A D E C R E D I T O Concepto = String.Format("{0} NC:{1}", VentaActual.ClienteNombre, Pago.Referencia) - Dim Ret As New ConceptosRetenciones Dim ConPrePNC As ConceptosTipoSaldo = ObtenerCveConceptoPrePoliza(6, Pago.CveMonedaPago, True, 2) If Pago.CveMonedaPago > 1 Then 'Agregamos la Extranjera @@ -9449,9 +9475,8 @@ Public Class ClsPaginas If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Pago.ImportePago, Pago.ImportePago, ConPrePNC.CveConcepto, Pago.Referencia, Concepto, CveVenta:=Pago.CveVentaAmortizacion, CveVentaAmortizacion:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal) Then ErrorMovtos = True End If End If - If Pago.TipoPago = "I" AndAlso Not ErrorMovtos Then ' I N G R E S O S X C O M P R O B A R + If Pago.TipoPago = "I" AndAlso Not ErrorMovtos AndAlso AplicarConceptoAplicacion Then ' I N G R E S O S X C O M P R O B A R Concepto = String.Format("{0} IxC:{1}", VentaActual.ClienteNombre, Pago.Referencia) - Dim Ret As New ConceptosRetenciones If VentaActual.UsuarioActual.Empresa.TipoContabilidad = 2 Then 'If Pago.CveMonedaPago > 1 AndAlso ObjConta.GetRetCuenta(207, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then Ret.IdCtaContablexAcreditar = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxAcreditar").ToString.ToEntero If VentaActual.UsuarioActual.CveEmpresa.Contiene(119) Then @@ -9473,6 +9498,14 @@ Public Class ClsPaginas If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Pago.ImportePago, Pago.ImportePago, 92, Pago.Referencia, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=Pago.CveClientePago, CveIE:=Pago.CveIE, CveSubProyecto:=VentaActual.CveSubProyecto, CvePersonal:=Pago.CvePersonal) Then ErrorMovtos = True End If End If + + If Pago.TipoPago = "FyE" AndAlso Not ErrorMovtos Then ' F U N C I O N A R I O S Y E M P L E A D O S + Concepto = String.Format("{0} - {1}", VentaActual.ClienteNombre, Pago.Referencia) + + 'Agregamos Nacional + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Pago.ImportePago, Pago.ImportePago, 29, Pago.Referencia, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=Pago.CveClientePago, CveIE:=Pago.CveIE, CveSubProyecto:=VentaActual.CveSubProyecto, CvePersonal:=Pago.CvePersonal) Then ErrorMovtos = True + + End If 'si tiene otros gastos/ingresos If Not ErrorMovtos AndAlso Pago.OtroGastoIngreso <> 0 Then @@ -10617,7 +10650,7 @@ Public Class ClsPaginas PaginaDict.Add("/RH/RepDocumentacionVencida.aspx".ToUpper(), 412) PaginaDict.Add("/RH/CatSubProyectosZonas.aspx".ToUpper(), 421) PaginaDict.Add("/RH/RepVacaciones.aspx".ToUpper(), 422) - PaginaDict.Add("/RH/CatChecadorTipo.aspx".ToUpper(), 427) + 'PaginaDict.Add("/RH/CatChecadorTipo.aspx".ToUpper(), 427) PaginaDict.Add("/RH/CatChecadorHorarios.aspx".ToUpper(), 428) PaginaDict.Add("/RH/RepChecadorPreAsistencia.aspx".ToUpper(), 628) PaginaDict.Add("/RH/CatCaptaciones.aspx".ToUpper(), 629) @@ -10770,6 +10803,9 @@ Public Class ClsPaginas PaginaDict.Add("/Ventas/CatProcedimientoDetalle.aspx".ToUpper(), 1344) PaginaDict.Add("/Ventas/CatEspecialidadesSubEspecialidades.aspx".ToUpper(), 1346) PaginaDict.Add("/Ventas/FacturacionGlobal.aspx".ToUpper(), 546) + PaginaDict.Add("/Ventas/RepComisionesSMS.aspx".ToUpper(), 1347) + + diff --git a/App_Code/ClsProductosServicios.vb b/App_Code/ClsProductosServicios.vb index 5fcda2cf9..c9bcb106e 100644 --- a/App_Code/ClsProductosServicios.vb +++ b/App_Code/ClsProductosServicios.vb @@ -347,7 +347,7 @@ Public Class ClsProductosServicios Return Retorno End Function - Public Function GetPSLite(CveClasificacion As Integer, CveEmpresa As Integer, Optional Codigo As String = "-1", Optional CodigoBarras As String = "-1", Optional PS As String = "-1", Optional pAplicaParaVenta As Integer = -1, Optional pEstado As Integer = -1, Optional CveTipoPS As Integer = -1, Optional UsoClasificacion As Integer = -1) As Boolean + Public Function GetPSLite(CveClasificacion As Integer, CveEmpresa As Integer, Optional Codigo As String = "-1", Optional CodigoBarras As String = "-1", Optional PS As String = "-1", Optional pAplicaParaVenta As Integer = -1, Optional pEstado As Integer = -1, Optional CveTipoPS As Integer = -1, Optional UsoClasificacion As Integer = -1, Optional CveMarca As Integer = -1) As Boolean Dim Retorno As Boolean = False ' @CveClasificacion int, @Codigo varchar(50) = '-1', @PS varchar(300) = '-1', @AplicaParaVenta int = -1, @Estado int = -1, @CodigoBarras varchar(50) = '-1', @CveTipoPS int = -1, @CveEmpresa int DataAdapter("PA_ProductosServiciosLiteGet") @@ -360,6 +360,7 @@ Public Class ClsProductosServicios .Add("@AplicaParaVenta", SqlDbType.Int).Value = pAplicaParaVenta .Add("@Estado", SqlDbType.Int).Value = pEstado .Add("@CveTipoPS", SqlDbType.Int).Value = CveTipoPS + .Add("@CveMarca", SqlDbType.Int).Value = CveMarca .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@UsoClasificacion", SqlDbType.Int).Value = UsoClasificacion End With @@ -647,6 +648,27 @@ Public Class ClsProductosServicios Return Retorno End Function + + Public Function UpdatePSImagen(CvePS As Integer, Imagen As String) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_PSImagenUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@Imagen", SqlDbType.VarChar).Value = Imagen + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al guardar la imagen del producto.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdatePS(CveClasificacion As Integer, CveClasificacionCosto As Integer, CveUnidadMedida As Integer, Codigo As String, NumeroParte As String, CodigoBarras As String, PS As String, Precio As Double, IVA As Double, RetIVA As Double, Inventariable As Boolean, CveProveedorCompra As Integer, AplicaParaConcepto As Boolean, AplicaParaVenta As Boolean, Estado As Boolean, CveUsuario As Integer, CvePS As Integer, CveMetodoInventario As Integer, EsPaquete As Integer, CveSATPS As Integer, CveEmpresa As Integer, Optional CveTipoPS As Integer = -1, Optional TipoServicio As Integer = -1, Optional CveClasificacion2 As Integer = -1, Optional CveMarca As Integer = -1, Optional AlmacenSeccion As String = "", Optional AplicaIEPS As Boolean = False, Optional IEPSPorcentaje As Decimal = -1, @@ -884,8 +906,6 @@ Public Class ClsProductosServicios DataAdapter("PA_Inv_UltimoPrecioCompraGet") With SqlAdapter.SelectCommand.Parameters - - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CvePS", SqlDbType.Int).Value = CvePS .Add("@PU", SqlDbType.Money).Direction = ParameterDirection.Output @@ -893,7 +913,7 @@ Public Class ClsProductosServicios Try SqlAdapter.Fill(Data) - Retorno = CDbl(SqlAdapter.SelectCommand.Parameters("@PU").Value) + Retorno = SqlAdapter.SelectCommand.Parameters("@PU").Value.ToString.ToDecimal Catch Ex1 As SqlException Me.OnError("Ocurrió un error al obtener el precio unitario.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) @@ -1545,7 +1565,7 @@ Public Class ClsProductosServicios - Public Function AddMarcas(Marca As String, Estatus As Boolean, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Public Function AddMarcas(Marca As String, Estatus As Boolean, CveUsuario As Integer, CveEmpresa As Integer, Optional ActualizarFranquicias As Boolean = False) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Gral_MarcasAdd") @@ -1555,6 +1575,7 @@ Public Class ClsProductosServicios .Add("@Estatus", SqlDbType.Bit).Value = Estatus .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@ActualizarFranquicias", SqlDbType.Bit).Value = ActualizarFranquicias End With Try @@ -1597,7 +1618,7 @@ Public Class ClsProductosServicios - Public Function UpdateMarca(Marca As String, CveMarca As Integer, Estatus As Boolean) As Boolean + Public Function UpdateMarca(Marca As String, CveMarca As Integer, Estatus As Boolean, CveEmpresa As Integer, Optional ActualizarFranquicias As Boolean = False) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Gral_MarcasUpdate") @@ -1605,6 +1626,8 @@ Public Class ClsProductosServicios .Add("@Marca", SqlDbType.VarChar).Value = Marca .Add("@CveMarca", SqlDbType.Int).Value = CveMarca .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@ActualizarFranquicias", SqlDbType.Bit).Value = ActualizarFranquicias End With Try diff --git a/App_Code/ClsPuntoVenta.vb b/App_Code/ClsPuntoVenta.vb index bae4421c5..416ba3ef3 100644 --- a/App_Code/ClsPuntoVenta.vb +++ b/App_Code/ClsPuntoVenta.vb @@ -222,7 +222,7 @@ Public Class ClsPuntoVenta Return Retorno End Function - Public Function GetCortesDetalleVentas(CveCorte As Integer, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean + Public Function GetCortesDetalleVentas(CveCorte As Integer, CveSubProyecto As Integer, CveEmpresa As Integer, Opcion As Integer) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_CortesDetalleVentasGet") @@ -230,7 +230,8 @@ Public Class ClsPuntoVenta With SqlAdapter.SelectCommand.Parameters .Add("@CveCorte", SqlDbType.Int).Value = CveCorte .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Opcion", SqlDbType.Int).Value = Opcion End With Try @@ -242,40 +243,40 @@ Public Class ClsPuntoVenta End Try Return Retorno - End Function + End Function + + 'Public Function GetCortesPorCuenta(CveCuenta As Integer, CveEmpresa As Integer) As Boolean + ' Dim Retorno As Boolean = False - Public Function GetCortesPorCuenta(CveCuenta As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False + ' DataAdapter("PA_Vta_CuentaCorteGet") - DataAdapter("PA_Vta_CuentaCorteGet") + ' With SqlAdapter.SelectCommand.Parameters + ' .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + ' .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + ' .Add("@CveCorte", SqlDbType.Int).Direction = ParameterDirection.Output + ' End With - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveCorte", SqlDbType.Int).Direction = ParameterDirection.Output - End With + ' Try + ' SqlAdapter.Fill(Data) + ' CveCorte = Integer.Parse(SqlAdapter.SelectCommand.Parameters("@CveCorte").Value.ToString) + ' Retorno = True + ' Catch ex As Exception + ' OnError("Ocurrió un error al obtener los cuenta de corte", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + ' End Try - Try - SqlAdapter.Fill(Data) - CveCorte = Integer.Parse(SqlAdapter.SelectCommand.Parameters("@CveCorte").Value.ToString) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los cuenta de corte", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function + ' Return Retorno + 'End Function - Public Function GetVta_ReporteCortes(CveEmpresa As Integer, FechaI As Date, FechaF As Date, Optional CveSubProyecto As Integer = -1) As Boolean + Public Function GetVta_ReporteCortes(CveEmpresa As Integer, FechaI As Date, FechaF As Date, Optional CveSubProyecto As Integer = -1, Optional CveCorte As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_ReporteCortesGet") SqlAdapter.SelectCommand.Parameters.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa SqlAdapter.SelectCommand.Parameters.Add("@FechaInicio", SqlDbType.Date).Value = FechaI SqlAdapter.SelectCommand.Parameters.Add("@FechaFin", SqlDbType.Date).Value = FechaF - SqlAdapter.SelectCommand.Parameters.Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - + SqlAdapter.SelectCommand.Parameters.Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + SqlAdapter.SelectCommand.Parameters.Add("@CveCorte", SqlDbType.Int).Value = CveCorte Try SqlAdapter.Fill(Data) Retorno = True diff --git a/App_Code/ClsRH.vb b/App_Code/ClsRH.vb index 8ef0812c4..8197581c5 100644 --- a/App_Code/ClsRH.vb +++ b/App_Code/ClsRH.vb @@ -7444,44 +7444,6 @@ Public Class ClsRH Return Retorno End Function - - Public Function AddRemoveChecadoresSubProyectos(CveChecador As Integer, CveSubProyecto As Integer, CveUsuario As Integer, Agreagar As Boolean) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_RH_ChecadorSubProyectosAddRemove") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveChecador", SqlDbType.Int).Value = CveChecador - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@Agreagar", SqlDbType.Bit).Value = Agreagar - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el sub proyecto", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - - - Public Function GetChecadoresSubProyectos(CveChecador As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_RH_ChecadorSubProyectosGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveChecador", SqlDbType.Int).Value = CveChecador - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obteger los sub proyecto", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - - - #End Region #Region " A C T I V I D A D E S" diff --git a/App_Code/ClsSisEmpresas.vb b/App_Code/ClsSisEmpresas.vb index ada1fd59f..c92c3b19a 100644 --- a/App_Code/ClsSisEmpresas.vb +++ b/App_Code/ClsSisEmpresas.vb @@ -382,7 +382,7 @@ Public Class ClsSisEmpresas _Empresa.FechaIng = Data.Rows(0)("Fecha").ToString.ToDate _Empresa.Usuario = Data.Rows(0)("Usuario").ToString _Empresa.FacturaProduccion = If(Data.Rows(0)("FacturaProduccion").ToString = "", False, CBool(Data.Rows(0)("FacturaProduccion").ToString)) - _Empresa.EstatusFacturacion = Data.Rows(0)("EstatusFacturacion").ToString <> "No" + '_Empresa.EstatusFacturacion = Data.Rows(0)("EstatusFacturacion").ToString <> "No" _Empresa.UsaContabilidad = Data.Rows(0)("UsaContabilidad").ToString <> "No" _Empresa.UsaBancos = Data.Rows(0)("UsaBancos").ToString <> "No" _Empresa.UsaVentas = Data.Rows(0)("UsaVentas").ToString <> "No" @@ -459,7 +459,7 @@ Public Class ClsSisEmpresas End Function Public Function AddEmpresa(CveEmpresa As Integer, Empresa As String, Direccion As String, NoExt As String, NoInt As String, Colonia As String, Ciudad As String, Estado As String, RFC As String, CP As String, Telefono As String, Contacto As String, Mail As String, TipoFacturacion As String, BIUsuario As String, BIContraseña As String, ContraseñaKey As String, ArchivoKey As String, - ArchivoCer As String, ArchivoPfx As String, Banner As String, CveUsuario As Integer, FacturaProduccion As Boolean, MostrarRetIVA As Boolean, MostrarRetISR As Boolean, Regimen As String, EstatusFacturacion As Boolean, + ArchivoCer As String, ArchivoPfx As String, Banner As String, CveUsuario As Integer, FacturaProduccion As Boolean, MostrarRetIVA As Boolean, MostrarRetISR As Boolean, Regimen As String, SendMail As String, SendMailPassword As String, SendMailServer As String, SendMailPuerto As Integer, SendMailSSL As Boolean, UsaContabilidad As Boolean, UsaBancos As Boolean, UsaVentas As Boolean, UsaCxC As Boolean, UsaCompras As Boolean, UsaInventarios As Boolean, UsaRH As Boolean, UsaNomina As Boolean, UsaOS As Boolean, BDContPAQi As String, ServerContPAQi As String, UsrContPAQi As String, PwdContPAQi As String, Buzon_Mail As String, Buzon_Server As String, Buzon_Puerto As Integer, Buzon_SSL As Boolean, Buzon_USR As String, Buzon_PWD As String, Buzon_Tipo As String, Soporte_Mail As String, @@ -504,7 +504,7 @@ Public Class ClsSisEmpresas .Add("@MostrarRetIVA", SqlDbType.Bit).Value = MostrarRetIVA .Add("@MostrarRetISR", SqlDbType.Bit).Value = MostrarRetISR .Add("@Regimen", SqlDbType.VarChar).Value = Regimen - .Add("@EstatusFacturacion", SqlDbType.Int).Value = EstatusFacturacion + '.Add("@EstatusFacturacion", SqlDbType.Int).Value = EstatusFacturacion .Add("@SendMail", SqlDbType.VarChar).Value = SendMail .Add("@SendMailPassword", SqlDbType.VarChar).Value = SendMailPassword .Add("@SendMailServer", SqlDbType.VarChar).Value = SendMailServer @@ -589,7 +589,7 @@ Public Class ClsSisEmpresas Public Function UpdateEmpresa(Empresa As String, Direccion As String, NoExt As String, NoInt As String, Colonia As String, Ciudad As String, Estado As String, RFC As String, CP As String, Telefono As String, Contacto As String, Mail As String, TipoFacturacion As String, BIUsuario As String, BIContraseña As String, ContraseñaKey As String, ArchivoKey As String, - ArchivoCer As String, ArchivoPfx As String, Banner As String, Estatus As Boolean, FacturaProduccion As Boolean, MostrarRetIVA As Boolean, MostrarRetISR As Boolean, Regimen As String, EstatusFacturacion As Boolean, + ArchivoCer As String, ArchivoPfx As String, Banner As String, Estatus As Boolean, FacturaProduccion As Boolean, MostrarRetIVA As Boolean, MostrarRetISR As Boolean, Regimen As String, SendMail As String, SendMailPassword As String, SendMailServer As String, SendMailPuerto As Integer, SendMailSSL As Boolean, UsaContabilidad As Boolean, UsaBancos As Boolean, UsaVentas As Boolean, UsaCxC As Boolean, UsaCompras As Boolean, UsaInventarios As Boolean, UsaRH As Boolean, UsaNomina As Boolean, UsaOS As Boolean, BDContPAQi As String, ServerContPAQi As String, UsrContPAQi As String, PwdContPAQi As String, Buzon_Mail As String, Buzon_Server As String, Buzon_Puerto As Integer, Buzon_SSL As Boolean, Buzon_USR As String, Buzon_PWD As String, CveEmpresa As Integer, Buzon_Tipo As String, Soporte_Mail As String, @@ -628,7 +628,6 @@ Public Class ClsSisEmpresas .Add("@MostrarRetIVA", SqlDbType.Bit).Value = MostrarRetIVA .Add("@MostrarRetISR", SqlDbType.Bit).Value = MostrarRetISR .Add("@Regimen", SqlDbType.VarChar).Value = Regimen - .Add("@EstatusFacturacion", SqlDbType.Int).Value = EstatusFacturacion .Add("@SendMail", SqlDbType.VarChar).Value = SendMail .Add("@SendMailPassword", SqlDbType.VarChar).Value = SendMailPassword .Add("@SendMailServer", SqlDbType.VarChar).Value = SendMailServer diff --git a/App_Code/ClsSisUsuarios.vb b/App_Code/ClsSisUsuarios.vb index 1c779adf5..56477c6b5 100644 --- a/App_Code/ClsSisUsuarios.vb +++ b/App_Code/ClsSisUsuarios.vb @@ -189,7 +189,7 @@ Public Class ClsSisUsuarios End Try Return Retorno End Function - Public Function ValidaUsuario(Usuario As String, Password As String, tIMEI As String, Optional CveEmpresa As Integer = -1, Optional CvePlataforma As Integer = -1) As Usuario + Public Function ValidaUsuario(Usuario As String, Password As String, tIMEI As String, Optional CveEmpresa As Integer = -1, Optional GrupoEmpresa As String = "", Optional CvePlataforma As Integer = -1) As Usuario Dim Retorno As Usuario = Nothing DataAdapter("PA_Sis_UsuariosGet") With SqlAdapter.SelectCommand.Parameters @@ -199,11 +199,12 @@ Public Class ClsSisUsuarios .Add("@Contraseña", SqlDbType.VarChar).Value = Password .Add("@CvePlataforma", SqlDbType.Int).Value = CvePlataforma .Add("@EsLogIn", SqlDbType.Bit).Value = 1 + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@GrupoEmpresa", SqlDbType.VarChar).Value = GrupoEmpresa End With Try SqlAdapter.Fill(Data) - If Data.Rows.Count > 0 Then Retorno = New Usuario @@ -215,7 +216,6 @@ Public Class ClsSisUsuarios Retorno.CveRol = Data.Rows(0)("CveRol").ToString().ToEntero() Retorno.Rol = Data.Rows(0)("Rol").ToString() - 'Retorno.NombreEmpresa = Data.Rows(0)("Empresa").ToString Retorno.CveEmpresa = Data.Rows(0)("CveEmpresa").ToString().ToEntero() Retorno.CvePlataforma = Data.Rows(0)("CvePlataforma").ToString().ToEntero() diff --git a/App_Code/ClsTransportes.vb b/App_Code/ClsTransportes.vb index d95cfed3a..07e43b962 100644 --- a/App_Code/ClsTransportes.vb +++ b/App_Code/ClsTransportes.vb @@ -135,7 +135,7 @@ Public Class ClsTransportes #End Region #Region "Boletos" - Public Function AddViajesPasajeros(CveViaje As Integer, CveDestinoOrigen As Integer, CveDestinoFinal As Integer, Importe As Decimal, Asiento As Integer, Nombre As String, Visa As String, Celular As String, Sexo As Boolean, Observacion As String, CveUsuario As Integer, CveVendedor As Integer) As Integer + Public Function AddViajesPasajeros(CveViaje As Integer, CveDestinoOrigen As Integer, CveDestinoFinal As Integer, CveVendedor As Integer, Importe As Decimal, Asiento As Integer, Nombre As String, INE As String, FechaNacimiento As Date, Sexo As Boolean, Visa As String, VisaVigencia As Date, Celular As String, Observacion As String, CveUsuario As Integer) As Integer Dim Retorno As Integer = -1 DataAdapter("PA_Trans_ViajesPasajerosAdd") @@ -145,15 +145,18 @@ Public Class ClsTransportes .Add("@CveViaje", SqlDbType.Int).Value = CveViaje .Add("@CveDestinoOrigen", SqlDbType.Int).Value = CveDestinoOrigen .Add("@CveDestinoFinal", SqlDbType.Int).Value = CveDestinoFinal + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor .Add("@Importe", SqlDbType.Money).Value = Importe .Add("@Asiento", SqlDbType.Int).Value = Asiento .Add("@Nombre", SqlDbType.VarChar).Value = Nombre - .Add("@Visa", SqlDbType.VarChar).Value = Visa - .Add("@Celular", SqlDbType.VarChar).Value = Celular + .Add("@INE", SqlDbType.VarChar).Value = INE + .Add("@FechaNacimiento", SqlDbType.Date).Value = FechaNacimiento .Add("@Sexo", SqlDbType.Bit).Value = Sexo + .Add("@Visa", SqlDbType.VarChar).Value = Visa + .Add("@VisaVigencia", SqlDbType.Date).Value = VisaVigencia + .Add("@Celular", SqlDbType.VarChar).Value = Celular .Add("@Observacion", SqlDbType.VarChar).Value = Observacion .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor End With @@ -275,7 +278,7 @@ Public Class ClsTransportes Return Retorno End Function - Public Function AddDestino(Destino As String, Estatus As String, EsNacional As String, CveUsuario As Integer, CveEmpresa As Integer) As Integer + Public Function AddDestino(Destino As String, Estatus As String, EsNacional As String, CveUsuario As Integer, CveEmpresa As Integer, CveEstado As Integer) As Integer Dim Retorno As Integer = -1 DataAdapter("PA_Trans_DestinosAdd") @@ -286,6 +289,7 @@ Public Class ClsTransportes .Add("@Estatus", SqlDbType.Bit).Value = Convert.ToBoolean(Estatus) .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveEstado", SqlDbType.Int).Value = CveEstado End With Try SqlAdapter.Fill(Data) @@ -297,7 +301,7 @@ Public Class ClsTransportes Return Retorno End Function - Public Function UpdateDestino(CveDestino As Integer, Destino As String, Estatus As String, EsNacional As String, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Public Function UpdateDestino(CveDestino As Integer, Destino As String, Estatus As String, EsNacional As String, CveUsuario As Integer, CveEmpresa As Integer, CveEstado As Integer) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Trans_DestinosUpdate") With SqlAdapter.SelectCommand.Parameters @@ -307,6 +311,8 @@ Public Class ClsTransportes .Add("@Estatus", SqlDbType.Bit).Value = Convert.ToBoolean(Estatus) .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveEstado", SqlDbType.Int).Value = CveEstado + End With Try SqlAdapter.Fill(Data) diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index 8234a17ad..c6406dcbb 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -3445,6 +3445,50 @@ Public Class ClsVentas Return Retorno End Function + Public Function GetCortesDetalleVentasResumenIVA(CveCorte As Integer, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_CortesDetalleVentasResumenIVAGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCorte", SqlDbType.Int).Value = CveCorte + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los detalle de cortes", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetCortesDetalleDepositosCaja(CveCorte As Integer, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_CortesDetalleDepositosCajaGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCorte", SqlDbType.Int).Value = CveCorte + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los detalle de cortes", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + #End Region #Region " CANCELAR ANTE SAT " @@ -6066,7 +6110,7 @@ Public Class ClsVentas SqlAdapter.Fill(Data) Retorno = True Catch ex As Exception - OnError("Ocurrió un error al eliminar los datos de facturación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + OnError("Ocurrió un error al actualizar el corte en la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) End Try Return Retorno @@ -6117,25 +6161,19 @@ Public Class ClsVentas End Function - - - - Public Function AddMedico(Medico As String, CedulaProfesional As String, FechaNacimiento As Date, Notas As String, DiasAtencion As String, Horario As String, Lugar As String, Estatus As Boolean, CveUsuario As Integer, - CveEmpresa As Integer, Telefono As String, Mail As String, CveMedicoEspecialidad As Integer, Celular As String, Consultorio As String, Optional CveMedicoSubEspecialidad As Integer = -1, - Optional Torre As String = "-1") As Integer + Public Function AddMedico(Nombre As String, Apellidos As String, CedulaProfesional As String, FechaNacimiento As Date, Notas As String, Estatus As Boolean, CveUsuario As Integer, + CveEmpresa As Integer, Telefono As String, Mail As String, CveMedicoEspecialidad As Integer, Celular As String, Optional CveMedicoSubEspecialidad As Integer = -1, Optional CveVendedor As Integer = -1) As Integer Dim Retorno As Boolean = False CveMedicoNuevo = -1 DataAdapter("PA_Vta_MedicosAdd") With SqlAdapter.SelectCommand.Parameters + .Add("@Nombre", SqlDbType.VarChar).Value = Nombre + .Add("@Apellidos", SqlDbType.VarChar).Value = Apellidos .Add("@CedulaProfesional", SqlDbType.VarChar).Value = CedulaProfesional - .Add("@Medico", SqlDbType.VarChar).Value = Medico .Add("@FechaNacimiento", SqlDbType.Date).Value = FechaNacimiento .Add("@Notas", SqlDbType.VarChar).Value = Notas - .Add("@DiasAtencion", SqlDbType.VarChar).Value = DiasAtencion - .Add("@Horario", SqlDbType.VarChar).Value = Horario - .Add("@Lugar", SqlDbType.VarChar).Value = Lugar .Add("@Estatus", SqlDbType.Bit).Value = Estatus .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa @@ -6143,13 +6181,10 @@ Public Class ClsVentas .Add("@Mail", SqlDbType.VarChar).Value = Mail .Add("@CveMedicoEspecialidad", SqlDbType.Int).Value = CveMedicoEspecialidad .Add("@Celular", SqlDbType.VarChar).Value = Celular - .Add("@Consultorio", SqlDbType.VarChar).Value = Consultorio .Add("@CveMedicoSubEspecialidad", SqlDbType.Int).Value = CveMedicoSubEspecialidad - .Add("@Torre", SqlDbType.VarChar).Value = Torre + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor .Add("@CveMedicoNuevo", SqlDbType.Int).Direction = ParameterDirection.Output - - End With Try SqlAdapter.Fill(Data) @@ -6163,21 +6198,22 @@ Public Class ClsVentas End Function - Public Function UpdateMedico(CveMedico As Integer, Medico As String, CedulaProfesional As String, FechaNacimiento As Date, Notas As String, DiasAtencion As String, Horario As String, Lugar As String, Estatus As Boolean, CveUsuario As Integer, - CveEmpresa As Integer, Telefono As String, Mail As String, CveMedicoEspecialidad As Integer, Celular As String, Consultorio As String, Optional CveMedicoSubEspecialidad As Integer = -1, - Optional Torre As String = "-1") As Boolean + Public Function UpdateMedico(CveMedico As Integer, Nombre As String, Apellidos As String, CedulaProfesional As String, FechaNacimiento As Date, Notas As String, Estatus As Boolean, CveUsuario As Integer, + CveEmpresa As Integer, Telefono As String, Mail As String, CveMedicoEspecialidad As Integer, Celular As String, Optional CveMedicoSubEspecialidad As Integer = -1, Optional CveVendedor As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_MedicosUpdate") With SqlAdapter.SelectCommand.Parameters .Add("@CveMedico", SqlDbType.Int).Value = CveMedico - .Add("@Medico", SqlDbType.VarChar).Value = Medico + .Add("@Nombre", SqlDbType.VarChar).Value = Nombre + .Add("@Apellidos", SqlDbType.VarChar).Value = Apellidos + '.Add("@Medico", SqlDbType.VarChar).Value = Medico .Add("@CedulaProfesional", SqlDbType.VarChar).Value = CedulaProfesional .Add("@FechaNacimiento", SqlDbType.Date).Value = FechaNacimiento .Add("@Notas", SqlDbType.VarChar).Value = Notas - .Add("@DiasAtencion", SqlDbType.VarChar).Value = DiasAtencion - .Add("@Horario", SqlDbType.VarChar).Value = Horario - .Add("@Lugar", SqlDbType.VarChar).Value = Lugar + '.Add("@DiasAtencion", SqlDbType.VarChar).Value = DiasAtencion + '.Add("@Horario", SqlDbType.VarChar).Value = Horario + '.Add("@Lugar", SqlDbType.VarChar).Value = Lugar .Add("@Estatus", SqlDbType.Bit).Value = Estatus .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa @@ -6185,9 +6221,10 @@ Public Class ClsVentas .Add("@Mail", SqlDbType.VarChar).Value = Mail .Add("@CveMedicoEspecialidad", SqlDbType.Int).Value = CveMedicoEspecialidad .Add("@Celular", SqlDbType.VarChar).Value = Celular - .Add("@Consultorio", SqlDbType.VarChar).Value = Consultorio + '.Add("@Consultorio", SqlDbType.VarChar).Value = Consultorio .Add("@CveMedicoSubEspecialidad", SqlDbType.Int).Value = CveMedicoSubEspecialidad - .Add("@Torre", SqlDbType.VarChar).Value = Torre + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + '.Add("@Torre", SqlDbType.VarChar).Value = Torre End With @@ -6310,9 +6347,6 @@ Public Class ClsVentas #End Region - - - #Region "S U B E S P E C I A L I D A D E S" Public Function GetMedicosSubEspecialidades(CveMedicoSubEspecialidad As Integer, CveEmpresa As Integer, Estatus As Integer) As Boolean @@ -6405,6 +6439,111 @@ Public Class ClsVentas #End Region +#Region "MEDICO CLIENTE SUCURALES" + + + + Public Function GetMedicosClientesSucursales(CveMedico As Integer, CveEmpresa As Integer) As Boolean + + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_MedicosClientesSucursalesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveMedico", SqlDbType.Int).Value = CveMedico + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los detalles.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + + End Function + + Public Function AddMedicosClientesSucursales(CveMedico As Integer, CveCliente As Integer, CveClienteSucursal As Integer, DiasAtencion As String, Horario As String, Consultorio As String, Torre As String, AsistenteNombre As String, + CveUsuario As Integer, CveEmpresa As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_MedicosClientesSucursalesAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveMedico", SqlDbType.Int).Value = CveMedico + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal + .Add("@DiasAtencion", SqlDbType.VarChar).Value = DiasAtencion + .Add("@Horario", SqlDbType.VarChar).Value = Horario + .Add("@Consultorio", SqlDbType.VarChar).Value = Consultorio + .Add("@Torre", SqlDbType.VarChar).Value = Torre + .Add("@AsistenteNombre", SqlDbType.VarChar).Value = AsistenteNombre + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al guardar el detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + + End Function + + Public Function UpdateMedicosClientesSucursales(CveMedicoClienteSucursal As Integer, CveMedico As Integer, CveCliente As Integer, CveClienteSucursal As Integer, DiasAtencion As String, Horario As String, Consultorio As String, Torre As String, + AsistenteNombre As String, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_MedicosClientesSucursalesUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveMedicoClienteSucursal", SqlDbType.Int).Value = CveMedicoClienteSucursal + .Add("@CveMedico", SqlDbType.Int).Value = CveMedico + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal + .Add("@DiasAtencion", SqlDbType.VarChar).Value = DiasAtencion + .Add("@Horario", SqlDbType.VarChar).Value = Horario + .Add("@Consultorio", SqlDbType.VarChar).Value = Consultorio + .Add("@Torre", SqlDbType.VarChar).Value = Torre + .Add("@AsistenteNombre", SqlDbType.VarChar).Value = AsistenteNombre + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el Medico.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + + End Function + + Public Function RemoveMedicosClientesSucursales(CveMedicoClienteSucursal As Integer, CveEmpresa As Integer) As Boolean + + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_MedicosClientesSucursalesRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveMedicoClienteSucursal", SqlDbType.Int).Value = CveMedicoClienteSucursal + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + + End Function + + +#End Region + #Region "PRODEDIMIENTOS" Public Function GetProcedimientos(CveProcedimiento As Integer, CveEmpresa As Integer, Estatus As Integer) As Boolean @@ -6631,6 +6770,82 @@ Public Class ClsVentas #End Region +#Region "VENTAS MEDICAS COMISIONES" + + Public Function GetComisionesMedicas(CveEmpresa As Integer) As Boolean + + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_ComisionesMedicasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las comisiones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + + End Function + + Public Function AddUpdateComisionesMedicas(CvePS As Integer, CveEmpresa As Integer, ComisionMedico As Decimal, ComisionVendedor As Decimal, ComisionTecnico As Decimal) As Boolean + + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_ComisionesMedicasAddUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@ComisionMedico", SqlDbType.Money).Value = ComisionMedico + .Add("@ComisionVendedor", SqlDbType.Money).Value = ComisionVendedor + .Add("@ComisionTecnico", SqlDbType.Money).Value = ComisionTecnico + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar las comisiones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + + End Function + + Public Function GetComisionesMedicasRep(FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer, CveSubProyecto As Integer, CveProcedimiento As Integer, CveMedico As Integer, CveVendedor As Integer, CveUsuario As Integer, CveTipoVenta As Integer) As Boolean + + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_ComisionesMedicasRepGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveMedico", SqlDbType.Int).Value = CveMedico + .Add("@CveProcedimiento", SqlDbType.Int).Value = CveProcedimiento + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveTipoVenta", SqlDbType.Int).Value = CveTipoVenta + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte comisiones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + + End Function + +#End Region #Region "DEVOLUICON" diff --git a/App_Code/Empresa.vb b/App_Code/Empresa.vb index 9125fe0bd..2b0d41c6f 100644 --- a/App_Code/Empresa.vb +++ b/App_Code/Empresa.vb @@ -62,8 +62,7 @@ Public Class Empresa Public Property Importe As Decimal Public Property CveMetodoPago As Integer Public Property CodigoRegimenFiscal As String - Public Property RegimenFiscal As String - Public Property EstatusFacturacion As Boolean + Public Property RegimenFiscal As String Public Property Estatus As Boolean Public Property UsaContabilidad As Boolean Public Property UsaBancos As Boolean diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 56b3d1290..2c1c5dec4 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -1670,7 +1670,7 @@ Namespace Modelos Me.IEPS = Me.DtDetalle.SUMD("ImporteIEPS") Me.Descuento = Me.DtDetalle.SUMD("Descuento") - Me.Total = Me.SubTotal + Me.IVA + Me.IEPS - (Me.RetIVA + Me.RetISR) + Me.Total = Me.SubTotal - Me.Descuento + Me.IVA + Me.IEPS - (Me.RetIVA + Me.RetISR) End Sub Public Sub PreparaTimbre() @@ -2303,7 +2303,7 @@ Namespace Modelos End If 'AJUSTES' - If DtAjustes IsNot Nothing AndAlso DtAjustes.Rows.Count > 0 Then + If DtAjustes IsNot Nothing AndAlso DtAjustes.FiltraParametros("CveVentaDetalle > 0").Rows.Count > 0 Then For Each Dr As DataRow In DtAjustes.Rows If Not ObjAcum.AddGarantiasDetalle(Dr("CveVentaDetalle").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("CveFolioGarantia").ToString.ToEntero, Dr("CveTipoUso").ToString.ToEntero, Dr("CodigoEnsamble").ToString, Dr("CodigoLinea").ToString, Dr("CodigoInspeccion").ToString, Dr("CveTipoDefecto").ToString.ToEntero, Dr("CodigoTD").ToString, Dr("TipoComprobante").ToString.ToEntero(), @@ -3248,31 +3248,40 @@ Namespace Modelos Dim TipoMovto68 As Boolean = TipoMovimiento 'SI ES CANCELACION DEBE GENERAR EL MOVIMIENTO DE SALIDA DE USADOS If ValorMultiplicador = -1 Then - CveMovimientoReferencia = CancelarInventarioUsado(ObjFactura, CveAlmacen, CveMovimiento, ObjInventario, ObjConta, GenerarPrePoliza:=False) + Dim CveMovCancelacion = CancelarInventarioUsado(ObjFactura, CveAlmacen, CveMovimiento, ObjInventario, ObjConta, GenerarPrePoliza:=False) + If CveMovCancelacion > 0 Then + CveMovimientoReferencia = CveMovCancelacion + Else + ErrorPrepoliza = True + End If Else CveMovimientoReferencia = CveMovimiento End If ' If ObjFactura.EsGarantia Then, el valor viene en cero ya - If ObjInventario.GetMovimientosDetalle(CveMovimientoReferencia, UsuarioActual.CveEmpresa) Then - Dim Importe68 As Decimal = ObjInventario.DtResultados.SUMD("Total").RoundSQL * ValorMultiplicador - If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovto68, Importe68, Importe68, 68, Referencia, Concepto, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimientoReferencia, Contabilizable:=False) Then + If Not ErrorPrepoliza Then + If ObjInventario.GetMovimientosDetalle(CveMovimientoReferencia, UsuarioActual.CveEmpresa) Then + Dim Importe68 As Decimal = ObjInventario.DtResultados.SUMD("Total").RoundSQL * ValorMultiplicador + + If Not ErrorPrepoliza AndAlso Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovto68, Importe68, Importe68, 68, Referencia, Concepto, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimientoReferencia, Contabilizable:=False) Then + ErrorPrepoliza = True + End If + + If Not ErrorPrepoliza AndAlso Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovto68, importeMovimiento, importeMX, 277, Referencia, Concepto, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then + ErrorPrepoliza = True + End If + + Dim Importe318 As Decimal = (Math.Abs(importeMovimiento) - Math.Abs(Importe68)) * ValorMultiplicador + + If Not ErrorPrepoliza AndAlso Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovto68, Importe318, Importe318, 318, Referencia, Concepto, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then + ErrorPrepoliza = True + End If + + Else ErrorPrepoliza = True End If - - If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovto68, importeMovimiento, importeMX, 277, Referencia, Concepto, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then - ErrorPrepoliza = True - End If - - Dim Importe318 As Decimal = (Math.Abs(importeMovimiento) - Math.Abs(Importe68)) * ValorMultiplicador - - If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovto68, Importe318, Importe318, 318, Referencia, Concepto, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then - ErrorPrepoliza = True - End If - - Else - ErrorPrepoliza = True End If + 'Else ' If ObjInventario.GetMovimientosDetalle(CveMovimientoReferencia, UsuarioActual.CveEmpresa) Then ' Dim Importe68 As Decimal = ObjInventario.DtResultados.SUMD("") @@ -4088,6 +4097,45 @@ Namespace Modelos ErrorList.Add("No se pueden facturar las remisiones, con ese tipo de comprobante seleccionado") Else If ObjFactura.RemisionesLista.Count > 0 Then + + 'CANCELACION DE PAGOS DE REMISIONES + If ObjFactura.DtPagosFacturaGlobal IsNot Nothing Then + For Each DrPago As DataRow In ObjFactura.DtPagosFacturaGlobal.Rows + + Dim ventaRef As ClsPaginas.Venta = Nothing + + Using ObjFacturaRef As New Modelos.Factura(UsuarioActual, DrPago("CveVenta").ToString().ToEntero(), UsuarioActual.CveEmpresa, CargaDTDetalle:=False, VerificaAlmacen:=False, CargaDatosCliente:=False, CargaDatosRelacionados:=False) + ventaRef = New ClsPaginas.Venta(ObjFacturaRef, UsuarioActual) + End Using + + If ventaRef IsNot Nothing Then + Dim Importe As Decimal = DrPago("Importe").ToString().ToDecimal() * -1 + + Dim Pago As New ClsPaginas.VentaPago + Pago.Fecha = Now + Pago.FechaDocumentoRelacionado = DrPago("FechaDocumento").ToString().ToDate + Pago.ImportePagoVenta = Importe + Pago.ImportePago = Importe + Pago.CveIE = DrPago("CveIE").ToString().ToEntero() + Pago.CveMonedaPago = DrPago("CveMoneda").ToString().ToEntero() + Pago.TCPago = DrPago("TipoCambio").ToString().ToDecimal() + Pago.AplicaTraslado = False + Pago.Referencia = DrPago("Folio").ToString() + Pago.CveVentaAmortizacion = -1 + Pago.TipoPago = DrPago("TipoPago").ToString() + Pago.CveClientePago = ObjFactura.CveCliente + + ErrorPrepoliza = ClsPaginas.AplicaPrePolizaPagoVenta(ventaRef, Pago, ObjFactura.CvePrePoliza, ObjConta, AplicarConceptoAplicacion:=False) + Else + ErrorPrepoliza = True + End If + + If ErrorPrepoliza Then + Exit For + End If + Next + End If + For Each CveRemision As Integer In RemisionesLista If Not ObjConta.TraspasarSaldosRemision(CveRemision, ObjFactura.CvePrePoliza, ObjFactura.CveVenta) Then ErrorPrepoliza = True @@ -4106,6 +4154,38 @@ Namespace Modelos Exit For End If Next + + 'TRASPASO DE PAGOS DE REMISIONES A FACTURA GLOBAL + If ObjFactura.DtPagosFacturaGlobal IsNot Nothing Then + + Dim VentaActual As New ClsPaginas.Venta(ObjFactura, UsuarioActual) + + For Each DrPago As DataRow In ObjFactura.DtPagosFacturaGlobal.Rows + Dim Importe As Decimal = DrPago("Importe").ToString().ToDecimal() + + Dim Pago As New ClsPaginas.VentaPago + Pago.Fecha = Now + Pago.FechaDocumentoRelacionado = DrPago("FechaDocumento").ToString().ToDate + Pago.ImportePagoVenta = Importe + Pago.ImportePago = Importe + Pago.CveIE = DrPago("CveIE").ToString().ToEntero() + Pago.CveMonedaPago = DrPago("CveMoneda").ToString().ToEntero() + Pago.TCPago = DrPago("TipoCambio").ToString().ToDecimal() + Pago.AplicaTraslado = False + Pago.Referencia = DrPago("Folio").ToString() + Pago.CveVentaAmortizacion = DrPago("CveVenta").ToString().ToEntero() + Pago.TipoPago = DrPago("TipoPago").ToString() + Pago.CveClientePago = ObjFactura.CveCliente + + ErrorPrepoliza = ClsPaginas.AplicaPrePolizaPagoVenta(VentaActual, Pago, ObjFactura.CvePrePoliza, ObjConta, AplicarConceptoAplicacion:=False) + + If ErrorPrepoliza Then + Exit For + End If + Next + End If + + End If End If End If @@ -4116,6 +4196,7 @@ Namespace Modelos End If End If + 'REGRESA SALDO A LAS REMISIONES QUE SE FACTURARON EN EL INGRESO QUE SE ESTA CANCELANDO 'SE DEBE DE EXCLUIR CUANDO ES REFACTURACIÓN If ObjFactura.TipoDocto = "Ing" And ValorMultiplicador = -1 AndAlso CveEstatusRefacturacion = 0 AndAlso Not SeCancelaRemisionProceso AndAlso DtRemisionesRelacionadas IsNot Nothing Then ' se debe de excluir cuando es refacturación @@ -4237,14 +4318,22 @@ Namespace Modelos End If End If - If RemisionesLista IsNot Nothing AndAlso factura.TipoDocto = "Ing" AndAlso RemisionesLista.Count > 0 Then - For Each CveRemision As Integer In RemisionesLista - 'El almacen general es el Primer Almacen de Material en la Sucursal - If Not TraspasoAlmacen(ObjInventario, ObjVentas, CveRemision, ObjConta, True, 9, factura.EsFacturaGlobal) Then - OcurrioError = True - Exit For - End If - Next + + 'TEMPORAL. PARA OPTIMIZAR LOS TIEMPOS PARA LA GENERACION DE LA FACTURA GLOBAL + If factura.EsFacturaGlobal Then + If Not ObjInventario.ActualizarEsDevolucionVenta(factura.CveVenta, 2) Then + OcurrioError = True + End If + Else + If RemisionesLista IsNot Nothing AndAlso factura.TipoDocto = "Ing" AndAlso RemisionesLista.Count > 0 Then + For Each CveRemision As Integer In RemisionesLista + 'El almacen general es el Primer Almacen de Material en la Sucursal + If Not TraspasoAlmacen(ObjInventario, ObjVentas, CveRemision, ObjConta, True, 9, factura.EsFacturaGlobal) Then + OcurrioError = True + Exit For + End If + Next + End If End If If factura.TipoDocto = "Rem" AndAlso factura.ServicioDomicilio Then @@ -7387,6 +7476,7 @@ Namespace Modelos Public Property DtPromociones As Data.DataTable Public Property DtImpuestosLocales As Data.DataTable Public Property DtPagos As Data.DataTable + Public Property DtPagosFacturaGlobal As Data.DataTable Public Property DtRemisionesPS As Data.DataTable Public Property DtRemisiones As Data.DataTable Public Property DtPedidos2 As Data.DataTable diff --git a/App_Code/Timbrado.vb b/App_Code/Timbrado.vb index ff33b1f0b..1374feb13 100644 --- a/App_Code/Timbrado.vb +++ b/App_Code/Timbrado.vb @@ -9,7 +9,6 @@ Imports System.Reflection Imports System.Xml Imports System.Xml.Serialization Imports Extensiones -Imports External.Office Imports Newtonsoft.Json.Linq Imports Profact.TimbraCFDI33.Complementos Imports ProfactCartaPorte = Profact.TimbraCFDI33.Complementos.CartaPorte30 @@ -29,8 +28,7 @@ Public Class Timbrado Public Property CancelacionState As Integer Public Property CancelacionMensaje As String Public Property CancelacionFecha As Date - Public Const LigaVerificacionSAT As String = "https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx" - Public Const LigaVerificacionSATCCP As String = "https://verificacfdi.facturaelectronica.sat.gob.mx/verificaccp/default.aspx" + Public Class AcuseCancelacionSAT Public Property CodigoEstatus As String Public Property EsCancelable As String @@ -2693,7 +2691,7 @@ concep.DescripcionesEspecificas.NumeroSerie) For Each docp As CFDIComplementoPago In ObjCFDITimbre.ComplementoPagos20.ComplementoPagos Dim MonDiferente As Integer = (From c In docp.DocumentosRelacionados - Where c.MonedaDR <> docp.MonedaP + Where c.MonedaDR <> docp.MonedaP AndAlso docp.MonedaP = "USD" Select c.MonedaDR).Count() If MonDiferente > 0 Then cfdi.ContieneVariasMonedas = True 'consideración adicional Rev. B @@ -3075,7 +3073,7 @@ concep.DescripcionesEspecificas.NumeroSerie) Try Dim RutaCBB As String = $"{UsuarioActual.Empresa.Ruta}CBB\{ObjCFDITimbre.Comprobante.SerieFolio}.jpg" Dim qrCode As New GoFac.QrCode() - Dim bCBB As Byte() = qrCode.GenerarQrCode($"{LigaVerificacionSAT}?re={UsuarioActual.Empresa.RFC}&rr={ObjCFDITimbre.Receptor.RFC}&tt={String.Format("{0,12:F6}", ObjCFDITimbre.Comprobante.Total).Trim()}&id={UUID}&fe={SelloCfdi.Substring(SelloCfdi.Length - 8, 8)}") + Dim bCBB As Byte() = qrCode.GenerarQrCode($"{ClsPaginas.LigaVerificacionSAT}?re={UsuarioActual.Empresa.RFC}&rr={ObjCFDITimbre.Receptor.RFC}&tt={String.Format("{0,12:F6}", ObjCFDITimbre.Comprobante.Total).Trim()}&id={UUID}&fe={SelloCfdi.Substring(SelloCfdi.Length - 8, 8)}") File.WriteAllBytes(RutaCBB, bCBB) bCBB = Nothing Catch ex As Exception @@ -3091,7 +3089,7 @@ concep.DescripcionesEspecificas.NumeroSerie) Dim RutaCBB As String = $"{UsuarioActual.Empresa.Ruta}CBB\{ObjCFDITimbre.Comprobante.SerieFolio}_CCP.jpg" Dim qrCode As New GoFac.QrCode() - Dim bCBB As Byte() = qrCode.GenerarQrCode($"{LigaVerificacionSATCCP}?IdCCP={cfdi.CfdiInfo.IdCCP}&FechaOrig={Carta.Ubicaciones(0).FechaHoraSalidaLlegada}&FechaTimb={cfdi.CfdiInfo.FechaTimbrado}") + Dim bCBB As Byte() = qrCode.GenerarQrCode($"{ClsPaginas.LigaVerificacionSATCCP}?IdCCP={cfdi.CfdiInfo.IdCCP}&FechaOrig={Carta.Ubicaciones(0).FechaHoraSalidaLlegada}&FechaTimb={cfdi.CfdiInfo.FechaTimbrado}") File.WriteAllBytes(RutaCBB, bCBB) bCBB = Nothing Catch ex As Exception @@ -3274,7 +3272,8 @@ concep.DescripcionesEspecificas.NumeroSerie) If result IsNot Nothing Then If result.timbradoOk Then - + Dim SelloCfdi As String + SelloCfdi = "" UUID = result.UUID 'GUARDA EL XML RETORNADO POR EL PAC @@ -3354,9 +3353,10 @@ concep.DescripcionesEspecificas.NumeroSerie) Try Dim RutaCBB As String = $"{UsuarioActual.Empresa.Ruta}CBB\{ObjCFDITimbre.Comprobante.SerieFolio}.jpg" - Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() - CBB.GenerarCBB(UsuarioActual.Empresa.RFC, ObjCFDITimbre.Receptor.RFC, ObjCFDITimbre.Comprobante.Total, UUID, RutaCBB) - CBB = Nothing + Dim qrCode As New GoFac.QrCode() + Dim bCBB As Byte() = qrCode.GenerarQrCode($"{ClsPaginas.LigaVerificacionSAT}?re={UsuarioActual.Empresa.RFC}&rr={ObjCFDITimbre.Receptor.RFC}&tt={String.Format("{0,12:F6}", ObjCFDITimbre.Comprobante.Total).Trim()}&id={UUID}&fe={SelloCfdi.Substring(SelloCfdi.Length - 8, 8)}") + File.WriteAllBytes(RutaCBB, bCBB) + bCBB = Nothing Catch ex As Exception OnError("Ocurrió un error al generar el QR", ex) End Try diff --git a/App_Code/modExtensiones.vb b/App_Code/modExtensiones.vb index 47a330307..854ab6997 100644 --- a/App_Code/modExtensiones.vb +++ b/App_Code/modExtensiones.vb @@ -1195,6 +1195,24 @@ Namespace Extensiones End If Return TmpDt + End Function + + + Public Function GroupByDt(dtt As DataTable, ByVal RowFilter As String, ByVal Orderby As String, ByVal GroupByColumns As String(), ByVal AggregateColumn As String) As DataTable + Dim dv As DataView = New DataView(dtt, RowFilter, Orderby, DataViewRowState.CurrentRows) + Dim dtGroup As DataTable = dv.ToTable(True, GroupByColumns) + dtGroup.Columns.Add("TotalCount", GetType(Integer)) + dtGroup.Columns.Add("TotalSum", GetType(Decimal)) + Dim filtros As New List(Of String) + For Each dr As DataRow In dtGroup.Rows + For Each col As String In GroupByColumns + filtros.Add($"{col}='{dr(col)}'") + Next + dr("TotalCount") = dtt.Compute($"Count({AggregateColumn})", String.Join(" AND ", filtros)) + dr("TotalSum") = dtt.Compute($" SUM({AggregateColumn})", String.Join(" AND ", filtros)) + Next + + Return dtGroup End Function diff --git a/Ashx/GenerarPDFFactura.ashx b/Ashx/GenerarPDFFactura.ashx index c6d59baaf..0ccfd7b5e 100644 --- a/Ashx/GenerarPDFFactura.ashx +++ b/Ashx/GenerarPDFFactura.ashx @@ -161,8 +161,8 @@ Public Class GenerarPDFFactura : Implements IHttpHandler Dim rutaReporte As String = "Empresas\Grales\Formatos\FacturaSALI.rdlc" - Dim QR As ClbNegBICFDv3_2.ClsNegCBBGenerar = New ClbNegBICFDv3_2.ClsNegCBBGenerar() - Dim cQr As Byte() = QR.GenerarCBBBytes(objxml.emisor.Rfc, objxml.receptor.Rfc, objxml.comprobante.Total, objxml.complemento.UUID) + Dim cQr As Byte() = ClsPaginas.GeneraQRSAT(objxml.emisor.Rfc, objxml.receptor.Rfc, objxml.comprobante.Total, objxml.complemento.UUID) + Dim parametros As List(Of ReportParameter) = New List(Of ReportParameter)() parametros.Add(New ReportParameter("comprobante_Certificado", objxml.comprobante.Certificado)) parametros.Add(New ReportParameter("comprobante_CondicionesDePago", objxml.comprobante.CondicionesDePago)) diff --git a/Ashx/SIGWeb.ashx b/Ashx/SIGWeb.ashx index 9d6cd2c89..fdf93a213 100644 --- a/Ashx/SIGWeb.ashx +++ b/Ashx/SIGWeb.ashx @@ -1008,9 +1008,9 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState Name = Name.REPLACE(" ", "*") If Name <> "-1" Then If PSCodigoDescripcion = "PSCodigo" Then - DTPS = DTPS.Where((Function(a) a!PSCodigo.ToString.ToLower Like ("*" + Name.ToLower + "*"))) + DTPS = DTPS.Where((Function(a) a!PSCodigo.ToString.ToLower Like ("*" + Name.ToLower + "*") OrElse a!NumeroParte.ToString.ToLower Like ("*" + Name.ToLower + "*"))) Else - DTPS = DTPS.Where((Function(a) a!PSCodigoClasificacion.ToString.ToLower Like ("*" + Name.ToLower + "*"))) + DTPS = DTPS.Where((Function(a) a!PSCodigoClasificacion.ToString.ToLower Like ("*" + Name.ToLower + "*") OrElse a!NumeroParte.ToString.ToLower Like ("*" + Name.ToLower + "*"))) End If End If diff --git a/Bancos/DepositosCaja.aspx b/Bancos/DepositosCaja.aspx index 0c7bb3ea1..db0f577d6 100644 --- a/Bancos/DepositosCaja.aspx +++ b/Bancos/DepositosCaja.aspx @@ -1,401 +1,403 @@ -<%@ Page Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="DepositosCaja.aspx.vb" Inherits="Bancos_DepositosCaja" %> - - - - - - - - - - - - -   - - - - <%--
  • +<%@ Page Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="DepositosCaja.aspx.vb" Inherits="Bancos_DepositosCaja" %> + + + + + + + + + + + + +   + + + + <%--
  • Imprimir -
  • --%> -
    - - - - - -
    -
    -
    - - -
    -
    -
    - - -
    - - -
    - - - -
    -
    - - - - - - - - -
    -
    - - - -
    -
    - - - - - - - - -
    - -
    - - -
    -
    - - - - - - - - - - - MSI - 3M - 6M - 9M - 12M - -
    -
    - -
    - -
    -
    - -
    - -
    - -
    -
    - - - -
    - -
    - -
    -
    - -
    - -
    - -
    -
    - -
    - - - - - - - - - - -
    -
    -
    -
    - -
    -
    -
    - -
    -
    - - - -
    - - -
    - Seleccionado: $ - 0.00 - -
    -
    -
    -
    - - -
    -
    - -
    - - - - - -
    -
    -
    - -
    - - -
    -
    - -
    - -
    - -
    - -
    -
    - - - -
    -
    - - - - - - - - - - - - - > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    -
    - - - -
    -
    -
    -
    - - -
    -
    -
    -
    - - -
    - - + --%> + + + + + + +
    +
    +
    + + +
    +
    +
    + + +
    + + +
    + + + +
    +
    + + + + + + + + +
    +
    + + + +
    +
    + + + + + + + + +
    + +
    + + +
    +
    + + + + + + + + + + + MSI + 3M + 6M + 9M + 12M + +
    +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + + + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + + + + + + + + + + +
    +
    +
    +
    + +
    +
    +
    + +
    +
    + + + +
    + + +
    + Seleccionado: $ + 0.00 + +
    +
    +
    +
    + + +
    +
    + +
    + + + + + +
    +
    +
    + +
    + + +
    +
    + +
    + +
    + +
    + +
    +
    + + + +
    +
    + + + + + + + + + + + + + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    +
    + + + +
    +
    +
    +
    + + +
    +
    +
    +
    + + +
    + + + - - - - + + + + + diff --git a/Bancos/DepositosCaja.aspx.vb b/Bancos/DepositosCaja.aspx.vb index b3150609e..f1d222eae 100644 --- a/Bancos/DepositosCaja.aspx.vb +++ b/Bancos/DepositosCaja.aspx.vb @@ -2,6 +2,8 @@ Option Strict On Imports System.Data +Imports System.IO +Imports System.Net.Http Imports Extensiones Partial Class Bancos_DepositosCaja Inherits ClsPaginas @@ -148,8 +150,9 @@ Partial Class Bancos_DepositosCaja Dim Comision As Decimal = TxtComision.Text.ToDecimal Dim Descuento As Decimal = TxtDescuento.Text.ToDecimal Dim IVA As Decimal = TxtIVA.Text.ToDecimal - Dim ImporteInter As Decimal = TxtComisionIntermediario.Text.ToDecimal - + Dim ImporteInter As Decimal = TxtComisionIntermediario.Text.ToDecimal + + Dim MsgError As String = "Ocurrió un error al realizar los depositos" For Each Gvr As GridViewRow In GvFacturas.Rows If Gvr.FCCheckBox("ChkFactura").Checked Then TotalImporte += Gvr.DataKey("Importe").ToDecimal @@ -184,197 +187,230 @@ Partial Class Bancos_DepositosCaja TotalImporte = TotalImporte - TxtComisionIntermediario.Text.ToDecimal - IVA End If - Dim OcurrioError As Boolean = False - Dim ObjConta As New ClsContabilidad() + Dim OcurrioError As Boolean = False + Dim NuevaCvePrePoliza As Integer + + Dim pdf64 As String = "" + Dim documentos As String = "Los Depósitos se realizaron exitosamente

    " + + Dim CveIEOrigen As Integer = -1 'CajaChica + Dim CveIEDestino As Integer = -1 'Banco + + Dim ObjConta As New ClsContabilidad() Dim ObjBancos As New ClsBancos(ObjConta.IniciaTransacSQL()) - Dim CveIEOrigen As Integer 'CajaChica - Dim CveIEDestino As Integer 'Banco - Dim NuevaCvePrePoliza As Integer - Dim FolioIE As Long = -1 - Dim CveMoneda As Integer = 1 - Dim TipoCambio As Decimal = 1 - Dim Fecha As Date = TxtFecha.Text.ToDate - Dim drOrigen As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveCuenta:=DdlCajaChica.SelectedValue.ToEntero, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("") - Dim drDestino As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveCuenta:=DdlCuentaDeposito.SelectedValue.ToEntero, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("") - Dim CveSubProyecto As Integer = DdlSubProyectos.SelectedValue.ToEntero - Dim CveClasificacion As Integer = -1 - - Dim CveSubProyectoComision As Integer - Dim CveClasificacionComision As Integer - - Dim CveSubProyectoDescuento As Integer - Dim CveClasificacionDescuento As Integer - - Dim documentos As String = "Los Depósitos se realizaron exitosamente

    " - Dim imprimirFolios As String = "" - Dim CveSubProyectoIntermediario As Integer - Dim CveClasificacionIntermediario As Integer - Dim CveProveedorIntermediario As Integer = -1 - - If drOrigen IsNot Nothing Then - CveMoneda = drOrigen("CveMoneda").ToString.ToEntero - End If - - If drDestino IsNot Nothing Then - CveMoneda = drDestino("CveMoneda").ToString.ToEntero - End If - - NuevaCvePrePoliza = ObjConta.AddPrePolizas("DepCaja", 13, TotalImportePrePoliza, TotalImportePrePoliza, CveMoneda, Fecha, "Depósito Bancario", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=1) - - Dim IntermediarioFactura As Boolean = False - If UsuarioActual.CveEmpresa = 145 Then IntermediarioFactura = True - If ChkIntermediario.Checked Then - - CveSubProyectoIntermediario = DdlSubProyectoIntermediario.SelectedValue.ToEntero - CveClasificacionIntermediario = DdlClasificacionIntermediario.SelectedValue.ToEntero - CveProveedorIntermediario = DdlProveedorIntermediario.SelectedValue.ToEntero - - If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then ' empresa llantera - If Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, False, TotalImporte, TotalImporte, 95, DdlClasificacionIntermediario.SelectedItem.Text, DdlClasificacionIntermediario.SelectedItem.Text, CveClasificacion:=CveClasificacionIntermediario, CveSubProyecto:=CveSubProyectoIntermediario, CveProveedor:=CveProveedorIntermediario, CveCuenta:=57619) Then - OcurrioError = True - End If - If Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, True, TotalImporte, TotalImporte, 95, DdlClasificacionIntermediario.SelectedItem.Text, DdlClasificacionIntermediario.SelectedItem.Text, CveClasificacion:=CveClasificacionIntermediario, CveSubProyecto:=CveSubProyectoIntermediario, CveProveedor:=CveProveedorIntermediario, CveCuenta:=57619) Then - OcurrioError = True - End If + Try + Dim FolioIE As Long = -1 + Dim CveMoneda As Integer = 1 + Dim TipoCambio As Decimal = 1 + Dim Fecha As Date = TxtFecha.Text.ToDate + Dim drOrigen As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveCuenta:=DdlCajaChica.SelectedValue.ToEntero, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("") + Dim drDestino As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveCuenta:=DdlCuentaDeposito.SelectedValue.ToEntero, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("") + Dim CveSubProyecto As Integer = DdlSubProyectos.SelectedValue.ToEntero + Dim CveClasificacion As Integer = -1 + + Dim CveSubProyectoComision As Integer + Dim CveClasificacionComision As Integer + + Dim CveSubProyectoDescuento As Integer + Dim CveClasificacionDescuento As Integer + + + Dim imprimirFolios As String = "" + Dim CveSubProyectoIntermediario As Integer + Dim CveClasificacionIntermediario As Integer + Dim CveProveedorIntermediario As Integer = -1 + + If drOrigen IsNot Nothing Then + CveMoneda = drOrigen("CveMoneda").ToString.ToEntero End If - If Not IntermediarioFactura Then ' si factura no se manda al gasto sino se disminuye solo lo depositado - If Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, False, ImporteInter, ImporteInter, 51, DdlClasificacionIntermediario.SelectedItem.Text, DdlClasificacionIntermediario.SelectedItem.Text, CveClasificacion:=CveClasificacionIntermediario, CveSubProyecto:=CveSubProyectoIntermediario) Then - OcurrioError = True - End If + If drDestino IsNot Nothing Then + CveMoneda = drDestino("CveMoneda").ToString.ToEntero End If - If IVA <> 0 Then - If Not OcurrioError AndAlso Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, False, IVA, IVA, 14, DdlClasificacionIntermediario.SelectedItem.Text, DdlClasificacionIntermediario.SelectedItem.Text, CveClasificacion:=CveClasificacionIntermediario, CveSubProyecto:=CveSubProyectoIntermediario, PorcentajeImpuesto:=0.16D) Then - OcurrioError = True - End If - End If - - End If - Dim CveTransaccionBanco As Integer = 13 - - If TotalImporte < 0 Then 'que es una devolución, entonces como es negativo, se cambia el concetpo de bancos, por condición de trigger - CveTransaccionBanco = 6 - End If + NuevaCvePrePoliza = ObjConta.AddPrePolizas("DepCaja", 13, TotalImportePrePoliza, TotalImportePrePoliza, CveMoneda, Fecha, "Depósito Bancario", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=1) - 'código temporal, para claudia y toñita, monge, anadelia, alba,patricia - If UsuarioActual.CveUsuario.Contiene(1937, 2452, 3358, 3033, 2897, 2560) Then - FolioIE = TxtFolio.Text.ToEntero - End If - - If FolioIE <= 0 Then - 'Entrada a bancos - FolioIE = ObjBancos.GetNextFolio(DdlCuentaDeposito.SelectedValue.ToEntero, CveTransaccionBanco) - End If + Dim IntermediarioFactura As Boolean = False + If UsuarioActual.CveEmpresa = 145 Then IntermediarioFactura = True + If ChkIntermediario.Checked Then - If CveSubProyecto <= 0 Then 'sino se seleccionó del combo, busca en el listado el primero + CveSubProyectoIntermediario = DdlSubProyectoIntermediario.SelectedValue.ToEntero + CveClasificacionIntermediario = DdlClasificacionIntermediario.SelectedValue.ToEntero + CveProveedorIntermediario = DdlProveedorIntermediario.SelectedValue.ToEntero - For Each Gvr As GridViewRow In GvFacturas.Rows - If Gvr.FCCheckBox("ChkFactura").Checked Then - CveSubProyecto = Gvr.DataKey("CveSubProyecto").ToEntero - Exit For + If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then ' empresa llantera + If Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, False, TotalImporte, TotalImporte, 95, DdlClasificacionIntermediario.SelectedItem.Text, DdlClasificacionIntermediario.SelectedItem.Text, CveClasificacion:=CveClasificacionIntermediario, CveSubProyecto:=CveSubProyectoIntermediario, CveProveedor:=CveProveedorIntermediario, CveCuenta:=57619) Then + OcurrioError = True + End If + If Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, True, TotalImporte, TotalImporte, 95, DdlClasificacionIntermediario.SelectedItem.Text, DdlClasificacionIntermediario.SelectedItem.Text, CveClasificacion:=CveClasificacionIntermediario, CveSubProyecto:=CveSubProyectoIntermediario, CveProveedor:=CveProveedorIntermediario, CveCuenta:=57619) Then + OcurrioError = True + End If End If - Next - End If - If FolioIE <= 0 Then - OcurrioError = True - End If - CveIEOrigen = ObjBancos.AddBancos_IE(DdlCuentaDeposito.SelectedValue.ToEntero, CveTransaccionBanco, Fecha, FolioIE.ToString, "Depósito Bancario", TotalImporte, CveMoneda, 1, TxtObservaciones.Text, "", False, False, -1, NuevaCvePrePoliza, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveProveedorIntermediario:=CveProveedorIntermediario) - - documentos += String.Format("Depósito: {1}    
    ", CveIEOrigen, FolioIE) - - If Not OcurrioError AndAlso ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, False, TotalImporte, TotalImporte * TipoCambio, 30, "Depósito Bancario", "Depósito Bancario", CveClasificacion:=CveClasificacion, CveSubProyecto:=CveSubProyecto, CveIE:=CveIEOrigen) Then - - If ChkFaltante.Checked Then - CveSubProyectoComision = DdlSubProyectoDeposito.SelectedValue.ToEntero - CveClasificacionComision = DdlClasificacion.SelectedValue.ToEntero - If Comision <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, True, Comision, Comision * TipoCambio, 78, DdlClasificacion.SelectedItem.Text, DdlClasificacion.SelectedItem.Text, CveClasificacion:=CveClasificacionComision, CveSubProyecto:=CveSubProyectoComision) Then - OcurrioError = True - End If + If Not IntermediarioFactura Then ' si factura no se manda al gasto sino se disminuye solo lo depositado + If Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, False, ImporteInter, ImporteInter, 51, DdlClasificacionIntermediario.SelectedItem.Text, DdlClasificacionIntermediario.SelectedItem.Text, CveClasificacion:=CveClasificacionIntermediario, CveSubProyecto:=CveSubProyectoIntermediario) Then + OcurrioError = True + End If End If - End If - - If Not OcurrioError AndAlso ChkDescuento.Checked Then - CveSubProyectoDescuento = DdlSubProyectoDescuento.SelectedValue.ToEntero - CveClasificacionDescuento = DdlClasificacionDescuento.SelectedValue.ToEntero - - If Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, False, Descuento, Descuento * TipoCambio, 51, DdlClasificacionDescuento.SelectedItem.Text, DdlClasificacionDescuento.SelectedItem.Text & " " & DdlPersonal.SelectedItem.Text, CveClasificacion:=CveClasificacionDescuento, CveSubProyecto:=CveSubProyectoDescuento, CvePersonal:=DdlPersonal.SelectedValue.ToEntero) Then - OcurrioError = True - End If + + If IVA <> 0 Then + If Not OcurrioError AndAlso Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, False, IVA, IVA, 14, DdlClasificacionIntermediario.SelectedItem.Text, DdlClasificacionIntermediario.SelectedItem.Text, CveClasificacion:=CveClasificacionIntermediario, CveSubProyecto:=CveSubProyectoIntermediario, PorcentajeImpuesto:=0.16D) Then + OcurrioError = True + End If + End If + End If - Else - OcurrioError = True - End If - If Not OcurrioError Then - Dim i As Integer = 0 - For Each Gvr As GridViewRow In GvFacturas.Rows + Dim CveTransaccionBanco As Integer = 13 - If Gvr.FCCheckBox("ChkFactura").Checked Then - 'Datos de las Nuevas PrePolizas - 'Entrada a Bancos + If TotalImporte < 0 Then 'que es una devolución, entonces como es negativo, se cambia el concetpo de bancos, por condición de trigger + CveTransaccionBanco = 6 + End If - Dim Importe As Decimal = Gvr.DataKey("Importe").ToDecimal - Dim SerieFolio As String = Gvr.DataKey("SerieFolio").ToString + If DdlTipoPago.SelectedValue.Contiene("11", "12") Then ' cuando son pagos con tarjetas + CveTransaccionBanco = DdlTipoPago.SelectedValue.ToEntero + End If - 'si es el primero, se descuenta la "comisión" - If i = 0 AndAlso IntermediarioFactura Then - Importe = Importe - ImporteInter - i += 1 - End If + 'código temporal, para claudia y toñita, monge, anadelia, alba,patricia + If UsuarioActual.CveUsuario.Contiene(1937, 2452, 3358, 3033, 2897, 2560) Then + FolioIE = TxtFolio.Text.ToEntero + End If - 'Datos de las Prepolizas A Cancelar - Dim CveIE As Integer = Gvr.DataKey("CveIE").ToEntero - Dim CveVenta As Integer = Gvr.DataKey("CveVenta").ToEntero - Dim CveCuentaBancaria As Integer = Gvr.DataKey("CveCuenta").ToEntero - Dim tCveSubProyecto As Integer = Gvr.DataKey("CveSubProyecto").ToEntero + If FolioIE <= 0 Then + 'Entrada a bancos + FolioIE = ObjBancos.GetNextFolio(DdlCuentaDeposito.SelectedValue.ToEntero, CveTransaccionBanco) + End If - FolioIE = ObjBancos.GetNextFolio(CveCuentaBancaria, 2) - If Not FolioIE > 0 Then - OcurrioError = True + If CveSubProyecto <= 0 Then 'sino se seleccionó del combo, busca en el listado el primero + + For Each Gvr As GridViewRow In GvFacturas.Rows + If Gvr.FCCheckBox("ChkFactura").Checked Then + CveSubProyecto = Gvr.DataKey("CveSubProyecto").ToEntero Exit For End If - CveIEDestino = ObjBancos.AddBancos_IE(CveCuentaBancaria, 2, Fecha, FolioIE.ToString, String.Format("Depósito Bancario: {0}", SerieFolio), Importe, CveMoneda, 1, TxtObservaciones.Text, "", False, False, -1, NuevaCvePrePoliza, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Next + End If - If Not OcurrioError AndAlso Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, True, Importe, Importe * TipoCambio, 30, SerieFolio, String.Format("Depósito Bancario: {0}", SerieFolio), CveClasificacion:=CveClasificacion, CveSubProyecto:=tCveSubProyecto, CveVenta:=CveVenta, CveIE:=CveIEDestino) Then - OcurrioError = True - Exit For - End If - - 'Asignamos la cuenta Deposito - If Not OcurrioError AndAlso Not ObjBancos.UpdateBancos_IECuentaDeposito(CveIEOrigen, CveIE) Then - OcurrioError = True - Exit For - End If - End If - Next - Dim StrEncript As String = Encripta($"OP=DC&CveIE={CveIEOrigen}&CuentaCaja={DdlCajaChica.SelectedItem.Text}&CuentaDepo={DdlCuentaDeposito.SelectedItem.Text}") - - documentos += String.Format("
    Imprimir {1}

    ", StrEncript, "Depósito Bancario") - - End If - - If Not OcurrioError AndAlso ObjConta.ValidacionesPrePoliza(NuevaCvePrePoliza, UsuarioActual, Opcion:=1) Then - If ObjConta.ValorPolizaDescuadre > 0 Then - GuardaLogAD($"Bancos/DepositoCaja | Error{ObjConta.MensajePolizaDescuadre} Diferencia{ObjConta.ValorDiferencia} | CvePrePoliza:{NuevaCvePrePoliza}", "LogPrePolizas") + If FolioIE <= 0 Then OcurrioError = True End If - End If + CveIEOrigen = ObjBancos.AddBancos_IE(DdlCuentaDeposito.SelectedValue.ToEntero, CveTransaccionBanco, Fecha, FolioIE.ToString, "Depósito Bancario", TotalImporte, CveMoneda, 1, TxtObservaciones.Text, "", False, False, -1, NuevaCvePrePoliza, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveProveedorIntermediario:=CveProveedorIntermediario) + + documentos += String.Format("Depósito: {1}    
    ", CveIEOrigen, FolioIE) + + If Not OcurrioError AndAlso ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, False, TotalImporte, TotalImporte * TipoCambio, 30, "Depósito Bancario", "Depósito Bancario", CveClasificacion:=CveClasificacion, CveSubProyecto:=CveSubProyecto, CveIE:=CveIEOrigen) Then + + If ChkFaltante.Checked Then + CveSubProyectoComision = DdlSubProyectoDeposito.SelectedValue.ToEntero + CveClasificacionComision = DdlClasificacion.SelectedValue.ToEntero + If Comision <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, True, Comision, Comision * TipoCambio, 78, DdlClasificacion.SelectedItem.Text, DdlClasificacion.SelectedItem.Text, CveClasificacion:=CveClasificacionComision, CveSubProyecto:=CveSubProyectoComision) Then + OcurrioError = True + End If + End If + End If + + If Not OcurrioError AndAlso ChkDescuento.Checked Then + CveSubProyectoDescuento = DdlSubProyectoDescuento.SelectedValue.ToEntero + CveClasificacionDescuento = DdlClasificacionDescuento.SelectedValue.ToEntero + + If Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, False, Descuento, Descuento * TipoCambio, 51, DdlClasificacionDescuento.SelectedItem.Text, DdlClasificacionDescuento.SelectedItem.Text & " " & DdlPersonal.SelectedItem.Text, CveClasificacion:=CveClasificacionDescuento, CveSubProyecto:=CveSubProyectoDescuento, CvePersonal:=DdlPersonal.SelectedValue.ToEntero) Then + OcurrioError = True + End If + End If + Else + OcurrioError = True + End If + If Not OcurrioError Then + Dim i As Integer = 0 + For Each Gvr As GridViewRow In GvFacturas.Rows + + If Gvr.FCCheckBox("ChkFactura").Checked Then + 'Datos de las Nuevas PrePolizas + 'Entrada a Bancos + + Dim Importe As Decimal = Gvr.DataKey("Importe").ToDecimal + Dim SerieFolio As String = Gvr.DataKey("SerieFolio").ToString + + 'si es el primero, se descuenta la "comisión" + If i = 0 AndAlso IntermediarioFactura Then + Importe = Importe - ImporteInter + i += 1 + End If + + 'Datos de las Prepolizas A Cancelar + Dim CveIE As Integer = Gvr.DataKey("CveIE").ToEntero + Dim CveVenta As Integer = Gvr.DataKey("CveVenta").ToEntero + Dim CveCuentaBancaria As Integer = Gvr.DataKey("CveCuenta").ToEntero + Dim tCveSubProyecto As Integer = Gvr.DataKey("CveSubProyecto").ToEntero + + FolioIE = ObjBancos.GetNextFolio(CveCuentaBancaria, 2) + If Not FolioIE > 0 Then + OcurrioError = True + Exit For + End If + CveIEDestino = ObjBancos.AddBancos_IE(CveCuentaBancaria, 2, Fecha, FolioIE.ToString, String.Format("Depósito Bancario: {0}", SerieFolio), Importe, CveMoneda, 1, TxtObservaciones.Text, "", False, False, -1, NuevaCvePrePoliza, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + + If Not OcurrioError AndAlso Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, True, Importe, Importe * TipoCambio, 30, SerieFolio, String.Format("Depósito Bancario: {0}", SerieFolio), CveClasificacion:=CveClasificacion, CveSubProyecto:=tCveSubProyecto, CveVenta:=CveVenta, CveIE:=CveIEDestino) Then + OcurrioError = True + Exit For + End If + + 'Asignamos la cuenta Deposito + If Not OcurrioError AndAlso Not ObjBancos.UpdateBancos_IECuentaDeposito(CveIEOrigen, CveIE) Then + OcurrioError = True + Exit For + End If + End If + Next + Dim StrEncript As String = Encripta($"OP=DC&CveIE={CveIEOrigen}&CuentaCaja={DdlCajaChica.SelectedItem.Text}&CuentaDepo={DdlCuentaDeposito.SelectedItem.Text}") + + documentos += String.Format("
    Imprimir {1}

    ", StrEncript, "Depósito Bancario") + + End If + + If Not OcurrioError AndAlso ObjConta.ValidacionesPrePoliza(NuevaCvePrePoliza, UsuarioActual, Opcion:=1) Then + If ObjConta.ValorPolizaDescuadre > 0 Then + GuardaLogAD($"Bancos/DepositoCaja | Error{ObjConta.MensajePolizaDescuadre} Diferencia{ObjConta.ValorDiferencia} | CvePrePoliza:{NuevaCvePrePoliza}", "LogPrePolizas") + OcurrioError = True + End If + End If + + If Not OcurrioError Then + documentos += String.Format("Prepóliza

    ", NuevaCvePrePoliza) + End If + + Catch ex As Exception + OcurrioError = True + OnError("Ocurrió un error al procesar los datos", ex) + End Try If OcurrioError Then ObjConta.RollBack() - Alert("Ocurrio un error al realizar los depositos", TipoMensaje.MsgError) + Alert(MsgError, TipoMensaje.MsgError) Else - ObjConta.Commit() - documentos += String.Format("Prepóliza

    ", NuevaCvePrePoliza) - + + If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then + Try + pdf64 = ImpresionDirectaPDF(CveIEOrigen, NuevaCvePrePoliza) + Catch ex As Exception + pdf64 = "" + GuardaLog(ex.ToString()) + End Try + + If Not String.IsNullOrEmpty(pdf64) Then + RegistraScript($"impresionBase64('{pdf64}');", "Imprimir") + Else + Alert("No se pudo imprimir el pdf", TipoMensaje.MsgAdvertencia) + End If + End If + Alert(documentos.ToString) CargaDatos() End If + TxtComision.Text = "" TxtDescuento.Text = "" TxtIVA.Text = "" @@ -462,5 +498,80 @@ Partial Class Bancos_DepositosCaja DDlMesesSinIntereses.Visible = False End If DDlMesesSinIntereses.SelectedValue = "-1" - End Sub + End Sub + + Private Function ImpresionDirectaPDF(CveIEOrigen As Integer, CvePrePoliza As Integer) As String + + Dim PDFPago As Byte() = Nothing + Dim PDFPrePoliza As Byte() = Nothing + + Dim ParametrosPago As String = Encripta($"OP=DC&CveIE={CveIEOrigen}&CuentaCaja={DdlCajaChica.SelectedItem.Text}&CuentaDepo={DdlCuentaDeposito.SelectedItem.Text}&TipoPago={DdlTipoPago.SelectedItem.Text}") + Dim ParametrosPrePoliza As String = Encripta($"OP=PREPO&CvePrePoliza={CvePrePoliza}") + + Try + PDFPago = DescargarPDF(ParametrosPago, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) + If PDFPago IsNot Nothing Then + PDFPrePoliza = DescargarPDF(ParametrosPrePoliza, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) + End If + + Catch ex As Exception + GuardaLog(ex.ToString()) + + PDFPago = Nothing + PDFPrePoliza = Nothing + End Try + + If PDFPago IsNot Nothing AndAlso PDFPrePoliza IsNot Nothing Then + Dim pdf64 As String = "" + 'UNIFICAR LOS 2 PDF + Using ms As New MemoryStream + Using pdfdoc As New iText.Kernel.Pdf.PdfDocument(New iText.Kernel.Pdf.PdfWriter(ms)) + pdfdoc.InitializeOutlines() + + Dim docPago As New iText.Kernel.Pdf.PdfDocument(New iText.Kernel.Pdf.PdfReader(New MemoryStream(PDFPago))) + docPago.CopyPagesTo(1, docPago.GetNumberOfPages(), pdfdoc) + docPago.Close() + + Dim docPrePoliza As New iText.Kernel.Pdf.PdfDocument(New iText.Kernel.Pdf.PdfReader(New MemoryStream(PDFPrePoliza))) + docPrePoliza.CopyPagesTo(1, docPrePoliza.GetNumberOfPages(), pdfdoc) + docPrePoliza.Close() + + pdfdoc.Close() + End Using + pdf64 = Convert.ToBase64String(ms.ToArray()) + End Using + + Return pdf64 + Else + Return "" + End If + + End Function + Private Function DescargarPDF(Parametros As String, CveEmpresa As Integer, CveUsuarioCreo As Integer, Optional GetBytes As Boolean = True, Optional strURLHOST As String = "") As Byte() + + If String.IsNullOrEmpty(strURLHOST) Then + strURLHOST = String.Format("{0}://{1}:{2}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port) + End If + + Dim Url As New Uri(String.Format("{0}/Compras/PopUpVerFactura.aspx?P={1}", strURLHOST, Parametros)) + Dim File As Byte() = Nothing + Try + Using httpClient As New HttpClient() + httpClient.Timeout = New TimeSpan(0, 1, 0) + Using request As New HttpRequestMessage(HttpMethod.Get, Url) + request.Headers.Add("ADSToken", Encripta(String.Format("CVEEMPRESA={0}&TICKS={1}&CveUsuario={2}", CveEmpresa, DateTime.UtcNow.Ticks, CveUsuarioCreo))) + Dim response = httpClient.SendAsync(request).Result + If GetBytes AndAlso response.StatusCode = Net.HttpStatusCode.OK Then + File = response.Content.ReadAsByteArrayAsync().Result + End If + End Using + End Using + Catch ex As Exception + File = Nothing + OnError("Ocurrió un error al descargar la factura", ex) + End Try + + Return File + End Function + End Class \ No newline at end of file diff --git a/Bancos/IE.aspx.vb b/Bancos/IE.aspx.vb index 836808ff2..4250b1def 100644 --- a/Bancos/IE.aspx.vb +++ b/Bancos/IE.aspx.vb @@ -744,12 +744,9 @@ Partial Class Bancos_IE - 'If TabCancelacion.Visible Then - ' LnkCancelar.Visible = False - ' LnkCancelarComplemento.Visible = False - ' 'LnkEliminar.Visible = False - ' LnkCancelarComplementoImporte.Visible = False - 'End If + If TabCancelacion.Visible Then + LnkCancelar.Visible = False + End If UppEliminarIE.Update() @@ -1637,7 +1634,7 @@ Partial Class Bancos_IE DdlCuenta.Items.Clear() Dim dt As DataTable - If UsuarioActual.Empresa.Funcionalidad(127) = "1" Then + If UsuarioActual.Empresa.Funcionalidad(127) = "1" OrElse UsuarioActual.Empresa.Funcionalidad(109) = "1" Then dt = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa) Else dt = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("CveTipoCuenta <> 1") ' quito las cajas chicas diff --git a/Bancos/PopIECompras.aspx b/Bancos/PopIECompras.aspx index 80d0624c6..9b31ac375 100644 --- a/Bancos/PopIECompras.aspx +++ b/Bancos/PopIECompras.aspx @@ -524,7 +524,7 @@
    - +
    diff --git a/Bancos/PopIECompras.aspx.vb b/Bancos/PopIECompras.aspx.vb index cdda5974c..43e4d2d87 100644 --- a/Bancos/PopIECompras.aspx.vb +++ b/Bancos/PopIECompras.aspx.vb @@ -861,6 +861,9 @@ Partial Class Bancos_PopIECompras CargaCuentas() CargaCuentasDepositos() + + ValidaFechaDocumentoDiasPosteriores() + UpDatos.Update() End Sub @@ -1718,4 +1721,21 @@ Partial Class Bancos_PopIECompras End Sub + + Private Sub ValidaFechaDocumentoDiasPosteriores() + + + RVTxtFechaDocumento.MaximumValue = NowADS().AddDays(2).ToShortDateString + Calendario.EndDate = NowADS().AddDays(2) + + If DdlTipoTransaccion.SelectedValue.ToEntero.Contiene(1, 16) Then + RVTxtFechaDocumento.MaximumValue = NowADS().AddDays(30).ToShortDateString + Calendario.EndDate = NowADS().AddDays(30) + End If + + UpDatos.Update() + UpGuardar.Update() + + End Sub + End Class \ No newline at end of file diff --git a/Bancos/PopIEVentas.aspx.vb b/Bancos/PopIEVentas.aspx.vb index b7108b91a..fe4168ba0 100644 --- a/Bancos/PopIEVentas.aspx.vb +++ b/Bancos/PopIEVentas.aspx.vb @@ -1149,7 +1149,6 @@ Partial Class Bancos_PopIEVentas End If Dim MsgError As String = "" - Dim CveConceptoPrePoliza As Integer = -1 Dim Inserta As Boolean = True Dim ImportePagado As Decimal = 0 Dim Fecha As Date = TxtFechaDocumento.Text.Trim.ToDate @@ -1162,7 +1161,6 @@ Partial Class Bancos_PopIEVentas Case "2" 'FyE ImportePagado = TxtImporte.Text.Trim.ToDecimal Fecha = TxtFechaDocumento.Text.Trim.ToDate - CveConceptoPrePoliza = 29 CveIE = -1 Dim stringPersonal As String = DdlFuncionarioEmpleado.SelectedItem.ToString 'CvePersonal = DdlFuncionarioEmpleado.SelectedValue.ToEntero @@ -1252,108 +1250,118 @@ Partial Class Bancos_PopIEVentas Case "1" ' Banco CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, Fecha, TxtFolio.Text.Trim, TxtPagueseA.Text.Trim, ImportePagado, CveMoneda, tipoCambioPago, TxtObservaciones.Text.Trim, "", True, True, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCuentaTarjeta:=If(DivTarjeta.Visible, DdlTarjeta.SelectedValue.ToEntero, -1), CveCuentaDeposito:=CveCuentaDeposito, Referencia:=If(TxtReferenciaCIE.Visible, TxtReferenciaCIE.Text, "-1"), CveCorte:=CveCorte) If CveIE > 0 Then - If CveVenta > 0 Then - Pago.ImportePago = ImportePagado - Pago.ImportePagoVenta = ImportePagado - Pago.CveIE = CveIE - Pago.TipoPago = "B" - If MsgError = "" AndAlso AplicaPrePolizaPagoVenta(VentaActual, Pago, CvePrePoliza, ObjMov) Then - MsgError = "No se pudo insertar la póliza" - End If + Pago.ImportePago = ImportePagado + Pago.ImportePagoVenta = ImportePagado + Pago.CveIE = CveIE + Pago.TipoPago = "B" + + If MsgError = "" AndAlso AplicaPrePolizaPagoVenta(VentaActual, Pago, CvePrePoliza, ObjMov) Then + MsgError = "No se pudo insertar la póliza" End If + Else MsgError = "Ocurrio un Error al registrarse el movimiento bancario." Inserta = False End If + Case "2" ' FyE + + Pago.ImportePago = ImportePagado + Pago.ImportePagoVenta = ImportePagado + Pago.TipoPago = "FyE" + Pago.CvePersonal = DdlFuncionarioEmpleado.SelectedValue.ToEntero + Pago.Referencia = DdlFuncionarioEmpleado.SelectedItem.ToString + + If MsgError = "" AndAlso AplicaPrePolizaPagoVenta(VentaActual, Pago, CvePrePoliza, ObjMov) Then + MsgError = "No se pudo insertar la póliza" + End If + Case "3" 'Ingresos x Comprobar - If CveVenta > 0 Then - CveConceptoPrePoliza = 2 - CveCliente = DdlIngreso.SelectedValue.ToEntero - CveIE = -1 - ImportePagado = TxtImporte.Text.Trim.ToDecimal - Pago.ImportePago = ImportePagado - Pago.TipoPago = "I" - For Each rw As GridViewRow In GvIngresos.Rows - If rw.FCCheckBox("Chk").Checked Then - CveIE = rw.DataKey("CveIE").ToEntero - Pago.CveMonedaPago = rw.DataKey("CveMoneda").ToEntero - Pago.ImportePago = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal - Pago.ImportePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal - Pago.TCPago = rw.DataKey("TipoCambio").ToDecimal - Pago.FechaDocumentoRelacionado = rw.DataKey("FechaDocumento").ToDate - Pago.CveIE = CveIE - Pago.CveClientePago = rw.DataKey("CveCliente").ToEntero - If ChkPagarPesos.Checked Then Pago.TCPago = 1 / rw.DataKey("TipoCambio").ToDecimal - If ChkPagarDolares.Checked Then Pago.TCPago = rw.DataKey("TipoCambio").ToDecimal + CveCliente = DdlIngreso.SelectedValue.ToEntero + CveIE = -1 + ImportePagado = TxtImporte.Text.Trim.ToDecimal + Pago.ImportePago = ImportePagado + Pago.TipoPago = "I" - If AplicaPrePolizaPagoVenta(VentaActual, Pago, CvePrePoliza, ObjMov) Then - MsgError = "No se pudo insertar la póliza" - Else - Exit For - End If + For Each rw As GridViewRow In GvIngresos.Rows + If rw.FCCheckBox("Chk").Checked Then + CveIE = rw.DataKey("CveIE").ToEntero + Pago.CveMonedaPago = rw.DataKey("CveMoneda").ToEntero + Pago.ImportePago = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal + Pago.ImportePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal + Pago.TCPago = rw.DataKey("TipoCambio").ToDecimal + Pago.FechaDocumentoRelacionado = rw.DataKey("FechaDocumento").ToDate + Pago.CveIE = CveIE + Pago.CveClientePago = rw.DataKey("CveCliente").ToEntero + If ChkPagarPesos.Checked Then Pago.TCPago = 1 / rw.DataKey("TipoCambio").ToDecimal + If ChkPagarDolares.Checked Then Pago.TCPago = rw.DataKey("TipoCambio").ToDecimal + + If AplicaPrePolizaPagoVenta(VentaActual, Pago, CvePrePoliza, ObjMov) Then + MsgError = "No se pudo insertar la póliza" + Else + Exit For End If - Next - End If - Case "4" 'Deudores Diversos - If CveVenta > 0 Then - ImportePagado = TxtImporte.Text.Trim.ToDecimal - CveConceptoPrePoliza = 2 - 'CveProveedor2 = DdlDeudor.SelectedValue.ToEntero - CveIE = -1 - If DdlDeudor.SelectedValue.ToEntero <= 0 Then - Alert("Debe especificar el deudor.", TipoMensaje.MsgAdvertencia) - Exit Sub End If + Next - For Each rw As GridViewRow In GvDeudores.Rows - If rw.FCCheckBox("Chk").Checked AndAlso rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal <> 0 Then - Pago.CveIE = rw.DataKey("CveIE").ToEntero - Pago.CveMonedaPago = rw.DataKey("CveMoneda").ToEntero - Pago.ImportePago = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal - Pago.TCPago = rw.DataKey("TipoCambio").ToDecimal - 'Pago.CveProveedor = DdlDeudor.SelectedValue.ToEntero - Pago.TipoPago = "DD" - If AplicaPrePolizaPagoVenta(VentaActual, Pago, CvePrePoliza, ObjMov) Then - MsgError = "No se pudo insertar la póliza" - Else - Exit For - End If - End If - Next + Case "4" 'Deudores Diversos + + ImportePagado = TxtImporte.Text.Trim.ToDecimal + 'CveProveedor2 = DdlDeudor.SelectedValue.ToEntero + CveIE = -1 + If DdlDeudor.SelectedValue.ToEntero <= 0 Then + Alert("Debe especificar el deudor.", TipoMensaje.MsgAdvertencia) + Exit Sub End If + + For Each rw As GridViewRow In GvDeudores.Rows + If rw.FCCheckBox("Chk").Checked AndAlso rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal <> 0 Then + Pago.CveIE = rw.DataKey("CveIE").ToEntero + Pago.CveMonedaPago = rw.DataKey("CveMoneda").ToEntero + Pago.ImportePago = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal + Pago.TCPago = rw.DataKey("TipoCambio").ToDecimal + 'Pago.CveProveedor = DdlDeudor.SelectedValue.ToEntero + Pago.TipoPago = "DD" + If AplicaPrePolizaPagoVenta(VentaActual, Pago, CvePrePoliza, ObjMov) Then + MsgError = "No se pudo insertar la póliza" + Else + Exit For + End If + End If + Next + Case "5" 'Compras - If CveVenta > 0 Then - ImportePagado = TxtImporte.Text.Trim.ToDecimal - CveIE = -1 - For Each rw As GridViewRow In GvCompras.Rows - If rw.FCCheckBox("Chk").Checked AndAlso rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal <> 0 Then - Pago.CveMonedaPago = 1 - Pago.ImportePago = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal - Pago.ImportePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal - Pago.TipoPago = "Compra" - If AplicaPrePolizaPagoVenta(VentaActual, Pago, CvePrePoliza, ObjMov) Then + + ImportePagado = TxtImporte.Text.Trim.ToDecimal + CveIE = -1 + For Each rw As GridViewRow In GvCompras.Rows + If rw.FCCheckBox("Chk").Checked AndAlso rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal <> 0 Then + Pago.CveMonedaPago = 1 + Pago.ImportePago = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal + Pago.ImportePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal + Pago.TipoPago = "Compra" + If AplicaPrePolizaPagoVenta(VentaActual, Pago, CvePrePoliza, ObjMov) Then + MsgError = "No se pudo insertar la póliza" + End If + If MsgError = "" Then + Dim CompraActual As New Compra() With {.CveCompra = rw.DataKey("CveCompra").ToEntero, .ProveedorNombre = NombreCliente, .SerieFolio = rw.DataKey("SerieFolio"), .CveProveedor = rw.DataKey("CveProveedor").ToEntero, .IVA = rw.DataKey("IVA").ToDecimal, .IEPS = rw.DataKey("IEPS").ToDecimal, .RetIVA = rw.DataKey("RetIVA").ToDecimal, .RetISR = rw.DataKey("RetISR").ToDecimal, .Total = rw.DataKey("Total").ToDecimal, .PorcentajeIVA = rw.DataKey("PorcentajeIVA").ToDecimal, .CveSubProyecto = rw.DataKey("CveSubProyecto").ToEntero, .CveMoneda = rw.DataKey("CveMoneda").ToEntero, .CveTipoConceptoProveedor = rw.DataKey("CveTipoConcepto").ToEntero} + Dim PagoCompra As New CompraPago + + PagoCompra.CveMonedaPago = rw.DataKey("CveMoneda").ToEntero + PagoCompra.ImportePago = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal + PagoCompra.TCPago = rw.DataKey("TipoCambio").ToDecimal + PagoCompra.CveProveedor = rw.DataKey("CveProveedor").ToEntero + PagoCompra.CveVentaRelacionada = CveVenta + PagoCompra.TipoPago = "Venta" + If AplicaPrePolizaPagoCompra(CompraActual, PagoCompra, CvePrePoliza, ObjMov) Then MsgError = "No se pudo insertar la póliza" End If - If MsgError = "" Then - Dim CompraActual As New Compra() With {.CveCompra = rw.DataKey("CveCompra").ToEntero, .ProveedorNombre = NombreCliente, .SerieFolio = rw.DataKey("SerieFolio"), .CveProveedor = rw.DataKey("CveProveedor").ToEntero, .IVA = rw.DataKey("IVA").ToDecimal, .IEPS = rw.DataKey("IEPS").ToDecimal, .RetIVA = rw.DataKey("RetIVA").ToDecimal, .RetISR = rw.DataKey("RetISR").ToDecimal, .Total = rw.DataKey("Total").ToDecimal, .PorcentajeIVA = rw.DataKey("PorcentajeIVA").ToDecimal, .CveSubProyecto = rw.DataKey("CveSubProyecto").ToEntero, .CveMoneda = rw.DataKey("CveMoneda").ToEntero, .CveTipoConceptoProveedor = rw.DataKey("CveTipoConcepto").ToEntero} - Dim PagoCompra As New CompraPago - - PagoCompra.CveMonedaPago = rw.DataKey("CveMoneda").ToEntero - PagoCompra.ImportePago = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal - PagoCompra.TCPago = rw.DataKey("TipoCambio").ToDecimal - PagoCompra.CveProveedor = rw.DataKey("CveProveedor").ToEntero - PagoCompra.CveVentaRelacionada = CveVenta - PagoCompra.TipoPago = "Venta" - If AplicaPrePolizaPagoCompra(CompraActual, PagoCompra, CvePrePoliza, ObjMov) Then - MsgError = "No se pudo insertar la póliza" - End If - End If - End If - Next - End If + + End If + Next + Case Else 'NO SE HA DEFINIDO PARA FUNCIONARIO Y EMPLEADO If RBLContado.SelectedValue <> "2" Then @@ -1372,7 +1380,8 @@ Partial Class Bancos_PopIEVentas MsgError = "No se pudo insertar la poliza detalle" End If End If - + Else + MsgError = "venta no identificada" End If Else MsgError = "No se pudo insertar la póliza" diff --git a/Bancos/ProveedoresAbonar.aspx b/Bancos/ProveedoresAbonar.aspx index fe63b8585..cdadcb7d9 100644 --- a/Bancos/ProveedoresAbonar.aspx +++ b/Bancos/ProveedoresAbonar.aspx @@ -99,14 +99,15 @@
    - + - + diff --git a/Bancos/ProveedoresAbonar.aspx.vb b/Bancos/ProveedoresAbonar.aspx.vb index 562c77be4..8e8952fee 100644 --- a/Bancos/ProveedoresAbonar.aspx.vb +++ b/Bancos/ProveedoresAbonar.aspx.vb @@ -1074,6 +1074,8 @@ Partial Class Bancos_ProveedoresAbonar CargaCuentas(DdlTipoTransaccion.SelectedValue.ToEntero) RecargaCuentasDepositos() + ValidaFechaDocumentoDiasPosteriores() + UpGuardar.Update() End Sub #End Region @@ -1612,6 +1614,29 @@ Partial Class Bancos_ProveedoresAbonar End Sub + Private Sub ValidaFechaDocumentoDiasPosteriores() + + + RVTxtFechaDocumento.MaximumValue = NowADS().AddDays(2).ToShortDateString + RVTxtFechaDocumentoMenor.MaximumValue = NowADS().AddDays(2).ToShortDateString + + RVTxtFechaDocumento.ErrorMessage = "ERROR:
    La fecha del documento no puede ser superior 2 días de la fecha actual" + + Calendario.EndDate = NowADS().AddDays(2) + + If DdlTipoTransaccion.SelectedValue.ToEntero.Contiene(1, 16) Then + + RVTxtFechaDocumento.MaximumValue = NowADS().AddDays(30).ToShortDateString + RVTxtFechaDocumentoMenor.MaximumValue = NowADS().AddDays(30).ToShortDateString + RVTxtFechaDocumento.ErrorMessage = "ERROR:
    La fecha del documento no puede ser superior 30 días de la fecha actual" + + Calendario.EndDate = NowADS().AddDays(30) + End If + + UpDatos.Update() + UpGuardar.Update() + + End Sub Protected Sub chkaplicaDescuento_CheckedChanged(sender As Object, e As EventArgs) diff --git a/Bancos/RepCortes.aspx b/Bancos/RepCortes.aspx index 16ad5bcc7..c173f0204 100644 --- a/Bancos/RepCortes.aspx +++ b/Bancos/RepCortes.aspx @@ -1,376 +1,488 @@ -<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RepCortes.aspx.vb" Inherits="Bancos_RepCortes" %> - - - - - - - - - -
  • - Generar EXCEL -
  • -
  • - Generar PDF -
  • -
    -
    - Personalizar -
    - - - - - - - - - - -
    -
    -
    - - "> - -<%-- --%> -
    -
    -
    -
    - - <%--SubProyecto--%> -
    -
    - - -
    -
    +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RepCortes.aspx.vb" Inherits="Bancos_RepCortes" %> + + + + + + + + + +
  • + Generar EXCEL +
  • +
  • + Generar PDF +
  • +
    +
    + Personalizar +
    + + + + + + + + + + +
    +
    +
    + + "> + + <%-- --%> +
    +
    +
    +
    + + <%--SubProyecto--%> +
    +
    + + +
    +
    F.I.: -
    -
    -
    - - - - - - - - - - -
    -
    -
    + +
    +
    +
    + + + + + + + + + + +
    +
    +
    F.F.: -
    -
    -
    - - - - - - - - - - -
    -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    -
    - Detalles del Corte - - - - - - - - - - + +
    +
    +
    + + + + + + + + + + +
    +
    +
    +
    +
    + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%----%> + + + + + + + + + + + + + + +
    +
    +
    +
    + Detalles del Corte + + + + + + +
    +
    +
    + Porcentajes de IVA + + + + + + + +
    +
    +
    + Depositos Caja +
    +
    + + + + + + + + + + + + +
    +
    + +
    +
    +
    + Anexo +
    +
    + + + + + + + + + + + + + +
    +
    + +
    +
    + + + + Serie - Folio - - - - - - + + + + + + + + + + + + - + - - <%----%> - - - - - - -
    -
    -
    - - - + + <%----%> + + + + + + +
    +
    +
    + +
    + - + + - + + - - + + + - + + diff --git a/Bancos/RepCortes.aspx.vb b/Bancos/RepCortes.aspx.vb index fd52292fd..399bfd788 100644 --- a/Bancos/RepCortes.aspx.vb +++ b/Bancos/RepCortes.aspx.vb @@ -5,8 +5,7 @@ Imports System.Data Imports Extensiones Partial Class Bancos_RepCortes - Inherits ClsPaginas - Private Shared missing As Object = System.Reflection.Missing.Value + Inherits ClsPaginas #Region "PROPIEDADES" Private Property DtCortes As DataTable @@ -66,7 +65,8 @@ Partial Class Bancos_RepCortes txtFechaVI.Text = NowADS().ToShortDateString txtFechaVF.Text = NowADS().ToShortDateString Me.Form.DefaultButton = BtnConsultar.UniqueID - CargarCentrosDeCosto(Nothing, DdlSubProyectos, Nothing, LblSubProyecto) + CargarCentrosDeCosto(Nothing, DdlSubProyectos, Nothing, LblSubProyecto) + End If End Sub @@ -83,6 +83,12 @@ Partial Class Bancos_RepCortes End If ObjPuntoVenta.Dispose() + If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then + GvDatos.Columns(3).Visible = True + GvDatos.Columns(4).Visible = True + GvDatos.Columns(13).Visible = True + End If + GvDatos.DataSource = DtCortes GvDatos.DataBind() UPDatos.Update() @@ -167,7 +173,21 @@ Partial Class Bancos_RepCortes GvP.DataSource = Vn.DtResultados DtCortesVentasResumen = Vn.DtResultados End If - If Vent.GetCortesDetalleVentas(CveCorte, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then + If UsuarioActual.CveEmpresa.Contiene(190, 192) Then + DivIVA.Visible = True + If Vn.GetCortesDetalleVentasResumenIVA(CveCorte, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then + GvPorIVA.DataSource = Vn.DtResultados + End If + End If + + If Vn.GetCortesDetalleDepositosCaja(CveCorte, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then + GvDep.DataSource = Vn.DtResultados + If Vn.DtResultados.Rows.Count > 0 Then + DivDep.Visible = True + End If + End If + + If Vent.GetCortesDetalleVentas(CveCorte, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, 2) Then GvD.DataSource = Vent.DtResultados DtCortesVentas = Vent.DtResultados divDetalle.Visible = True @@ -183,8 +203,26 @@ Partial Class Bancos_RepCortes End If Vn.Dispose() Vent.Dispose() + + GvD.DataBind() GvP.DataBind() + GvDep.DataBind() + GvPorIVA.DataBind() + + If UsuarioActual.CveEmpresa = 193 AndAlso UsuarioActual.CveRol = 1 Then + DivAnexo.Visible = True + + Dim CveCuenta As Integer = 186367 + Using ObjConta As New ClsContabilidad + If ObjConta.GetAnexoCatalogo(CveCuenta, Fecha.ToDate(), Fecha.ToDate(), -1, -1, -1, UsuarioActual.CveEmpresa, 1) Then + GvAnexo.DataSource = ObjConta.DtResultados + End If + End Using + + GvAnexo.DataBind() + End If + UPPDetalle.Update() UpAcciones.Update() End Sub diff --git a/Compras/Compras.aspx b/Compras/Compras.aspx index 7ab6aed8c..f1b590b20 100644 --- a/Compras/Compras.aspx +++ b/Compras/Compras.aspx @@ -498,7 +498,12 @@ - <%----%> + + <%-- Ocuoado usado en Garantía--%> + <%-- Ocupado RECEPCION ADELANTADO --%> + <%-- Ocupado Recolecciones --%> + <%-- Ocuado se carga con funcionalidad 574 --%> +
    @@ -528,12 +533,25 @@
    Recolección
    - +
    + +
    + Remisión Nota de Crédito +
    + + + + <%----%> +
    +
    + + +
    @@ -761,7 +779,7 @@
    - +
    @@ -921,7 +939,23 @@ -
    + + + + + +
    +
    + + Atención! + El Proveedor tiene Saldo a favor pendiente por aplicar +
    +
    +
    +
    + + +
    @@ -1186,7 +1220,8 @@ - + @@ -4800,7 +4835,7 @@
    + DataKeyNames="CveCompra,TipoCambio,CveTipoConcepto,UUID,Saldo,SerieFolio,Fecha,CveMoneda,Total,CveProveedor,SubTotal" runat="server" AutoGenerateColumns="false" GridLines="None" CssClass="table table-striped table-hover Widthall ScrollAD"> @@ -5495,6 +5530,43 @@
    + + + + + diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 07fa87194..aeb94a329 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -10,7 +10,10 @@ Imports System.Threading.Tasks Imports Newtonsoft.Json Imports Extensiones Imports MoreLinq -Imports ClbNegBICFDv3_3 +Imports ClsPaginas +Imports System.Data.SqlClient + + Partial Class Compras_Compras Inherits ClsPaginas @@ -714,6 +717,18 @@ Partial Class Compras_Compras ViewState("CveMetodoPago") = value End Set End Property + + Private Property MetodoPagoOC As Integer + Get + If ViewState("MetodoPagoOC") Is Nothing Then + ViewState("MetodoPagoOC") = -1 + End If + Return ViewState("MetodoPagoOC").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("MetodoPagoOC") = value + End Set + End Property Private Property TipoCambio As Decimal Get Return ViewState("TipoCambio").ToString.ToDecimal @@ -1018,6 +1033,20 @@ Partial Class Compras_Compras End Set End Property + Private Property CveIEAnticipo As Integer + Get + If ViewState("CveIEAnticipo") Is Nothing Then + ViewState("CveIEAnticipo") = -1 + End If + Return ViewState("CveIEAnticipo").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveIEAnticipo") = value + End Set + End Property + + + Public Property FechaCompraOriginal As Date Get Return ViewState("FechaCompraOriginal").ToString.ToDate @@ -1089,6 +1118,174 @@ Partial Class Compras_Compras End Set End Property + +#Region "PROPIEDADES PRONTO PAGO" + ''' + ''' Descuento por pronto pago proveedor + ''' + ''' Porcentaje de descuento de proveedor + Private Property PorcentajeProntoPago As Decimal + Get + If ViewState("PorcentajeProntoPago") Is Nothing Then + ViewState("PorcentajeProntoPago") = 0D + End If + Return ViewState("PorcentajeProntoPago").ToString.ToDecimal + End Get + Set(value As Decimal) + ViewState("PorcentajeProntoPago") = value + End Set + End Property + Private Property AjusteProntoPagoConIVA As Decimal + Get + If ViewState("AjusteProntoPagoConIVA") Is Nothing Then + ViewState("AjusteProntoPagoConIVA") = 0D + End If + Return ViewState("AjusteProntoPagoConIVA").ToString.ToDecimal + End Get + Set(value As Decimal) + ViewState("AjusteProntoPagoConIVA") = value + End Set + End Property + + Private Property AjusteProntoPagoPorcentajeIVA As Decimal + Get + If ViewState("AjusteProntoPagoPorcentajeIVA") Is Nothing Then + ViewState("AjusteProntoPagoPorcentajeIVA") = 0D + End If + Return ViewState("AjusteProntoPagoPorcentajeIVA").ToString.ToDecimal + End Get + Set(value As Decimal) + ViewState("AjusteProntoPagoPorcentajeIVA") = value + End Set + End Property + + + Private Property AjusteProntoPagoSinIVA As Decimal + Get + If ViewState("AjusteProntoPagoSinIVA") Is Nothing Then + ViewState("AjusteProntoPagoSinIVA") = 0D + End If + Return ViewState("AjusteProntoPagoSinIVA").ToString.ToDecimal + End Get + Set(value As Decimal) + ViewState("AjusteProntoPagoSinIVA") = value + End Set + End Property + Private Property ImporteRNC As Decimal + Get + If ViewState("ImporteRNC") Is Nothing Then + ViewState("ImporteRNC") = 0D + End If + Return ViewState("ImporteRNC").ToString.ToDecimal + End Get + Set(value As Decimal) + ViewState("ImporteRNC") = value + End Set + End Property + Private Property ImporteRNCProntoPago As Decimal + Get + If ViewState("ImporteRNCProntoPago") Is Nothing Then + ViewState("ImporteRNCProntoPago") = 0D + End If + Return ViewState("ImporteRNCProntoPago").ToString.ToDecimal + End Get + Set(value As Decimal) + ViewState("ImporteRNCProntoPago") = value + End Set + End Property + + Private Property ImporteRNCSaldar As Decimal + Get + If ViewState("ImporteRNCSaldar") Is Nothing Then + ViewState("ImporteRNCSaldar") = 0D + End If + Return ViewState("ImporteRNCSaldar").ToString.ToDecimal + End Get + Set(value As Decimal) + ViewState("ImporteRNCSaldar") = value + End Set + End Property + + Private Property DTRemisionesNotaDeCredito As DataTable + Get + + If ViewState("DTRemisionesNotaDeCredito") Is Nothing Then + ViewState("DTRemisionesNotaDeCredito") = New DataTable + End If + + Return DirectCast(ViewState("DTRemisionesNotaDeCredito"), DataTable) + + End Get + Set(value As DataTable) + ViewState("DTRemisionesNotaDeCredito") = value + End Set + End Property + + + Private Property SerieFolioProntoPago As String + Get + If ViewState("SerieFolioProntoPago") Is Nothing Then + ViewState("SerieFolioProntoPago") = "" + End If + Return ViewState("SerieFolioProntoPago").ToString + End Get + Set(value As String) + ViewState("SerieFolioProntoPago") = value + End Set + End Property + + Private Property TipoCambioProntoPago As Decimal + Get + If ViewState("TipoCambioProntoPago") Is Nothing Then + ViewState("TipoCambioProntoPago") = 0D + End If + Return ViewState("TipoCambioProntoPago").ToString.ToDecimal + End Get + Set(value As Decimal) + ViewState("TipoCambioProntoPago") = value + End Set + End Property + + Private Property FechaProntoPago As Date + Get + If ViewState("FechaProntoPago") Is Nothing Then + ViewState("FechaProntoPago") = MinFecha + End If + Return ViewState("FechaProntoPago").ToString.ToDate + End Get + Set(value As Date) + ViewState("FechaProntoPago") = value + End Set + End Property + + Private Property CveMonedaProntoPago As Integer + Get + If ViewState("CveMonedaProntoPago") Is Nothing Then + ViewState("CveMonedaProntoPago") = 0D + End If + Return ViewState("CveMonedaProntoPago").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveMonedaProntoPago") = value + End Set + End Property + + 'ImporteRNCSaldar = 0 + 'SerieFolioProntoPago = "" + 'TipoCambioProntoPago = 1 + 'FechaProntoPago = MinFecha + 'CveMonedaProntoPago = 1 + + +#End Region + + + + + + + + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then 'ImgBtnBuscarOC.Attributes.Add("data-toggle", "tooltip") @@ -1488,6 +1685,11 @@ Partial Class Compras_Compras DdlTipoComprobante.SelectedValueExist("DEV") End If + If UsuarioActual.Empresa.Funcionalidad(574).ToEntero = 1 Then + DdlTipoCompra.Items.Add(New ListItem("Remision Nota De Crédito", "15")) + End If + + End If 'SE OCUPAN AFUERA DEL POSTBACK ?? @@ -3252,6 +3454,8 @@ Partial Class Compras_Compras Private Sub CargaProveedor(CveProveedor As Integer, RFC As String, Optional RecargaCombo As Boolean = True) + PorcentajeProntoPago = 0D + Dim ObjProveedor As New ClsCompProveedores() If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, CveProveedor, "-1", "-1", "-1", "-1", RFC, "-1", "-1", -1, UsuarioActual.CveEmpresa) Then @@ -3271,7 +3475,13 @@ Partial Class Compras_Compras ViewState("CveProveedor") = ObjProveedor.CveProveedor ViewState("CveTipoProveedor") = ObjProveedor.CveTipoProveedor - If ObjProveedor.CveTipoProveedor = 1 Then LblProveedor.Text = "Proveedor:" Else LblProveedor.Text = "Acreedor:" + + If ObjProveedor.CveTipoProveedor = 2 Then + LblProveedor.Text = "Acreedor:" + Else + LblProveedor.Text = "Proveedor:" + End If + CveTipoConcepto = ObjProveedor.CveTipoProveedor ViewState("NombreProveedor") = ObjProveedor.RazonSocial @@ -3407,6 +3617,10 @@ Partial Class Compras_Compras End If + If UsuarioActual.Empresa.Funcionalidad(574).ToEntero = 1 Then + PorcentajeProntoPago = ObjProveedor.PorcentajeProntoPago + End If + Else Alert("El Proveedor solicitado no existe, por favor intente de nuevo.", TipoMensaje.MsgAdvertencia) End If @@ -3965,8 +4179,18 @@ Partial Class Compras_Compras + If Not ValidaPresupuesto(2) Then + Exit Sub + End If + '------------------ INICIA VALIDACIONES ------------------ + If MetodoPagoOC = 0 AndAlso RBLPago.SelectedValue.ToEntero <> 2 Then + Alert("La orden de compra se definió de contado, favor de especificar la compra de contado.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + Dim CveSubProyectoPrincipal As Integer = AsignarSubProyectoPrincipal() If Not CveSubProyectoPrincipal > 0 Then @@ -6265,7 +6489,8 @@ Partial Class Compras_Compras If DdlMoneda.SelectedValue.ToEntero <> 1 Then TCO = TxtTC.Text.ToDecimal ImporteCI176 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteCI228").ToDecimal - CostoIndirectoAcum176 += ImporteCI176 + 'CostoIndirectoAcum176 += ImporteCI176 + CostoIndirectoAcum176 += 0 SumatoriaInventario += Importe228 + Importe229 'se considera costoindirecto, para que la factura tiene en un concepto tipo servicio SumatoriaOCINV += (Dr(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total")).ToString.ToDecimal * tipoCambioActual) - (ImporteMN228 + ImporteMN229 - ImporteCI176) @@ -6475,8 +6700,24 @@ Partial Class Compras_Compras ErrorPrepoliza = True End If Else - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento.RoundSQL, importeMovimiento * tipoCambioActual * Multiplicador, ConceptoContabilizacionNC, Referencia, Concepto, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual, CveMovimientoAlmacen:=CveMovimientoDevolucion, CveClasificacion:=tCveClasif, CveSubProyecto:=tCveSubProyecto, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True + Dim AplicadoenFactura As Boolean = False + If UsuarioActual.CveEmpresa = 119 Then + For Each Gvr As GridViewRow In GvFacturaNC.Rows + If Gvr.FCCheckBox("ChkFacturaNC").Checked Then ' recorro la seleccion y tomo el TC de cada aplicación + AplicadoenFactura = True + Dim timporteMovimientoNC As Decimal = (Gvr.FCTextBox("TxtImporte").Text.ToDecimal * Gvr.DataKey("SubTotal").ToDecimal / Gvr.DataKey("Saldo").ToDecimal).RoundSQL + Dim TCNC As Decimal = Gvr.DataKey("TipoCambio").ToDecimal + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, timporteMovimientoNC, (timporteMovimientoNC * TCNC * Multiplicador).RoundSQL, ConceptoContabilizacionNC, Referencia, Concepto, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=TCNC, CveMovimientoAlmacen:=CveMovimientoDevolucion, CveClasificacion:=tCveClasif, CveSubProyecto:=tCveSubProyecto, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + End If + Next + End If + + If Not AplicadoenFactura Then ' se aplica el subtotal + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento.RoundSQL, importeMovimiento * tipoCambioActual * Multiplicador, ConceptoContabilizacionNC, Referencia, Concepto, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual, CveMovimientoAlmacen:=CveMovimientoDevolucion, CveClasificacion:=tCveClasif, CveSubProyecto:=tCveSubProyecto, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If End If End If End If @@ -6759,6 +7000,52 @@ Partial Class Compras_Compras End If Next + + If UsuarioActual.Empresa.Funcionalidad(574).ToEntero = 1 AndAlso DdlRemisionNotaCredito.SelectedValue.ToEntero > 0 AndAlso ImporteRNCSaldar > 0 Then + + 'Dim importeMovimientoNC As Decimal = Gvr.FCTextBox("TxtImporte").Text.ToDecimal + + Dim Pago As New CompraPago + Pago.ImportePago = ImporteRNCSaldar + Pago.CveMonedaPago = CompraActual.CveMoneda + Pago.CveCompraAmortizacion = CompraActual.CveCompra + Pago.Referencia = CompraActual.SerieFolio + Pago.TCPago = CompraActual.TC + Pago.AplicaAcreditable = False + Pago.TipoPago = "NC" + Pago.Fecha = CompraActual.Fecha 'toma la misma fecha de la provisión en el pago de NC + + Dim CompraPago As New Compra + ''datos de la compra tipodocto:Fac, para sobreescribirlos + CompraPago.CveCompra = DdlRemisionNotaCredito.SelectedValue.ToEntero + CompraPago.CveProveedor = DdlProveedor.SelectedValue.ToEntero + CompraPago.SerieFolio = SerieFolioProntoPago + CompraPago.TC = TipoCambioProntoPago + CompraPago.Fecha = FechaProntoPago + CompraPago.CveMoneda = CveMonedaProntoPago + CompraPago.Total = ImporteRNCSaldar + CompraPago.CveTipoConceptoProveedor = CveTipoConcepto + CompraPago.CveSubProyecto = CompraActual.CveSubProyecto + + ErrorPrepoliza = AplicaPrePolizaPagoCompra(CompraPago, Pago, CvePrePoliza, ObjConta) + + If Not ErrorPrepoliza Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteRNCSaldar, ImporteRNCSaldar, 371, Referencia, Concepto, CveCompra:=DdlRemisionNotaCredito.SelectedValue.ToEntero, CveProveedor:=Me.CveProveedor, ImporteME:=If(TipoCambio = 1, 0, ImporteRNCSaldar), TipoCambio:=TipoCambio, + CveClasificacion:=-1, CveSubProyecto:=CompraActual.CveSubProyecto, Contabilizable:=True) Then + ErrorPrepoliza = True + End If + + If Not ErrorPrepoliza Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteRNCSaldar, ImporteRNCSaldar, 372, Referencia, Concepto, CveCompra:=DdlRemisionNotaCredito.SelectedValue.ToEntero, CveProveedor:=Me.CveProveedor, ImporteME:=If(TipoCambio = 1, 0, ImporteRNCSaldar), TipoCambio:=TipoCambio, + CveClasificacion:=-1, CveSubProyecto:=CompraActual.CveSubProyecto, Contabilizable:=True) Then + ErrorPrepoliza = True + End If + End If + End If + + + End If + If ErrorPrepoliza Then ErrorMovtosCxP = True Exit Select @@ -6997,7 +7284,7 @@ Partial Class Compras_Compras 'EMPIEZA REFACTURACION If Not ErrorPrepoliza AndAlso CveCompraRefacturacion > 0 Then - ErrorBitacora = GuardaRefacturacion(ObjCompras, ObjEventos, CvePrePoliza) + ErrorBitacora = GuardaRefacturacion(ObjCompras, ObjEventos, CvePrePoliza, ObjConta, CompraActual) If ErrorBitacora Then Alert("Ocurrió un error al hacer la Refacturación", TipoMensaje.MsgError) End If @@ -7320,11 +7607,19 @@ Partial Class Compras_Compras If Not ErrorPrepoliza AndAlso Not ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual, Opcion:=4, AutoConta:=AutoConta) Then TieneError = True 'If ObjConta.ValorPolizaDescuadre > 0 Then - ' GuardaLogAD($"Compras/Compras-Guardar | Error{ObjConta.MensajePolizaDescuadre} Diferencia{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") + ' Alert($"{ObjConta.MensajePolizaDescuadre} Diferencia{ObjConta.ValorDiferencia}", TipoMensaje.MsgError) ' ErrorPrepolizaDescuadre = True 'End If End If + + If UsuarioActual.Empresa.Funcionalidad(574).ToEntero = 1 AndAlso (ImporteRNC > 0 Or ImporteRNCProntoPago > 0) Then + If Not GeneraRemisionsNotadeCredito(ObjCompras.IniciaTransacSQL, CveCompra) Then + TieneError = True + End If + End If + + If Not TieneError Then ObjCompras.Commit() If ObjContaAC IsNot Nothing Then ObjContaAC.Commit() @@ -9588,6 +9883,8 @@ Partial Class Compras_Compras e.Row.FCLabel("LtlUnidadMedida").Attributes.Add("title", "Unidad de medida SIN registrar") End If + If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then e.Row.FCHyperLink("HplPS").Text = e.Row.DBCampo("PSCodigo") + 'EQUIVALENCIA If e.Row.DBCampo("CveUM").ToString.ToEntero > 0 And e.Row.DBCampo("CveTipoPS").ToString.ToEntero = 2 Then @@ -9946,6 +10243,7 @@ Partial Class Compras_Compras TmpDT.Columns.Add("CveCultivoCuadroDetalle", GetType(Integer)) TmpDT.Columns.Add("TemporadaCuadro", GetType(String)) + TmpDTOriginal = New DataTable TmpDTOriginal.Columns.Add("Consec", GetType(Integer)) TmpDTOriginal.Columns.Add("Cantidad", GetType(Decimal)) @@ -10056,6 +10354,7 @@ Partial Class Compras_Compras TmpDTOriginal.Columns.Add("TemporadaCuadro", GetType(String)) + End Sub Protected Sub RecargaMaximum_Click(sender As Object, e As System.EventArgs) @@ -10383,6 +10682,17 @@ Partial Class Compras_Compras e.Row.FCTextBox("TxtDividir").Visible = False End If End If + + If UsuarioActual.Empresa.Funcionalidad(574).ToEntero = 1 Then + + 'e.Row.Cells(4).Text = e.Row.DataKey("PUProtoPago").ToDecimal.ToString("###,###,###.00") + + 'If PorcentajeProntoPago > 0 Then + ' e.Row.Cells(4).Text = e.Row.DataKey("PUProtoPago").ToDecimal - () + 'End If + + End If + End If 'HEADER GvInv @@ -13060,7 +13370,7 @@ Partial Class Compras_Compras RegistraScript(String.Format("$('#{0}').modal('hide')", DivRefacturacion.ClientID)) End Sub - Private Function GuardaRefacturacion(ByRef ObjCompra As ClsCompras, ByRef ObjEventos As ClsOIEventos, CvePrePoliza As Integer) As Boolean + Private Function GuardaRefacturacion(ByRef ObjCompra As ClsCompras, ByRef ObjEventos As ClsOIEventos, CvePrePoliza As Integer, ByRef ObjConta As ClsContabilidad, ByRef CompraActual As Compra) As Boolean Dim dr As DataRow = Nothing Dim ErrorBitacora As Boolean = False Dim IdPolizaAnterior As Integer = -1 @@ -13080,8 +13390,28 @@ Partial Class Compras_Compras If ChkRefacNC.Checked Then Tipo = 2 'CONTABILIZA REFACTURACION - If Not ObjCompra.Refacturacion(CveCompraRefacturacion, CveCompra, UsuarioActual.CveEmpresa, Tipo) Then + If ObjCompra.Refacturacion(CveCompraRefacturacion, CveCompra, UsuarioActual.CveEmpresa, Tipo) Then + Dim dttpagos As DataTable + If ObjCompra.GetComprasPagos(CveCompraRefacturacion, UsuarioActual.CveEmpresa) Then + dttpagos = ObjCompra.DtResultados + + For Each drp As DataRow In dttpagos.Rows + Dim Pago As New CompraPago + Pago.ImportePago = drp("ImporteMN").ToString.ToDecimal + Pago.CveIE = drp("CveIE").ToString.ToEntero + Pago.CveMonedaPago = 1 + Pago.CveCompraAmortizacion = -1 + Pago.TipoPago = If(drp("CveIE").ToString.ToEntero > 0, "B", "NC") + + Dim ErrorMovtosCxP As Boolean = AplicaPrePolizaPagoCompra(CompraActual, Pago, CvePrePoliza, ObjConta) + Next + + End If + + Else + ErrorBitacora = True + End If @@ -13650,6 +13980,7 @@ Partial Class Compras_Compras CargaOC() End Sub Private Sub CargaOC() + MetodoPagoOC = -1 Dim EntregaDirecta As Integer = 0 DivOCSolicitudAnticipo.Visible = False DivOCSolicitudAnticipoModal.Visible = False @@ -13688,6 +14019,7 @@ Partial Class Compras_Compras HdnVCveOC.Value += String.Format("{0}{1}", If(HdnVCveOC.Value <> "", ",", ""), OC.DtResultados.Rows(0)("CveOrdenCompra").ToString) HdnCveEstatusOC.Value += String.Format("{0}{1}", If(HdnCveEstatusOC.Value <> "", ",", ""), OC.DtResultados.Rows(0)("CveEstatusSiguiente").ToString) EntregaDirecta += If(OC.DtResultados.Rows(0)("EntregaDirecta").ToString = "True", 1, 0) + MetodoPagoOC = OC.DtResultados.Rows(0)("MetodoPagoOC").ToString.ToEntero End If End If Next @@ -13703,6 +14035,7 @@ Partial Class Compras_Compras HdnVCveOC.Value += String.Format("{0}{1}", If(HdnVCveOC.Value <> "", ",", ""), OC.DtResultados.Rows(0)("CveOrdenCompra").ToString) HdnCveEstatusOC.Value += String.Format("{0}{1}", If(HdnCveEstatusOC.Value <> "", ",", ""), OC.DtResultados.Rows(0)("CveEstatusSiguiente").ToString) EntregaDirecta += If(OC.DtResultados.Rows(0)("EntregaDirecta").ToString = "True", 1, 0) + MetodoPagoOC = OC.DtResultados.Rows(0)("MetodoPagoOC").ToString.ToEntero End If End If Next @@ -13745,7 +14078,9 @@ Partial Class Compras_Compras Protected Sub BtnVOC_Click(sender As Object, e As EventArgs) VinculaOC() End Sub + Private Sub VinculaOC() + CveIEAnticipo = -1 If TxtOC.Text <> "" Then 'VARIABLES @@ -13792,6 +14127,7 @@ Partial Class Compras_Compras If ObjOC.DtResultados.Rows(0)("CveIEAnticipo").ToString.ToEntero > 0 Then FoliosOCAnticipo += $"{ObjOC.DtResultados.Rows(0)("FolioOC").ToString}," FoliosOCAnticipoIE += $"{ObjOC.DtResultados.Rows(0)("FolioIEAnticipo").ToString}," + CveIEAnticipo = ObjOC.DtResultados.Rows(0)("CveIEAnticipo").ToString.ToEntero DivOCSolicitudAnticipo.Visible = True DivOCSolicitudAnticipoModal.Visible = True End If @@ -13883,6 +14219,9 @@ Partial Class Compras_Compras If DivOCSolicitudAnticipo.Visible And FoliosOCAnticipo.Length > 0 Then LtSolicitudAnticipoFoliosOC.Text = $"La(s) siguiente(s) OC: {FoliosOCAnticipo.Substring(0, FoliosOCAnticipo.Length - 1)}. tienen vinculado un anticipo" LtSolicitudAnticipoFoliosIE.Text = $" {FoliosOCAnticipoIE.Substring(0, FoliosOCAnticipoIE.Length - 1)}" + + DVAtencionOCAnticipo.Visible = True + UpDVAtencionOCAnticipo.Update() End If 'PROMOCIONES @@ -14154,6 +14493,10 @@ Partial Class Compras_Compras End Sub Protected Sub BtnVincularOC_Click(sender As Object, e As EventArgs) + 'VincularOcProntoPago = False + AjusteProntoPagoPorcentajeIVA = 0D + AjusteProntoPagoConIVA = 0D + AjusteProntoPagoSinIVA = 0D 'If DdlOCVinculaInv.SelectedValue.ToEntero = 237 And Not CveFlete > 0 Then Alert("Necesita vincular un flete si selecciona Factura de Flete", TipoMensaje.MsgAdvertencia) : Exit Sub 'If DdlOCVinculaInv.SelectedValue.ToEntero = 240 And Not CveImportacion > 0 Then Alert("Necesita vincular una Importación si selecciona Factura de Importación", TipoMensaje.MsgAdvertencia) : Exit Sub @@ -14210,15 +14553,50 @@ Partial Class Compras_Compras LbSubTotalDif.Visible = False Vinculacion() Else - LbSubTotalDif.Visible = True - LbSubTotalDif.Text = (SubTotalCompra - SubTotalGV).FormatoNumero - Alert("Los SubTotales de la vinculación no coinciden. Rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia,,) - RegistraScript("CalculaTotalesOC();") + + If UsuarioActual.Empresa.Funcionalidad(574).ToEntero = 1 Then + + ImporteRNC = (SubTotalCompra - SubTotalGV).RoundSQL(2) + ImporteRNCProntoPago = (SubTotalCompra * PorcentajeProntoPago).RoundSQL(2) + + Dim ImporteOCConIVA As Decimal = 0D + Dim ImporteOCSinIVA As Decimal = 0D + + Dim ImporteCompraConIVA As Decimal = TmpDT.SUM("Total", " IVAPorcentaje > 0 ") + Dim ImporteCompraSinIVA As Decimal = TmpDT.SUM("Total", " IVAPorcentaje = 0 ") + + For Each gvr As GridViewRow In GvOC1.Rows + If gvr.DataKey("IVAPorcentaje").ToDecimal > 0 Then + ImporteOCConIVA = ImporteOCConIVA + (gvr.FCTextBox("TxtCantidad").Text.ToDecimal * gvr.FCTextBox("TxtPU").Text.ToDecimal) + Else + ImporteOCSinIVA = ImporteOCSinIVA + (gvr.FCTextBox("TxtCantidad").Text.ToDecimal * gvr.FCTextBox("TxtPU").Text.ToDecimal) + End If + Next + + AjusteProntoPagoPorcentajeIVA = TmpDT.MAX("IVAPorcentaje").ToDecimal + AjusteProntoPagoConIVA = (ImporteCompraConIVA - ImporteOCConIVA) + AjusteProntoPagoSinIVA = (ImporteCompraSinIVA - ImporteOCSinIVA) + + If ConfirmaVinculacionOCProntoPago() Then + Vinculacion() + End If + + + + Else + LbSubTotalDif.Visible = True + LbSubTotalDif.Text = (SubTotalCompra - SubTotalGV).FormatoNumero + Alert("Los SubTotales de la vinculación no coinciden. Rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia,,) + RegistraScript("CalculaTotalesOC();") + End If + + End If UpEstatus.Update() End Sub Protected Sub BtnVincularOCCompleta_Click(sender As Object, e As EventArgs) + VincularOcProntoPago = False Vinculacion(True) End Sub Private Sub Vinculacion(Optional VinculacionCompleta As Boolean = False) @@ -14346,6 +14724,51 @@ Partial Class Compras_Compras IndexTmpOriginal += 1 Next + + + + + If UsuarioActual.Empresa.Funcionalidad(574).ToEntero = 1 AndAlso (AjusteProntoPagoConIVA > 0 Or AjusteProntoPagoSinIVA > 0) Then + + Dim CvePS_RNC As Integer = UsuarioActual.Empresa.Funcionalidad(580).ToEntero + Dim PSRow As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS_RNC).FiltroPrimero("") + Dim CveSubProyectoPrincipal As Integer = AsignarSubProyectoPrincipal() + Dim SubProyecto As String = GlobalDTSubProyectos(-1, CveSubProyectoPrincipal, UsuarioActual.CveEmpresa).FiltroPrimeroValor("SubProyecto") + + Dim CveTipoPS As Integer = PSRow("CveTipoPS").ToString.ToEntero + If PSRow("CvePSCargo").ToString <> "" Then + CveTipoPS = 2 + End If + + Dim CveClasificacion As Integer = PSRow("CveClasificacion").ToString.ToEntero + Dim Clasificacion As String = PSRow("Clasificacion").ToString + Dim PS As String = PSRow("PS").ToString + Dim CveUM As Integer = PSRow("CveUnidadMedida").ToString.ToEntero + + + + Dim DTConIVA As DataTable = TmpDT.FiltraParametros(" IVAPorcentaje > 0") + If DTConIVA.Rows.Count > 0 Then + + End If + + Dim DTSinIVA As DataTable = TmpDT.FiltraParametros(" IVAPorcentaje = 0") + If DTSinIVA.Rows.Count > 0 Then + + End If + + Dim UM As String = PSRow("UnidadMedida").ToString + + If AjusteProntoPagoConIVA > 0 Then + AddPS(1, CveUM, UM, CveClasificacion, Clasificacion, CvePS_RNC, PS, 1, CveSubProyectoPrincipal.ToString, SubProyecto, "", "-1", "", AjusteProntoPagoConIVA, AjusteProntoPagoConIVA, AjusteProntoPagoPorcentajeIVA, 0, 0, 0, 0, 0) + End If + + If AjusteProntoPagoSinIVA > 0 Then + AddPS(1, CveUM, UM, CveClasificacion, Clasificacion, CvePS_RNC, PS, 1, CveSubProyectoPrincipal.ToString, SubProyecto, "", "-1", "", AjusteProntoPagoSinIVA, AjusteProntoPagoSinIVA, 0, 0, 0, 0, 0, 0) + End If + + End If + AddPS2(False) 'AJUSTE DE REDONDEO O DIFERENCIA PERMITIDA DE IMPORTE @@ -14430,10 +14853,32 @@ Partial Class Compras_Compras 'ANTICIPO OC If DivOCSolicitudAnticipo.Visible Then + + If CveIEAnticipo > 0 Then + DVAtencionOCAnticipo.Visible = True + UpDVAtencionOCAnticipo.Update() + End If + + Dim scripsSeccion As String = "" + For Each gvRow As GridViewRow In GVAnticipos.Rows + If gvRow.DataKey("CveIE").ToEntero = CveIEAnticipo Then + Dim Chk As CheckBox = gvRow.FCCheckBox("Chk") + scripsSeccion = scripsSeccion & $"$('#{Chk.ClientID}').click();" + 'RegistraScript($"$('#{Chk.ClientID}').click();", "100") + End If + Next + RegistraScript("MuestraAnticipos();", "MuestaAnticiposOC") + RegistraScript(" + setTimeout(function() { + " & scripsSeccion & " + }, 200) + ") UpAnticipos.Update() + End If + CalculaTotales() CompraEstaVinculadaOC = True @@ -15055,6 +15500,9 @@ Partial Class Compras_Compras Protected Sub DdlProveedores_SelectedIndexChanged(sender As Object, e As EventArgs) CargarFacturas() + If UsuarioActual.Empresa.Funcionalidad(574).ToEntero = 1 Then + CargaDdlRemisionNotaCredito() + End If End Sub Private Sub CargarFacturas() @@ -16502,6 +16950,12 @@ Partial Class Compras_Compras End Sub Protected Sub LbAgregar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LbAgregar.Click + + Dim ValImporte As Decimal = (TxtCantidad.Text.ToDecimal * TxtPrecio.Text.ToDecimal).RoundSQL(2) + If Not ValidaPresupuesto(1, DdlSubProyecto.SelectedValue.ToEntero, DdlSubProyecto.SelectedItem.Text, DdlClasificacion.SelectedValue.ToEntero, DdlClasificacion.SelectedItem.Text, DdlTipoGasto.SelectedValue.ToEntero, DdlTipoGasto.SelectedItem.Text, ValImporte) Then + Exit Sub + End If + 'VALIDACIONES If Not DdlPS.SelectedValue.ToEntero > 0 Then Alert("Es necesario seleccionar un Producto o Servicio registrado en el sistema.", TipoMensaje.MsgAdvertencia) @@ -16548,39 +17002,43 @@ Partial Class Compras_Compras Dim Total As Decimal = (TxtCantidad.Text.ToDecimal * TxtPrecio.Text.ToDecimal) - TxtDescuentoModal.Text.ToDecimal - If UsuarioActual.Empresa.Funcionalidad(532) = "1" Then - Dim ObjCon As New ClsContratos - Dim CvePresupuesto As Integer = 0 - Dim Autorizado As Double = 0 - Dim Ejercido As Double = 0 - If ObjCon.GetPresupuestos(-1, "-1", DdlSubProyecto.SelectedValue.ToEntero, 2, -1, UsuarioActual.CveEmpresa) Then - If ObjCon.DtResultados.Rows.Count > 0 Then - CvePresupuesto = ObjCon.DtResultados.Rows(0)("CvePresupuesto").ToString.ToEntero - If CvePresupuesto > 0 Then - If ObjCon.GetPresupuestosDetalle(CvePresupuesto, -1, UsuarioActual.CveEmpresa) Then - If ObjCon.DtResultados.FiltraParametros($"CveClasificacion = {DdlClasificacion.SelectedValue.ToEntero} AND CveTipoGasto = {DdlTipoGasto.SelectedValue.ToEntero} AND Importe > 0").Rows.Count > 0 Then - Autorizado = ObjCon.DtResultados.FiltraParametros($"CveClasificacion = {DdlClasificacion.SelectedValue.ToEntero} AND CveTipoGasto = {DdlTipoGasto.SelectedValue.ToEntero} AND Importe > 0").Rows(0)("Importe").ToString.ToDouble - End If - End If - If ObjCon.GetPresupuestosRep(CvePresupuesto, DdlTipoGasto.SelectedValue.ToEntero, 1, $"01/09/{NowADS().Year - 1}".ToDate, NowADS(), UsuarioActual.CveEmpresa, DdlProyecto.SelectedValue.ToEntero, - DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.CveUsuario, DdlClasificacion.SelectedValue.ToEntero) Then - If ObjCon.DtResultados.Rows.Count > 0 Then - Ejercido = ObjCon.DtResultados.Rows(0)("Ejercido").ToString.ToDouble - End If - End If - End If - End If - End If - ObjCon.Dispose() + 'If UsuarioActual.Empresa.Funcionalidad(532) = "1" Then + ' Dim ObjCon As New ClsContratos + ' Dim CvePresupuesto As Integer = 0 + ' Dim Autorizado As Double = 0 + ' Dim Ejercido As Double = 0 + ' If ObjCon.GetPresupuestos(-1, "-1", DdlSubProyecto.SelectedValue.ToEntero, 2, -1, UsuarioActual.CveEmpresa) Then + ' If ObjCon.DtResultados.Rows.Count > 0 Then + ' CvePresupuesto = ObjCon.DtResultados.Rows(0)("CvePresupuesto").ToString.ToEntero + ' If CvePresupuesto > 0 Then - If CvePresupuesto > 0 And Autorizado > 0 Then - Dim Diferencia As Double = (Ejercido + Total) - Autorizado - If Diferencia > 0 Then - Alert($"No hay presupuesto disponible en el subproyecto {DdlSubProyecto.SelectedItem.Text} con la clasificación {DdlClasificacion.SelectedItem.Text} y el tipo de gasto {DdlTipoGasto.SelectedItem.Text}. Se excede por {Diferencia.FormatoNumero}", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - End If + ' If ObjCon.GetPresupuestosDetalle(CvePresupuesto, -1, UsuarioActual.CveEmpresa) Then + ' If ObjCon.DtResultados.FiltraParametros($"CveClasificacion = {DdlClasificacion.SelectedValue.ToEntero} AND CveTipoGasto = {DdlTipoGasto.SelectedValue.ToEntero} AND Importe > 0").Rows.Count > 0 Then + ' Autorizado = ObjCon.DtResultados.FiltraParametros($"CveClasificacion = {DdlClasificacion.SelectedValue.ToEntero} AND CveTipoGasto = {DdlTipoGasto.SelectedValue.ToEntero} AND Importe > 0").Rows(0)("Importe").ToString.ToDouble + ' End If + ' End If + + ' If ObjCon.GetPresupuestosRep(CvePresupuesto, DdlTipoGasto.SelectedValue.ToEntero, 1, $"01/09/{NowADS().Year - 1}".ToDate, NowADS(), UsuarioActual.CveEmpresa, DdlProyecto.SelectedValue.ToEntero, + ' DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.CveUsuario, DdlClasificacion.SelectedValue.ToEntero) Then + ' If ObjCon.DtResultados.Rows.Count > 0 Then + ' Ejercido = ObjCon.DtResultados.Rows(0)("Ejercido").ToString.ToDouble + ' End If + ' End If + + ' End If + ' End If + ' End If + ' ObjCon.Dispose() + + ' If CvePresupuesto > 0 And Autorizado > 0 Then + ' Dim Diferencia As Double = (Ejercido + Total) - Autorizado + ' If Diferencia > 0 Then + ' Alert($"No hay presupuesto disponible en el subproyecto {DdlSubProyecto.SelectedItem.Text} con la clasificación {DdlClasificacion.SelectedItem.Text} y el tipo de gasto {DdlTipoGasto.SelectedItem.Text}. Se excede por {Diferencia.FormatoNumero}", TipoMensaje.MsgAdvertencia) + ' Exit Sub + ' End If + ' End If + + 'End If ActualizaTotales = True @@ -16657,6 +17115,8 @@ Partial Class Compras_Compras ' End If 'End If + + Select Case Modalidad Case "A" 'ADD @@ -16671,6 +17131,8 @@ Partial Class Compras_Compras Else IVA = Math.Round(DdlIVA.SelectedValue.ToDecimal - 1, 2) End If + + AddPS(TxtCantidad.Text.Trim.ToDecimal, ddlUM.SelectedValue.ToEntero, ddlUM.SelectedItem.Text, DdlClasificacion.SelectedValue.ToEntero, DdlClasificacion.SelectedItem.Text, DdlPS.SelectedValue.ToEntero, DdlPS.SelectedText, HdnTipoPS.Value.ToEntero, DdlSubProyecto.SelectedValue.ToString, DdlSubProyecto.SelectedItem.Text, DdlProyecto.SelectedItem.Text, DdlProyecto.SelectedValue.ToString, TxtObsPS.Text.Trim, TxtPrecio.Text.Trim.ToDecimal, Total, IVA, TxtRetIVAModal.Text.ToDecimal / 100, TxtRetISRModal.Text.ToDecimal / 100, TxtIEPSModal.Text.ToDecimal / 100, 0, TxtDescuentoModal.Text.ToDecimal, OtrosGastos:=0, CveTipoGasto:=DdlTipoGasto.SelectedValue.ToEntero, TipoGasto:=DdlTipoGasto.SelectedItem.Text, @@ -16748,10 +17210,14 @@ Partial Class Compras_Compras Optional PSCodigo As String = "-", Optional PSDescripcion As String = "-", Optional CantidadF As Double = -1, Optional EntregaDirecta As Integer = -1, Optional OtrosGastos As Decimal = 0, Optional CveSATPS As Integer = -1, Optional CargaXml As Boolean = False, Optional CveTipoGasto As Integer = -1, Optional TipoGasto As String = "", Optional PorcentajeIVA As Decimal = 0, Optional PorcentajeIEPS As Decimal = 0, Optional PorcentajeRetIVA As Decimal = 0, Optional PorcentajeRetISR As Decimal = 0, Optional NoDeducible As Boolean = False, Optional CveContratoDetalle As Integer = -1, Optional CveCultivoCuadroDetalle As Integer = -1, - Optional CveSATPSActualizado As Boolean = False, Optional TemporadaCuadro As String = "") As Integer + Optional CveSATPSActualizado As Boolean = False, Optional TemporadaCuadro As String = "", Optional CodigoPS As String = "") As Integer Dim Row As DataRow = Nothing + If Not TmpDT.Columns.Contains("CodigoPS") Then + TmpDT.Columns.Add("CodigoPS") + End If + Row = TmpDT.NewRow() Dim Retorno As Integer = 0 Dim CveContrato As Integer = -1 @@ -16835,6 +17301,12 @@ Partial Class Compras_Compras Row("Clasificacion") = Clasificacion Row("CvePS") = CvePS Row("PS") = PS + + If CodigoPS.Trim = "" Then + CodigoPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimeroValor("CodigoPS") + End If + Row("CodigoPS") = CodigoPS + Row("CveTipoPS") = CveTipoPS Row("PSDescripcion") = PSDescripcion @@ -17018,6 +17490,9 @@ Partial Class Compras_Compras DrPS("Clasificacion") = PSRow("Clasificacion").ToString DrPS("CvePS") = DdlPS.SelectedValue DrPS("PS") = PSRow("PS").ToString + + DrPS("CodigoPS") = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPS.SelectedValue.ToEntero).FiltroPrimeroValor("CodigoPS") + DrPS("CveTipoPS") = CveTipoPS DrPS("CveSATPS") = PSRow("CveSATPS").ToString.ToEntero DrPS("SATClaveProductoServicio") = PSRow("SATClaveProductoServicio").ToString @@ -17322,9 +17797,19 @@ Partial Class Compras_Compras Dim CvePS As Integer = -1 Dim tPS As String = "" + Dim tCodigoPS As String = "" CvePS = DdlPSAlias2.SelectedValue.ToEntero - tPS = DdlPSAlias2.SelectedText + + Dim dRowPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") + + If dRowPS IsNot Nothing Then + tPS = dRowPS("PS").ToString + tCodigoPS = dRowPS("CodigoPS").ToString + End If + + 'tPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimeroValor("PS") 'DdlPSAlias2.SelectedText + If CvePS <= 0 Then Alert("No se ha seleccionado el producto.", TipoMensaje.MsgAdvertencia) Exit Sub @@ -17350,6 +17835,7 @@ Partial Class Compras_Compras TmpDT.Rows(HdnAliasInd.Value.ToEntero)("CvePS") = CvePS TmpDT.Rows(HdnAliasInd.Value.ToEntero)("PS") = tPS + TmpDT.Rows(HdnAliasInd.Value.ToEntero)("CodigoPS") = tCodigoPS TmpDT.Rows(HdnAliasInd.Value.ToEntero)("CveUM") = DdlUnidadAlias.SelectedValue.ToEntero TmpDT.Rows(HdnAliasInd.Value.ToEntero)("UM") = DdlUnidadAlias.SelectedItem.Text TmpDT.Rows(HdnAliasInd.Value.ToEntero)("CveClasificacion") = HdnPSAliasCveClasificacion.Value.ToEntero @@ -17367,6 +17853,7 @@ Partial Class Compras_Compras For Each drt As DataRow In TmpDT.Select($"PS ='{TxtPSAlias.Text.Trim}' and ISNULL(CvePS,0) = 0") drt("CvePS") = CvePS drt("PS") = tPS + drt("CodigoPS") = tCodigoPS drt("CveUM") = DdlUnidadAlias.SelectedValue.ToEntero drt("UM") = DdlUnidadAlias.SelectedItem.Text drt("CveClasificacion") = HdnPSAliasCveClasificacion.Value.ToEntero @@ -19014,6 +19501,7 @@ Partial Class Compras_Compras dr("CveMetodoInventario") = 1 Next CargaGvInv() + End If ElseIf DdlTipoComprobante.SelectedValue.Contiene("Fac") Then If DdlTipoCompra.SelectedValue.Contiene("14") Then 'Recolección @@ -19029,9 +19517,24 @@ Partial Class Compras_Compras End If End If + If DdlTipoCompra.SelectedValue = "15" Then 'Remisión de nota de crédito + + If DdlTipoComprobante.SelectedValue = "NC" Then + CargaDdlRemisionNotaCredito() + Else + Alert("Para elegir Remisión de Nota de Crédito el tipo de documento debe de ser Nota de Crédito.", TipoMensaje.MsgAdvertencia) + DdlRemisionNotaCredito.SelectedValueExist(-1) + DdlTipoCompra.SelectedValueExist(-1) + End If + + + End If + End Sub + + #End Region #Region "GARANTÍAS" @@ -19318,12 +19821,12 @@ Partial Class Compras_Compras End Sub Public Sub LblProveedor_OnClick(sender As Object, e As EventArgs) Handles LblProveedor.Click - If CveTipoConcepto = 1 Then - LblProveedor.Text = "Acreedor:" - CveTipoConcepto = 2 - Else + If CveTipoConcepto = 2 Then LblProveedor.Text = "Proveedor:" CveTipoConcepto = 1 + Else + LblProveedor.Text = "Acreedor:" + CveTipoConcepto = 2 End If End Sub @@ -20140,6 +20643,400 @@ Partial Class Compras_Compras Protected Sub BtnRecolecciónAplicar_Click(sender As Object, e As EventArgs) End Sub + +#Region "PRESUPUESTOS" + + ''' + ''' Valida si hay presupuesto, Se valida con base en CveSubProyecto, CveClasificacion y CveTipoGasto + ''' + ''' Int 1 Indica que es una valiadcion al agregar el Producto o servicio 2 Indica validacion General antes de guardae . + ''' Usado al validar Presupuesto cuando se agrega un producto o servicio + ''' Usado al validar Presupuesto cuando se agrega un producto o servicio + ''' Usado al validar Presupuesto cuando se agrega un producto o servicio + ''' Usado al validar Presupuesto cuando se agrega un producto o servicio + ''' Usado al validar Presupuesto cuando se agrega un producto o servicio + ''' Usado al validar Presupuesto cuando se agrega un producto o servicio + ''' Usado al validar Presupuesto cuando se agrega un producto o servicio + ''' Verdadero si hay presupuesto, Falso si no hay presupuesto. + Public Function ValidaPresupuesto(Opcion As Integer, Optional ValCveSubProyecto As Integer = -1, Optional ValSubProyecto As String = "", Optional ValCveClasificacion As Integer = -1, Optional ValClasificacion As String = "", + Optional ValCveTipoGasto As Integer = -1, Optional ValTipoGasto As String = "", Optional ValImporte As Decimal = 0) As Boolean + + Dim respuesta As Boolean = False + + If DdlTipoComprobante.SelectedValue <> "Fac" Then + Return True + End If + + + + If UsuarioActual.Empresa.Funcionalidad(532) = "1" Then + + Dim ObjCon As New ClsContratos + Dim CvePresupuesto As Integer = 0 + Dim Autorizado As Double = 0 + Dim Ejercido As Double = 0 + + If ObjCon.GetPresupuestosResumen(UsuarioActual.CveEmpresa, -1, 1) Then + + Dim FechaCompra As Date = TxtFecha.Text.ToDate + + Dim resultadosFiltrados = From row In ObjCon.DtResultados.AsEnumerable() + Where FechaCompra >= row.Field(Of Date)("FechaInicio") AndAlso + FechaCompra <= row.Field(Of Date)("FechaFin") + Select row + + + + + + 'Dim dataTable As New DataTable + 'Dim rowFilter As String = "" + 'Dim orderby As String = "" + 'Dim groupByColumns As String()() = {New String() {"SubProyecto", "CveSubProyecto", "Clasificacion", "CveClasificacion", "TipoGasto", "CveTipoGasto"}} + 'Dim sumColumns As String() = {"Total"} + + + 'Dim resultDataTable As DataTable = GroupByDT(TmpDT, rowFilter, orderby, groupByColumns, sumColumns) + + + + + + If resultadosFiltrados.Count > 0 Then + + + + ''.TotalSum = Group.Sum(Function(r) r.Field(Of Decimal)("Total")) + If Opcion = 1 Then + + + Dim tieneRegistrosConCveSubProyecto As Boolean = resultadosFiltrados.Any(Function(row) CType(row("CveSubProyecto"), Integer) = ValCveSubProyecto) + + If tieneRegistrosConCveSubProyecto Then + Dim saldoTotal As Decimal = (From row In resultadosFiltrados + Where row.Field(Of Integer)("CveSubProyecto") = ValCveSubProyecto AndAlso + row.Field(Of Integer)("CveClasificacion") = ValCveClasificacion AndAlso + row.Field(Of Integer)("CveTipoGasto") = ValCveTipoGasto + Select row.Field(Of Decimal)("Saldo")).Sum() + If saldoTotal > 0 Then + + Dim TotalAcumuladoTabla As Decimal = (TmpDT.SUM("Total", $" CveSubProyecto = {ValCveSubProyecto} AND CveClasificacion = {ValCveClasificacion} AND CveTipoGasto = {ValCveTipoGasto} ")) + Dim Diferencia As Decimal = saldoTotal - TotalAcumuladoTabla - ValImporte + + If (Diferencia) < 0 Then + Alert($"No hay presupuesto disponible en el subproyecto {ValSubProyecto} con la clasificación {ValClasificacion}, Tipo de gasto {ValTipoGasto}. Se excede por {Math.Abs(Diferencia).FormatoNumero}", TipoMensaje.MsgAdvertencia) + respuesta = False + + Else + respuesta = True + End If + + Else + Alert($"No hay presupuesto disponible en el subproyecto {ValSubProyecto} con la clasificación {ValClasificacion}, Tipo de gasto {ValTipoGasto} ", TipoMensaje.MsgAdvertencia) + respuesta = False + End If + Else + respuesta = True + End If + + + Else + + 'Dim EnumAgrupado = (From row In TmpDT.AsEnumerable() + ' Group row By + ' SubProyecto = row.Field(Of String)("SubProyecto"), + ' CveSubProyecto = row.Field(Of Integer)("CveSubProyecto"), + ' Clasificacion = row.Field(Of String)("Clasificacion"), + ' CveClasificacion = row.Field(Of Integer)("CveClasificacion"), + ' TipoGasto = row.Field(Of String)("TipoGasto"), + ' CveTipoGasto = row.Field(Of Integer)("CveTipoGasto") + ' Into Group + ' Select New With { + ' .SubProyecto = SubProyecto, + ' .CveSubProyecto = CveSubProyecto, + ' .Clasificacion = Clasificacion, + ' .CveClasificacion = CveClasificacion, + ' .CveTipoGasto = CveTipoGasto, + ' .TipoGasto = TipoGasto, + ' .TotalSum = Group.Sum(Function(r) If(IsDBNull(r("Total")), 0D, Convert.ToDecimal(r("Total")))) + ' }).ToList() + + Dim EnumAgrupado = ( + From row In TmpDT.AsEnumerable() + Group row By + SubProyecto = If(row.IsNull("SubProyecto"), String.Empty, row.Field(Of String)("SubProyecto")), + CveSubProyecto = If(row.IsNull("CveSubProyecto"), -1, row.Field(Of Integer)("CveSubProyecto")), + Clasificacion = If(row.IsNull("Clasificacion"), String.Empty, row.Field(Of String)("Clasificacion")), + CveClasificacion = If(row.IsNull("CveClasificacion"), -1, row.Field(Of Integer)("CveClasificacion")), + TipoGasto = If(row.IsNull("TipoGasto"), String.Empty, row.Field(Of String)("TipoGasto")), + CveTipoGasto = If(row.IsNull("CveTipoGasto"), -1, row.Field(Of Integer)("CveTipoGasto")) + Into Group + Select New With { + .SubProyecto = SubProyecto, + .CveSubProyecto = CveSubProyecto, + .Clasificacion = Clasificacion, + .CveClasificacion = CveClasificacion, + .CveTipoGasto = CveTipoGasto, + .TipoGasto = TipoGasto, + .TotalSum = Group.Sum(Function(r) If(IsDBNull(r("Total")), 0D, Convert.ToDecimal(r("Total")))) + } + ).ToList() + + + For Each item In EnumAgrupado + + + Dim tieneRegistrosConCveSubProyecto As Boolean = resultadosFiltrados.Any(Function(row) CType(row("CveSubProyecto"), Integer) = item.CveSubProyecto) + + If tieneRegistrosConCveSubProyecto Then + Dim saldoTotal As Decimal = (From row In resultadosFiltrados + Where row.Field(Of Integer)("CveSubProyecto") = item.CveSubProyecto AndAlso + row.Field(Of Integer)("CveClasificacion") = item.CveClasificacion + Select row.Field(Of Decimal)("Saldo")).Sum() + If saldoTotal > 0 Then + + Dim Diferencia As Decimal = saldoTotal - item.TotalSum + + If (Diferencia) < 0 Then + Alert($"No hay presupuesto disponible en el subproyecto {item.SubProyecto} con la clasificación {item.Clasificacion}, Tipo de gasto {item.TipoGasto}. Se excede por {Math.Abs(Diferencia).FormatoNumero}", TipoMensaje.MsgAdvertencia) + respuesta = False + Exit For + Else + respuesta = True + End If + + Else + Alert($"No hay presupuesto disponible en el subproyecto {item.SubProyecto} con la clasificación {item.Clasificacion}, Tipo de gasto {item.TipoGasto}", TipoMensaje.MsgAdvertencia) + respuesta = False + Exit For + End If + Else + respuesta = True + End If + Next + End If + + + + + Else + 'Alert("No hay presupuestos.", TipoMensaje.MsgAdvertencia) + respuesta = True + End If + + + Else + 'Alert("No hay presupuestos.", TipoMensaje.MsgAdvertencia) + respuesta = False + End If + + ObjCon.Dispose() + + + + Else + respuesta = True + End If + + + Return respuesta + + End Function + +#End Region + + +#Region "PRONTO PAGO" + + Public Function GeneraRemisionsNotadeCredito(ByRef trasaccion As SqlTransaction, CveCompraRegistrada As Integer) As Boolean + Dim respuesta As Boolean = True + Dim PorcentajeIVA As Decimal = TmpDT.MAX("IVAPorcentaje").ToDecimal + + Dim CvePS_RNC As Integer = UsuarioActual.Empresa.Funcionalidad(580).ToEntero + Dim PSRow As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS_RNC).FiltroPrimero("") + Dim CveSubProyectoPrincipal As Integer = AsignarSubProyectoPrincipal() + Dim SubProyecto As String = "" + + If Not CvePS_RNC > 0 Then + Alert("No esta definido el producto de Remisión de Nota de Crédito.", TipoMensaje.MsgAdvertencia) + Return False + End If + + + If Not CveSubProyectoPrincipal > 0 Then + Alert("No esta definido el Sub Proyecto.", TipoMensaje.MsgAdvertencia) + Return False + End If + + SubProyecto = GlobalDTSubProyectos(-1, CveSubProyectoPrincipal, UsuarioActual.CveEmpresa).FiltroPrimeroValor("SubProyecto") + + If PSRow IsNot Nothing Then + + Dim CompraRNC As New ClsCompraManagerCompras("", ClsCompraManagerCompras.EnumCargaCompra.SinXML, GlobalDTTiposGastos(UsuarioActual.CveEmpresa), UsuarioActual) + CompraRNC.CveFactura = -1 + CompraRNC.CveProveedor = DdlProveedor.SelectedValue.ToEntero + CompraRNC.CveTipoProveedor = CveTipoProveedor + CompraRNC.CveTipoConceptoProveedor = CveTipoConcepto + CompraRNC.TipoCompra = ClsCompraManagerCompras.EnumTipoCompra.Sin_definir + CompraRNC.IEPSGasto = False + CompraRNC.Descripcion = $"Remisión Nota de Crédito {TxtDescripcion.Text}" + CompraRNC.NombreProveedor = DdlProveedor.SelectedItem.Text + CompraRNC.Fecha = TxtFecha.Text.ToDate + CompraRNC.CveMoneda = DdlMoneda.SelectedValue.ToEntero + CompraRNC.Serie = TxtSerie.Text + CompraRNC.Folio = TxtFolio.Text + CompraRNC.CveCompraAmortizacion = CveCompraRegistrada + + + + + Dim CveTipoPS As Integer = PSRow("CveTipoPS").ToString.ToEntero + If PSRow("CvePSCargo").ToString <> "" Then + CveTipoPS = 2 + End If + + Dim CveClasificacion As Integer = PSRow("CveClasificacion").ToString.ToEntero + Dim Clasificacion As String = PSRow("Clasificacion").ToString + Dim PS As String = PSRow("PS").ToString + Dim CveUM As Integer = PSRow("CveUnidadMedida").ToString.ToEntero + Dim UM As String = PSRow("UnidadMedida").ToString + Dim IVARNC As Decimal = (ImporteRNC * PorcentajeIVA).RoundSQL(2) + + + CompraRNC.ConfiguraRegistroRapidoRNC(CvePS_RNC, CveUM, UM, CveClasificacion, Clasificacion, PS, CveSubProyectoPrincipal, SubProyecto, ImporteRNC, (ImporteRNC + IVARNC), IVARNC) + If Not CompraRNC.AddCompraRNC(trasaccion) Then + respuesta = False + End If + + If respuesta Then + + Dim CompraRNCProntoPAgo As New ClsCompraManagerCompras("", ClsCompraManagerCompras.EnumCargaCompra.SinXML, GlobalDTTiposGastos(UsuarioActual.CveEmpresa), UsuarioActual) + CompraRNCProntoPAgo.CveFactura = -1 + CompraRNCProntoPAgo.CveProveedor = DdlProveedor.SelectedValue.ToEntero + CompraRNCProntoPAgo.CveTipoProveedor = CveTipoProveedor + CompraRNCProntoPAgo.CveTipoConceptoProveedor = CveTipoConcepto + CompraRNCProntoPAgo.TipoCompra = ClsCompraManagerCompras.EnumTipoCompra.Sin_definir + CompraRNCProntoPAgo.IEPSGasto = False + CompraRNCProntoPAgo.Descripcion = $"Remisión Nota de Crédito {TxtDescripcion.Text}" + CompraRNCProntoPAgo.NombreProveedor = DdlProveedor.SelectedItem.Text + CompraRNCProntoPAgo.Fecha = TxtFecha.Text.ToDate + CompraRNCProntoPAgo.CveMoneda = DdlMoneda.SelectedValue.ToEntero + CompraRNCProntoPAgo.Serie = $"{TxtSerie.Text}_P" + CompraRNCProntoPAgo.Folio = $"{TxtFolio.Text}_P" + CompraRNCProntoPAgo.CveCompraAmortizacion = CveCompraRegistrada + Dim IVARNCProntoPago As Decimal = (ImporteRNC * PorcentajeIVA).RoundSQL(2) + + CompraRNCProntoPAgo.ConfiguraRegistroRapidoRNC(CvePS_RNC, CveUM, UM, CveClasificacion, Clasificacion, PS, CveSubProyectoPrincipal, SubProyecto, ImporteRNCProntoPago, (ImporteRNCProntoPago + IVARNCProntoPago), IVARNCProntoPago) + If Not CompraRNCProntoPAgo.AddCompraRNC(trasaccion) Then + respuesta = False + End If + + End If + + + End If + + + + Return respuesta + End Function + + + Public Property VincularOcProntoPago As Boolean + Get + If ViewState("VincularOcProntoPago") Is Nothing Then + ViewState("VincularOcProntoPago") = False + End If + Return Boolean.Parse(ViewState("VincularOcProntoPago").ToString) + End Get + Set(value As Boolean) + ViewState("VincularOcProntoPago") = value + End Set + End Property + + Public Function ConfirmaVinculacionOCProntoPago() As Boolean + + If VincularOcProntoPago Then + Return True + Else + + If ImporteRNCProntoPago > 0 Then + LblModalConfirmaVinculacionProntoPago.Text = $"Existe una diferencia de ${(ImporteRNC + ImporteRNCProntoPago).ToString("###,###,###.00")} entre la compra y la Orden de Compra, se generaran dos Remisiones de Nota de Crédito una por descuento de ${ImporteRNC.ToString("###,###,###.00")} y otra por pronto pago de ${ImporteRNCProntoPago.ToString("###,###,###.00")}" + Else + LblModalConfirmaVinculacionProntoPago.Text = $"Existe una diferencia de ${(ImporteRNC).ToString("###,###,###.00")} entre la compra y la Orden de Compra, se generara una Remision de Nota de Crédito una por descuento de ${ImporteRNC.ToString("###,###,###.00")}" + End If + + RegistraScript("$('#DVModalConfirmaVinculacionProntoPago').modal('show');") + UpModalConfirmaVinculacionProntoPago.Update() + + Return False + End If + + End Function + + Protected Sub BtnModalConfirmaVinculacionProntoPago_Click(sender As Object, e As EventArgs) + + RegistraScript("$('#DVModalConfirmaVinculacionProntoPago').modal('hide');") + VincularOcProntoPago = True + BtnVincularOC_Click(Nothing, Nothing) + + End Sub + + Private Sub CargaDdlRemisionNotaCredito() + DvDdlRemisionNotaCredito.Visible = True + DTRemisionesNotaDeCredito = New DataTable + + Dim ObjCompras As New ClsCompras + + If ObjCompras.GetNotasCreditoRep(DdlProveedor.SelectedValue.ToEntero, 0, "-1", "-1", UsuarioActual.CveEmpresa, 2) Then + DdlRemisionNotaCredito.DataSource = ObjCompras.DtResultados + DTRemisionesNotaDeCredito = ObjCompras.DtResultados + Else + Alert("Ocurrió un error al obtener el catálogo de Notas de Crédito", Extensiones.TipoMensaje.MsgError) + End If + + ObjCompras.Dispose() + + DdlRemisionNotaCredito.DataBind() + DdlRemisionNotaCredito.Items.Insert(0, New ListItem("-", "-1")) + + UpEstatus.Update() + + End Sub + Protected Sub DdlRemisionNotaCredito_SelectedIndexChanged(sender As Object, e As EventArgs) + + ImporteRNCSaldar = 0 + SerieFolioProntoPago = "" + TipoCambioProntoPago = 1 + FechaProntoPago = MinFecha + CveMonedaProntoPago = 1 + + If DdlRemisionNotaCredito.SelectedValue.ToEntero > 0 Then + ImporteRNCSaldar = DTRemisionesNotaDeCredito.FiltroPrimeroValor("Saldo", $" CveCompra = {DdlRemisionNotaCredito.SelectedValue.ToEntero} ").ToDecimal + SerieFolioProntoPago = DTRemisionesNotaDeCredito.FiltroPrimeroValor("SerieFolio", $" CveCompra = {DdlRemisionNotaCredito.SelectedValue.ToEntero} ") + TipoCambioProntoPago = DTRemisionesNotaDeCredito.FiltroPrimeroValor("TipoCambio", $" CveCompra = {DdlRemisionNotaCredito.SelectedValue.ToEntero} ").ToDecimal + FechaProntoPago = DTRemisionesNotaDeCredito.FiltroPrimeroValor("Fecha", $" CveCompra = {DdlRemisionNotaCredito.SelectedValue.ToEntero} ").ToString.ToDate + CveMonedaProntoPago = DTRemisionesNotaDeCredito.FiltroPrimeroValor("CveMoneda", $" CveCompra = {DdlRemisionNotaCredito.SelectedValue.ToEntero} ").ToEntero + End If + + ''Alert(ImporteRNCSaldar.ToString) + 'CompraPago.SerieFolio = Gvr.DataKey("SerieFolio") + 'CompraPago.TC = Gvr.DataKey("TipoCambio").ToDecimal + 'CompraPago.Fecha = Gvr.DataKey("Fecha").ToDate + 'CompraPago.CveMoneda = Gvr.DataKey("CveMoneda").ToEntero + + 'CompraPago.Total = Gvr.DataKey("Total").ToDecimal + 'CompraPago.CveTipoConceptoProveedor = CveTipoConcepto + + + End Sub + +#End Region + + + + + End Class @@ -20150,3 +21047,2106 @@ Public Class MMensajeDevolucion Public Property Total As Decimal End Class + + +Public Class ClsCompraManagerCompras + + Enum EnumCargaCompra + DesdeXML + DesdeArchivo + SinXML + End Enum + Public Enum EnumCFDIVersion + v32 + V33 + V40 + End Enum + Public Enum EnumTipoCompra + Sin_definir = -1 + Gasto_con_almacen = 10 + Activo_Fijo = 1 + 'Costo_Indirecto = 2 + Almacen = 3 + Almacen_con_costo_indirecto = 8 + Costo_Indirecto = 4 + Importación = 5 + NC_Con_Productos = 6 + Apoyo_Logístico = 9 + NC_Por_Devolución = 11 + Garantia = 12 + End Enum + + + Public Enum EnumModalidadAccionPS + Agregar + Actualizar + End Enum + + Public Property CveCompra As Integer = -1 + Public Property CveProveedor As Integer + Public Property CveTipoConceptoProveedor As Integer + Public Property CveMoneda As Integer + Public Property Fecha As Date + Public ReadOnly Property SerieFolio As String + Get + If Serie.Length > 0 Then + Return $"{Serie}-{Folio}" + Else + Return $"{Folio}" + End If + End Get + End Property + + Public Property Serie As String = "" + Public Property Folio As String = "" + Public Property FolioSecundario As String = "" + Public Property Descripcion As String = "" + Public Property CFDIVersion As EnumCFDIVersion = EnumCFDIVersion.V40 + Public Property ProveedorNombre As String = "" + Public Property EsImportacion As Boolean = False + Public Property TC As Decimal = 1 + Public Property SubTotal As Decimal = 0D + Public Property SubTotal2 As Decimal = 0D + Public Property Descuento As Decimal = 0D + Public Property Total As Decimal = 0D + Public Property Moneda As String = "" + Public Property TipoComprobante As String + Public Property TipoCambio As Decimal = 1 + Public Property CompraNoDeducible As Integer = 0 + Public Property IVA As Decimal = 0D + Public Property IVADeducible As Decimal = 0D + Public Property IVANoDeducible As Decimal = 0 + Public Property IEPS As Decimal = 0D + Public Property RetIVA As Decimal = 0D + Public Property RetISR As Decimal = 0D + Public Property PorcentajeIVA As Decimal = 0 + Public Property PorcentajeISR As Decimal = 0 + Public Property CveRetIVAConcepto As Integer = -1 + Public Property CveRetISRConcepto As Integer = -1 + Public Property CveSubProyecto As Integer = -1 + Public Property UsuarioActual As Usuario + Public ReadOnly Property ConceptoPrePolizaIVA As ConceptosRetenciones + Get + Dim Ret As New ConceptosRetenciones + If EsImportacion Then + Ret.CveConceptoAcreditable = 288 + Ret.CveConceptoxAcreditar = 287 + Else + Ret.CveConceptoAcreditable = 19 + Ret.CveConceptoxAcreditar = 14 + End If + Return Ret + End Get + End Property + Public ReadOnly Property ConceptoPrePolizaRetIVA As ConceptosRetenciones + Get + Dim Ret As New ConceptosRetenciones + Dim Funcionalidad, FuncionalidadxAcred As Integer + If CveRetIVAConcepto = 1 Then + Funcionalidad = 308 : FuncionalidadxAcred = 307 + Ret.CveConceptoAcreditable = 22 + Ret.CveConceptoxAcreditar = 15 + ElseIf CveRetIVAConcepto = 2 Then + Funcionalidad = 310 : FuncionalidadxAcred = 309 + Ret.CveConceptoAcreditable = 184 + Ret.CveConceptoxAcreditar = 183 + ElseIf CveRetIVAConcepto = 3 Then + Funcionalidad = 312 : FuncionalidadxAcred = 311 + Ret.CveConceptoAcreditable = 186 + Ret.CveConceptoxAcreditar = 185 + ElseIf CveRetIVAConcepto = 4 Then + Funcionalidad = 314 : FuncionalidadxAcred = 313 + Ret.CveConceptoAcreditable = 249 + Ret.CveConceptoxAcreditar = 248 + ElseIf CveRetIVAConcepto = 5 Then + Funcionalidad = 578 : FuncionalidadxAcred = 578 + Ret.CveConceptoAcreditable = 286 + Ret.CveConceptoxAcreditar = 285 + ElseIf CveRetIVAConcepto = 6 Then + Funcionalidad = 578 : FuncionalidadxAcred = 578 + Ret.CveConceptoAcreditable = 333 + Ret.CveConceptoxAcreditar = 334 + End If + Return Ret + End Get + End Property + Public ReadOnly Property ConceptoPrePolizaRetISR As ConceptosRetenciones + Get + Dim Ret As New ConceptosRetenciones + Dim Funcionalidad, FuncionalidadxAcred As Integer + If CveRetISRConcepto = 1 Then + Funcionalidad = 316 : FuncionalidadxAcred = 315 + Ret.CveConceptoAcreditable = 23 + Ret.CveConceptoxAcreditar = 16 + ElseIf CveRetISRConcepto = 2 Then + Funcionalidad = 318 : FuncionalidadxAcred = 317 + Ret.CveConceptoAcreditable = 244 + Ret.CveConceptoxAcreditar = 243 + ElseIf CveRetISRConcepto = 3 Then + Funcionalidad = 349 : FuncionalidadxAcred = 348 + Ret.CveConceptoAcreditable = 328 + Ret.CveConceptoxAcreditar = 327 + End If + Return Ret + End Get + End Property + + Public Property CveMetodoPago As Integer + Public Property MetodoPago As String + Public Property DocumentosRelacionadosUUIDSList As List(Of String) = New List(Of String) + Public ReadOnly Property DocumentosRelacionadosUUIDSString As String + Get + Return GeneraStringDoctosRelacionados() + End Get + End Property + + Public Property DocumentosRelacionadosAnticiposUUIDList As List(Of String) = New List(Of String) + Public Property TieneAnticiposXML As Boolean = False + Public Property EmisorRFC As String + Public Property ReceptorRFC As String + Public Property UUID As String = "" + Public Property TotalRetenciones As Decimal = 0D + Public Property RetencionIVA As Decimal = 0D + Public Property RetencionISR As Decimal = 0D + Public Property SumaTotalRetenciones As Decimal = 0D + Public Property TotalTraslados As Decimal = 0D + Public Property TrasladoIVA As Decimal = 0D + Public Property TrasladoIEPS As Decimal = 0D + Public Property SumaTotalTraslados As Decimal = 0D + Public Property OtrosImpuestos As Decimal = 0D + Private Property OtrosImpuestosRetenciones As Decimal = 0D + Public Property Amortizacion As Decimal = 0D + Public Property FechaPago As Date 'FIX ME corregir usando fecha interna calculada por los dias de credito del proveedor + Public Property AplicaNotaCredito As Boolean = False + Public Property XMlStr As String + Public Property XMLCargaExistosa As Boolean = True + Public Property Observaciones As String = "" + Public Property CveEstatusFactura As Integer = 1 + Public Property CvePrePoliza As Integer = -1 + Public Property Redondeo As Decimal = 0 + Public Property IdPoliza As Integer = -1 + Public Property CveCajaChica As Integer = -1 + Public Property CvePersonal As Integer = -1 + Public Property NumeroReembolso As String = "" + Public Property CveProveedorSucursal As Integer = -1 + Public Property AplicoPromocion As Boolean = False + Public Property CveConceptoContableAlmacen As Integer = -1 + Public Property NoDeducible As Integer = 0 + Public Property CveTipoCompra As Integer = 1 + Public Property TotalOriginal As Decimal = 0D + Public Property CveTipoConcepto As Integer = 1 'FIX ME Esto tiene que ver con el CveTipoProveedor 1 y 3 es CveTipoConcepto 1 y 2 es CveTipoConcepto 2 + Public Property CveSubProyectoPrincipal As Integer = -1 + Public Property CveFactura As Integer = -1 + Public Property CveFolioGarantia As Integer = -1 + Public Property TmpDT As DataTable = New DataTable + Public Property SubTotalConceptos As Decimal = 0D + + Private Errores As StringBuilder = New StringBuilder + + Public ReadOnly Property MensajeError As String + Get + Return Errores.ToString() + End Get + End Property + + Public Property CompraSaldo As Decimal = 0D + Public Property SubTotalOriginal As Decimal = 0D + Public Property SubTotal2Original As Double = 0D + Public Property IVAOriginal As Decimal = 0D + Public Property RetIVAOriginal As Decimal = 0D + Public Property RetISROriginal As Decimal = 0D + Public Property Proyecto As String = "" + Public Property CveProyecto As Integer = -1 + Public Property SubProyecto As String = "" + Public Property TipoCompra As EnumTipoCompra = EnumTipoCompra.Sin_definir + Private Property DTTiposGastos() As DataTable + Public Property CveTipoProveedor As Integer = -1 + Public Property IEPSGasto As Boolean = False + Public Property OtrosImpuestosGasto As Boolean = False + Public Property OCVinculada As Boolean = False + Public Property NumNoDed As Integer = 0 + Public Property CveTipoPoliza As Integer = -1 + Public Property NombreProveedor As Object + Public Property CveCreditoDetalle As Integer = -1 + Public Property CveIE As Integer = -1 + Public Property CveCompraAmortizacion As Integer = -1 + + Public Sub New(XmlFuente As String, OpcionCarga As EnumCargaCompra, DTTiposGastos As DataTable, UsuarioActual As Usuario) + + Errores = New StringBuilder + + Me.DTTiposGastos = DTTiposGastos + Me.UsuarioActual = UsuarioActual + + + + If OpcionCarga = EnumCargaCompra.SinXML Then + + Else + If OpcionCarga = EnumCargaCompra.DesdeArchivo Then + CargaDesdeArchivo(XmlFuente) + Else + CargaDesdeString(XmlFuente) + End If + End If + + + + End Sub + + Private Sub CargaDesdeArchivo(XmlFuenteRuta As String) + + Dim XMLDoc As New XmlDocument + + If IO.File.Exists(XmlFuenteRuta) Then + XMlStr = File.ReadAllText(XmlFuenteRuta).Replace("<br>", "").Replace("<", "").Replace("o;?", "") + Try + XMLDoc.LoadXml(XMlStr) + XMLCargaExistosa = True + Catch ex As Exception + Try + Dim oReader As New StreamReader(XmlFuenteRuta, Encoding.GetEncoding("ISO-8859-1")) + XMLDoc.Load(oReader) + oReader.Dispose() + XMLCargaExistosa = True + Catch ex2 As Exception + GuardaLog("Error al intentar leer el XML del SAT. Error:" & ex2.ToString()) + Errores.AppendLine("Error al intentar leer el XML. Error:" & ex2.ToString()) + XMLCargaExistosa = False + End Try + End Try + End If + + If XMLCargaExistosa Then + CargaComprobanteXML(XMLDoc) + End If + + End Sub + Private Sub CargaDesdeString(XmlFuente As String) + XMlStr = XmlFuente.Replace("<br>", "").Replace("<", "").Replace("o;?", "") + Dim XMLDoc As New XmlDocument + Try + XMLDoc.LoadXml(XMlStr) + XMLCargaExistosa = True + Catch ex As Exception + GuardaLog("Error al intentar leer . Error:" & ex.ToString()) + Errores.AppendLine("Error al intentar leer el XML. Error:" & ex.ToString()) + XMLCargaExistosa = False + End Try + + If XMLCargaExistosa Then + CargaComprobanteXML(XMLDoc) + End If + + End Sub + + Private Sub CargaComprobanteXML(XMLDoc As XmlDocument) + Dim nodo As XmlNode = XMLDoc.DocumentElement + + Serie = ValorXML(nodo, "serie") + + Dim StrCFDIVerion As String = ValorXML(nodo, "version") + + If StrCFDIVerion = "3.2" Then + CFDIVersion = EnumCFDIVersion.v32 + ElseIf StrCFDIVerion = "3.3" Then + CFDIVersion = EnumCFDIVersion.V33 + ElseIf StrCFDIVerion = "4.0" Then + CFDIVersion = EnumCFDIVersion.V40 + Else + GuardaLog($"CFDI Versión {StrCFDIVerion} no soportada") + Errores.AppendLine($"CFDI Versión {StrCFDIVerion} no soportada") + XMLCargaExistosa = False + Exit Sub + End If + + Folio = ValorXML(nodo, "folio") + Fecha = ValorXML(nodo, "fecha").ToDate + SubTotal = ValorXML(nodo, "subTotal").ToDecimal + Total = ValorXML(nodo, "total").ToDecimal + Descuento = ValorXML(nodo, "descuento").ToDecimal + Moneda = ValorXML(nodo, "Moneda") + + CveMoneda = GlobalDTMonedas().FiltroPrimeroValor("CveMoneda", $" AbreviaturaSAT = '{Moneda}' ").ToEntero + If Not CveMoneda > 0 Then + GuardaLog($"Moneda {Moneda} no se obtuvo la clabe") + Errores.AppendLine($"Moneda {Moneda} no se obtuvo la clabe") + XMLCargaExistosa = False + Exit Sub + End If + + TipoComprobante = ValorXML(nodo, "tipoDeComprobante") + TipoCambio = ValorXML(nodo, "TipoCambio", "1").ToDecimal + + If CFDIVersion = EnumCFDIVersion.V33 Or CFDIVersion = EnumCFDIVersion.V40 Then + Dim drm As DataRow = GlobalDTVtaMetodoPago.FiltroPrimero(String.Format("ClaveMetodoPagoSAT = '{0}'", ValorXML(nodo, "MetodoPago"))) + If drm IsNot Nothing Then + CveMetodoPago = drm("CveMetodoPago").ToString.ToEntero + MetodoPago = drm("MetodoPagoSAT").ToString + End If + End If + + Dim namespaces As New XmlNamespaceManager(XMLDoc.NameTable) + Dim Prefijo As String = If(XMLDoc.DocumentElement.Prefix = "", "cfd", XMLDoc.DocumentElement.Prefix) + Dim cfdVer As String = "" + + If CFDIVersion = EnumCFDIVersion.v32 Then + Prefijo = "cfd" + cfdVer = "http://www.sat.gob.mx/cfd/2" + ElseIf CFDIVersion = EnumCFDIVersion.V33 Then + cfdVer = "http://www.sat.gob.mx/cfd/3" + Else ' se considera que es la version 4.0 + cfdVer = "http://www.sat.gob.mx/cfd/4" + End If + namespaces.AddNamespace(Prefijo, cfdVer) + namespaces.AddNamespace("aerolineas", "http://www.sat.gob.mx/aerolineas") + namespaces.AddNamespace("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital") + namespaces.AddNamespace("implocal", "http://www.sat.gob.mx/implocal") + namespaces.AddNamespace("registrofiscal", "http://www.sat.gob.mx/registrofiscal") + + If TipoComprobante.ToUpper = "E" AndAlso (CFDIVersion = EnumCFDIVersion.V33 OrElse CFDIVersion = EnumCFDIVersion.V40) Then + Dim UUIDS As String = "" + + Dim UUIDSLista As New List(Of String) + Dim nodeCFDIRelacionados As XmlNode + nodeCFDIRelacionados = XMLDoc.SelectSingleNode(String.Format("//{0}:CfdiRelacionados", Prefijo), namespaces) + + If nodeCFDIRelacionados IsNot Nothing Then + For Each CFDIRelacionados As XmlNode In nodeCFDIRelacionados + UUIDSLista.Add("" & CFDIRelacionados.Attributes("UUID").Value.ToString & "") + Next + End If + DocumentosRelacionadosUUIDSList = UUIDSLista + + End If + + Dim node As XmlNode + node = XMLDoc.SelectSingleNode(String.Format("//{0}:Emisor", Prefijo), namespaces) + + If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then + EmisorRFC = ValorXML(node, "RFC") + End If + + node = XMLDoc.SelectSingleNode(String.Format("//{0}:Receptor", Prefijo), namespaces) + + If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then + ReceptorRFC = ValorXML(node, "RFC") + End If + + If UsuarioActual.CveEmpresa.Contiene(119, 7) Then + node = XMLDoc.SelectSingleNode(String.Format("//{0}:CfdiRelacionados", Prefijo), namespaces) + If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then + If ValorXML(node, "TipoRelacion").ToString.Contiene("07") Then + Dim nodeDocumentosRelacionados As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:CfdiRelacionado", Prefijo), namespaces) + For Each documento As XmlNode In nodeDocumentosRelacionados + If documento.Attributes("UUID").Value <> "" Then + DocumentosRelacionadosAnticiposUUIDList.Add(documento.Attributes("UUID").Value) + End If + TieneAnticiposXML = True + Next + End If + End If + End If + + node = XMLDoc.SelectSingleNode(String.Format("//{0}:Impuestos", Prefijo), namespaces) + If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then + Dim nodeRetenciones As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:Comprobante/{0}:Impuestos/{0}:Retenciones/{0}:Retencion", Prefijo), namespaces) + + TotalRetenciones = ValorXML(node, "totalImpuestosRetenidos", "0").ToDecimal + + If CFDIVersion = EnumCFDIVersion.V33 OrElse CFDIVersion = EnumCFDIVersion.V40 Then + + For Each retencion As XmlNode In nodeRetenciones + If retencion.Attributes("Impuesto").Value = "002" Then RetencionIVA += retencion.Attributes("Importe").Value.ToDecimal + If retencion.Attributes("Impuesto").Value = "001" Then RetencionISR += retencion.Attributes("Importe").Value.ToDecimal + Next + + Else + + For Each retencion As XmlNode In nodeRetenciones + If retencion.Attributes("impuesto").Value = "IVA" Then RetencionIVA += retencion.Attributes("importe").Value.ToDecimal + If retencion.Attributes("impuesto").Value = "ISR" Then RetencionISR += retencion.Attributes("importe").Value.ToDecimal + Next + End If + SumaTotalRetenciones += RetencionIVA + SumaTotalRetenciones += RetencionISR + + TotalTraslados = ValorXML(node, "totalImpuestosTrasladados", "0").ToDecimal + Dim nodeTraslados As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:Comprobante/{0}:Impuestos/{0}:Traslados/{0}:Traslado", Prefijo), namespaces) + + If CFDIVersion = EnumCFDIVersion.V33 OrElse CFDIVersion = EnumCFDIVersion.V40 Then + + For Each traslado As XmlNode In nodeTraslados + + If traslado.Attributes("Importe") IsNot Nothing Then + If traslado.Attributes("Impuesto").Value = "002" Then TrasladoIVA += traslado.Attributes("Importe").Value.ToDecimal + If traslado.Attributes("Impuesto").Value = "003" Then TrasladoIEPS += traslado.Attributes("Importe").Value.ToDecimal + End If + Next + Else + + For Each traslado As XmlNode In nodeTraslados + If traslado.Attributes("Importe") IsNot Nothing Then + If traslado.Attributes("impuesto").Value = "IVA" Then TrasladoIVA += traslado.Attributes("importe").Value.ToDecimal + + If traslado.Attributes("impuesto").Value = "IEPS" Then TrasladoIEPS += traslado.Attributes("importe").Value.ToDecimal + End If + Next + End If + + SumaTotalTraslados += TrasladoIVA + SumaTotalTraslados += TrasladoIEPS + End If + + Dim nodeComp As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Complemento", Prefijo), namespaces) + If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then + + Dim nodeTFD As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:TimbreFiscalDigital", "tfd"), namespaces) + + UUID = ValorXML(nodeTFD, "UUID", "") + + Dim nodeRF As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:CFDIRegistroFiscal ", "registrofiscal"), namespaces) + If nodeRF IsNot Nothing Then + Folio = ValorXML(nodeRF, "folio").TrimStart("0"c) + End If + + node = node.SelectSingleNode(String.Format("//{0}:ImpuestosLocales", "implocal"), namespaces) + + If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then + OtrosImpuestos = ValorXML(node, "TotaldeTraslados", "0").ToDecimal + '2022.06.04-- se quitan los datos de retenciones de impuestos locales, generan conflicto. RMF + 'OtrosImpuestosRetenciones = ValorXML(node, "TotaldeRetenciones", "0").ToDecimal + End If + End If + + + If XMLCargaExistosa Then + If Not ValidateUUID(UUID) Then + GuardaLog($"UUID Invalido {UUID} .") + Errores.AppendLine($"UUID Invalido {UUID} .") + XMLCargaExistosa = False + End If + End If + + +#Region "DETALLES" + + Dim ObjeFacturas As New ClsCompras + Dim AjustaUltimoConcepto As Boolean = False + + Dim nodeconceptos As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Conceptos", Prefijo), namespaces) + Dim XML As String = Replace(nodeconceptos.OuterXml, "", "") 'salto de linea html + XML = XML.Replace("<br>", "") + XML = XML.Replace("<", "") + + XML = XML.Replace("&", "") 'adicional, si hay otros + + If ObjeFacturas.GetFacturasComparacionXML(StrCFDIVerion, XML, UsuarioActual.CveEmpresa) Then + TmpDT = ObjeFacturas.DtResultados + TmpDT.Columns.Add("CveSATPSActualizado") + SubTotalConceptos = TmpDT.SUMD("Total").RoundSQL + + If Not TmpDT.Columns.Contains("Amortizacion") Then + TmpDT.Columns.Add("Amortizacion", GetType(Decimal)) + End If + 'VALIDA QUE EL XML SI VIENE CON EL CODIGO SAT 01010101 + Dim ProductosCodigoSATNoPermitidos As New StringBuilder("") + For Each drr As DataRow In TmpDT.FiltraParametros("ClaveProdServ = '01010101'").Rows + ProductosCodigoSATNoPermitidos.AppendFormat("{0}
    ", drr("PS")) + Next + + If ProductosCodigoSATNoPermitidos.ToString.Length > 0 Then + Errores.AppendLine($"El comprobante contiene productos con código SAT '01010101', revise los productos:

    {ProductosCodigoSATNoPermitidos.ToString}") + + End If + Else + GuardaLog($"Error al cargar detalles GetFacturasComparacionXML.") + Errores.AppendLine($"Error al cargar detalles GetFacturasComparacionXML.") + XMLCargaExistosa = False + End If + + ObjeFacturas.Dispose() + + If CFDIVersion = EnumCFDIVersion.V33 OrElse CFDIVersion = EnumCFDIVersion.V40 Then + If Not TmpDT.Columns.Contains("Amortizacion") Then + TmpDT.Columns.Add("Amortizacion", GetType(Decimal)) + End If + TmpDT.AcceptChanges() + ValidacionesTotalesXml() + End If + + Me.PorcentajeIVA = TmpDT.MAX("IVAPorcentaje").ToDecimal + +#End Region + End Sub + + Public Function ConfiguraRegistroRapidoReembolso(CvePS As Integer, CveSubProyecto As Integer, CveCajaChica As Integer, CvePersonal As Integer, CveRetIVAConcepto As Integer, CveRetISRConcepto As Integer, NumeroReembolso As String) As Boolean + + Dim respuesta As Boolean = True + Me.CveSubProyecto = CveSubProyecto + Me.CveSubProyectoPrincipal = CveSubProyecto + Me.CveCajaChica = CveCajaChica + Me.CvePersonal = CvePersonal + Me.CveRetIVAConcepto = CveRetIVAConcepto + Me.CveRetISRConcepto = CveRetISRConcepto + Me.CveTipoPoliza = 3 + Me.NumeroReembolso = NumeroReembolso + + Dim dRowSubProyecto As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("") + + If dRowSubProyecto IsNot Nothing Then + Me.Proyecto = dRowSubProyecto("Proyecto").ToString + Me.CveProyecto = (dRowSubProyecto("CveProyecto").ToString).ToEntero + Me.SubProyecto = dRowSubProyecto("SubProyecto").ToString + Else + Errores.AppendLine($"Error al cargar el Sub Proyecto CveSubProyecto: {CveSubProyecto}") + Return False + End If + + Dim DTIndex As DataTable = TmpDT.FiltraParametros("", DistinctColumns:={"Consec"}) + + For Each dRowIndex As DataRow In DTIndex.Rows + If Not UpdatePSReembolso(dRowIndex("Consec").ToString.ToEntero, CvePS) Then + respuesta = False + End If + Next + + If respuesta AndAlso IEPS > 0 Then + If Not AgregaIEPSReembolso(CvePS:=CvePS) Then + respuesta = False + Else + IEPS = 0 + End If + End If + + If Not AjustesValidacion() Then + respuesta = False + End If + + Return respuesta + + End Function + Public Function ConfiguraRegistroRapidoRNC(CvePS As Integer, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, PS As String, CveSubProyecto As Integer, SubProyecto As String, + SubTotal As Decimal, Total As Decimal, IVA As Decimal) As Boolean + + Dim respuesta As Boolean = True + Me.CveSubProyecto = CveSubProyecto + Me.CveSubProyectoPrincipal = CveSubProyecto + Me.CveCajaChica = -1 + Me.CvePersonal = -1 + Me.CveRetIVAConcepto = -1 + Me.CveRetISRConcepto = -1 + Me.CveTipoPoliza = 3 + Me.NumeroReembolso = "" + Me.SubTotal = SubTotal + Me.IVA = IVA + Me.Total = Total + + + Dim dRowSubProyecto As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("") + + If dRowSubProyecto IsNot Nothing Then + Me.Proyecto = dRowSubProyecto("Proyecto").ToString + Me.CveProyecto = (dRowSubProyecto("CveProyecto").ToString).ToEntero + Me.SubProyecto = dRowSubProyecto("SubProyecto").ToString + Else + Errores.AppendLine($"Error al cargar el Sub Proyecto CveSubProyecto: {CveSubProyecto}") + Return False + End If + + + CreaDTCompras() + AddPS(1, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, 1, CveSubProyecto.ToString, SubProyecto, "", "-1", "", SubTotal, SubTotal, 0, 0, 0, 0, 0, 0) + + 'If respuesta AndAlso IEPS > 0 Then + ' If Not AgregaIEPSReembolso(CvePS:=CvePS) Then + ' respuesta = False + ' Else + ' IEPS = 0 + ' End If + 'End If + + 'If Not AjustesValidacion() Then + ' respuesta = False + 'End If + + Return respuesta + + End Function + + + Private Sub CreaDTCompras() + + TmpDT = New DataTable + TmpDT.Columns.Add("Consec", GetType(Integer)) + TmpDT.Columns.Add("Cantidad", GetType(Decimal)) + TmpDT.Columns.Add("Codigo", GetType(String)) + TmpDT.Columns.Add("CveUM", GetType(Integer)) + TmpDT.Columns.Add("UM", GetType(String)) + TmpDT.Columns.Add("CveClasificacion", GetType(Integer)) + TmpDT.Columns.Add("Clasificacion", GetType(String)) + TmpDT.Columns.Add("CveClasificacionActualizar", GetType(Integer)) + TmpDT.Columns.Add("CvePS", GetType(Integer)) + TmpDT.Columns.Add("PS", GetType(String)) + TmpDT.Columns.Add("Obs", GetType(String)) + TmpDT.Columns.Add("PU", GetType(Decimal)) + TmpDT.Columns.Add("IVA", GetType(Decimal)) + TmpDT.Columns.Add("IVAPorcentaje", GetType(Decimal)) + TmpDT.Columns.Add("RetIVA", GetType(Decimal)) + TmpDT.Columns.Add("RetIVAPorcentaje", GetType(Decimal)) + TmpDT.Columns.Add("RetISR", GetType(Decimal)) + TmpDT.Columns.Add("RetISRPorcentaje", GetType(Decimal)) + TmpDT.Columns.Add("IEPSPS", GetType(Double)) + TmpDT.Columns.Add("IEPSPSPorcentaje", GetType(Double)) + TmpDT.Columns.Add("IEPSPSIVA", GetType(Double)) + TmpDT.Columns.Add("IEPSPSIVAPorcentaje", GetType(Double)) + TmpDT.Columns.Add("Descuento", GetType(Decimal)) + TmpDT.Columns.Add("OtrosGastos", GetType(Decimal)) + TmpDT.Columns.Add("Total", GetType(Decimal)) + TmpDT.Columns.Add("AsientoContableCompras", GetType(Integer)) + TmpDT.Columns.Add("Proyecto", GetType(String)) + TmpDT.Columns.Add("CveProyecto", GetType(Integer)) + TmpDT.Columns.Add("CveSubProyecto", GetType(Integer)) + TmpDT.Columns.Add("CveContrato", GetType(Integer)) + TmpDT.Columns.Add("SubProyecto", GetType(String)) + 'TmpDT.Columns.Add("CveEq", GetType(Integer)) + TmpDT.Columns.Add("CveAlmacen", GetType(Integer)) + TmpDT.Columns.Add("CvePersonal", GetType(String)) + TmpDT.Columns.Add("Referencia", GetType(String)) + + 'AC + TmpDT.Columns.Add("CveTipoGastoAC", GetType(Integer)) + TmpDT.Columns.Add("CvePresupuestoEgreso", GetType(Integer)) + TmpDT.Columns.Add("CveProgramaOperativo", GetType(Integer)) + TmpDT.Columns.Add("CveUnidadAdministrativa", GetType(Integer)) + TmpDT.Columns.Add("CveFuenteFinanciamiento", GetType(Integer)) + TmpDT.Columns.Add("CveClasificacionOG", GetType(Integer)) + + TmpDT.Columns.Add("IdCuentaComprometido", GetType(Integer)) + TmpDT.Columns.Add("IdCuentaPorEjercer", GetType(Integer)) + TmpDT.Columns.Add("IdCuentaDevengado", GetType(Integer)) + TmpDT.Columns.Add("IdCuentaMatriz", GetType(Integer)) + + 'INVENTARIO SERIE/LOTE + TmpDT.Columns.Add("CveMetodoInventario", GetType(Integer)) + + TmpDT.Columns.Add("CveConcepto", GetType(Integer)) + + 'AF + TmpDT.Columns.Add("CveActivoFijo", GetType(Integer)) + TmpDT.Columns.Add("CodAF", GetType(String)) + TmpDT.Columns.Add("TipoAF", GetType(Integer)) + TmpDT.Columns.Add("AFMedida", GetType(Integer)) + TmpDT.Columns.Add("AFTipoMantenimiento", GetType(Integer)) + + 'PS + TmpDT.Columns.Add("CveTipoPS", GetType(Integer)) + TmpDT.Columns.Add("CodigoPS", GetType(String)) + TmpDT.Columns.Add("PSDescripcion", GetType(String)) + 'CAMPO ESPECIAL PARA GLUYAS - LEE EL DEL XML - A GLUYAS LE INTERESA EL CODIGO DEL PROVEEDOR + TmpDT.Columns.Add("PSCodigo", GetType(String)) + + + 'OC + TmpDT.Columns.Add("CveOrdenCompraDetalle", GetType(Integer)) + TmpDT.Columns.Add("ProductoOC", GetType(String)) + TmpDT.Columns.Add("CantidadF", GetType(Double)) + + 'Consignaciones + TmpDT.Columns.Add("CveAlmacenConsignacion", GetType(Integer)) + TmpDT.Columns.Add("NoConsignacion", GetType(Integer)) + TmpDT.Columns.Add("CveConsignacion", GetType(Integer)) + TmpDT.Columns.Add("HdnPS", GetType(String)) + TmpDT.Columns.Add("HdnCvePS", GetType(String)) + TmpDT.Columns.Add("HdnClasificacion", GetType(String)) + TmpDT.Columns.Add("HdnCveClasificacion", GetType(String)) + TmpDT.Columns.Add("HdnCveAlmacen", GetType(String)) + + 'Fletes y Servicios + TmpDT.Columns.Add("AplicaCostoIndirecto", GetType(Integer)) + TmpDT.Columns.Add("CostoIndirectoAlmacen", GetType(Decimal)) + TmpDT.Columns.Add("CveCompraDetalle", GetType(Integer)) + + TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) + + 'SAT + TmpDT.Columns.Add("CveSATPS", GetType(Integer)) + TmpDT.Columns.Add("SATClaveProductoServicio", GetType(String)) + TmpDT.Columns.Add("CveUnidadMedidaSAT", GetType(Integer)) + TmpDT.Columns.Add("SATClaveUnidadMedida", GetType(String)) + TmpDT.Columns.Add("CveSATPSActualizado", GetType(Integer)) + + + 'Tipo de Gasto + TmpDT.Columns.Add("CveTipoGasto", GetType(Integer)) + TmpDT.Columns.Add("TipoGasto", GetType(String)) + + TmpDT.Columns.Add("ImporteSinImpuestos", GetType(Double)) + TmpDT.Columns.Add("ImporteConImpuestos", GetType(Double)) + TmpDT.Columns.Add("NoDeducible", GetType(Boolean)) + + TmpDT.Columns.Add("DifPSSat", GetType(Integer)) + + + TmpDT.Columns.Add("CveContratoDetalle", GetType(Integer)) + TmpDT.Columns.Add("CveCultivoCuadroDetalle", GetType(Integer)) + TmpDT.Columns.Add("TemporadaCuadro", GetType(String)) + + + TmpDT.AcceptChanges() + + + End Sub + Private Function AjustesValidacion() As Boolean + Dim respuesta As Boolean = True + 'VALIDA IMPORTES + If Not ValidaTotalesGuardar() Then + respuesta = False + End If + + If Not AjustaCombustibles() Then + respuesta = False + End If + + If Not AjustaIVA() Then + respuesta = False + End If + + If Not AjustaRetIVA() Then + respuesta = False + End If + + If Not AjustaRetISR() Then + respuesta = False + End If + + Return respuesta + + End Function + + Private Function ValidaTotalesGuardar() As Boolean + Dim EsValido As Boolean = True + + 'VALIDA IMPORTES + 'VALIDA TOTAL CON LOS IMPORTES TOTALES + Dim TempSubTotal, TempDescuentos, TempIVA, TempSubTotal2, TempRetIVA, TempRetISR, TempTotal, DifTotales, TempIEPS As Decimal + + Dim Amortizacion As Decimal = 0 + Dim TieneAmortizacion As Boolean = False + If DocumentosRelacionadosAnticiposUUIDList IsNot Nothing AndAlso DocumentosRelacionadosAnticiposUUIDList.Count > 0 Then 'Fix me + ' AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 Then + 'TieneAmortizacion = True + End If + + 'If CveCompra < 0 AndAlso Not TieneAmortizacion Then + ' LblAmortizacion.Text = "0.00" + 'End If + + 'If UsuarioActual.CveEmpresa = 119 AndAlso TieneAmortizacion Then + ' Amortizacion = LblAmortizacion.Text.Trim.ToDecimal + ' TxtSubTotal.Text = (TxtSubTotal.Text.ToDouble + Amortizacion).ToString + 'End If + + + TempSubTotal = SubTotal + SubTotalOriginal = SubTotal + SubTotal2Original = SubTotal2 + TempDescuentos = Descuento + Amortizacion + TempSubTotal2 = TempSubTotal - TempDescuentos + TempIVA = IVA + TempIEPS = IEPS + TempRetIVA = RetIVA + TempRetISR = RetISR + TempTotal = Math.Round(TempSubTotal2 + TempIVA + TempIEPS - TempRetIVA - TempRetISR + OtrosImpuestos - Amortizacion, 2) + DifTotales = Total - TempTotal + Dim DiferenciaPermitida As Decimal = 0.6D + + If Math.Abs(DifTotales) > DiferenciaPermitida Then + Errores.AppendLine($"Los importes de los conceptos (Productos/Servicios) no cuadran con el total. Por favor verifique y vuelva a intentar.[{Math.Abs(DifTotales) - DiferenciaPermitida}]") + EsValido = False + ElseIf DifTotales <> 0 Then + SubTotal2 = (SubTotal2 + DifTotales) + SubTotal = (SubTotal + DifTotales) + SubTotalOriginal = SubTotal + SubTotal2Original = SubTotal2 + End If + + Dim DiferenciaSubtotales As Decimal = 0 + If CveCompra > 0 Or CveFactura > 0 Or OCVinculada Then + + If SubTotalOriginal = Nothing Then + SubTotalOriginal = 0 + End If + + If SubTotal2Original = Nothing Then + SubTotal2Original = 0 + End If + + DiferenciaSubtotales = SubTotal2Original.ToString.ToDecimal - TmpDT.SUM("Total").ToString.ToDecimal + '[IPP] PARCHE: Factura TELMEX para APH 12/ENERO/2018 + If CveFactura = 286290 Then + DiferenciaSubtotales += Descuento + End If + If Math.Abs(DiferenciaSubtotales) > 1 And Not CompraNoDeducible = 1 Then 'EsNoDeducible + Errores.AppendLine("Los importes de los conceptos (Productos/Servicios) no cuadran con el total. Por favor verifique y vuelva a intentar.") + EsValido = False + Else + AjustaImporteUltimoConcepto(DiferenciaSubtotales) + End If + Else + DiferenciaSubtotales = (SubTotal2 - TmpDT.SUMD("Total")).ToString.ToDecimal + If Math.Abs(DiferenciaSubtotales) > 1 Then + Errores.AppendLine("Los importes de los conceptos (Productos/Servicios) no cuadran con el total. Por favor verifique y vuelva a intentar.") + EsValido = False + Else + AjustaImporteUltimoConcepto(DiferenciaSubtotales) + End If + End If + + Return EsValido + End Function + + + + Private Function AjustaCombustibles() As Boolean + + Dim Respuesta As Boolean = False + + Dim IVADetalles As Decimal = TmpDT.SUMD("IVA", " IVA > 0 ") + Dim DiferenciaIVas As Decimal = IVA - IVADetalles + + + If Not TmpDT.Columns.Contains("AplicaIEPS") Then + TmpDT.Columns.Add(New DataColumn("AplicaIEPS", GetType(Boolean))) + End If + + If Not TmpDT.Columns.Contains("IEPSGrabaIVA") Then + TmpDT.Columns.Add(New DataColumn("IEPSGrabaIVA", GetType(Boolean))) + End If + + For Each dRow As DataRow In TmpDT.Rows + Dim DttPS As DataTable = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=dRow("CvePS").ToString.ToEntero) + If DttPS IsNot Nothing AndAlso DttPS.Rows.Count > 0 Then + Dim DrPS As DataRow = DttPS.Rows(0) + dRow("AplicaIEPS") = Boolean.Parse(DrPS("AplicaIEPS").ToString) + dRow("IEPSGrabaIVA") = Boolean.Parse(DrPS("IEPSGrabaIVA").ToString) + Else + dRow("AplicaIEPS") = False + dRow("IEPSGrabaIVA") = False + End If + Next + + Dim DTConsulta As New DataTable + DTConsulta = TmpDT.FiltraParametros(" AplicaIEPS = 'True' AND IEPSGrabaIVA = 'False' AND IVA > 0 ") + + If DTConsulta.Rows.Count > 0 Then + + Dim IndiceContador As Integer = 0 + Dim IndiceUltimo As Integer = 0 + Dim CantidadRegistroConIVA As Decimal + + For Each dRow As DataRow In TmpDT.Rows + If Boolean.Parse(dRow("AplicaIEPS").ToString) And Boolean.Parse(dRow("IEPSGrabaIVA").ToString) = False And dRow("IVA").ToString.ToDecimal > 0 Then + IndiceUltimo = IndiceContador + CantidadRegistroConIVA = CantidadRegistroConIVA + 1 + End If + IndiceContador = IndiceContador + 1 + Next + + IVADetalles = TmpDT.SUMD("IVA", " IVA > 0 ") + DiferenciaIVas = IVA - IVADetalles + + If Math.Abs(DiferenciaIVas) > 0.01D Then + + If (TmpDT.Rows(IndiceUltimo)("IVA").ToString.ToDecimal + DiferenciaIVas) < 0 Then + + Dim AjusteteDividido As Decimal = Math.Abs(DiferenciaIVas) / CantidadRegistroConIVA + + For Each dRow As DataRow In TmpDT.Rows + If Boolean.Parse(dRow("AplicaIEPS").ToString) And Boolean.Parse(dRow("IEPSGrabaIVA").ToString) = False And dRow("IVA").ToString.ToDecimal > 0 Then + dRow("IVA") = dRow("IVA").ToString.ToDecimal - AjusteteDividido + End If + Next + Else + TmpDT.Rows(IndiceUltimo)("IVA") = TmpDT.Rows(IndiceUltimo)("IVA").ToString.ToDecimal + DiferenciaIVas + End If + TmpDT.AcceptChanges() + End If + + End If + + 'Revalidacion de ajuste + IVADetalles = TmpDT.SUMD("IVA", " IVA > 0 ") + DiferenciaIVas = IVA - IVADetalles + + If Math.Abs(DiferenciaIVas) > 0.01D Then + Respuesta = False + If IVADetalles > 0 Then + + For Each dRow As DataRow In TmpDT.Rows + If dRow("IVA").ToString.ToDecimal > 0 Then + dRow("IVA") = dRow("IVA").ToString.ToDecimal + DiferenciaIVas + TmpDT.AcceptChanges() + Respuesta = True + Exit For + End If + Next + Else + Alert("Los productos especificados en el listado no tienen asignado impuesto IVA, favor de realizar la corrección en el producto que aplique el impuesto.", TipoMensaje.MsgAdvertencia) + Respuesta = False + End If + Else + Respuesta = True + End If + + If Respuesta Then + + Dim IEPSPSDetalles As Decimal = TmpDT.SUMD("IEPSPS", " IEPSPS > 0 ") + Dim DiferenciaIEPSPS As Decimal = IEPS - IEPSPSDetalles + + Dim DTConsultaIEPSPS As New DataTable + DTConsultaIEPSPS = TmpDT.FiltraParametros(" AplicaIEPS = 'True'") + Dim IndiceContador As Integer = 0 + Dim IndicePrimero As Integer = 0 + + For Each dRow As DataRow In TmpDT.Rows + If Boolean.Parse(dRow("AplicaIEPS").ToString) And dRow("IEPSPS").ToString.ToDecimal > 0 Then + IndicePrimero = IndiceContador + Exit For + End If + IndiceContador = IndiceContador + 1 + Next + If DiferenciaIEPSPS.RoundSQL(2) <> 0 Then + + TmpDT.Rows(IndicePrimero)("IEPSPS") = TmpDT.Rows(IndicePrimero)("IEPSPS").ToString.ToDecimal + DiferenciaIEPSPS + TmpDT.AcceptChanges() + End If + + For Each dRow As DataRow In TmpDT.Rows + If dRow("IEPSPSPorcentaje").ToString.ToDecimal > 0 AndAlso dRow("IEPSPS").ToString.ToDecimal = 0 Then + dRow("IEPSPSPorcentaje") = 0 + End If + Next + TmpDT.AcceptChanges() + End If + + Return Respuesta + + End Function + + + Private Function AjustaIVA() As Boolean + + Dim Respuesta As Boolean = False + + Dim IVADetalles As Decimal = TmpDT.SUMD("IVA", " IVA > 0 ") + Dim DiferenciaIVas As Decimal = IVA - IVADetalles + + If Math.Abs(DiferenciaIVas) > 0 Then + If Math.Abs(DiferenciaIVas) <= 0.05 Then + + Dim DTConsulta As New DataTable + DTConsulta = TmpDT.FiltraParametros(" IVA > 0 ") + + If DTConsulta.Rows.Count > 0 Then + + Dim IndiceContador As Integer = 0 + Dim IndiceUltimo As Integer = 0 + Dim CantidadRegistroConIVA As Decimal + + For Each dRow As DataRow In TmpDT.Rows + If dRow("IVA").ToString.ToDecimal > 0 Then + IndiceUltimo = IndiceContador + CantidadRegistroConIVA = CantidadRegistroConIVA + 1 + End If + IndiceContador = IndiceContador + 1 + Next + + IVADetalles = TmpDT.SUMD("IVA", " IVA > 0 ") + DiferenciaIVas = IVA - IVADetalles + + If Math.Abs(DiferenciaIVas) > 0.0D Then + + If (TmpDT.Rows(IndiceUltimo)("IVA").ToString.ToDecimal + DiferenciaIVas) < 0 Then + + Dim AjusteteDividido As Decimal = Math.Abs(DiferenciaIVas) / CantidadRegistroConIVA + + For Each dRow As DataRow In TmpDT.Rows + dRow("IVA") = dRow("IVA").ToString.ToDecimal - AjusteteDividido + Next + Else + TmpDT.Rows(IndiceUltimo)("IVA") = TmpDT.Rows(IndiceUltimo)("IVA").ToString.ToDecimal + DiferenciaIVas + End If + TmpDT.AcceptChanges() + End If + End If + + 'Revalidacion de ajuste + IVADetalles = TmpDT.SUMD("IVA", " IVA > 0 ") + DiferenciaIVas = IVA - IVADetalles + + If Math.Abs(DiferenciaIVas) > 0.01D Then + Respuesta = False + If IVADetalles > 0 Then + + For Each dRow As DataRow In TmpDT.Rows + If dRow("IVA").ToString.ToDecimal > 0 Then + dRow("IVA") = dRow("IVA").ToString.ToDecimal + DiferenciaIVas + TmpDT.AcceptChanges() + Respuesta = True + Exit For + End If + Next + + Else + Errores.AppendLine("Los productos especificados en el listado no tienen asignado impuesto IVA, favor de realizar la corrección en el producto que aplique el impuesto.") + Respuesta = False + End If + Else + Respuesta = True + End If + + Else + Errores.AppendLine($"existe una diferencia de {DiferenciaIVas} entre el IVA de la compra y los detalles.") + Respuesta = False + End If + Else + Respuesta = True + End If + + Return Respuesta + + End Function + + Private Function AjustaRetIVA() As Boolean + + Dim Respuesta As Boolean = False + + Dim RetIVADetalles As Decimal = TmpDT.SUMD("RetIVA", " RetIVA > 0 ") + Dim DiferenciaRetIVA As Decimal = RetIVA - RetIVADetalles + + If Math.Abs(DiferenciaRetIVA) > 0 Then + If Math.Abs(DiferenciaRetIVA) <= 0.05 Then + + Dim DTConsulta As New DataTable + DTConsulta = TmpDT.FiltraParametros(" RetIVA > 0 ") + + If DTConsulta.Rows.Count > 0 Then + + Dim IndiceContador As Integer = 0 + Dim IndiceUltimo As Integer = 0 + Dim CantidadRegistroConRetIVA As Decimal + + For Each dRow As DataRow In TmpDT.Rows + If dRow("RetIVA").ToString.ToDecimal > 0 Then + IndiceUltimo = IndiceContador + CantidadRegistroConRetIVA = CantidadRegistroConRetIVA + 1 + End If + IndiceContador = IndiceContador + 1 + Next + + RetIVADetalles = TmpDT.SUMD("RetIVA", " RetIVA > 0 ") + DiferenciaRetIVA = RetIVA - RetIVADetalles + + If Math.Abs(DiferenciaRetIVA) > 0.0D Then + + If (TmpDT.Rows(IndiceUltimo)("RetIVA").ToString.ToDecimal + DiferenciaRetIVA) < 0 Then + + Dim AjusteteDividido As Decimal = Math.Abs(DiferenciaRetIVA) / CantidadRegistroConRetIVA + + For Each dRow As DataRow In TmpDT.Rows + dRow("RetIVA") = dRow("RetIVA").ToString.ToDecimal - AjusteteDividido + Next + + Else + TmpDT.Rows(IndiceUltimo)("RetIVA") = TmpDT.Rows(IndiceUltimo)("RetIVA").ToString.ToDecimal + DiferenciaRetIVA + End If + + TmpDT.AcceptChanges() + + End If + + End If + + 'Revalidacion de ajuste + RetIVADetalles = TmpDT.SUMD("RetIVA", " RetIVA > 0 ") + DiferenciaRetIVA = RetIVA - RetIVADetalles + + If Math.Abs(DiferenciaRetIVA) > 0.01D Then + Respuesta = False + If RetIVADetalles > 0 Then + + For Each dRow As DataRow In TmpDT.Rows + If dRow("RetIVA").ToString.ToDecimal > 0 Then + dRow("RetIVA") = dRow("RetIVA").ToString.ToDecimal + DiferenciaRetIVA + TmpDT.AcceptChanges() + Respuesta = True + Exit For + End If + Next + + Else + Errores.AppendLine("Los productos especificados en el listado no tienen asignado impuesto RetIVA, favor de realizar la corrección en el producto que aplique el impuesto.") + Respuesta = False + End If + Else + Respuesta = True + End If + + Else + Errores.AppendLine($"existe una diferencia de {DiferenciaRetIVA} entre el RetIVA de la compra y los detalles.") + End If + Else + Respuesta = True + + End If + + Return Respuesta + + End Function + + Private Function AjustaRetISR() As Boolean + + Dim Respuesta As Boolean = False + + Dim RetISRDetalles As Decimal = TmpDT.SUMD("RetISR", " RetISR > 0 ") + Dim DiferenciaRetISR As Decimal = RetISR - RetISRDetalles + + If Math.Abs(DiferenciaRetISR) > 0 Then + If Math.Abs(DiferenciaRetISR) <= 0.05 Then + + Dim DTConsulta As New DataTable + DTConsulta = TmpDT.FiltraParametros(" RetISR > 0 ") + + If DTConsulta.Rows.Count > 0 Then + + Dim IndiceContador As Integer = 0 + Dim IndiceUltimo As Integer = 0 + Dim CantidadRegistroConRetISR As Decimal + + For Each dRow As DataRow In TmpDT.Rows + If dRow("RetISR").ToString.ToDecimal > 0 Then + IndiceUltimo = IndiceContador + CantidadRegistroConRetISR = CantidadRegistroConRetISR + 1 + End If + IndiceContador = IndiceContador + 1 + Next + + RetISRDetalles = TmpDT.SUMD("RetISR", " RetISR > 0 ") + DiferenciaRetISR = RetISR - RetISRDetalles + + If Math.Abs(DiferenciaRetISR) > 0.0D Then + + If (TmpDT.Rows(IndiceUltimo)("RetISR").ToString.ToDecimal + DiferenciaRetISR) < 0 Then + + Dim AjusteteDividido As Decimal = Math.Abs(DiferenciaRetISR) / CantidadRegistroConRetISR + + For Each dRow As DataRow In TmpDT.Rows + dRow("RetISR") = dRow("RetISR").ToString.ToDecimal - AjusteteDividido + Next + + Else + TmpDT.Rows(IndiceUltimo)("RetISR") = TmpDT.Rows(IndiceUltimo)("RetISR").ToString.ToDecimal + DiferenciaRetISR + End If + + TmpDT.AcceptChanges() + + End If + + End If + + 'Revalidacion de ajuste + RetISRDetalles = TmpDT.SUMD("RetISR", " RetISR > 0 ") + DiferenciaRetISR = RetISR - RetISRDetalles + + If Math.Abs(DiferenciaRetISR) > 0.01D Then + Respuesta = False + If RetISRDetalles > 0 Then + + For Each dRow As DataRow In TmpDT.Rows + If dRow("RetISR").ToString.ToDecimal > 0 Then + dRow("RetISR") = dRow("RetISR").ToString.ToDecimal + DiferenciaRetISR + TmpDT.AcceptChanges() + Respuesta = True + Exit For + End If + Next + + Else + Errores.AppendLine("Los productos especificados en el listado no tienen asignado impuesto RetISR, favor de realizar la corrección en el producto que aplique el impuesto.") + Respuesta = False + End If + Else + Respuesta = True + End If + + Else + Errores.AppendLine($"existe una diferencia de {DiferenciaRetISR} entre el RetISR de la compra y los detalles.") + Respuesta = False + End If + Else + Respuesta = True + End If + + Return Respuesta + + End Function + + Private Function AgregaIEPSReembolso(CvePS As Integer) As Boolean + + Dim respuesta As Boolean = True + + If IEPSGasto Or OtrosImpuestosGasto Then + + 'AGREGA IEPS COMO CONCEPTO + If IEPSGasto Then + AgregarConceptoIEPS(TrasladoIEPS, CvePS) + For Each Dr As DataRow In TmpDT.Rows + Dr("IEPSPS") = 0 + Dr("IEPSPSPorcentaje") = 0 + Next + TmpDT.AcceptChanges() + End If + 'AGREGA OTROS IMPUESTOS COMO CONCEPTO + If OtrosImpuestosGasto Then + AgregarConceptoIEPS(OtrosImpuestos, CvePS) + End If + Else + respuesta = False + Errores.AppendLine("Debe seleccionar al menos un impuesto. ") + End If + CalculaTotales() + + Return respuesta + + End Function + + + Private Sub AgregarConceptoIEPS(IEPS As Decimal, CvePS1 As Integer) + Dim SubTotalR As Decimal = TmpDT.SUM("Total").ToString.ToDecimal + + Dim PSS As DataTable = GlobalDTPS(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CvePS = {0} ", CvePS1), "PS") + Dim PSS2 As DataTable = TmpDT.FiltraParametros(String.Format("CvePS = {0} ", CvePS1), "PS") + + If PSS.Rows.Count > 0 Or PSS2.Rows.Count > 0 Then + Dim CveUM As Integer = 0 + Dim UM As String = "" + Dim CveClasificacion As Integer = 0 + Dim Clasificacion As String = "" + Dim CvePS As Integer = 0 + Dim PS As String = "" + Dim CveTipoPS As Integer = 0 + + If PSS.Rows.Count > 0 Then + CveUM = PSS.Rows(0)("CveUM").ToString.ToEntero + UM = PSS.Rows(0)("UnidadMedida").ToString + CveClasificacion = PSS.Rows(0)("CveClasificacion").ToString.ToEntero + Clasificacion = PSS.Rows(0)("Clasificacion").ToString + CvePS = PSS.Rows(0)("CvePS").ToString.ToEntero + PS = PSS.Rows(0)("PS").ToString + CveTipoPS = PSS.Rows(0)("CveTipoPS").ToString.ToEntero + End If + + Dim Cantidad As Decimal = 1 + Dim CveSubProyectoContrato As String = "-1" + Dim CveProyecto As String = "-1" + Dim SubProyecto As String = "SE" + Dim Proyecto As String = "SE" + Dim Obs As String = "" + Dim PU As Decimal = IEPS + Dim Total As Decimal = Cantidad * PU + Dim IVA As Decimal = 0 + Dim Descuento As Decimal = 0 + + If PSS2.Rows.Count > 0 Then + CveUM = PSS2.Rows(0)("CveUM").ToString.ToEntero + UM = PSS2.Rows(0)("UM").ToString + CveClasificacion = PSS2.Rows(0)("CveClasificacion").ToString.ToEntero + Clasificacion = PSS2.Rows(0)("Clasificacion").ToString + CvePS = PSS2.Rows(0)("CvePS").ToString.ToEntero + PS = PSS2.Rows(0)("PS").ToString + CveTipoPS = PSS2.Rows(0)("CveTipoPS").ToString.ToEntero + + CveSubProyectoContrato = PSS2.Rows(0)("CveSubProyecto").ToString + CveProyecto = PSS2.Rows(0)("CveProyecto").ToString + SubProyecto = PSS2.Rows(0)("SubProyecto").ToString + Proyecto = PSS2.Rows(0)("Proyecto").ToString + Obs = PSS2.Rows(0)("Obs").ToString + + Dim CveTipoGasto As Integer = PSS2.Rows(0)("CveTipoGasto").ToString.ToEntero + Dim TipoGasto As String = PSS2.Rows(0)("TipoGasto").ToString + + AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, 0, 0, 0, 0, Descuento, TCalculaTotales:=False, CveTipoGasto:=CveTipoGasto, + TipoGasto:=TipoGasto, ModalidadAccionPS:=EnumModalidadAccionPS.Agregar) + + Else + AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, 0, 0, 0, 0, Descuento, TCalculaTotales:=False) + End If + End If + + Dim SubTotalIEPS As Decimal = TmpDT.SUMD("Total") + + Me.SubTotal = Math.Round(SubTotalIEPS, 2) + Me.SubTotalConceptos = Math.Round(SubTotalIEPS, 2) + + PSS.Dispose() + End Sub + + Private Function AddPS(Cantidad As Decimal, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, CvePS As Integer, PS As String, CveTipoPS As Integer, CveSubProyectoContrato As String, SubProyecto As String, Proyecto As String, CveProyecto As String, + Obs As String, PU As Decimal, Total As Decimal, IVA As Decimal, RetIVA As Decimal, RetISR As Decimal, IEPSPS As Decimal, IEPSPSIVA As Decimal, Descuento As Decimal, Optional CveOrdenCompraDetalle As Integer = -1, Optional TCalculaTotales As Boolean = True, + Optional PSCodigo As String = "-", Optional PSDescripcion As String = "-", Optional CantidadF As Double = -1, Optional EntregaDirecta As Integer = -1, Optional OtrosGastos As Decimal = 0, + Optional CveSATPS As Integer = -1, Optional CargaXml As Boolean = False, Optional CveTipoGasto As Integer = -1, Optional TipoGasto As String = "", Optional PorcentajeIVA As Decimal = 0, + Optional PorcentajeIEPS As Decimal = 0, Optional PorcentajeRetIVA As Decimal = 0, Optional PorcentajeRetISR As Decimal = 0, Optional NoDeducible As Boolean = False, Optional CveContratoDetalle As Integer = -1, Optional CveCultivoCuadroDetalle As Integer = -1, + Optional CveSATPSActualizado As Boolean = False, Optional TemporadaCuadro As String = "", Optional ModalidadAccionPS As EnumModalidadAccionPS = EnumModalidadAccionPS.Agregar, Optional Con As Integer = -1, + Optional CveProgramaOperativo As Integer = -1, Optional CveUnidadAdministrativa As Integer = -1, Optional CveFuenteFinanciamiento As Integer = -1, Optional CveTipoGastoAC As Integer = -1, Optional CveClasificacionOG As Integer = -1) As Integer + + Dim Row As DataRow = Nothing + + Row = TmpDT.NewRow() + Dim Retorno As Integer = 0 + Dim CveContrato As Integer = -1 + Dim CveSubProyecto As Integer = -1 + Dim Valores As String() + + ''CONTRATOS + If CveSubProyectoContrato.Contains("|"c) Then + Valores = CveSubProyectoContrato.Split("|"c) + CveContrato = Valores(1).ToEntero + CveSubProyecto = Valores(0).ToEntero + Else + CveSubProyecto = CveSubProyectoContrato.ToEntero + End If + + 'DR PS + Dim DrPS As DataRow = Nothing + If CvePS > 0 Then + DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).Rows(0) + End If + + If DrPS IsNot Nothing Then + Row("PSCodigo") = If(PSCodigo = "", DrPS("PSCodigo").ToString, PSCodigo) + Row("CveMetodoInventario") = DrPS("Inv_CveMetodoInventario").ToString.ToEntero + + If CveTipoCompra = EnumTipoCompra.Garantia AndAlso DrPS("AplicaSerie").ToString = "True" Then + Row("CveMetodoInventario") = "1" + End If + + Else + Row("PSCodigo") = PSCodigo + Row("CveMetodoInventario") = 0 + End If + + If ModalidadAccionPS = EnumModalidadAccionPS.Actualizar Then + Row("Consec") = Con + Else + Row("Consec") = TmpDT.Rows.Count + 1 + End If + + If (CFDIVersion = EnumCFDIVersion.V33 Or CFDIVersion = EnumCFDIVersion.V40) And CveSATPS > 0 Then + Dim DrPSSAT As DataRow = Nothing + If CargaXml Then + DrPSSAT = GlobalDTPSATPS("-1", CveSATPS.ToString).FiltroPrimero("") + Else + DrPSSAT = GlobalDTPSATPS("-1", CveSATPS.ToString).FiltroPrimero("") + End If + If DrPSSAT IsNot Nothing Then + Row("SATClaveProductoServicio") = DrPSSAT("SATClaveProductoServicio").ToString + Row("CveSATPS") = DrPSSAT("CveSATPS").ToString + If CveSATPSActualizado Then + Row("CveSATPSActualizado") = 1 + Else + Row("CveSATPSActualizado") = 0 + End If + End If + End If + + Try + If (DrPS("CvePSCargo").ToString <> "") Then 'si es un producto de usado. que se registre contablemente como alamcen(como producto) + CveTipoPS = 2 + End If + Catch ex As Exception + + End Try + + Dim DecimalesPermitidos As Integer = 6 + + Row("CveConcepto") = TmpDT.Rows.Count + 1 + Row("Cantidad") = Math.Round(Cantidad, DecimalesPermitidos) + Row("CantidadF") = If(CantidadF = -1, Math.Round(Cantidad, DecimalesPermitidos), Math.Round(CantidadF, DecimalesPermitidos)) + Row("CveUM") = CveUM + Row("UM") = UM + Row("CveClasificacion") = CveClasificacion + Row("CveClasificacionActualizar") = CveClasificacion + Row("Clasificacion") = Clasificacion + Row("CvePS") = CvePS + Row("PS") = PS + Row("CveTipoPS") = CveTipoPS + + Row("PSDescripcion") = PSDescripcion + Row("CveSubProyecto") = CveSubProyecto.ToEntero + Row("CveProyecto") = CveProyecto.ToEntero + Row("CveContrato") = CveContrato.ToEntero + Row("SubProyecto") = If(SubProyecto = "Seleccione", "Sin Sub Proyecto", SubProyecto) + Row("Proyecto") = If(Proyecto = "Seleccione", "Sin Proyecto", Proyecto) + Row("CveActivoFijo") = -1 + Row("Obs") = Obs + Row("CveActivoFijo") = -1 + Row("CodAF") = "-1" + Row("TipoAF") = -1 + Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle + Row("EntregaDirecta") = EntregaDirecta + + Row("NoDeducible") = NoDeducible + + + Total = Math.Round(PU, DecimalesPermitidos) * Cantidad - Descuento + Row("PU") = Math.Round(PU, DecimalesPermitidos) + If CargaXml And (CFDIVersion = EnumCFDIVersion.V33 Or CFDIVersion = EnumCFDIVersion.V40) Then + + If CveFactura > 0 And IVA = 0 Then + Row("IVA") = 0 + Row("IVAPorcentaje") = 0 + Else + Row("IVA") = Math.Round(IVA, DecimalesPermitidos) + Row("IVAPorcentaje") = PorcentajeIVA + End If + + Row("RetIVA") = Math.Round(RetIVA, DecimalesPermitidos) + Row("RetIVAPorcentaje") = PorcentajeRetIVA + Row("RetISR") = Math.Round(RetISR, DecimalesPermitidos) + Row("RetISRPorcentaje") = PorcentajeRetISR + Row("IEPSPS") = Math.Round(IEPSPS, DecimalesPermitidos) + Row("IEPSPSPorcentaje") = PorcentajeIEPS + Else + 'If DdlIVA.SelectedValue.ToDouble = 0 Then Row("IVA") = 0 Else Row("IVA") = Math.Round(IVA * Total, DecimalesPermitidos) + + If CveFactura > 0 And IVA = 0 Then + Row("IVA") = 0 + Row("IVAPorcentaje") = 0 + Else + Row("IVA") = (IVA * Total).RoundSQL + Row("IVAPorcentaje") = IVA + End If + + Row("RetIVA") = (RetIVA * Total).RoundSQL + Row("RetIVAPorcentaje") = RetIVA + Row("RetISR") = (RetISR * Total).RoundSQL + Row("RetISRPorcentaje") = RetISR + Row("IEPSPS") = (IEPSPS * Total).RoundSQL + Row("IEPSPSPorcentaje") = IEPSPS + End If + + Row("ImporteConImpuestos") = (Row("Cantidad").ToString.ToDecimal * Row("PU").ToString.ToDecimal) + Row("IVA").ToString.ToDecimal + Row("IEPSPS").ToString.ToDecimal - (Row("RetIVA").ToString.ToDecimal + Row("RetISR").ToString.ToDecimal) + Row("ImporteSinImpuestos") = Row("Cantidad").ToString.ToDecimal * Row("PU").ToString.ToDecimal + + Row("IEPSPSIVA") = Math.Round(IEPSPSIVA * Total, DecimalesPermitidos) + Row("IEPSPSIVAPorcentaje") = IEPSPSIVA + Row("Descuento") = Math.Round(Descuento, DecimalesPermitidos) + Row("OtrosGastos") = Math.Round(OtrosGastos, DecimalesPermitidos) + Row("Total") = Math.Round(Total, DecimalesPermitidos) + + Row("CveTipoGasto") = CveTipoGasto + Row("TipoGasto") = If(CveTipoGasto > 0, TipoGasto, "") + + Row("CveContratoDetalle") = CveContratoDetalle + + Row("CveCultivoCuadroDetalle") = CveCultivoCuadroDetalle + Row("TemporadaCuadro") = TemporadaCuadro + + If UsuarioActual.Empresa.UsaAC Then + Row("CveProgramaOperativo") = CveProgramaOperativo + Row("CveUnidadAdministrativa") = CveUnidadAdministrativa + Row("CveFuenteFinanciamiento") = CveFuenteFinanciamiento + Row("CveTipoGastoAC") = CveTipoGastoAC + Row("CveClasificacionOG") = CveClasificacionOG + End If + 'Esta parte es para validar cuando la factura tenga ieps en o se asignara el ieps como una partida ya no se considere + If (CveFactura > 0 Or CveCompra > 0) And IEPS = 0 Then + Row("IEPSPS") = 0 + Row("IEPSPSPorcentaje") = 0 + End If + TmpDT.Rows.Add(Row) + TmpDT.Rows.IndexOf(Row) + + If TCalculaTotales Then + CalculaTotales(True) + End If + + Return Retorno + End Function + + Private Sub CalculaTotales(Optional CalculaIVA As Boolean = False, Optional EsNoDeducible As Boolean = False) + 'VARIABLES DE CALCULO + Dim LocalSubTotal, LocalDescuentos, LocalAmortizacion, LocalIVA, LocalSubTotal2, LocalRetIVA, LocalRetISR, LocalIEPSPS, LocalTotal, LocalSubTotalIVA, LocalSubTotalIEPSIVA As Decimal + + 'HACEMOS CALCULOS + LocalSubTotalIVA = TmpDT.SUMD("IVA") + LocalSubTotalIEPSIVA = TmpDT.SUMD("IEPSPSIVA") + LocalSubTotal = (TmpDT.SUMD("Total") + TmpDT.SUMD("Descuento")).RoundSQL(8) + LocalRetIVA = TmpDT.SUMD("RetIVA") + LocalRetISR = TmpDT.SUMD("RetISR") + LocalIEPSPS = TmpDT.SUMD("IEPSPS") + + If CveCompra > 0 AndAlso CveFactura > 0 Then + LocalIVA = IVA + Else + LocalIVA = If(TmpDT.SUM("IVA") > 0, LocalSubTotalIVA + LocalSubTotalIEPSIVA, 0) + End If + + LocalDescuentos = TmpDT.SUMD("Descuento") + + If Not CveCompra > 0 Then + LocalAmortizacion = Me.Amortizacion + End If + + 'RETENCIONES + Dim Retenciones As Decimal = 0 + Retenciones = LocalRetIVA + Retenciones += LocalRetISR + + + LocalSubTotal2 = LocalSubTotal - LocalDescuentos + LocalTotal = LocalSubTotal2 + LocalIVA + LocalIEPSPS - Retenciones + + 'ASIGNAMOS VALORES A VISTA + If CveCompra > 0 Or CveFactura > 0 Or Me.OCVinculada Then + SubTotal = LocalSubTotal + SubTotal2 = LocalSubTotal2 + Descuento = LocalDescuentos + + If EsNoDeducible Then + IVA = LocalIVA + RetIVA = LocalRetIVA + RetISR = LocalRetISR + IEPS = LocalIEPSPS + End If + + Total = LocalTotal + Else + SubTotal = LocalSubTotal + SubTotal2 = LocalSubTotal2 + IVA = LocalIVA + Descuento = LocalDescuentos + RetIVA = LocalRetIVA + RetISR = LocalRetISR + IEPS = LocalIEPSPS + Total = LocalTotal + 'VALORES PROPIEDAD + CompraSaldo = LocalTotal + + End If + Me.NumNoDed = TmpDT.COUNT("CvePS", "NoDeducible = True ") + + End Sub + + Private Function UpdatePSReembolso(Index As Integer, CvePS As Integer) As Boolean + + Dim Respuesta As Boolean = True + + Dim DrPS As DataRow = Nothing + Try + DrPS = TmpDT.Select($"Consec = {Index}")(0) + If DrPS Is Nothing Then + Errores.AppendLine($"No se encontrol el producto con index {Index}") + Return False + End If + Catch ex As Exception + Errores.AppendLine($"No se encontrol el producto con index {Index}") + Return False + End Try + + 'DATOS GENERALES + DrPS("Obs") = "" + DrPS("Proyecto") = Proyecto + DrPS("CveProyecto") = CveProyecto + DrPS("SubProyecto") = SubProyecto + DrPS("CveSubProyecto") = CveSubProyecto + DrPS("CveContratoDetalle") = -1 + + 'IMPORTES - [CANTIDAD Y PRECIO] + Dim Cantidad As Double = DrPS("Cantidad").ToString.ToDouble + Dim PU As Double = DrPS("PU").ToString.ToDouble + Dim Descuento As Double = DrPS("Descuento").ToString.ToDouble + Dim Total As Double = (Cantidad * PU) - Descuento + DrPS("NoDeducible") = NoDeducible + + Dim PSRow As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") + If PSRow IsNot Nothing Then + Dim CveTipoPS As Integer = PSRow("CveTipoPS").ToString.ToEntero + If PSRow("CvePSCargo").ToString <> "" Then 'si es un producto de usado. que se registre contablemente como alamcen(como producto) + CveTipoPS = 2 + End If + + DrPS("CveClasificacion") = PSRow("CveClasificacion").ToString + DrPS("Clasificacion") = PSRow("Clasificacion").ToString + DrPS("CvePS") = CvePS + DrPS("PS") = PSRow("PS").ToString + DrPS("CveTipoPS") = CveTipoPS + DrPS("CveSATPS") = PSRow("CveSATPS").ToString.ToEntero + DrPS("SATClaveProductoServicio") = PSRow("SATClaveProductoServicio").ToString + DrPS("CveSATPSActualizado") = 0 + + DrPS("CveUM") = PSRow("CveUnidadMedida").ToString.ToEntero + DrPS("UM") = PSRow("UnidadMedida").ToString + + Dim DrTipoGasto As DataRow = Me.DTTiposGastos.FiltroPrimero("") + + DrPS("CveTipoGasto") = DrTipoGasto("CveTipoGasto") + DrPS("TipoGasto") = DrTipoGasto("TipoGasto") + + If UsuarioActual.Empresa.Funcionalidad(562).ToEntero > 0 Then + DrPS("AplicaCostoIndirecto") = "0" + End If + + DrPS("CveCultivoCuadroDetalle") = -1 + DrPS("TemporadaCuadro") = "" + + Else + Errores.AppendLine($"No se encontrol el producto con CvePS {CvePS}") + Respuesta = False + End If + TmpDT.AcceptChanges() + Return Respuesta + End Function + + Private Sub ValidacionesTotalesXml() + + If Not TmpDT.Columns.Contains("Amortizacion") Then + TmpDT.Columns.Add("Amortizacion", GetType(Decimal)) + End If + + Dim Msg As String = "" + Dim SubtotalTemp As Decimal = TmpDT.SUMD("Total") + Math.Round(TmpDT.SUM("Descuento") + Math.Round(TmpDT.SUM("Amortizacion")), 2) + Dim DescuentosTemp As Decimal = TmpDT.SUMD("Descuento") + Dim Subtotal2Temp As Decimal = TmpDT.SUMD("Total") + Dim IVATemp As Decimal = TmpDT.SUMD("IVA") + Dim IEPSTemp As Decimal = TmpDT.SUMD("IEPSPS") + Dim RetIVATemp As Decimal = TmpDT.SUMD("RetIVA") + Dim RetISRTemp As Decimal = TmpDT.SUMD("RetISR") + Dim TotalTemp As Decimal = Subtotal2Temp - RetIVATemp - RetISRTemp + Math.Round(IVATemp, 6) + IEPSTemp + OtrosImpuestos - OtrosImpuestosRetenciones + + If Math.Abs(Math.Round(DescuentosTemp, 6) - Math.Round(Descuento, 6)) > 0.01 Then + Msg &= String.Format("- Los descuentos del detalle no coinciden con el descuento general
    ") + End If + + If Math.Abs(Math.Round(IVATemp, 6) - Math.Round(TrasladoIVA, 6)) > 0.01 Then + Msg &= String.Format("- Los IVAS del detalle no coinciden con el IVA general
    ") + End If + + If Math.Abs(Math.Round(IEPSTemp, 6) - Math.Round(TrasladoIEPS, 6)) > 0.01 Then + Msg &= String.Format("- Los IEPS del detalle no coinciden con el IEPS general
    ") + End If + + If Math.Abs(Math.Round(RetIVATemp, 6) - Math.Round(RetencionIVA, 6)) > 0.01 Then + Msg &= String.Format("- Los RetIVA del detalle no coinciden con el RetIVA general
    ") + End If + + If Math.Abs(Math.Round(RetISRTemp, 6) - Math.Round(RetencionISR, 6)) > 0.01 Then + Msg &= String.Format("- Las RetISR del detalle no coinciden con el RetIVA general
    ") + End If + + If Math.Abs(Math.Round(TotalTemp, 2) - Math.Round(Total, 2)) > 0.01 Then + Msg &= String.Format("- El total generado por los detalles no coincide con el total general
    ({0}-{1})", Math.Round(TotalTemp, 2), Math.Round(Total, 2)) + End If + + If Msg <> "" Then + Errores.AppendLine($" El comprobante XML presenta las siguientes inconsistencias:{Msg}. ") + Else + + DescuentosTemp = Descuento + IVATemp = TrasladoIVA + TotalTemp = Total + RetIVATemp = RetencionIVA + RetISRTemp = RetencionISR + IEPSTemp = TrasladoIEPS + End If + + Me.SubTotal = SubtotalTemp + Me.Descuento = DescuentosTemp + Me.SubTotal2 = Subtotal2Temp + Me.IVA = IVATemp + Me.Total = TotalTemp + Me.RetIVA = RetIVATemp + Me.RetISR = RetISRTemp + Me.IEPS = IEPSTemp + CompraSaldo = TotalTemp + + AsignaValoresOriginales(SubtotalTemp, Subtotal2Temp, IVATemp, RetIVATemp, RetISRTemp, Total) + + End Sub + + Private Sub AsignaValoresOriginales(SubTotal As Decimal, SubTotal2 As Double, IVA As Decimal, RetIVA As Decimal, RetISR As Decimal, Total As Decimal) + SubTotalOriginal = SubTotal + SubTotal2Original = SubTotal2 + IVAOriginal = IVA + RetIVAOriginal = RetIVA + RetISROriginal = RetISR + TotalOriginal = Total + End Sub + + Private Sub AjustaImporteUltimoConcepto(ImporteAjuste As Decimal, Optional EsCarga As Boolean = False) + + If ImporteAjuste = 0 Then Exit Sub + + Dim Amortizacion As Decimal = 0 + + If TmpDT.Rows.Count > 0 Then ' si hay movimientos y si esta afectando al total, que se haga el ajuste + Dim Indice As Integer = If(TmpDT.Rows(TmpDT.Rows.Count - 1)("CvePS").ToString = UsuarioActual.Empresa.Funcionalidad(112).ToString, TmpDT.Rows.Count - 2, TmpDT.Rows.Count - 1) + Dim tPU As Decimal + + If TmpDT.Rows(Indice)("Cantidad").ToString.ToDecimal > 0 Then + tPU = ImporteAjuste / TmpDT.Rows(Indice)("Cantidad").ToString.ToDecimal + Else + tPU = 0 + End If + + If TmpDT.Rows(Indice)("PU").ToString.ToDecimal + tPU < 0 Then 'si es negativo, que tome el dato anterior + Indice = Indice - 1 + If TmpDT.Rows(Indice)("Cantidad").ToString.ToDecimal > 0 Then + tPU = ImporteAjuste / TmpDT.Rows(Indice)("Cantidad").ToString.ToDecimal + Else + tPU = 0 + End If + End If + + TmpDT.Rows(Indice)("PU") = TmpDT.Rows(Indice)("PU").ToString.ToDecimal + tPU + TmpDT.Rows(Indice)("Total") = TmpDT.Rows(Indice)("Total").ToString.ToDecimal + ImporteAjuste + TmpDT.Rows(Indice)("IEPSPS") = (TmpDT.Rows(Indice)("Total").ToString.ToDecimal() * TmpDT.Rows(Indice)("IEPSPSPorcentaje").ToString.ToDecimal()).RoundAD(2) + TmpDT.Rows(Indice)("IVA") = (TmpDT.Rows(Indice)("PU").ToString.ToDecimal * TmpDT.Rows(Indice)("Cantidad").ToString.ToDecimal - TmpDT.Rows(Indice)("Descuento").ToString.ToDecimal) * TmpDT.Rows(Indice)("IVAPorcentaje").ToString.ToDecimal + TmpDT.AcceptChanges() + End If + + SubTotal = TmpDT.SUMD("Total") + If Not EsCarga Then + Descuento = TmpDT.SUMD("Descuento") + End If + + SubTotalConceptos = SubTotal + + End Sub + + Public Function ValidateUUID(ByVal uuid As String) As Boolean + Dim pattern As String = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" + Dim regex As New Regex(pattern) + Return regex.IsMatch(uuid) + End Function + Private Function GeneraStringDoctosRelacionados() As String + + Dim DoctosRelacionados As String = "-1" + Dim listaUUIDSRelacionados As New List(Of String) + + If DocumentosRelacionadosUUIDSList.Count > 0 Then + For Each s As String In DocumentosRelacionadosUUIDSList + If s.Trim.Length > 0 Then + listaUUIDSRelacionados.Add(s.Trim) + End If + Next + End If + + If listaUUIDSRelacionados.Count > 0 Then + DoctosRelacionados = String.Join(",", listaUUIDSRelacionados.ToArray()) + End If + + Return DoctosRelacionados + End Function + Private Function ValorXML(n As XmlNode, Campo As String, Optional Retorno As String = "") As String + Dim o As XmlNode = n.Attributes.Cast(Of XmlAttribute)().SingleOrDefault(Function(a) String.Compare(a.Name, Campo, True) = 0) + If o Is Nothing Then + Return Retorno + Else + Return o.Value + End If + End Function + + Public Function AddCompra() As Boolean + + If Not AjustesValidacion() Then Return False + + Dim respuesta As Boolean = True + Dim ObjCompras As New ClsCompras + Dim ObjConta As New ClsContabilidad(ObjCompras.IniciaTransacSQL()) + + If Not AddPrepolizaCabecera(ObjConta) Then + respuesta = False + End If + + If respuesta AndAlso ObjCompras.AddCompra(If(Me.TipoComprobante = "I", "Fac", "NC"), Me.Descripcion, Me.Serie, Me.Folio, Me.FolioSecundario, Me.CveProveedor, Me.SubTotal, Me.Descuento, + Me.Amortizacion, Me.IVA, Me.RetIVA, Me.RetISR, Me.IEPS, Me.OtrosImpuestos, + Me.Redondeo, Me.Total, Me.Fecha, Me.CveMoneda, Me.TipoCambio, If(Me.FechaPago = Nothing, Me.Fecha, Me.FechaPago), Me.AplicaNotaCredito, Me.Observaciones, Me.CveEstatusFactura, + Me.CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Me.IdPoliza, CveCajaChica:=Me.CveCajaChica, CvePersonal:=Me.CvePersonal, NumeroReembolso:=Me.NumeroReembolso, CveProveedorSucursal:=Me.CveProveedorSucursal, + AplicoPromocion:=Me.AplicoPromocion, PorcentajeIVA:=Me.PorcentajeIVA, CveMetodoPago:=Me.CveMetodoPago, CveRetIVAConcepto:=Me.CveRetIVAConcepto, + CveConceptoContableAlmacen:=Me.CveConceptoContableAlmacen, + CveRetISRConcepto:=Me.CveRetISRConcepto, NoDeducible:=Me.NoDeducible, CveTipoCompra:=Me.CveTipoCompra, TotalOriginal:=Me.TotalOriginal, CveTipoConcepto:=Me.CveTipoConcepto, + EsImportacion:=Me.EsImportacion, CveFactura:=Me.CveFactura, CveSubProyecto:=Me.CveSubProyectoPrincipal, DoctosRelacionados:=Me.DocumentosRelacionadosUUIDSString, CveFolioGarantia:=Me.CveFolioGarantia) Then + Me.CveCompra = ObjCompras.CveCompra + Else + respuesta = False + End If + + If respuesta AndAlso Me.CveCompra > 0 Then + + For Each Row As DataRow In Me.TmpDT.Rows + + Dim TipoRecepcion As Integer = -1 + Dim Referencia As String = "" + Dim EsNoDeducible As Boolean = False + Dim CveAF As Integer = If(Row("CveActivoFijo").ToString.ToEntero > 0 AndAlso Row("TipoAF").ToString.ToEntero = 1, Row("CveActivoFijo").ToString.ToEntero, -1) + Dim CveAFC As Integer = If(Row("CveActivoFijo").ToString.ToEntero > 0 AndAlso Row("TipoAF").ToString.ToEntero = 2, Row("CveActivoFijo").ToString.ToEntero, -1) + + If Not ObjCompras.AddCompraDetalle(Me.CveCompra, Row("CveUM").ToString.ToEntero, Row("CvePS").ToString.ToEntero, Row("CveSubProyecto").ToString.ToEntero, -1, CveAF, + Row("Cantidad").ToString.ToDecimal, Row("PU").ToString.ToDecimal, Row("IVA").ToString.ToDecimal, Row("Total").ToString.ToDecimal, Row("Descuento").ToString.ToDecimal, + Row("Obs").ToString, Row("CveOrdenCompraDetalle").ToString.ToEntero, TipoRecepcion, Row("CveContrato").ToString.ToEntero, Row("CvePresupuestoEgreso").ToString.ToEntero, + AplicaCostoIndirecto:=Row("AplicaCostoIndirecto").ToString.ToEntero, EstatusAlmacen:=Row("EntregaDirecta").ToString.ToEntero, CvePersonal:=CvePersonal, + CveTipoGasto:=Row("CveTipoGasto").ToString.ToEntero, AF_Medida:=Row("AFMedida").ToString.ToEntero, AF_TipoMantenimiento:=Row("AFTipoMantenimiento").ToString.ToEntero, Referencia:=Referencia, OtrosGastos:=Row("OtrosGastos").ToString.ToDecimal, + RetIVA:=Row("RetIVA").ToString.ToDecimal, RetISR:=Row("RetISR").ToString.ToDecimal, IEPSPS:=Row("IEPSPS").ToString.ToDecimal.RoundSQL, IEPSPSIVA:=Row("IEPSPSIVA").ToString.ToDecimal, + IVAPorcentaje:=Row("IVAPorcentaje").ToString.ToDecimal, RetIVAPorcentaje:=Row("RetIVAPorcentaje").ToString.ToDecimal, RetISRPorcentaje:=Row("RetISRPorcentaje").ToString.ToDecimal, + IEPSPSPorcentaje:=Row("IEPSPSPorcentaje").ToString.ToDecimal, IEPSPSIVAPorcentaje:=Row("IEPSPSIVAPorcentaje").ToString.ToDecimal, NoDeducible:=If((Row("NoDeducible").ToString().ToUpper().Contiene("TRUE", "1")) AndAlso EsNoDeducible, True, False), + CveContratoDetalle:=Row("CveContratoDetalle").ToString.ToEntero, CveCultivoCuadroDetalle:=Row("CveCultivoCuadroDetalle").ToString.ToEntero, CveActivoFijoCompra:=CveAFC) Then + + respuesta = False + Exit For + End If + Next + End If + + If respuesta Then + If Not AddPrePolizaDetalles(ObjConta) Then respuesta = False + End If + + If respuesta AndAlso ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual, 4) Then + If ObjConta.ValorPolizaDescuadre > 0 Then + Errores.AppendLine($"eFacturas/Compras-Guardar | Error{ObjConta.MensajePolizaDescuadre} Diferencia{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}.") + GuardaLogAD($"eFacturas/Compras-Guardar | Error{ObjConta.MensajePolizaDescuadre} Diferencia{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") + respuesta = False + End If + End If + + If respuesta Then + If Not ObjCompras.UpdateCompraFactura(Me.CveCompra, Me.CveFactura, Me.Serie, Me.Folio) Then respuesta = False + End If + + If respuesta Then + ObjCompras.Commit() + Else + ObjCompras.RollBack() + End If + + ObjCompras.Dispose() + ObjConta.Dispose() + + Return respuesta + End Function + + + Public Function AddCompraRNC(ByRef transacccion As SqlTransaction) As Boolean + + If Not AjustesValidacion() Then Return False + + Dim respuesta As Boolean = True + Dim ObjCompras As New ClsCompras(transacccion) + Dim ObjConta As New ClsContabilidad(transacccion) + + If Not AddPrepolizaCabecera(ObjConta) Then + respuesta = False + End If + + If respuesta AndAlso ObjCompras.AddCompra("RNC", Me.Descripcion, Me.Serie, Me.Folio, Me.FolioSecundario, Me.CveProveedor, Me.SubTotal, Me.Descuento, + Me.Amortizacion, Me.IVA, Me.RetIVA, Me.RetISR, Me.IEPS, Me.OtrosImpuestos, + Me.Redondeo, Me.Total, Me.Fecha, Me.CveMoneda, Me.TipoCambio, If(Me.FechaPago = Nothing, Me.Fecha, Me.FechaPago), Me.AplicaNotaCredito, Me.Observaciones, Me.CveEstatusFactura, + Me.CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Me.IdPoliza, CveCajaChica:=Me.CveCajaChica, CvePersonal:=Me.CvePersonal, NumeroReembolso:=Me.NumeroReembolso, CveProveedorSucursal:=Me.CveProveedorSucursal, + AplicoPromocion:=Me.AplicoPromocion, PorcentajeIVA:=Me.PorcentajeIVA, CveMetodoPago:=Me.CveMetodoPago, CveRetIVAConcepto:=Me.CveRetIVAConcepto, + CveConceptoContableAlmacen:=Me.CveConceptoContableAlmacen, + CveRetISRConcepto:=Me.CveRetISRConcepto, NoDeducible:=Me.NoDeducible, CveTipoCompra:=Me.CveTipoCompra, TotalOriginal:=Me.TotalOriginal, CveTipoConcepto:=Me.CveTipoConcepto, + EsImportacion:=Me.EsImportacion, CveFactura:=Me.CveFactura, CveSubProyecto:=Me.CveSubProyectoPrincipal, DoctosRelacionados:=Me.DocumentosRelacionadosUUIDSString, CveFolioGarantia:=Me.CveFolioGarantia) Then + Me.CveCompra = ObjCompras.CveCompra + Else + respuesta = False + End If + + If respuesta AndAlso Me.CveCompra > 0 Then + + For Each Row As DataRow In Me.TmpDT.Rows + + Dim TipoRecepcion As Integer = -1 + Dim Referencia As String = "" + Dim EsNoDeducible As Boolean = False + Dim CveAF As Integer = If(Row("CveActivoFijo").ToString.ToEntero > 0 AndAlso Row("TipoAF").ToString.ToEntero = 1, Row("CveActivoFijo").ToString.ToEntero, -1) + Dim CveAFC As Integer = If(Row("CveActivoFijo").ToString.ToEntero > 0 AndAlso Row("TipoAF").ToString.ToEntero = 2, Row("CveActivoFijo").ToString.ToEntero, -1) + + If Not ObjCompras.AddCompraDetalle(Me.CveCompra, Row("CveUM").ToString.ToEntero, Row("CvePS").ToString.ToEntero, Row("CveSubProyecto").ToString.ToEntero, -1, CveAF, + Row("Cantidad").ToString.ToDecimal, Row("PU").ToString.ToDecimal, Row("IVA").ToString.ToDecimal, Row("Total").ToString.ToDecimal, Row("Descuento").ToString.ToDecimal, + Row("Obs").ToString, Row("CveOrdenCompraDetalle").ToString.ToEntero, TipoRecepcion, Row("CveContrato").ToString.ToEntero, Row("CvePresupuestoEgreso").ToString.ToEntero, + AplicaCostoIndirecto:=Row("AplicaCostoIndirecto").ToString.ToEntero, EstatusAlmacen:=Row("EntregaDirecta").ToString.ToEntero, CvePersonal:=CvePersonal, + CveTipoGasto:=Row("CveTipoGasto").ToString.ToEntero, AF_Medida:=Row("AFMedida").ToString.ToEntero, AF_TipoMantenimiento:=Row("AFTipoMantenimiento").ToString.ToEntero, Referencia:=Referencia, OtrosGastos:=Row("OtrosGastos").ToString.ToDecimal, + RetIVA:=Row("RetIVA").ToString.ToDecimal, RetISR:=Row("RetISR").ToString.ToDecimal, IEPSPS:=Row("IEPSPS").ToString.ToDecimal.RoundSQL, IEPSPSIVA:=Row("IEPSPSIVA").ToString.ToDecimal, + IVAPorcentaje:=Row("IVAPorcentaje").ToString.ToDecimal, RetIVAPorcentaje:=Row("RetIVAPorcentaje").ToString.ToDecimal, RetISRPorcentaje:=Row("RetISRPorcentaje").ToString.ToDecimal, + IEPSPSPorcentaje:=Row("IEPSPSPorcentaje").ToString.ToDecimal, IEPSPSIVAPorcentaje:=Row("IEPSPSIVAPorcentaje").ToString.ToDecimal, NoDeducible:=If((Row("NoDeducible").ToString().ToUpper().Contiene("TRUE", "1")) AndAlso EsNoDeducible, True, False), + CveContratoDetalle:=Row("CveContratoDetalle").ToString.ToEntero, CveCultivoCuadroDetalle:=Row("CveCultivoCuadroDetalle").ToString.ToEntero, CveActivoFijoCompra:=CveAFC) Then + + respuesta = False + Exit For + End If + Next + End If + + If respuesta Then + If Not AddPrePolizaDetalles(ObjConta, True) Then respuesta = False + End If + + If respuesta AndAlso ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual, 4) Then + If ObjConta.ValorPolizaDescuadre > 0 Then + Errores.AppendLine($"Compras/RNC | Error{ObjConta.MensajePolizaDescuadre} Diferencia{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}.") + GuardaLogAD($"Compras/RNC | Error{ObjConta.MensajePolizaDescuadre} Diferencia{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") + respuesta = False + End If + End If + + 'If respuesta Then + ' If Not ObjCompras.UpdateCompraFactura(Me.CveCompra, Me.CveFactura, Me.Serie, Me.Folio) Then respuesta = False + 'End If + + 'If respuesta Then + ' ObjCompras.Commit() + 'Else + ' ObjCompras.RollBack() + 'End If + + 'ObjCompras.Dispose() + 'ObjConta.Dispose() + + Return respuesta + End Function + + + Private Function AddPrepolizaCabecera(ByRef ObjConta As ClsContabilidad, Optional ES_RNC As Boolean = False) As Boolean + + Dim respuesta As Boolean = False + + Dim ConceptoPoliza As String = String.Format("{0} - {1} - {2}", NombreProveedor, SerieFolio, "") + Dim Modulo As String = "eFacturas/Registrar" + + If ES_RNC Then + ConceptoPoliza = String.Format("{0} - {1} - {2}", NombreProveedor, SerieFolio, "") + Modulo = "Compras/RNC" + End If + + Me.CvePrePoliza = ObjConta.AddPrePolizas(Modulo, 1, Me.Total, Me.Total, Me.CveMoneda, Me.Fecha, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, "", CveTipoPoliza:=Me.CveTipoPoliza) + respuesta = If(Me.CvePrePoliza > 0, True, False) + + Return respuesta + End Function + + Private Function AddPrePolizaDetalles(ByRef ObjConta As ClsContabilidad, Optional ES_RNC As Boolean = False) As Boolean + Dim respuesta As Boolean = True + Dim Concepto As String = $"{Me.NombreProveedor} {Me.SerieFolio}" + Dim Referencia As String = Me.SerieFolio + + If ES_RNC Then + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Me.Total, Me.Total, 370, Referencia, Concepto, CveCompra:=CveCompra, CveCompraAmortizacion:=Me.CveCompraAmortizacion, CveProveedor:=Me.CveProveedor, ImporteME:=If(TipoCambio = 1, 0, Me.Total), TipoCambio:=TipoCambio, + CveClasificacion:=-1, CveSubProyecto:=Me.CveSubProyecto, Contabilizable:=True) Then + respuesta = False + + End If + + If respuesta Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Me.Total, Me.Total, 372, Referencia, Concepto, CveCompra:=CveCompra, CveCompraAmortizacion:=Me.CveCompraAmortizacion, CveProveedor:=Me.CveProveedor, ImporteME:=If(TipoCambio = 1, 0, Me.Total), TipoCambio:=TipoCambio, + CveClasificacion:=-1, CveSubProyecto:=Me.CveSubProyecto, Contabilizable:=True) Then + respuesta = False + + End If + End If + + Else + + Dim importeMovimiento As Decimal + Dim importeMN As Decimal + + + '6 + For Each RowDetalle As DataRow In TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2", "", {"CveClasificacion", "CveSubProyecto"}).Rows + + importeMovimiento = TmpDT.SUMD("Total", $" CveClasificacion = {RowDetalle("CveClasificacion").ToString} AND CveSubProyecto = {RowDetalle("CveSubProyecto").ToString}") + importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL + + If importeMN <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, importeMN, 6, Referencia, Concepto, CveCompra:=CveCompra, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=Me.CveCreditoDetalle, ImporteME:=If(TipoCambio = 1, 0, importeMovimiento), TipoCambio:=TipoCambio, + CveClasificacion:=RowDetalle("CveClasificacion").ToString().ToEntero(), CveSubProyecto:=RowDetalle("CveSubProyecto").ToString().ToEntero(), Contabilizable:=True) Then + respuesta = False + Exit For + End If + End If + Next + '14 + If respuesta AndAlso Me.IVA > 0 Then + importeMovimiento = Me.IVA + importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, importeMN, 14, Referencia, Concepto, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=Me.PorcentajeIVA, Contabilizable:=True) Then + respuesta = False + End If + End If + '25 + If respuesta AndAlso Me.IEPS > 0 Then + importeMovimiento = Me.IEPS + importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, importeMN, 25, Referencia, Concepto, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=0, Contabilizable:=True) Then + respuesta = False + End If + End If + ' + If respuesta AndAlso Me.RetIVA > 0 Then + importeMovimiento = Me.RetIVA + importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL + Dim ret As ConceptosRetenciones = ConceptoPrePolizaRetIVA + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, importeMN, ret.CveConceptoxAcreditar, Referencia, Concepto, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=0, Contabilizable:=True) Then + respuesta = False + End If + End If + ' + If respuesta AndAlso Me.RetISR > 0 Then + importeMovimiento = Me.RetISR + importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL + Dim ret As ConceptosRetenciones = ConceptoPrePolizaRetISR + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, importeMN, ret.CveConceptoxAcreditar, Referencia, Concepto, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=0, Contabilizable:=True) Then + respuesta = False + End If + End If + '5 + If respuesta Then + importeMovimiento = Me.Total + importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL + Dim ConPreP As ConceptosTipoSaldo = ObtenerCveConceptoPrePoliza(1, Me.CveMoneda, False, Me.CveTipoConceptoProveedor) + Dim ImporteME As Decimal = importeMovimiento + Dim UsaComplementaria As Boolean = True + If Me.CveMoneda > 1 Then ImporteME = importeMovimiento + + If UsuarioActual.CveEmpresa.Contiene(13, 83) Then 'caso excepcional de complementarias + UsaComplementaria = False + importeMN = importeMovimiento * Me.TipoCambio + Else + importeMN = importeMovimiento + End If + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, importeMN, ConPreP.CveConcepto, Referencia, Concepto, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=0, Contabilizable:=True) Then + respuesta = False + End If + If respuesta AndAlso Me.CveMoneda > 1 AndAlso UsaComplementaria Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, (importeMovimiento * Me.TipoCambio - importeMovimiento).RoundSQL, ConPreP.CveConceptoComplementario, Referencia, Concepto, CveCompra:=Me.CveCompra, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=Me.CvePersonal, CveCompraAmortizacion:=Me.CveCompraAmortizacion, TipoCambio:=Me.TipoCambio, TipoCambioPago:=1, ImporteME:=ImporteME, CveSubProyecto:=Me.CveSubProyecto) Then + respuesta = False + End If + End If + End If + End If + + Return respuesta + + End Function + +End Class \ No newline at end of file diff --git a/Compras/PopUpVerFactura.aspx.vb b/Compras/PopUpVerFactura.aspx.vb index 2e73e1c62..5810f81d3 100644 --- a/Compras/PopUpVerFactura.aspx.vb +++ b/Compras/PopUpVerFactura.aspx.vb @@ -10,6 +10,7 @@ Imports iText.Barcodes.Dmcode Imports Microsoft.Reporting.WebForms Imports Modelos Imports Stimulsoft.Base.Context +Imports ZXing Partial Class PopUpVerFactura @@ -1417,7 +1418,11 @@ Partial Class PopUpVerFactura 'IMPRIME DEPOSITOS CAJA If UrlParametros("OP").ToString = "DC" Then If UrlParametros("CVEIE") IsNot Nothing AndAlso UrlParametros("CVEIE").ToString.ToEntero > 0 Then - CargaDepositosCaja(UrlParametros("CVEIE").ToString.ToEntero, UrlParametros("CUENTACAJA").ToString, UrlParametros("CUENTADEPO").ToString) + Dim TipoPago As String = "" + If UrlParametros("TIPOPAGO") IsNot Nothing Then + TipoPago = UrlParametros("TIPOPAGO").ToString() + End If + CargaDepositosCaja(UrlParametros("CVEIE").ToString.ToEntero, UrlParametros("CUENTACAJA").ToString, UrlParametros("CUENTADEPO").ToString, TipoPago) End If End If @@ -1561,17 +1566,24 @@ Partial Class PopUpVerFactura #Region "OP = CORT - IMPRIMIR CORTE" Private Sub ImprimeCorte(CveCorte As Integer, Formato As String, Optional CveSubProyecto As Integer = -1) - Dim ObjVenta As New ClsVentas - Dim ObjPuntoVenta As New ClsPuntoVenta Dim DtCortesVentasResumen As DataTable = Nothing Dim DtCortesVentas As DataTable = Nothing + Dim DtReporteCorte As DataTable = Nothing + Dim DtIngresosRetiros As DataTable = Nothing + Dim Fecha As String = "", Nombre As String = "" + Dim OpcionDetallado As Integer = 1 + If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then OpcionDetallado = 2 + + Dim ObjVenta As New ClsVentas + Dim ObjPuntoVenta As New ClsPuntoVenta + If ObjVenta.GetCortesDetalleVentasResumen(CveCorte, CveSubProyecto, UsuarioActual.CveEmpresa) Then - DtCortesVentasResumen = ObjVenta.DtResultados + DtCortesVentasResumen = ObjVenta.DtResultados.Copy() End If - If ObjPuntoVenta.GetCortesDetalleVentas(CveCorte, CveSubProyecto, UsuarioActual.CveEmpresa) Then - DtCortesVentas = ObjPuntoVenta.DtResultados + If ObjPuntoVenta.GetCortesDetalleVentas(CveCorte, CveSubProyecto, UsuarioActual.CveEmpresa, OpcionDetallado) Then + DtCortesVentas = ObjPuntoVenta.DtResultados.Copy() If DtCortesVentas.Rows.Count > 0 Then Dim RowInfo As DataRow = DtCortesVentas.FiltroPrimero("CveVenta > 0") @@ -1580,27 +1592,201 @@ Partial Class PopUpVerFactura End If End If + If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then + If ObjPuntoVenta.GetVta_ReporteCortes(UsuarioActual.CveEmpresa, MinFecha, MaxFecha, CveSubProyecto, CveCorte:=CveCorte) Then + DtReporteCorte = ObjPuntoVenta.DtResultados.FiltraParametros("CveCorte > 0") + End If + + If ObjPuntoVenta.GetVta_MovimientosCajas(CveCorte, -1) Then + DtIngresosRetiros = ObjPuntoVenta.DtResultados.Copy() + End If + End If + ObjVenta.Dispose() ObjPuntoVenta.Dispose() + Dim FechaCorte As String = $" Fecha fin: {Fecha}" Dim Usuario As String = $" Usuario: {Nombre}" If DtCortesVentas.Rows.Count > 0 Or DtCortesVentasResumen.Rows.Count > 0 Then + Dim lrds As New List(Of ReportDataSource) + + Dim DtMetodosPago = DtCortesVentasResumen.Copy() + + 'MOVER EL VENTAS CREDITO DE LA DERECHA A LA IZQUIERDA EN EL PDF + If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then + DtMetodosPago = DtCortesVentasResumen.FiltraParametros("MetodoPago <> 'Crédito'") + End If + + Dim DirFormato As String = "Empresas/Grales/Formatos/RepCortes.rdlc" + If File.Exists(UsuarioActual.Empresa.Ruta + "\Formatos\RepCortes.rdlc") Then + DirFormato = UsuarioActual.Empresa.Ruta + "\Formatos\RepCortes.rdlc" + End If + Dim params As New List(Of ReportParameter) params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) params.Add(New ReportParameter("FechaImpresion", NowADS().ToDateTime.ToShortDateString)) params.Add(New ReportParameter("AgrupoPor", $"{FechaCorte}{Usuario}")) params.Add(New ReportParameter("LogoPath", RutaImagenLogo)) - Dim lrds As New List(Of ReportDataSource) - Dim rds As New ReportDataSource With {.Name = "DataSet1", .Value = DtCortesVentasResumen} + + If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then + If DtReporteCorte IsNot Nothing Then + Dim DtTT = GenerateTransposedTable(DtReporteCorte) + Dim DtDatosVentas As New DataTable() + DtDatosVentas.Columns.Add(New DataColumn("Orden", GetType(Integer))) + DtDatosVentas.Columns.Add(New DataColumn("Columna", GetType(String))) + DtDatosVentas.Columns.Add(New DataColumn("Importe", GetType(Decimal))) + + Dim DtDatosCajas As DataTable = DtDatosVentas.Copy() + + For Each row As DataRow In DtTT.Rows + Dim Total = row(1).ToString() + If IsNumeric(Total) Then + Dim TipoTabla As Integer = 0 + + Dim Orden As Integer = 0 + Dim rowData = DtDatosVentas.NewRow() + Select Case row(0).ToString() + Case "ImporteInicial" + rowData("Columna") = "Importe Inicial" + Orden = 1 + TipoTabla = 2 + Case "VentasCorte" + rowData("Columna") = "Total Ventas" + Orden = 2 + TipoTabla = 1 + Case "NotasCredito" + rowData("Columna") = "N.C." + Orden = 3 + TipoTabla = 1 + Case "VentasCredito" + rowData("Columna") = "Ventas Crédito" + Orden = 4 + TipoTabla = 1 + Case "VentaTotalIngreso" + rowData("Columna") = "Ventas Ingreso" + Orden = 4 + TipoTabla = 1 + Case "VentaTotalRemision" + rowData("Columna") = "Ventas Remisiones" + Orden = 4 + TipoTabla = 1 + 'Case "TotalEfectivo" + ' rowData("Columna") = "Total Efectivo" + 'Case "TotalCheque" + ' rowData("Columna") = "Total Cheque" + 'Case "TarjDebito" + ' rowData("Columna") = "Tarj. Débito" + 'Case "TarjCredito" + ' rowData("Columna") = "Tarj. Crédito" + 'Case "VentasTransferencia" + ' rowData("Columna") = "Total Transf." + Case "TotalRetiros" + rowData("Columna") = "Total Retiro" + Orden = 6 + TipoTabla = 2 + Case "TotalIngresos" + rowData("Columna") = "Total Ingreso" + Orden = 5 + TipoTabla = 2 + Case "Devoluciones" + rowData("Columna") = "Devoluciones" + Orden = 7 + TipoTabla = 1 + 'Case "SaldoAnteriorAplicado" + ' rowData("Columna") = "Saldo Aplicado" + ' Orden = 0 + ' TipoTabla = 0 + Case "TotalCaja" + rowData("Columna") = "Total Caja" + Orden = 9 + TipoTabla = 2 + Case Else + rowData("Columna") = row(0).ToString() + Orden = 0 + End Select + + rowData("Importe") = Total.ToDecimal() + rowData("Orden") = Orden + + If TipoTabla = 1 Then + DtDatosVentas.Rows.Add(rowData.ItemArray) + ElseIf TipoTabla = 2 Then + DtDatosCajas.Rows.Add(rowData.ItemArray) + End If + + If row(0).ToString() = "SaldoAnteriorAplicado" Then + Dim RowMP As DataRow = DtMetodosPago.NewRow + RowMP("MetodoPago") = "Saldo Aplicado" + RowMP("Importe") = Total.ToDecimal() + + DtMetodosPago.Rows.Add(RowMP) + End If + + End If + Next + + Dim TotalCredito As Decimal = DtCortesVentasResumen.SUMD("Importe", "MetodoPago = 'Crédito'") + + Dim rowCredito = DtDatosVentas.NewRow() + rowCredito("Columna") = "Crédito" + rowCredito("Importe") = TotalCredito + rowCredito("Orden") = 4 + DtDatosVentas.Rows.Add(rowCredito) + + Dim rds3 As New ReportDataSource With {.Name = "DataSet3", .Value = DtDatosVentas.FiltraParametros("Orden > 0", "Orden")} + lrds.Add(rds3) + + Dim rds4 As New ReportDataSource With {.Name = "DataSet4", .Value = DtDatosCajas.FiltraParametros("Orden > 0", "Orden")} + lrds.Add(rds4) + + Dim rds5 As New ReportDataSource With {.Name = "DataSet5", .Value = DtIngresosRetiros} + lrds.Add(rds5) + + 'params.Add(New ReportParameter("VentasCorte", RowCorte("VentasCorte").ToString())) + 'params.Add(New ReportParameter("NotasCredito", RowCorte("NotasCredito").ToString())) + 'params.Add(New ReportParameter("NotasCredito", RowCorte("NotasCredito").ToString())) + 'params.Add(New ReportParameter("VentasCredito", RowCorte("VentasCorte").ToString())) + 'params.Add(New ReportParameter("VentasCorte", RowCorte("VentasCorte").ToString())) + 'params.Add(New ReportParameter("VentasCorte", RowCorte("VentasCorte").ToString())) + End If + End If + + Dim rds As New ReportDataSource With {.Name = "DataSet1", .Value = DtMetodosPago} lrds.Add(rds) Dim rds2 As New ReportDataSource With {.Name = "DataSet2", .Value = DtCortesVentas} lrds.Add(rds2) - ImprimirPDF("Empresas/Grales/Formatos/RepCortes.rdlc", lrds, params, "ReporteCortes", Formato) + + + ImprimirPDF(DirFormato, lrds, params, "ReporteCortes", Formato) End If End Sub + Private Function GenerateTransposedTable(ByVal inputTable As DataTable) As DataTable + Dim outputTable As DataTable = New DataTable() + outputTable.Columns.Add(inputTable.Columns(0).ColumnName.ToString()) + + For Each inRow As DataRow In inputTable.Rows + Dim newColName As String = inRow(0).ToString() + outputTable.Columns.Add(newColName) + Next + + For rCount As Integer = 1 To inputTable.Columns.Count - 1 + Dim newRow As DataRow = outputTable.NewRow() + newRow(0) = inputTable.Columns(rCount).ColumnName.ToString() + + For cCount As Integer = 0 To inputTable.Rows.Count - 1 + Dim colValue As String = inputTable.Rows(cCount)(rCount).ToString() + newRow(cCount + 1) = colValue + Next + + outputTable.Rows.Add(newRow) + Next + + Return outputTable + End Function + #End Region #Region " OP = FACTURA - IMPRIME COMPRA" @@ -2042,17 +2228,10 @@ Partial Class PopUpVerFactura Dim RutaCBB As String = $"{UsuarioActual.Empresa.Ruta}CBB\{SerieFolio}.jpg" Dim ImagenCBB As New System.IO.FileInfo(RutaCBB) - - - If Not ImagenCBB.Exists Then - Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() - CBB.GenerarCBB(UsuarioActual.Empresa.RFC, ReceptorRFC, 1, FolioFiscal, RutaCBB) - End If - + If Not ImagenCBB.Exists Then GeneraQRSAT(UsuarioActual.Empresa.RFC, ReceptorRFC, 1, FolioFiscal, RutaGuardado:=RutaCBB) Dim ImgCBB As String = $"file://{ImagenCBB.FullName}" - params.Add(New ReportParameter("FolioFiscal", FolioFiscal)) params.Add(New ReportParameter("CertificadoSAT", NoSerieCertificado)) params.Add(New ReportParameter("FechaCertificacion", FechaCertificacion.ToString)) @@ -2754,7 +2933,7 @@ Partial Class PopUpVerFactura If CveConcepto = 33 Then ConceptoFormato = "ENTRADA MANUAL" 'IMPRESION ESPECIAL SALIDA DE COMPUPROVEEDORES y VSH - If UsuarioActual.CveEmpresa.Contiene(72, 80, 119, 4, 145, 146, 186) Then + If UsuarioActual.CveEmpresa.Contiene(72, 80, 119, 4, 145, 146, 186, 193) Then params.Add(New ReportParameter("Empresa", UsuarioActual.Empresa.Empresa)) params.Add(New ReportParameter("Concepto", ConceptoFormato)) params.Add(New ReportParameter("Almacen", Almacen)) @@ -2782,7 +2961,7 @@ Partial Class PopUpVerFactura End If - If UsuarioActual.CveEmpresa.Contiene(72, 80) Then + If UsuarioActual.CveEmpresa.Contiene(72, 80, 193) Then params.Add(New ReportParameter("NombreProveedor", If(CveCompra > 0, dr("RazonSocial").ToString, ""))) params.Add(New ReportParameter("DireccionProveedor", If(CveCompra > 0, dr("Direccion").ToString, ""))) params.Add(New ReportParameter("RFCProveedor", If(CveCompra > 0, dr("RFC").ToString, ""))) @@ -2890,7 +3069,7 @@ Partial Class PopUpVerFactura End If - Case 3, 16, 37, 40, 45 ' S A L I D A S + Case 3, 16, 37, 40, 45, 47 ' S A L I D A S 'Dim Archivo As New System.IO.FileInfo(String.Format("Empresas/{0}/Formatos/Salidas.rdlc", 72)) 'Dim Imagen As New System.IO.FileInfo(String.Format("Empresas/{0}/Logo.png", 72)) Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos/Salidas.rdlc", UsuarioActual.Empresa.Ruta)) @@ -2903,6 +3082,8 @@ Partial Class PopUpVerFactura concepto = "SALIDA VIRTUAL" ElseIf CveConcepto = 45 Then concepto = "SALIDA DE USADOS" + ElseIf CveConcepto = 47 Then + concepto = "SALIDA POR CAMBIO DE VIGENCIA" Else concepto = "SALIDA DE ALMACÉN POR RECONSTRUCCIÓN" End If @@ -5138,22 +5319,25 @@ Partial Class PopUpVerFactura #End Region #Region "OP = 'DC' - DEPOSITOS CAJA" - Private Sub CargaDepositosCaja(CveIE As Integer, CuentaCaja As String, CuentaDeposito As String) + Private Sub CargaDepositosCaja(CveIE As Integer, CuentaCaja As String, CuentaDeposito As String, TipoPago As String) Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos/DepositoCaja.rdlc", UsuarioActual.Empresa.Ruta)) + Dim Tabla As DataTable = Nothing + Dim ObjIE As New ClsBancos() - Dim Tabla As DataTable - ObjIE.GetBancosIEMovimientosDepositos(CveIE, UsuarioActual.CveEmpresa) + If ObjIE.GetBancosIEMovimientosDepositos(CveIE, UsuarioActual.CveEmpresa) Then + Tabla = ObjIE.DtResultados.Copy() + End If + ObjIE.Dispose() - - If ObjIE.DtResultados IsNot Nothing AndAlso ObjIE.DtResultados.Rows.Count > 0 Then - Tabla = ObjIE.DtResultados + If Tabla IsNot Nothing AndAlso Tabla.Rows.Count > 0 Then Dim params As New List(Of ReportParameter) params.Add(New ReportParameter("Fecha", NowADS().ToDateTime.ToString)) - params.Add(New ReportParameter("FechaIE", ObjIE.DtResultados(0)("FechaDocumento").ToString.ToDate.ToShortDateString)) + params.Add(New ReportParameter("FechaIE", Tabla(0)("FechaDocumento").ToString.ToDate.ToShortDateString)) params.Add(New ReportParameter("CuentaCaja", CuentaCaja)) params.Add(New ReportParameter("CuentaDeposito", CuentaDeposito)) + params.Add(New ReportParameter("TipoPago", TipoPago)) If Archivo.Exists Then params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) @@ -5164,11 +5348,6 @@ Partial Class PopUpVerFactura End If End If - - - - ObjIE.Dispose() - End Sub #End Region @@ -6039,6 +6218,13 @@ Partial Class PopUpVerFactura ObjVentas.Dispose() If DtPrecios IsNot Nothing Then + + DtPrecios.Columns.Add(New DataColumn("CBBase64", GetType(String))) + + For Each Row As DataRow In DtPrecios.Rows + Row("CBBase64") = Convert.ToBase64String(GeneraCodigoQR(Row("CodigoBarras").ToString(), 40, 150, 0, "CODE_39", True)) + Next + Dim DirectorioArchivo As String = "Empresas/Grales/Formatos/Etiqueta.mrt" If System.IO.File.Exists(UsuarioActual.Empresa.Ruta + "Formatos/Etiqueta.mrt") Then DirectorioArchivo = UsuarioActual.Empresa.Ruta + "Formatos/Etiqueta.mrt" @@ -6153,4 +6339,94 @@ Partial Class PopUpVerFactura #End Region + + Private Function GeneraCodigoQR(CodigoBarras As String, Alto As Integer, Largo As Integer, Margen As Integer, Formato As String, Optional PureBacode As Boolean = False) As Byte() + + Dim barcodeWriter As New BarcodeWriter + Dim opciones As New ZXing.Common.EncodingOptions + Dim FormatoBar As New BarcodeFormat + 'Dim Respuesta As Byte() + + opciones.Height = Alto + opciones.Width = Largo + opciones.Margin = Margen + opciones.PureBarcode = PureBacode + barcodeWriter.Options = opciones + + Select Case Formato + Case "All_1D" + barcodeWriter.Format = BarcodeFormat.All_1D + Exit Select + Case "AZTEC" + barcodeWriter.Format = BarcodeFormat.AZTEC + Exit Select + Case "CODABAR" + barcodeWriter.Format = BarcodeFormat.CODABAR + Exit Select + Case "CODE_128" + barcodeWriter.Format = BarcodeFormat.CODE_128 + Exit Select + Case "CODE_39" + barcodeWriter.Format = BarcodeFormat.CODE_39 + Exit Select + Case "CODE_93" + barcodeWriter.Format = BarcodeFormat.CODE_93 + Exit Select + Case "DATA_MATRIX" + barcodeWriter.Format = BarcodeFormat.DATA_MATRIX + Exit Select + Case "EAN_13" + barcodeWriter.Format = BarcodeFormat.EAN_13 + Exit Select + Case "EAN_8" + barcodeWriter.Format = BarcodeFormat.EAN_8 + Exit Select + Case "IMB" + barcodeWriter.Format = BarcodeFormat.IMB + Exit Select + Case "ITF" + barcodeWriter.Format = BarcodeFormat.ITF + Exit Select + Case "MAXICODE" + barcodeWriter.Format = BarcodeFormat.MAXICODE + Exit Select + Case "MSI" + barcodeWriter.Format = BarcodeFormat.MSI + Exit Select + Case "PDF_417" + barcodeWriter.Format = BarcodeFormat.PDF_417 + Exit Select + Case "PLESSEY" + barcodeWriter.Format = BarcodeFormat.PLESSEY + Exit Select + Case "QR_CODE" + barcodeWriter.Format = BarcodeFormat.QR_CODE + Exit Select + Case "RSS_14" + barcodeWriter.Format = BarcodeFormat.RSS_14 + Exit Select + Case "RSS_EXPANDED" + barcodeWriter.Format = BarcodeFormat.RSS_EXPANDED + Exit Select + Case "UPC_A" + barcodeWriter.Format = BarcodeFormat.UPC_A + Exit Select + Case "UPC_E" + barcodeWriter.Format = BarcodeFormat.UPC_E + Exit Select + Case "UPC_EAN_EXTENSION" + barcodeWriter.Format = BarcodeFormat.UPC_EAN_EXTENSION + Exit Select + + End Select + + Dim imgCod As Drawing.Bitmap = barcodeWriter.Write(CodigoBarras) + Dim memoriStream As New System.IO.MemoryStream + imgCod.Save(memoriStream, Drawing.Imaging.ImageFormat.Bmp) + + 'Respuesta = Convert.ToBase64String(memoriStream.ToArray()) + + Return memoriStream.ToArray() + + End Function End Class diff --git a/Compras/Proveedores.aspx b/Compras/Proveedores.aspx index 22104def6..60c46cc56 100644 --- a/Compras/Proveedores.aspx +++ b/Compras/Proveedores.aspx @@ -344,8 +344,8 @@
    -
    -
    +
    +
    @@ -356,7 +356,14 @@
    +
    +
    +
    + + +
    +
    diff --git a/Compras/Proveedores.aspx.vb b/Compras/Proveedores.aspx.vb index d4b2ccf60..ea2e659fe 100644 --- a/Compras/Proveedores.aspx.vb +++ b/Compras/Proveedores.aspx.vb @@ -640,9 +640,9 @@ Partial Class Compras_Proveedores GvA.Columns(5).Visible = True End If - - - + If UsuarioActual.Empresa.Funcionalidad(574).ToEntero = 1 Then + DVPorcentajeProntoPago.Visible = True + End If End If @@ -920,7 +920,7 @@ Partial Class Compras_Proveedores ChkEstado.Checked = ObjProveedor.Estatus = "Activo" LblFechaCaptura.Text = ObjProveedor.FechaIng.ToShortDateString LblUsuarioCapturo.Text = ObjProveedor.Usuario - TxtObservaciones.Text = ObjProveedor.Observaciones + TxtObservaciones.Text = ObjProveedor.Observaciones.ToString CargaCombos() @@ -950,6 +950,8 @@ Partial Class Compras_Proveedores Retorno = True + TxtPorcentajeProntoPago.Text = (100 * ObjProveedor.PorcentajeProntoPago).ToString("###.00") + ' enviaractivacion() CargaEventoBitacora() @@ -1403,6 +1405,11 @@ Partial Class Compras_Proveedores Dim CicloEvaluacion As Integer = If(AplicarEvaluacion, DdlCicloEvaluacion.SelectedValue.ToEntero(), -1) + Dim PorcentajeProntoPago As Decimal = 0 + If TxtPorcentajeProntoPago.Text.ToDecimal > 0 Then + PorcentajeProntoPago = TxtPorcentajeProntoPago.Text.ToDecimal / 100 + End If + If CveProveedor = -1 Then Dim ObjProveedores As New ClsCompProveedores() @@ -1414,7 +1421,7 @@ Partial Class Compras_Proveedores DdlCveClasificacionProveedor.SelectedValue.ToEntero, DdlCveUsuarioResponsable.SelectedValue.ToEntero, TxtNotificarA.Text.Trim, TxtCorreoCobranza.Text.Trim, ChkFolioDuplicado.Checked, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DdlCveTipoProveedor.SelectedValue.ToEntero, DdlMonedaPrefente.SelectedValue.ToEntero, UsaLimiteCredito:=ChkUsaLimiteCredito.Checked, DIOTCveTipoTercero:=DDlDIOTTipoTercero.SelectedValue.ToEntero, DIOTCveTipoOperacion:=DdlDIOTTipoOperacion.SelectedValue.ToEntero, DIOTNumeroIDFiscal:=TxtDIOTNumIDFiscal.Text, AplicarEvaluacion:=AplicarEvaluacion, FechaEvaluacion:=FechaEvaluacion, CicloEvaluacion:=CicloEvaluacion, DIOTCvePais:=DdlDIOTPais.SelectedValue.ToEntero, CveUsuarioEvaluador:=DdlUsuarioEvaluador.SelectedValue.ToEntero(), CP:=TxtCP.Text.ToEntero, DIOTNacionalidad:=TxtDIOTNacionalidad.Text, - CveConfianzaProveedor:=DdlConfianzaProveedor.SelectedValue.ToEntero(), CveRegimenFiscal:=DdlRegimenFiscal.SelectedValue.ToEntero) Then + CveConfianzaProveedor:=DdlConfianzaProveedor.SelectedValue.ToEntero(), CveRegimenFiscal:=DdlRegimenFiscal.SelectedValue.ToEntero, PorcentajeProntoPago:=PorcentajeProntoPago) Then Dim NuevoCveProveedor As Integer = ObjProveedores.CveProveedor @@ -1525,7 +1532,7 @@ Partial Class Compras_Proveedores DdlCveClasificacionProveedor.SelectedValue.ToEntero, DdlCveUsuarioResponsable.SelectedValue.ToEntero, ChkEstado.Checked, TxtNotificarA.Text.Trim, TxtCorreoCobranza.Text.Trim, ChkFolioDuplicado.Checked, CveProveedor, DdlCveTipoProveedor.SelectedValue.ToEntero, DdlMonedaPrefente.SelectedValue.ToEntero, UsaLimiteCredito:=ChkUsaLimiteCredito.Checked, DIOTCveTipoTercero:=DDlDIOTTipoTercero.SelectedValue.ToEntero, DIOTCveTipoOperacion:=DdlDIOTTipoOperacion.SelectedValue.ToEntero, DIOTNumeroIDFiscal:=TxtDIOTNumIDFiscal.Text, CveUsuarioModifico:=UsuarioActual.CveUsuario, DIOTCvePais:=DdlDIOTPais.SelectedValue.ToEntero, AplicarEvaluacion:=ChkAplicarEvaluacion.Checked, FechaEvaluacion:=FechaEvaluacion, CicloEvaluacion:=CicloEvaluacion, CveUsuarioEvaluador:=DdlUsuarioEvaluador.SelectedValue.ToEntero(), CP:=TxtCP.Text.ToEntero, DIOTNacionalidad:=TxtDIOTNacionalidad.Text, - CveConfianzaProveedor:=DdlConfianzaProveedor.SelectedValue.ToEntero(), CveRegimenFiscal:=DdlRegimenFiscal.SelectedValue.ToEntero) Then + CveConfianzaProveedor:=DdlConfianzaProveedor.SelectedValue.ToEntero(), CveRegimenFiscal:=DdlRegimenFiscal.SelectedValue.ToEntero, PorcentajeProntoPago:=PorcentajeProntoPago) Then GlobalDTCompProveedores(UsuarioActual.CveEmpresa) = Nothing diff --git a/Compras/RepCompras.aspx b/Compras/RepCompras.aspx index 9b735f488..c2c3b08bd 100644 --- a/Compras/RepCompras.aspx +++ b/Compras/RepCompras.aspx @@ -58,29 +58,34 @@ Reporte de Compras -
  • - PDF -
  • -
  • - Excel -
  • - - -
  • - Personalizar -
  • -
    -
    -
  • - Ver Dlls en pesos -
  • - - -
  • - Ver Grafica -
  • -
    -
    + + +
  • + PDF +
  • +
  • + Excel +
  • +
  • + Personalizar +
  • +
  • + Excel Personalizado +
  • +
  • + Ver Dlls en pesos +
  • + +
  • + Ver Grafica +
  • +
    + + + + + +
    diff --git a/Compras/RepCompras.aspx.vb b/Compras/RepCompras.aspx.vb index dc5b5fb03..9e5844ce5 100644 --- a/Compras/RepCompras.aspx.vb +++ b/Compras/RepCompras.aspx.vb @@ -8,7 +8,15 @@ Imports Microsoft.Reporting.WebForms Partial Class Compras_RepCompras Inherits ClsPaginas #Region "PROPIEDADES" + Private Property Personalizo As Integer + Get + Return ViewState("Personalizo").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("Personalizo") = value + End Set + End Property Private Property TCEspecifico As Double Get If ViewState("TCEspecifico") Is Nothing Then @@ -43,6 +51,7 @@ Partial Class Compras_RepCompras Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then + Personalizo = 0 CargaCombos() End If End Sub @@ -289,8 +298,16 @@ Partial Class Compras_RepCompras GvDatos.Columns(15).Visible = True Else GvDatos.Columns(15).Visible = False + End If + + + Personalizo = 1 + If Personalizo = 1 Then + ImgExcelPersonalizado.Visible = True + Else + ImgExcelPersonalizado.Visible = False End If - + UppAcciones.Update() UPDatos.Update() End Sub @@ -398,9 +415,14 @@ Partial Class Compras_RepCompras Protected Sub DdlVer_SelectedIndexChanged(sender As Object, e As EventArgs) CambioGrafica() - End Sub - + End Sub + #End Region - - + + Protected Sub ImgExcelPersonalizado_Click(sender As Object, e As EventArgs) Handles ImgExcelPersonalizado.Click + + GvDatos.ExportToExcel("Compras_" & NowADS().ToShortDateString) + 'GvDatos.ExportToExcelG("DetalleCompras_" & NowADS().ToShortDateString & ".xlsx") + End Sub + End Class diff --git a/Compras/RepComprasDetalle.aspx b/Compras/RepComprasDetalle.aspx index 820b840e8..df26c2813 100644 --- a/Compras/RepComprasDetalle.aspx +++ b/Compras/RepComprasDetalle.aspx @@ -3,37 +3,46 @@ <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> - <%----%> -
  • - Generar PDF -
  • + + + +
  • + Generar PDF +
  • -
  • - - Exportar Excel - -
  • -
  • - - Imprimir Remesa - -
  • - - -
  • - Personalizar -
  • -
    -
    -
  • - Ver Dlls en pesos -
  • - - -
  • - Ver Grafica -
  • +
  • + + Exportar Excel + +
  • +
  • + Excel Personalizado +
  • +
  • + + Imprimir Remesa + +
  • + +
  • + Personalizar +
  • + +
  • + Ver Dlls en pesos +
  • + +
  • + Ver Grafica +
  • +
    + + + + + +
    diff --git a/Compras/RepComprasDetalle.aspx.vb b/Compras/RepComprasDetalle.aspx.vb index b7e7c2946..669e79f5a 100644 --- a/Compras/RepComprasDetalle.aspx.vb +++ b/Compras/RepComprasDetalle.aspx.vb @@ -28,6 +28,15 @@ Partial Class Compras_RepComprasDetalle End Set End Property + Private Property Personalizo As Integer + Get + Return ViewState("Personalizo").ToString.ToEntero + End Get + + Set(value As Integer) + ViewState("Personalizo") = value + End Set + End Property Private Property TCEspecifico As Double Get If ViewState("TCEspecifico") Is Nothing Then @@ -62,6 +71,7 @@ Partial Class Compras_RepComprasDetalle Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then + Personalizo = 0 CargaCombos() CargaParametrosInicio() CargaDatos() @@ -460,10 +470,22 @@ Partial Class Compras_RepComprasDetalle GvDatos.Columns(14).Visible = ChkFecha.Checked GvDatos.Columns(15).Visible = ChkObs.Checked GvDatos.Columns(16).Visible = ChkDescripcion.Checked + + Personalizo = 1 + If Personalizo = 1 Then + ImgExcelPersonalizado.Visible = True + Else + ImgExcelPersonalizado.Visible = False + End If + UppAcciones.Update() UPDatos.Update() End Sub + Protected Sub ImgExcelPersonalizado_Click(sender As Object, e As EventArgs) Handles ImgExcelPersonalizado.Click + GvDatos.ExportToExcel("DetalleCompras_" & NowADS().ToShortDateString) + 'GvDatos.ExportToExcelG("DetalleCompras_" & NowADS().ToShortDateString & ".xlsx") + End Sub End Class diff --git a/Compras/RepCxP.aspx b/Compras/RepCxP.aspx index 1d1e25ff5..c9371d679 100644 --- a/Compras/RepCxP.aspx +++ b/Compras/RepCxP.aspx @@ -476,66 +476,64 @@ - + - SubTotal Pend + SubTotal - + - IVA Pend + IVA - + - IEPS Pend + IEPS - - - - Ret IVA Pend - - - - - - - - - Ret ISR Pend - - - - - - - + + + - + - + - + + + + + + + + + + + + + + + + diff --git a/Compras/RepCxP.aspx.vb b/Compras/RepCxP.aspx.vb index c5782cf3e..39f548632 100644 --- a/Compras/RepCxP.aspx.vb +++ b/Compras/RepCxP.aspx.vb @@ -98,7 +98,7 @@ Partial Class Compras_RepCxP If Not Page.IsPostBack Then SePersonalizo = 0 CargaCombos() - CargaGvPersonalizarRaqngoColumnas() + CargaGvPersonalizarRangoColumnas() ProcesaRequest() CargaDatos() @@ -656,7 +656,6 @@ Partial Class Compras_RepCxP If e.Row.FCHyperLink("HplColumna14").Text.ToDouble = 0 Then e.Row.FCHyperLink("HplColumna14").Text = "-" If e.Row.FCHyperLink("HplColumna15").Text.ToDouble = 0 Then e.Row.FCHyperLink("HplColumna15").Text = "-" - If e.Row.FCHyperLink("LtlPorVencer").Text = "0.00" Then e.Row.FCHyperLink("LtlPorVencer").Text = "-" If e.Row.FCHyperLink("LtlVentas").Text = "0.00" Then e.Row.FCHyperLink("LtlVentas").Text = "-" If e.Row.FCHyperLink("LtlSaldo1").Text = "0.00" Then e.Row.FCHyperLink("LtlSaldo1").Text = "-" @@ -1009,6 +1008,16 @@ Partial Class Compras_RepCxP If e.Row.FCHyperLink("LtlVentas").Text = "0.00" Then e.Row.FCHyperLink("LtlVentas").Text = "-" If e.Row.FCHyperLink("LtlSaldo1").Text = "0.00" Then e.Row.FCHyperLink("LtlSaldo1").Text = "-" + If e.Row.FCLabel("LtlSubtotalP").Text = "0.00" Then e.Row.FCLabel("LtlSubtotalP").Text = "-" + If e.Row.FCLabel("LtlIVAP").Text = "0.00" Then e.Row.FCLabel("LtlIVAP").Text = "-" + If e.Row.FCLabel("LtlIEPSP").Text = "0.00" Then e.Row.FCLabel("LtlIEPSP").Text = "-" + If e.Row.FCLabel("LtlRETIVASerProf").Text = "0.00" Then e.Row.FCLabel("LtlRETIVASerProf").Text = "-" + If e.Row.FCLabel("LtlRETIVAFletes").Text = "0.00" Then e.Row.FCLabel("LtlRETIVAFletes").Text = "-" + If e.Row.FCLabel("LtlRETIVAArrend").Text = "0.00" Then e.Row.FCLabel("LtlRETIVAArrend").Text = "-" + If e.Row.FCLabel("LtlRETISRSerProf").Text = "0.00" Then e.Row.FCLabel("LtlRETISRSerProf").Text = "-" + If e.Row.FCLabel("LtlRETISRArrend").Text = "0.00" Then e.Row.FCLabel("LtlRETISRArrend").Text = "-" + If e.Row.FCLabel("LtlRETISRResico").Text = "0.00" Then e.Row.FCLabel("LtlRETISRResico").Text = "-" + e.Row.Cells(2).Width = Unit.Pixel(75) e.Row.Cells(3).Width = Unit.Pixel(75) e.Row.Cells(4).Width = Unit.Pixel(75) @@ -1547,7 +1556,7 @@ Partial Class Compras_RepCxP UpBodyPersonalizar.Update() End Sub - Private Sub CargaGvPersonalizarRaqngoColumnas() + Private Sub CargaGvPersonalizarRangoColumnas() Dim ObjComp As New ClsCompras If ObjComp.GetRepCxPColumnas(UsuarioActual.CveEmpresa) Then GvPersonalizarRango.DataSource = ObjComp.DtResultados @@ -1895,7 +1904,13 @@ Partial Class Compras_RepCxP ActivaColumna(24, ChkIVAP.Checked) ActivaColumna(25, ChkIEPSP.Checked) ActivaColumna(26, ChkRetIVAPendiente.Checked) - ActivaColumna(27, ChkRetISRPendiente.Checked) + ActivaColumna(27, ChkRetIVAPendiente.Checked) + ActivaColumna(28, ChkRetIVAPendiente.Checked) + 'ActivaColumna(29, ChkRetIVAPendiente.Checked) + ActivaColumna(29, ChkRetISRPendiente.Checked) + ActivaColumna(30, ChkRetISRPendiente.Checked) + ActivaColumna(31, ChkRetISRPendiente.Checked) + 'ActivaColumna(33, ChkRetISRPendiente.Checked) If SePersonalizo = 1 Then ImgExcelPersonalizado.Visible = True diff --git a/Compras/RepCxPDetalle.aspx b/Compras/RepCxPDetalle.aspx index eb8f03b10..a7d940773 100644 --- a/Compras/RepCxPDetalle.aspx +++ b/Compras/RepCxPDetalle.aspx @@ -13,6 +13,9 @@ .tooltip-inner { max-width: 350px !important; } + .TextoGris { + color:gray; + } @@ -436,7 +439,7 @@ - SubTotal Pend + SubTotal @@ -445,7 +448,7 @@ - IVA Pend + IVA @@ -454,31 +457,43 @@ - IEPS Pend + IEPS - - - Ret IVA Pend - + - - - + + - - - Ret ISR Pend - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Compras/RepCxPDetalle.aspx.vb b/Compras/RepCxPDetalle.aspx.vb index bb867e3dd..7cea6cea1 100644 --- a/Compras/RepCxPDetalle.aspx.vb +++ b/Compras/RepCxPDetalle.aspx.vb @@ -566,7 +566,11 @@ Partial Class RepCxPDetalle ActivaColumna(18, ChkIVAPend.Checked) ActivaColumna(19, ChkIEPSPend.Checked) ActivaColumna(20, ChkRetIVAPendiente.Checked) - ActivaColumna(21, ChkRetISRPendiente.Checked) + ActivaColumna(21, ChkRetIVAPendiente.Checked) + ActivaColumna(22, ChkRetIVAPendiente.Checked) + ActivaColumna(23, ChkRetISRPendiente.Checked) + ActivaColumna(24, ChkRetISRPendiente.Checked) + ActivaColumna(25, ChkRetISRPendiente.Checked) If SePersonalizo = 1 Then ImgExcelPersonalizado.Visible = True diff --git a/Compras/RepNotasCredito.aspx b/Compras/RepNotasCredito.aspx index d7f55adc9..81a7980dc 100644 --- a/Compras/RepNotasCredito.aspx +++ b/Compras/RepNotasCredito.aspx @@ -104,108 +104,224 @@
    - - - - - - - - - - - - <%-- --%> - Serie Folio - <%-- --%> - <%-- --%> - - - - - - - - - <%----%> - Fecha - <%-- --%> - <%----%> - - - - - - - - - <%----%> - Proveedor - <%-- --%> - <%-- --%> - - - - - - - - - <%----%> - Moneda - <%----%> - <%----%> - - - - - - - - - <%----%> - Original - <%----%> - <%----%> - - - - - - - - - <%-- --%> - Abonado - <%----%> - <%-- --%> - - - - - - - - - <%-- --%> - Saldo - <%----%> - <%----%> - - - - - - - - - - - - - + + + + + + +
    +
    + + + + + + + + + + + + + + <%-- --%> + Serie Folio + <%-- --%> + <%-- --%> + + + + + + + + + <%----%> + Fecha + <%-- --%> + <%----%> + + + + + + + + + <%----%> + Proveedor + <%-- --%> + <%-- --%> + + + + + + + + + <%----%> + Moneda + <%----%> + <%----%> + + + + + + + + + <%----%> + Original + <%----%> + <%----%> + + + + + + + + + <%-- --%> + Abonado + <%----%> + <%-- --%> + + + + + + + + + <%-- --%> + Saldo + <%----%> + <%----%> + + + + + + + + + + + + + + + +
    +
    + +
    +
    + + + +
    +
    + + + + + + + + + + + + + Serie Folio + + + + + + + + + Fecha + + + + + + + + + Proveedor + + + + + + + + + Moneda + + + + + + + + + Original + + + + + + + + + Abonado + + + + + + + + + Saldo + + + + + + + + + + + + + + + +
    +
    + +
    +
    + + +
    + + @@ -1487,6 +1494,12 @@ + + + + + diff --git a/Compras/eFacturas.aspx.vb b/Compras/eFacturas.aspx.vb index 99bdde358..8497a219a 100644 --- a/Compras/eFacturas.aspx.vb +++ b/Compras/eFacturas.aspx.vb @@ -2249,10 +2249,8 @@ Partial Class Compras_eFacturas CargaImpuestosXML(XMLDoc) CargaTFD(XMLDoc) - Dim QR As New ClbNegBICFDv3_2.ClsNegCBBGenerar() Dim dtotal As Decimal = (If(total.ToDecimal() <= 0.0D, 0.0001D, total.ToDecimal())) - QR.GenerarCBB(EmiRFC, RecRfc, dtotal, TFDUUID, TmpArchivoQR) - + ClsPaginas.GeneraQRSAT(EmiRFC, RecRfc, dtotal, TFDUUID, RutaGuardado:=TmpArchivoQR) If System.IO.File.Exists(TmpArchivoQR) Then 'Dim ArchivoBaseXLS As String = String.Format("{0}FacturaPDF.xlsm", Ruta.Replace("Temp", "Compras")) @@ -2652,6 +2650,9 @@ Partial Class Compras_eFacturas 'End Sub Protected Sub LnkSolicitarSat_Click(ByVal sender As Object, ByVal e As EventArgs) + + Exit Sub + Dim sbResultado As StringBuilder = New StringBuilder() Dim idSolicitudCFDI As Integer = 0 Dim idSolicitudMetadata As Integer = 0 @@ -4038,8 +4039,7 @@ Partial Class Compras_eFacturas Dim objxml As XmlSatCFDI = XmlSatCFDI.readXML(rutaxml) Dim rutaReporte As String = String.Format("{0}{1}", ModExtensiones.DirectorioBaseEmpresas, "\Empresas\Grales\Formatos\CFDIV3.rdlc") - Dim QR As ClbNegBICFDv3_2.ClsNegCBBGenerar = New ClbNegBICFDv3_2.ClsNegCBBGenerar() - Dim cQr As Byte() = QR.GenerarCBBBytes(objxml.emisor.Rfc, objxml.receptor.Rfc, objxml.comprobante.Total, objxml.complemento.UUID) + Dim cQr As Byte() = ClsPaginas.GeneraQRSAT(objxml.emisor.Rfc, objxml.receptor.Rfc, objxml.comprobante.Total, objxml.complemento.UUID) Dim parametros As List(Of ReportParameter) = New List(Of ReportParameter)() parametros.Add(New ReportParameter("comprobante_Certificado", objxml.comprobante.Certificado)) parametros.Add(New ReportParameter("comprobante_CondicionesDePago", objxml.comprobante.CondicionesDePago)) @@ -5205,13 +5205,13 @@ Partial Class Compras_eFacturas Exit For End If - Dim CompraActual As New Compra2(CFDIXmlPath, Compra2.EnumCargaCompra.DesdeArchivo, GlobalDTTiposGastos(UsuarioActual.CveEmpresa), UsuarioActual) + Dim CompraActual As New ClsCompraManager(CFDIXmlPath, ClsCompraManager.EnumCargaCompra.DesdeArchivo, GlobalDTTiposGastos(UsuarioActual.CveEmpresa), UsuarioActual) CompraActual.CveFactura = GvRow.DataKey("CveFactura").ToEntero CompraActual.CveProveedor = GvRow.DataKey("CveProveedor").ToEntero CompraActual.CveTipoProveedor = GvRow.DataKey("CveTipoProveedor").ToEntero CompraActual.CveTipoConceptoProveedor = GvRow.DataKey("CveTipoProveedor").ToEntero - CompraActual.TipoCompra = Compra2.EnumTipoCompra.Sin_definir + CompraActual.TipoCompra = ClsCompraManager.EnumTipoCompra.Sin_definir CompraActual.IEPSGasto = True CompraActual.Descripcion = TxtDescripcionCompra.Text.Trim CompraActual.NombreProveedor = GvRow.DataKey("NombreProveedor") @@ -5250,7 +5250,9 @@ Partial Class Compras_eFacturas End Class -Public Class Compra2 + + +Public Class ClsCompraManager Enum EnumCargaCompra DesdeXML @@ -6941,7 +6943,7 @@ Public Class Compra2 End If If respuesta Then - If Not AddPrepolizaDetalles(ObjConta) Then respuesta = False + If Not AddPrePolizaDetalles(ObjConta) Then respuesta = False End If If respuesta AndAlso ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual, 4) Then @@ -7064,7 +7066,6 @@ End Class - Public Class GeneralesAPIeFacturas Inherits ADSNetLibraryzdE.HelpersE.ConexionesE.SIGAPIE.BaseSIGAPIeFacturas diff --git a/Contabilidad/CatCuentas.aspx.vb b/Contabilidad/CatCuentas.aspx.vb index 36f391f24..2fe4e638d 100644 --- a/Contabilidad/CatCuentas.aspx.vb +++ b/Contabilidad/CatCuentas.aspx.vb @@ -28,22 +28,22 @@ Partial Class Contabilidad_CatCuentas Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then - 'If Not UsuarioActual.CveEmpresa.Contiene(13, 83) AndAlso EsProduccion Then - ' Response.Redirect("/Contabilidad2/CatCuentas.aspx") - ' Exit Sub - 'End If - - If UsuarioActual.Empresa.UsaContabilidad Then - CargaMonedas() - CargaAgrupadorSAT() - CargaDatos() - Else - Alert("Este módulo requiere el uso de Contabilidad.", TipoMensaje.MsgAdvertencia) - MEECuenta.Enabled = False - LnkPdf.Visible = False + If UsuarioActual.Empresa.TipoContabilizacion = 1 Then + Response.Redirect("/Contabilidad2/CatCuentas.aspx") + Exit Sub End If - End If + If UsuarioActual.Empresa.UsaContabilidad Then + CargaMonedas() + CargaAgrupadorSAT() + CargaDatos() + Else + Alert("Este módulo requiere el uso de Contabilidad.", TipoMensaje.MsgAdvertencia) + MEECuenta.Enabled = False + LnkPdf.Visible = False + End If + + End If End Sub Private Sub CargaMonedas() diff --git a/Contabilidad/RegPoliza.aspx.vb b/Contabilidad/RegPoliza.aspx.vb index 9ade722b9..d8e1ffc2b 100644 --- a/Contabilidad/RegPoliza.aspx.vb +++ b/Contabilidad/RegPoliza.aspx.vb @@ -153,7 +153,7 @@ Partial Class RegPoliza Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.LoadComplete If Not IsPostBack Then If UsuarioActual.Empresa.TipoContabilizacion = 1 OrElse UsuarioActual.Empresa.TipoContabilidad = 1 Then - Response.Redirect("/Contabilidad2/RegPrePolizaS.aspx") + Response.Redirect("/Contabilidad/RegPrePolizaS.aspx") End If ViewState("Orden0") = "" diff --git a/Contabilidad2/RepLibroDiario.aspx.vb b/Contabilidad2/RepLibroDiario.aspx.vb index 425085a8f..0f488f8de 100644 --- a/Contabilidad2/RepLibroDiario.aspx.vb +++ b/Contabilidad2/RepLibroDiario.aspx.vb @@ -180,7 +180,7 @@ Partial Class Contabilidad2_RepLibroDiario lista.Add(New CrystalParametro("UsuarioImprimio", UsuarioActual.Nombre)) lista.Add(New CrystalParametro("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", ""))) - ImprimirbytesPDF(ImprimirPDFCrystal(Server.MapPath("~/Empresas/Grales/Formatos/LibroDiario.rpt"), DtDatos, lista, "LibroDiario", Formato), "LibroDiario", Formato) + ImprimirbytesPDF(ImprimirPDFCrystal(DirectorioEmpresas + "\Grales\Formatos\LibroDiario.rpt", DtDatos, lista, "LibroDiario", Formato), "LibroDiario", Formato) End Sub #End Region End Class diff --git a/CxC/RepCxCDetalle.aspx.vb b/CxC/RepCxCDetalle.aspx.vb index a89e8f4dc..a22dcc01e 100644 --- a/CxC/RepCxCDetalle.aspx.vb +++ b/CxC/RepCxCDetalle.aspx.vb @@ -765,7 +765,6 @@ Partial Class RepCxCDetalle logouri = String.Format("file://{0}", Imagen.FullName) End If - Dim params As New List(Of ReportParameter) params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) params.Add(New ReportParameter("FechaInicio", FechaI)) @@ -774,20 +773,24 @@ Partial Class RepCxCDetalle params.Add(New ReportParameter("FechaImpresion", NowADS().ToDateTime.ToShortDateString)) params.Add(New ReportParameter("AgrupadoPor", $"{Cliente}{Sucursal}{Grupo}{Vendedor}{FechaIn}{FechaFn}{Registro}{Responsable}{TipoDocto}{EstatusCob}{FVI}{FVF}{ClasificacionCli}{CorteA}")) params.Add(New ReportParameter("TituloReporte", TituloReporte)) - params.Add(New ReportParameter("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", ""))) - Dim lrds As New List(Of ReportDataSource) Dim DSDatos As DataSet = CargaDatos() - - Dim rds As New ReportDataSource With {.Name = "DataSet1", .Value = DSDatos.Tables(0)} + Dim dtt1 As DataTable = Nothing + Dim dtt2 As DataTable = Nothing + + If DSDatos IsNot Nothing AndAlso DSDatos.Tables.Count >= 1 Then + dtt1 = DSDatos.Tables(0) + If DSDatos.Tables.Count >= 2 Then dtt2 = DSDatos.Tables(1) + End If + + Dim rds As New ReportDataSource With {.Name = "DataSet1", .Value = dtt1} lrds.Add(rds) - If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then - Dim rdsCartera As New ReportDataSource With {.Name = "DSCartera", .Value = DSDatos.Tables(1)} + Dim rdsCartera As New ReportDataSource With {.Name = "DSCartera", .Value = dtt2} lrds.Add(rdsCartera) Else Dim DTCartera As New DataTable @@ -800,7 +803,6 @@ Partial Class RepCxCDetalle End If - Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos/RepCxCDetalle.rdlc", UsuarioActual.Empresa.Ruta)) If Archivo.Exists Then ImprimirPDF(String.Format("{0}Formatos/RepCxCDetalle.rdlc", UsuarioActual.Empresa.Ruta), lrds, params, "ReporteCxCDetalle", TipoImpresion) @@ -808,8 +810,6 @@ Partial Class RepCxCDetalle ImprimirPDF("Empresas/Grales/Formatos/RepCxCDetalle.rdlc", lrds, params, "ReporteCxCDetalle", TipoImpresion) End If - - End Sub Protected Sub ImgImprimir_Click(sender As Object, e As EventArgs) Handles ImgImprimir.Click GenerarImpresion("PDF") diff --git a/Empresas/140/Formatos/Factura.rdlc b/Empresas/140/Formatos/Factura.rdlc index 495426efa..90554a4fd 100644 --- a/Empresas/140/Formatos/Factura.rdlc +++ b/Empresas/140/Formatos/Factura.rdlc @@ -2321,7 +2321,7 @@ - =Fields!Importe.Value + =IIf(Fields!Importe.Value = 0.01 ,0.00,Fields!Importe.Value) - 21.0638cm + 21.06381cm 0.5327cm diff --git a/Empresas/140/Formatos/Remision.rdlc b/Empresas/140/Formatos/Remision.rdlc index d6b8d4dd0..f3ae0410a 100644 --- a/Empresas/140/Formatos/Remision.rdlc +++ b/Empresas/140/Formatos/Remision.rdlc @@ -1677,7 +1677,7 @@ - =Fields!Importe.Value + =IIf(Fields!Importe.Value = 0.01 ,0.00,Fields!Importe.Value) + + + + + + Textbox4 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Total + + + + + + + Textbox16 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.42588cm + + + + + true + + + + + =Fields!MetodoPago.Value + + + + + + + MetodoPago + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + + + + + =Fields!Importe.Value + + + + + + + Importe + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + After + + + + + + + DataSet1 + 0.73025cm + 0.06614cm + 0.90467cm + 6.69369cm + + + + + + true + true + + + + + Detalles de Pagos + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + 2.73022cm + + + 10.35439cm + + + 2.28714cm + + + 3.20444cm + + + + + 0.47879cm + + + + + true + true + + + + + Serie Folio + + + + + + + Textbox4 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Nombre Comercial + + + + + + + Textbox16 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Total + + + + + + + Textbox18 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Método de Pago + + + + + + + Textbox20 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.45234cm + + + + + true + + + + + =Fields!SerieFolio.Value + + + + + + + MetodoPago + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + + + + + =Fields!NombreComercial.Value + + + + + + + Importe + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!ImportePagado.Value + + + + + + + ImportePagado + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!MetodoPago.Value + + + + + + + MetodoPago1 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSet2 + 3.73395cm + 0.06614cm + 0.93113cm + 18.57619cm + 2 + + + + + + + + + 2.68035cm + + + 2.97963cm + + + + + 0.47879cm + + + + + true + true + + + + + Resumen + + + + + + + Textbox4 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Total + + + + + + + Textbox16 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.42588cm + + + + + true + + + + + =Fields!Columna.Value + + + + + + + MetodoPago + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + + + + + =Fields!Importe.Value + + + + + + + Importe + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + After + + + + + + + DataSet3 + 0.73025cm + 7.21681cm + 0.90467cm + 5.65998cm + 3 + + + + + + + + + 2.68035cm + + + 2.97963cm + + + + + 0.47879cm + + + + + true + true + + + + + Resumen + + + + + + + Textbox4 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Total + + + + + + + Textbox16 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.42588cm + + + + + true + + + + + =Fields!Columna.Value + + + + + + + MetodoPago + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + + + + + =Fields!Importe.Value + + + + + + + Importe + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + After + + + + + + + DataSet4 + 0.73025cm + 13.18603cm + 0.90467cm + 5.65998cm + 4 + + + + + + true + true + + + + + Ventas + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Cajas + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + 2.73022cm + + + 7.79329cm + + + 2.28714cm + + + + + 0.47879cm + + + + + true + true + + + + + Tipo + + + + + + + Textbox4 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Descripción + + + + + + + Textbox16 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Total + + + + + + + Textbox18 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.45234cm + + + + + true + + + + + =Fields!TipoMovimiento.Value + + + + + + + MetodoPago + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + + + + + =Fields!Descripcion.Value + + + + + + + Importe + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Importe.Value + + + + + + + ImportePagado + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSet5 + 2.73226cm + 0.06614cm + 0.93113cm + 12.81065cm + 7 + + + + + + true + true + + + + + Ingresos/Retiros + + + + + + 2pt + 2pt + 2pt + 2pt + + + + 1.83665in + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + REPORTE DE CORTES + + + + + + + Textbox2 + 1.10271cm + 5.07342cm + 0.52945cm + 10.36447cm + 1 + + + 2pt + 2pt + 2pt + 2pt + + + + External + =Parameters!LogoPath.Value + FitProportional + 0.06614cm + 2.22362cm + 2.33715cm + 2 + + + + + + true + true + + + + + =Parameters!AgrupoPor.Value + HTML + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + 0.68792cm + true + true + + + true + true + + + + + ="Página " & Globals.PageNumber & " de " & Globals.TotalPages + + + + + + + Textbox3 + 0.0829cm + 15.43789cm + 0.38981cm + 3.20444cm + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Usuario: + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!UsuarioImprimio.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Fecha Impresión: + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!FechaImpresion.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 27.94cm + 21.59cm + 0.5cm + 0.5cm + 0.3cm + 0.5cm + 0.13cm + + + + + + + Textbox3 + + + DimGray + 2pt + 2pt + 2pt + 2pt + + + 3 + + + + + + + + 0.52063cm + + + + + true + true + + + + + Clave + + + + + + + Textbox175 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + + + + + Concepto + + + + + + + Textbox34 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + + + + + Importe + + + + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.4148cm + + + + + true + true + + + + + =Fields!Codigo.Value + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Concepto.Value + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Importe.Value + + + + + + + Importe + + + + + + + + + 2pt + 2pt + 2pt + 2pt + es-MX + + + + + + + + 0.43657cm + + + + + true + true + + + + + + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + TOTAL PERCEPCIONES + + + + + + + Textbox226 + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =SUM(Fields!Importe.Value) + + + + + + + Textbox227 + + + + + + 2pt + 2pt + 2pt + 2pt + es-MX + + + + + + + + 0.07938cm + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + After + + + After + + + + + + Before + + + Before + + + + DsOC + 7.70215cm + 0.15979cm + 2.05138cm + 10.0953cm + + + + + + + + + 1.69328cm + + + 6.23048cm + + + 1.87118cm + + + + + 0.6cm + + + + + true + true + + + + + DEDUCCIONES + + + + + + + Textbox6 + + + DimGray + 2pt + 2pt + 2pt + 2pt + + + 3 + + + + + + + + 0.52063cm + + + + + true + true + + + + + Clave + + + + + + + Textbox175 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + + + + + Concepto + + + + + + + Textbox34 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + + + + + Importe + + + + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.4148cm + + + + + true + true + + + + + =Fields!Codigo.Value + + + + + + + + + + + + + Black + + + Black + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Concepto.Value + + + + + + + + + + + + + Black + + + Black + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Importe.Value + + + + + + + Textbox214 + + + + + + + + + + Black + + + Black + + 2pt + 2pt + 2pt + 2pt + es-MX + + + + + + + + 0.44125cm + + + + + true + true + + + + + + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + TOTAL DEDUCCIONES + + + + + + + Textbox229 + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!ImporteDeducciones.Value + + + + + + + Textbox4 + + + + + + 2pt + 2pt + 2pt + 2pt + es-MX + + + + + + + + 0.07938cm + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + After + + + After + + + + + + Before + + + Before + + + + DataSet1 + 7.70435cm + 10.2551cm + 2.05606cm + 9.79494cm + 1 + + + + + + true + true + + + + + HECTOR ADRIAN DIAZ CASTILLO + + + + + + + + + DICH7409082KA + + + + + + + + + Registro Patronal + + + + + + + + + =Parameters!RegistroPatronal.Value + + + + + + + + + 601 Régimen General de Ley Personas Morales +Lugar de expedición: 83190 Hermosillo + + + + + + + Textbox2 + 0.12976cm + 4.80311cm + 2.24428cm + 8.10317cm + 2 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + 3.71238cm + + + 7.38712cm + + + 4.59571cm + + + 4.19504cm + + + + + 0.38834cm + + + + + true + true + + + + + + + + + + + + Textbox232 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + SubTotal + + + + + + + Textbox124 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!SubTotal.Value + + + + + + + Textbox126 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.44125cm + + + + + true + true + + + + + Folio Fiscal + + + + + + + Textbox120 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!FolioFiscal.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Descuentos + + + + + + + Textbox130 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!Descuentos.Value + + + + + + + Textbox131 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.44125cm + + + + + true + true + + + + + No. Certificado del SAT + + + + + + + Textbox128 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!CertificadoSAT.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Retenciones + + + + + + + Textbox134 + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!ISR.Value + + + + + + + Textbox135 + + + + + + 2pt + 2pt + 2pt + 2pt + es-MX + + + + + + + + 0.44125cm + + + + + true + true + + + + + Fecha de certificación + + + + + + + Textbox132 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!FechaCertificacion.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + TOTAL + + + + + + + Textbox138 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!Total.Value + + + + + + + Textbox139 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + + + + + + DsOC + 9.86624cm + 0.15979cm + 1.71209cm + 19.89025cm + 3 + + + + + + Embedded + Logo + FitProportional + 0.19855cm + 0.33984cm + 2.01901cm + 3.94122cm + 4 + + + + + + + + + 3.31842cm + + + 3.75478cm + + + + + 0.51659cm + + + + + true + true + + + + + Recibo Nómina + + + + + + + Textbox218 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!ReciboNomina.Value + + + + + + + Textbox216 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.50702cm + + + + + true + true + + + + + Serie + + + + + + + Textbox220 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!Serie.Value + + + + + + + Textbox221 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + Fecha + + + + + + + Textbox223 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!Fecha.Value + + + + + + + Textbox224 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + Tipo de comprobante + + + + + + + Textbox219 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + N + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + + + + DsOC + 0.05745cm + 12.97684cm + 2.22361cm + 7.0732cm + 5 + + + + + + + + + 11.53918cm + + + 2.5cm + + + 5.85106cm + + + + + 0.6cm + + + + + true + true + + + + + Recibí de la empresa arriba mencionada, la cantidad neta a que este documento, se refiere, estando conforme con las Percepciones y deducciones que en el aparecen especificados. + + + + + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + true + true + + + + + + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.52062cm + + + + + true + true + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!NombreCompleto.Value + + + + + + + Textbox17 + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + + + DsOC + 17.07534cm + 0.15979cm + 1.12062cm + 19.89024cm + 6 + + + + + + Database + =First(Fields!ImagenByte.Value, "dsImagenes") + image/png + FitProportional + 4.64173in + 0.068in + 1.30194in + 1.48366in + 7 + + + + + + + + + 7.90238cm + + + 8.04297cm + + + + + 0.6cm + + + + + true + true + + + + + Éste documento es una representación impresa de un CFDi + + + + + + + Textbox258 + + + DimGray + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + 0.6cm + + + + + true + true + + + + + Sello digital del emisor + + + + + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + 0.6cm + + + + + true + true + + + + + =Parameters!SelloDigitalEmisor.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + 0.6cm + + + + + true + true + + + + + Sello dígital del SAT: + + + + + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + 0.6cm + + + + + true + true + + + + + =Parameters!SelloDigitalSAT.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + 0.6cm + + + + + true + true + + + + + Cadena Original del timbre + + + + + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + 0.57354cm + + + + + true + true + + + + + =Parameters!CadenaOriginal.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + 0.44125cm + + + + + true + true + + + + + Versión del comprobante: + + + + =Parameters!CFDIVersion.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Versión del complemento: 1.2 + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + Usos del CFDI: + + + + =Parameters!UsoCFDI.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + dsImagenes + 11.78999cm + 4.13053cm + 5.21479cm + 15.94535cm + 8 + + + + + + + + + 2.2642cm + + + 2.11107cm + + + 2.2102cm + + + 2.57342cm + + + 2.70756cm + + + 2.08963cm + + + 2.633cm + + + 3.2606cm + + + + + 0.49417cm + + + + + true + true + + + + + DATOS DEL EMPLEADO + + + + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + 8 + + + + + + + + + + + + + 0.41479cm + + + + + true + true + + + + + No Empleado + + + + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!NoEmpleado.Value + + + + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Nombre + + + + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!NombreCompleto.Value + + + + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + true + true + + + + + NSS + + + + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!NSS.Value + + + + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.38834cm + + + + + true + true + + + + + RFC + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!RFC.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + true + true + + + + + Régimen + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!Regimen.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + true + true + + + + + Departamento + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!Departamento.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.38834cm + + + + + true + true + + + + + CURP + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!CURP.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + true + true + + + + + Riesgo Puesto + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!RiesgoPuesto.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + true + true + + + + + Puesto + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!Puesto.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.49417cm + + + + + true + true + + + + + INFORMACION LABORAL + + + + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + 8 + + + + + + + + + + + + + 0.38832cm + + + + + true + true + + + + + Jornada + + + + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!Jornada.Value + + + + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + true + true + + + + + Contrato + + + + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!Contrato.Value + + + + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + true + true + + + + + Periodo + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!Periodo.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.38833cm + + + + + true + true + + + + + Dias Pagados + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!DiasPagados.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Fecha ingreso + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!FechaIngreso.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Salario Base + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!SalarioBase.Value + + + + + + + Textbox166 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Salario Diario Int + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!SalarioDiarioInt.Value + + + + + + + Textbox159 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.44124cm + + + + + true + true + + + + + PAGO + + + + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + 8 + + + + + + + + + + + + + 0.36187cm + + + + + true + true + + + + + Banco + + + + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!Banco.Value + + + + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + true + true + + + + + Método de Pago + + + + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + PUE + + + + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + true + true + + + + + Fecha Inicio + + + + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!FechaInicio.Value + + + + + + + Black + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.38834cm + + + + + true + true + + + + + CLABE + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!CLABE.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + true + true + + + + + Fecha Fin + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!FechaFin.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.38833cm + + + + + true + true + + + + + Clave + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Cantidad + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Unidad + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Moneda + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Descripción + + + + + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + true + true + + + + + Precio Unit. + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Importe + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.49416cm + + + + + true + true + + + + + =Parameters!Clave.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!Cantidad.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!Unidad.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + MXN + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!Descripcion.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + true + true + + + + + =Parameters!PU.Value + + + + + + + Textbox103 + + + 2pt + 2pt + 2pt + 2pt + es-MX + + + + + + + + true + true + + + + + =Parameters!Importe.Value + + + + + + + Textbox110 + + + 2pt + 2pt + 2pt + 2pt + es-MX + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DsOC + 2.51578cm + 0.15979cm + 5.0304cm + 19.84968cm + 9 + + + + + + 18.41425cm + + + + + + + + =Today + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 27.94cm + 21.59cm + 0.5cm + 0.5cm + 1cm + 0.5cm + 1.27cm + + + + + + + Textbox3 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + U. M. + + + + + + + Textbox7 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Producto o Servicio + + + + + + + Textbox9 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Observaciones + + + + + + + Textbox68 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + P. U. + + + + + + + Textbox2 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Total + + + + + + + Textbox1 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.473cm + + + + + true + true + + + + + =Fields!Cantidad.Value + + + + + + + Cantidad + + + 2pt + 2pt + 1pt + + + + + + + + true + true + + + + + =Fields!UM.Value + + + + + + + UM + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + 2pt + 2pt + 1pt + + + + + + + + true + true + + + + + =Fields!PS.Value + + + + + + + PS + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + 2pt + 2pt + 1pt + + + + + + + + true + true + + + + + =Fields!Observacion.Value + + + + + + + Observacion + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + 2pt + 2pt + 1pt + + + + + + + + true + true + + + + + =Fields!Importe.Value + + + + + + + Importe + + + 2pt + 2pt + 1pt + + + + + + + + true + true + + + + + =Fields!Total.Value + + + + + + + Total + + + 2pt + 2pt + 1pt + + + + + + + + + + + + + + + + + =IIF(Parameters!TipoProveedor.Value = "1",true,false) + + + + + =IIF(Parameters!TipoProveedor.Value = "1",true,false) + + + + + + + + After + + + + + + + DsOC + 4.58198cm + 0.20457cm + 0.96717cm + 20.25842cm + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + + + true + true + + + + + ORDEN DE COMPRA DE MATERIALES Y SERVICIOS + + + + + + + Textbox8 + 0.12484cm + 4.03472cm + 0.5365cm + 11.69962cm + 1 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!TipoOC.Value + + + + + + + Textbox12 + 0.12484cm + 16.1331cm + 0.44478cm + 4.32987cm + 2 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!Folio.Value + + + + + + + Textbox12 + 0.56962cm + 16.1331cm + 0.44478cm + 4.32987cm + 3 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Fecha + + + + + + + Textbox12 + 1.0144cm + 16.13311cm + 0.44478cm + 4.32987cm + 4 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =CDate(replace(Parameters!FechaSolicitud.Value, "T" ," ")).ToString("dd/MM/yyyy") + + + + + + + Textbox12 + 1.45918cm + 16.13312cm + 0.44478cm + 4.32987cm + 5 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Proveedor + + + + + + + Textbox12 + 2.53982cm + 0.20457cm + 0.44478cm + 2.34596cm + 6 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Descripción + + + + + + + Textbox12 + 2.9846cm + 0.20457cm + 0.44478cm + 2.34596cm + 7 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Justificación + + + + + + + Textbox12 + 3.42938cm + 0.20457cm + 0.44478cm + 2.34596cm + 8 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + #e36c09 + Middle + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Fecha Entrega + + + + + + + Textbox12 + 2.9846cm + 13.61054cm + 0.44478cm + 2.52258cm + 9 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Lugar de Entrega + + + + + + + Textbox12 + 3.42938cm + 13.61054cm + 0.44478cm + 2.52258cm + 10 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Estatus + + + + + + + Textbox12 + 2.53982cm + 13.61054cm + 0.44478cm + 2.52258cm + 11 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =iif(Parameters!FechaEntrega.Value="01/01/0001","",Parameters!FechaEntrega.Value) + + + + + + + Textbox12 + 2.9846cm + 16.1331cm + 0.44478cm + 4.32987cm + 12 + + + White + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!ProveedorLugar.Value + + + + + + + Textbox12 + 3.42938cm + 16.1331cm + 0.44478cm + 4.32987cm + 13 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + White + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!Estatus.Value + + + + + + + Textbox12 + 2.53982cm + 16.1331cm + 0.44478cm + 4.32987cm + 14 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + White + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!Descripcion.Value + + + + + + + Textbox12 + 2.9846cm + 2.55053cm + 0.44478cm + 11.06001cm + 15 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + White + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!Asunto.Value + + + + + + + Textbox12 + 3.42938cm + 2.55053cm + 0.44478cm + 11.06001cm + 16 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + White + Middle + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!ProveedorNombre.Value + + + + + + + Textbox12 + 2.53982cm + 2.55053cm + 0.44478cm + 11.06001cm + 17 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + White + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + HECTOR ADRIAN DIAZ CASTILLO + + + + + + + Textbox8 + 0.92326cm + 4.03472cm + 0.76228cm + 11.69962cm + 18 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Autorizó + + + + + + + Textbox12 + 8.30549cm + 7.33306cm + 0.44478cm + 5.83844cm + 19 + + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + + + + + + + + Textbox12 + 8.75027cm + 7.33306cm + 0.4095cm + 5.83844cm + 20 + + + + Black + + 1pt + + Top + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!NombreAutorizo.Value + + + + + + + Textbox12 + 9.19505cm + 7.33306cm + 0.44478cm + 5.83844cm + 21 + + + White + 2pt + 2pt + 2pt + 2pt + + + + External + =Parameters!FirmaAutorizo.Value + Fit + 6.73531cm + 8.35229cm + 3.5cm + 3.5cm + 22 + + =iif(Parameters!FirmaAutorizo.Value <> "", False, True) + + + + + + + true + true + + + + + Uso CFDI 3.3: + + + + + + + Textbox12 + 3.87416cm + 0.20457cm + 0.44478cm + 2.34596cm + 23 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + #e36c09 + Middle + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!UsoCFDI.Value + + + + + + + Textbox12 + 3.87416cm + 2.55053cm + 0.44478cm + 11.06001cm + 24 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + White + Middle + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Sucursal + + + + + + + Textbox12 + 3.87416cm + 13.61054cm + 0.44478cm + 2.55786cm + 25 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!Proyecto.Value + + + + + + + Textbox12 + 3.87416cm + 16.13312cm + 0.44478cm + 4.32987cm + 26 + + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + + LightGrey + + 1pt + + White + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + ="Total " & Parameters!Moneda.Value + + + + + + + Textbox20 + 7.3465cm + 16.7985cm + 0.45183cm + 1.8653cm + 27 + + =IIF(Parameters!TipoProveedor.Value = "1",true,false) + + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + SubTotal + + + + + + + Textbox20 + 5.54915cm + 16.7985cm + 0.42361cm + 1.8653cm + 28 + + =IIF(Parameters!TipoProveedor.Value = "1",true,false) + + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =Parameters!Total.Value + + + + + + + Textbox20 + 7.3465cm + 18.6638cm + 0.45183cm + 1.80228cm + 29 + + =IIF(Parameters!TipoProveedor.Value = "1",true,false) + + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =Parameters!SubTotal.Value + + + + + + + Textbox20 + 5.54915cm + 18.6638cm + 0.42361cm + 1.7992cm + 30 + + =IIF(Parameters!TipoProveedor.Value = "1",true,false) + + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + IVA + + + + + + + Textbox20 + 6.90659cm + 16.7985cm + 0.45183cm + 1.8653cm + 31 + + =IIF(Parameters!TipoProveedor.Value = "1",true,false) + + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =Parameters!IVA.Value + + + + + + + Textbox20 + 6.90659cm + 18.6638cm + 0.45183cm + 1.80228cm + 32 + + =IIF(Parameters!TipoProveedor.Value = "1",true,false) + + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + Descuento + + + + + + + Textbox20 + 6.00293cm + 16.7985cm + 0.45183cm + 1.8653cm + 33 + + =IIF(Parameters!TipoProveedor.Value = "1",true,false) + + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =Parameters!Descuento.Value + + + + + + + Textbox20 + 6.00293cm + 18.6638cm + 0.45183cm + 1.80228cm + 34 + + =IIF(Parameters!TipoProveedor.Value = "1",true,false) + + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + Sub Total 2 + + + + + + + Textbox20 + 6.45476cm + 16.7985cm + 0.45183cm + 1.8653cm + 35 + + =IIF(Parameters!TipoProveedor.Value = "1",true,false) + + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =Parameters!SubTotal2.Value + + + + + + + Textbox20 + 6.45476cm + 18.6638cm + 0.45183cm + 1.80228cm + 36 + + =IIF(Parameters!TipoProveedor.Value = "1",true,false) + + + + 2pt + 2pt + 2pt + 2pt + + + + Embedded + Logo + FitProportional + 0.12484cm + 0.05822cm + 2.01901cm + 3.94122cm + 37 + + + + + + 4.17138in + + + + + + + + =Today + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 27.94cm + 21.59cm + 0.5cm + 0cm + 1cm + 1cm + 0.13cm + + + + + + + Textbox24 + + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + U.M. + + + + + + + Textbox27 + + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + DESCRIPCIÓN + + + + + + + Textbox26 + + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + P/U + + + + + + + Textbox36 + + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + IMPORTE + + + + + + + Textbox38 + + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + =Parameters!Cantidad.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!UnidadMedida.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!Descripcion.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!PU.Value + + + + + + + Textbox37 + + + 2pt + 2pt + 2pt + 2pt + es-MX + + + + + + + + true + true + + + + + =Parameters!Importe.Value + + + + + + + Textbox39 + + + 2pt + 2pt + 2pt + 2pt + es-MX + + + + + + + + + + + + + + + + + + + + + + + + DataSet2 + 2.59417cm + 1.09cm + 20.53564cm + + + + + + + + + 2.13038cm + + + 1.64459cm + + + 1.80415cm + + + 1.76995cm + + + 1.8cm + + + 1.8cm + + + 1.8cm + + + 1.99576cm + + + 2.49576cm + + + 3.2908cm + + + + + 0.56938cm + + + + + true + true + + + + + UUID + + + + + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + 4 + + + + + + + + + true + true + + + + + SERIE + + + + + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + FOLIO + + + + + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + MONEDA + + + + + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + NO.PARC. + + + + + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + SALDO ANT. + + + + + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + MONTO PAGADO + + + + + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.43188cm + + + + + true + true + + + + + =Fields!IdDocumento.Value + + + + + + + + 4 + + + + + + + + + true + true + + + + + =Fields!Serie.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Folio.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!MonedaDR.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!NumParcialidad.Value + + + + + + + NumParcialidad + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!ImpSaldoAnt.Value + + + + + + + ImpSaldoAnt + + + 2pt + 2pt + 2pt + 2pt + es-MX + + + + + + + + true + true + + + + + =Fields!ImpPagado.Value + + + + + + + ImpPagado + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.07938cm + + + + + true + true + + + + + Impuesto + + + + + + + Textbox108 + + = IIF( + Fields!Tra001BaseDR.Value > 0 + OR Fields!Tra002BaseDR.Value > 0 + OR Fields!Tra003BaseDR.Value > 0 + OR Fields!Ret001BaseDR.Value > 0 + OR Fields!Ret002BaseDR.Value > 0 + OR Fields!Ret003BaseDR.Value > 0 + ,False,true) + + + + Top + + + + + + + + true + true + + + + + Tipo + + + + + + + Textbox109 + + = IIF( + Fields!Tra001BaseDR.Value > 0 + OR Fields!Tra002BaseDR.Value > 0 + OR Fields!Tra003BaseDR.Value > 0 + OR Fields!Ret001BaseDR.Value > 0 + OR Fields!Ret002BaseDR.Value > 0 + OR Fields!Ret003BaseDR.Value > 0 + ,False,true) + + + + Top + + + + + + + + true + true + + + + + Base + + + + + + + Textbox110 + + = IIF( + Fields!Tra001BaseDR.Value > 0 + OR Fields!Tra002BaseDR.Value > 0 + OR Fields!Tra003BaseDR.Value > 0 + OR Fields!Ret001BaseDR.Value > 0 + OR Fields!Ret002BaseDR.Value > 0 + OR Fields!Ret003BaseDR.Value > 0 + ,False,true) + + + + Top + + + + + + + + true + true + + + + + Tipo Factor + + + + + + + Textbox111 + + = IIF( + Fields!Tra001BaseDR.Value > 0 + OR Fields!Tra002BaseDR.Value > 0 + OR Fields!Tra003BaseDR.Value > 0 + OR Fields!Ret001BaseDR.Value > 0 + OR Fields!Ret002BaseDR.Value > 0 + OR Fields!Ret003BaseDR.Value > 0 + ,False,true) + + + + Top + + + + + + + + true + true + + + + + Tasa/Cuota + + + + + + + Textbox112 + + = IIF( + Fields!Tra001BaseDR.Value > 0 + OR Fields!Tra002BaseDR.Value > 0 + OR Fields!Tra003BaseDR.Value > 0 + OR Fields!Ret001BaseDR.Value > 0 + OR Fields!Ret002BaseDR.Value > 0 + OR Fields!Ret003BaseDR.Value > 0 + ,False,true) + + + + Top + + + + + + + + true + true + + + + + Importe + + + + + + + Textbox113 + + = IIF( + Fields!Tra001BaseDR.Value > 0 + OR Fields!Tra002BaseDR.Value > 0 + OR Fields!Tra003BaseDR.Value > 0 + OR Fields!Ret001BaseDR.Value > 0 + OR Fields!Ret002BaseDR.Value > 0 + OR Fields!Ret003BaseDR.Value > 0 + ,False,true) + + + + Top + + + + + + + + true + true + + + + + + + + + + + + Textbox114 + + = IIF( + Fields!Tra001BaseDR.Value > 0 + OR Fields!Tra002BaseDR.Value > 0 + OR Fields!Tra003BaseDR.Value > 0 + OR Fields!Ret001BaseDR.Value > 0 + OR Fields!Ret002BaseDR.Value > 0 + OR Fields!Ret003BaseDR.Value > 0 + ,False,true) + + + + Top + + + + + + + + true + true + + + + + + + + + + + + Textbox115 + + = IIF( + Fields!Tra001BaseDR.Value > 0 + OR Fields!Tra002BaseDR.Value > 0 + OR Fields!Tra003BaseDR.Value > 0 + OR Fields!Ret001BaseDR.Value > 0 + OR Fields!Ret002BaseDR.Value > 0 + OR Fields!Ret003BaseDR.Value > 0 + ,False,true) + + + + Top + + + + + + + + true + true + + + + + + + + + + + Top + + + + + + + + true + true + + + + + + + + + + + Top + + + + + + + + 0.07938cm + + + + + true + true + + + + + ISR + + + + + + + Textbox61 + + = IIF( + Fields!Tra001BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + Traslado + + + + + + + Textbox204 + + = IIF( + Fields!Tra001BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!ImpPagado.Value + + + + + + + ImpPagado + + = IIF( + Fields!Tra001BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!Tra001TipoFactorDR.Value + + + + + + + ImpPagado + + = IIF( + Fields!Tra001BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!Tra001TasaOCuotaDR.Value + + + + + + + ImpPagado + + = IIF( + Fields!Tra001BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!Tra001ImporteDR.Value + + + + + + + ImpPagado + + = IIF( + Fields!Tra001BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + + + + + + + + Textbox4 + + = IIF( + Fields!Tra001BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + + + + + + + + Textbox13 + + = IIF( + Fields!Tra001BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + + + + + + + + + + + + + + true + true + + + + + + + + + + + + + + + + + + 0.07938cm + + + + + true + true + + + + + IVA + + + + + + + Textbox61 + + = IIF( + Fields!Tra002BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + Traslado + + + + + + + Textbox204 + + = IIF( + Fields!Tra002BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!ImpPagado.Value + + + + + + + ImpPagado + + = IIF( + Fields!Tra002BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!Tra002TipoFactorDR.Value + + + + + + + ImpPagado + + = IIF( + Fields!Tra002BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!Tra002TasaOCuotaDR.Value + + + + + + + ImpPagado + + = IIF( + Fields!Tra002BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!Tra002ImporteDR.Value + + + + + + + ImpPagado + + = IIF( + Fields!Tra002BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + + + + + + + + Textbox67 + + = IIF( + Fields!Tra002BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + + + + + + + + Textbox68 + + = IIF( + Fields!Tra002BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + + + + + + + + + + + + + + true + true + + + + + + + + + + + + + + + + + + 0.07938cm + + + + + true + true + + + + + IEPS + + + + + + + Textbox61 + + = IIF( + Fields!Tra003BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + Traslado + + + + + + + Textbox204 + + = IIF( + Fields!Tra003BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!ImpPagado.Value + + + + + + + ImpPagado + + = IIF( + Fields!Tra003BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!Tra003TipoFactorDR.Value + + + + + + + ImpPagado + + = IIF( + Fields!Tra003BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!Tra003TasaOCuotaDR.Value + + + + + + + ImpPagado + + = IIF( + Fields!Tra003BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!Tra003ImporteDR.Value + + + + + + + ImpPagado + + = IIF( + Fields!Tra003BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + + + + + + + + Textbox51 + + = IIF( + Fields!Tra003BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + + + + + + + + Textbox55 + + = IIF( + Fields!Tra003BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + + + + + + + + + + + + + + true + true + + + + + + + + + + + + + + + + + + 0.07938cm + + + + + true + true + + + + + ISR + + + + + + + Textbox61 + + = IIF( + Fields!Ret001BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + Retención + + + + + + + Textbox207 + + = IIF( + Fields!Ret001BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!ImpPagado.Value + + + + + + + ImpPagado + + = IIF( + Fields!Ret001BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!Ret001TipoFactorDR.Value + + + + + + + ImpPagado + + = IIF( + Fields!Ret001BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!Ret001TasaOCuotaDR.Value + + + + + + + ImpPagado + + = IIF( + Fields!Ret001BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!Ret001ImporteDR.Value + + + + + + + ImpPagado + + = IIF( + Fields!Ret001BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + + + + + + + + Textbox75 + + = IIF( + Fields!Ret001BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + + + + + + + + Textbox76 + + = IIF( + Fields!Ret001BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + + + + + + + + + + + + + + true + true + + + + + + + + + + + + + + + + + + 0.07939cm + + + + + true + true + + + + + IVA + + + + + + + Textbox61 + + = IIF( + Fields!Ret002BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + Retención + + + + + + + Textbox207 + + = IIF( + Fields!Ret002BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!ImpPagado.Value + + + + + + + ImpPagado + + = IIF( + Fields!Ret002BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!Ret002TipoFactorDR.Value + + + + + + + ImpPagado + + = IIF( + Fields!Ret002BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!Ret002TasaOCuotaDR.Value + + + + + + + ImpPagado + + = IIF( + Fields!Ret002BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!Ret002ImporteDR.Value + + + + + + + ImpPagado + + = IIF( + Fields!Ret002BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + + + + + + + + Textbox85 + + = IIF( + Fields!Ret002BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + + + + + + + + Textbox86 + + = IIF( + Fields!Ret002BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + + + + + + + + + + + + + + true + true + + + + + + + + + + + + + + + + + + 0.07938cm + + + + + true + true + + + + + IEPS + + + + + + + Textbox59 + + = IIF( + Fields!Ret003BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + Retención + + + + + + + Textbox207 + + = IIF( + Fields!Ret003BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!ImpPagado.Value + + + + + + + ImpPagado + + = IIF( + Fields!Ret003BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!Ret003TipoFactorDR.Value + + + + + + + ImpPagado + + = IIF( + Fields!Ret003BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!Ret003TasaOCuotaDR.Value + + + + + + + ImpPagado + + = IIF( + Fields!Ret003BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + =Fields!Ret003ImporteDR.Value + + + + + + + ImpPagado + + = IIF( + Fields!Ret003BaseDR.Value > 0 + ,False,True) + + + + es-MX + + + + + + + + true + true + + + + + + + + + + + + Textbox95 + + = IIF( + Fields!Ret003BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + + + + + + + + Textbox96 + + = IIF( + Fields!Ret003BaseDR.Value > 0 + ,False,True) + + + + + + + + + + + true + true + + + + + + + + + + + + + + + + + + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + After + + + + + + + + + + + + + + + + + DataSet2 + 4.62704cm + 1.55693cm + 20.53139cm + 1 + + + + + + + + + 4.5cm + + + 1.74905cm + + + 1.5cm + + + 2.96606cm + + + 6.82934cm + + + 2.98695cm + + + + + 0.49cm + + + + + true + true + + + + + FECHA Y HORA DE PAGO + + + + + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + MONEDA + + + + + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + TC + + + + + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + CTA ORDENANTE + + + + + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + FORMA DE PAGO + + + + + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + TOTAL DE PAGO + + + + + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + =Fields!FechaPago.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!MonedaP.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!TipoCambioP.Value + + + + + + 2pt + 2pt + 2pt + 2pt + es-MX + + + + + + + + true + true + + + + + =Fields!CtaOrdenante.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!FormaDePagoP.Value + + + + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Monto.Value + + + + + + + Monto + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + es-MX + + + + + + + + 0.6cm + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!CantidadLetra.Value + + + + + + + Textbox53 + + + + #e36c09 + 3pt + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + + + + + + + + + + + + + + + After + + + + + + Before + + + + DataSet1 + 6.51414cm + 1.69cm + 20.5314cm + 2 + + + + + + true + true + + + + + CFDI Relacionados + + + + + + + Textbox5 + 4.01644cm + 0.49cm + 20.5314cm + 3 + + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Datos del Cliente: + + + + + + + + + Cliente + + + + : + + + + =Parameters!Cliente.Value + + + + + + + + + Dirección: + + + + =Parameters!ClienteDireccion.Value + + + + , + + + + =Parameters!ClienteColonia.Value + + + + + + + + + Ciudad: + + + + =Parameters!ClienteCiudad.Value + + + + + + + + + CP: + + + + =Parameters!ClienteCP.Value + + + + + + + + + RFC Ordenante: + + + + + + + + =Parameters!RFCOrdenante.Value + + + + + + + + + = IIF( Parameters!RegimenFiscalCodigo.Value <> "ND-", "<b>Reg. Fiscal:</b> " & Parameters!RegimenFiscalCodigo.Value,"") + HTML + + + + + + + Textbox2 + 0.03528cm + 0.99355in + 5.01932in + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + "Este documento es una representación impresa de un CFDI" + + + + + + + + + Cadena original del complemento de certificación digital del SAT: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =Parameters!UUIDPago.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + + + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + External + =Parameters!QR.Value + FitProportional + 3.3896in + 6.51771in + 1.3in + 1.5in + 7 + + + + + + true + true + + + + + + + + #e36c09 + 2pt + 2pt + 2pt + 2pt + + + + 12.1432cm + + + + + + + + + Folio: + + + + =Parameters!SerieFolio.Value + + + + + + + + + Fecha Timbre: + + + + =Parameters!FechaTimbre.Value + + + + + + + + + + + + + + + + + + Régimen Fiscal: + + + + + + + + + + + + + Regimen General de Ley Personas Morales + + + + + + + Textbox1 + 12.95686cm + 2.84197cm + 7.57454cm + + + White + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Domicilio Fiscal: + + + + + + + + + + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + Embedded + Logo + FitProportional + 2.53cm + 4.13cm + 2 + + + + + + + + + + + 0.45509cm + true + true + + + true + true + + + + + ="Página " & Globals.PageNumber & " de " & Globals.TotalPages + + + + + + + Textbox35 + 17.09769cm + 0.41981cm + 2.94979cm + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Usuario: + + + + + + + + =Parameters!UsuarioImprimio.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Fecha Impresión: + + + + + + + + =Parameters!FechaImpresion.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 27.94cm + 21.59cm + 0.5cm + 0.5cm + 0.5cm + 0.5cm + 1.27cm + + + + + + + Textbox4 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Total + + + + + + + Textbox16 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.42588cm + + + + + true + + + + + =Fields!MetodoPago.Value + + + + + + + MetodoPago + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + + + + + =Fields!Importe.Value + + + + + + + Importe + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + After + + + + + + + DataSet1 + 0.73025cm + 0.06614cm + 0.90467cm + 6.69369cm + + + + + + true + true + + + + + Detalles de Pagos + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + 2.73022cm + + + 10.35439cm + + + 2.28714cm + + + 3.20444cm + + + + + 0.47879cm + + + + + true + true + + + + + Serie Folio + + + + + + + Textbox4 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Nombre Comercial + + + + + + + Textbox16 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Total + + + + + + + Textbox18 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Método de Pago + + + + + + + Textbox20 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.45234cm + + + + + true + + + + + =Fields!SerieFolio.Value + + + + + + + MetodoPago + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + + + + + =Fields!NombreComercial.Value + + + + + + + Importe + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!ImportePagado.Value + + + + + + + ImportePagado + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!MetodoPago.Value + + + + + + + MetodoPago1 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSet2 + 3.73395cm + 0.06614cm + 0.93113cm + 18.57619cm + 2 + + + + + + + + + 2.68035cm + + + 2.97963cm + + + + + 0.47879cm + + + + + true + true + + + + + Resumen + + + + + + + Textbox4 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Total + + + + + + + Textbox16 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.42588cm + + + + + true + + + + + =Fields!Columna.Value + + + + + + + MetodoPago + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + + + + + =Fields!Importe.Value + + + + + + + Importe + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + After + + + + + + + DataSet3 + 0.73025cm + 7.21681cm + 0.90467cm + 5.65998cm + 3 + + + + + + + + + 2.68035cm + + + 2.97963cm + + + + + 0.47879cm + + + + + true + true + + + + + Resumen + + + + + + + Textbox4 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Total + + + + + + + Textbox16 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.42588cm + + + + + true + + + + + =Fields!Columna.Value + + + + + + + MetodoPago + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + + + + + =Fields!Importe.Value + + + + + + + Importe + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + After + + + + + + + DataSet4 + 0.73025cm + 13.18603cm + 0.90467cm + 5.65998cm + 4 + + + + + + true + true + + + + + Ventas + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Cajas + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + 2.73022cm + + + 7.79329cm + + + 2.28714cm + + + + + 0.47879cm + + + + + true + true + + + + + Tipo + + + + + + + Textbox4 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Descripción + + + + + + + Textbox16 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Total + + + + + + + Textbox18 + + + Silver + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.45234cm + + + + + true + + + + + =Fields!TipoMovimiento.Value + + + + + + + MetodoPago + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + + + + + =Fields!Descripcion.Value + + + + + + + Importe + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Importe.Value + + + + + + + ImportePagado + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSet5 + 2.73226cm + 0.06614cm + 0.93113cm + 12.81065cm + 7 + + + + + + true + true + + + + + Ingresos/Retiros + + + + + + 2pt + 2pt + 2pt + 2pt + + + + 1.83665in + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + REPORTE DE CORTES + + + + + + + Textbox2 + 1.10271cm + 5.07342cm + 0.52945cm + 10.36447cm + 1 + + + 2pt + 2pt + 2pt + 2pt + + + + External + =Parameters!LogoPath.Value + FitProportional + 0.06614cm + 2.22362cm + 2.33715cm + 2 + + + + + + true + true + + + + + =Parameters!AgrupoPor.Value + HTML + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + 0.68792cm + true + true + + + true + true + + + + + ="Página " & Globals.PageNumber & " de " & Globals.TotalPages + + + + + + + Textbox3 + 0.0829cm + 15.43789cm + 0.38981cm + 3.20444cm + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Usuario: + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!UsuarioImprimio.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Fecha Impresión: + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!FechaImpresion.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 27.94cm + 21.59cm + 0.5cm + 0.5cm + 0.3cm + 0.5cm + 0.13cm + + + + + + + Textbox9 + + + + DimGray + + 1pt + + + DimGray + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + @@ -346,6 +393,49 @@ + + + + true + true + + + + + =Fields!TipoPago.Value + + + + + + + TipoPago + + + + DimGray + + 1pt + + + DimGray + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + @@ -401,6 +491,7 @@ + @@ -415,9 +506,9 @@ DataSet1 - 1.43975in + 1.6342in 0.43in - 7.75822in + 7.89455in @@ -670,8 +761,8 @@ Textbox2 - 4.74917cm - 15.02042cm + 5.31361cm + 15.35404cm 0.6cm 2.53175cm 7 @@ -704,8 +795,8 @@ Textbox4 - 4.74917cm - 17.56276cm + 5.31361cm + 17.89638cm 0.6cm 2.14313cm 8 @@ -876,11 +967,99 @@ 2pt + + true + true + + + + + Tipo Pago: + + + + + + + + + + + + + + + + Textbox12 + 3.44148cm + 0.12912cm + 0.53299cm + 3.12013cm + 13 + + =(Parameters!TipoPago.Value = "") + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!TipoPago.Value + + + + + + + Textbox12 + 3.44148cm + 3.28453cm + 0.53299cm + 3.76632cm + 14 + + + 2pt + 2pt + 2pt + 2pt + + - 5.34917cm + 6.09cm --%> + +
    + + diff --git a/Ventas/CatMedicos.aspx.vb b/Ventas/CatMedicos.aspx.vb index 25f8a783f..b1fa46788 100644 --- a/Ventas/CatMedicos.aspx.vb +++ b/Ventas/CatMedicos.aspx.vb @@ -2,7 +2,6 @@ Option Strict On Imports Extensiones -Imports Microsoft.Extensions.Primitives Partial Class Ventas_CatMedicos Inherits ClsPaginas @@ -170,7 +169,7 @@ Partial Class Ventas_CatMedicos AddMedicoControl.CveMedico = -1 AddMedicoControl.LimpiarControles() UpModalAddMedico.Update() - RegistraScript("$('#DvModalAddMedico').modal();") + RegistraScript("$('#DvModalAddMedico').modal({ backdrop: 'static', keyboard: false });") End Sub Public Sub Edit_Click(sender As Object, e As EventArgs) @@ -179,10 +178,12 @@ Partial Class Ventas_CatMedicos CveMedico = GvRow.DataKey("CveMedico").ToEntero - AddMedicoControl.PreparaEdicion(CveMedico, GvRow.DataKey("Medico"), GvRow.DataKey("CedulaProfesional"), GvRow.DataKey("FechaNacimiento").ToDate(), GvRow.DataKey("Notas"), GvRow.DataKey("DiasAtencion"), - GvRow.DataKey("Horario"), GvRow.DataKey("Lugar"), GvRow.DataKey("Consultorio"), Boolean.Parse(GvRow.DataKey("Estatus")), GvRow.DataKey("Mail"), GvRow.DataKey("Telefono"), - GvRow.DataKey("Celular"), GvRow.DataKey("CveMedicoEspecialidad").ToEntero, GvRow.DataKey("CveMedicoSubEspecialidad").ToEntero, GvRow.DataKey("Torre"), - GvRow.DataKey("FechaIng").ToDateTime, GvRow.DataKey("Usuario")) + AddMedicoControl.PreparaEdicion(CveMedico, GvRow.DataKey("Nombre"), GvRow.DataKey("Apellidos"), GvRow.DataKey("CedulaProfesional"), GvRow.DataKey("FechaNacimiento").ToDate(), GvRow.DataKey("Notas"), + Boolean.Parse(GvRow.DataKey("Estatus")), GvRow.DataKey("Mail"), GvRow.DataKey("Telefono"), GvRow.DataKey("Celular"), GvRow.DataKey("CveMedicoEspecialidad").ToEntero, GvRow.DataKey("CveMedicoSubEspecialidad").ToEntero, + GvRow.DataKey("FechaIng").ToDateTime, GvRow.DataKey("Usuario"), GvRow.DataKey("CveVendedor").ToEntero) + + + 'TxtMedico.Text = GvRow.DataKey("Medico") @@ -213,7 +214,7 @@ Partial Class Ventas_CatMedicos 'UpModal.Update() UpModalAddMedico.Update() - RegistraScript("$('#DvModalAddMedico').modal();") + RegistraScript("$('#DvModalAddMedico').modal({ backdrop: 'static', keyboard: false });") End Sub diff --git a/Ventas/CatPS.aspx b/Ventas/CatPS.aspx index 61512bfa9..54ae45b71 100644 --- a/Ventas/CatPS.aspx +++ b/Ventas/CatPS.aspx @@ -189,13 +189,18 @@
    -
    +
    + +
    + + +
    diff --git a/Ventas/CatPS.aspx.vb b/Ventas/CatPS.aspx.vb index aa09a535e..4b8a2f3dd 100644 --- a/Ventas/CatPS.aspx.vb +++ b/Ventas/CatPS.aspx.vb @@ -58,6 +58,10 @@ Partial Class CatPS Ddlclasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(String.Format(" (UsoClasificacion = {0} OR {0} = -1)", DdlTipoClasificacion.SelectedValue)) Ddlclasificacion.DataBind() Ddlclasificacion.Items.Insert(0, New ListItem("Todos", "-1")) + + DdlMarcas.DataSource = GlobalDTGralMarcas(UsuarioActual.CveEmpresa) + DdlMarcas.DataBind() + DdlMarcas.Items.Insert(0, New ListItem("Todos", "-1")) End Sub Public Sub CargaDatos() @@ -70,7 +74,12 @@ Partial Class CatPS If TxtNombre.Text.Trim = "" Then Nombre = "-1" Else Nombre = TxtNombre.Text.ToUpper.Trim Dim ObjPS As New ClsProductosServicios - If ObjPS.GetPSLite(Ddlclasificacion.SelectedValue.ToEntero, UsuarioActual.Empresa.CveEmpresa, Codigo, CodigoBarras, Nombre, DdlAplicaVenta.SelectedValue.ToEntero, DdlEstado.SelectedValue.ToEntero, DdlCveTipoPS.SelectedValue.ToEntero, DdlTipoClasificacion.SelectedValue.ToEntero) Then + If ObjPS.GetPSLite(Ddlclasificacion.SelectedValue.ToEntero, UsuarioActual.Empresa.CveEmpresa, Codigo, CodigoBarras, Nombre, + pAplicaParaVenta:=DdlAplicaVenta.SelectedValue.ToEntero, + pEstado:=DdlEstado.SelectedValue.ToEntero, + CveTipoPS:=DdlCveTipoPS.SelectedValue.ToEntero, + UsoClasificacion:=DdlTipoClasificacion.SelectedValue.ToEntero, + CveMarca:=DdlMarcas.SelectedValue.ToEntero) Then DtDatos = ObjPS.DtResultados GvDatos.DataSource = DtDatos Else diff --git a/Ventas/CatPreciosLista.aspx b/Ventas/CatPreciosLista.aspx index 15b3eb16f..d694e50f9 100644 --- a/Ventas/CatPreciosLista.aspx +++ b/Ventas/CatPreciosLista.aspx @@ -30,11 +30,16 @@ - + + + + + + diff --git a/Ventas/Clientes.aspx b/Ventas/Clientes.aspx index 347109d9d..615d5941e 100644 --- a/Ventas/Clientes.aspx +++ b/Ventas/Clientes.aspx @@ -1461,6 +1461,7 @@ + diff --git a/Ventas/Clientes.aspx.vb b/Ventas/Clientes.aspx.vb index 34288b8e0..758792a55 100644 --- a/Ventas/Clientes.aspx.vb +++ b/Ventas/Clientes.aspx.vb @@ -723,20 +723,18 @@ Partial Class Clientes TabCuentasEquipos.Visible = True End If - If UsuarioActual.Empresa.Funcionalidad(504).ToEntero() > 0 Then - If UsuarioActual.TienePermisoProceso(162) Then - ChkPermiteCredito.Enabled = True - TxtLimiteCreditoSucursal.Enabled = True - TxtFechaLimiteCredito.Enabled = True - Else - ChkPermiteCredito.Enabled = False - TxtLimiteCreditoSucursal.Enabled = False - TxtFechaLimiteCredito.Enabled = False - End If - ChkEstado.Enabled = False - If UsuarioActual.TienePermisoProceso(180) Then - ChkEstado.Enabled = True - End If + If UsuarioActual.TienePermisoProceso(162) Then + ChkPermiteCredito.Enabled = True + TxtLimiteCreditoSucursal.Enabled = True + TxtFechaLimiteCredito.Enabled = True + Else + ChkPermiteCredito.Enabled = False + TxtLimiteCreditoSucursal.Enabled = False + TxtFechaLimiteCredito.Enabled = False + End If + ChkEstado.Enabled = False + If UsuarioActual.TienePermisoProceso(180) Then + ChkEstado.Enabled = True End If If UsuarioActual.Empresa.Funcionalidad(579) = "1" Then @@ -922,12 +920,18 @@ Partial Class Clientes LnkAgregarLineaAdicional.Visible = True GetLineasAdicionales() End If + + If UsuarioActual.Empresa.Funcionalidad(109) <> "1" Then + If RblTipo.Items.FindByValue("RNC") IsNot Nothing Then + RblTipo.Items.Remove(RblTipo.Items.FindByValue("RNC")) + End If + End If + + ChkPermiso4.Enabled = False + ChkPermiso5.Enabled = False + ChkPermiso6.Enabled = False End If - 'EN SERIO SE OCUPA EN CADA POSTBACK ??? IPP 7 SEPTIEMNRE 2017 - ChkPermiso4.Enabled = False - ChkPermiso5.Enabled = False - ChkPermiso6.Enabled = False End Sub @@ -1224,7 +1228,8 @@ Partial Class Clientes End Sub Private Sub CargaPrecioLista() 'SI NO TIENE LA FUNCIONALIDAD DE LISTA DE PRECIOS - If Not GlobalDTPrecioListas(UsuarioActual.CveEmpresa).Rows.Count > 0 Then + Dim dtt As DataTable = GlobalDTPrecioListas(UsuarioActual.CveEmpresa) + If dtt Is Nothing OrElse dtt.Rows.Count = 0 Then DdlSubProyecto.AutoPostBack = False DivPrecioLista.Visible = False End If @@ -3171,6 +3176,8 @@ Partial Class Clientes ObjCliente.Dispose() + GlobalDTClientesSucursales(UsuarioActual.CveEmpresa, CveCliente) = Nothing + Else AddSucursalTemp() End If @@ -3185,8 +3192,9 @@ Partial Class Clientes Me.Actualizar = False Me.CveClienteSuc = -1 - RegistraScript("hideDivEC();") - + RegistraScript("hideDivEC();") + + End Sub Protected Sub LnkAgragarDireccion_Click(sender As Object, e As EventArgs) @@ -3227,6 +3235,8 @@ Partial Class Clientes GVSucursales.EditIndex = -1 ViewState("DTSucursalesCliente") = ObjCliente.DtResultados Alert("La Sucursal del Cliente se eliminó correctamente.", TipoMensaje.MsgInformacion) + + GlobalDTClientesSucursales(UsuarioActual.CveEmpresa, CveCliente) = Nothing End If Else TempDTSucursales.Rows.RemoveAt(e.RowIndex) diff --git a/Ventas/FacturacionGlobal.aspx b/Ventas/FacturacionGlobal.aspx index ff74a30ee..60028d4a4 100644 --- a/Ventas/FacturacionGlobal.aspx +++ b/Ventas/FacturacionGlobal.aspx @@ -203,6 +203,7 @@ + diff --git a/Ventas/FacturacionGlobal.aspx.vb b/Ventas/FacturacionGlobal.aspx.vb index 18ff563b0..fc174e83d 100644 --- a/Ventas/FacturacionGlobal.aspx.vb +++ b/Ventas/FacturacionGlobal.aspx.vb @@ -106,7 +106,11 @@ Partial Class Ventas_FacturacionGlobal Public Sub CargaDatos() Me.CveSubProyecto = -1 - Dim CveCliente As Integer = UsuarioActual.Empresa.Funcionalidad(714).ToEntero() + If UsuarioActual.CveRol = 1 Then + GvDatos.Columns(7).Visible = True + End If + + Dim CveCliente As Integer = -1 'UsuarioActual.Empresa.Funcionalidad(714).ToEntero() Dim FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim(), "-1") Dim FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim(), "-1") @@ -148,7 +152,7 @@ Partial Class Ventas_FacturacionGlobal End Sub Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) - Dim CveCliente As Integer = UsuarioActual.Empresa.Funcionalidad(714).ToEntero() + Dim CveCliente As Integer = -1 'UsuarioActual.Empresa.Funcionalidad(714).ToEntero() Dim CveMoneda As Integer = 1 Dim SbRemisiones As New StringBuilder() @@ -171,7 +175,7 @@ Partial Class Ventas_FacturacionGlobal SbRemisiones.Remove(SbRemisiones.Length - 1, 1) Dim DtRemisionesPS As New DataTable() - Dim DtPagos As New DataTable() + Dim DtPagosFacturaGlobal As New DataTable() Dim ObjClientes As New ClsClientes If ObjClientes.GetVentasRemisionesTotales(CveCliente, SbRemisiones.ToString(), 1) Then @@ -179,7 +183,7 @@ Partial Class Ventas_FacturacionGlobal End If If ObjClientes.GetVentasRemisionesPagos(CveCliente, SbRemisiones.ToString()) Then - DtPagos = ObjClientes.DtResultados.Copy() + DtPagosFacturaGlobal = ObjClientes.DtResultados.Copy() End If ObjClientes.Dispose() @@ -188,7 +192,7 @@ Partial Class Ventas_FacturacionGlobal Exit Sub End If - If DtPagos Is Nothing OrElse DtPagos.Rows.Count = 0 Then + If DtPagosFacturaGlobal Is Nothing OrElse DtPagosFacturaGlobal.Rows.Count = 0 Then Alert("No se pudieron cargar los pagos", TipoMensaje.MsgError) Exit Sub End If @@ -198,6 +202,7 @@ Partial Class Ventas_FacturacionGlobal Exit Sub End If + CveCliente = UsuarioActual.Empresa.Funcionalidad(714).ToEntero() If CveCliente <= 0 Then Alert("No se pudo cargar el cliente", TipoMensaje.MsgError) Exit Sub @@ -211,18 +216,24 @@ Partial Class Ventas_FacturacionGlobal ObjFactura.RemisionesLista = RemisionesLista ObjFactura.DtRemisionesPS = DtRemisionesPS ObjFactura.DtRemisiones = DtRemisiones.FiltraParametros($"CveVenta IN ({SbRemisiones.ToString()})") - ObjFactura.DtPagos = DtPagos + ObjFactura.DtPagosFacturaGlobal = DtPagosFacturaGlobal - For Each Dr As DataRow In DtRemisionesPS.Rows + For Each Dr As DataRow In ObjFactura.DtRemisionesPS.Rows ObjFactura.AgregarPS(Dr("CvePS").ToString().ToEntero(), Dr("Cantidad").ToString().ToDecimal(), Dr("PU").ToString().ToDecimal(), Dr("Descuento").ToString().ToDecimal, Dr("Obs").ToString(), CveUM:=Dr("CveUM").ToString().ToEntero(), CveProyecto:=Dr("CveProyecto").ToString().ToEntero(), CveSubProyecto:=Dr("CveSubProyecto").ToString().ToEntero(), CveVentaDetallePadre:=Dr("CveVentaDetalle").ToString().ToEntero(), CveVentaDetalleRemision:=Dr("CveVentaDetalle").ToString().ToEntero()) Next ObjFactura.CalculaTotales() + + 'DEBE ESTAR DENTRO DE LA CLASE, COMENTAR UNA VEZ SE HAYA HECHO EL CAMBIO + 'If ObjFactura.Descuento > 0 Then + ' ObjFactura.Total = ObjFactura.Total - ObjFactura.Descuento + 'End If + ObjFactura.PreparaTimbre() - If ObjFactura.Total <> DtPagos.SUMD("Importe") Then - Alert("Los pagos no coinciden con el total de la factura", TipoMensaje.MsgError) + If Math.Abs(ObjFactura.Total.RoundSQL(2) - DtPagosFacturaGlobal.SUMD("Importe").RoundSQL(2)) > 0.1 Then + Alert($"Los pagos no coinciden con el total de la factura [{ObjFactura.Total.RoundSQL(2)}-{ DtPagosFacturaGlobal.SUMD("Importe").RoundSQL(2)}]", TipoMensaje.MsgError) Exit Sub End If diff --git a/Ventas/PV.aspx.vb b/Ventas/PV.aspx.vb index dcf8f8b3d..d22776991 100644 --- a/Ventas/PV.aspx.vb +++ b/Ventas/PV.aspx.vb @@ -3466,7 +3466,7 @@ Partial Class PV Dim SbAlert As New StringBuilder Try - Retorno = ObjFactura.EmitirFactura(Transac:=ObjAcum.IniciaTransacSQL()) + Retorno = ObjFactura.EmitirFactura(Transac:=ObjAcum.IniciaTransacSQL(), Modulo:="PV/GuardarVenta") If Retorno IsNot Nothing AndAlso Retorno.CveVenta > 0 Then @@ -7378,8 +7378,8 @@ Partial Class PV Dim strDate As Date = ($"20{TxtEtiqueta.Text.Substring(2, 2)}/{TxtEtiqueta.Text.Substring(0, 2)}/01").ToDate Dim drg As DataRow = dtt.FiltroPrimero($" #{strDate.ToString("yyyy/MM/dd")}# >= FechaInicioVigencia ", "FechaInicioVigencia DESC") If drg IsNot Nothing Then - - TxtPorcentajeAjuste.Text = (drg("Valor").ToString.ToDouble / 100).ToString + Dim PorcentajeAjuste As Decimal = drg("Valor").ToString.ToDecimal + TxtPorcentajeAjuste.Text = (PorcentajeAjuste / 100).ToString TxtImporteAjuste.Text = (TxtPorcentajeAjuste.Text.ToDecimal * TxtPUFactura.Text.ToDecimal).FormatoNumero ImportePagarCliente = TxtImporteAjuste.Text.ToDecimal @@ -7441,6 +7441,7 @@ Partial Class PV Alert("Especificar el producto a recibir") End If End If + Catch ex As Exception OnError("Ocurrió un error al recalcular el costo", ex) End Try @@ -7545,7 +7546,7 @@ Partial Class PV Dr("Descuento") = Math.Round(TxtImporteAjuste.Text.ToDouble, NumeroDecimales) 'Dr("Descuento") = Math.Round((TxtPrecio.Text.ToDouble - TxtImporteAjuste.Text.ToDouble) + (CargoActual - CargoAnterior), NumeroDecimales) - If Dr("Descuento").ToString.ToDouble > TxtPrecio.Text.ToDouble Then Dr("Descuento") = TxtPrecio.Text.ToDouble + If Dr("Descuento").ToString.ToDouble >= TxtPrecio.Text.ToDouble Then Dr("Descuento") = TxtPrecio.Text.ToDouble - 0.01D Dim TotalCalculableImpuestos As Decimal = (Dr("Cantidad").ToString.ToDecimal * (Dr("PU").ToString.ToDecimal)) - Dr("Descuento").ToString.ToDecimal Dr("ImporteIVA") = Math.Round(Dr("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) diff --git a/Ventas/PVCobranza.aspx b/Ventas/PVCobranza.aspx index bc89fc143..2217a2461 100644 --- a/Ventas/PVCobranza.aspx +++ b/Ventas/PVCobranza.aspx @@ -270,222 +270,287 @@ + + -
    - - -
    - Turno: - -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - -
    -
    - -
    -
    -
    -
    Nombre:
    -
             
    - - -
    -
    -
    -
    +
    +
    + + +
    + Turno: +
    -
    -
    -
    + + +
    +
    +
    + + + + + + + + + +   + + + + + +
    +
    + +
    +
    +
    +
    Nombre:
    +
             
    -
    -
    -
    -
    - -
    - $ - - -
    -
    - - - +
    Folio:
    +
      
    + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    + $ + + +
    +
    + + + +
    -
    -
    -
    - -
    - $ - - -
    -
    - - - -
    -
    - - MSI - 3M - 6M - 9M - 12M - - <%-- - --%> +
    +
    + +
    + $ + + +
    +
    + + + +
    +
    + + MSI + 3M + 6M + 9M + 12M + + <%-- + --%> +
    -
    -
    -
    - -
    - $ - - -
    -
    - - - +
    +
    + +
    + $ + + +
    +
    + + + +
    -
    -
    -
    - -
    - $ - - -
    -
    - - - +
    +
    + +
    + $ + + +
    +
    + + + +
    -
    -
    -
    - -
    - $ - - -
    -
    - - - +
    +
    + +
    + $ + + +
    +
    + + + +
    -
    -
    -
    +
    +
    -
    - - Otros - Credito - Debito - Cheque - -
    +
    + + Otros + Credito + Debito + Cheque + +
    -
    - $ - - -
    +
    + $ + + +
    -
    - - - -
    +
    + + + +
    -
    - - Meses - 3M - 6M - 9M - 12M - -
    +
    + + Meses + 3M + 6M + 9M + 12M + +
    -
    -
    - -
    -
    - -
    - $ - - - -
    - -
    - $ - - -
    -
    -
    - - - + +
    +
    + +
    + $ + + + +
    + +
    + $ + + +
    +
    +
    +
    +
    + + + +
    -
    - + +
    +
    +
    +
    + + + + + + Serie - Folio + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + + + + + + + + + + + @@ -813,6 +959,11 @@ function impresionDirecta(urlPDF) { printJS({ printable: urlPDF, type: 'pdf', showModal: true }); } + + function impresionBase64(pdfBase64) { + printJS({ printable: pdfBase64, type: 'pdf', showModal: true, base64: true }); + } + function CalculaTotalPagoContado() { debugger; var totalEfectivo = ToDouble($get("TxtImporteEfectivo").value); @@ -850,5 +1001,8 @@ $('#C_LblDiferenciaCajaBloqueo').val(FormatoNumero(total)); } + + + diff --git a/Ventas/PVCobranza.aspx.vb b/Ventas/PVCobranza.aspx.vb index 2da8d426b..eef0ecab6 100644 --- a/Ventas/PVCobranza.aspx.vb +++ b/Ventas/PVCobranza.aspx.vb @@ -2,6 +2,7 @@ Option Strict On Imports System.Data +Imports System.IO Imports Extensiones Partial Class Ventas_PVCobranza @@ -16,6 +17,8 @@ Partial Class Ventas_PVCobranza End Set End Property + + Private Property DineroCaja As Double Get Return If(IsNothing(ViewState("DineroCaja")), 0, ViewState("DineroCaja").ToString().ToDecimal()) @@ -23,12 +26,51 @@ Partial Class Ventas_PVCobranza Set(value As Double) ViewState("DineroCaja") = value End Set + End Property + + Private Property CveIE As Integer + Get + If ViewState("CveIE") Is Nothing Then + ViewState("CveIE") = -1 + End If + Return ViewState("CveIE").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveIE") = value + End Set + End Property + + Private Property CveTipoTransaccionOriginal As Integer + Get + If ViewState("CveTipoTransaccionOriginal") Is Nothing Then + ViewState("CveTipoTransaccionOriginal") = -1 + End If + Return ViewState("CveTipoTransaccionOriginal").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveTipoTransaccionOriginal") = value + End Set + End Property + + Private Property DtCortesVentas As DataTable + Get + + If ViewState("DtCortesVentas") Is Nothing Then + ViewState("DtCortesVentas") = New DataTable + End If + Return CType(ViewState("DtCortesVentas"), DataTable) + + End Get + Set(value As DataTable) + ViewState("DtCortesVentas") = value + End Set End Property Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then CveCorte = 0 CargaFiltros() + CargaDdlPagos() If UsuarioActual.TienePermisoProceso(371) Then CargaCorteCaja() End If @@ -54,8 +96,8 @@ Partial Class Ventas_PVCobranza 'MOSTRAR SOLO CUENTAS DE CONTADO EN BDH 'If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then - DdlCuentaEfectivo.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta = 1 AND TieneTerminal = 0", CveMon)) - DdlCuentaCheque.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta = 1 AND TieneTerminal = 0", CveMon)) + DdlCuentaEfectivo.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta = 1", CveMon)) + DdlCuentaCheque.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta = 1", CveMon)) 'If UsuarioActual.Empresa.Funcionalidad(558) = "1" OrElse UsuarioActual.Empresa.Funcionalidad(531) = "1" Then @@ -71,6 +113,14 @@ Partial Class Ventas_PVCobranza DdlCuentaCheque.DataBind() DdlCuentaTransferencia.DataBind() + DdlCuentaGastoOrigen.DataSource = DtCC.FiltraParametros("CveMoneda = 1 AND CveTipoCuenta = 1") + DdlCuentaGastoOrigen.DataBind() + DdlCuentaGastoOrigen.Items.Insert(0, New ListItem("Seleccione", "-1")) + + DdlCuentaGastoDestino.DataSource = DtCC.FiltraParametros("CveMoneda = 1 AND CveTipoCuenta = 1") + DdlCuentaGastoDestino.DataBind() + DdlCuentaGastoDestino.Items.Insert(0, New ListItem("Seleccione", "-1")) + TxtImporteEfectivo.Attributes.Add("onKeyUp", "CalculaTotalPagoContado();") TxtImporteCredito.Attributes.Add("onKeyUp", "CalculaTotalPagoContado();") TxtImporteDebito.Attributes.Add("onKeyUp", "CalculaTotalPagoContado();") @@ -209,18 +259,36 @@ Partial Class Ventas_PVCobranza TxtImporteOtrosContado.Text = "" TxtCambio.Text = "" - End Sub - - Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click - CargaDatos() - End Sub - + End Sub + + + Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click + + If ChkMostrarSoloPagados.Checked Then + DVCobraza.Visible = False + DVPagado.Visible = True + CargaDatosPagos() + Else + DVCobraza.Visible = True + DVPagado.Visible = False + CargaDatos() + End If + + End Sub + + + Private Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.DBCampo("CveUsuarioCobranza") <> "" Then - e.Row.BackColor = Drawing.ColorTranslator.FromHtml("#3598dc") - 'e.Row.CssClass = "blue-madison" + e.Row.BackColor = Drawing.ColorTranslator.FromHtml("#3598dc") + 'e.Row.CssClass = "blue-madison" + End If + + If e.Row.DBCampo("CveCondicionEntrega").ToEntero() = 9 Then + e.Row.FCLinkButton("LnkImprimir").Visible = True + ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FCLinkButton("LnkImprimir")) End If End If End Sub @@ -240,11 +308,29 @@ Partial Class Ventas_PVCobranza TieneError = True End If HdnCveVenta.Value = CveVenta.ToString - TxtImporteEfectivo.Text = GvRow.DataKey("Saldo").FormatoNumero + + 'según la forma de pago va a establecer el valor para pago. + Select Case GvRow.DataKey("CveFormaPago33") + Case "1" + TxtImporteEfectivo.Text = GvRow.DataKey("Saldo").FormatoNumero + Case "2" + TxtImporteCheque.Text = GvRow.DataKey("Saldo").FormatoNumero + Case "3" + TxtImporteTransferencia.Text = GvRow.DataKey("Saldo").FormatoNumero + Case "4" + TxtImporteCredito.Text = GvRow.DataKey("Saldo").FormatoNumero + Case "18" + TxtImporteDebito.Text = GvRow.DataKey("Saldo").FormatoNumero + Case Else + TxtImporteEfectivo.Text = GvRow.DataKey("Saldo").FormatoNumero + End Select + + TxtImporteContado.Text = GvRow.DataKey("Saldo").FormatoNumero HdnTotal.Value = GvRow.DataKey("Saldo") TxtImporteEfectivo.Focus() LtlNombre.Text = GvRow.DataKey("AtencionA") + LtlFolio.Text = GvRow.DataKey("SerieFolio") LtlSaldo.Text = GvRow.DataKey("Saldo").ToDecimal.FormatoNumero Catch ex As Exception TieneError = True @@ -270,11 +356,24 @@ Partial Class Ventas_PVCobranza 'registrar pago 'validaciones - If TxtImporteEfectivo.Text.ToDecimal + TxtImporteCredito.Text.ToDecimal + TxtImporteDebito.Text.ToDecimal + TxtImporteCheque.Text.ToDecimal = 0 Then - Alert("Favor de especificar importe", TipoMensaje.ToastAdventencia) + Dim Pagado As Decimal = TxtImporteEfectivo.Text.ToDecimal + TxtImporteCredito.Text.ToDecimal + TxtImporteDebito.Text.ToDecimal + TxtImporteCheque.Text.ToDecimal + TxtImporteTransferencia.Text.ToDecimal + If Pagado = 0 Then + Alert("Favor de especificar importe", TipoMensaje.MsgAdvertencia) Exit Sub End If + If LtlSaldo.Text.ToDecimal() > Pagado Then + Alert("Favor de especificar el saldo total de pagar", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + Dim PagadoSinEfectivo As Decimal = Pagado - TxtImporteEfectivo.Text.ToDecimal + + If PagadoSinEfectivo > LtlSaldo.Text.ToDecimal() Then + Alert("El pago con los metodos de pago actuales no puede ser mayor al importe de la venta", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero Dim DbRowVenta As DataRow = Nothing @@ -306,41 +405,61 @@ Partial Class Ventas_PVCobranza Dim CvePrePoliza As Integer Dim Fecha As Date = NowADS() - Dim PagoEfectivo As Decimal = TxtImporteEfectivo.Text.ToDecimal + Dim MsgError As String = "" - Dim SaldoPendiente As Decimal = VentaActual.Total + Dim SaldoPendiente As Decimal = DbRowVenta("Saldo").ToString.ToDecimal + Dim SaldoTotalInicial As Decimal = DbRowVenta("Saldo").ToString.ToDecimal + Dim PagoAplicado As Decimal = 0 Dim ObjConta As New ClsContabilidad Dim ObjIE As New ClsBancos(ObjConta.IniciaTransacSQL()) Dim ObjVentas2 As New ClsVentas(ObjConta.IniciaTransacSQL()) Try - CvePrePoliza = ObjConta.AddPrePolizas("PVCobranza", 5, 0, 0, 1, Fecha, $"Pago {VentaActual.SerieFolio}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + CvePrePoliza = ObjConta.AddPrePolizas("PVCobranza", 11, 0, 0, 1, Fecha, $"Pago {VentaActual.SerieFolio}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=3) If CvePrePoliza > 0 Then - If PagoEfectivo > 0 Then - If PagoEfectivo > VentaActual.Total Then - TxtCambio.Text = (VentaActual.Total - PagoEfectivo).FormatoNumero - PagoEfectivo = VentaActual.Total - End If - MsgError = RegistraIE(13, DdlCuentaEfectivo.SelectedValue.ToEntero, PagoEfectivo, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta, ObjVentas2) - End If - SaldoPendiente -= PagoEfectivo - If SaldoPendiente > 0 AndAlso TxtImporteCredito.Text.ToDecimal > 0 Then + If MsgError = "" AndAlso SaldoPendiente > 0 AndAlso TxtImporteCredito.Text.ToDecimal > 0 Then MsgError = RegistraIE(12, DdlCuentaTarjetaCredito.SelectedValue.ToEntero, TxtImporteCredito.Text.ToDecimal, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta, ObjVentas2) - PagoEfectivo = TxtImporteCredito.Text.ToDecimal - End If - SaldoPendiente -= PagoEfectivo - If SaldoPendiente > 0 AndAlso TxtImporteDebito.Text.ToDecimal > 0 Then - MsgError = RegistraIE(11, DdlCuentaTarjetaDebito.SelectedValue.ToEntero, TxtImporteDebito.Text.ToDecimal, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta, ObjVentas2) - PagoEfectivo = TxtImporteDebito.Text.ToDecimal - End If - If SaldoPendiente > 0 AndAlso TxtImporteCheque.Text.ToDecimal > 0 Then - MsgError = RegistraIE(3, DdlCuentaCheque.SelectedValue.ToEntero, TxtImporteCheque.Text.ToDecimal, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta, ObjVentas2) - PagoEfectivo = TxtImporteCheque.Text.ToDecimal + SaldoPendiente -= TxtImporteCredito.Text.ToDecimal + PagoAplicado += TxtImporteCredito.Text.ToDecimal End If - If Not ObjVentas2.UpdateVentaCorte(CveVenta, UsuarioActual.CveEmpresa, CveCorte) Then + If MsgError = "" AndAlso SaldoPendiente > 0 AndAlso TxtImporteDebito.Text.ToDecimal > 0 Then + MsgError = RegistraIE(11, DdlCuentaTarjetaDebito.SelectedValue.ToEntero, TxtImporteDebito.Text.ToDecimal, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta, ObjVentas2) + SaldoPendiente -= TxtImporteDebito.Text.ToDecimal + PagoAplicado += TxtImporteDebito.Text.ToDecimal + End If + + If SaldoPendiente > 0 AndAlso TxtImporteCheque.Text.ToDecimal > 0 Then + MsgError = RegistraIE(3, DdlCuentaCheque.SelectedValue.ToEntero, TxtImporteCheque.Text.ToDecimal, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta, ObjVentas2) + SaldoPendiente -= TxtImporteCheque.Text.ToDecimal + PagoAplicado += TxtImporteCheque.Text.ToDecimal + End If + + If MsgError = "" AndAlso SaldoPendiente > 0 AndAlso TxtImporteTransferencia.Text.ToDecimal > 0 Then + MsgError = RegistraIE(8, DdlCuentaTransferencia.SelectedValue.ToEntero, TxtImporteTransferencia.Text.ToDecimal, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta, ObjVentas2) + SaldoPendiente -= TxtImporteTransferencia.Text.ToDecimal + PagoAplicado += TxtImporteTransferencia.Text.ToDecimal + End If + + If MsgError = "" AndAlso SaldoPendiente > 0 AndAlso TxtImporteEfectivo.Text.ToDecimal > 0 Then + Dim PagoEfectivo As Decimal = TxtImporteEfectivo.Text.ToDecimal + + PagoAplicado += PagoEfectivo + If PagoAplicado >= SaldoTotalInicial Then + TxtCambio.Text = (PagoAplicado - SaldoTotalInicial).FormatoNumero + PagoEfectivo = SaldoPendiente + End If + MsgError = RegistraIE(13, DdlCuentaEfectivo.SelectedValue.ToEntero, PagoEfectivo, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta, ObjVentas2) + SaldoPendiente -= PagoEfectivo + End If + + If SaldoPendiente > 0 Then + MsgError = "Tiene saldo pendiente por aplicar" + End If + + If MsgError = "" AndAlso Not ObjVentas2.UpdateVentaCorte(CveVenta, UsuarioActual.CveEmpresa, CveCorte) Then MsgError = "Error al aplicar el corte" End If @@ -524,32 +643,115 @@ Partial Class Ventas_PVCobranza End Sub Private Sub BtnAceptarIE_Click(sender As Object, e As EventArgs) Handles BtnAceptarIE.Click - Dim ObjPVenta As New ClsPuntoVenta - If TxtCantidadIE.Text.ToEntero() > 0 Then - If ObjPVenta.AddVta_MovimientosCajas(CveCorte, UsuarioActual.CveUsuario, TxtCantidadIE.Text.ToDouble, TxtDescripcionIE.Text, HdnTipoMovimiento.Value.ToEntero(), NowADS()) Then - TxtCantidadIE.Text = "" - TxtDescripcionIE.Text = "" - RegistraScript("$('#DivIngresoEgreso').modal('hide')", "divingresoegreso") - Alert("El movimiento se realizó correctamente") - UpIngresoEgreso.Update() - End If + If TxtCantidadIE.Text.ToEntero() <= 0 Then + Alert("La cantidad debe ser mayor a 0", TipoMensaje.MsgAdvertencia) + Exit Sub End If + + Dim TieneError As Boolean = False + Dim ObjPVenta As New ClsPuntoVenta + Dim ObjIE As New ClsBancos(ObjPVenta.IniciaTransacSQL()) + Dim ObjMov As New ClsContabilidad(ObjPVenta.IniciaTransacSQL()) + Dim documentos As String = "" + Try + Dim CveMoneda As Integer = 1 + Dim TipoCambio As Decimal = 1D + + Dim Importe As Decimal = TxtCantidadIE.Text.ToDecimal() + If Not ObjPVenta.AddVta_MovimientosCajas(CveCorte, UsuarioActual.CveUsuario, Importe, TxtDescripcionIE.Text, HdnTipoMovimiento.Value.ToEntero(), NowADS()) Then + TieneError = True + End If + + If ChkAplicaGasto.Checked Then + documentos = "Los Depósitos se realizaron exitosamente

    " + + Dim CvePrePoliza = ObjMov.AddPrePolizas("PVCobranza/Gasto ", 23, Importe, Importe, CveMoneda, Now, "Gasto", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + 'TRANSFERENCIA BANCARIA + Dim EsAbonoEnCuenta As Boolean = False + Dim AplicaImpuestos As Boolean = False + Dim FolioOrigen As Long = ObjIE.GetNextFolio(DdlCuentaGastoOrigen.SelectedValue.ToEntero, 2) + Dim FolioDestino As Long = ObjIE.GetNextFolio(DdlCuentaGastoOrigen.SelectedValue.ToEntero, 8) + + Dim CveIEDestino As Integer = -1 + Dim CveIEOrigen = ObjIE.AddBancos_IE(DdlCuentaGastoOrigen.SelectedValue.ToEntero, 2, Now, FolioOrigen.ToString(), "", Importe, CveMoneda, + TipoCambio, TxtDescripcionIE.Text.Trim(), "", EsAbonoEnCuenta, AplicaImpuestos, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCorte:=Me.CveCorte) + + If CveIEOrigen > 0 Then + documentos += String.Format("IE Salida: {1}    
    ", CveIEOrigen, FolioOrigen) + + CveIEDestino = ObjIE.AddBancos_IE(DdlCuentaGastoDestino.SelectedValue.ToEntero, 8, Now, FolioDestino.ToString(), "", Importe, CveMoneda, + TipoCambio, TxtDescripcionIE.Text.Trim(), "", EsAbonoEnCuenta, AplicaImpuestos, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCorte:=Me.CveCorte) + If CveIEDestino > 0 Then + documentos += String.Format("IE Entrada: {1}    
    ", CveIEDestino, FolioDestino) + Else + TieneError = True + End If + Else + TieneError = True + End If + + If Not TieneError Then + Dim TipoMovimiento As Boolean = True + + If ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, Importe, Importe, 30, FolioOrigen.ToString(), FolioOrigen.ToString(), CveIE:=CveIEOrigen) Then + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, Importe, Importe, 30, FolioDestino.ToString(), FolioDestino.ToString(), CveIE:=CveIEDestino) Then + TieneError = True + End If + Else + TieneError = True + End If + End If + End If + Catch ex As Exception + TieneError = True + GuardaLog(ex.ToString()) + End Try + + If TieneError Then + documentos = "" + ObjPVenta.RollBack() + Alert("Ocurrió un error al generar el movimiento", TipoMensaje.MsgError) + Else + ObjPVenta.Commit() + End If + ObjPVenta.Dispose() + ObjIE.Dispose() + ObjMov.Dispose() + + If Not TieneError Then + TxtCantidadIE.Text = "" + TxtDescripcionIE.Text = "" + RegistraScript("$('#DivIngresoEgreso').modal('hide')", "divingresoegreso") + + If ChkAplicaGasto.Checked Then + Alert(documentos) + Else + Alert("El movimiento se realizó correctamente") + End If + + End If + + UpIngresoEgreso.Update() End Sub Private Sub ImpresionDirectaPDF(CveVenta As Integer) Dim ObjFactura As New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, CargaDTDetalle:=False, CargaDatosCliente:=False, CargaDatosRelacionados:=False, VerificaAlmacen:=False) Dim ExistePDF As Boolean = False - Dim ArchivoPDF As String = String.Format("{0}/PDF/{1}/{2}.pdf", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio) - - If ObjFactura.TipoDocto = "Rem" AndAlso System.IO.File.Exists(ArchivoPDF) Then + Dim ArchivoPDF As String = "" + If ObjFactura.TipoDocto = "Ing" Then + ArchivoPDF = String.Format("{0}/PDF/{1}/{2}_Ticket.pdf", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio) + Else + ArchivoPDF = String.Format("{0}/PDF/{1}/{2}.pdf", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio) + End If + If File.Exists(ArchivoPDF) AndAlso ObjFactura.TipoDocto = "Rem" Then ExistePDF = True Else 'REGENERAR EL PDF Try GenerarPDFVenta(CveVenta, AplicaPagare:="1", GuardarPDF:=True, RegenerarPDF:=True, DescargarArchivo:=False, EsTicket:=True) - If System.IO.File.Exists(ArchivoPDF) Then + If File.Exists(ArchivoPDF) Then ExistePDF = True End If Catch ex As Exception @@ -558,8 +760,24 @@ Partial Class Ventas_PVCobranza End If If ExistePDF Then - Dim urlPDF As String = $"/Ashx/SIGDesc.ashx?metodo=descargarPDFVenta&CveVenta={CveVenta}" - RegistraScript($"impresionDirecta('{urlPDF}');", "Imprimir") + Dim pdf64 As String = "" + 'DUPLICA EL PDF + Using ms As New MemoryStream + Using pdfdoc As New iText.Kernel.Pdf.PdfDocument(New iText.Kernel.Pdf.PdfWriter(ms)) + pdfdoc.InitializeOutlines() + Dim reporteByte As New MemoryStream(System.IO.File.ReadAllBytes(ArchivoPDF)) + + Dim docPDF As New iText.Kernel.Pdf.PdfDocument(New iText.Kernel.Pdf.PdfReader(reporteByte)) + docPDF.CopyPagesTo(1, docPDF.GetNumberOfPages(), pdfdoc) + docPDF.CopyPagesTo(1, docPDF.GetNumberOfPages(), pdfdoc) + docPDF.Close() + + pdfdoc.Close() + End Using + pdf64 = Convert.ToBase64String(ms.ToArray()) + End Using + + RegistraScript($"impresionBase64('{pdf64}');", "Imprimir") Else Alert("No se pudo imprimir el pdf directamente. favor de descargar manualmente el pdf.", TipoMensaje.MsgAdvertencia) End If @@ -576,4 +794,120 @@ Partial Class Ventas_PVCobranza End If ObjVentas.Dispose() End Sub + Protected Sub LnkImprimir_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 + ImpresionDirectaPDF(CveVenta) + End If + + End Sub + + + +#Region "PAGOS" + + Public Sub CargaDatosPagos() + + Dim FechaI As Date = If(txtFechaI.Text <> "", txtFechaI.Text.ToDate, MinFecha) + Dim FechaF As Date = If(txtFechaF.Text <> "", txtFechaF.Text.ToDate, MaxFecha) + + Dim ObjPuntoVenta As New ClsPuntoVenta + + If ObjPuntoVenta.GetCortesDetalleVentas(CveCorte, DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, 2) Then + GvD.DataSource = ObjPuntoVenta.DtResultados + DtCortesVentas = ObjPuntoVenta.DtResultados + End If + + ObjPuntoVenta.Dispose() + + GvD.DataBind() + UpL.Update() + End Sub + + Protected Sub GvD_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvD.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CveVenta").ToString = "" Then + e.Row.CssClass = "Totales" + End If + If e.Row.DBCampo("ImportePagado").ToDecimal() < 0 Then + e.Row.FCLabel("LblTotal").CssClass = "badge badge-danger" + End If + If e.Row.DataKey("CveIE").ToEntero > 0 Then + e.Row.FCLinkButton("LnkEditarPago").Visible = True + End If + End If + End Sub + + + + Sub CargaDdlPagos() + + DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo='Ing' AND Estatus = 1") + DdlTipoTransaccion.DataBind() + DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1")) + + DdlCuenta.DataSource = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa) + DdlCuenta.DataBind() + DdlCuenta.Items.Insert(0, New ListItem("Seleccione", "-1")) + + End Sub + + Protected Sub LnkEditarPago_Click(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + + + CveIE = GvRow.DataKey("CveIE").ToEntero + CveTipoTransaccionOriginal = GvRow.DataKey("CveTipoTransaccion").ToEntero + + Dim CveTipoTransaccion As Integer = GvRow.DataKey("CveTipoTransaccion").ToEntero + Dim CveCuenta As Integer = GvRow.DataKey("CveCuenta").ToEntero + + LblModalPagoTitulo.Text = $"Editar Pago {GvRow.DataKey("SerieFolio")}" + DdlTipoTransaccion.SelectedValueExist(CveTipoTransaccion) + DdlCuenta.SelectedValueExist(CveCuenta) + + UpModalPago.Update() + + RegistraScript("$('#DVModalPagos').modal('show');") + + End Sub + + + Protected Sub LnkDvModalPagoAceptar_Click(sender As Object, e As EventArgs) + + Dim TieneError As Boolean = False + If CveTipoTransaccionOriginal <> DdlTipoTransaccion.SelectedValue.ToEntero Then + + Dim Folio As Long + Dim objBanco As New ClsBancos + Folio = objBanco.GetNextFolio(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero) + + If Not objBanco.UpdateBancosIECobranza(CveIE, DdlTipoTransaccion.SelectedValue.ToEntero, Folio.ToString, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + TieneError = True + End If + + objBanco.Dispose() + + End If + + If Not TieneError Then + CargaDatosPagos() + Alert("Movimiento actualizado correctamente") + RegistraScript("$('#DVModalPagos').modal('hide');") + End If + + End Sub + + Protected Sub ChkAplicaGasto_CheckedChanged(sender As Object, e As EventArgs) + DivCuentaGasto.Visible = ChkAplicaGasto.Checked + + UpIngresoEgreso.Update() + End Sub + +#End Region + End Class diff --git a/Ventas/PopUpBuscarPs.aspx b/Ventas/PopUpBuscarPs.aspx index 7a4a5260e..2bc29e272 100644 --- a/Ventas/PopUpBuscarPs.aspx +++ b/Ventas/PopUpBuscarPs.aspx @@ -94,14 +94,19 @@
    - - + + - + + + + + +
    @@ -112,8 +117,13 @@ + - + +
    + + + + + <%-- MODAL PS ADICIONALES --%> + + + <%-- MODAL PS ADICIONALES --%> + + + + <%-- FIN MODAL PS ADICIONALES --%> + + + + + + + + + + + + + + + - + + diff --git a/Ventas/ProductosServicios.aspx.vb b/Ventas/ProductosServicios.aspx.vb index 4b87baa9e..e26bd4a02 100644 --- a/Ventas/ProductosServicios.aspx.vb +++ b/Ventas/ProductosServicios.aspx.vb @@ -5,6 +5,7 @@ Imports System.Data Imports System.Data.SqlClient Imports System.IO Imports Extensiones +Imports Microsoft.Reporting.WebForms Imports ZXing Partial Class ProductosyServicios @@ -131,6 +132,15 @@ Partial Class ProductosyServicios ViewState("GeneraServicioAF") = value End Set End Property + + Public Property Imagen As String + Get + Return IfNull(ViewState("Imagen"), "", ViewState("Imagen")).ToString() + End Get + Set(value As String) + ViewState("Imagen") = value + End Set + End Property #End Region Private ReadOnly Property PermiteClasificacion2 As Boolean @@ -951,6 +961,17 @@ Partial Class ProductosyServicios DdlTipoFactor.SelectedValueExist(ObjProductosServicios.DtResultados.Rows(0)("CveTipoFactor").ToString) + Me.Imagen = ObjProductosServicios.DtResultados.Rows(0)("Imagen").ToString + + If Not String.IsNullOrEmpty(Me.Imagen) Then + imgImagen.Attributes.Add("src", String.Format("/ashx/SIGWeb.ashx?Metodo=GetImg&r={0}", Extensiones.Encripta(Me.Imagen))) + hplImagen.Attributes.Add("href", String.Format("/ashx/SIGWeb.ashx?Metodo=GetImg&r={0}", Extensiones.Encripta(Me.Imagen))) + End If + + DivImagen.Visible = True + upGaleria.Update() + RegistraScript("clickgaleria();", "CG") + If ObjProductosServicios.DtResultados.Rows(0)("CveTipoFactor").ToString.Contiene("1", "2") Then LIva.Visible = True DdlIVA.Visible = True @@ -1083,6 +1104,10 @@ Partial Class ProductosyServicios LnkUnificar.Visible = True ChkPrecioLibre.Checked = ObjProductosServicios.PrecioLibre + If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then + LnkGenerarEtiqueta.Visible = True + End If + If UsuarioActual.Empresa.Funcionalidad(143) = "1" Then TxtRegistroRSCO.Text = ObjProductosServicios.DtResultados.Rows(0)("RegistroRSCO").ToString @@ -2203,7 +2228,7 @@ Partial Class ProductosyServicios #Region "Codigo Barras" 'Codigo barras/QR se retorna como una imagen bmp - Private Function GeneraCodigoQR(CodigoBarras As String, Alto As Integer, Largo As Integer, Margen As Integer, Formato As String) As Byte() + Private Function GeneraCodigoQR(CodigoBarras As String, Alto As Integer, Largo As Integer, Margen As Integer, Formato As String, Optional PureBacode As Boolean = False) As Byte() Dim barcodeWriter As New BarcodeWriter Dim opciones As New ZXing.Common.EncodingOptions @@ -2213,7 +2238,7 @@ Partial Class ProductosyServicios opciones.Height = Alto opciones.Width = Largo opciones.Margin = Margen - + opciones.PureBarcode = PureBacode barcodeWriter.Options = opciones Select Case Formato @@ -2477,83 +2502,83 @@ Partial Class ProductosyServicios #Region " ECOMMERCE " Private Sub InicializaEcommerce() - AplicaEcommerce = False + 'AplicaEcommerce = False - If UsuarioActual.Empresa.Funcionalidad(700).ToEntero = 1 And CvePS > 0 Then + 'If UsuarioActual.Empresa.Funcionalidad(700).ToEntero = 1 And CvePS > 0 Then - TabEcommerce.Visible = True - LBBitacoraEcommerce.Visible = True + ' TabEcommerce.Visible = True + ' LBBitacoraEcommerce.Visible = True - 'INICIALIZA PRODUCTOS ECOMMERCE - Dim ObjEcommerce As New ClsECommerce - If ObjEcommerce.InsigniasGet(-1, "", UsuarioActual.CveEmpresa) Then - DdlEcommerceInsignia.DataSource = ObjEcommerce.DtResultados - End If - ObjEcommerce.Dispose() - DdlEcommerceInsignia.DataBind() - CargaEcommerce() + ' 'INICIALIZA PRODUCTOS ECOMMERCE + ' Dim ObjEcommerce As New ClsECommerce + ' If ObjEcommerce.InsigniasGet(-1, "", UsuarioActual.CveEmpresa) Then + ' DdlEcommerceInsignia.DataSource = ObjEcommerce.DtResultados + ' End If + ' ObjEcommerce.Dispose() + ' DdlEcommerceInsignia.DataBind() + ' CargaEcommerce() - 'INICIALIZA PRODUCTOS INSIGNIAS - CargaPSInsigniasEcommerce() + ' 'INICIALIZA PRODUCTOS INSIGNIAS + ' CargaPSInsigniasEcommerce() - 'INICIALIZA PRODUCTOS IMAGENES - CargarGaleriaImagenesEcommerce() + ' 'INICIALIZA PRODUCTOS IMAGENES + ' CargarGaleriaImagenesEcommerce() - 'INICIALIZA PRODUCTOS RELACIONADOS - DdlEcommercePSRelacionado.setEsWebService(True) - CargaPSRelacionadosEcommerce() + ' 'INICIALIZA PRODUCTOS RELACIONADOS + ' DdlEcommercePSRelacionado.setEsWebService(True) + ' CargaPSRelacionadosEcommerce() - UpEcommerce.Update() + ' UpEcommerce.Update() - End If + 'End If End Sub #Region " PRODUCTOS ECOMMERCE " Private Sub CargaEcommerce() - Dim DrEcommerce As DataRow = Nothing - Dim ObjEcommerce As New ClsECommerce - If ObjEcommerce.ProductosGet(CvePS, -1, -1, -1, UsuarioActual.CveEmpresa) Then - DrEcommerce = ObjEcommerce.DtResultados.FiltroPrimero("") - End If - ObjEcommerce.Dispose() + 'Dim DrEcommerce As DataRow = Nothing + 'Dim ObjEcommerce As New ClsECommerce + 'If ObjEcommerce.ProductosGet(CvePS, -1, -1, -1, UsuarioActual.CveEmpresa) Then + ' DrEcommerce = ObjEcommerce.DtResultados.FiltroPrimero("") + 'End If + 'ObjEcommerce.Dispose() - If DrEcommerce IsNot Nothing Then - AplicaEcommerce = True + 'If DrEcommerce IsNot Nothing Then + ' AplicaEcommerce = True - TxtEcommerceDescripcion.Text = DrEcommerce("Descripcion").ToString - TxtEcommercePrecioBase.Text = DrEcommerce("PrecioBase").ToString.FormatoNumero - TxtEcommercePrecioPromocion.Text = DrEcommerce("PrecioPromocion").ToString.FormatoNumero - ChkEcommerceDisponible.Checked = CBool(DrEcommerce("Disponible").ToString) - End If - GvEcommercePSRealacionados.DataBind() - UpEcommercePSRelacionados.Update() + ' TxtEcommerceDescripcion.Text = DrEcommerce("Descripcion").ToString + ' TxtEcommercePrecioBase.Text = DrEcommerce("PrecioBase").ToString.FormatoNumero + ' TxtEcommercePrecioPromocion.Text = DrEcommerce("PrecioPromocion").ToString.FormatoNumero + ' ChkEcommerceDisponible.Checked = CBool(DrEcommerce("Disponible").ToString) + 'End If + 'GvEcommercePSRealacionados.DataBind() + 'UpEcommercePSRelacionados.Update() End Sub Private Function GuardaEcommerce() As Boolean Dim TieneError As Boolean = False If UsuarioActual.Empresa.Funcionalidad(700) = "1" Then - 'SI NO SE HA GUARDADO EN ECOMMERCE Y NO TIENE NINGUN VALOR OMITE - If Not AplicaEcommerce And Not ChkEcommerceDisponible.Checked And TxtEcommerceDescripcion.Text.Length = 0 And TxtEcommercePrecioBase.Text.Length = 0 And TxtEcommercePrecioPromocion.Text.Length = 0 Then - Return False - End If + ''SI NO SE HA GUARDADO EN ECOMMERCE Y NO TIENE NINGUN VALOR OMITE + 'If Not AplicaEcommerce And Not ChkEcommerceDisponible.Checked And TxtEcommerceDescripcion.Text.Length = 0 And TxtEcommercePrecioBase.Text.Length = 0 And TxtEcommercePrecioPromocion.Text.Length = 0 Then + ' Return False + 'End If - If ChkEcommerceDisponible.Checked Then - If Not ValidaGuardarEcommerce() Then - Return True - End If - End If + 'If ChkEcommerceDisponible.Checked Then + ' If Not ValidaGuardarEcommerce() Then + ' Return True + ' End If + 'End If - Dim Descripcion As String = TxtEcommerceDescripcion.Text.Trim - Dim PrecioBase As Double = TxtEcommercePrecioBase.Text.Trim.ToDouble - Dim PrecioPromocion As Double = TxtEcommercePrecioPromocion.Text.Trim.ToDouble - Dim Disponible As Boolean = ChkEcommerceDisponible.Checked + 'Dim Descripcion As String = TxtEcommerceDescripcion.Text.Trim + 'Dim PrecioBase As Double = TxtEcommercePrecioBase.Text.Trim.ToDouble + 'Dim PrecioPromocion As Double = TxtEcommercePrecioPromocion.Text.Trim.ToDouble + 'Dim Disponible As Boolean = ChkEcommerceDisponible.Checked - Dim ObjEcommerce As New ClsECommerce - If Not ObjEcommerce.ProductosAddUpdate(CvePS, Descripcion, PrecioBase, PrecioPromocion, Disponible, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - TieneError = True - End If - ObjEcommerce.Dispose() + 'Dim ObjEcommerce As New ClsECommerce + 'If Not ObjEcommerce.ProductosAddUpdate(CvePS, Descripcion, PrecioBase, PrecioPromocion, Disponible, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + ' TieneError = True + 'End If + 'ObjEcommerce.Dispose() End If @@ -2564,28 +2589,28 @@ Partial Class ProductosyServicios Dim Mensaje As New StringBuilder 'DESCRIPCION - Dim Descripcion As String = TxtEcommerceDescripcion.Text.Trim - If Descripcion.Length = 0 Then - Mensaje.Append("- El campo Descripción es obligatorio. Por favor introduzcalo y vuelva a intentar.
    ") - End If - If Descripcion.Length > 255 Then - Mensaje.Append("- El campo Descripción admite maximo 255 caracteres. Por favor verifique y vuelva a intentar.
    ") - End If + 'Dim Descripcion As String = TxtEcommerceDescripcion.Text.Trim + 'If Descripcion.Length = 0 Then + ' Mensaje.Append("- El campo Descripción es obligatorio. Por favor introduzcalo y vuelva a intentar.
    ") + 'End If + 'If Descripcion.Length > 255 Then + ' Mensaje.Append("- El campo Descripción admite maximo 255 caracteres. Por favor verifique y vuelva a intentar.
    ") + 'End If - 'PRECIO BASE - Dim PrecioBase As Double = TxtEcommercePrecioBase.Text.Trim.ToDouble - If PrecioBase = 0 Then - Mensaje.Append("- El campo Precio es obligatorio. Por favor verifique y vuelva a intentar.
    ") - End If - If PrecioBase < 0 Then - Mensaje.Append("- El campo Precio no puede ser negativo. Por favor verifique y vuelva a intentar.
    ") - End If + ''PRECIO BASE + 'Dim PrecioBase As Double = TxtEcommercePrecioBase.Text.Trim.ToDouble + 'If PrecioBase = 0 Then + ' Mensaje.Append("- El campo Precio es obligatorio. Por favor verifique y vuelva a intentar.
    ") + 'End If + 'If PrecioBase < 0 Then + ' Mensaje.Append("- El campo Precio no puede ser negativo. Por favor verifique y vuelva a intentar.
    ") + 'End If - 'PRECIO FINAL - Dim PrecioPromocion As Double = TxtEcommercePrecioPromocion.Text.Trim.ToDouble - If PrecioPromocion < 0 Then - Mensaje.Append("- El campo Precio Final no puede ser negativo. Por favor verifique y vuelva a intentar.
    ") - End If + ''PRECIO FINAL + 'Dim PrecioPromocion As Double = TxtEcommercePrecioPromocion.Text.Trim.ToDouble + 'If PrecioPromocion < 0 Then + ' Mensaje.Append("- El campo Precio Final no puede ser negativo. Por favor verifique y vuelva a intentar.
    ") + 'End If 'VALIDACION @@ -2601,225 +2626,225 @@ Partial Class ProductosyServicios #Region " PRODUCTOS INSIGNIAS " Private Sub CargaPSInsigniasEcommerce() - Dim ObjEcommerce As New ClsECommerce - If ObjEcommerce.ProductosInsigniasGet(CvePS, -1, UsuarioActual.CveEmpresa) Then - GvEcommercePSInsignias.DataSource = ObjEcommerce.DtResultados - Else - GvEcommercePSInsignias.DataSource = Nothing - End If - ObjEcommerce.Dispose() + 'Dim ObjEcommerce As New ClsECommerce + 'If ObjEcommerce.ProductosInsigniasGet(CvePS, -1, UsuarioActual.CveEmpresa) Then + ' GvEcommercePSInsignias.DataSource = ObjEcommerce.DtResultados + 'Else + ' GvEcommercePSInsignias.DataSource = Nothing + 'End If + 'ObjEcommerce.Dispose() - GvEcommercePSInsignias.DataBind() - UpEcommerceInsignias.Update() + 'GvEcommercePSInsignias.DataBind() + 'UpEcommerceInsignias.Update() End Sub Protected Sub BtnEcommerceInsignias_Click(sender As Object, e As EventArgs) - If Not ValidaAgregarProductosInsigniasEcommerce() Then - Exit Sub - End If + 'If Not ValidaAgregarProductosInsigniasEcommerce() Then + ' Exit Sub + 'End If - Dim TieneError As Boolean = False - Dim CveInsignia As Integer = DdlEcommerceInsignia.SelectedValue.ToEntero + 'Dim TieneError As Boolean = False + 'Dim CveInsignia As Integer = DdlEcommerceInsignia.SelectedValue.ToEntero - 'AGREGAR - Dim ObjEcommerce As New ClsECommerce - If ObjEcommerce.ProductosInsigniasAdd(Me.CvePS, CveInsignia, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - Alert("La Insignia se agregó correctamente.", TipoMensaje.MsgInformacion) - Else - TieneError = True - End If - ObjEcommerce.Dispose() + ''AGREGAR + 'Dim ObjEcommerce As New ClsECommerce + 'If ObjEcommerce.ProductosInsigniasAdd(Me.CvePS, CveInsignia, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + ' Alert("La Insignia se agregó correctamente.", TipoMensaje.MsgInformacion) + 'Else + ' TieneError = True + 'End If + 'ObjEcommerce.Dispose() - If Not TieneError Then - DdlEcommerceInsignia.SelectedValueExist(-1) - CargaPSInsigniasEcommerce() - End If + 'If Not TieneError Then + ' DdlEcommerceInsignia.SelectedValueExist(-1) + ' CargaPSInsigniasEcommerce() + 'End If End Sub Private Function ValidaAgregarProductosInsigniasEcommerce() As Boolean Dim Retorno As Boolean = True - Dim Mensaje As New StringBuilder + 'Dim Mensaje As New StringBuilder - 'INSIGNIA - Dim CveInsignia As Integer = DdlEcommerceInsignia.SelectedValue.ToEntero - If CveInsignia = 0 Then - Mensaje.Append("- El campo Insignia es obligatorio. Por favor introduzcalo y vuelva a intentar.
    ") - End If - For Each GvRow As GridViewRow In GvEcommercePSInsignias.Rows - If GvRow.DataKey("CveInsignia").ToString.ToEntero = CveInsignia Then - Mensaje.Append($"- La Insignia {DdlEcommerceInsignia.SelectedItem.Text} ya es parte del producto y no se puede duplicar. Por favor verifique y vuelva a intentar.
    ") - Exit For - End If - Next + ''INSIGNIA + 'Dim CveInsignia As Integer = DdlEcommerceInsignia.SelectedValue.ToEntero + 'If CveInsignia = 0 Then + ' Mensaje.Append("- El campo Insignia es obligatorio. Por favor introduzcalo y vuelva a intentar.
    ") + 'End If + 'For Each GvRow As GridViewRow In GvEcommercePSInsignias.Rows + ' If GvRow.DataKey("CveInsignia").ToString.ToEntero = CveInsignia Then + ' Mensaje.Append($"- La Insignia {DdlEcommerceInsignia.SelectedItem.Text} ya es parte del producto y no se puede duplicar. Por favor verifique y vuelva a intentar.
    ") + ' Exit For + ' End If + 'Next - 'VALIDACION - If Mensaje.ToString.Length > 0 Then - Retorno = False - Alert(Mensaje.ToString, TipoMensaje.MsgAdvertencia) - End If + ''VALIDACION + 'If Mensaje.ToString.Length > 0 Then + ' Retorno = False + ' Alert(Mensaje.ToString, TipoMensaje.MsgAdvertencia) + 'End If Return Retorno End Function - Protected Sub GvEcommercePSInsignias_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvEcommercePSInsignias.RowDeleting - Dim TieneError As Boolean = False - Dim GvRow As GridViewRow = GvEcommercePSInsignias.Rows(e.RowIndex) + 'Protected Sub GvEcommercePSInsignias_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvEcommercePSInsignias.RowDeleting + ' Dim TieneError As Boolean = False + ' Dim GvRow As GridViewRow = GvEcommercePSInsignias.Rows(e.RowIndex) - Dim ObjEcommerce As New ClsECommerce - If ObjEcommerce.ProductosInsigniasRemove(GvRow.DataKey("CvePS").ToString.ToEntero, GvRow.DataKey("CveInsignia").ToString.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - Alert("La Insignia se eliminó correctamente.", TipoMensaje.MsgInformacion) - Else - TieneError = True - End If - ObjEcommerce.Dispose() + ' Dim ObjEcommerce As New ClsECommerce + ' If ObjEcommerce.ProductosInsigniasRemove(GvRow.DataKey("CvePS").ToString.ToEntero, GvRow.DataKey("CveInsignia").ToString.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + ' Alert("La Insignia se eliminó correctamente.", TipoMensaje.MsgInformacion) + ' Else + ' TieneError = True + ' End If + ' ObjEcommerce.Dispose() - If Not TieneError Then - CargaPSInsigniasEcommerce() - End If - End Sub + ' If Not TieneError Then + ' CargaPSInsigniasEcommerce() + ' End If + 'End Sub #End Region #Region " PRODUCTOS IMAGENES " - Private Sub CargarGaleriaImagenesEcommerce() - Dim TmpDT As DataTable = Nothing + 'Private Sub CargarGaleriaImagenesEcommerce() + ' Dim TmpDT As DataTable = Nothing - Dim ObjEcommerce As New ClsECommerce - If ObjEcommerce.ProductosImagenesGet(CvePS, UsuarioActual.CveEmpresa) Then - TmpDT = ObjEcommerce.DtResultados - Else - TmpDT = Nothing - End If - ObjEcommerce.Dispose() + ' Dim ObjEcommerce As New ClsECommerce + ' If ObjEcommerce.ProductosImagenesGet(CvePS, UsuarioActual.CveEmpresa) Then + ' TmpDT = ObjEcommerce.DtResultados + ' Else + ' TmpDT = Nothing + ' End If + ' ObjEcommerce.Dispose() - RptFotos.DataSource = TmpDT - RptFotos.DataBind() - UpEcommerceGaleriaImagenes.Update() - End Sub + ' RptFotos.DataSource = TmpDT + ' RptFotos.DataBind() + ' UpEcommerceGaleriaImagenes.Update() + 'End Sub Protected Sub BtnEcommerceImagenes_Click(sender As Object, e As EventArgs) - Dim FilesGral As List(Of Archivo) = TxtEcommerceImagenes.getfiles().Archivos - Dim FileMove As String = "" - Dim Archivo As String = "" - Dim DirectorioTemporal As String = "" + 'Dim FilesGral As List(Of Archivo) = TxtEcommerceImagenes.getfiles().Archivos + 'Dim FileMove As String = "" + 'Dim Archivo As String = "" + 'Dim DirectorioTemporal As String = "" - Dim DirectorioDestino As String = $"{UsuarioActual.Empresa.Ruta}\Ecommerce\Productos\Imagenes\" - If Not Directory.Exists(DirectorioDestino) Then - Directory.CreateDirectory(DirectorioDestino) - End If + 'Dim DirectorioDestino As String = $"{UsuarioActual.Empresa.Ruta}\Ecommerce\Productos\Imagenes\" + 'If Not Directory.Exists(DirectorioDestino) Then + ' Directory.CreateDirectory(DirectorioDestino) + 'End If - Dim ObjEcommerce As New ClsECommerce - For Each FileItem As Archivo In FilesGral - Archivo = NowADS().Ticks.ToString - Try - FileMove = FileItem.filename - DirectorioTemporal = $"{AppDomain.CurrentDomain.BaseDirectory}Temp\{FileMove}" + 'Dim ObjEcommerce As New ClsECommerce + 'For Each FileItem As Archivo In FilesGral + ' Archivo = NowADS().Ticks.ToString + ' Try + ' FileMove = FileItem.filename + ' DirectorioTemporal = $"{AppDomain.CurrentDomain.BaseDirectory}Temp\{FileMove}" - Archivo = $"{Archivo}{IO.Path.GetExtension(DirectorioTemporal)}" - DirectorioDestino += Archivo - If ObjEcommerce.ProductosImagenesAdd(CvePS, $"Ecommerce\Productos\Imagenes\{Archivo}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - CargarGaleriaImagenesEcommerce() - My.Computer.FileSystem.MoveFile(DirectorioTemporal, DirectorioDestino) - End If - Catch ex As Exception - End Try - Next - ObjEcommerce.Dispose() + ' Archivo = $"{Archivo}{IO.Path.GetExtension(DirectorioTemporal)}" + ' DirectorioDestino += Archivo + ' If ObjEcommerce.ProductosImagenesAdd(CvePS, $"Ecommerce\Productos\Imagenes\{Archivo}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + ' CargarGaleriaImagenesEcommerce() + ' My.Computer.FileSystem.MoveFile(DirectorioTemporal, DirectorioDestino) + ' End If + ' Catch ex As Exception + ' End Try + 'Next + 'ObjEcommerce.Dispose() - RegistraScript("$(""#Modalupfotos"").modal(""hide"");initcarusel();") - TxtEcommerceImagenes.Text = "[]" - UpUpFotos.Update() + 'RegistraScript("$(""#Modalupfotos"").modal(""hide"");initcarusel();") + 'TxtEcommerceImagenes.Text = "[]" + 'UpUpFotos.Update() End Sub Protected Sub BtnEcommerceEliminarImagenes_Click(sender As Object, e As System.EventArgs) - Dim CveImagenActivoFijo As Integer = 0 - CveImagenActivoFijo = Integer.Parse(DirectCast(sender, Button).CommandArgument) + 'Dim CveImagenActivoFijo As Integer = 0 + 'CveImagenActivoFijo = Integer.Parse(DirectCast(sender, Button).CommandArgument) - If (CveImagenActivoFijo > 0) Then - Dim ObjEcommerce As New ClsECommerce - If ObjEcommerce.ProductosImagenesRemove(CveImagenActivoFijo, UsuarioActual.CveEmpresa) Then - File.Delete(String.Format("{0}{1}", UsuarioActual.Empresa.Ruta, ObjEcommerce.DtResultados.Rows(0)("URL"))) - CargarGaleriaImagenesEcommerce() - RegistraScript("initcarusel();") - End If - ObjEcommerce.Dispose() - End If + 'If (CveImagenActivoFijo > 0) Then + ' Dim ObjEcommerce As New ClsECommerce + ' If ObjEcommerce.ProductosImagenesRemove(CveImagenActivoFijo, UsuarioActual.CveEmpresa) Then + ' File.Delete(String.Format("{0}{1}", UsuarioActual.Empresa.Ruta, ObjEcommerce.DtResultados.Rows(0)("URL"))) + ' CargarGaleriaImagenesEcommerce() + ' RegistraScript("initcarusel();") + ' End If + ' ObjEcommerce.Dispose() + 'End If End Sub #End Region #Region " PRODUCTOS RELACIONADOS " Private Sub CargaPSRelacionadosEcommerce() - Dim ObjEcommerce As New ClsECommerce - If ObjEcommerce.ProductosRelacionadosGet(CvePS, UsuarioActual.CveEmpresa) Then - GvEcommercePSRealacionados.DataSource = ObjEcommerce.DtResultados - Else - GvEcommercePSRealacionados.DataSource = Nothing - End If - ObjEcommerce.Dispose() + 'Dim ObjEcommerce As New ClsECommerce + 'If ObjEcommerce.ProductosRelacionadosGet(CvePS, UsuarioActual.CveEmpresa) Then + ' GvEcommercePSRealacionados.DataSource = ObjEcommerce.DtResultados + 'Else + ' GvEcommercePSRealacionados.DataSource = Nothing + 'End If + 'ObjEcommerce.Dispose() - GvEcommercePSRealacionados.DataBind() - UpEcommercePSRelacionados.Update() + 'GvEcommercePSRealacionados.DataBind() + 'UpEcommercePSRelacionados.Update() End Sub Protected Sub BtnEcommercePSRelacionados_Click(sender As Object, e As EventArgs) - If Not ValidaAgregarProductosRelacionadosEcommerce() Then - Exit Sub - End If + 'If Not ValidaAgregarProductosRelacionadosEcommerce() Then + ' Exit Sub + 'End If - Dim TieneError As Boolean = False - Dim CvePS As Integer = DdlEcommercePSRelacionado.SelectedValue.ToEntero + 'Dim TieneError As Boolean = False + 'Dim CvePS As Integer = DdlEcommercePSRelacionado.SelectedValue.ToEntero - 'AGREGAR - Dim ObjEcommerce As New ClsECommerce - If ObjEcommerce.ProductosRelacionadosAdd(Me.CvePS, CvePS, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - Alert("La relación se agregó correctamente.", TipoMensaje.MsgInformacion) - Else - TieneError = True - End If - ObjEcommerce.Dispose() + ''AGREGAR + 'Dim ObjEcommerce As New ClsECommerce + 'If ObjEcommerce.ProductosRelacionadosAdd(Me.CvePS, CvePS, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + ' Alert("La relación se agregó correctamente.", TipoMensaje.MsgInformacion) + 'Else + ' TieneError = True + 'End If + 'ObjEcommerce.Dispose() - If Not TieneError Then - DdlEcommercePSRelacionado.SelectedValue = "-1" - DdlEcommercePSRelacionado.SelectedText = "" - CargaPSRelacionadosEcommerce() - End If + 'If Not TieneError Then + ' DdlEcommercePSRelacionado.SelectedValue = "-1" + ' DdlEcommercePSRelacionado.SelectedText = "" + ' CargaPSRelacionadosEcommerce() + 'End If End Sub Private Function ValidaAgregarProductosRelacionadosEcommerce() As Boolean Dim Retorno As Boolean = True - Dim Mensaje As New StringBuilder + 'Dim Mensaje As New StringBuilder - 'PS - Dim CvePS As Integer = DdlEcommercePSRelacionado.SelectedValue.ToEntero - If CvePS = 0 Then - Mensaje.Append("- El campo Producto es obligatorio. Por favor introduzcalo y vuelva a intentar.
    ") - End If - For Each GvRow As GridViewRow In GvEcommercePSRealacionados.Rows - If GvRow.DataKey("CvePS").ToString.ToEntero = CvePS Then - Mensaje.Append($"- El producto {DdlEcommercePSRelacionado.SelectedText} ya esta relacionado y no se puede duplicar. Por favor verifique y vuelva a intentar.
    ") - Exit For - End If - Next + ''PS + 'Dim CvePS As Integer = DdlEcommercePSRelacionado.SelectedValue.ToEntero + 'If CvePS = 0 Then + ' Mensaje.Append("- El campo Producto es obligatorio. Por favor introduzcalo y vuelva a intentar.
    ") + 'End If + 'For Each GvRow As GridViewRow In GvEcommercePSRealacionados.Rows + ' If GvRow.DataKey("CvePS").ToString.ToEntero = CvePS Then + ' Mensaje.Append($"- El producto {DdlEcommercePSRelacionado.SelectedText} ya esta relacionado y no se puede duplicar. Por favor verifique y vuelva a intentar.
    ") + ' Exit For + ' End If + 'Next - 'VALIDACION - If Mensaje.ToString.Length > 0 Then - Retorno = False - Alert(Mensaje.ToString, TipoMensaje.MsgAdvertencia) - End If + ''VALIDACION + 'If Mensaje.ToString.Length > 0 Then + ' Retorno = False + ' Alert(Mensaje.ToString, TipoMensaje.MsgAdvertencia) + 'End If Return Retorno End Function - Protected Sub GvEcommercePSRealacionados_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvEcommercePSRealacionados.RowDeleting - Dim TieneError As Boolean = False - Dim GvRow As GridViewRow = GvEcommercePSRealacionados.Rows(e.RowIndex) + 'Protected Sub GvEcommercePSRealacionados_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvEcommercePSRealacionados.RowDeleting + ' 'Dim TieneError As Boolean = False + ' 'Dim GvRow As GridViewRow = GvEcommercePSRealacionados.Rows(e.RowIndex) - Dim ObjEcommerce As New ClsECommerce - If ObjEcommerce.ProductosRelacionadosRemove(GvRow.DataKey("CvePS1").ToString.ToEntero, GvRow.DataKey("CvePS2").ToString.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - Alert("La relación se eliminó correctamente.", TipoMensaje.MsgInformacion) - Else - TieneError = True - End If - ObjEcommerce.Dispose() + ' 'Dim ObjEcommerce As New ClsECommerce + ' 'If ObjEcommerce.ProductosRelacionadosRemove(GvRow.DataKey("CvePS1").ToString.ToEntero, GvRow.DataKey("CvePS2").ToString.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + ' ' Alert("La relación se eliminó correctamente.", TipoMensaje.MsgInformacion) + ' 'Else + ' ' TieneError = True + ' 'End If + ' 'ObjEcommerce.Dispose() - If Not TieneError Then - CargaPSRelacionadosEcommerce() - End If - End Sub + ' 'If Not TieneError Then + ' ' CargaPSRelacionadosEcommerce() + ' 'End If + 'End Sub #End Region @@ -3542,12 +3567,12 @@ Partial Class ProductosyServicios 'If DdlMaterialPeligroso.SelectedValue.ToEntero > 0 And DdlEmbalaje.SelectedValue.ToEntero > 0 And DdlClaveSectorCOFEPRIS.SelectedValue.ToEntero > 0 And CamposStringCCP.Length > 0 Then Dim ObjPS As New ClsProductosServicios(transaccionSQL) - If Not ObjPS.AddUpdateProductosServiciosComplementos(CvePS, TxtPesoKg.Text.ToDecimal, DdlMaterialPeligroso.SelectedValue.ToEntero, DdlEmbalaje.SelectedValue.ToEntero, TxtDimensiones.Text, DdlClaveSectorCOFEPRIS.SelectedValue.ToEntero, - TxtNombreIngredienteActivo.Text.Trim, TxtNomQuimico.Text.Trim, TxtDenominacionGenerica.Text.Trim, TxtDenominacionDistintiva.Text.Trim, TxtFabricante.Text.Trim, DdlClaveFormaFarmaceutica.SelectedValue.ToEntero, DdlCondicionesEspTransporte.SelectedValue.ToEntero, - TxtRegistroSanitarioAutorizacion.Text.Trim, TxtPermisoImportacion.Text.Trim, TxtFolioImportacionVUCEM.Text.Trim, TxtNumCAS.Text.Trim, TxtRazonSocialEmpImportacion.Text, TxtNumRegistroPlagCOFEPRIS.Text.Trim, TxtDatosFabricante.Text.Trim, - TxtDatosFormulador.Text.Trim, TxtDatosMaquilador.Text.Trim, TxtUsoAutorizado.Text, DdlTipoMateria.SelectedValue.ToEntero) Then - Respuesta = False - End If + If Not ObjPS.AddUpdateProductosServiciosComplementos(CvePS, TxtPesoKg.Text.ToDecimal, DdlMaterialPeligroso.SelectedValue.ToEntero, DdlEmbalaje.SelectedValue.ToEntero, TxtDimensiones.Text, DdlClaveSectorCOFEPRIS.SelectedValue.ToEntero, + TxtNombreIngredienteActivo.Text.Trim, TxtNomQuimico.Text.Trim, TxtDenominacionGenerica.Text.Trim, TxtDenominacionDistintiva.Text.Trim, TxtFabricante.Text.Trim, DdlClaveFormaFarmaceutica.SelectedValue.ToEntero, DdlCondicionesEspTransporte.SelectedValue.ToEntero, + TxtRegistroSanitarioAutorizacion.Text.Trim, TxtPermisoImportacion.Text.Trim, TxtFolioImportacionVUCEM.Text.Trim, TxtNumCAS.Text.Trim, TxtRazonSocialEmpImportacion.Text, TxtNumRegistroPlagCOFEPRIS.Text.Trim, TxtDatosFabricante.Text.Trim, + TxtDatosFormulador.Text.Trim, TxtDatosMaquilador.Text.Trim, TxtUsoAutorizado.Text, DdlTipoMateria.SelectedValue.ToEntero) Then + Respuesta = False + End If ' End If 'End If @@ -3566,4 +3591,102 @@ Partial Class ProductosyServicios + Protected Sub LnkGenerarEtiqueta_Click(sender As Object, e As EventArgs) + Dim CvePrecioListaPredeterminada = GlobalDTPrecioListas(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePrecioLista", "Predeterminada = True").ToEntero() + Dim DtPrecios As DataTable = Nothing + + Dim ObjVentas As New ClsProductosServicios + If ObjVentas.GetPSPrecios(CvePrecioListaPredeterminada, Me.CvePS.ToString()) AndAlso ObjVentas.DtResultados IsNot Nothing AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then + DtPrecios = ObjVentas.DtResultados.Copy() + End If + ObjVentas.Dispose() + + If DtPrecios IsNot Nothing Then + + DtPrecios.Columns.Add(New DataColumn("CBBase64", GetType(String))) + + For Each Row As DataRow In DtPrecios.Rows + Row("CBBase64") = Convert.ToBase64String(GeneraCodigoQR(Row("CodigoBarras").ToString(), 40, 150, 0, "CODE_39", True)) + Next + + Dim DirectorioArchivo As String = "Empresas/Grales/Formatos/Etiqueta.mrt" + If System.IO.File.Exists(UsuarioActual.Empresa.Ruta + "Formatos/Etiqueta.mrt") Then + DirectorioArchivo = UsuarioActual.Empresa.Ruta + "Formatos/Etiqueta.mrt" + End If + Dim params As New List(Of ReportParameter) + + Dim lrds As New List(Of ReportDataSource) + Dim rds As New ReportDataSource + rds.Name = "Datos" + rds.Value = DtPrecios + lrds.Add(rds) + + Dim bytesPDF = StreamBytesStimul("Facturas", DirectorioArchivo, lrds, params, NombreArchivo:="Precios", Formato:="PDF") + Dim pdf64 = Convert.ToBase64String(bytesPDF) + + RegistraScript($"impresionBase64('{pdf64}');", "Imprimir") + 'ImprimirPDFStimul(DirectorioArchivo, DtPrecios, params, "Precios") + End If + + End Sub + + Private Sub BtnUpFotos_Click(sender As Object, e As EventArgs) Handles BtnUpFotos.Click + + Dim FilesGral As List(Of Archivo) = TxtUpFotos.getfiles().Archivos + Dim FileMove As String = "" + Dim NewName As String + For Each FileItem As Archivo In FilesGral + + NewName = NowADS().Ticks.ToString + Dim ObjPS As New ClsProductosServicios + Try + FileMove = FileItem.filename + Dim DirectorioOld As New StringBuilder + Dim DirectorioNew As New StringBuilder + DirectorioOld.AppendFormat("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, FileMove) + DirectorioNew.AppendFormat("{0}PS\", UsuarioActual.Empresa.Ruta) + If Not Directory.Exists(DirectorioNew.ToString) Then + Directory.CreateDirectory(DirectorioNew.ToString) + End If + NewName = String.Format("{0}{1}", NewName, IO.Path.GetExtension(DirectorioOld.ToString())) + DirectorioNew.Append(NewName) + + Me.Imagen = String.Format("PS/{0}", NewName) + If ObjPS.UpdatePSImagen(Me.CvePS, Me.Imagen) Then + My.Computer.FileSystem.MoveFile(DirectorioOld.ToString, DirectorioNew.ToString) + End If + + imgImagen.Attributes.Add("src", String.Format("/ashx/SIGWeb.ashx?Metodo=GetImg&r={0}", Extensiones.Encripta(Me.Imagen))) + hplImagen.Attributes.Add("href", String.Format("/ashx/SIGWeb.ashx?Metodo=GetImg&r={0}", Extensiones.Encripta(Me.Imagen))) + upGaleria.Update() + + Catch ex As Exception + OnError("Ocurrió un error al guardar la imagen", ex) + End Try + + ObjPS.Dispose() + RegistraScript("$(""#Modalupfotos"").modal(""hide"");initcarusel();") + TxtUpFotos.Text = "[]" + UpUpFotos.Update() + Next + + End Sub + + Protected Sub BtnEliminarFoto_Click(sender As Object, e As System.EventArgs) + + If (Me.CvePS > 0) Then + Dim ObjPS As New ClsProductosServicios + If ObjPS.UpdatePSImagen(Me.CvePS, "") Then + File.Delete(String.Format("{0}{1}", UsuarioActual.Empresa.Ruta, Me.Imagen)) + Me.Imagen = "" + imgImagen.Attributes.Add("src", "") + hplImagen.Attributes.Add("href", "") + RegistraScript("initcarusel();") + End If + ObjPS.Dispose() + + upGaleria.Update() + End If + + End Sub End Class diff --git a/Ventas/Promociones.aspx.vb b/Ventas/Promociones.aspx.vb index 21fce0286..e622f196e 100644 --- a/Ventas/Promociones.aspx.vb +++ b/Ventas/Promociones.aspx.vb @@ -1116,9 +1116,9 @@ Partial Class Ventas_Promociones Else If ClasificacionStr.Length > 0 Then - SBErrorRegistro.Append(If(CveClasificacion > 0, "", $"No se encontro Clasificación '{ClasificacionStr}'. ")) + SBErrorRegistro.Append(If(CveClasificacion > 0, "", $"No se encontro Clasificación '{ClasificacionStr}'.
    ")) Else - SBErrorRegistro.Append(If(CvePS > 0, "", $"No se encontro código de Producto/Servicio '{CodigoStr }'. ")) + SBErrorRegistro.Append(If(CvePS > 0, "", $"No se encontro código de Producto/Servicio '{CodigoStr }'.
    ")) End If End If @@ -1129,19 +1129,19 @@ Partial Class Ventas_Promociones ElseIf TipoPromocionStr.Trim.ToUpper = "CANTIDAD" Then CveTipoPromocion = 3 Else - SBErrorRegistro.Append($"Tipo Promoción no encontrada '{TipoPromocionStr}'. ") + SBErrorRegistro.Append($"Tipo Promoción no encontrada '{TipoPromocionStr}'.
    ") End If If Not Promocion > 0 Then - SBErrorRegistro.Append($"La Promoción debe de ser mayor a 0. ") + SBErrorRegistro.Append($"La Promoción debe de ser mayor a 0.
    ") End If If CantidadMinimaStr.Length > 0 And Not CantidadMinima > 0 Then - SBErrorRegistro.Append($"La Cantidad MÍnima debe de ser mayor a 0. ") + SBErrorRegistro.Append($"La Cantidad Mínima debe de ser mayor a 0.
    ") End If If RinStr.Length > 0 And Not CveRin > 0 Then - SBErrorRegistro.Append($"Tamaño de Rin no encontrado '{RinStr}'. ") + SBErrorRegistro.Append($"Tamaño de Rin no encontrado '{RinStr}'.
    ") End If If Not IncluyeImpuestosStr.ToUpper.Contiene("´SÍ", "SI", "1", "NO", "0") Then diff --git a/Ventas/RepComisionesSMS.aspx b/Ventas/RepComisionesSMS.aspx new file mode 100644 index 000000000..d7122528f --- /dev/null +++ b/Ventas/RepComisionesSMS.aspx @@ -0,0 +1,241 @@ +<%@ Page Title="Reporte de Comisiones" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RepComisionesSMS.aspx.vb" Inherits="Ventas_RepComisionesSMS" %> +<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> +<%@ Register Src="~/UserControl/AddMedico.ascx" TagPrefix="UserControl" TagName="AddMedico" %> + + + + + + Reporte de Comisiones + + + + + Reporte de Comisiones + + + + + +
  • + +
  • +
  • + Excel +
  • +
    + + + +
    + +
    + + + + + +
    +
    +
    + + +
    +
    +
    + + +
    + Fecha Inicio: +
    +
    +
    + + + + +
    + + + + + + +
    +
    + Fecha Fin: + +
    +
    +
    + + + + +
    + + + + + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + + +
    +
    +
    + +
    +
    +
    + + + + +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + +
    +
    + + + + + + + + +
    + + + + + diff --git a/Ventas/RepComisionesSMS.aspx.vb b/Ventas/RepComisionesSMS.aspx.vb new file mode 100644 index 000000000..9641a8d16 --- /dev/null +++ b/Ventas/RepComisionesSMS.aspx.vb @@ -0,0 +1,193 @@ +Option Explicit On +Option Strict On + +Imports System.Data +Imports Extensiones + + +Partial Class Ventas_RepComisionesSMS + Inherits ClsPaginas + + Property DTDatos As DataTable + Get + If ViewState("DTDatos") Is Nothing Then + ViewState("DTDatos") = New DataTable + End If + Return DirectCast(ViewState("DTDatos"), DataTable) + End Get + Set(value As DataTable) + ViewState("DTDatos") = value + End Set + End Property + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load + + If Not Page.IsPostBack Then + + Dim FechaInicial As Date = New Date(10) + + txtFechaI.Text = Now.FirstDayOfMonth.ToString("dd/MM/yyyy") + txtFechaF.Text = Now.ToString("dd/MM/yyyy") + CargaCombos() + CargaDatos() + End If + + End Sub + + Private Sub CargaCombos() + + + 'If UsuarioActual.Empresa.Funcionalidad(302) = "1" AndAlso DdlSubProyectoDatos.SelectedValue.ToEntero() > 0 Then + ' DdlVendedor.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo:=-1).FiltraParametros(String.Format("VendedorTipo IN (1,4) AND (CveSubProyecto IS NULL OR CveSubProyecto = {0})", DdlSubProyectoDatos.SelectedValue)) + 'Else + DdlVendedor.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa).FiltraParametros("VendedorTipo = 1") + 'End If + DdlVendedor.DataBind() + DdlVendedor.Items.Insert(0, New ListItem("Todos", "-1")) + + + DdlMedico.DataSource = GlobalDTMedicos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ") + DdlMedico.DataBind() + DdlMedico.Items.Insert(0, New ListItem("Todos", "-1")) + + DdlUsuarioAtendio.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa) + DdlUsuarioAtendio.DataBind() + DdlUsuarioAtendio.Items.Insert(0, New ListItem("Todos", "-1")) + + + + End Sub + + Public Sub CargaDatos() + + + + LnkExportar.Visible = False + + Dim ObjVentas As New ClsVentas + + If ObjVentas.GetComisionesMedicasRep(txtFechaI.Text.ToDate, txtFechaF.Text.ToDate, UsuarioActual.CveEmpresa, -1, -1, DdlMedico.SelectedValue.ToEntero, DdlVendedor.SelectedValue.ToEntero, DdlUsuarioAtendio.SelectedValue.ToEntero, -1) Then + GvDatos.DataSource = ObjVentas.DtResultados + + If ObjVentas.DtResultados IsNot Nothing AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then + LnkExportar.Visible = True + End If + Else + GvDatos.DataSource = Nothing + End If + + ObjVentas.Dispose() + + GvDatos.DataBind() + + UpDatos.Update() + + + + + End Sub + + Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) + CargaDatos() + End Sub + +#Region "EXCEL" + + Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click + + GvDatos.Columns(10).Visible = False + Dim SbFiltros As New StringBuilder() + SbFiltros.AppendFormat($"Fecha Inicio: {txtFechaI.Text} Fecha Fin: {txtFechaF.Text}|") + GvDatos.ExportToExcelGembox("CatMedicos", UsuarioActual, "Catálogo de Médicos", DatoTituloExtra:=$"", DatosFiltros:=SbFiltros.ToString()) + GvDatos.Columns(10).Visible = True + + + + End Sub + + Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control) + End Sub + +#End Region + + + Protected Sub LnkComisiones_Click(sender As Object, e As EventArgs) + CargaComisiones() + RegistraScript("$('#DvModalComisiones').modal('show');") + End Sub + + Private Sub CargaComisiones() + DTDatos = New DataTable + GvComisiones.DataSource = Nothing + + Dim objVentas As New ClsVentas + + If objVentas.GetComisionesMedicas(UsuarioActual.CveEmpresa) Then + GvComisiones.DataSource = objVentas.DtResultados + DTDatos = objVentas.DtResultados + End If + + objVentas.Dispose() + + GvComisiones.DataBind() + + UpDvModalComisiones.Update() + + End Sub + + + + Protected Sub BtnGuardarComisiones_Click(sender As Object, e As EventArgs) + + Dim objVentas As New ClsVentas + objVentas.IniciaTransacSQL() + + Dim TieneError As Boolean = False + + For Each GvRow As GridViewRow In GvComisiones.Rows + + Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero + Dim ComisionMedicoDT As Decimal = DTDatos.FiltroPrimeroValor("ComisionMedico", $"CvePS = {CvePS} ").ToDecimal + Dim ComisionVendedorDT As Decimal = DTDatos.FiltroPrimeroValor("ComisionVendedor", $"CvePS = {CvePS} ").ToDecimal + Dim ComisionTecnicoDT As Decimal = DTDatos.FiltroPrimeroValor("ComisionTecnico", $"CvePS = {CvePS} ").ToDecimal + + Dim ComisionMedicoGV As Decimal = GvRow.FCTextBox("TxtComisionMedico").Text.ToDecimal + Dim ComisionVendedorGV As Decimal = GvRow.FCTextBox("TxtComisionVendedor").Text.ToDecimal + Dim ComisionTecnicoGV As Decimal = GvRow.FCTextBox("TxtComisionTecnico").Text.ToDecimal + + If ComisionMedicoDT <> ComisionMedicoGV Or ComisionVendedorDT <> ComisionVendedorGV Or ComisionTecnicoDT <> ComisionTecnicoGV Then + If Not objVentas.AddUpdateComisionesMedicas(GvRow.DataKey("CvePS").ToEntero, UsuarioActual.CveEmpresa, ComisionMedicoGV, ComisionVendedorGV, ComisionTecnicoGV) Then + TieneError = True + End If + End If + + Next + + If TieneError Then + objVentas.RollBack() + Else + objVentas.Commit() + Alert("Comisiones Actualizadas correctamente") + End If + + objVentas.Dispose() + + End Sub + + Protected Sub GvComisiones_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.DataRow Then + + If e.Row.FCTextBox("TxtComisionMedico").Text.ToDecimal = 0 Then + e.Row.FCTextBox("TxtComisionMedico").Text = "" + End If + If e.Row.FCTextBox("TxtComisionVendedor").Text.ToDecimal = 0 Then + e.Row.FCTextBox("TxtComisionVendedor").Text = "" + End If + If e.Row.FCTextBox("TxtComisionTecnico").Text.ToDecimal = 0 Then + e.Row.FCTextBox("TxtComisionTecnico").Text = "" + End If + + End If + + End Sub +End Class diff --git a/Ventas/RepVentasUtilidad.aspx.vb b/Ventas/RepVentasUtilidad.aspx.vb index f4f737dd2..c9947773f 100644 --- a/Ventas/RepVentasUtilidad.aspx.vb +++ b/Ventas/RepVentasUtilidad.aspx.vb @@ -338,7 +338,7 @@ Partial Class Ventas_RepVentasUtilidad params.Add(New ReportParameter("UtilidadPerdida", LblNombreNeto.Text)) params.Add(New ReportParameter("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", ""))) - ImprimirPDF("Empresas/Grales/Formatos/RepVentasUtilidad.rdlc", dt, params, "RepVentasUtilidad", Formato) + ImprimirPDF("Grales/Formatos/RepVentasUtilidad.rdlc", dt, params, "RepVentasUtilidad", Formato) Else Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia) End If diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 25bdaabd5..c41799abf 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -252,7 +252,7 @@
  • -
  • @@ -386,14 +386,14 @@ Enviar Póliza Virtual
  • - Relacionar Facturas + Relacionar Facturas
  • Solicitar autorización de crédito
  • - <%--
  • +
  • Cancelar solo CFDI -
  • --%> +
  • Agregar Orden de Servicio @@ -454,7 +454,7 @@ - + : @@ -979,6 +979,41 @@
  • + + + +
    +
    + + Imagen del producto + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    @@ -1042,7 +1077,7 @@ - P.U.  + P.U.  Desc Predial @@ -1114,7 +1149,8 @@ -
    + +
    <%----%> @@ -1329,15 +1365,24 @@
    - - - - - +
    +
    + +
    +
    +
    +
    + + + + + - + - + +
    +
    <%--10--%> @@ -1386,7 +1431,7 @@ <%--16--%> - + <%--17--%> @@ -4425,25 +4470,47 @@