diff --git a/App_Code/ClsRH.vb b/App_Code/ClsRH.vb
index 912ed24d9..bd72d8ceb 100644
--- a/App_Code/ClsRH.vb
+++ b/App_Code/ClsRH.vb
@@ -4,6 +4,7 @@ Option Explicit On
Imports System.Data
Imports System.Data.SqlClient
Imports CrystalDecisions.[Shared].Json
+Imports DocumentFormat.OpenXml.Presentation
Imports Extensiones
Imports Microsoft.Ajax.Utilities
Imports Profact.TimbraCFDI40
@@ -2283,7 +2284,9 @@ Public Class ClsRH
End Try
Return Retorno
End Function
- Public Function UpdateSalarios(CvePersonal As Integer, Fecha As String, CveUsuario As Integer, CveEmpresa As Integer, SalarioDiario As Double, SDI As Double, SalarioDiarioSS As Double, SalarioDiarioPago As Double, Optional CalcularSDI As Boolean = False) As Boolean
+ Public Function UpdateSalarios(CvePersonal As Integer, Fecha As String, CveUsuario As Integer, CveEmpresa As Integer, SalarioDiario As Double, SDI As Double,
+ SalarioDiarioSS As Double, SalarioDiarioPago As Double, Optional CalcularSDI As Boolean = False, Optional ActualizaSalarioV As Boolean = False,
+ Optional OrigenU As String = "") As Boolean
Dim Retorno As Boolean = False
SqlDataAdapter("PA_RH_PersonalUpdateSalarios")
With SqlAdapter.SelectCommand.Parameters
@@ -2296,6 +2299,8 @@ Public Class ClsRH
.Add("@SDI", SqlDbType.Money).Value = SDI
.Add("@SalarioDiarioSS", SqlDbType.Money).Value = SalarioDiarioSS
.Add("@CalcularSDI", SqlDbType.Bit).Value = CalcularSDI
+ .Add("@ActualizaSalarioV", SqlDbType.Bit).Value = ActualizaSalarioV
+ .Add("@OrigenU", SqlDbType.Bit).Value = OrigenU
End With
Try
SqlAdapter.Fill(Data)
diff --git a/App_Code/ClsTransportes.vb b/App_Code/ClsTransportes.vb
index 07e43b962..e861b9e06 100644
--- a/App_Code/ClsTransportes.vb
+++ b/App_Code/ClsTransportes.vb
@@ -420,5 +420,24 @@ Public Class ClsTransportes
Return Retorno
End Function
+
+
+ Public Function VIA_FormularioTrip(cveTrip As Int32, cveUsuario As Int32, cveEmpresa As Int32) As Boolean
+ Dim retorno As Boolean = False
+ DataAdapter("PA_VIA_FormularioTrip", CommandType.StoredProcedure)
+ With SqlAdapter.SelectCommand.Parameters
+ .Add("@CveTrip", SqlDbType.Int).Value = cveTrip
+ .Add("@CveUsuario", SqlDbType.Int).Value = cveUsuario
+ .Add("@CveEmpresa", SqlDbType.Int).Value = cveEmpresa
+ End With
+
+ Try
+ SqlAdapter.Fill(Data)
+ retorno = True
+ Catch ex As Exception
+ OnError("Ocurrió un error al eliminar el importe.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
+ End Try
+ Return retorno
+ End Function
#End Region
End Class
diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb
index d89ca7f8b..a37c2505c 100644
--- a/App_Code/Modelos.vb
+++ b/App_Code/Modelos.vb
@@ -3962,14 +3962,14 @@ Namespace Modelos
If DT.Rows.Count > 0 Then
'Se agrega movimiento separado por la cuenta de ventas (ER)
For Each Row2 As DataRow In DT.Rows
- importeMovimiento = ((TmpDTDetalle.SUM("TotalImporte", String.Format("CveClasificacion = {0} AND CveSubProyecto = {1} AND PorcentajeIVA = {2}", Row2("CveClasificacion"), Row2("CveSubProyecto"), Row2("PorcentajeIVA"))).ToString.ToDecimal) * ValorMultiplicador)
+ importeMovimiento = ((TmpDTDetalle.SUM("TotalImporte", String.Format("CveClasificacion = {0} AND CveSubProyecto = {1} AND PorcentajeIVA = {2}", Row2("CveClasificacion").ToString.ToEntero, Row2("CveSubProyecto").ToString.ToEntero, Row2("PorcentajeIVA").ToString.ToDecimal)).ToString.ToDecimal) * ValorMultiplicador)
importeMX = importeMovimiento * tipoCambio * Multiplicador
FechaMovimiento = ObjFactura.FechaPago
Concepto = $"{ObjFactura.SerieFolio} {If(Row2("CveClasificacion").ToString.ToEntero > 0, ClsPaginas.GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString}"), "")} - {If(Row2("CveSubProyecto").ToString.ToEntero > 0, ClsPaginas.GlobalDTSubProyectos(UsuarioActual.CveEmpresa).FiltroPrimeroValor("SubProyecto", $"CveSubProyecto = {Row2("CveSubProyecto").ToString}"), "Sin SubProyecto Asignado")}"
If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
- 'Nota cuando es Nota de crédiot, debe de tomar el devoluciones y rebajas
+ 'Nota cuando es Nota de crédito, debe de tomar el devoluciones y rebajas
If importeMovimiento <> 0 Then
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, importeMX, ConceptoContableAplicar, Referencia, Concepto, CveVenta:=CveVentaAplicar, CveVentaAmortizacion:=CveVentaAmortizacionAplicar, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), TipoCambio:=tipoCambio, PorcentajeImpuesto:=Row2("PorcentajeIVA").ToString().ToDecimal) Then
@@ -3996,10 +3996,10 @@ Namespace Modelos
If DT.Rows.Count > 0 Then
'Se agrega movimiento separado por la cuenta de ventas (ER)
For Each Row2 As DataRow In DT.Rows
- importeMovimiento = (TmpDTDetalle.SUM("Descuento", String.Format("CveClasificacion = {0} And CveSubProyecto = {1}", Row2("CveClasificacion"), Row2("CveSubProyecto"))).ToString().ToDecimal) * ValorMultiplicador
+ importeMovimiento = (TmpDTDetalle.SUM("Descuento", String.Format("CveClasificacion = {0} And CveSubProyecto = {1} AND PorcentajeIVA = {2}", Row2("CveClasificacion"), Row2("CveSubProyecto"), Row2("PorcentajeIVA"))).ToString.ToDecimal) * ValorMultiplicador
importeMX = importeMovimiento * tipoCambio * Multiplicador
FechaMovimiento = ObjFactura.FechaPago
- Concepto = $"{ObjFactura.SerieFolio} {If(Row2("CveClasificacion").ToString().ToEntero() > 0, ClsPaginas.GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString()}"), "")} - {If(Row2("CveSubProyecto").ToString().ToEntero() > 0, ClsPaginas.GlobalDTSubProyectos(UsuarioActual.CveEmpresa).FiltroPrimeroValor("SubProyecto", $"CveSubProyecto = {Row2("CveSubProyecto").ToString()}"), "Sin SubProyecto Asignado")}"
+ Concepto = $"{ObjFactura.SerieFolio} {ClsPaginas.GlobalDTClasificaciones(UsuarioActual.CveEmpresa, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero).FiltroPrimeroValor("Clasificacion")} - {ClsPaginas.GlobalDTSubProyectos(UsuarioActual.CveEmpresa).FiltroPrimeroValor("SubProyecto", $"CveSubProyecto = {Row2("CveSubProyecto").ToString.ToEntero}") }"
If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
'Nota cuando es Nota de crédiot, debe de tomar el devoluciones y rebajas
@@ -4013,7 +4013,6 @@ Namespace Modelos
End If
Next
End If
-
End If
importeMovimiento = 0
@@ -6641,7 +6640,7 @@ Namespace Modelos
If Not ObjOS.LiberarVentaOS(ObjFactura.CveVenta, UsuarioActual.CveEmpresa) Then
ErrorCancelar = True
- MensajeError = "No se pudo actualizar el estatus de almacen del pedido"
+ MensajeError = "No se pudo liberar la remisión de la Orden de servicio"
End If
End If
diff --git a/Bancos/PopIECompras.aspx b/Bancos/PopIECompras.aspx
index 5f33cdea9..09ee2d437 100644
--- a/Bancos/PopIECompras.aspx
+++ b/Bancos/PopIECompras.aspx
@@ -703,11 +703,11 @@
total = total * TC;
}
- debugger
+ debugger;
if ($("#" + Chk.id).is(":checked")) {
$('#' + Obj).attr('disabled', false);
if (ToDouble($get('TxtImporte').value) != total) {
-
+
if ((ToDouble($get('TxtImporte').value) + saldo) > total) {
$('#' + Obj).val(saldo - (ToDouble($get('TxtImporte').value) + saldo - total));
$get('TxtImporte').value = (total / TC).toFixed(2)
diff --git a/Bancos/PopIECompras.aspx.vb b/Bancos/PopIECompras.aspx.vb
index 1190b4409..5d3eb3332 100644
--- a/Bancos/PopIECompras.aspx.vb
+++ b/Bancos/PopIECompras.aspx.vb
@@ -1181,7 +1181,7 @@ Partial Class Bancos_PopIECompras
e.Row.FCTextBox("TxtSaldoDeudor").Attributes.Add("onKeyUp", "AjustaTextboxDeudores();")
e.Row.FCTextBox("LbTipoMoneda").Text = If(e.Row.DataKey("CveMoneda").ToString.ToEntero = 1, "USD", " MXN")
- Dim rv As RangeValidator = CType(e.Row.FindControl("RVSaldoDeudor"), RangeValidator)
+ 'Dim rv As RangeValidator = CType(e.Row.FindControl("RVSaldoDeudor"), RangeValidator)
End If
End Sub
#End Region
@@ -1456,12 +1456,13 @@ Partial Class Bancos_PopIECompras
End If
If MsgError = "" Then
+ Dim tc As Decimal = If(rw.DataKey("CveMoneda").ToEntero = 1, 1, TxtTipoCambio.Text.Trim.ToDecimal)
Dim VentaActual As New Venta(UsuarioActual) With {.CveVenta = rw.DataKey("CveVenta").ToEntero, .ClienteNombre = NombreCliente, .SerieFolio = rw.DataKey("SerieFolio"), .CveCliente = rw.DataKey("CveCliente").ToEntero, .IVA = rw.DataKey("IVA").ToDecimal, .IEPS = rw.DataKey("IEPS").ToDecimal, .RetIVA = rw.DataKey("RetIVA").ToDecimal, .RetISR = rw.DataKey("RetISR").ToDecimal, .Total = rw.DataKey("Total").ToDecimal, .PorcentajeIVA = rw.DataKey("PorcentajeIVA").ToDecimal, .CveSubProyecto = rw.DataKey("CveSubProyecto").ToEntero, .CveMoneda = rw.DataKey("CveMoneda").ToEntero, .TC = rw.DataKey("TipoCambio").ToDecimal}
Dim PagoVenta As New VentaPago
PagoVenta.CveMonedaPago = rw.DataKey("CveMoneda").ToEntero
PagoVenta.ImportePago = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
PagoVenta.ImportePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
- PagoVenta.TCPago = rw.DataKey("TipoCambio").ToDecimal
+ PagoVenta.TCPago = tc
PagoVenta.CveCompraRelacionada = CompraActual.CveCompra
PagoVenta.TipoPago = "Venta"
If AplicaPrePolizaPagoVenta(VentaActual, PagoVenta, CvePrePoliza, ObjMov) Then
diff --git a/Compras/Proveedores.aspx.vb b/Compras/Proveedores.aspx.vb
index 6c937d58b..8a0b376d3 100644
--- a/Compras/Proveedores.aspx.vb
+++ b/Compras/Proveedores.aspx.vb
@@ -724,21 +724,39 @@ Partial Class Compras_Proveedores
Dim ObjeFacturas As New ClsCompras
If ObjeFacturas.GetFacturas(CveFactura, "-1", NowADS().AddYears(-2), NowADS(), "-1", "-1", -1, -1, -1, -1, "-1", UsuarioActual.CveEmpresa) Then
Dim XMLDoc As New XmlDocument
+ Dim SXML As String
+ Dim dr As DataRow = ObjeFacturas.DtResultados.FiltroPrimero("")
+ If dr IsNot Nothing Then
+ Dim Archivo As String = String.Format("{0}Compras\{1}\{2}", UsuarioActual.Empresa.Ruta, dr("RFCDe"), dr("XML"))
+ Try
+ SXML = File.ReadAllText(Archivo).Replace("<br>", "").Replace("<", "").Replace("o;?", "").Replace(ChrW(&HFEFF), "")
+ 'SXML = SXML.TrimStart(vbCr, vbLf, vbNullChar)
+ 'SXML = SXML.TrimEnd(vbCr, vbLf, vbNullChar)
+ SXML = SXML.Trim(New Char() {""c})
+ SXML = SXML.Replace("o;?", "")
- Try
- Dim dr As DataRow = ObjeFacturas.DtResultados.Rows(0)
+ XMLDoc.LoadXml(SXML)
+ Catch ex As Exception
+ Try
+ Dim oReader As New StreamReader(Archivo, Encoding.GetEncoding("ISO-8859-1"))
+ XMLDoc.Load(oReader)
+ oReader.Dispose()
+ Catch ex2 As Exception
+ GuardaLog("Error al intentar leer el XML del SAT. Error:" & ex2.ToString())
+ End Try
+ End Try
+ If XMLDoc.InnerXml = "" Then
+ Alert("No se pudo procesar el archivo xml.", TipoMensaje.MsgError)
+ Return 0
+ End If
+ Else
+ Alert("No se encontró el documento para cargarlo.", TipoMensaje.MsgError)
+ Return 0
+ End If
-
- Dim SXML As String = File.ReadAllText(UsuarioActual.Empresa.Ruta & "Compras\" & dr("RFCDe").ToString & "\" & dr("XML").ToString)
- 'SXML = SXML.TrimStart(vbCr, vbLf, vbNullChar)
- 'SXML = SXML.TrimEnd(vbCr, vbLf, vbNullChar)
- SXML = SXML.Trim(New Char() {""c})
- SXML = SXML.Replace("o;?", "")
-
- XMLDoc.LoadXml(SXML)
- Dim Prefijo As String = If(XMLDoc.DocumentElement.Prefix = "", "cfd", XMLDoc.DocumentElement.Prefix)
- Dim cfdVer As String = "http://www.sat.gob.mx/cfd/3"
- Dim namespaces As New XmlNamespaceManager(XMLDoc.NameTable)
+ Dim Prefijo As String = If(XMLDoc.DocumentElement.Prefix = "", "cfd", XMLDoc.DocumentElement.Prefix)
+ Dim cfdVer As String = "http://www.sat.gob.mx/cfd/3"
+ Dim namespaces As New XmlNamespaceManager(XMLDoc.NameTable)
Dim nodo As XmlNode = XMLDoc.DocumentElement
Dim Version As String = ValorXml(nodo, "Version")
@@ -756,55 +774,51 @@ Partial Class Compras_Proveedores
'If Prefijo.ToLower <> "cfdi" Then cfdVer = "http://www.sat.gob.mx/cfd/2"
namespaces.AddNamespace(Prefijo, cfdVer)
+ ' XMLDoc.LoadXml(File.ReadAllText(Archivo).Replace("<br>", "").Replace("<", "").Replace("o;?", "").Replace(ChrW(&HFEFF), ""))
Dim node As XmlNode
node = XMLDoc.SelectSingleNode(String.Format("//{0}:Emisor", Prefijo), namespaces)
- If node IsNot Nothing Then
- TxtRFC.Text = ValorXml(node, "rfc")
+ If node IsNot Nothing Then
+ TxtRFC.Text = ValorXml(node, "rfc")
- If Version = "3.3" Or Version = "4.0" Then
- TxtRazonSocial.Text = HttpUtility.HtmlDecode(ValorXml(node, "Nombre"))
- TxtNombreComercial.Text = HttpUtility.HtmlDecode(ValorXml(node, "Nombre"))
- ChkEstado.Checked = True
+ If Version = "3.3" Or Version = "4.0" Then
+ TxtRazonSocial.Text = HttpUtility.HtmlDecode(ValorXml(node, "Nombre"))
+ TxtNombreComercial.Text = HttpUtility.HtmlDecode(ValorXml(node, "Nombre"))
+ ChkEstado.Checked = True
- Dim CodigoRegimenFiscal As String = ValorXml(node, "RegimenFiscal")
+ Dim CodigoRegimenFiscal As String = ValorXml(node, "RegimenFiscal")
- If Version = "4.0" Or CodigoRegimenFiscal.Trim.Length > 0 Then
+ If Version = "4.0" Or CodigoRegimenFiscal.Trim.Length > 0 Then
- Dim CveRegimenFiscal As Integer = GlobalDTRegimenesFiscales(-1).FiltroPrimeroValor("CveRegimenFiscal", $" CodigoRegimenFiscal = '{ CodigoRegimenFiscal }'").ToEntero
- DdlRegimenFiscal.SelectedValueExist(CveRegimenFiscal)
+ Dim CveRegimenFiscal As Integer = GlobalDTRegimenesFiscales(-1).FiltroPrimeroValor("CveRegimenFiscal", $" CodigoRegimenFiscal = '{ CodigoRegimenFiscal }'").ToEntero
+ DdlRegimenFiscal.SelectedValueExist(CveRegimenFiscal)
- End If
+ End If
- Else
- TxtRazonSocial.Text = HttpUtility.HtmlDecode(ValorXml(node, "nombre"))
- TxtNombreComercial.Text = HttpUtility.HtmlDecode(ValorXml(node, "nombre"))
- Dim nodeDomicilio As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:DomicilioFiscal", Prefijo), namespaces)
- TxtDireccion.Text = ValorXml(nodeDomicilio, "calle") & " " & ValorXml(nodeDomicilio, "noExterior")
- ChkEstado.Checked = True
+ Else
+ TxtRazonSocial.Text = HttpUtility.HtmlDecode(ValorXml(node, "nombre"))
+ TxtNombreComercial.Text = HttpUtility.HtmlDecode(ValorXml(node, "nombre"))
+ Dim nodeDomicilio As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:DomicilioFiscal", Prefijo), namespaces)
+ TxtDireccion.Text = ValorXml(nodeDomicilio, "calle") & " " & ValorXml(nodeDomicilio, "noExterior")
+ ChkEstado.Checked = True
- 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}:Retencion", Prefijo), namespaces)
- 'Dim nodeRet As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Retenciones", Prefijo), namespaces)
+ 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}:Retencion", Prefijo), namespaces)
+ 'Dim nodeRet As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Retenciones", Prefijo), namespaces)
- Dim nodeTraslados As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:Traslado", Prefijo), namespaces)
- For Each traslado As XmlNode In nodeTraslados
- If traslado.Attributes("impuesto").Value = "IVA" Then
- TxtIVA.Text = traslado.Attributes("tasa").Value.ToDouble.ToString("N2")
- 'Retenciones
- End If
- Next
- End If
+ Dim nodeTraslados As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:Traslado", Prefijo), namespaces)
+ For Each traslado As XmlNode In nodeTraslados
+ If traslado.Attributes("impuesto").Value = "IVA" Then
+ TxtIVA.Text = traslado.Attributes("tasa").Value.ToDouble.ToString("N2")
+ 'Retenciones
+ End If
+ Next
End If
End If
-
- Catch ex As Exception
- Alert(String.Format("No se pudo cargar la información ({0})", ex.Message), TipoMensaje.MsgAdvertencia)
- Return 0
- End Try
+ End If
End If
Return 1
@@ -5847,11 +5861,8 @@ Partial Class Compras_Proveedores
Protected Sub LnkDownLoadDoc_Click(sender As Object, e As EventArgs)
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
Dim Adjunto As String = GvRow.DataKey("Adjunto")
-
-
Dim stringDescargaDocumento As String = UsuarioActual.Empresa.Ruta & String.Format("Edoc\\Proveedor\{0}\{1}", CveProveedor, Adjunto)
-
Dim File As New FileInfo(stringDescargaDocumento)
If File.Exists Then
diff --git a/General/SaldosIniciales.aspx.vb b/General/SaldosIniciales.aspx.vb
index cfc3b5882..786b351da 100644
--- a/General/SaldosIniciales.aspx.vb
+++ b/General/SaldosIniciales.aspx.vb
@@ -3,6 +3,7 @@ Option Explicit On
Imports System.Data
Imports System.Math
Imports ClosedXML.Excel
+Imports DocumentFormat.OpenXml.Drawing.Diagrams
Imports Extensiones
@@ -1549,7 +1550,7 @@ Partial Class General_SaldosIniciales
'P R O V E E D O R E S - F A C T U R A S
- ElseIf RblFormato.SelectedValue = "3" Or RblFormato.SelectedValue = "18" Then
+ ElseIf RblFormato.SelectedValue = "3" Then
#Region "P R O V E E D O R E S - F A C T U R A S"
@@ -1774,14 +1775,314 @@ Partial Class General_SaldosIniciales
End If
ObjCompras.Dispose()
+ ElseIf RblFormato.SelectedValue = "18" Then
+
+ Dim ObjCompras As New ClsCompras
+ Dim ErrorCompras As Boolean = False
+ Dim ObjConta As New ClsContabilidad(ObjCompras.IniciaTransacSQL())
+ Dim CveCompra As Integer
+ Dim CvePrePoliza As Integer
+ 'Dim Contador As Integer = 0
+ Dim ExisteCompra As Boolean = False
+ Dim DtProveedores As New DataTable
+ Dim NoEncontrados As Integer = 0
+ Dim Encontrados As Integer = 0
+ Dim RFC As String = ""
+
+
+ Try
+ DtProveedores = GlobalDTCompProveedores(UsuarioActual.CveEmpresa)
+
+ Dim drr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero("")
+ Dim CvePS As Integer = drr("CvePS").ToString().ToEntero()
+ Dim CveUnidadMedida As Integer = drr("CveUnidadMedida").ToString().ToEntero()
+ Dim CveClasificacion As Integer = drr("CveClasificacion").ToString().ToEntero()
+ Dim dtsubp As DataTable = GlobalDTSubProyectos(UsuarioActual.CveEmpresa)
+
+ Dim CountRow As Integer = 1
+ Dim LastSerieFolioTipoDoc As String = String.Empty
+ Dim EsDetalle As Boolean = False
+ For Each Row As DataRow In dt.FiltraParametros("RFC <> ''").Rows
+ Dim Sucursal As String = dtsubp.FiltroPrimeroValor("CveSubProyecto", $"SubProyecto = '{Row("Sucursal").ToString()}'")
+ RFC = Row("RFC").ToString().Trim
+ Dim Serie As String = Row("Serie").ToString().Trim
+ Dim Folio As String = Row("Folio").ToString().Trim
+ Dim Fecha As Date = Row("Fecha").ToString().ToDate
+ Dim TipoDocto As String = Row("Tipo Documento").ToString().Trim.ToUpper
+ Dim CveProveedor As Integer = 0
+ If UsuarioActual.CveEmpresa = 189 Then
+ CveProveedor = DtProveedores.FiltroPrimeroValor("CveProveedor", $"RazonSocial = '{RFC}'").ToString().ToEntero()
+ Else
+ CveProveedor = DtProveedores.FiltroPrimeroValor("CveProveedor", $"RFC = '{RFC}'").ToString().ToEntero()
+ End If
+ GuardaLog(Sucursal + " - " + Row("Sucursal").ToString())
+ Dim Moneda As String = Row("Moneda").ToString()
+ Dim TipoCambio As String = If(dt.Columns.Contains("Tipo Cambio"), Row("Tipo Cambio").ToString(), "1")
+ Dim FechaVencimiento As Date = Row("Fecha Vencimiento").ToString().ToDate
+ Dim CveMoneda As Integer = 1
+ Dim CveProveedorSucursal As Integer = If(dt.Columns.Contains("CveProveedorSucursal"), Row("CveProveedorSucursal").ToString(), "0").ToEntero
+ Dim PorcentajeIVA As Decimal = If(dt.Columns.Contains("PorcentajeIVA"), Row("PorcentajeIVA").ToString(), "0").ToDecimal.RoundSQL
+ Dim ImpuestosLocales As Decimal = If(dt.Columns.Contains("ImpuestosLocales"), Row("ImpuestosLocales").ToString(), "0").ToDecimal
+ Dim RetIVAPorcentaje As Decimal = If(dt.Columns.Contains("RetIVAPorcentaje"), Row("RetIVAPorcentaje").ToString(), "0").ToDecimal
+ Dim RetISRPorcentaje As Decimal = If(dt.Columns.Contains("RetISRPorcentaje"), Row("RetISRPorcentaje").ToString(), "0").ToDecimal
+ Dim CveSubProyecto As Integer = GlobalDTSubProyectos(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", String.Format("SubProyecto='{0}'", If(dt.Columns.Contains("SubProyecto"), Row("SubProyecto").ToString(), ""))).ToEntero
+ If CveSubProyecto = 0 Then CveSubProyecto = GlobalDTSubProyectos(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto").ToEntero
+
+ If Not CvePS > 0 Then Alert(String.Format("No se encontró el Producto Servicio"), TipoMensaje.MsgError) : ErrorCompras = True
+ If Not CveUnidadMedida > 0 Then Alert(String.Format("No se encontró la Unidad de Medida."), TipoMensaje.MsgError) : ErrorCompras = True
+ If UsuarioActual.CveEmpresa = 189 Then
+ If Not CveProveedor > 0 Then Alert(String.Format("No se encontró el Proveedor con la razon social: {0}", {RFC}), TipoMensaje.MsgError) : ErrorCompras = True : Exit For
+ Else
+ If Not CveProveedor > 0 Then Alert(String.Format("No se encontró el Proveedor con el RFC: {0}", {RFC}), TipoMensaje.MsgError) : ErrorCompras = True : Exit For
+ End If
+ If Not CveProveedorSucursal > 0 Then CveProveedorSucursal = -1
+
+
+ If LastSerieFolioTipoDoc = $"{Folio}" AndAlso UsuarioActual.CveEmpresa = 189 Then
+ EsDetalle = True
+ Else
+ LastSerieFolioTipoDoc = $"{Folio}"
+ EsDetalle = False
+ End If
+
+
+ Dim SubTotal As Decimal = 0
+ Dim IVA As Decimal = 0
+ Dim Total As Decimal = 0
+ Dim Saldo As Decimal = 0
+ Dim RetIVA As Decimal = 0
+ Dim RetISR As Decimal = 0
+ Dim IEPS As Decimal = 0
+
+
+ If UsuarioActual.CveEmpresa = 189 AndAlso Not EsDetalle Then
+ For Each item As DataRow In dt.FiltraParametros($"RFC <> '' AND Folio = '{Row("Folio").ToString()}'").Rows
+ SubTotal += item("SubTotal").ToString().ToDecimal.RoundSQL
+ IVA += item("IVA").ToString().ToDecimal.RoundSQL
+ Total += item("Total").ToString().ToDecimal.RoundSQL
+ Saldo += item("Saldo").ToString().ToDecimal.RoundSQL
+ RetIVA += item("Ret IVA").ToString().ToDecimal.RoundSQL
+ RetISR += item("Ret ISR").ToString().ToDecimal.RoundSQL
+ IEPS += If(dt.Columns.Contains("IEPS"), Row("IEPS").ToString(), "0").ToDecimal.RoundSQL
+ Next
+ Else
+ SubTotal = Row("SubTotal").ToString().ToDecimal.RoundSQL
+ IVA = Row("IVA").ToString().ToDecimal.RoundSQL
+ Total = Row("Total").ToString().ToDecimal.RoundSQL
+ Saldo = Row("Saldo").ToString().ToDecimal.RoundSQL
+ RetIVA = Row("Ret IVA").ToString().ToDecimal.RoundSQL
+ RetISR = Row("Ret ISR").ToString().ToDecimal.RoundSQL
+ IEPS = If(dt.Columns.Contains("IEPS"), Row("IEPS").ToString(), "0").ToDecimal.RoundSQL
+ End If
+
+ If PorcentajeIVA > 0 AndAlso IVA = 0 Then PorcentajeIVA = 0
+
+ Dim RetIVAConcepto As String = If(dt.Columns.Contains("RetIVAConcepto"), Row("RetIVAConcepto").ToString(), "").ToUpper
+ Dim RetISRConcepto As String = If(dt.Columns.Contains("RetISRConcepto"), Row("RetISRConcepto").ToString(), "").ToUpper
+ Dim CveRetIVAConcepto As Integer = If(RetIVAConcepto = "HONORARIOS", 1, If(RetIVAConcepto = "FLETES", 2, If(RetIVAConcepto = "ARRENDAMIENTO", 4, -1)))
+ Dim CveRetISRConcepto As Integer = If(RetISRConcepto = "HONORARIOS", 1, If(RetISRConcepto = "ARRENDAMIENTO", 2, If(RetISRConcepto = "RESICO", 4, -1)))
+
+ TipoDocto = IIf(TipoDocto.Contiene("INGRESOS", "INGRESO", "ING", "FACTURA", "FACTURAS", ""), "Fac", "NC").ToString()
+
+ 'RMF. falta validación de totales.
+ 'Temporalmente SE BORRARA
+ Dim Transaccion As String = "" 'Row("Transaccion2").ToString()
+ Dim Folio2 As String = "" 'Row("Folio2").ToString()
+ Dim CodProvee As String = "" 'Row("CodProvee2").ToString()
+
+ 'Moneda
+ If Moneda.ToUpper.Contiene("PESOS", "PESO", "MXN", "MONEDA NACIONAL") Then
+ CveMoneda = 1
+ ElseIf Moneda.ToUpper.Contiene("DOLARES", "DOLAR", "USD", "DÓLARES", "DÓLAR") Then
+ CveMoneda = 2
+ End If
+
+ 'Si no se especifica TC, se manda como pesos.
+ If TipoCambio = "" Then TipoCambio = "1"
+ If CveMoneda = 2 AndAlso TipoCambio = "1" Then
+ TipoCambio = GlobalTipoCambio(Fecha).ToString
+ End If
+
+
+ Dim IEPSDetalle As Decimal = 0
+ Dim CantidadDetalle As Decimal = 0
+ Dim PUDetalle As Decimal = 0
+ Dim IVADetalle As Decimal = 0
+
+ If RblFormato.SelectedValue = "18" Then
+
+ Dim CodigoDetalle As String = Row("Codigo").ToString
+ If CodigoDetalle.Trim.Length > 0 Then
+ Dim DrDetalles As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($"Codigo = '{CodigoDetalle}'")
+
+ If DrDetalles IsNot Nothing Then
+ CvePS = DrDetalles("CvePS").ToString().ToEntero()
+ CveUnidadMedida = DrDetalles("CveUnidadMedida").ToString().ToEntero()
+ CveClasificacion = DrDetalles("CveClasificacion").ToString().ToEntero()
+ Else
+ Alert($"El código del producto no se encontro, error en registro {CountRow}")
+ ErrorCompras = True
+ End If
+
+ Else
+ Alert($"El código es requerido, error en registro {CountRow}")
+ ErrorCompras = True
+ End If
+
+
+ IEPSDetalle = Row("IEPS").ToString.ToDecimal
+ CantidadDetalle = Row("Cantidad").ToString.ToDecimal
+ PUDetalle = Row("PU").ToString.ToDecimal
+ IVADetalle = Row("IVA").ToString.ToDecimal
+
+ If CantidadDetalle = 0 Then
+ Alert($"No se especifico la cantidad, error en registro {CountRow}")
+ ErrorCompras = True
+ End If
+
+ End If
+
+ 'PrePóliza
+ If Not EsDetalle Then
+ CvePrePoliza = ObjConta.AddPrePolizas("Compras/SaldoInicial", 1, Total, Total, CveMoneda, Fecha, String.Format("{0}-{1}", Serie, Folio), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+ If Not CvePrePoliza > 0 Then
+ ErrorCompras = True
+ Exit For
+ End If
+ End If
+
+ If FechaVencimiento = "".ToDate Or FechaVencimiento < "1900/01/01".ToDate Then
+ FechaVencimiento = Fecha
+ End If
+
+ If Not EsDetalle Then
+ If Not ObjCompras.AddCompra(TipoDocto, "", Serie, Folio, Folio2, CveProveedor.ToEntero(), SubTotal + ImpuestosLocales, 0, 0, IVA, RetIVA, RetISR, IEPS, 0, 0, Total, Fecha, CveMoneda, TipoCambio.ToDecimal, FechaVencimiento,
+ False, CodProvee, 1, CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveProveedorSucursal:=CveProveedorSucursal,
+ NumeroReembolso:=Transaccion, PorcentajeIVA:=PorcentajeIVA, TotalOriginal:=Total, CveSubProyecto:=CveSubProyecto, CveRetIVAConcepto:=CveRetIVAConcepto, CveRetISRConcepto:=CveRetISRConcepto) Then
+ ErrorCompras = True
+ Exit For
+ End If
+ CveCompra = ObjCompras.CveCompra
+
+ SubTotal = Row("SubTotal").ToString().ToDecimal
+ IVA = Row("IVA").ToString().ToDecimal
+ Total = Row("Total").ToString().ToDecimal
+ Saldo = Row("Saldo").ToString().ToDecimal
+ RetIVA = Row("Ret IVA").ToString().ToDecimal
+ RetISR = Row("Ret ISR").ToString().ToDecimal
+ IEPS = Row("IEPS").ToString().ToDecimal
+ End If
+
+ 'Compra Detalle
+ If RblFormato.SelectedValue = "18" Then
+
+ Dim TotalDetalles As Decimal = SubTotal
+ If PUDetalle > 0 Then
+ TotalDetalles = (CantidadDetalle * PUDetalle) + IVA - RetIVA - RetISR + IEPSDetalle
+ End If
+
+ If Math.Abs(TotalDetalles - Total) > 0.01 Then
+ ErrorCompras = True
+ Alert($"Registro {CountRow} El total no councide con el calculo de los detalles, total: {Total.ToString("###,###,###.00")} calculo detatalles: {TotalDetalles.ToString("###,###,###.00")}", TipoMensaje.MsgAdvertencia)
+ Exit For
+ End If
+
+ If Not ObjCompras.AddCompraDetalle(CveCompra, CveUnidadMedida, CvePS, CveSubProyecto, -1, 0, CantidadDetalle, PUDetalle, (CantidadDetalle * PUDetalle) * PorcentajeIVA, TotalDetalles, 0, "Carga Inicial", -1, IVAPorcentaje:=PorcentajeIVA, RetIVAPorcentaje:=RetIVAPorcentaje, RetISRPorcentaje:=RetISRPorcentaje, IEPSPS:=IEPSDetalle) Then
+ ErrorCompras = True
+ Exit For
+ End If
+ Else
+ If Not ObjCompras.AddCompraDetalle(CveCompra, CveUnidadMedida, CvePS, CveSubProyecto, -1, 0, 1, SubTotal, SubTotal * PorcentajeIVA, SubTotal, 0, "Carga Inicial", -1, IVAPorcentaje:=PorcentajeIVA, RetIVAPorcentaje:=RetIVAPorcentaje, RetISRPorcentaje:=RetISRPorcentaje) Then
+ ErrorCompras = True
+ Exit For
+ End If
+ End If
+
+ If ImpuestosLocales > 0 Then 'se agrega como parte de la partida, sin iva.
+ If Not ObjCompras.AddCompraDetalle(CveCompra, CveUnidadMedida, CvePS, CveSubProyecto, -1, 0, 1, ImpuestosLocales, ImpuestosLocales, ImpuestosLocales, 0, "Carga Inicial", -1, IVAPorcentaje:=0, RetIVAPorcentaje:=0, RetISRPorcentaje:=0) Then
+ ErrorCompras = True
+ Exit For
+ End If
+ End If
+ Dim ConceptoContablePago As Integer = 17
+ If TipoDocto = "NC" Then ConceptoContablePago = 60
+
+ If Not EsDetalle Then
+
+ SubTotal = 0
+ IVA = 0
+ Total = 0
+ Saldo = 0
+ RetIVA = 0
+ RetISR = 0
+ IEPS = 0
+
+ For Each item As DataRow In dt.FiltraParametros($"RFC <> '' AND Folio = '{Row("Folio").ToString()}'").Rows
+ SubTotal += item("SubTotal").ToString().ToDecimal.RoundSQL
+ IVA += item("IVA").ToString().ToDecimal.RoundSQL
+ Total += item("Total").ToString().ToDecimal.RoundSQL
+ Saldo += item("Saldo").ToString().ToDecimal.RoundSQL
+ RetIVA += item("Ret IVA").ToString().ToDecimal.RoundSQL
+ RetISR += item("Ret ISR").ToString().ToDecimal.RoundSQL
+ IEPS += If(dt.Columns.Contains("IEPS"), Row("IEPS").ToString(), "0").ToDecimal.RoundSQL
+ Next
+
+ 'PrePólizaDetalle
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total, Total, IIf(TipoDocto = "Fac", 5, 18).ToString().ToEntero(), Folio, String.Format("{0}-{1}", Serie, Folio), CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveSubProyecto:=Sucursal.ToEntero(), Contabilizable:=False) Then ErrorCompras = True : Exit For
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, SubTotal, SubTotal, 6, Folio, String.Format("{0}-{1}", Serie, Folio), CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveClasificacion:=CveClasificacion, CveSubProyecto:=Sucursal.ToEntero(), Contabilizable:=False) Then ErrorCompras = True : Exit For
+
+ If IVA > 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, IVA, IVA, 14, Folio, String.Format("{0}-{1}", Serie, Folio), CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveSubProyecto:=Sucursal.ToEntero(), CveClasificacion:=CveClasificacion, PorcentajeImpuesto:=PorcentajeIVA, Contabilizable:=False) Then ErrorCompras = True : Exit For
+ End If
+
+ If IEPS > 0 Then If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, IEPS, IEPS, 25, Folio, String.Format("{0}-{1}", Serie, Folio), CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveSubProyecto:=Sucursal.ToEntero(), Contabilizable:=False) Then ErrorCompras = True : Exit For
+
+ If RetIVA > 0 Then If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, RetIVA, RetIVA, 15, Folio, String.Format("{0}-{1}", Serie, Folio), CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveSubProyecto:=Sucursal.ToEntero(), Contabilizable:=False) Then ErrorCompras = True : Exit For
+ If RetISR > 0 Then If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, RetISR, RetISR, 16, Folio, String.Format("{0}-{1}", Serie, Folio), CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveSubProyecto:=Sucursal.ToEntero(), Contabilizable:=False) Then ErrorCompras = True : Exit For
+ 'If ImpuestosLocales > 0 Then If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImpuestosLocales, ImpuestosLocales, 27, Folio, String.Format("{0}-{1}", Serie, Folio), CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveSubProyecto:=Sucursal.ToEntero()) Then ErrorCompras = True : Exit For
+
+ 'Saldo
+ If Saldo < Total Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total - Saldo, Total - Saldo, ConceptoContablePago, Folio.ToString(), Folio.ToString(), CveCompra:=CveCompra, CveProveedor:=CveProveedor, Contabilizable:=False) Then ErrorCompras = True : Exit For
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total - Saldo, Total - Saldo, 95, Folio.ToString(), Folio.ToString(), CveCompra:=CveCompra, CveProveedor:=CveProveedor, Contabilizable:=False) Then ErrorCompras = True : Exit For
+ End If
+ End If
+ Encontrados = Encontrados + 1
+
+ CountRow = CountRow + 1
+ Next
+
+ Catch ex As Exception
+ OnError("Ocurrió un error al cargar los datos", ex)
+ ErrorCompras = True
+ End Try
+
+ If Not ErrorCompras Then
+
+ 'If Encontrados > 0 Then
+ ' Alert(String.Format("Se agregaron: {0} Compras correctamente.
Se Omitieron: {1} Compras ya que ya se encuentran registradas.", Encontrados, NumRows - 1 - Encontrados), TipoMensaje.MsgInformacion)
+ 'Else
+ ' Alert(String.Format("Se agregaron: {0} Compras correctamente.", Encontrados), TipoMensaje.MsgInformacion)
+ 'End If
+ Alert(String.Format("Se agregaron: {0} Compras correctamente.", Encontrados), TipoMensaje.MsgInformacion)
+ 'Alert(String.Format("Se agregaron: {0} Compras correctamente. RFC:{1} ", Encontrados, RFC), TipoMensaje.MsgInformacion)
+
+ ObjCompras.Commit()
+ TxtExcel.Text = ""
+ UpDatos.Update()
+ Else
+ Alert(String.Format("NO Se agregaron: {0} Compras.", NumRows), TipoMensaje.MsgError)
+ ObjCompras.RollBack()
+ End If
+ ObjCompras.Dispose()
+
#End Region
'C L I E N T E S - F A C T U R A S
- ElseIf RblFormato.SelectedValue = "4" Or RblFormato.SelectedValue = "17" Then
+ ElseIf RblFormato.SelectedValue = "4" Then
#Region "C L I E N T E S - F A C T U R A S"
-
Dim NoEncontrados As Integer = 0
Dim Encontrados As Integer = 0
Dim StrRFCNoencontrados As New StringBuilder
@@ -2089,11 +2390,397 @@ Partial Class General_SaldosIniciales
End If
ObjVentas.Dispose()
+
+
+ ElseIf RblFormato.SelectedValue = "17" Then
+ Dim NoEncontrados As Integer = 0
+ Dim Encontrados As Integer = 0
+ Dim StrRFCNoencontrados As New StringBuilder
+ Dim drr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero("AplicaParaVenta = 1")
+ If drr Is Nothing Then
+ Alert("No existen productos para venta. favor de crear uno e intentar de nuevo", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+ Dim ObjVentas As New ClsVentas
+ Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL())
+ Dim ObjIE As New ClsBancos(ObjVentas.IniciaTransacSQL())
+ Dim ErrorVentas As Boolean = False
+ Dim CveVenta As Integer
+ Dim CvePrePoliza As Integer
+ Dim DtClientes As New DataTable
+ 'Dim ExisteVenta As Boolean = False
+ 'Dim Contador As Integer = 0
+ DtClientes = GlobalDTCliente(UsuarioActual.CveEmpresa, Estatus:=-1)
+ Dim CvePS As Integer = drr("CvePS").ToString().ToEntero()
+ Dim CveUnidadMedida As Integer = drr("CveUnidadMedida").ToString().ToEntero()
+ Dim CveClasificacion As Integer = drr("CveClasificacion").ToString().ToEntero()
+
+ If Not CvePS > 0 Then Alert(String.Format("No se encontró el Producto Servicio"), TipoMensaje.MsgError) : ErrorVentas = True
+ ' If Not CveSucursal > 0 Then Alert("No se encontró la sucursal.", TipoMensaje.MsgError) : ErrorVentas = True
+ If Not CveUnidadMedida > 0 Then Alert(String.Format("No se encontró la Unidad de Medida."), TipoMensaje.MsgError) : ErrorVentas = True
+ Dim dtsubp As DataTable = GlobalDTSubProyectos(UsuarioActual.CveEmpresa)
+
+ 'For Each drt As DataRow In dt.FiltraParametros("RFC <> ''", DistinctColumns:={"RFC"}).Rows
+ ' Dim RFC As String = drt("RFC").ToString().Trim.Replace("-", "").Replace(" ", "")
+ ' Dim CveCliente As Integer = DtClientes.FiltroPrimeroValor("CveCliente", $"RFC = '{RFC}'").ToString().ToEntero()
+ ' If CveCliente <= 0 Then
+ ' Dim OBJ As New ClsClientes
+ ' OBJ.AgregarClienteNoFrecuente(RFC, RFC, "", "", "", "", "", 26, RFC, "", "", "", -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, "", -1, -1)
+ ' OBJ.Dispose()
+ ' End If
+ 'Next
+ 'GlobalDTCliente(UsuarioActual.CveEmpresa) = Nothing
+ 'DtClientes = GlobalDTCliente(UsuarioActual.CveEmpresa, Estatus:=-1)
+ Dim CountRow As Integer = 1
+ Dim LastSerieFolioTipoDoc As String = String.Empty
+ Dim EsDetalle As Boolean = False
+ For Each Row As DataRow In dt.FiltraParametros("RFC <> ''").Rows
+ Dim Sucursal As String = dtsubp.FiltroPrimeroValor("CveSubProyecto", $"SubProyecto = '{Row("Sucursal").ToString()}'")
+ Dim TipoDocto As String = Row("Tipo Documento").ToString().Trim
+ Dim RFC As String = Row("RFC").ToString().Trim.Replace("-", "").Replace(" ", "")
+ Dim Serie As String = Row("Serie").ToString().Trim
+ Dim Folio As Integer = Row("Folio").ToString().ToEntero()
+ Dim Fecha As Date = Row("Fecha").ToString().ToDate
+ Dim FechaVencimiento As Date = Row("Fecha Vencimiento").ToString().ToDate
+ Dim ImpuestoLocal As Decimal = If(dt.Columns.Contains("ImpuestoLocal"), Row("ImpuestoLocal").ToString().ToDecimal, 0D)
+ Dim Amortizacion As Decimal = If(dt.Columns.Contains("Amort.Ant"), Row("Amort.Ant").ToString().ToDecimal, 0)
+ Dim CveCliente As Integer = DtClientes.FiltroPrimeroValor("CveCliente", $"RFC = '{RFC}'").ToString().ToEntero()
+
+ If LastSerieFolioTipoDoc = $"{Serie}{Folio}{TipoDocto}" AndAlso UsuarioActual.CveEmpresa = 189 Then
+ EsDetalle = True
+ Else
+ LastSerieFolioTipoDoc = $"{Serie}{Folio}{TipoDocto}"
+ EsDetalle = False
+ End If
+
+
+ Dim SubTotal As Decimal = 0
+ Dim IVA As Decimal = 0
+ Dim Total As Decimal = 0
+ Dim Saldo As Decimal = 0
+ Dim RetIVA As Decimal = 0
+ Dim RetISR As Decimal = 0
+ Dim IEPS As Decimal = 0
+
+ If UsuarioActual.CveEmpresa = 189 AndAlso Not EsDetalle Then
+
+ For Each item As DataRow In dt.FiltraParametros($"RFC <> '' AND Folio = '{Row("Folio").ToString()}' AND Serie = '{Row("Serie").ToString()}' AND [Tipo Documento] = '{Row("Tipo Documento").ToString()}' ").Rows
+ SubTotal += item("SubTotal").ToString().ToDecimal
+ IVA += item("IVA").ToString().ToDecimal
+ Total += item("Total").ToString().ToDecimal
+ Saldo += item("Saldo").ToString().ToDecimal
+ RetIVA += item("Ret IVA").ToString().ToDecimal
+ RetISR += item("Ret ISR").ToString().ToDecimal
+ IEPS += item("IEPS").ToString().ToDecimal
+ Next
+ Else
+ SubTotal = Row("SubTotal").ToString().ToDecimal
+ IVA = Row("IVA").ToString().ToDecimal
+ Total = Row("Total").ToString().ToDecimal
+ Saldo = Row("Saldo").ToString().ToDecimal
+ RetIVA = Row("Ret IVA").ToString().ToDecimal
+ RetISR = Row("Ret ISR").ToString().ToDecimal
+ IEPS = Row("IEPS").ToString().ToDecimal
+ End If
+
+ Dim Moneda As String = Row("Moneda").ToString()
+ Dim TipoCambio As String = Row("Tipo Cambio").ToString()
+ Dim CveMoneda As Integer = 1
+ Dim Vendedor As String = If(dt.Columns.Contains("Vendedor"), Row("Vendedor").ToString(), "")
+ Dim CveVendedor As Integer = 0
+
+ Dim CveClienteSucursal As Integer = 0 'Row("CveClienteSucursal").ToString().ToEntero()
+ Dim FolioFiscal As String = If(dt.Columns.Contains("Folio Fiscal"), Row("Folio Fiscal").ToString(), "")
+ Dim PorcentajeIVA As Decimal = If(dt.Columns.Contains("PorcentajeIVA"), Round(Row("PorcentajeIVA").ToString().ToDecimal, 2), 0)
+ Dim PorcentajeRetIVA As Decimal = If(dt.Columns.Contains("PorcentajeRetIVA"), Round(Row("PorcentajeRetIVA").ToString().ToDecimal, 4), 0)
+ Dim PorcentajeRetISR As Decimal = If(dt.Columns.Contains("PorcentajeRetISR"), Round(Row("PorcentajeRetISR").ToString().ToDecimal, 4), 0)
+ Dim PedidoContrato As String = If(dt.Columns.Contains("Pedido"), Row("Pedido").ToString(), "")
+
+ GuardaLog(Sucursal + "-" + Row("Folio").ToString())
+ 'Temporalmente SE BORRARA
+ Dim Transaccion As String = "" ' Row("Transaccion2").ToString()
+ Dim Folio2 As String = "" ' Row("Folio2").ToString()
+ Dim CodCliente As String = "" 'Row("CodCliente2").ToString()
+
+ Dim IEPSDetalle As Decimal = 0
+ Dim CantidadDetalle As Decimal = 0
+ Dim PUDetalle As Decimal = 0
+ Dim IVADetalle As Decimal = 0
+ Dim PorcentajeIEPS As Decimal = 0
+
+ If IEPS > 0 Then
+ PorcentajeIEPS = If(dt.Columns.Contains("PorcentajeIEPS"), Round(Row("PorcentajeIEPS").ToString().ToDecimal, 4), 0)
+ End If
+
+ If RblFormato.SelectedValue = "17" Then
+
+ Dim CodigoDetalle As String = Row("Codigo").ToString
+ If CodigoDetalle.Trim.Length > 0 Then
+ Dim DrDetalles As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($"Codigo = '{CodigoDetalle}'")
+
+ If DrDetalles IsNot Nothing Then
+ CvePS = DrDetalles("CvePS").ToString().ToEntero()
+ CveUnidadMedida = DrDetalles("CveUnidadMedida").ToString().ToEntero()
+ CveClasificacion = DrDetalles("CveClasificacion").ToString().ToEntero()
+ Else
+ Alert($"El código del producto no se encontro, error en registro {CountRow}")
+ ErrorVentas = True
+ End If
+ Else
+ Alert($"El código es requerido, error en registro {CountRow}")
+ ErrorVentas = True
+ End If
+
+ IEPSDetalle = Row("IEPS").ToString.ToDecimal
+ CantidadDetalle = Row("Cantidad").ToString.ToDecimal
+ PUDetalle = Row("PU").ToString.ToDecimal
+ IVADetalle = Row("IVA").ToString.ToDecimal
+
+ If CantidadDetalle = 0 Then
+ Alert($"No se especifico la cantidad, error en registro {CountRow}")
+ ErrorVentas = True
+ End If
+
+ End If
+
+ If dt.Columns.Contains("Cliente Sucursal") AndAlso Row("Cliente Sucursal").ToString() <> "" Then
+
+ Dim ObjCliente As New ClsClientes
+ If ObjCliente.GetSucursales(CveCliente) Then
+ If ObjCliente.DtResultados.Rows.Count > 0 Then
+ CveClienteSucursal = ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "SucursalCliente = '" & Row("Cliente Sucursal").ToString().Trim & "'").ToEntero
+ End If
+ End If
+
+ ObjCliente.Dispose()
+ End If
+
+
+ 'If Not CveCliente > 0 Then Alert(String.Format("No se encontró el cliente con el RFC: {0}", {RFC}), TipoMensaje.MsgError) : ErrorVentas = True : RFC.GuardaLog : Exit For
+ TipoDocto = IIf(TipoDocto.ToUpper.Contiene("INGRESO", "INGRESOS", "ING", "FACTURA", "FACTURAS"), "Ing", IIf(TipoDocto.ToUpper.Contiene("EGRESO", "EGRESOS", "EGS"), "Egs", "Rem")).ToString()
+ 'PrePóliza
+ If Not EsDetalle Then
+ CvePrePoliza = ObjConta.AddPrePolizas("Venta/SaldoInicial", 1, Total, Total, 1, Fecha, String.Format("{0}-{1}", Serie, Folio), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+ End If
+
+ If Vendedor <> "" Then
+ CveVendedor = GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo:=-1).FiltroPrimeroValor("CveVendedor", $"Vendedor = '{Vendedor}'").ToString().ToEntero()
+ If Not CveVendedor > 0 Then CveVendedor = 0
+ Else
+ CveVendedor = 0
+ End If
+
+ 'Moneda
+ If Moneda.ToUpper.Contiene("PESOS", "PESO", "MXN") Then
+ CveMoneda = 1
+ TipoCambio = "1"
+ ElseIf Moneda.ToUpper.Contiene("DÓLAR", "DÓLARES", "DOLARES", "USD") Then
+ CveMoneda = 2
+
+ If TipoCambio.Trim.ToDecimal < 10 Then
+
+ If UsuarioActual.CveEmpresa.Contiene(13, 83) Then
+ TipoCambio = GlobalTipoCambio(Fecha.AddDays(-1)).ToString()
+ Else
+ TipoCambio = GlobalTipoCambio(Fecha).ToString()
+ End If
+
+ End If
+
+ End If
+
+ 'Si no se especifica TC, se manda como pesos.
+ If TipoCambio = "" Then TipoCambio = "1"
+
+ If Not CveClienteSucursal > 0 Then CveClienteSucursal = -1
+
+ If FechaVencimiento = "".ToDate Or FechaVencimiento < "1900/01/01".ToDate Then
+ FechaVencimiento = Fecha
+ End If
+
+
+ 'Venta
+ If CveCliente > 0 Then
+
+
+ If TipoDocto.Contiene("Ing", "Egs", "Rem") Then
+ GuardaLog(Serie & "-" & Folio)
+ If Not EsDetalle Then
+ If Not ObjVentas.AddVenta(TipoDocto, Folio, CveCliente.ToEntero(), CveClienteSucursal, SubTotal, 0, Amortizacion, IVA, RetIVA, RetISR, Total, CveMoneda, TipoCambio.ToDouble,
+ 0, 0, 0, FechaVencimiento, Fecha, "", "", Fecha, CveVendedor, Folio2, "", "", 0, 0, 0, "-1".ToDate, "-1".ToDate, "-1".ToDate, -1, 0, CvePrePoliza,
+ UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Serie:=Serie, CveSubProyecto:=Sucursal.ToEntero(), CveSubProyectoEjecucion:=Sucursal.ToEntero(),
+ CveSubProyectoCobranza:=Sucursal.ToEntero(), IEPS:=IEPS, ObservacionesAlmacen:=Transaccion, Entrega:=CodCliente, ImpuestoLocal:=ImpuestoLocal,
+ PedidoContrato:=PedidoContrato, CveMetodoPago33:=3) Then
+ ErrorVentas = True
+ Exit For
+ End If
+ CveVenta = ObjVentas.CveVenta
+ End If
+
+ If Not EsDetalle Then
+ SubTotal = Row("SubTotal").ToString().ToDecimal
+ IVA = Row("IVA").ToString().ToDecimal
+ Total = Row("Total").ToString().ToDecimal
+ Saldo = Row("Saldo").ToString().ToDecimal
+ RetIVA = Row("Ret IVA").ToString().ToDecimal
+ RetISR = Row("Ret ISR").ToString().ToDecimal
+ IEPS = Row("IEPS").ToString().ToDecimal
+ End If
+
+ If RblFormato.SelectedValue = "17" Then
+
+ Dim TotalDetalles As Decimal = SubTotal
+ If PUDetalle > 0 Then
+ TotalDetalles = (CantidadDetalle * PUDetalle) + IVA - RetIVA - RetISR + IEPSDetalle
+ End If
+
+ If Math.Abs(TotalDetalles - Total) > 0.01 Then
+ ErrorVentas = True
+ Alert($"Registro {CountRow} El total no councide con el calculo de los detalles, total: {Total.ToString("###,###,###.00")} calculo detatalles: {TotalDetalles.ToString("###,###,###.00")}", TipoMensaje.MsgAdvertencia)
+ Exit For
+ End If
+
+ If Not ObjVentas.AddVentaDetalle(CveVenta, CvePS, CantidadDetalle, CveUnidadMedida, PUDetalle, IVADetalle, TotalDetalles, "Saldo Inicial", 0, 0, Sucursal.ToEntero(), 0,
+ PorcentajeIVA:=PorcentajeIVA, PorcentajeRetIVA:=PorcentajeRetIVA, ImporteRetIVA:=RetIVA, IEPS:=IEPSDetalle, PorcentajeRetISR:=PorcentajeRetISR, PorcentajeIEPS:=PorcentajeIEPS) Then
+ ErrorVentas = True
+ Exit For
+ End If
+
+ Else
+ If Not ObjVentas.AddVentaDetalle(CveVenta, CvePS, 1, CveUnidadMedida, SubTotal, IVA, SubTotal * PorcentajeIVA, "Saldo Inicial", 0, 0, Sucursal.ToEntero(), 0, PorcentajeIVA:=PorcentajeIVA, PorcentajeRetIVA:=PorcentajeRetIVA, ImporteRetIVA:=RetIVA, IEPS:=0) Then
+ ErrorVentas = True
+ Exit For
+ End If
+ End If
+
+
+
+ Dim ConceptoContable As Integer = 1
+ Dim ConceptoContablePago As Integer = 2
+ If TipoDocto = "Egs" Then
+ ConceptoContable = 12
+ ConceptoContablePago = 91
+ End If
+
+ If FolioFiscal <> "" Then
+ If Not ObjVentas.UpdateVentaFolioFiscal(FolioFiscal, CveVenta, UsuarioActual.CveEmpresa) Then
+ ErrorVentas = True
+ Exit For
+ End If
+ End If
+
+ Dim UsaComplementaria As Boolean = False
+
+ If UsuarioActual.CveEmpresa.Contiene(119, 158) Then UsaComplementaria = True
+
+ If Not EsDetalle Then
+
+ SubTotal = 0
+ IVA = 0
+ Total = 0
+ Saldo = 0
+ RetIVA = 0
+ RetISR = 0
+ For Each item As DataRow In dt.FiltraParametros($"RFC <> '' AND Folio = '{Row("Folio").ToString()}' AND Serie = '{Row("Serie").ToString()}' AND [Tipo Documento] = '{Row("Tipo Documento").ToString()}' ").Rows
+ SubTotal += item("SubTotal").ToString().ToDecimal
+ IVA += item("IVA").ToString().ToDecimal
+ Total += item("Total").ToString().ToDecimal
+ Saldo += item("Saldo").ToString().ToDecimal
+ RetIVA += item("Ret IVA").ToString().ToDecimal
+ RetISR += item("Ret ISR").ToString().ToDecimal
+ IEPS += item("IEPS").ToString().ToDecimal
+ Next
+
+ 'PrePólizaDetalle
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, SubTotal, SubTotal, 4, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, CveClasificacion:=CveClasificacion, CveSubProyecto:=Sucursal.ToEntero(), PorcentajeImpuesto:=PorcentajeIVA, Contabilizable:=False) Then ErrorVentas = True : Exit For
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total, Total, ConceptoContable, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=PorcentajeIVA, Contabilizable:=False) Then ErrorVentas = True : Exit For
+
+ If IVA > 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IVA, IVA, 13, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=PorcentajeIVA, Contabilizable:=False) Then ErrorVentas = True : Exit For
+ End If
+
+ If IEPS > 0 Then
+ 'AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IEPS, Folio, 38, String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=IEPS)
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IEPS, IEPS, 38, Folio.ToString, String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, Contabilizable:=False) Then ErrorVentas = True : Exit For
+
+ End If
+
+ If RetIVA > 0 Then
+
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, RetISR, RetISR, 8, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=PorcentajeRetISR, Contabilizable:=False) Then ErrorVentas = True : Exit For
+ End If
+
+ If RetISR > 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, RetISR, RetISR, 9, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=PorcentajeRetISR, Contabilizable:=False) Then ErrorVentas = True : Exit For
+ End If
+
+ If ImpuestoLocal > 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImpuestoLocal, ImpuestoLocal, 27, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=PorcentajeIVA, Contabilizable:=False) Then ErrorVentas = True : Exit For
+ End If
+
+
+ If UsaComplementaria Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total * TipoCambio.ToDecimal - Total, Total * TipoCambio.ToDecimal - Total, 203, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteME:=Total, TipoCambio:=TipoCambio.ToDecimal, Contabilizable:=False) Then ErrorVentas = True : Exit For
+ End If
+
+ 'Saldo
+ If Saldo < Total Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total - Saldo, Total - Saldo, ConceptoContablePago, Folio.ToString(), Folio.ToString(), CveVenta:=CveVenta, CveCliente:=CveCliente, CveVentaAmortizacion:=CveVenta, Contabilizable:=False) Then ErrorVentas = True : Exit For
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total - Saldo, Total - Saldo, 95, Folio.ToString(), Folio.ToString(), CveVenta:=CveVenta, CveCliente:=CveCliente, Contabilizable:=False) Then ErrorVentas = True : Exit For
+ End If
+ End If
+
+ Else
+
+ If Not EsDetalle Then
+
+ SubTotal = 0
+ IVA = 0
+ Total = 0
+ Saldo = 0
+ RetIVA = 0
+ RetISR = 0
+ For Each item As DataRow In dt.FiltraParametros($"RFC <> '' AND Folio = '{Row("Folio").ToString()}' AND Serie = '{Row("Serie").ToString()}' AND [Tipo Documento] = '{Row("Tipo Documento").ToString()}' ").Rows
+ SubTotal += item("SubTotal").ToString().ToDecimal
+ IVA += item("IVA").ToString().ToDecimal
+ Total += item("Total").ToString().ToDecimal
+ Saldo += item("Saldo").ToString().ToDecimal
+ RetIVA += item("Ret IVA").ToString().ToDecimal
+ RetISR += item("Ret ISR").ToString().ToDecimal
+ IEPS += item("IEPS").ToString().ToDecimal
+ Next
+
+ 'ANTICIPOS
+ Dim CveIE As Integer = ObjIE.AddBancos_IE(1, 1, Fecha, Folio.ToString(), "", Total, 1,
+ 1, "Anticipo Cliente", "", False, False, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total, Total, 30, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveIE:=CveIE, CveCliente:=CveCliente, Contabilizable:=False) Then ErrorVentas = True : Exit For
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total, Total, 66, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveIE:=CveIE, CveCliente:=CveCliente, Contabilizable:=False) Then ErrorVentas = True : Exit For
+ End If
+ End If
+ Encontrados = Encontrados + 1
+
+ Else
+ NoEncontrados = NoEncontrados + 1
+ StrRFCNoencontrados.AppendFormat("{0}
", RFC)
+ 'ErrorVentas = True
+ 'Exit For
+ End If
+
+ CountRow = CountRow + 1
+ Next
+ If Not ErrorVentas Then
+ Alert(String.Format("Se agregaron: {0} Ventas correctamente. {1} no encontrados
{2} ", Encontrados, NoEncontrados, StrRFCNoencontrados), TipoMensaje.MsgInformacion)
+ ObjVentas.Commit()
+ TxtExcel.Text = ""
+ UpDatos.Update()
+ Else
+ Alert(String.Format("Error al registrar : {0} Ventas correctamente. {1} no encontrados
{2} ", Encontrados, NoEncontrados, StrRFCNoencontrados), TipoMensaje.MsgError)
+ ObjVentas.RollBack()
+ End If
+ ObjVentas.Dispose()
#End Region
-
-
-
' R H - P E R S O N A L
ElseIf RblFormato.SelectedValue = "6" Then
diff --git a/Imagenes/autobus.png b/Imagenes/autobus.png
new file mode 100644
index 000000000..cc13d8aa6
Binary files /dev/null and b/Imagenes/autobus.png differ
diff --git a/Imagenes/sprinter.png b/Imagenes/sprinter.png
new file mode 100644
index 000000000..c07dcc15e
Binary files /dev/null and b/Imagenes/sprinter.png differ
diff --git a/Inventarios/PopUpExistenciasAlmacen.aspx.vb b/Inventarios/PopUpExistenciasAlmacen.aspx.vb
index 99b2f1985..2df14d506 100644
--- a/Inventarios/PopUpExistenciasAlmacen.aspx.vb
+++ b/Inventarios/PopUpExistenciasAlmacen.aspx.vb
@@ -54,7 +54,7 @@ Partial Class Inventarios_Default
DivListasPrecios2.Visible = True
End If
- If UsuarioActual.CveRol = 1 Then
+ If UsuarioActual.TienePermisoProceso(387) Then
LnkBsucarSerie.Visible = True
End If
diff --git a/Inventarios/RecepcionAlmacen.aspx b/Inventarios/RecepcionAlmacen.aspx
index 937f907e0..569ec3073 100644
--- a/Inventarios/RecepcionAlmacen.aspx
+++ b/Inventarios/RecepcionAlmacen.aspx
@@ -19,14 +19,25 @@