From 2f6e7f77204f31756edcfa13cb3dee89d388fd78 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Thu, 19 May 2022 13:48:35 -0700 Subject: [PATCH 01/25] Centrar generacion de pdf en el popUpVerFactura.aspx --- Ventas/Ventas.aspx.vb | 57 +++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 2313b57c3..4eb92796f 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -11021,6 +11021,10 @@ Partial Class Ventas ObjFactura.EsGarantia = Me.EsGarantia + If UsuarioActual.Empresa.Funcionalidad(558).ToEntero() = 1 AndAlso TrKilometraje.Visible Then + ObjFactura.Kilometraje = TxtKilometraje.Text.Trim.ToDecimal() + End If + 'ASIGNAR RFC RECEPTOR If ObjFactura.Timbre IsNot Nothing Then If ObjFactura.Timbre.Receptor IsNot Nothing Then @@ -14831,12 +14835,11 @@ Partial Class Ventas 'TIMBRADO NUEVO Try - PdfFactura(ObjFactura) - 'If DdlTipoComprobante.SelectedValue = "Ing" Or DdlTipoComprobante.SelectedValue = "Ant" Then - ' PdfFactura(ObjFactura) - ' 'Else - ' ' pdf = PdfFactura(ObjFactura) - 'End If + Dim ObjetoPDF As Byte() = DescargarFactura(ObjFactura.CveVenta, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) + + If ObjetoPDF Is Nothing OrElse ObjetoPDF.Length = 0 Then + PdfFactura(ObjFactura, AplicaPagare:=If(ObjFactura.TipoDocto.Contiene("Ing", "Rem", "Ant"), "1", "0")) + End If Catch ex As Exception Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgError) @@ -14935,7 +14938,7 @@ Partial Class Ventas 'TIMBRADO NUEVO Try - pdf = PdfFactura(ObjFactura) + pdf = PdfFactura(ObjFactura, AplicaPagare:="1") Catch ex As Exception Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgError) End Try @@ -32987,27 +32990,27 @@ Partial Class Ventas ' Return File 'End Function - 'Private Function DescargarFactura(CveVenta As Integer, CveEmpresa As Integer, Optional GetBytes As Boolean = True) As Byte() - ' Dim Url = New Uri(String.Format("http://{0}:{1}/Compras/PopUpVerFactura.aspx?P={2}", HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port, Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1", CveVenta)))) - ' Dim File As Byte() = Nothing - ' Try - ' Using httpClient = New HttpClient() - ' httpClient.Timeout = New TimeSpan(0, 15, 0) - ' Using request = New HttpRequestMessage(HttpMethod.Get, Url) - ' request.Headers.Add("ADSToken", Encripta(String.Format("CVEEMPRESA={0}&TICKS={1}&CveUsuario=100", CveEmpresa, DateTime.UtcNow.Ticks))) - ' Dim response = httpClient.SendAsync(request).Result - ' If GetBytes AndAlso response.StatusCode = Net.HttpStatusCode.OK Then - ' File = response.Content.ReadAsByteArrayAsync().Result - ' End If - ' End Using - ' End Using - ' Catch ex As Exception - ' File = Nothing - ' OnError("Ocurrió un error al descargar la factura", ex) - ' End Try + Private Function DescargarFactura(CveVenta As Integer, CveEmpresa As Integer, CveUsuarioCreo As Integer, Optional GetBytes As Boolean = True) As Byte() + Dim Url = New Uri(String.Format("{0}://{1}:{2}/Compras/PopUpVerFactura.aspx?P={3}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port, Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1", CveVenta)))) + Dim File As Byte() = Nothing + Try + Using httpClient = New HttpClient() + httpClient.Timeout = New TimeSpan(0, 2, 0) + Using request = New HttpRequestMessage(HttpMethod.Get, Url) + request.Headers.Add("ADSToken", Encripta(String.Format("CVEEMPRESA={0}&TICKS={1}&CveUsuario={2}", CveEmpresa, DateTime.UtcNow.Ticks, CveUsuarioCreo))) + Dim response = httpClient.SendAsync(request).Result + If GetBytes AndAlso response.StatusCode = Net.HttpStatusCode.OK Then + File = response.Content.ReadAsByteArrayAsync().Result + End If + End Using + End Using + Catch ex As Exception + File = Nothing + OnError("Ocurrió un error al descargar la factura", ex) + End Try - ' Return File - 'End Function + Return File + End Function Protected Sub LnkGenerarOC_Click(sender As Object, e As EventArgs) Response.Redirect($"~/OC/OC.aspx?CveCotizacion={Me.CveVenta}&Tipo=OC") End Sub From f1568d1751d109c668e61a15e3a6abc579666b2b Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Thu, 19 May 2022 13:49:39 -0700 Subject: [PATCH 02/25] Decimales en RFV para aplicar usados en RNC --- Ventas/Ventas.aspx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 573a49386..94e7c3304 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -6896,8 +6896,8 @@ - - + + @@ -7000,8 +7000,8 @@ - - + + @@ -7680,8 +7680,8 @@ - - + + @@ -7780,8 +7780,8 @@ - - + + From 5a85db6a213bf049918c024c63961931be60ae92 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 25 May 2022 12:36:35 -0700 Subject: [PATCH 03/25] Movimientos de garantia en cancelacion de factura y servicio a domicilio --- App_Code/Modelos.vb | 134 +++++++++++++++++++++++++++++++------------- 1 file changed, 94 insertions(+), 40 deletions(-) diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index bac3058ee..0c6090932 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -3826,46 +3826,9 @@ Namespace Modelos OcurrioError = True End If - ' COMIENZA: GARANTIAS - Dim CveAlmacenGarantia As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveTipoAlmacen:=6).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto={factura.CveSubProyecto}").ToEntero() - Dim DtGarantias As DataTable = Nothing - - If ObjAcum.GetGarantiasDetalle(factura.CveVenta) Then - DtGarantias = ObjAcum.DtResultados.Copy() - End If - - If DtGarantias IsNot Nothing AndAlso DtGarantias.Rows.Count > 0 AndAlso CveAlmacenGarantia > 0 Then - Dim TotalGarantia As Decimal = 0 - Dim CveMovimientoGarantia = ObjInventario.AddMovimiento(CveAlmacenGarantia, 2, 1, factura.Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, factura.CveVenta, -1, -1, Observaciones:="", Guia:="", Modulo:="Modelos/SDGA") - Dim FolioGarantia = ObjInventario.Folio - - For Each RowGarantia As DataRow In DtGarantias.Rows - Dim CvePS = RowGarantia("CvePS").ToString().ToEntero() - Dim CveTamaño As Integer = RowGarantia("CveTamaño").ToString().ToEntero() - Dim CveUM As Integer = RowGarantia("CveUnidadMedida").ToString().ToEntero() - Dim PU As Decimal = RowGarantia("Importe").ToString().ToDecimal() ' / RowGarantia("Cantidad").ToString().ToDouble() - Dim Serie As String = RowGarantia("Comprobante").ToString - - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoGarantia, RowGarantia("Cantidad").ToString().ToDouble(), CveUM, CvePS, PU, Serie:=Serie, CveVentaDetalle:=RowGarantia("CveVentaDetalle").ToString.ToEntero) Then - OcurrioError = True - Exit For - End If - TotalGarantia += (RowGarantia("Cantidad").ToString().ToDecimal() * PU) - Next - - Dim CvePrePolizaTraspaso As Integer = ObjConta.AddPrePolizas("EA/Gar", 53, 0, 0, 1, factura.Fecha, "Entrada Garantía", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - If CvePrePolizaTraspaso > 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTraspaso, False, TotalGarantia, "MOVIMIENTO DE GARANTIA", 68, "MOVIMIENTO DE GARANTIA", factura.Fecha, -1, -1, CveMovimientoAlmacen:=CveMovimientoGarantia, Contabilizable:=True, ImporteMX:=TotalGarantia) Then - OcurrioError = True - End If - - If Not OcurrioError AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTraspaso, True, TotalGarantia, "MOVIMIENTO DE GARANTIA", 331, "MOVIMIENTO DE GARANTIA", factura.Fecha, -1, -1, CveMovimientoAlmacen:=CveMovimientoGarantia, Contabilizable:=True, ImporteMX:=TotalGarantia) Then - OcurrioError = True - End If - Else - OcurrioError = True - End If - + ' GENERA EL MOVIMIENTO DE GARANTIA SI TIENE + If Not GenerarMovimientoGarantia(14, "Entrada Garantía", Now, factura, ObjAcum, ObjInventario, ObjConta) Then + OcurrioError = True End If Else @@ -3902,6 +3865,75 @@ Namespace Modelos Return OcurrioError End Function + + Private Function GenerarMovimientoGarantia(CveConceptoMovimiento As Integer, ConceptoPoliza As String, FechaMovimiento As DateTime, factura As Factura, ByRef ObjAcum As ClsAcumuladores, ByRef ObjInventario As ClsInventarios, ObjConta As ClsContabilidad, Optional Modulo As String = "Modelos/SDGA") As Boolean + Dim OcurrioError As Boolean = False + Try + Dim CveAlmacenGarantia As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveTipoAlmacen:=6).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto={factura.CveSubProyecto}").ToEntero() + Dim DtGarantias As DataTable = Nothing + + If ObjAcum.GetGarantiasDetalle(factura.CveVenta) Then + DtGarantias = ObjAcum.DtResultados.Copy() + Else + OcurrioError = True + End If + + 'SI TIENE UNA GARANTIA, GENERAR EL MOVIMIENTO DE ALMACEN + If DtGarantias IsNot Nothing AndAlso DtGarantias.Rows.Count > 0 AndAlso CveAlmacenGarantia > 0 Then + Dim TotalGarantia As Decimal = 0 + Dim CveMovimientoGarantia = ObjInventario.AddMovimiento(CveAlmacenGarantia, CveConceptoMovimiento, 1, FechaMovimiento, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, factura.CveVenta, -1, -1, Observaciones:="", Guia:="", Modulo:=Modulo) + Dim FolioGarantia = ObjInventario.Folio + + For Each RowGarantia As DataRow In DtGarantias.Rows + Dim CvePS = RowGarantia("CvePS").ToString().ToEntero() + Dim CveTamaño As Integer = RowGarantia("CveTamaño").ToString().ToEntero() + Dim CveUM As Integer = RowGarantia("CveUnidadMedida").ToString().ToEntero() + Dim PU As Decimal = RowGarantia("Importe").ToString().ToDecimal() ' / RowGarantia("Cantidad").ToString().ToDouble() + Dim Serie As String = RowGarantia("Comprobante").ToString + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoGarantia, RowGarantia("Cantidad").ToString().ToDouble(), CveUM, CvePS, PU, Serie:=Serie, CveVentaDetalle:=RowGarantia("CveVentaDetalle").ToString.ToEntero) Then + OcurrioError = True + Exit For + End If + Next + + If Not OcurrioError Then + If ObjInventario.GetMovimientosDetalle(CveMovimientoGarantia, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then + TotalGarantia = ObjInventario.DtResultados.SUMD("Total").RoundSQL + Else + OcurrioError = True + End If + End If + + If Not OcurrioError Then + Dim CvePrePolizaGarantia As Integer = ObjConta.AddPrePolizas("EA/Gar", 53, 0, 0, 1, FechaMovimiento, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If CvePrePolizaGarantia > 0 Then + Dim TipoMovto As Boolean = False + If CveConceptoMovimiento = 15 Then + TipoMovto = True + End If + + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaGarantia, TipoMovto, TotalGarantia, "MOVIMIENTO DE GARANTIA", 68, "MOVIMIENTO DE GARANTIA", factura.Fecha, -1, -1, CveMovimientoAlmacen:=CveMovimientoGarantia, Contabilizable:=True, ImporteMX:=TotalGarantia) Then + OcurrioError = True + End If + + If Not OcurrioError AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePolizaGarantia, Not TipoMovto, TotalGarantia, "MOVIMIENTO DE GARANTIA", 331, "MOVIMIENTO DE GARANTIA", factura.Fecha, -1, -1, CveMovimientoAlmacen:=CveMovimientoGarantia, Contabilizable:=True, ImporteMX:=TotalGarantia) Then + OcurrioError = True + End If + Else + OcurrioError = True + End If + End If + + + End If + Catch ex As Exception + OcurrioError = True + OnError("Ocurrió un error al generar el movimiento de garantía", ex) + End Try + + Return Not OcurrioError + End Function Private Function CuadrarFacturaMovimientos(MovDetalle As DataTable) As DataTable Dim MovDTCuadrados As New DataTable MovDTCuadrados = MovDetalle.Clone @@ -5540,6 +5572,21 @@ Namespace Modelos End If + 'CANCELAR MOVIMIENTOS DE GARANTIA SI TIENE + If Not ErrorCancelar AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + If Not GenerarMovimientoGarantia(15, "Salida Garantía", Now, ObjRemision, ObjAcum, ObjInventario, ObjConta) Then + ErrorCancelar = True + End If + End If + + 'CANCELA LOS FOLIOS DE GARANTIA + If Not ErrorCancelar Then + If Not ObjAcum.UpdateGarantiaCancelacion(ObjRemision.CveVenta) Then + ErrorCancelar = True + MensajeError = "Ocurrió un error al actualizar la garantía" + End If + End If + If DtDevRemision IsNot Nothing Then DtDevRemision.Dispose() End If @@ -5629,6 +5676,13 @@ Namespace Modelos End If End If + 'CANCELAR MOVIMIENTOS DE GARANTIA SI TIENE + If Not ErrorCancelar AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + If Not GenerarMovimientoGarantia(15, "Salida Garantía", Now, ObjFactura, ObjAcum, ObjInventario, ObjConta) Then + ErrorCancelar = True + End If + End If + End If 'VERIFICAR MOVIMIENTOS DE APARTADOS From b661cf5822aeedd52b2448d9f7120cecda59f9db Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 25 May 2022 12:38:48 -0700 Subject: [PATCH 04/25] E140. Considerar cantidad en descuento de lubricantes --- Ventas/PV.aspx.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ventas/PV.aspx.vb b/Ventas/PV.aspx.vb index dd24d323b..94d46ff08 100644 --- a/Ventas/PV.aspx.vb +++ b/Ventas/PV.aspx.vb @@ -4393,7 +4393,7 @@ Partial Class PV End If Else If DrPS("CveClasificacion").ToString.ToEntero.Contiene(20516, 20515) Then - Descuento = PU * ClasificacionesDescuentos(DrPS("CveClasificacion").ToString.ToEntero) + Descuento = ((Cantidad * PU) * ClasificacionesDescuentos(DrPS("CveClasificacion").ToString.ToEntero)).RoundSQL(2) End If End If From 37166a80a0baa3912723254c81d02cf58b457484 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 25 May 2022 12:41:27 -0700 Subject: [PATCH 05/25] Validacion de aplicacion de anticipos y pagos de contado, no validar movimiento de almacen al refacturar. --- Ventas/Ventas.aspx.vb | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 4eb92796f..c1fe6f050 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -5322,6 +5322,11 @@ Partial Class Ventas BtnsFacturar.Visible = True End If + 'VERIFICA SI YA SE FACTURO COMPLETAMENTE + If TmpDT.SUM("CantidadFacturadaRem") = TmpDT.SUM("Cantidad") Then + BtnsFacturar.Visible = False + End If + 'VERIFICA SI TIENE USADOS O GARANTIAS PENDIENTES If BtnsFacturar.Visible Then If (Not EsGarantia AndAlso (DtUsadosPendientes IsNot Nothing AndAlso DtUsadosPendientes.Rows.Count > 0)) Then @@ -14387,15 +14392,16 @@ Partial Class Ventas End If - End If - - Dim DebeGenerarMovimiento As Boolean = TmpDT.COUNT("CvePS", "CveTipoPS = 2") > 0 - 'VERIFICA QUE SE REALIZO EL MOVIMIENTO DE ALMACEN - If DebeGenerarMovimiento AndAlso UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso UsuarioActual.Empresa.Funcionalidad(567) = "1" AndAlso factura.TipoDocto.Contiene("Ing", "Rem") Then - If Not (ObjInventario.GetInv_Mov(factura.CveVenta, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0) Then - OcurrioError = True - ErrorList.Add("Ocurrió un error al verificar inventario.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") + 'DEBE GENERAR MOVIMIENTO SI SE FACTURAON PRODUCTOS, O NO SE REALIZA UNA REFACTURACION + Dim DebeGenerarMovimiento As Boolean = TmpDT.COUNT("CvePS", "CveTipoPS = 2") > 0 AndAlso (NuevaFactura <> 1) + 'VERIFICA QUE SE REALIZO EL MOVIMIENTO DE ALMACEN + If Not OcurrioError AndAlso DebeGenerarMovimiento AndAlso UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso UsuarioActual.Empresa.Funcionalidad(567) = "1" AndAlso factura.TipoDocto.Contiene("Ing", "Rem") Then + If Not (ObjInventario.GetInv_Mov(factura.CveVenta, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0) Then + OcurrioError = True + ErrorList.Add("Ocurrió un error al verificar inventario.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") + End If End If + End If End If @@ -22237,10 +22243,10 @@ Partial Class Ventas Return Retorno End If - If Not PermiteCredito AndAlso TienePagos AndAlso TxtTotal.Text.ToDecimal > 0 Then + If (Not PermiteCredito OrElse RBLPago.SelectedValue = "2") AndAlso TienePagos AndAlso TxtTotal.Text.ToDecimal > 0 Then Dim TotalPago As Decimal = DtPagos.SUM("Importe").ToDecimal() + AmortizacionNC - If TotalPago < TxtTotal.Text.ToDecimal Then + If TotalPago <> TxtTotal.Text.ToDecimal Then If MostrarAlertas Then Alert("La suma de los pagos debe ser igual al total de la venta.", TipoMensaje.MsgAdvertencia) End If @@ -22315,7 +22321,7 @@ Partial Class Ventas If Not PermiteCredito AndAlso TienePagos AndAlso TxtTotal.Text.ToDecimal > 0 Then Dim TotalPago As Decimal = DtPagos.SUM("Importe").ToDecimal() + AmortizacionNC - If TotalPago < TxtTotal.Text.ToDecimal Then + If TotalPago <> TxtTotal.Text.ToDecimal Then If MostrarAlertas Then Alert("La suma de los pagos debe ser igual al total de la venta.", TipoMensaje.MsgAdvertencia) End If From e6dc55a47886f56a67ae7031577202938c3ee2a7 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 25 May 2022 12:43:00 -0700 Subject: [PATCH 06/25] E141. Correcion de descarga de pdf por QR --- Ashx/E141.ashx | 888 ++++++++++++++++++++++++------------------------- 1 file changed, 444 insertions(+), 444 deletions(-) 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() From 367a3a41259e1444e8f142a1fcbf452f96127a84 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 25 May 2022 12:43:37 -0700 Subject: [PATCH 07/25] E140. Importe inicial de caja en reporte de cortes --- Bancos/RepCortes.aspx | 13 +++++++++++-- Bancos/RepCortes.aspx.vb | 34 ++++++++++++++++++++++++---------- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/Bancos/RepCortes.aspx b/Bancos/RepCortes.aspx index 3ccba8aaf..16ad5bcc7 100644 --- a/Bancos/RepCortes.aspx +++ b/Bancos/RepCortes.aspx @@ -231,7 +231,7 @@ - + @@ -240,7 +240,16 @@ - + + + + + + + + + + diff --git a/Bancos/RepCortes.aspx.vb b/Bancos/RepCortes.aspx.vb index e47ba73e7..bf069b542 100644 --- a/Bancos/RepCortes.aspx.vb +++ b/Bancos/RepCortes.aspx.vb @@ -8,10 +8,17 @@ Imports System.Collections.Generic Partial Class Bancos_RepCortes Inherits ClsPaginas - Private Shared missing As Object = System.Reflection.Missing.Value - + Private Shared missing As Object = System.Reflection.Missing.Value + #Region "PROPIEDADES" - + Private Property DtCortes As DataTable + Get + Return CType(ViewState("DtCortes"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtCortes") = value + End Set + End Property Private Property DtCortesVentasResumen As DataTable Get Return CType(ViewState("DtCortesVentasResumen"), DataTable) @@ -67,16 +74,20 @@ Partial Class Bancos_RepCortes #Region " C A R G A - D A T O S " - Public Sub CargaDatos() - Dim ObjPuntoVenta As New ClsPuntoVenta + Public Sub CargaDatos() + Dim FechaI As Date = If(txtFechaVI.Text <> "", txtFechaVI.Text.ToDate, MinFecha) - Dim FechaF As Date = If(txtFechaVF.Text <> "", txtFechaVF.Text.ToDate, MaxFecha) + Dim FechaF As Date = If(txtFechaVF.Text <> "", txtFechaVF.Text.ToDate, MaxFecha) + + Dim ObjPuntoVenta As New ClsPuntoVenta If ObjPuntoVenta.GetVta_ReporteCortes(UsuarioActual.CveEmpresa, FechaI, FechaF, DdlSubProyectos.SelectedValue.ToEntero) Then - GvDatos.DataSource = ObjPuntoVenta.DtResultados - GvDatos.DataBind() - UPDatos.Update() + DtCortes = ObjPuntoVenta.DtResultados.Copy() End If - ObjPuntoVenta.Dispose() + ObjPuntoVenta.Dispose() + + GvDatos.DataSource = DtCortes + GvDatos.DataBind() + UPDatos.Update() End Sub #End Region @@ -85,6 +96,9 @@ Partial Class Bancos_RepCortes If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.DBCampo("CveCorte").ToString = "" Then e.Row.CssClass = "SubTotales2" + If DtCortes IsNot Nothing Then + e.Row.FCLiteral("LtlImporteInicial").Text = DtCortes.SUMD("ImporteInicial").FormatoNumero(2) + End If End If End If End Sub From e4510c33f6dbb6e241e2b171ccaef862e6c3914d Mon Sep 17 00:00:00 2001 From: rrene Date: Thu, 26 May 2022 12:59:46 -0700 Subject: [PATCH 08/25] =?UTF-8?q?--=20cancelaci=C3=B3n,=20no=20se=20enviab?= =?UTF-8?q?a=20el=20concepto=20de=20porcentaje=20impuesto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Compras/Compras.aspx.vb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 8c901ce40..0ad0f2514 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -15281,7 +15281,10 @@ Partial Class Compras_Compras dr("CveVenta").ToString.ToEntero, dr("CveCompra").ToString.ToEntero, dr("CveSubProyecto").ToString.ToEntero, dr("CveCliente").ToString.ToEntero, dr("CveProveedor").ToString.ToEntero, dr("CvePersonal").ToString.ToEntero, If(cvemovimientoentrada > 0, cvemovimientoentrada, dr("CveMovimientoAlmacen").ToString.ToEntero), dr("CveActivoFijo").ToString.ToEntero, -1, -1, dr("CveCreditoDetalle").ToString.ToEntero, - ImporteMX:=dr("Importe").ToString.ToDecimal * -1, ImporteME:=dr("Importe").ToString.ToDecimal * -1, CveTipoGasto:=dr("CveTipoGasto").ToString.ToEntero, CveClasificacion:=dr("CveClasificacion").ToString.ToEntero, CveOCDetalle:=dr("CveOCDetalle").ToString.ToEntero) Then + ImporteMX:=dr("Importe").ToString.ToDecimal * -1, ImporteME:=dr("Importe").ToString.ToDecimal * -1, + CveTipoGasto:=dr("CveTipoGasto").ToString.ToEntero, CveClasificacion:=dr("CveClasificacion").ToString.ToEntero, + PorcentajeImpuesto:=dr("PorcentajeImpuesto").ToString.ToDecimal, + CveOCDetalle:=dr("CveOCDetalle").ToString.ToEntero) Then ErrorCancelar = True Exit For End If From 36a9e5f2d8f84a6c633ee2a39f10bb1c580cb3eb Mon Sep 17 00:00:00 2001 From: rrene Date: Thu, 26 May 2022 13:05:54 -0700 Subject: [PATCH 09/25] -- mejora en el % de descuento autorizado --- Sistemas/UsuarioDetalle.aspx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sistemas/UsuarioDetalle.aspx b/Sistemas/UsuarioDetalle.aspx index 21c0aadb7..296c3093e 100644 --- a/Sistemas/UsuarioDetalle.aspx +++ b/Sistemas/UsuarioDetalle.aspx @@ -1496,8 +1496,8 @@ Porcentaje Máximo: - - + + @@ -1505,7 +1505,7 @@ Días vencidos: - + From 367385d699d89a789d77dc27558481a52d7d0bea Mon Sep 17 00:00:00 2001 From: rrene Date: Thu, 26 May 2022 13:06:28 -0700 Subject: [PATCH 10/25] -- mejora en el nombrecomercial, preparativo para 4.0 --- Ventas/Clientes.aspx.vb | 2 +- Ventas/Ventas.aspx.vb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Ventas/Clientes.aspx.vb b/Ventas/Clientes.aspx.vb index fbe2b19e6..eac0461d1 100644 --- a/Ventas/Clientes.aspx.vb +++ b/Ventas/Clientes.aspx.vb @@ -1503,7 +1503,7 @@ Partial Class Clientes 'End If 'Campos para Modificación - LtlCliente.Text = ObjClientes.Nombre + LtlCliente.Text = ObjClientes.NombreComercial TxtNombre.Text = ObjClientes.Nombre TxtRegimenSociedad.Text = ObjClientes.RegimenSociedad TxtNombreComercial.Text = ObjClientes.NombreComercial diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 9a94df0f8..13e3eeff7 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -5963,7 +5963,7 @@ Partial Class Ventas If ObjCliente.DtResultados.Rows.Count > 0 Then TxtCodigo.Text = ObjCliente.Codigo DdlFormaEntrega.SelectedValueExist(ObjCliente.DtResultados(0)("CveCondicionEntrega").ToString()) - LblCliente.Text = String.Format("{1}", CveCliente, ObjCliente.Nombre) + LblCliente.Text = String.Format("{1}", CveCliente, ObjCliente.NombreComercial) ViewState("NombreCliente") = ObjCliente.Nombre LtlCliente.Text = ObjCliente.Nombre ViewState("RequiereOC") = ObjCliente.RequiereOC From 819a5e0db07f6fc22eb858a3e6810cd39da0797a Mon Sep 17 00:00:00 2001 From: rrene Date: Thu, 26 May 2022 13:24:13 -0700 Subject: [PATCH 11/25] -- mejora en acomodo de encabezados --- Bancos/RepCxCCliente.aspx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Bancos/RepCxCCliente.aspx b/Bancos/RepCxCCliente.aspx index 2e3cf4dae..283a6e5ba 100644 --- a/Bancos/RepCxCCliente.aspx +++ b/Bancos/RepCxCCliente.aspx @@ -156,7 +156,7 @@ - + @@ -164,8 +164,8 @@ - - + + From 6440299038e9d1db9c0047cd06e93d08ed12e148 Mon Sep 17 00:00:00 2001 From: rrene Date: Thu, 26 May 2022 13:47:57 -0700 Subject: [PATCH 12/25] -- mejora en manejo de liga para prepoliza --- Contabilidad/PopUpAuxiliar.aspx.vb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Contabilidad/PopUpAuxiliar.aspx.vb b/Contabilidad/PopUpAuxiliar.aspx.vb index d7547cfe2..6f0951149 100644 --- a/Contabilidad/PopUpAuxiliar.aspx.vb +++ b/Contabilidad/PopUpAuxiliar.aspx.vb @@ -268,7 +268,7 @@ Partial Class PopUpAuxiliar End If If Not TieneError Then - If IdPoliza > 0 Then + If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso IdPoliza > 0 Then If UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad Then ObjContPaq = New ClsContPAQi(UsuarioActual.Empresa) ObjContPaq.IniciaTransacSQL() @@ -410,8 +410,9 @@ Partial Class PopUpAuxiliar RegistraScript(" $('#DivCancelar').modal('hide'); ") If UsuarioActual.Empresa.Funcionalidad(200) = "1" Then If ObjContabilidad.ContabilizarPrePoliza(CvePrePolizaNueva, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then - Str.AppendFormat("Ver Poliza", ObjContabilidad.ContaIdPoliza) - + If UsuarioActual.Empresa.TipoContabilidad = 2 Then + Str.AppendFormat("Ver Poliza", ObjContabilidad.ContaIdPoliza) + End If End If End If Alert(Str.ToString) @@ -420,8 +421,6 @@ Partial Class PopUpAuxiliar End If - - ObjContabilidad.Dispose() CargaDatos() From 25d58fb0d1463fd72c51adca678700313600c5b0 Mon Sep 17 00:00:00 2001 From: rrene Date: Fri, 27 May 2022 13:32:27 -0700 Subject: [PATCH 13/25] -- nombre comercial --- Ventas/PopUpBuscarClientes.aspx.vb | 2 +- Ventas/PopUpBuscarFolio.aspx.vb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Ventas/PopUpBuscarClientes.aspx.vb b/Ventas/PopUpBuscarClientes.aspx.vb index a65d2da95..fa8690108 100644 --- a/Ventas/PopUpBuscarClientes.aspx.vb +++ b/Ventas/PopUpBuscarClientes.aspx.vb @@ -133,7 +133,7 @@ Partial Class PopUpBuscarClientes End If e.Row.FCLiteral("LtlCodigo").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("Codigo")) - e.Row.FCLiteral("LtlNombre").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("Nombre")) + e.Row.FCLiteral("LtlNombre").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("NombreComercial")) e.Row.FCLiteral("LtlRFC").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("RFC")) e.Row.FCLiteral("LtlDireccion").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("Direccion")) e.Row.FCLiteral("LtlCiudad").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("Ciudad")) diff --git a/Ventas/PopUpBuscarFolio.aspx.vb b/Ventas/PopUpBuscarFolio.aspx.vb index e30f76935..bdc26edb0 100644 --- a/Ventas/PopUpBuscarFolio.aspx.vb +++ b/Ventas/PopUpBuscarFolio.aspx.vb @@ -170,7 +170,7 @@ Partial Class PopUpBuscarFolio e.Row.FCLiteral("LtlTipo").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("TipoDocto")) e.Row.FCLiteral("LtlFolio").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("Folio")) e.Row.FCLiteral("LtlFecha").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("Fecha").ToDate.ToShortDateString) - e.Row.FCLiteral("LtlNombre").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("Nombre")) + e.Row.FCLiteral("LtlNombre").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("NombreComercial")) 'e.Row.FCLiteral("LtlSubTotal").Text = Liga & e.Row.DBCampo("SubTotal").FormatoNumero & " " e.Row.FCLiteral("LtlTotal").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("Total").FormatoNumero) e.Row.FCLiteral("LtlMon").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("Abreviatura")) From e997ed175de445aaabfd4c92eb442431b6d3ebb1 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Fri, 27 May 2022 19:20:52 -0700 Subject: [PATCH 14/25] Error al consultar precios masivamente. --- Ventas/ActualizarPrecios.aspx | 115 +++++++++++++++++++--------------- 1 file changed, 65 insertions(+), 50 deletions(-) diff --git a/Ventas/ActualizarPrecios.aspx b/Ventas/ActualizarPrecios.aspx index 20f8df15b..0a6afc9f3 100644 --- a/Ventas/ActualizarPrecios.aspx +++ b/Ventas/ActualizarPrecios.aspx @@ -178,10 +178,10 @@ - - + + <%-- - + --%> @@ -191,10 +191,10 @@ - - + +<%-- - + --%> @@ -239,7 +239,7 @@
- Seleccionar Todos + Seleccionar Todos
@@ -266,7 +266,7 @@ - + @@ -364,84 +364,99 @@
- From fcd459581b3d5bf52fd24cfb3ae410a693a7dc62 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Fri, 27 May 2022 19:21:37 -0700 Subject: [PATCH 15/25] Mercancias en carta porte --- App_Code/Modelos.vb | 2 + Ventas/Ventas.aspx | 1056 ++++++++++++++++++++++------------------- Ventas/Ventas.aspx.vb | 78 ++- 3 files changed, 651 insertions(+), 485 deletions(-) diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 0c6090932..781074ec6 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -6671,6 +6671,7 @@ Namespace Modelos Public Property SubProyecto As Modelos.SubProyectoModel Public Property DtDetalle As Data.DataTable + Public Property DtMercancias As Data.DataTable Public Property DtDetalleAC As Data.DataTable Public Property DtAjustes As Data.DataTable Public Property DtRecepcionUsados As Data.DataTable @@ -7220,6 +7221,7 @@ Namespace Modelos If Not DtRemisiones Is Nothing Then DtRemisiones.Dispose() : DtRemisiones = Nothing If Not DtRemisionesPS Is Nothing Then DtRemisionesPS.Dispose() : DtRemisionesPS = Nothing If Not DtVentasNC Is Nothing Then DtVentasNC.Dispose() : DtVentasNC = Nothing + If Not DtMercancias Is Nothing Then DtMercancias.Dispose() : DtMercancias = Nothing End If End If Me.disposedValue = True diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 94e7c3304..8fd0b3cd6 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -2445,244 +2445,73 @@
-
-
-
-
-
- - COMERCIO EXTERIOR -
-
-
-
-
- -
- -
-
-
- - -
-
- -
- - <%----%> -
- -
- - <%----%> -
-
-
- -
- - -
-
-
- -
- -
- -
- -
- <%-- -
-
--%> -
-
-
- - -
- -
Nombre:
- -
- -
- -
-
- -
Calle:
- -
- -
-
Núm.
-
- -
-
CP.
-
- -
-
-
-
Pais:
- -
- - -
- - -
Estado:
- -
- - -
- -
-
-
Municipio:
- -
- - -
- -
Colonia:
- -
- - -
- -
- -
- -
- -
-
-
-
-
- Convertir a unidad Aduana - - - - - - - - - - - - - - - - - <%-- - - - - - - - - - --%> - - - - - - - - - - - - -
-
-
-
+
+
+
+ + CARTA PORTE +
+
+
-
-
-
-
-
- - CARTA PORTE -
-
-
-
-
-
- -
-
-
-
- - -
- -
- -
+
+ +
+
+
+
+ + +
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+
+ + + + + +
-
-
- -
- -
+
+ +
+
+ + + + + +
-
-
- -
- -
-
-
-
- -
-
- - - - - - -
-
- -
-
- - - - - - -
-
-
-
+
+
+
+
+
@@ -2698,7 +2527,8 @@
-
+
+
@@ -2729,11 +2559,54 @@
- - +
+
+
+
+
+
+
+
+ + Mercancias +
+
+
+ +
+
+
+ +
+
+
+
+ + + + +   + + + + + + + + + + + +
+
+
+
+
+ + -
-
@@ -2741,79 +2614,140 @@ -
-
-
- - 7Eleven +
+
+
+
+
+
+
+ + FORD -
-
-
+
+
+
+
+
+ +
+ +
+
+
+
+ + + + + + + + + + + + + +
GSDB:   +
+ +
+
ASN :   +
+ +
+   + + +
+ + +
+
+
+
+
+
-
- -
-
+
+
+
+ + 7Eleven -
-
- - - - - - - - - - - - - - - - - -
Proveedor:  -
-
-
Folio:  -
- +
+
+
-
Tienda:  -
- -
- <%----%> -
Fecha:  -
- - - - - - - - +
+
-
+
+ +
+
+ + + + + + + + + + + + + + + + + +
Proveedor:  +
+ +
+
Folio:  +
+ +
+
Tienda:  +
+ +
+ <%----%> +
Fecha:  + +
+ + + + + + + + +
+
+
+
+
+
-
+
- FORD - + COMERCIO EXTERIOR
@@ -2821,40 +2755,161 @@
- +
-
-
- - - - - - - - - - - - - -
GSDB:   -
- +
+ + +
+
+ +
+ + <%----%>
-
ASN :   -
- + +
+ + <%----%>
-   - - -
- - -
-
+
+
+ +
+ + +
+
+
+ +
+ +
+ +
+ +
+ <%-- +
+
--%> +
+
+
+ + +
+ +
Nombre:
+ +
+ +
+ +
+
+ +
Calle:
+ +
+ +
+
Núm.
+
+ +
+
CP.
+
+ +
+
+
+
Pais:
+ +
+ + +
+ + +
Estado:
+ +
+ + +
+ +
+
+
Municipio:
+ +
+ + +
+ +
Colonia:
+ +
+ + +
+ +
+ +
+ +
+ +
+
+
+
+
+ Convertir a unidad Aduana + + + + + + + + + + + + + + + + + <%-- + + + + + + + + + --%> + + + + + + + + + + + + +
+
+ +
@@ -5889,6 +5944,43 @@
<%--FIN MODAL ADD PS --%> + <%--MODAL ADD PS --%> + + <%--FIN MODAL ADD PS --%> +