E141. Correcion de descarga de pdf por QR
This commit is contained in:
888
Ashx/E141.ashx
888
Ashx/E141.ashx
@@ -259,39 +259,39 @@ Public Class E141 : Implements IHttpHandler
|
|||||||
End Property
|
End Property
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
#Region "V A L I D A - D A T O S"
|
#Region "V A L I D A - D A T O S"
|
||||||
Private Function ValidaUsuarioSistema(CveUsuario As Integer, CveEmpresa As Integer) As Usuario
|
Private Function ValidaUsuarioSistema(CveUsuario As Integer, CveEmpresa As Integer) As Usuario
|
||||||
Dim UsuarioActual As Usuario = Nothing
|
Dim UsuarioActual As Usuario = Nothing
|
||||||
Dim ObjUsuarios As New ClsSisUsuarios
|
Dim ObjUsuarios As New ClsSisUsuarios
|
||||||
If ObjUsuarios.GetUsuarios(CveUsuario) Then
|
If ObjUsuarios.GetUsuarios(CveUsuario) Then
|
||||||
If ObjUsuarios.DtResultados.Rows.Count > 0 Then
|
If ObjUsuarios.DtResultados.Rows.Count > 0 Then
|
||||||
Dim Usuario = ObjUsuarios.DtResultados.Rows(0)("Usuario").ToString()
|
Dim Usuario = ObjUsuarios.DtResultados.Rows(0)("Usuario").ToString()
|
||||||
Dim Contrasenia = ObjUsuarios.DtResultados.Rows(0)("Contraseña").ToString()
|
Dim Contrasenia = ObjUsuarios.DtResultados.Rows(0)("Contraseña").ToString()
|
||||||
UsuarioActual = ObjUsuarios.ValidaUsuario(Usuario, Contrasenia, IMEI, CveEmpresa)
|
UsuarioActual = ObjUsuarios.ValidaUsuario(Usuario, Contrasenia, IMEI, CveEmpresa)
|
||||||
UsuarioActual.CveEmpresa = CveEmpresa
|
UsuarioActual.CveEmpresa = CveEmpresa
|
||||||
CreaObjetoEmpresa(UsuarioActual)
|
CreaObjetoEmpresa(UsuarioActual)
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
ObjUsuarios.Dispose()
|
ObjUsuarios.Dispose()
|
||||||
Return UsuarioActual
|
Return UsuarioActual
|
||||||
End Function
|
End Function
|
||||||
Private Sub CreaObjetoEmpresa(ByRef UsuarioActual As Usuario)
|
Private Sub CreaObjetoEmpresa(ByRef UsuarioActual As Usuario)
|
||||||
|
|
||||||
Dim ObjEmpresa As New ClsSisEmpresas()
|
Dim ObjEmpresa As New ClsSisEmpresas()
|
||||||
If ObjEmpresa.GetEmpresas(UsuarioActual.CveEmpresa, "-1", "-1", "-1", "-1") Then
|
If ObjEmpresa.GetEmpresas(UsuarioActual.CveEmpresa, "-1", "-1", "-1", "-1") Then
|
||||||
If ObjEmpresa.GetEmpresasFuncionalidades(UsuarioActual.CveEmpresa) Then
|
If ObjEmpresa.GetEmpresasFuncionalidades(UsuarioActual.CveEmpresa) Then
|
||||||
Dim dttmp As Data.DataTable = ObjEmpresa.DtResultados
|
Dim dttmp As Data.DataTable = ObjEmpresa.DtResultados
|
||||||
|
|
||||||
Dim EmpresasFuncionalidades As New HybridDictionary
|
Dim EmpresasFuncionalidades As New HybridDictionary
|
||||||
For Each Row As Data.DataRow In dttmp.Rows
|
For Each Row As Data.DataRow In dttmp.Rows
|
||||||
EmpresasFuncionalidades.Add(Convert.ToInt32(Row("CveFuncionalidad")), Row("Valor").ToString)
|
EmpresasFuncionalidades.Add(Convert.ToInt32(Row("CveFuncionalidad")), Row("Valor").ToString)
|
||||||
Next
|
Next
|
||||||
ObjEmpresa.Empresa.SetFuncionalidades(EmpresasFuncionalidades)
|
ObjEmpresa.Empresa.SetFuncionalidades(EmpresasFuncionalidades)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
UsuarioActual.Empresa = ObjEmpresa.Empresa
|
UsuarioActual.Empresa = ObjEmpresa.Empresa
|
||||||
End If
|
End If
|
||||||
ObjEmpresa.Dispose()
|
ObjEmpresa.Dispose()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
#End Region
|
#End Region
|
||||||
@@ -766,7 +766,7 @@ Public Class E141 : Implements IHttpHandler
|
|||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
|
||||||
#Region "D E F I N I R - O B J E T O S"
|
#Region "D E F I N I R - O B J E T O S"
|
||||||
Private Function CrearCliente(TipoDocto As String, ObjClientes As ClsClientes, ByRef Resp As Modelos.Factura.MMensajeFactura, JsonRequest As JObject, UsuarioActual As Usuario) As Integer
|
Private Function CrearCliente(TipoDocto As String, ObjClientes As ClsClientes, ByRef Resp As Modelos.Factura.MMensajeFactura, JsonRequest As JObject, UsuarioActual As Usuario) As Integer
|
||||||
Dim CveCliente As Integer = -1
|
Dim CveCliente As Integer = -1
|
||||||
|
|
||||||
@@ -892,9 +892,9 @@ Public Class E141 : Implements IHttpHandler
|
|||||||
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Function CreaFactura(ObjInventario As ClsInventarios, ObjClientes As ClsClientes, TipoDocto As String, Resp As Modelos.Factura.MMensajeFactura, JsonRequest As JObject, UsuarioActual As Usuario) As Modelos.Factura
|
Private Function CreaFactura(ObjInventario As ClsInventarios, ObjClientes As ClsClientes, TipoDocto As String, Resp As Modelos.Factura.MMensajeFactura, JsonRequest As JObject, UsuarioActual As Usuario) As Modelos.Factura
|
||||||
Try
|
Try
|
||||||
Resp.TieneError = False
|
Resp.TieneError = False
|
||||||
Dim Serie As String = "-1"
|
Dim Serie As String = "-1"
|
||||||
Dim CveMoneda As Integer = 1
|
Dim CveMoneda As Integer = 1
|
||||||
|
|
||||||
@@ -914,52 +914,52 @@ Public Class E141 : Implements IHttpHandler
|
|||||||
|
|
||||||
If CveCliente <= 0 Then
|
If CveCliente <= 0 Then
|
||||||
Return Nothing
|
Return Nothing
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim ObjFactura = New Modelos.Factura(UsuarioActual)
|
Dim ObjFactura = New Modelos.Factura(UsuarioActual)
|
||||||
ObjFactura.TipoMensajeRespuesta = Modelos.TipoMensajeRespuesta.TextoLimpio
|
ObjFactura.TipoMensajeRespuesta = Modelos.TipoMensajeRespuesta.TextoLimpio
|
||||||
ObjFactura.Serie = Serie
|
ObjFactura.Serie = Serie
|
||||||
ObjFactura.Folio = -1
|
ObjFactura.Folio = -1
|
||||||
ObjFactura.Version = "3.3"
|
ObjFactura.Version = "3.3"
|
||||||
ObjFactura.FolioFiscal = ""
|
ObjFactura.FolioFiscal = ""
|
||||||
ObjFactura.CveUsuario = UsuarioActual.CveUsuario
|
ObjFactura.CveUsuario = UsuarioActual.CveUsuario
|
||||||
ObjFactura.CveEmpresa = UsuarioActual.CveEmpresa
|
ObjFactura.CveEmpresa = UsuarioActual.CveEmpresa
|
||||||
ObjFactura.TipoCambio = 1
|
ObjFactura.TipoCambio = 1
|
||||||
ObjFactura.ConvertirPesos = False
|
ObjFactura.ConvertirPesos = False
|
||||||
ObjFactura.CveMoneda = CveMoneda
|
ObjFactura.CveMoneda = CveMoneda
|
||||||
ObjFactura.Moneda = GlobalDTMonedas.FiltroPrimeroValor("Moneda", String.Format("CveMoneda = {0} ", CveMoneda))
|
ObjFactura.Moneda = GlobalDTMonedas.FiltroPrimeroValor("Moneda", String.Format("CveMoneda = {0} ", CveMoneda))
|
||||||
ObjFactura.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", String.Format("CveMoneda = {0} ", CveMoneda))
|
ObjFactura.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", String.Format("CveMoneda = {0} ", CveMoneda))
|
||||||
ObjFactura.TipoDocto = TipoDocto
|
ObjFactura.TipoDocto = TipoDocto
|
||||||
ObjFactura.RefDocto = ""
|
ObjFactura.RefDocto = ""
|
||||||
ObjFactura.CveMesa = -1
|
ObjFactura.CveMesa = -1
|
||||||
ObjFactura.Fecha = Now
|
ObjFactura.Fecha = Now
|
||||||
ObjFactura.CvePrePoliza = -1
|
ObjFactura.CvePrePoliza = -1
|
||||||
ObjFactura.FechaPago = Now
|
ObjFactura.FechaPago = Now
|
||||||
ObjFactura.MotivoDescuento = ""
|
ObjFactura.MotivoDescuento = ""
|
||||||
ObjFactura.FechaEjecucion = Now
|
ObjFactura.FechaEjecucion = Now
|
||||||
ObjFactura.UsuarioCreo = UsuarioActual.Usuario
|
ObjFactura.UsuarioCreo = UsuarioActual.Usuario
|
||||||
ObjFactura.CveCondicionEntrega = -1
|
ObjFactura.CveCondicionEntrega = -1
|
||||||
ObjFactura.CondicionEntrega = ""
|
ObjFactura.CondicionEntrega = ""
|
||||||
ObjFactura.NumeroCuenta = ""
|
ObjFactura.NumeroCuenta = ""
|
||||||
ObjFactura.CondicionesPago = 0
|
ObjFactura.CondicionesPago = 0
|
||||||
ObjFactura.FormaPago = 0
|
ObjFactura.FormaPago = 0
|
||||||
ObjFactura.PedidoContrato = ""
|
ObjFactura.PedidoContrato = ""
|
||||||
ObjFactura.NumeroContrato = ""
|
ObjFactura.NumeroContrato = ""
|
||||||
ObjFactura.DescripcionContrato = ""
|
ObjFactura.DescripcionContrato = ""
|
||||||
ObjFactura.CveCorte = -1
|
ObjFactura.CveCorte = -1
|
||||||
ObjFactura.TipoDocumento = ObjFactura.TipodeComprobante
|
ObjFactura.TipoDocumento = ObjFactura.TipodeComprobante
|
||||||
ObjFactura.Alfa1 = ""
|
ObjFactura.Alfa1 = ""
|
||||||
ObjFactura.Alfa2 = ""
|
ObjFactura.Alfa2 = ""
|
||||||
ObjFactura.Alfa3 = ""
|
ObjFactura.Alfa3 = ""
|
||||||
ObjFactura.CveContrato = -1
|
ObjFactura.CveContrato = -1
|
||||||
ObjFactura.ConvertirPesos = False
|
ObjFactura.ConvertirPesos = False
|
||||||
ObjFactura.CveSubProyecto = CveSubProyecto
|
ObjFactura.CveSubProyecto = CveSubProyecto
|
||||||
ObjFactura.CveSubProyectoCobranza = CveSubProyecto
|
ObjFactura.CveSubProyectoCobranza = CveSubProyecto
|
||||||
ObjFactura.CveSubProyectoEjecucion = CveSubProyecto
|
ObjFactura.CveSubProyectoEjecucion = CveSubProyecto
|
||||||
ObjFactura.SubProyecto = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1, CveEmpresa:=CveEmpresa).FiltroPrimero(String.Format("CveSubProyecto = {0}", CveSubProyecto)))
|
ObjFactura.SubProyecto = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1, CveEmpresa:=CveEmpresa).FiltroPrimero(String.Format("CveSubProyecto = {0}", CveSubProyecto)))
|
||||||
ObjFactura.SubProyectoMatriz = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1, CveSubProyecto:=-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("TipoSucursal=1"))
|
ObjFactura.SubProyectoMatriz = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1, CveSubProyecto:=-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("TipoSucursal=1"))
|
||||||
|
|
||||||
'CLIENTE
|
'CLIENTE
|
||||||
ObjFactura.CveCliente = CveCliente
|
ObjFactura.CveCliente = CveCliente
|
||||||
ObjFactura.CveClienteSucursal = -1
|
ObjFactura.CveClienteSucursal = -1
|
||||||
|
|
||||||
@@ -1147,24 +1147,24 @@ Public Class E141 : Implements IHttpHandler
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
'IMPORTES
|
'IMPORTES
|
||||||
Dim TotalImporte As Decimal = ObjFactura.DtDetalle.SUMD("TotalImporte")
|
Dim TotalImporte As Decimal = ObjFactura.DtDetalle.SUMD("TotalImporte")
|
||||||
Dim ImporteIVA As Decimal = ObjFactura.DtDetalle.SUMD("ImporteIVA")
|
Dim ImporteIVA As Decimal = ObjFactura.DtDetalle.SUMD("ImporteIVA")
|
||||||
Dim ImporteRetIVA As Decimal = ObjFactura.DtDetalle.SUMD("ImporteRetIVA")
|
Dim ImporteRetIVA As Decimal = ObjFactura.DtDetalle.SUMD("ImporteRetIVA")
|
||||||
Dim ImporteRetISR As Decimal = ObjFactura.DtDetalle.SUMD("ImporteRetISR")
|
Dim ImporteRetISR As Decimal = ObjFactura.DtDetalle.SUMD("ImporteRetISR")
|
||||||
Dim ImporteIEPS As Decimal = ObjFactura.DtDetalle.SUMD("ImporteIEPS")
|
Dim ImporteIEPS As Decimal = ObjFactura.DtDetalle.SUMD("ImporteIEPS")
|
||||||
Dim Descuento As Decimal = ObjFactura.DtDetalle.SUMD("Descuento")
|
Dim Descuento As Decimal = ObjFactura.DtDetalle.SUMD("Descuento")
|
||||||
Dim Amortizacion As Decimal = 0
|
Dim Amortizacion As Decimal = 0
|
||||||
|
|
||||||
Dim Total As Decimal = (TotalImporte + ImporteIVA + ImporteIEPS) - (ImporteRetIVA + ImporteRetISR + Descuento + Amortizacion)
|
Dim Total As Decimal = (TotalImporte + ImporteIVA + ImporteIEPS) - (ImporteRetIVA + ImporteRetISR + Descuento + Amortizacion)
|
||||||
|
|
||||||
ObjFactura.SubTotal = TotalImporte
|
ObjFactura.SubTotal = TotalImporte
|
||||||
ObjFactura.Descuento = Descuento
|
ObjFactura.Descuento = Descuento
|
||||||
ObjFactura.Amortizacion = Amortizacion
|
ObjFactura.Amortizacion = Amortizacion
|
||||||
ObjFactura.IVA = ImporteIVA
|
ObjFactura.IVA = ImporteIVA
|
||||||
ObjFactura.RetIVA = ImporteRetIVA
|
ObjFactura.RetIVA = ImporteRetIVA
|
||||||
ObjFactura.RetISR = ImporteRetISR
|
ObjFactura.RetISR = ImporteRetISR
|
||||||
ObjFactura.IEPS = ImporteIEPS
|
ObjFactura.IEPS = ImporteIEPS
|
||||||
ObjFactura.Total = Total
|
ObjFactura.Total = Total
|
||||||
ObjFactura.TotalOtrosConceptos = 0
|
ObjFactura.TotalOtrosConceptos = 0
|
||||||
|
|
||||||
'SI HAY DIFERENCIA DE UN CENTAVO AJUSTA
|
'SI HAY DIFERENCIA DE UN CENTAVO AJUSTA
|
||||||
@@ -1200,224 +1200,224 @@ Public Class E141 : Implements IHttpHandler
|
|||||||
ObjFactura.Observaciones = "PEDIDO PROVENIENTE DE ECOMMERCE"
|
ObjFactura.Observaciones = "PEDIDO PROVENIENTE DE ECOMMERCE"
|
||||||
ElseIf TipoDocto = "Cot" Then
|
ElseIf TipoDocto = "Cot" Then
|
||||||
ObjFactura.Observaciones = "COTIZACION PROVENIENTE DE ECOMMERCE"
|
ObjFactura.Observaciones = "COTIZACION PROVENIENTE DE ECOMMERCE"
|
||||||
End If
|
End If
|
||||||
|
|
||||||
ObjFactura.OrdenCompra = ""
|
ObjFactura.OrdenCompra = ""
|
||||||
ObjFactura.PedidoContrato = ""
|
ObjFactura.PedidoContrato = ""
|
||||||
ObjFactura.ObservacionesAlmacen = ""
|
ObjFactura.ObservacionesAlmacen = ""
|
||||||
ObjFactura.EnviarCorreo = False
|
ObjFactura.EnviarCorreo = False
|
||||||
|
|
||||||
ObjFactura.Timbre = PreParaTimbre(ObjFactura)
|
ObjFactura.Timbre = PreParaTimbre(ObjFactura)
|
||||||
ObjFactura.FemsaFactura = New Modelos.FemsaFactura() With {
|
ObjFactura.FemsaFactura = New Modelos.FemsaFactura() With {
|
||||||
.AplicaFEMSA = False,
|
.AplicaFEMSA = False,
|
||||||
.FEMSA_Version = 1
|
.FEMSA_Version = 1
|
||||||
}
|
}
|
||||||
Return ObjFactura
|
Return ObjFactura
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
Resp.Mensajes.Add(ex.ToString())
|
Resp.Mensajes.Add(ex.ToString())
|
||||||
Return Nothing
|
Return Nothing
|
||||||
End Try
|
End Try
|
||||||
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Function PreParaTimbre(Obj As Modelos.Factura) As CFDITimbre
|
Private Function PreParaTimbre(Obj As Modelos.Factura) As CFDITimbre
|
||||||
Dim Timbre As New CFDITimbre
|
Dim Timbre As New CFDITimbre
|
||||||
Timbre.Comprobante.TipoComprobante = If(Obj.TipoDocto.Contiene("Ing", "Ant"), "I", If(Obj.TipoDocto.Contiene("Egs", "Dev"), "E", ""))
|
Timbre.Comprobante.TipoComprobante = If(Obj.TipoDocto.Contiene("Ing", "Ant"), "I", If(Obj.TipoDocto.Contiene("Egs", "Dev"), "E", ""))
|
||||||
Timbre.Comprobante.Folio = Obj.Folio.ToString
|
Timbre.Comprobante.Folio = Obj.Folio.ToString
|
||||||
Timbre.Comprobante.Serie = Obj.Serie
|
Timbre.Comprobante.Serie = Obj.Serie
|
||||||
Timbre.Comprobante.Fecha = Obj.FechaCP
|
Timbre.Comprobante.Fecha = Obj.FechaCP
|
||||||
Timbre.Comprobante.FormadePago = Obj.FormaPagoSAT33
|
Timbre.Comprobante.FormadePago = Obj.FormaPagoSAT33
|
||||||
Timbre.Comprobante.CondicionesdePago = Obj.FormaPago33
|
Timbre.Comprobante.CondicionesdePago = Obj.FormaPago33
|
||||||
Timbre.Comprobante.MetodoPago = Obj.ClaveMetodoPagoSAT
|
Timbre.Comprobante.MetodoPago = Obj.ClaveMetodoPagoSAT
|
||||||
Timbre.Comprobante.Subtotal = Obj.SubTotal
|
Timbre.Comprobante.Subtotal = Obj.SubTotal
|
||||||
Timbre.Comprobante.Descuentos = Obj.Descuento
|
Timbre.Comprobante.Descuentos = Obj.Descuento
|
||||||
Timbre.Comprobante.Moneda = Obj.MonedaSAT
|
Timbre.Comprobante.Moneda = Obj.MonedaSAT
|
||||||
Timbre.Comprobante.TipoCambio = If(Obj.CveMoneda = 1, "1", Obj.TipoCambio.ToString)
|
Timbre.Comprobante.TipoCambio = If(Obj.CveMoneda = 1, "1", Obj.TipoCambio.ToString)
|
||||||
Timbre.Comprobante.Total = Obj.Total
|
Timbre.Comprobante.Total = Obj.Total
|
||||||
|
|
||||||
Timbre.Comprobante.LugarExpedicion = Obj.SubProyecto.CP
|
Timbre.Comprobante.LugarExpedicion = Obj.SubProyecto.CP
|
||||||
Timbre.Comprobante.Confirmacion = ""
|
Timbre.Comprobante.Confirmacion = ""
|
||||||
|
|
||||||
Timbre.Receptor.RFC = Obj.Cliente.RFC
|
Timbre.Receptor.RFC = Obj.Cliente.RFC
|
||||||
Timbre.Receptor.Nombre = Obj.Cliente.Nombre
|
Timbre.Receptor.Nombre = Obj.Cliente.Nombre
|
||||||
Timbre.Receptor.ResidenciaFiscal = ""
|
Timbre.Receptor.ResidenciaFiscal = ""
|
||||||
Timbre.Receptor.NumeroRegistroTributario = ""
|
Timbre.Receptor.NumeroRegistroTributario = ""
|
||||||
Timbre.Receptor.UsoCFDI = Obj.ClaveUsoCFDI
|
Timbre.Receptor.UsoCFDI = Obj.ClaveUsoCFDI
|
||||||
|
|
||||||
|
|
||||||
If Obj.CveTipoRelacion > 0 Then
|
If Obj.CveTipoRelacion > 0 Then
|
||||||
Select Case Obj.CveTipoRelacion
|
Select Case Obj.CveTipoRelacion
|
||||||
Case 1
|
Case 1
|
||||||
Timbre.CFDIRelacionados.TipoRelacion = "01"
|
Timbre.CFDIRelacionados.TipoRelacion = "01"
|
||||||
Timbre.CFDIRelacionados.TipoRelacionTexto = "01-Nota de Crédito aplicada a Ingreso"
|
Timbre.CFDIRelacionados.TipoRelacionTexto = "01-Nota de Crédito aplicada a Ingreso"
|
||||||
Case 2
|
Case 2
|
||||||
Timbre.CFDIRelacionados.TipoRelacion = "02"
|
Timbre.CFDIRelacionados.TipoRelacion = "02"
|
||||||
Timbre.CFDIRelacionados.TipoRelacionTexto = "02-Nota de débito de los documentos relacionados"
|
Timbre.CFDIRelacionados.TipoRelacionTexto = "02-Nota de débito de los documentos relacionados"
|
||||||
Case 3
|
Case 3
|
||||||
Timbre.CFDIRelacionados.TipoRelacion = "03"
|
Timbre.CFDIRelacionados.TipoRelacion = "03"
|
||||||
Timbre.CFDIRelacionados.TipoRelacionTexto = "03-Devolución aplicada a Ingreso"
|
Timbre.CFDIRelacionados.TipoRelacionTexto = "03-Devolución aplicada a Ingreso"
|
||||||
Case 4
|
Case 4
|
||||||
Timbre.CFDIRelacionados.TipoRelacion = "04"
|
Timbre.CFDIRelacionados.TipoRelacion = "04"
|
||||||
Timbre.CFDIRelacionados.TipoRelacionTexto = "04-Refacturación de Ingreso"
|
Timbre.CFDIRelacionados.TipoRelacionTexto = "04-Refacturación de Ingreso"
|
||||||
Case 7
|
Case 7
|
||||||
Timbre.CFDIRelacionados.TipoRelacion = "07"
|
Timbre.CFDIRelacionados.TipoRelacion = "07"
|
||||||
Timbre.CFDIRelacionados.TipoRelacionTexto = "07-CFDI por aplicación de anticipo"
|
Timbre.CFDIRelacionados.TipoRelacionTexto = "07-CFDI por aplicación de anticipo"
|
||||||
Case 8
|
Case 8
|
||||||
Timbre.CFDIRelacionados.TipoRelacion = "08"
|
Timbre.CFDIRelacionados.TipoRelacion = "08"
|
||||||
Timbre.CFDIRelacionados.TipoRelacionTexto = "08-Factura generada por pagos en parcialidades "
|
Timbre.CFDIRelacionados.TipoRelacionTexto = "08-Factura generada por pagos en parcialidades "
|
||||||
Case 9
|
Case 9
|
||||||
Timbre.CFDIRelacionados.TipoRelacion = "09"
|
Timbre.CFDIRelacionados.TipoRelacion = "09"
|
||||||
Timbre.CFDIRelacionados.TipoRelacionTexto = "09-Factura generada por pagos diferidos"
|
Timbre.CFDIRelacionados.TipoRelacionTexto = "09-Factura generada por pagos diferidos"
|
||||||
|
|
||||||
End Select
|
End Select
|
||||||
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
|
||||||
Dim totSubTotal As Decimal = Obj.SubTotal
|
Dim totSubTotal As Decimal = Obj.SubTotal
|
||||||
Dim totIVA As Decimal = Obj.IVA
|
Dim totIVA As Decimal = Obj.IVA
|
||||||
Dim totRetIVA As Decimal = Obj.RetIVA
|
Dim totRetIVA As Decimal = Obj.RetIVA
|
||||||
Dim totRetISR As Decimal = Obj.RetISR
|
Dim totRetISR As Decimal = Obj.RetISR
|
||||||
Dim i As Integer = 1
|
Dim i As Integer = 1
|
||||||
|
|
||||||
'DETALLES
|
'DETALLES
|
||||||
Dim tPS As String = ""
|
Dim tPS As String = ""
|
||||||
|
|
||||||
For Each drr As DataRow In Obj.DtDetalle.Rows
|
For Each drr As DataRow In Obj.DtDetalle.Rows
|
||||||
If drr("PS").ToString.Length = 1 Then
|
If drr("PS").ToString.Length = 1 Then
|
||||||
tPS = drr("Obs").ToString
|
tPS = drr("Obs").ToString
|
||||||
Else
|
Else
|
||||||
If drr("PS").ToString.Length = 0 Then
|
If drr("PS").ToString.Length = 0 Then
|
||||||
tPS = ""
|
tPS = ""
|
||||||
Else
|
Else
|
||||||
tPS = String.Format("{0} {1}", drr("PS"), drr("Obs"))
|
tPS = String.Format("{0} {1}", drr("PS"), drr("Obs"))
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
'CONDICIONANTE, ESPECIAL
|
'CONDICIONANTE, ESPECIAL
|
||||||
If Obj.CveEmpresa = 15 Then drr("UM") = "" 'LES COMENTAN QUE NO DEBE IR LA ETIQUETA DE LA UNIDAD EN EL PRODUCTO
|
If Obj.CveEmpresa = 15 Then drr("UM") = "" 'LES COMENTAN QUE NO DEBE IR LA ETIQUETA DE LA UNIDAD EN EL PRODUCTO
|
||||||
|
|
||||||
Dim concepto As New CFDIConceptos With {.Cantidad = drr("Cantidad").ToString.ToDecimal,
|
Dim concepto As New CFDIConceptos With {.Cantidad = drr("Cantidad").ToString.ToDecimal,
|
||||||
.Descripcion = tPS,
|
.Descripcion = tPS,
|
||||||
.ValorUnitario = drr("PU").ToString.ToDecimal,
|
.ValorUnitario = drr("PU").ToString.ToDecimal,
|
||||||
.Importe = drr("TotalImporte").ToString.ToDecimal,
|
.Importe = drr("TotalImporte").ToString.ToDecimal,
|
||||||
.Descuento = drr("Descuento").ToString.ToDecimal,
|
.Descuento = drr("Descuento").ToString.ToDecimal,
|
||||||
.Unidad = drr("UM").ToString,
|
.Unidad = drr("UM").ToString,
|
||||||
.ClaveUnidad = drr("SATClaveUM").ToString,
|
.ClaveUnidad = drr("SATClaveUM").ToString,
|
||||||
.ClaveProdServ = drr("SATClaveProdServ").ToString,
|
.ClaveProdServ = drr("SATClaveProdServ").ToString,
|
||||||
.Noidentificacion = drr("Noidentificacion").ToString,
|
.Noidentificacion = drr("Noidentificacion").ToString,
|
||||||
.CuentaPredial = drr("CuentaPredial").ToString}
|
.CuentaPredial = drr("CuentaPredial").ToString}
|
||||||
'VERIFICA SUMA SUBTOTALES
|
'VERIFICA SUMA SUBTOTALES
|
||||||
If i = Obj.DtDetalle.Rows.Count AndAlso totSubTotal <> concepto.Importe Then 'PROCESO DE AJUSTA DE DECIMALES
|
If i = Obj.DtDetalle.Rows.Count AndAlso totSubTotal <> concepto.Importe Then 'PROCESO DE AJUSTA DE DECIMALES
|
||||||
concepto.Importe = totSubTotal
|
concepto.Importe = totSubTotal
|
||||||
End If
|
End If
|
||||||
totSubTotal = totSubTotal - concepto.Importe
|
totSubTotal = totSubTotal - concepto.Importe
|
||||||
|
|
||||||
'SIEMPRE ESTAMOS AGREGANDO EL IVA
|
'SIEMPRE ESTAMOS AGREGANDO EL IVA
|
||||||
concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeIVA").ToString.ToDecimal, .Impuesto = "002", .Importe = drr("ImporteIVA").ToString.ToDecimal})
|
concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeIVA").ToString.ToDecimal, .Impuesto = "002", .Importe = drr("ImporteIVA").ToString.ToDecimal})
|
||||||
|
|
||||||
If drr("ImporteIEPS").ToString.ToDouble > 0 Then
|
If drr("ImporteIEPS").ToString.ToDouble > 0 Then
|
||||||
concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeIEPS").ToString.ToDecimal, .Impuesto = "003", .Importe = drr("ImporteIEPS").ToString.ToDecimal})
|
concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeIEPS").ToString.ToDecimal, .Impuesto = "003", .Importe = drr("ImporteIEPS").ToString.ToDecimal})
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If drr("ImporteRetIVA").ToString.ToDouble > 0 Then 'si hay retenciones
|
If drr("ImporteRetIVA").ToString.ToDouble > 0 Then 'si hay retenciones
|
||||||
concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "R", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeRetIVA").ToString.ToDecimal, .Impuesto = "002", .Importe = drr("ImporteRetIVA").ToString.ToDecimal})
|
concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "R", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeRetIVA").ToString.ToDecimal, .Impuesto = "002", .Importe = drr("ImporteRetIVA").ToString.ToDecimal})
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If drr("ImporteRetISR").ToString.ToDouble > 0 Then 'retención de ISR
|
If drr("ImporteRetISR").ToString.ToDouble > 0 Then 'retención de ISR
|
||||||
concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "R", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeRetISR").ToString.ToDecimal, .Impuesto = "001", .Importe = drr("ImporteRetISR").ToString.ToDecimal})
|
concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "R", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeRetISR").ToString.ToDecimal, .Impuesto = "001", .Importe = drr("ImporteRetISR").ToString.ToDecimal})
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Timbre.Conceptos.Add(concepto)
|
Timbre.Conceptos.Add(concepto)
|
||||||
i += 1
|
i += 1
|
||||||
Next
|
Next
|
||||||
Return Timbre
|
Return Timbre
|
||||||
End Function
|
End Function
|
||||||
Private Function CreaDTDetalle(ByRef ObjInventarios As ClsInventarios, ObjFactura As Modelos.Factura, ByRef Retorno As Modelos.Factura.MMensajeFactura, UsuarioActual As Usuario, JsonRequest As JObject) As DataTable
|
Private Function CreaDTDetalle(ByRef ObjInventarios As ClsInventarios, ObjFactura As Modelos.Factura, ByRef Retorno As Modelos.Factura.MMensajeFactura, UsuarioActual As Usuario, JsonRequest As JObject) As DataTable
|
||||||
Dim TmpDT = New DataTable
|
Dim TmpDT = New DataTable
|
||||||
TmpDT.Columns.Add("CveVenta", GetType(Integer))
|
TmpDT.Columns.Add("CveVenta", GetType(Integer))
|
||||||
TmpDT.Columns.Add("Consec", GetType(Integer))
|
TmpDT.Columns.Add("Consec", GetType(Integer))
|
||||||
TmpDT.Columns.Add("Cantidad", GetType(Decimal))
|
TmpDT.Columns.Add("Cantidad", GetType(Decimal))
|
||||||
TmpDT.Columns.Add("Codigo", GetType(String))
|
TmpDT.Columns.Add("Codigo", GetType(String))
|
||||||
TmpDT.Columns.Add("CveUM", GetType(Integer))
|
TmpDT.Columns.Add("CveUM", GetType(Integer))
|
||||||
TmpDT.Columns.Add("UM", GetType(String))
|
TmpDT.Columns.Add("UM", GetType(String))
|
||||||
TmpDT.Columns.Add("SATClaveUM", GetType(String))
|
TmpDT.Columns.Add("SATClaveUM", GetType(String))
|
||||||
TmpDT.Columns.Add("CveClasificacion", GetType(Integer))
|
TmpDT.Columns.Add("CveClasificacion", GetType(Integer))
|
||||||
TmpDT.Columns.Add("Clasificacion", GetType(String))
|
TmpDT.Columns.Add("Clasificacion", GetType(String))
|
||||||
TmpDT.Columns.Add("CvePS", GetType(Integer))
|
TmpDT.Columns.Add("CvePS", GetType(Integer))
|
||||||
TmpDT.Columns.Add("PS", GetType(String))
|
TmpDT.Columns.Add("PS", GetType(String))
|
||||||
TmpDT.Columns.Add("CodigoPS", GetType(String))
|
TmpDT.Columns.Add("CodigoPS", GetType(String))
|
||||||
TmpDT.Columns.Add("SATClaveProdServ", GetType(String))
|
TmpDT.Columns.Add("SATClaveProdServ", GetType(String))
|
||||||
TmpDT.Columns.Add("NoIdentificacion", GetType(String))
|
TmpDT.Columns.Add("NoIdentificacion", GetType(String))
|
||||||
TmpDT.Columns.Add("CveTipoPS", GetType(Integer))
|
TmpDT.Columns.Add("CveTipoPS", GetType(Integer))
|
||||||
TmpDT.Columns.Add("CveTipoInvPS", GetType(Integer))
|
TmpDT.Columns.Add("CveTipoInvPS", GetType(Integer))
|
||||||
TmpDT.Columns.Add("Serie", GetType(String))
|
TmpDT.Columns.Add("Serie", GetType(String))
|
||||||
TmpDT.Columns.Add("CuentaPredial", GetType(String))
|
TmpDT.Columns.Add("CuentaPredial", GetType(String))
|
||||||
TmpDT.Columns.Add("Obs", GetType(String))
|
TmpDT.Columns.Add("Obs", GetType(String))
|
||||||
TmpDT.Columns.Add("TiempoEntrega", GetType(String))
|
TmpDT.Columns.Add("TiempoEntrega", GetType(String))
|
||||||
TmpDT.Columns.Add("PU", GetType(Decimal))
|
TmpDT.Columns.Add("PU", GetType(Decimal))
|
||||||
TmpDT.Columns.Add("IVA", GetType(Decimal))
|
TmpDT.Columns.Add("IVA", GetType(Decimal))
|
||||||
TmpDT.Columns.Add("ImporteIVA", GetType(Decimal))
|
TmpDT.Columns.Add("ImporteIVA", GetType(Decimal))
|
||||||
TmpDT.Columns.Add("PorcentajeIVA", GetType(Decimal))
|
TmpDT.Columns.Add("PorcentajeIVA", GetType(Decimal))
|
||||||
TmpDT.Columns.Add("ImporteRetIVA", GetType(Decimal))
|
TmpDT.Columns.Add("ImporteRetIVA", GetType(Decimal))
|
||||||
TmpDT.Columns.Add("ImporteRetISR", GetType(Decimal))
|
TmpDT.Columns.Add("ImporteRetISR", GetType(Decimal))
|
||||||
TmpDT.Columns.Add("PorcentajeRetIVA", GetType(Decimal))
|
TmpDT.Columns.Add("PorcentajeRetIVA", GetType(Decimal))
|
||||||
TmpDT.Columns.Add("PorcentajeRetISR", GetType(Decimal))
|
TmpDT.Columns.Add("PorcentajeRetISR", GetType(Decimal))
|
||||||
TmpDT.Columns.Add("ImporteIEPS", GetType(Decimal))
|
TmpDT.Columns.Add("ImporteIEPS", GetType(Decimal))
|
||||||
TmpDT.Columns.Add("IEPS", GetType(Decimal))
|
TmpDT.Columns.Add("IEPS", GetType(Decimal))
|
||||||
TmpDT.Columns.Add("PorcentajeIEPS", GetType(Decimal))
|
TmpDT.Columns.Add("PorcentajeIEPS", GetType(Decimal))
|
||||||
TmpDT.Columns.Add("Descuento", GetType(Decimal))
|
TmpDT.Columns.Add("Descuento", GetType(Decimal))
|
||||||
TmpDT.Columns.Add("TipoDescuento", GetType(Integer))
|
TmpDT.Columns.Add("TipoDescuento", GetType(Integer))
|
||||||
TmpDT.Columns.Add("TotalImporte", GetType(Decimal))
|
TmpDT.Columns.Add("TotalImporte", GetType(Decimal))
|
||||||
TmpDT.Columns.Add("Total", GetType(Decimal))
|
TmpDT.Columns.Add("Total", GetType(Decimal))
|
||||||
'Para uso del módulo contable
|
'Para uso del módulo contable
|
||||||
TmpDT.Columns.Add("AsientoContableVentas", GetType(Integer))
|
TmpDT.Columns.Add("AsientoContableVentas", GetType(Integer))
|
||||||
TmpDT.Columns.Add("IdCtaContVentas", GetType(Integer))
|
TmpDT.Columns.Add("IdCtaContVentas", GetType(Integer))
|
||||||
TmpDT.Columns.Add("AplicaParaConcepto", GetType(Boolean))
|
TmpDT.Columns.Add("AplicaParaConcepto", GetType(Boolean))
|
||||||
TmpDT.Columns.Add("CveProyecto", GetType(Integer))
|
TmpDT.Columns.Add("CveProyecto", GetType(Integer))
|
||||||
TmpDT.Columns.Add("Proyecto", GetType(String))
|
TmpDT.Columns.Add("Proyecto", GetType(String))
|
||||||
TmpDT.Columns.Add("CveSubProyecto", GetType(Integer))
|
TmpDT.Columns.Add("CveSubProyecto", GetType(Integer))
|
||||||
TmpDT.Columns.Add("SubProyecto", GetType(String))
|
TmpDT.Columns.Add("SubProyecto", GetType(String))
|
||||||
'TipoDescuento: 1 = Descuento * PU; 2 = Descuento por Total del concepto
|
'TipoDescuento: 1 = Descuento * PU; 2 = Descuento por Total del concepto
|
||||||
TmpDT.Columns.Add("CvePresupuestoIngreso", GetType(Integer))
|
TmpDT.Columns.Add("CvePresupuestoIngreso", GetType(Integer))
|
||||||
TmpDT.Columns.Add("CveFuenteRecaudacion", GetType(Integer))
|
TmpDT.Columns.Add("CveFuenteRecaudacion", GetType(Integer))
|
||||||
'Contratos
|
'Contratos
|
||||||
TmpDT.Columns.Add("CveContratoDetalle", GetType(Integer))
|
TmpDT.Columns.Add("CveContratoDetalle", GetType(Integer))
|
||||||
'Remisiones a Facturas
|
'Remisiones a Facturas
|
||||||
TmpDT.Columns.Add("CveVentaDetalle", GetType(Integer))
|
TmpDT.Columns.Add("CveVentaDetalle", GetType(Integer))
|
||||||
TmpDT.Columns.Add("CveVentaDetalleRemision", GetType(Integer))
|
TmpDT.Columns.Add("CveVentaDetalleRemision", GetType(Integer))
|
||||||
TmpDT.Columns.Add("CveVentaDetalleCotizacion", GetType(Integer))
|
TmpDT.Columns.Add("CveVentaDetalleCotizacion", GetType(Integer))
|
||||||
|
|
||||||
'Pedido2 a Facturas
|
'Pedido2 a Facturas
|
||||||
TmpDT.Columns.Add("CveVentaDetallePedido2", GetType(Integer))
|
TmpDT.Columns.Add("CveVentaDetallePedido2", GetType(Integer))
|
||||||
|
|
||||||
TmpDT.Columns.Add("Origen", GetType(Integer))
|
TmpDT.Columns.Add("Origen", GetType(Integer))
|
||||||
'Ordenes Servicio
|
'Ordenes Servicio
|
||||||
TmpDT.Columns.Add("CveOS", GetType(Integer))
|
TmpDT.Columns.Add("CveOS", GetType(Integer))
|
||||||
TmpDT.Columns.Add("CveOSDetalle", GetType(Integer))
|
TmpDT.Columns.Add("CveOSDetalle", GetType(Integer))
|
||||||
TmpDT.Columns.Add("SeFacturara", GetType(Integer))
|
TmpDT.Columns.Add("SeFacturara", GetType(Integer))
|
||||||
TmpDT.Columns.Add("Folio", GetType(Integer))
|
TmpDT.Columns.Add("Folio", GetType(Integer))
|
||||||
TmpDT.Columns.Add("Estatus", GetType(String))
|
TmpDT.Columns.Add("Estatus", GetType(String))
|
||||||
'Ordenamiento
|
'Ordenamiento
|
||||||
TmpDT.Columns.Add("Orden", GetType(Integer))
|
TmpDT.Columns.Add("Orden", GetType(Integer))
|
||||||
TmpDT.Columns.Add("TipoDocto", GetType(String))
|
TmpDT.Columns.Add("TipoDocto", GetType(String))
|
||||||
'OC
|
'OC
|
||||||
TmpDT.Columns.Add("CveOrdenCompraDetalle", GetType(Integer))
|
TmpDT.Columns.Add("CveOrdenCompraDetalle", GetType(Integer))
|
||||||
TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
|
TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
|
||||||
|
|
||||||
TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
|
TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
|
||||||
TmpDT.Columns.Add("CantidadFacturadaRem", GetType(Decimal))
|
TmpDT.Columns.Add("CantidadFacturadaRem", GetType(Decimal))
|
||||||
TmpDT.Columns.Add("CantidadFacturadaCot", GetType(Decimal))
|
TmpDT.Columns.Add("CantidadFacturadaCot", GetType(Decimal))
|
||||||
TmpDT.Columns.Add("CantidadInventario", GetType(Decimal))
|
TmpDT.Columns.Add("CantidadInventario", GetType(Decimal))
|
||||||
|
|
||||||
TmpDT.Columns.Add("ClaveSATFraccionArancelaria", GetType(String))
|
TmpDT.Columns.Add("ClaveSATFraccionArancelaria", GetType(String))
|
||||||
TmpDT.Columns.Add("ClaveSATUnidadAduana", GetType(String))
|
TmpDT.Columns.Add("ClaveSATUnidadAduana", GetType(String))
|
||||||
TmpDT.Columns.Add("ClaveSATFraccionArancelariaDescripcion", GetType(String))
|
TmpDT.Columns.Add("ClaveSATFraccionArancelariaDescripcion", GetType(String))
|
||||||
TmpDT.Columns.Add("ClaveSATUnidadAduanaDescripcion", GetType(String))
|
TmpDT.Columns.Add("ClaveSATUnidadAduanaDescripcion", GetType(String))
|
||||||
|
|
||||||
TmpDT.Columns.Add("CveTamaño", GetType(Integer))
|
TmpDT.Columns.Add("CveTamaño", GetType(Integer))
|
||||||
|
|
||||||
|
|
||||||
Try
|
Try
|
||||||
Dim ListaPS = JArray.Parse(JsonRequest("details").ToString())
|
Dim ListaPS = JArray.Parse(JsonRequest("details").ToString())
|
||||||
Dim DescuentoTotal As Decimal = JsonRequest("discount").ToString().ToDecimal()
|
Dim DescuentoTotal As Decimal = JsonRequest("discount").ToString().ToDecimal()
|
||||||
@@ -1490,142 +1490,142 @@ Public Class E141 : Implements IHttpHandler
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
Consec += 1
|
Consec += 1
|
||||||
Next
|
Next
|
||||||
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
Retorno.TieneError = True
|
Retorno.TieneError = True
|
||||||
Retorno.Mensajes.Add(ex.ToString())
|
Retorno.Mensajes.Add(ex.ToString())
|
||||||
End Try
|
End Try
|
||||||
|
|
||||||
If Retorno.TieneError = True Then
|
If Retorno.TieneError = True Then
|
||||||
TmpDT.Clear()
|
TmpDT.Clear()
|
||||||
TmpDT = Nothing
|
TmpDT = Nothing
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Return TmpDT
|
Return TmpDT
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Function AgregarProductoServicio(ByRef Retorno As Modelos.Factura.MMensajeFactura, UsuarioActual As Usuario, TmpDT As DataTable, Consec As Integer, Cantidad As Decimal, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, CvePS As Integer, PS As String, Obs As String,
|
Private Function AgregarProductoServicio(ByRef Retorno As Modelos.Factura.MMensajeFactura, UsuarioActual As Usuario, TmpDT As DataTable, Consec As Integer, Cantidad As Decimal, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, CvePS As Integer, PS As String, Obs As String,
|
||||||
PU As Decimal, Descuento As Decimal, CveSubProyecto As Integer,
|
PU As Decimal, Descuento As Decimal, CveSubProyecto As Integer,
|
||||||
Optional Serie As String = "", Optional TiempoEntrega As String = "", Optional EntregaDirecta As Integer = 0,
|
Optional Serie As String = "", Optional TiempoEntrega As String = "", Optional EntregaDirecta As Integer = 0,
|
||||||
Optional CveContratoDetalle As Integer = 0, Optional CveVentaDetalle As Integer = 0, Optional CveMovimientoDetallePedido As Integer = 0,
|
Optional CveContratoDetalle As Integer = 0, Optional CveVentaDetalle As Integer = 0, Optional CveMovimientoDetallePedido As Integer = 0,
|
||||||
Optional CveOrdenCompraDetalle As Integer = 0, Optional CveVentaDetalleRemision As Integer = 0, Optional CveVentaDetalleCotizacion As Integer = 0,
|
Optional CveOrdenCompraDetalle As Integer = 0, Optional CveVentaDetalleRemision As Integer = 0, Optional CveVentaDetalleCotizacion As Integer = 0,
|
||||||
Optional CuentaPredial As String = "", Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0,
|
Optional CuentaPredial As String = "", Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0,
|
||||||
Optional ClienteRetIVA As Double = 0, Optional ClienteRetISR As Double = 0, Optional ClienteDesglosaIEPS As Boolean = True) As DataRow
|
Optional ClienteRetIVA As Double = 0, Optional ClienteRetISR As Double = 0, Optional ClienteDesglosaIEPS As Boolean = True) As DataRow
|
||||||
|
|
||||||
|
|
||||||
Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
|
Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
|
||||||
|
|
||||||
If DrPS Is Nothing Then
|
If DrPS Is Nothing Then
|
||||||
Retorno.Mensajes.Add("Ocurrió un error al cargar la información del Producto. Por favor vuelva a intentar.")
|
Retorno.Mensajes.Add("Ocurrió un error al cargar la información del Producto. Por favor vuelva a intentar.")
|
||||||
Return Nothing
|
Return Nothing
|
||||||
End If
|
End If
|
||||||
|
|
||||||
'verifica si tiene ventaminima
|
'verifica si tiene ventaminima
|
||||||
If Cantidad > 0 AndAlso DrPS("VentaMinima").ToString.ToDouble() > 0 Then
|
If Cantidad > 0 AndAlso DrPS("VentaMinima").ToString.ToDouble() > 0 Then
|
||||||
'verifico que la cantidad sea multiplo de venta minima, es decir ventaminima =5, solo puede vender 5,10,15...
|
'verifico que la cantidad sea multiplo de venta minima, es decir ventaminima =5, solo puede vender 5,10,15...
|
||||||
If Cantidad < DrPS("VentaMinima").ToString.ToDouble() Then
|
If Cantidad < DrPS("VentaMinima").ToString.ToDouble() Then
|
||||||
Retorno.Mensajes.Add("La cantidad es menor que la venta minima")
|
Retorno.Mensajes.Add("La cantidad es menor que la venta minima")
|
||||||
Return Nothing
|
Return Nothing
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If (DrPS("SATClaveUnidadMedida").ToString = "" Or DrPS("SATClavePS").ToString = "") Then
|
If (DrPS("SATClaveUnidadMedida").ToString = "" Or DrPS("SATClavePS").ToString = "") Then
|
||||||
'VALIDA CLAVESAT
|
'VALIDA CLAVESAT
|
||||||
If DrPS("SATClavePS").ToString = "" Then
|
If DrPS("SATClavePS").ToString = "" Then
|
||||||
Retorno.Mensajes.Add(String.Format("<b>{0}-{1}</b>: Sin producto SAT<br/>", DrPS("Codigo").ToString, DrPS("PS").ToString))
|
Retorno.Mensajes.Add(String.Format("<b>{0}-{1}</b>: Sin producto SAT<br/>", DrPS("Codigo").ToString, DrPS("PS").ToString))
|
||||||
Return Nothing
|
Return Nothing
|
||||||
ElseIf DrPS("SATClaveUnidadMedida").ToString = "" Then
|
ElseIf DrPS("SATClaveUnidadMedida").ToString = "" Then
|
||||||
Retorno.Mensajes.Add(String.Format("<b>{0}-{1}</b>: Sin Unidad Medida SAT<br/>", DrPS("Codigo").ToString, DrPS("PS").ToString))
|
Retorno.Mensajes.Add(String.Format("<b>{0}-{1}</b>: Sin Unidad Medida SAT<br/>", DrPS("Codigo").ToString, DrPS("PS").ToString))
|
||||||
Return Nothing
|
Return Nothing
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If Not ClienteDesglosaIEPS Then
|
If Not ClienteDesglosaIEPS Then
|
||||||
If Not RegeneraIEPS Then
|
If Not RegeneraIEPS Then
|
||||||
PU = PU * (1 + DrPS("IEPSPorcentaje").ToString.ToDecimal)
|
PU = PU * (1 + DrPS("IEPSPorcentaje").ToString.ToDecimal)
|
||||||
End If
|
End If
|
||||||
DrPS("IEPSPorcentaje") = 0
|
DrPS("IEPSPorcentaje") = 0
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim Row As DataRow = Nothing
|
Dim Row As DataRow = Nothing
|
||||||
Dim TotalCalculableImpuestos As Decimal = 0
|
Dim TotalCalculableImpuestos As Decimal = 0
|
||||||
PU = Math.Round(PU, 6) ' el precio unitario puede llevar hasta 6 decimales permitidos
|
PU = Math.Round(PU, 6) ' el precio unitario puede llevar hasta 6 decimales permitidos
|
||||||
Dim DrSubProyecto As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto).Rows(0)
|
Dim DrSubProyecto As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto).Rows(0)
|
||||||
|
|
||||||
Row = TmpDT.NewRow()
|
Row = TmpDT.NewRow()
|
||||||
Row("CveProyecto") = DrSubProyecto("CveProyecto").ToString().ToEntero()
|
Row("CveProyecto") = DrSubProyecto("CveProyecto").ToString().ToEntero()
|
||||||
Row("Proyecto") = DrSubProyecto("Proyecto").ToString()
|
Row("Proyecto") = DrSubProyecto("Proyecto").ToString()
|
||||||
Row("CveSubProyecto") = CveSubProyecto
|
Row("CveSubProyecto") = CveSubProyecto
|
||||||
Row("SubProyecto") = DrSubProyecto("SubProyecto").ToString()
|
Row("SubProyecto") = DrSubProyecto("SubProyecto").ToString()
|
||||||
Row("Serie") = Serie
|
Row("Serie") = Serie
|
||||||
Row("TiempoEntrega") = TiempoEntrega
|
Row("TiempoEntrega") = TiempoEntrega
|
||||||
Row("Orden") = TmpDT.Rows.Count + 1
|
Row("Orden") = TmpDT.Rows.Count + 1
|
||||||
Row("Cantidad") = Cantidad
|
Row("Cantidad") = Cantidad
|
||||||
Row("CveUM") = CveUM
|
Row("CveUM") = CveUM
|
||||||
Row("UM") = UM
|
Row("UM") = UM
|
||||||
Row("CveClasificacion") = CveClasificacion
|
Row("CveClasificacion") = CveClasificacion
|
||||||
Row("Clasificacion") = Clasificacion
|
Row("Clasificacion") = Clasificacion
|
||||||
Row("CvePS") = CvePS
|
Row("CvePS") = CvePS
|
||||||
Row("Obs") = Obs
|
Row("Obs") = Obs
|
||||||
|
|
||||||
TotalCalculableImpuestos = (Cantidad * PU) - Descuento
|
TotalCalculableImpuestos = (Cantidad * PU) - Descuento
|
||||||
|
|
||||||
Row("PU") = PU
|
Row("PU") = PU
|
||||||
Row("Codigo") = DrPS("Codigo")
|
Row("Codigo") = DrPS("Codigo")
|
||||||
Row("NoIdentificacion") = DrPS("Codigo")
|
Row("NoIdentificacion") = DrPS("Codigo")
|
||||||
Row("ClaveSATFraccionArancelaria") = DrPS("ClaveSATFraccionArancelaria")
|
Row("ClaveSATFraccionArancelaria") = DrPS("ClaveSATFraccionArancelaria")
|
||||||
Row("ClaveSATUnidadAduana") = DrPS("ClaveSATUnidadAduana")
|
Row("ClaveSATUnidadAduana") = DrPS("ClaveSATUnidadAduana")
|
||||||
Row("ClaveSATFraccionArancelariaDescripcion") = DrPS("ClaveSATFraccionArancelariaDescripcion")
|
Row("ClaveSATFraccionArancelariaDescripcion") = DrPS("ClaveSATFraccionArancelariaDescripcion")
|
||||||
Row("ClaveSATUnidadAduanaDescripcion") = DrPS("ClaveSATUnidadAduanaDescripcion")
|
Row("ClaveSATUnidadAduanaDescripcion") = DrPS("ClaveSATUnidadAduanaDescripcion")
|
||||||
Row("Consec") = Consec
|
Row("Consec") = Consec
|
||||||
|
|
||||||
Row("PS") = DrPS("PS")
|
Row("PS") = DrPS("PS")
|
||||||
Row("CodigoPS") = DrPS("PSCodigo").ToString
|
Row("CodigoPS") = DrPS("PSCodigo").ToString
|
||||||
Row("CveTipoPS") = DrPS("CveTipoPS")
|
Row("CveTipoPS") = DrPS("CveTipoPS")
|
||||||
Row("CveTipoInvPS") = DrPS("Inv_CveMetodoInventario")
|
Row("CveTipoInvPS") = DrPS("Inv_CveMetodoInventario")
|
||||||
Row("CveTamaño") = DrPS("CveTamaño")
|
Row("CveTamaño") = DrPS("CveTamaño")
|
||||||
|
|
||||||
If CveClasificacion <= 0 Then Row("CveClasificacion") = DrPS("CveClasificacion")
|
If CveClasificacion <= 0 Then Row("CveClasificacion") = DrPS("CveClasificacion")
|
||||||
If Clasificacion = "" Then Row("Clasificacion") = DrPS("Clasificacion")
|
If Clasificacion = "" Then Row("Clasificacion") = DrPS("Clasificacion")
|
||||||
|
|
||||||
If DrPS("IVA").ToString.Contiene("-1", "") Then
|
If DrPS("IVA").ToString.Contiene("-1", "") Then
|
||||||
Row("PorcentajeIVA") = DrSubProyecto("IVA")
|
Row("PorcentajeIVA") = DrSubProyecto("IVA")
|
||||||
Else
|
Else
|
||||||
Row("PorcentajeIVA") = DrPS("IVA")
|
Row("PorcentajeIVA") = DrPS("IVA")
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Row("IVA") = Row("PorcentajeIVA")
|
Row("IVA") = Row("PorcentajeIVA")
|
||||||
Row("ImporteIVA") = Math.Round(Row("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, 2)
|
Row("ImporteIVA") = Math.Round(Row("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, 2)
|
||||||
Row("ImporteRetIVA") = Math.Round(ClienteRetIVA * TotalCalculableImpuestos, 2)
|
Row("ImporteRetIVA") = Math.Round(ClienteRetIVA * TotalCalculableImpuestos, 2)
|
||||||
Row("ImporteRetISR") = Math.Round(ClienteRetISR * TotalCalculableImpuestos, 2)
|
Row("ImporteRetISR") = Math.Round(ClienteRetISR * TotalCalculableImpuestos, 2)
|
||||||
Row("PorcentajeRetIVA") = ClienteRetIVA
|
Row("PorcentajeRetIVA") = ClienteRetIVA
|
||||||
Row("PorcentajeRetISR") = ClienteRetISR
|
Row("PorcentajeRetISR") = ClienteRetISR
|
||||||
Row("PorcentajeIEPS") = DrPS("IEPSPorcentaje")
|
Row("PorcentajeIEPS") = DrPS("IEPSPorcentaje")
|
||||||
Row("ImporteIEPS") = Math.Round(DrPS("IEPSPorcentaje").ToString.ToDecimal * TotalCalculableImpuestos, 2)
|
Row("ImporteIEPS") = Math.Round(DrPS("IEPSPorcentaje").ToString.ToDecimal * TotalCalculableImpuestos, 2)
|
||||||
Row("IEPS") = Row("ImporteIEPS")
|
Row("IEPS") = Row("ImporteIEPS")
|
||||||
Row("Descuento") = Math.Round(Descuento, 2)
|
Row("Descuento") = Math.Round(Descuento, 2)
|
||||||
Row("TipoDescuento") = "2"
|
Row("TipoDescuento") = "2"
|
||||||
|
|
||||||
Row("Total") = Cantidad * PU
|
Row("Total") = Cantidad * PU
|
||||||
Row("TotalImporte") = Math.Round(Cantidad * PU, 2)
|
Row("TotalImporte") = Math.Round(Cantidad * PU, 2)
|
||||||
|
|
||||||
Row("SATClaveProdServ") = DrPS("SATClavePS")
|
Row("SATClaveProdServ") = DrPS("SATClavePS")
|
||||||
Row("SATClaveUM") = DrPS("SATClaveUnidadMedida")
|
Row("SATClaveUM") = DrPS("SATClaveUnidadMedida")
|
||||||
|
|
||||||
Row("EntregaDirecta") = EntregaDirecta
|
Row("EntregaDirecta") = EntregaDirecta
|
||||||
'Contratos
|
'Contratos
|
||||||
Row("CveContratoDetalle") = CveContratoDetalle
|
Row("CveContratoDetalle") = CveContratoDetalle
|
||||||
Row("CveVentaDetalle") = CveVentaDetalle
|
Row("CveVentaDetalle") = CveVentaDetalle
|
||||||
Row("CveMovimientoDetallePedido") = CveMovimientoDetallePedido
|
Row("CveMovimientoDetallePedido") = CveMovimientoDetallePedido
|
||||||
Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle
|
Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle
|
||||||
Row("CveVentaDetalleRemision") = CveVentaDetalleRemision
|
Row("CveVentaDetalleRemision") = CveVentaDetalleRemision
|
||||||
Row("CveVentaDetalleCotizacion") = CveVentaDetalleCotizacion
|
Row("CveVentaDetalleCotizacion") = CveVentaDetalleCotizacion
|
||||||
Row("CveVentaDetallePedido2") = CveVentaDetallePedido2
|
Row("CveVentaDetallePedido2") = CveVentaDetallePedido2
|
||||||
Row("CuentaPredial") = CuentaPredial
|
Row("CuentaPredial") = CuentaPredial
|
||||||
|
|
||||||
'RECARGAR GV
|
'RECARGAR GV
|
||||||
Return Row
|
Return Row
|
||||||
End Function
|
End Function
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
@@ -2353,7 +2353,7 @@ Public Class E141 : Implements IHttpHandler
|
|||||||
#Region "D E S C A R G A - P D F"
|
#Region "D E S C A R G A - P D F"
|
||||||
|
|
||||||
Private Function DescargarFactura(FilePDF As String) As Byte()
|
Private Function DescargarFactura(FilePDF As String) As Byte()
|
||||||
Dim Url = New Uri(String.Format("{0}Compras/PopUpVerFactura.aspx?TipoDocto=Ing&File={1}&TipoArchivo=PDF", "http://localhost/", FilePDF))
|
Dim Url = New Uri(String.Format("{0}://{1}:{2}/Compras/PopUpVerFactura.aspx?TipoDocto=Ing&File={3}&TipoArchivo=PDF", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port, FilePDF))
|
||||||
Dim File As Byte() = Nothing
|
Dim File As Byte() = Nothing
|
||||||
Try
|
Try
|
||||||
Using httpClient = New HttpClient()
|
Using httpClient = New HttpClient()
|
||||||
|
|||||||
Reference in New Issue
Block a user