diff --git a/Bancos/IE.aspx.vb b/Bancos/IE.aspx.vb
index 06f55f91d..19e05fdb1 100644
--- a/Bancos/IE.aspx.vb
+++ b/Bancos/IE.aspx.vb
@@ -2575,6 +2575,12 @@ Partial Class Bancos_IE
Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:
"
Dim Msg As New StringBuilder
+
+ If RBL.SelectedValue = "C" AndAlso DdlCliente.SelectedValue.ToEntero > 0 Then ' Clientes
+ CveConceptoCompra = 66
+ End If
+
+
If CveIE = -1 Then
diff --git a/Compras/ReembolsosComprobaciones.aspx.vb b/Compras/ReembolsosComprobaciones.aspx.vb
index 95a0f5c77..ab0edc788 100644
--- a/Compras/ReembolsosComprobaciones.aspx.vb
+++ b/Compras/ReembolsosComprobaciones.aspx.vb
@@ -402,8 +402,10 @@ Partial Class Compras_ReembolsosComprobaciones
Protected Sub BtnIEGuardar_Click(sender As Object, e As EventArgs) Handles BtnIEGuardar.Click
Dim ValFechaDocumento As Boolean = False
- Dim FoliosFechasValFechaDocumento As New StringBuilder
- FoliosFechasValFechaDocumento.AppendLine("Se seleccionaron facturas con fecha de mes superior al mes del pago:
")
+
+ Dim FoliosFechasValFechaDocumentoAnio As New StringBuilder
+ Dim FoliosFechasValFechaDocumentoPagoMesSuperior As New StringBuilder
+ Dim FoliosFechasValFechaDocumentoMesInferior As New StringBuilder
For Each gvRowVal As GridViewRow In GvCxP.Rows
@@ -422,12 +424,16 @@ Partial Class Compras_ReembolsosComprobaciones
Dim MesDocumento As Integer = FechaDocumento.Month
If AnioFactura > AnioDocumento Then
- FoliosFechasValFechaDocumento.AppendLine($"Folio: { gvRowVal.DataKey("SerieFolio") } fecha: {gvRowVal.DataKey("FechaCompra").ToDate.ToString("dd/MM/yyyy") }
")
+ FoliosFechasValFechaDocumentoAnio.AppendLine($"Folio: { gvRowVal.DataKey("SerieFolio") } fecha: {gvRowVal.DataKey("FechaCompra").ToDate.ToString("dd/MM/yyyy") }
")
ValFechaDocumento = True
ElseIf AnioFactura = AnioDocumento And MesFactura > MesDocumento Then
- FoliosFechasValFechaDocumento.AppendLine($"Folio: { gvRowVal.DataKey("SerieFolio") } fecha: {gvRowVal.DataKey("FechaCompra").ToDate.ToString("dd/MM/yyyy") }
")
+ FoliosFechasValFechaDocumentoMesInferior.AppendLine($"Folio: { gvRowVal.DataKey("SerieFolio") } fecha: {gvRowVal.DataKey("FechaCompra").ToDate.ToString("dd/MM/yyyy") }
")
+ ValFechaDocumento = True
+ ElseIf AnioFactura = AnioDocumento And MesDocumento > MesFactura Then
+ FoliosFechasValFechaDocumentoPagoMesSuperior.AppendLine($"Folio: { gvRowVal.DataKey("SerieFolio") } fecha: {gvRowVal.DataKey("FechaCompra").ToDate.ToString("dd/MM/yyyy") }
")
ValFechaDocumento = True
End If
+
End If
Next
@@ -437,7 +443,13 @@ Partial Class Compras_ReembolsosComprobaciones
End If
If ValFechaDocumento Then
- Alert(FoliosFechasValFechaDocumento.ToString, TipoMensaje.MsgAdvertencia)
+
+ Dim strMensajeValFechas As String = ""
+ strMensajeValFechas = $"{strMensajeValFechas}{If(FoliosFechasValFechaDocumentoAnio.Length > 0, "Se seleccionarón facturas con fecha de año superior al año del pago:
" & FoliosFechasValFechaDocumentoAnio.ToString, "")}"
+ strMensajeValFechas = $"{strMensajeValFechas}{If(FoliosFechasValFechaDocumentoPagoMesSuperior.Length > 0, "Se seleccionarón facturas con fecha de mes inferior al mes del pago:
" & FoliosFechasValFechaDocumentoPagoMesSuperior.ToString, "")}"
+ strMensajeValFechas = $"{strMensajeValFechas}{If(FoliosFechasValFechaDocumentoMesInferior.Length > 0, "Se seleccionarón facturas con fecha de mes superior al mes del pago:
" & FoliosFechasValFechaDocumentoMesInferior.ToString, "")}"
+
+ Alert(strMensajeValFechas, TipoMensaje.MsgAdvertencia)
Exit Sub
End If
diff --git a/Compras/eFacturas.aspx b/Compras/eFacturas.aspx
index d5ac164f8..09a6f4be6 100644
--- a/Compras/eFacturas.aspx
+++ b/Compras/eFacturas.aspx
@@ -80,6 +80,9 @@
Personalizar
+
+ Registar Compras
+
@@ -184,11 +187,157 @@
+
+
+
+
+
+
+
+
+ Registro de Facturas
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Caja Chica
+ Viáticos
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
-
-
-
+
-
+
+
+
+
+
+
@@ -268,16 +389,7 @@
- <%-- --%>
- <%----%>
-
-
diff --git a/Compras/eFacturas.aspx.vb b/Compras/eFacturas.aspx.vb
index f844f6e0c..2596308da 100644
--- a/Compras/eFacturas.aspx.vb
+++ b/Compras/eFacturas.aspx.vb
@@ -13,9 +13,15 @@ Imports System.Threading.Tasks
Imports System.Xml
Imports ADSistemaLibrary.SatXml
Imports ADSistemaLibrary.SatXml.XmlSatCFDI
+'Imports ADSNetLibrary.SIGAPI.Helpers
+Imports ClsPaginas
+'Imports DocumentFormat.OpenXml.Spreadsheet
+'Imports DocumentFormat.OpenXml.Wordprocessing
Imports Extensiones
Imports Microsoft.Reporting.WebForms
Imports Newtonsoft.Json.Linq
+Imports Telerik.Web.Apoc
+
Partial Class Compras_eFacturas
Inherits ClsPaginas
@@ -773,9 +779,9 @@ Partial Class Compras_eFacturas
'If UsuarioActual.TienePermisoProceso(206) Then GvD.Columns(10).Visible = False
'If UsuarioActual.Empresa.Funcionalidad(156) = "1" Then GvD.Columns(5).Visible = True
- If UsuarioActual.TienePermisoProceso(81) Then GvD.Columns(13).Visible = True : GvD.Columns(14).Visible = True
- If UsuarioActual.TienePermisoProceso(206) Then GvD.Columns(12).Visible = False
- If UsuarioActual.Empresa.Funcionalidad(156) = "1" Then GvD.Columns(6).Visible = True
+ If UsuarioActual.TienePermisoProceso(81) Then GvD.Columns(14).Visible = True : GvD.Columns(15).Visible = True
+ If UsuarioActual.TienePermisoProceso(206) Then GvD.Columns(13).Visible = False
+ If UsuarioActual.Empresa.Funcionalidad(156) = "1" Then GvD.Columns(7).Visible = True
CargaGvBitacora()
@@ -786,6 +792,21 @@ Partial Class Compras_eFacturas
GVSolicitudesPendientes.Columns(8).Visible = True
End If
+ 'CARGA REGISTRO DE FACTURA
+
+
+ CargaClasificacionesComprobaciones()
+ CargaClasificaciones()
+ CargaPS(-1)
+ CargaPersoanlCajaChica()
+ CargaPersonalViaticos()
+ CargaDdlRetIVA()
+ CargaDdlRetISR()
+
+ Dim LblSubProyectoTemp As New Label
+ CargarCentrosDeCosto(Nothing, DdlSubProyecto, Nothing, LblSubProyectoTemp, "Seleccione")
+ LblSubProyecto.InnerText = $"{LblSubProyectoTemp.Text}:"
+
End If
removeasincevent()
End Sub
@@ -999,7 +1020,7 @@ Partial Class Compras_eFacturas
Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvD.RowDataBound
If e.Row.RowType = DataControlRowType.Header Then
- e.Row.Cells(4).Attributes.Add("data-tipodato", "numeric")
+ e.Row.Cells(5).Attributes.Add("data-tipodato", "numeric")
End If
If e.Row.RowType = DataControlRowType.DataRow Then
@@ -1025,7 +1046,7 @@ Partial Class Compras_eFacturas
End Select
- e.Row.Cells(2).Attributes.Add("data-order", e.Row.DBCampo("FechaFactura").ToDate.Ticks.ToString)
+ e.Row.Cells(3).Attributes.Add("data-order", e.Row.DBCampo("FechaFactura").ToDate.Ticks.ToString)
'e.Row.Cells(4).Attributes.Add("data-order", Convert.ToInt64(e.Row.DBCampo("Total").ToDecimal).ToString.PadLeft(10, "0"c))
@@ -1057,12 +1078,12 @@ Partial Class Compras_eFacturas
e.Row.FCLiteral("LtlValidado").Visible = True
If e.Row.DBCampo("FueValidado") = "2" Then
e.Row.FCLiteral("LtlValidado").Text = "Cancelada"
- e.Row.ForeColor = Drawing.Color.Red
- e.Row.FCHyperLink("HplProveedor").ForeColor = Drawing.Color.Red
+ e.Row.ForeColor = System.Drawing.Color.Red
+ e.Row.FCHyperLink("HplProveedor").ForeColor = System.Drawing.Color.Red
ElseIf e.Row.DBCampo("FueValidado") = "3" Then
e.Row.FCLiteral("LtlValidado").Text = "Omitida"
- e.Row.ForeColor = Drawing.Color.Gray
- e.Row.FCHyperLink("HplProveedor").ForeColor = Drawing.Color.Gray
+ e.Row.ForeColor = System.Drawing.Color.Gray
+ e.Row.FCHyperLink("HplProveedor").ForeColor = System.Drawing.Color.Gray
End If
Else
If e.Row.DBCampo("TipoFactura") = "CFD" Then
@@ -1114,6 +1135,13 @@ Partial Class Compras_eFacturas
If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then
End If
+
+ If Not e.Row.DataKey("CveProveedor").ToEntero > 0 Then
+
+ e.Row.FCCheckBox("chkRegistraFactura").Visible = False
+
+ End If
+
End If
End Sub
Protected Sub GvDatos_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvD.RowUpdating
@@ -1221,12 +1249,12 @@ Partial Class Compras_eFacturas
e.Row.FCLiteral("LtlValidado").Visible = True
If e.Row.DBCampo("FueValidado") = "2" Then
e.Row.FCLiteral("LtlValidado").Text = "Cancelada"
- e.Row.ForeColor = Drawing.Color.Red
- e.Row.FCHyperLink("HplProveedor").ForeColor = Drawing.Color.Red
+ e.Row.ForeColor = System.Drawing.Color.Red
+ e.Row.FCHyperLink("HplProveedor").ForeColor = System.Drawing.Color.Red
ElseIf e.Row.DBCampo("FueValidado") = "3" Then
e.Row.FCLiteral("LtlValidado").Text = "Omitida"
- e.Row.ForeColor = Drawing.Color.Gray
- e.Row.FCHyperLink("HplProveedor").ForeColor = Drawing.Color.Gray
+ e.Row.ForeColor = System.Drawing.Color.Gray
+ e.Row.FCHyperLink("HplProveedor").ForeColor = System.Drawing.Color.Gray
End If
Else
If e.Row.DBCampo("TipoFactura") = "CFD" Then
@@ -5022,7 +5050,7 @@ Partial Class Compras_eFacturas
Protected Sub LnkModalPersonalizar_Click(sender As Object, e As EventArgs)
- GvD.Columns(11).Visible = ChkModalPersonalzarFolioFiscal.Checked
+ GvD.Columns(12).Visible = ChkModalPersonalzarFolioFiscal.Checked
GvPagos.Columns(9).Visible = ChkModalPersonalzarFolioFiscal.Checked
GvTraslados.Columns(9).Visible = ChkModalPersonalzarFolioFiscal.Checked
@@ -5059,8 +5087,2251 @@ Partial Class Compras_eFacturas
End Sub
+
+
+#Region "REGISTRO DE FACTURAS"
+
+ Private Property DTClasificacionesComprobaciones As DataTable
+ Get
+
+ If ViewState("DTClasificacionesComprobaciones") Is Nothing Then
+ Return New DataTable
+ Else
+ Return DirectCast(ViewState("DTClasificacionesComprobaciones"), DataTable)
+ End If
+
+ End Get
+ Set(value As DataTable)
+ ViewState("DTClasificacionesComprobaciones") = value
+ End Set
+ End Property
+
+
+ Private Property EstaAsociadoACajaChica() As Boolean
+ Get
+ Return If(IsNothing(ViewState("EstaAsociadoACajaChica")), False, CBool(ViewState("EstaAsociadoACajaChica")))
+ End Get
+ Set
+ ViewState("EstaAsociadoACajaChica") = Value
+ End Set
+ End Property
+
+ Private Property EstaAsociadoAPersonal() As Boolean
+ Get
+ Return If(IsNothing(ViewState("EstaAsociadoAPersonal")), False, CBool(ViewState("EstaAsociadoAPersonal")))
+ End Get
+ Set
+ ViewState("EstaAsociadoAPersonal") = Value
+ End Set
+ End Property
+
+ Private Property CveMoneda As Integer
+ Get
+ Return ViewState("CveMoneda").ToString.ToEntero
+ End Get
+ Set(value As Integer)
+ ViewState("CveMoneda") = value
+ End Set
+ End Property
+ Private Property IdCuentaBancaria As Integer
+ Get
+ Return ViewState("IdCuentaBancaria").ToString.ToEntero
+ End Get
+ Set(value As Integer)
+ ViewState("IdCuentaBancaria") = value
+ End Set
+ End Property
+
+
+
+ Private Sub CargaClasificacionesComprobaciones()
+
+ If UsuarioActual.TienePermisoProceso(300) Or UsuarioActual.TienePermisoProceso(301) Then
+
+ Dim ObjClasificaciones As New ClsClasificaciones()
+
+ If ObjClasificaciones.GetClasificacionesComprobaciones(UsuarioActual.CveEmpresa) Then
+
+ If UsuarioActual.TienePermisoProceso(300) And UsuarioActual.TienePermisoProceso(301) Then
+ DTClasificacionesComprobaciones = ObjClasificaciones.DtResultados
+ Else
+
+ If UsuarioActual.TienePermisoProceso(300) Then 'TipoComprobacion = 1 Biaticos
+ DTClasificacionesComprobaciones = ObjClasificaciones.DtResultados.FiltraParametros("TipoComprobacion = 1")
+ ElseIf UsuarioActual.TienePermisoProceso(301) Then 'TipoComprobacion = 2 Comprobaciones
+ DTClasificacionesComprobaciones = ObjClasificaciones.DtResultados.FiltraParametros("TipoComprobacion = 2")
+ End If
+
+ End If
+ End If
+
+ ObjClasificaciones.Dispose()
+
+ End If
+
+ End Sub
+
+ Private Sub CargaClasificaciones()
+ DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion")
+ DdlClasificacion.DataBind()
+ End Sub
+
+ Private Sub CargaPS(CveClasificacion As Integer)
+
+ DdlPS.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
+
+ If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then
+ DdlPS.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue)
+ DdlPS.SelectedText = ""
+ DdlPS.SelectedValue = "-1"
+ Else
+ DdlPS.ddl.Items.Clear()
+
+ 'DdlPS.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacion)
+
+ If UsuarioActual.TienePermisoProceso(300) Or UsuarioActual.TienePermisoProceso(301) Then
+
+ Dim DTTemp As New DataTable
+ DTTemp.Columns.Add("CvePS", GetType(Integer))
+ DTTemp.Columns.Add("PSCodigo", GetType(String))
+ DTTemp.Columns.Add("CveClasificacion", GetType(Integer))
+
+ For Each dRow As DataRow In GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).Rows
+ For Each drowCla As DataRow In DTClasificacionesComprobaciones.Rows
+
+ If drowCla("CveClasificacion").ToString.ToEntero = dRow("CveClasificacion").ToString.ToEntero Then
+
+ Dim InRow As DataRow = DTTemp.NewRow
+ InRow("CvePS") = dRow("CvePS").ToString.ToEntero
+ InRow("PSCodigo") = dRow("PSCodigo").ToString
+ InRow("CveClasificacion") = dRow("CveClasificacion").ToString.ToEntero
+ DTTemp.Rows.Add(InRow)
+
+ End If
+ Next
+ Next
+
+
+ DdlPS.DataSource = If(CveClasificacion > 0, DTTemp.FiltraParametros($"CveClasificacion = {CveClasificacion}"), DTTemp)
+
+ Else
+ DdlPS.DataSource = If(CveClasificacion > 0, GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros($"CveClasificacion = {CveClasificacion}"), GlobalDTPSSimplificado(UsuarioActual.CveEmpresa))
+ End If
+
+ DdlPS.ddl.DataBind()
+ DdlPS.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1"))
+ End If
+
+
+
+ End Sub
+
+
+ Protected Sub RBLContado_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RBLContado.SelectedIndexChanged
+
+ CargaContado()
+ End Sub
+
+ Private Sub CargaContado()
+
+
+ DivPersonalReembolso.Visible = False
+ DivCuentaCajaChicaReembolso.Visible = False
+
+
+ Select Case RBLContado.SelectedValue
+
+ Case "2" ' F y E
+ DivPersonalReembolso.Visible = True
+ RfvTxtNumeroReembolso.Enabled = True
+ TxtNumeroReembolso.Text = ""
+ Case "6" ' Caja Chica
+ DivCuentaCajaChicaReembolso.Visible = True
+ RfvTxtNumeroReembolso.Enabled = True
+ TxtNumeroReembolso.Text = ""
+ End Select
+
+ UpRegistroFacturas.Update()
+
+ End Sub
+
+ Private Sub CargaPersoanlCajaChica()
+ Dim dt As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa)
+ dt = dt.FiltraParametros(String.Format("CveTipoCuenta = 1"))
+ DdlCuentaCajaChicaReembolso.DataSource = dt
+ DdlCuentaCajaChicaReembolso.DataBind()
+ End Sub
+
+ Private Sub CargaPersonalViaticos()
+ Dim dtpersonal As DataTable = GlobalDTRHPersonal(UsuarioActual.CveEmpresa)
+ DdlPersonalReembolso.DataSource = dtpersonal.FiltraParametros("CveEstatusPersonal = 1")
+ DdlPersonalReembolso.DataBind()
+ End Sub
+
+ Private Sub CargaDdlRetIVA()
+ DdlRetIVAConcepto.Items.Insert(0, New ListItem("Honorarios/Serv. Prof.", "1"))
+ DdlRetIVAConcepto.Items.Add(New ListItem("Arrendamiento", "4"))
+ DdlRetIVAConcepto.Items.Insert(0, New ListItem("Fletes P.F.", "2"))
+ DdlRetIVAConcepto.Items.Add(New ListItem("Resico", "5"))
+ DdlRetIVAConcepto.Items.Add(New ListItem("General", "6"))
+ End Sub
+
+
+ Private Sub CargaDdlRetISR()
+ DdlRetISRConcepto.Items.Insert(0, New ListItem("Honorarios", "1"))
+ DdlRetISRConcepto.Items.Insert(1, New ListItem("Arrendamiento", "2"))
+ DdlRetISRConcepto.Items.Insert(1, New ListItem("Resico", "3"))
+ End Sub
+
+
+
+ Protected Sub DdlPersonal2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPersonalReembolso.SelectedIndexChanged
+ ViewState("CvePersonal") = DdlPersonalReembolso.SelectedValue
+ If DdlPersonalReembolso.SelectedValue.ToEntero > 0 Then
+ EstaAsociadoAPersonal = True
+ End If
+ End Sub
+ Protected Sub DdlCajaChica2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuentaCajaChicaReembolso.SelectedIndexChanged
+ Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("CveCuenta = " & DdlCuentaCajaChicaReembolso.SelectedValue)
+
+ If dr IsNot Nothing Then
+ CveMoneda = dr("CveMoneda").ToString.ToEntero
+ IdCuentaBancaria = dr("IdCtaContable").ToString.ToEntero
+ EstaAsociadoACajaChica = True
+ End If
+ ViewState("CveCajaChica") = DdlCuentaCajaChicaReembolso.SelectedValue
+ End Sub
+
+#End Region
+
+
+
+
+ Protected Sub LnkRegistarFactura_Click(sender As Object, e As EventArgs)
+ DVRegistraFacturas.Visible = True
+ GvD.Columns(0).Visible = True
+
+ UpRegistroFacturas.Update()
+ UpDatos.Update()
+ End Sub
+
+ Protected Sub BtnGuardarFacturas_Click(sender As Object, e As EventArgs)
+
+
+
+ For Each GvRow As GridViewRow In GvD.Rows
+ If GvRow.FCCheckBox("").Checked Then
+
+ Dim CFDIXmlPath As String = $"{UsuarioActual.Empresa.Ruta}Compras\{GvRow.DataKey("RFCDe")}\{GvRow.DataKey("XML")}"
+ If Not File.Exists(CFDIXmlPath) Then
+ Exit For
+ End If
+
+ Dim CompraActual As New Compra2(CFDIXmlPath, Compra2.EnumCargaCompra.DesdeArchivo, GlobalDTTiposGastos(UsuarioActual.CveEmpresa), UsuarioActual)
+
+ CompraActual.CveProveedor = GvRow.DataKey("CveProveedor").ToEntero
+ CompraActual.CveTipoProveedor = GvRow.DataKey("CveTipoProveedor").ToEntero
+ CompraActual.CveEstatusFactura = -1
+ CompraActual.CvePrePoliza = -1
+ CompraActual.TipoCompra = Compra2.EnumTipoCompra.Sin_definir
+ CompraActual.IEPSGasto = True
+
+
+
+ Dim ObjCompras As New ClsCompras
+ Dim ObjConta As New ClsContabilidad(ObjCompras.IniciaTransacSQL)
+
+ Dim ConceptoPoliza As String = String.Format("{0} - {1} - {2}", GvRow.DataKey("NombreProveedor"), GvRow.DataKey("SerieFolio"), "")
+
+ CompraActual.CvePrePoliza = ObjConta.AddPrePolizas("eFacturas/Registrar", 1, CompraActual.Total, CompraActual.Total, CompraActual.CveMoneda, CompraActual.Fecha, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, "", CveTipoPoliza:=3)
+
+ CompraActual.ConfiguraRegistroRapidoReembolso(DdlPS.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero, DdlPersonalReembolso.SelectedValue.ToEntero,
+ DdlRetIVAConcepto.SelectedValue.ToEntero, DdlRetISRConcepto.SelectedValue.ToEntero)
+
+ 'CompraActual.AddCompra()
+
+
+
+
+ 'If ObjCompras.AddCompra"Fac", TxtDescripcion.Text.Trim, CompraActual.SerieFolio, CompraActual.Folio, CompraActual.FolioSecundario, CompraActual.CveProveedor, CompraActual.SubTotal, CompraActual.Descuentos,
+ ' CompraActual.Amortizacion, CompraActual.IVA, CompraActual.RetIVA, CompraActual.RetISR, CompraActual.IEPS, CompraActual.OtrosImpuestos,
+ ' CompraActual.Redondeo, CompraActual.Total, CompraActual.Fecha, CompraActual.CveMoneda, CompraActual.TipoCambio, If(CompraActual.FechaPago = Nothing, CompraActual.Fecha, CompraActual.FechaPago), CompraActual.AplicaNotaCredito, CompraActual.Observaciones, CompraActual.CveEstatusFactura,
+ ' CompraActual.CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CompraActual.IdPoliza, CveCajaChica:=CompraActual.CveCajaChica, CvePersonal:=CompraActual.CvePersonal, NumeroReembolso:=CompraActual.NumeroReembolso, CveProveedorSucursal:=CompraActual.CveProveedorSucursal,
+ ' AplicoPromocion:=CompraActual.AplicoPromocion, PorcentajeIVA:=CompraActual.PorcentajeIVA, CveMetodoPago:=CompraActual.CveMetodoPago, CveRetIVAConcepto:=CompraActual.CveRetIVAConcepto,
+ ' CveConceptoContableAlmacen:=CompraActual.CveConceptoContableAlmacen,
+ ' CveRetISRConcepto:=CompraActual.CveRetISRConcepto, NoDeducible:=CompraActual.NoDeducible, CveTipoCompra:=CompraActual.CveTipoCompra, TotalOriginal:=CompraActual.TotalOriginal, CveTipoConcepto:=CompraActual.CveTipoConcepto,
+ ' EsImportacion:=CompraActual.EsImportacion, CveFactura:=CompraActual.CveFactura, CveSubProyecto:=CompraActual.CveSubProyectoPrincipal, DoctosRelacionados:=CompraActual.DocumentosRelacionadosUUIDSString, CveFolioGarantia:=CompraActual.CveFolioGarantia) Then
+
+
+ ' CompraActual.CveCompra = ObjCompras.CveCompra
+
+ ' If CompraActual.CveCompra > 0 Then
+
+
+ ' 'For Each Row As DataRow In CompraActual.TmpDT.Rows
+ ' ' If Not ObjCompras.AddCompraDetalle(CompraActual.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
+
+ ' ' ErrorDetalles = True
+ ' ' Exit For
+ ' ' End If
+ ' 'Next
+
+
+
+ ' End If
+
+
+ 'End If
+
+
+
+ ObjCompras.RollBack()
+ End If
+ Next
+
+ End Sub
End Class
+Public Class Compra2
+
+ Enum EnumCargaCompra
+ DesdeXML
+ DesdeArchivo
+ 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 Descuentos 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 Property IdCtaContableProv As Integer = -1
+ Public Property IdCtaContableProvComplementaria As Integer = -1
+ Public Property IdCtaContableAnticipoProv As Integer = -1
+ Public Property IdCtaContableAnticipoProvComplementaria As Integer = -1
+ 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
+ If UsuarioActual.Empresa.TipoContabilidad = 2 Then
+ Dim ObjConta As New ClsContabilidad
+ If UsuarioActual.Empresa.Funcionalidad(FuncionalidadxAcred).ToEntero > 0 Then
+ Ret.IdCtaContablexAcreditar = UsuarioActual.Empresa.Funcionalidad(FuncionalidadxAcred).ToEntero
+ Else
+ If ObjConta.GetRetCuenta(Ret.CveConceptoxAcreditar, UsuarioActual.CveEmpresa) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then Ret.IdCtaContablexAcreditar = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
+ End If
+ End If
+ If UsuarioActual.Empresa.Funcionalidad(Funcionalidad).ToEntero > 0 Then
+ Ret.IdCtaContableAcreditable = UsuarioActual.Empresa.Funcionalidad(Funcionalidad).ToEntero
+ Else
+ If ObjConta.GetRetCuenta(Ret.CveConceptoAcreditable, UsuarioActual.CveEmpresa) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then Ret.IdCtaContableAcreditable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
+ End If
+ End If
+ ObjConta.Dispose()
+ 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
+ If UsuarioActual.Empresa.TipoContabilidad = 2 Then
+ Dim ObjConta As New ClsContabilidad
+ If UsuarioActual.Empresa.Funcionalidad(FuncionalidadxAcred).ToEntero > 0 Then
+ Ret.IdCtaContablexAcreditar = UsuarioActual.Empresa.Funcionalidad(FuncionalidadxAcred).ToEntero
+ Else
+ If ObjConta.GetRetCuenta(Ret.CveConceptoxAcreditar, UsuarioActual.CveEmpresa) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then Ret.IdCtaContablexAcreditar = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero
+ End If
+ End If
+ If UsuarioActual.Empresa.Funcionalidad(Funcionalidad).ToEntero > 0 Then
+ Ret.IdCtaContableAcreditable = UsuarioActual.Empresa.Funcionalidad(Funcionalidad).ToEntero
+ Else
+ If ObjConta.GetRetCuenta(Ret.CveConceptoAcreditable, UsuarioActual.CveEmpresa) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then Ret.IdCtaContableAcreditable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero
+ End If
+ End If
+ ObjConta.Dispose()
+ 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)
+ Public ReadOnly Property DocumentosRelacionadosUUIDSString As String
+ Get
+ Return GeneraStringDoctosRelacionados()
+ End Get
+ End Property
+
+ Public Property DocumentosRelacionadosAnticiposUUIDList As 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 TrasladoIEP 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
+
+ Public ReadOnly Property MSG_Error 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 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 = 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
+ Descuentos = 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" And (CFDIVersion = EnumCFDIVersion.V33 Or 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 = False
+
+ Dim nodeconceptos As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Conceptos", Prefijo), namespaces)
+ Dim XML = 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
+ Dim mensajeAdvertencia As String = String.Format("El comprobante contiene productos con código SAT '01010101', revise los productos:{0}", ProductosCodigoSATNoPermitidos.ToString)
+ Alert(mensajeAdvertencia, TipoMensaje.MsgAdvertencia)
+ 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
+
+
+
+
+#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) As Boolean
+
+ Dim respuesta As Boolean = True
+ Me.CveSubProyecto = CveSubProyecto
+ Me.CveCajaChica = CveCajaChica
+ Me.CvePersonal = CvePersonal
+ Me.CveRetIVAConcepto = CveRetIVAConcepto
+ Me.CveRetISRConcepto = CveRetISRConcepto
+
+ 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
+ End If
+ End If
+
+ If respuesta Then
+
+ '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
+
+ End If
+
+ Return respuesta
+
+ End Function
+
+ Private Function ValidaTotalesGuardar() As Boolean
+ Dim EsValido = 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 = Descuentos + 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 = 0.6
+
+ 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 = 0.0D
+ 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 += Descuentos
+ 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.RoundAD(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
+
+ 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 = TmpDT.SUM("Total").ToString.ToDecimal
+
+ Me.SubTotal = Math.Round(SubTotalIEPS, 2)
+ Me.SubTotalConceptos = Math.Round(SubTotalIEPS, 2)
+
+ 'If SubTotalR <> SubTotalIEPS Then
+ ' Dim IA As Decimal = SubTotalR - SubTotalIEPS
+ ' AjustaImporteUltimoConcepto(IA)
+ 'End If
+
+ 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 = -1
+ Dim CveSubProyecto = -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 = 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
+ 'If GlobalDTProductosServiciosEquivalencias(CvePS, CveUM).Rows.Count = 0 Then Row("CveEq") = 1 Else Row("CveEq") = 0
+ 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
+
+ ' CveProgramaOperativo AS Integer = -1, Optional CveUnidadAdministrativa, Optional CveUnidadAdministrativa AS Integer = -1,, Optional CveFuenteFinanciamiento AS Integer = -1, Optional CveTipoGastoAC AS Integer = -1, Optional CveClasificacionOG AS Integer = -1,
+
+ '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
+
+
+ 'If CalculaIVA Then IVA = TxtIVA.Text.ToDouble
+ LocalDescuentos = TmpDT.SUMD("Descuento")
+
+ '[IPP] SI YA ES COMPRA REGISTRADA NO CONSIDERA LA AMORTIZACIÓN PARA EL CALCULO DE TOTAL
+ If Not CveCompra > 0 Then
+ LocalAmortizacion = Me.Amortizacion
+ End If
+
+ 'RETENCIONES
+ Dim Retenciones = 0D
+ Retenciones = LocalRetIVA
+ Retenciones += LocalRetISR
+
+
+ LocalSubTotal2 = LocalSubTotal - LocalDescuentos ' - Amortizacion '[IPP] COMENTADO CASO JAM 12653 CON NC 27122 | 23/MAYO/2018
+ LocalTotal = LocalSubTotal2 + LocalIVA + LocalIEPSPS - Retenciones
+
+ 'ASIGNAMOS VALORES A VISTA
+ If CveCompra > 0 Or CveFactura > 0 Or Me.OCVinculada Then
+ SubTotal = LocalSubTotal
+ SubTotal2 = LocalSubTotal2
+ Descuentos = LocalDescuentos
+
+ If EsNoDeducible Then
+ IVA = LocalIVA
+ RetIVA = LocalRetIVA
+ RetISR = LocalRetISR
+ IEPS = LocalIEPSPS
+ End If
+
+ Total = LocalTotal
+ Else
+ SubTotal = LocalSubTotal
+ SubTotal2 = LocalSubTotal2
+ IVA = LocalIVA
+ Descuentos = LocalDescuentos
+ RetIVA = LocalRetIVA
+ RetISR = LocalRetISR
+ IEPS = LocalIEPSPS
+ Total = LocalTotal
+ 'VALORES PROPIEDAD
+ CompraSaldo = LocalTotal
+
+ End If
+
+ 'CUANDO SEA COMPRA, FACTURA O VENGA DE VINCULACIÓN OC NO SE MODIFICAN VALORES
+ 'SE VERIFICA SI ALGUN DATO ES DIFERENTE PARA MOSTRAR COLUMNA CON VALORES ORIGINALES
+ 'If (CveCompra > 0 Or CveFactura > 0 Or OCVinculada) And Not EsNoDeducible Then
+ ' If LocalSubTotal <> SubTotalOriginal Then
+ ' OriginalesVisible(True)
+ ' LbSubTotalOriginal.Text = SubTotalOriginal.ToString.FormatoNumero(2)
+ ' Else
+ ' OriginalesVisible(False)
+ ' End If
+ 'End If
+
+ 'If Not CveCompra > 0 Then 'cuando se está registrando manualmente y se va amortizar
+ ' LblSaldoFactura.Text = TxtTotal.Text.FormatoNumero
+ ' UpAnticipos.Update()
+ 'End If
+
+ 'LblRetIVA.Text = If(TxtRetIVA.Text.ToDecimal > 0, (TmpDT.MAX("RetIVAPorcentaje").ToDecimal() * 100).FormatoNumero(4), "")
+ 'LblRetISR.Text = If(TxtRetISR.Text.ToDecimal > 0, (TmpDT.MAX("RetISRPorcentaje").ToDecimal() * 100).FormatoNumero(4), "")
+
+ 'IMPORTES DE RESTRICCION
+ 'TxtDocumentoImporteFE.Text = LocalTotal.ToString.FormatoNumero(2)
+ 'RVDocumentoImporte.MaximumValue = LocalTotal.ToString.FormatoNumero(2)
+ 'RVDocumentoImporteFE.MaximumValue = RVDocumentoImporte.MaximumValue
+ 'RVDocumentoImporteCaja.MaximumValue = RVDocumentoImporte.MaximumValue
+
+ 'CargaRetIVAConcepto()
+ 'CargaRetISRConcepto()
+
+ Me.NumNoDed = TmpDT.COUNT("CvePS", "NoDeducible = True ")
+
+ 'If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") And CveFactura <= 0 Then
+ ' InicializaAplicaNCFact()
+ 'End If
+
+ 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
+
+
+ 'BANDERA
+ 'Dim AplicaCalculaTotales = False
+
+ '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 = DrPS("Cantidad").ToString.ToDouble
+ Dim PU = DrPS("PU").ToString.ToDouble
+ Dim Descuento = DrPS("Descuento").ToString.ToDouble
+ Dim Total = (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") = ""
+
+ 'RESPETAR VALORES DE LA PANTALLA
+ 'IVA = PSRow("IVA").ToString.ToDouble
+ 'If IVA = -1 Then
+ ' IVA = GlobalDTSubProyectos(-1, DdlSubProyecto.SelectedValue.ToEntero()).FiltroPrimeroValor("IVA").ToDouble
+ 'End If
+ 'RetIVA = If(PSRow("RetIVA").ToString = "-1", ViewState("RetIVA"), PSRow("RetIVA").ToString).ToString.ToDouble
+ 'RetISR = If(PSRow("RetISR").ToString = "-1", ViewState("RetISR"), PSRow("RetISR").ToString).ToString.ToDouble
+ 'IEPSPS = If(PSRow("IEPSPorcentaje").ToString = "-1", ViewState("IEPSPS"), PSRow("IEPSPorcentaje").ToString).ToString.ToDouble
+ 'IEPSPSIVA = If(PSRow("IEPSGrabaIVA").ToString = "True", PSRow("IEPSPorcentaje").ToString.ToDouble, 0)
+ Else
+ Errores.AppendLine($"No se encontrol el producto con CvePS {CvePS}")
+ Respuesta = False
+ End If
+
+
+ 'UM
+
+
+ 'TIPO DE GASTO
+
+
+
+
+ 'IMPUESTOS: SI ES COMPRA, FACUTRA O CON OC, NO MODIFICA IMPUESTOS!!
+ 'Dim IVA = (TxtIVAModal.Text.ToDouble / 100)
+ 'Dim IVA = Math.Round(DdlIVA.SelectedValue.ToDecimal - 1, 2)
+ 'Dim RetISR = (TxtRetISRModal.Text.ToDecimal / 100)
+ 'Dim RetIVA = (TxtRetIVAModal.Text.ToDecimal / 100)
+ 'Dim IEPSPS = (TxtIEPSModal.Text.ToDecimal / 100)
+ 'Dim IEPSPSIVA = 0
+
+ 'I f Not (CveCompra > 0 Or CveFactura > 0 Or OCVinculada) Then
+ 'If DdlIVA.SelectedValue.ToDouble = 0 Then DrPS("IVA") = 0 Else DrPS("IVA") = IVA * Total
+
+ 'If CveFactura > 0 And TxtIVA.Text.ToDecimal = 0 Then
+ ' DrPS("IVA") = 0
+ ' DrPS("IVAPorcentaje") = 0
+ 'Else
+
+ ' If ActualizarIva Then
+ ' DrPS("IVA") = (IVA * Total).RoundSQL
+ ' End If
+
+ ' DrPS("IVAPorcentaje") = IVA
+ 'End If
+
+ 'DrPS("RetIVA") = (RetIVA * Total).RoundSQL
+ 'DrPS("RetIVAPorcentaje") = RetIVA
+ 'DrPS("RetISR") = RetISR * Total
+ 'DrPS("RetISRPorcentaje") = RetISR
+ 'DrPS("IEPSPS") = (IEPSPS * Total).RoundSQL
+ 'DrPS("IEPSPSPorcentaje") = IEPSPS
+ 'DrPS("IEPSPSIVA") = (IEPSPSIVA * Total).RoundSQL
+ 'DrPS("IEPSPSIVAPorcentaje") = IEPSPSIVA
+
+
+
+ '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 TxtIEPS.Text.ToDecimal = 0 Then
+ ' DrPS("IEPSPS") = 0
+ ' DrPS("IEPSPSPorcentaje") = 0
+ 'End If
+
+
+
+
+ 'AplicaCalculaTotales = True
+ TmpDT.AcceptChanges()
+ Return Respuesta
+ End Function
+
+
+
+
+ 'Private Function AsignarPSReembolso(CvePS As Integer) As Boolean
+
+ ' Dim respuesta As Boolean
+
+ ' If Not CvePS > 0 Then
+ ' Errores.AppendLine("AsignarPSReembolso el CvePS debe de ser matoy a 0,")
+ ' Return False
+ ' End If
+
+
+ ' 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 = TmpDT.SUMD("Total") + Math.Round(TmpDT.SUM("Descuento") + Math.Round(TmpDT.SUM("Amortizacion")), 2).ToDecimal
+ Dim DescuentosTemp = TmpDT.SUMD("Descuento")
+ Dim Subtotal2Temp = TmpDT.SUMD("Total")
+ Dim IVATemp = TmpDT.SUMD("IVA")
+ Dim IEPSTemp = TmpDT.SUMD("IEPSPS")
+ Dim RetIVATemp = TmpDT.SUMD("RetIVA")
+ Dim RetISRTemp = 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(Descuentos, 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
+ '[IPP] IGUALAMOS VALORES PARA RESPETAR LOS DEL XML EN CASO DE DIF DE 0.01
+ DescuentosTemp = Descuentos
+ IVATemp = TrasladoIVA
+ TotalTemp = Total
+ RetIVATemp = RetencionIVA
+ RetISRTemp = RetencionISR
+ IEPSTemp = TrasladoIEPS
+ End If
+
+ If TrasladoIEPS > 0 Or OtrosImpuestos > 0 Then
+
+ If OtrosImpuestos > 0 Or TrasladoIEPS > 0 Then
+
+ 'If UsuarioActual.Empresa.Funcionalidad(713) = "1" Then
+ ' 'Si tiene funcionalidad y es Acreedor se muestra modal
+ ' If CveTipoProveedor.Contiene(2, 3) Then ' Acreedor
+ ' RegistraScript("$('#ModalIEPS').modal({ backdrop: 'static', keyboard: false },'show');")
+ ' End If
+ 'Else
+ ' 'Si no tiene funcionalidad y es proveedor se muestra
+ ' RegistraScript("$('#ModalIEPS').modal({ backdrop: 'static', keyboard: false },'show');")
+
+ 'End If
+
+ 'Else
+ ' RegistraScript("$('#ModalIEPS').modal('show');")
+ 'BtnCancelarotrosImpuestos.Visible = True
+ End If
+
+
+ If TrasladoIEPS > 0 Then
+ 'ChkIEPS.Visible = True
+ 'ChkIEPS.Checked = True
+ 'DdlConceptoIEPS.Visible = True
+ 'CargaProductos(DdlConceptoIEPS, If(UsuarioActual.Empresa.Funcionalidad(112).ToString.ToEntero > 0, UsuarioActual.Empresa.Funcionalidad(112).ToString.ToEntero, -1))
+ 'LbImporte.Text = "$" + TrasladoIEPS.ToString
+ End If
+ If OtrosImpuestos > 0 Then
+ 'ChkOtrosI.Visible = True
+ 'ChkOtrosI.Checked = True
+ 'DdlConceptoOI.Visible = True
+ 'CargaProductos(DdlConceptoOI, If(UsuarioActual.Empresa.Funcionalidad(305).ToString.ToEntero > 0, UsuarioActual.Empresa.Funcionalidad(305).ToString.ToEntero, -1))
+ 'LbImporte2.Text = "$" + OtrosImpuestos.ToString
+ End If
+ End If
+
+ 'TxtSubTotal.Text = SubtotalTemp.FormatoNumero
+ 'TxtDescuento.Text = DescuentosTemp.FormatoNumero
+ 'TxtSubTotal2.Text = Subtotal2Temp.FormatoNumero
+ 'TxtIVA.Text = IVATemp.FormatoNumero
+ 'TxtTotal.Text = TotalTemp.FormatoNumero
+ 'TxtRetIVA.Text = RetIVATemp.FormatoNumero
+ 'TxtRetISR.Text = RetISRTemp.FormatoNumero
+ 'TxtIEPS.Text = IEPSTemp.FormatoNumero
+
+ 'TrDescuento.Visible = DescuentosTemp > 0
+ 'TrIEPS.Visible = IEPSTemp > 0
+ 'TrRetIVA.Visible = RetIVATemp > 0
+ 'TrRetISR.Visible = RetISRTemp > 0
+
+ 'TxtSubTotal.Enabled = False
+ 'TxtDescuento.Enabled = False
+ 'TxtSubTotal2.Enabled = False
+ 'TxtIVA.Enabled = False
+ 'TxtTotal.Enabled = False
+ 'TxtRetIVA.Enabled = False
+ 'TxtRetISR.Enabled = False
+ 'TxtIEPS.Enabled = False
+
+ 'HfTotalCompra.Value = TotalTemp.ToString
+ 'CompraSaldo = TotalTemp
+ 'CalculaTotalPorDevengar()
+ 'TxtDocumentoImporteFE.Text = TotalTemp.ToString
+ 'RVDocumentoImporte.MaximumValue = Math.Round(TotalTemp, 2).ToString
+ 'RVDocumentoImporteFE.MaximumValue = RVDocumentoImporte.MaximumValue
+ 'RVDocumentoImporteCaja.MaximumValue = RVDocumentoImporte.MaximumValue
+ 'TxtDocumentoImporte.Text = TotalTemp.FormatoNumero
+ 'TxtDocumentoImporteCaja.Text = TotalTemp.FormatoNumero
+ 'TxtOtrosImpuestos.Text = OtrosImpuestos.FormatoNumero
+ 'If OtrosImpuestos > 0 Then TrOtrosImpuestos.Visible = True
+ 'If OtrosImpuestosRetenciones > 0 Then TrOtrosImpuestos.Visible = True : TxtOtrosImpuestos.Text = (-OtrosImpuestosRetenciones).FormatoNumero
+ 'HFDiferenciaCompra.Value = TxtTotal.Text
+ 'HdnCompraSaldo.Value = TotalTemp.ToString
+
+ CompraSaldo = TotalTemp
+
+ 'LblRetIVA.Text = If(RetIVATemp > 0, (TmpDT.MAX("RetIVAPorcentaje").ToDecimal() * 100).FormatoNumero(4), "")
+ 'LblRetISR.Text = If(RetISRTemp > 0, (TmpDT.MAX("RetISRPorcentaje").ToDecimal() * 100).FormatoNumero(4), "")
+
+ 'ASIGNA VALORES ORIGINALES PARA GUARDAR
+ 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 ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 Then
+ ' Amortizacion = LblAmortizacion.Text.ToDecimal
+ 'End If
+
+ 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)("IVAPorcentaje").ToString.ToDecimal
+ 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
+ 'Row("IEPSPS") = Math.Round(IEPSPS, DecimalesPermitidos)
+ 'Row("IEPSPSPorcentaje") = PorcentajeIEPS
+ TmpDT.AcceptChanges()
+ End If
+
+ SubTotal = TmpDT.SUMD("Total")
+ If Not EsCarga Then
+ Descuentos = 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
+
+End Class
+
+
+
+
+
+
+
+
+
+
Public Class GeneralesAPIeFacturas
diff --git a/Contabilidad/RepAnexoCatalogoSegmento.aspx b/Contabilidad/RepAnexoCatalogoSegmento.aspx
index dfcf45a3c..7110105ca 100644
--- a/Contabilidad/RepAnexoCatalogoSegmento.aspx
+++ b/Contabilidad/RepAnexoCatalogoSegmento.aspx
@@ -145,171 +145,170 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Contabilidad/RepAnexoCatalogoSegmento.aspx.vb b/Contabilidad/RepAnexoCatalogoSegmento.aspx.vb
index 84f411697..c22931cc4 100644
--- a/Contabilidad/RepAnexoCatalogoSegmento.aspx.vb
+++ b/Contabilidad/RepAnexoCatalogoSegmento.aspx.vb
@@ -3,6 +3,7 @@ Option Strict On
Imports System.Data
Imports Extensiones
+Imports Microsoft.Extensions.Primitives
Imports Microsoft.Reporting.WebForms
Partial Class AC_RepAnexoCatalogoSegmento
@@ -339,10 +340,19 @@ Partial Class AC_RepAnexoCatalogoSegmento
Protected Sub LnkExcel_Click(sender As Object, e As EventArgs) Handles LnkExcel.Click
'GvDatos.ExportToExcelG("RepAnexoCatalogoSegmento", "RepAnexoCatalogoSegmento", UsuarioActual)
- GvDatos.ExportToExcelX("RepAnexoCatalogoSegmento")
+ 'GvDatos.ExportToExcelX("RepAnexoCatalogoSegmento")
+ Dim SbFiltros As New StringBuilder()
+ SbFiltros.Append($"Fecha Inicio: {TxtFechaDel.Text} Fecha Fin: {TxtFechaAl.Text} ")
+ SbFiltros.Append($" Cuenta: {TxtCuenta.Text}")
+
+ GvDatos.ExportToExcelGembox($"RepAnexoCatalogoSegmento{Now.ToString("yyyyMMddhhss")}", UsuarioActual, "Anexo del Catálogo Por Segmento", DatoTituloExtra:=$"", DatosFiltros:=SbFiltros.ToString())
End Sub
+
+
+
+
'Private Sub ImprimirReporte(Optional Formato As String = "PDF")
- ' Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
+ ' Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
' 'ubicacion del rdlc
' Dim reportpath As String = "Contabilidad/Reportes/RepAnexoCatalogo.rdlc"
' 'nombre del reporte
diff --git a/RH/CatTurno.aspx.vb b/RH/CatTurno.aspx.vb
index f2bf474c2..db8defe5d 100644
--- a/RH/CatTurno.aspx.vb
+++ b/RH/CatTurno.aspx.vb
@@ -127,13 +127,7 @@ Partial Class RH_CatTurno
Private Sub CargaGlobalDTTurno()
- Dim ObjRH As New ClsRH
- If ObjRH.GetTurnos() Then
- Application("GlobalDTTurno") = ObjRH.DtResultados
- Else
- Application("GlobalDTTurno") = Nothing
- End If
- ObjRH.Dispose()
+ GlobalDTTurno(UsuarioActual.CveEmpresa) = Nothing
End Sub
Public Sub Delete_Click(sender As Object, e As EventArgs)
diff --git a/RH/Personal.aspx b/RH/Personal.aspx
index b18c06677..d576de5e0 100644
--- a/RH/Personal.aspx
+++ b/RH/Personal.aspx
@@ -2876,10 +2876,11 @@
-
-
+
+
Solicitar Vacaciones
+ <%--
Solicitar Vacaciones
-
+ --%>
@@ -3038,7 +3039,7 @@
-
+
@@ -3065,11 +3066,12 @@
-
@@ -5748,6 +5760,7 @@
+
@@ -5762,6 +5775,30 @@
height: 50
});
$('[data-toggle="tooltip"]').tooltip();
+
+
+
+ $("#Txtdiasinabiles").prop("readonly", true);
+ $("#Txtdiasinabiles").on("paste", function (event) {
+ event.preventDefault();
+ });
+ $("#Txtdiasinabiles").on("contextmenu", function (event) {
+ if (event.which === 3) {
+ event.preventDefault();
+ }
+ });
+
+
+ $("#TxtFechaFinVac").prop("readonly", true);
+ $("#TxtFechaFinVac").on("paste", function (event) {
+ event.preventDefault();
+ });
+ $("#TxtFechaFinVac").on("contextmenu", function (event) {
+ if (event.which === 3) {
+ event.preventDefault();
+ }
+ });
+
});
}
@@ -7276,5 +7313,11 @@
return pstCURP
}
+
+
+ function calculaFechasVacaciones(){
+ $('#LnkCalculaFechasVacaciones').click();
+ }
+
diff --git a/RH/Personal.aspx.vb b/RH/Personal.aspx.vb
index a96c4ffc3..4feea3f48 100644
--- a/RH/Personal.aspx.vb
+++ b/RH/Personal.aspx.vb
@@ -1896,6 +1896,8 @@ Partial Class RH_Personal
TxtFechaFinVac.Text = Now.AddDays(VacDiasDisponibles).ToString("dd/MM/yyyy")
+
+
'PERSONAL ALTAS
If ObjPersonal.GetPersonalAltas(CvePersonal) Then
GvPersonalAltas.DataSource = ObjPersonal.DtResultados
@@ -7814,5 +7816,60 @@ Partial Class RH_Personal
#End Region
+
+
+ Protected Sub LnkSolicitarVacaciones_Click(sender As Object, e As EventArgs)
+
+ TxtVacDiasPago.Text = VacDiasDisponibles.ToString
+
+ Dim diaDescanso As Integer = GlobalDTTurno(UsuarioActual.CveEmpresa).FiltroPrimeroValor("DiaDescanso", $" CveTurno = {DdlTurno.SelectedValue.ToEntero}").ToEntero
+ diaDescanso = If(diaDescanso <= 0, 1, diaDescanso)
+
+ ContarDiasDeLaSemana(TxtFechaInicioVac.Text.ToDate, TxtVacDiasPago.Text.ToEntero)
+
+ If Not diaDescanso > 0 Then
+ Alert("El turno no tiene día de descanso, provisionalmente se tomara el domingo.", TipoMensaje.MsgAdvertencia)
+ End If
+
+ RegistraScript("$('#ModalAddVacaciones').modal('show');")
+ End Sub
+
+
+ Private Sub ContarDiasDeLaSemana(fechaInicio As Date, diasVacaciones As Integer)
+
+ Dim diaDescanso As Integer = GlobalDTTurno(UsuarioActual.CveEmpresa).FiltroPrimeroValor("DiaDescanso", $" CveTurno = {DdlTurno.SelectedValue.ToEntero}").ToEntero
+ diaDescanso = If(diaDescanso <= 0, 1, diaDescanso)
+
+ Dim DiasAgregados As Integer = 0
+ Dim FechaFin As Date = fechaInicio
+
+ For x = 2 To diasVacaciones
+ Dim day_of_week = CType(FechaFin.DayOfWeek, Integer) + 1
+ If day_of_week = diaDescanso Then
+ FechaFin = FechaFin.AddDays(2)
+ DiasAgregados = DiasAgregados + 1
+ Else
+ FechaFin = FechaFin.AddDays(1)
+ day_of_week = CType(FechaFin.DayOfWeek, Integer) + 1
+ If day_of_week = diaDescanso Then
+ DiasAgregados = DiasAgregados + 1
+ End If
+
+ End If
+
+ Next
+
+ TxtFechaFinVac.Text = FechaFin.ToString
+ Txtdiasinabiles.Text = DiasAgregados.ToString
+
+ UpSolicitarVacaciones.Update()
+
+ End Sub
+
+ Protected Sub LnkCalculaFechasVacaciones_Click(sender As Object, e As EventArgs)
+
+ ContarDiasDeLaSemana(TxtFechaInicioVac.Text.ToDate, TxtVacDiasPago.Text.ToEntero)
+
+ End Sub
End Class