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