diff --git a/App_Code/ClsGPS.vb b/App_Code/ClsGPS.vb index 6e1ee8d05..622a9de14 100644 --- a/App_Code/ClsGPS.vb +++ b/App_Code/ClsGPS.vb @@ -4750,7 +4750,7 @@ Public Class ClsGPS #End Region #Region "T R A Y E C T O S" - Public Function AddTrayecto(Trayecto As String, Fecha As DateTime, Folio As String, CveDispositivo As Integer, CveCliente As Integer) As Integer + Public Function AddTrayecto(Trayecto As String, Fecha As DateTime, Folio As String, CveDispositivo As Integer, CveCliente As Integer, Optional EnviarNotificacion As Boolean = False, Optional CorreosNotificacion As String = "", Optional Intervalo As Integer = 0, Optional EnviarLiga As Boolean = False) As Integer Dim retorno As Integer = 0 DataAdapter("PA_GPS_TrayectosAdd", CommandType.StoredProcedure) With SqlAdapter.SelectCommand.Parameters @@ -4759,6 +4759,10 @@ Public Class ClsGPS .Add("@Folio", SqlDbType.VarChar).Value = Folio .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@EnviarNotificacion", SqlDbType.Bit).Value = EnviarNotificacion + .Add("@CorreosNotificacion", SqlDbType.VarChar).Value = CorreosNotificacion + .Add("@Intervalo", SqlDbType.Int).Value = Intervalo + .Add("@EnviarLiga", SqlDbType.Bit).Value = EnviarLiga .Add("@CveTrayecto", SqlDbType.Int).Direction = ParameterDirection.Output End With diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index fecdfa152..eeffb9d57 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -541,7 +541,7 @@ Namespace Modelos End Class - Public Function EmitirFactura(Optional Timbrar As Boolean = True) As MMensajeFactura + Public Function EmitirFactura(Optional Timbrar As Boolean = True, Optional Trasac As SqlClient.SqlTransaction = Nothing, Optional ObjContPaqTransac As ClsContPAQi = Nothing) As MMensajeFactura Dim Retorno As New MMensajeFactura() If Me.Version = "3.3" AndAlso Not Me.TipoDocto.Contiene("Ped", "PeC") Then @@ -586,9 +586,16 @@ Namespace Modelos End If If Me.CveCliente > 0 Or Me.CveEmpresaCRM > 0 Then - If DtDetalle.Rows.Count > 0 Then + If DtDetalle.Rows.Count > 0 Then + + Dim ObjVentas As ClsVentas = Nothing + If Trasac IsNot Nothing Then + ObjVentas = New ClsVentas(Trasac) + Else + ObjVentas = New ClsVentas() + ObjVentas.IniciaTransacSQL() + End If - Dim ObjVentas As New ClsVentas() Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL()) Dim ObjInventario As New ClsInventarios(ObjVentas.IniciaTransacSQL()) Dim ObjContr As New ClsContratos(ObjVentas.IniciaTransacSQL()) @@ -604,10 +611,15 @@ Namespace Modelos Try 'CONTABILIDAD AUTOMATICA Y AC - If UsuarioActual.Empresa.UsaAC OrElse UsuarioActual.Empresa.Funcionalidad(200) = "1" Then - ObjContPaq = New ClsContPAQi(UsuarioActual.Empresa) + If ObjContPaqTransac IsNot Nothing Then + ObjContPaq = ObjContPaqTransac + Else + If UsuarioActual.Empresa.UsaAC OrElse UsuarioActual.Empresa.Funcionalidad(200) = "1" Then + ObjContPaq = New ClsContPAQi(UsuarioActual.Empresa) + End If End If + 'GUARDA VENTA Dim TieneAnticipo As Boolean = False Dim CveAnticipoPadre As Integer = 0 ' vinculación con anticipo @@ -787,9 +799,15 @@ Namespace Modelos End If End If - If Me.CveVenta > 0 AndAlso ErrorList.Count = 0 AndAlso (SeGuardoPrePoliza Or Me.TipoDocto.Contiene("Ped", "Cot", "DPe", "PeC", "PA", "Pd2")) Then - ObjVentas.Commit() - If ObjContPaq IsNot Nothing Then ObjContPaq.Commit() + If Me.CveVenta > 0 AndAlso ErrorList.Count = 0 AndAlso (SeGuardoPrePoliza Or Me.TipoDocto.Contiene("Ped", "Cot", "DPe", "PeC", "PA", "Pd2")) Then + + If Trasac Is Nothing Then + ObjVentas.Commit() + End If + If ObjContPaqTransac Is Nothing Then + If ObjContPaq IsNot Nothing Then ObjContPaq.Commit() + End If + Try If Not String.IsNullOrEmpty(DirectorioServidor) Then Dim DirectoriArchivoXML As String = System.IO.Path.Combine(DirectorioServidor, "Empresas", UsuarioActual.CveEmpresa.ToString, Me.TipoDocto) @@ -986,42 +1004,61 @@ Namespace Modelos Retorno.Mensajes = ListaMensajes End Try Else - ObjVentas.RollBack() - If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack() + If Trasac Is Nothing Then + ObjVentas.RollBack() + End If + If ObjContPaqTransac Is Nothing Then + If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack() + End If Retorno.Mensajes = ErrorList Retorno.TieneError = True End If Else - ObjVentas.RollBack() - If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack() + If Trasac Is Nothing Then + ObjVentas.RollBack() + End If + + If ObjContPaqTransac Is Nothing Then + If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack() + End If + ErrorList.Add("Ocurrió un error al procesar los datos. Por favor rectifique y vuelta a intentar.") Retorno.Mensajes = ErrorList Retorno.TieneError = True End If Catch ex As Exception Me.ErrorList.Add(ex.ToString()) - ObjVentas.RollBack() - If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack() + + If Trasac Is Nothing Then + ObjVentas.RollBack() + End If + If ObjContPaqTransac Is Nothing Then + If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack() + End If + Retorno.Mensajes = ErrorList Retorno.TieneError = True Finally - ObjVentas.Dispose() - ObjConta.Dispose() - ObjInventario.Dispose() - ObjCGame.Dispose() - ObjContr.Dispose() - ObjDocCliente.Dispose() - ObjClientes.Dispose() - ObjAcum.Dispose() - If ObjContPaq IsNot Nothing Then ObjContPaq.Dispose() + If Trasac Is Nothing Then + ObjVentas.Dispose() + ObjConta.Dispose() + ObjInventario.Dispose() + ObjCGame.Dispose() + ObjContr.Dispose() + ObjDocCliente.Dispose() + ObjClientes.Dispose() + ObjAcum.Dispose() + End If + If ObjContPaqTransac Is Nothing Then + If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack() + End If End Try Else Retorno.Mensajes.Add("No se han agregado productos/servicios") End If End If - Return Retorno End Function @@ -5086,7 +5123,8 @@ Namespace Modelos Public Property CveAlmacenRecepcionUsados As Integer = -1 Public Property CveDireccionEnvio As Integer Public Property RefacturacionGeneroNC As Boolean = False - Public Property Pagado As Decimal + Public Property Pagado As Decimal + Public Property DescuentoProntoPago As Decimal 'Public Property Sucursal As SucursalModel Public Property SubProyecto As Modelos.SubProyectoModel diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index aefa1347e..c312c7dee 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -13647,19 +13647,32 @@ Partial Class Compras_Compras End Sub Private Sub VinculaDevolucion() - 'Borramos el TmpDT - TmpDT.Clear() + 'LIMPIAR PARTIDAS DE LA COMPRA PARA AGREGAR NUEVAS + TmpDT.Clear() + + Dim SubTotalCompra As Decimal = TxtSubTotal.Text.ToDecimal() + Dim TotalCompra As Decimal = TxtTotal.Text.ToDecimal() + Dim IVACompra As Decimal = TxtIVA.Text.ToDecimal() + Dim IEPSCompra As Decimal = TxtIEPS.Text.ToDecimal() + Dim RetIVACompra As Decimal = TxtRetIVA.Text.ToDecimal() + Dim RetISRCompra As Decimal = TxtRetISR.Text.ToDecimal() + + 'Dim TotalCalculable As Decimal = TotalCompra - IEPSCompra + RetIVACompra + RetISRCompra + + Dim IVAPorcentajeCompra As Decimal = Math.Round((IVACompra / SubTotalCompra), 2) 'Iteramos el GridView de la OC For Each gvr As GridViewRow In GVDevolucion.Rows - If gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Then - + If gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Then + + Dim CvePS As Integer = gvr.DataKey("CvePS").ToString.ToEntero + Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).Rows(0) + Dim Cantidad As Decimal = gvr.FCTextBox("TxtCantidad").Text.ToDecimal Dim CveUM As Integer = gvr.DataKey("CveUM").ToString.ToEntero Dim UM As String = gvr.DataKey("UM").ToString Dim CveClasificacion As Integer = gvr.DataKey("CveClasificacion").ToString.ToEntero Dim Clasificacion As String = gvr.DataKey("Clasificacion").ToString - Dim CvePS As Integer = gvr.DataKey("CvePS").ToString.ToEntero Dim PS As String = gvr.DataKey("PS").ToString Dim CveTipoPS As Integer = gvr.DataKey("CveTipoPS").ToString.ToEntero Dim CveSubProyectoContrato As String = "-1" @@ -13669,7 +13682,7 @@ Partial Class Compras_Compras Dim Obs As String = "" Dim PU As Decimal = gvr.DataKey("PU").ToString.ToDecimal Dim Total As Decimal = gvr.FCTextBox("TxtTotalDevolucion").Text.ToDecimal - Dim IVA As Decimal = 0 + Dim IVA As Decimal = IVAPorcentajeCompra 'Math.Round(Total * IVAPorcentajeCompra, 2) Dim Descuento As Decimal = 0 AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, 0, 0, 0, 0, Descuento, -1, False) @@ -17540,15 +17553,17 @@ Partial Class Compras_Compras TmpDT.Rows(HdnAliasInd.Value.ToEntero)("Obs") = TxtPSAlias.Text.Trim 'busco si el producto está en otros renglones QUE NO LO TENGAN ASIGNADO, LO VINCULE - For Each drt As DataRow In TmpDT.Select($"PS ='{TxtPSAlias.Text.Trim}' and ISNULL(CvePS,0) = 0") - drt("CvePS") = CvePS - drt("PS") = tPS - drt("CveUM") = DdlUnidadAlias.SelectedValue.ToEntero - drt("UM") = DdlUnidadAlias.SelectedItem.Text - drt("CveClasificacion") = HdnPSAliasCveClasificacion.Value.ToEntero - drt("Clasificacion") = HdnPSAliasClasificacion.Value - drt("Obs") = TxtPSAlias.Text.Trim - Next + If UsuarioActual.CveEmpresa <> 141 Then + For Each drt As DataRow In TmpDT.Select($"PS ='{TxtPSAlias.Text.Trim}' and ISNULL(CvePS,0) = 0") + drt("CvePS") = CvePS + drt("PS") = tPS + drt("CveUM") = DdlUnidadAlias.SelectedValue.ToEntero + drt("UM") = DdlUnidadAlias.SelectedItem.Text + drt("CveClasificacion") = HdnPSAliasCveClasificacion.Value.ToEntero + drt("Clasificacion") = HdnPSAliasClasificacion.Value + drt("Obs") = TxtPSAlias.Text.Trim + Next + End If TmpDT.AcceptChanges() diff --git a/Empresas/141/Formatos/Cotizacion.rdlc b/Empresas/141/Formatos/Cotizacion.rdlc index b27d690f7..f3e160397 100644 --- a/Empresas/141/Formatos/Cotizacion.rdlc +++ b/Empresas/141/Formatos/Cotizacion.rdlc @@ -2621,7 +2621,7 @@ - IVA (16%): + IVA + + + + + + + +
+ +
+ + + + + + + + + + diff --git a/GPS/RastreoTrayectos.aspx.vb b/GPS/RastreoTrayectos.aspx.vb new file mode 100644 index 000000000..46c849a09 --- /dev/null +++ b/GPS/RastreoTrayectos.aspx.vb @@ -0,0 +1,343 @@ +Option Strict On +Option Explicit On + +Imports System.Data +Imports System.IO +Imports System.Net +Imports Extensiones +Imports Microsoft.Reporting.WebForms +Imports Newtonsoft.Json.Linq +Imports System.Linq + +Partial Class GPS_RastreoTrayectos + Inherits Page + +#Region "P R O P I E D A D E S" + Private Property TrazarLineaContinuo As Boolean + Get + Return CType(ViewState("TrazarLineaContinuo"), Boolean) + End Get + Set(value As Boolean) + ViewState("TrazarLineaContinuo") = value + End Set + End Property + Private Property CveTrayecto As Integer + Get + Return IfNull(ViewState("CveTrayecto"), -1, ViewState("CveTrayecto").ToString().ToEntero()).ToString().ToEntero() + End Get + Set(value As Integer) + ViewState("CveTrayecto") = value + End Set + End Property + Private Property CveDispositivo As Integer + Get + Return IfNull(ViewState("CveDispositivo"), -1, ViewState("CveDispositivo").ToString().ToEntero()).ToString().ToEntero() + End Get + Set(value As Integer) + ViewState("CveDispositivo") = value + End Set + End Property + Private Property CveCliente As Integer + Get + Return IfNull(ViewState("CveCliente"), -1, ViewState("CveCliente").ToString().ToEntero()).ToString().ToEntero() + End Get + Set(value As Integer) + ViewState("CveCliente") = value + End Set + End Property + Private Property DtCoordenadasContinuas As DataTable + Get + Return CType(ViewState("DtCoordenadasContinuas"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtCoordenadasContinuas") = value + End Set + End Property + Private Property DtPosiciones As DataTable + Get + Return CType(ViewState("DtPosiciones"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtPosiciones") = value + End Set + End Property + + Property GlobalDTDispositivos(CveCliente As Integer) As DataTable + Get + Dim Str As StringBuilder = New StringBuilder() + + If CveCliente <> -1 Then Str.AppendFormat(" {0} CveCliente = {1}", If(Str.Length > 0, "AND", ""), CveCliente) + + + If CveCliente <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTDispositivos"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTDispositivos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTDispositivos = DirectCast(HttpContext.Current.Application("GlobalDTDispositivos"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTDispositivos") = value + End Set + End Property +#End Region + + Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load + If Not Page.IsPostBack Then + RegistraScript("$('#SideNav').click();initMap();") + Me.CveTrayecto = 97 + + CreaDTPosiciones() + CargaDatos() + RastrearEquipos() + CargaTabla() + End If + End Sub + Private Sub CreaDTPosiciones() + DtPosiciones = Nothing + + Dim dt As New DataTable + dt.Columns.Add("CveDispositivo", Type.GetType("System.Int32")) + dt.Columns.Add("Vehiculo", Type.GetType("System.String")) + dt.Columns.Add("Fecha", Type.GetType("System.String")) + dt.Columns.Add("Evento", Type.GetType("System.String")) + dt.Columns.Add("TiempoDetenido", Type.GetType("System.Double")) + dt.Columns.Add("Velocidad", Type.GetType("System.Double")) + dt.Columns.Add("Posicion", Type.GetType("System.String")) + dt.Columns.Add("KMRecorridos", Type.GetType("System.Double")) + dt.Columns.Add("Icono", Type.GetType("System.String")) + + DtPosiciones = dt + End Sub + Private Sub CreaDTCoordenadas() + + Dim dt As New DataTable + dt.Columns.Add("CveDispositivo", Type.GetType("System.Int32")) + dt.Columns.Add("Coord", Type.GetType("System.String")) + + DtCoordenadasContinuas = dt + End Sub + Private Sub CargaDatos() + Using ObjGPS As New ClsGPS + If ObjGPS.GetTrayectos(CveTrayecto, -1, -1) AndAlso ObjGPS.DtResultados.Rows.Count > 0 Then + Dim Row As DataRow = ObjGPS.DtResultados.Rows(0) + Me.CveDispositivo = Row("CveDispositivo").ToString().ToEntero() + Me.CveCliente = Row("CveCliente").ToString().ToEntero() + End If + End Using + TrazarLineaContinuo = True + CreaDTCoordenadas() + End Sub + Protected Sub TimmerRefresh_Tick(sender As Object, e As EventArgs) + DtPosiciones.Rows.Clear() + RegistraScript("DeleteMarkers();") + Dim LastCoord As String = "" + Dim TmpDT As New DataTable + Dim Info = "" + Dim Direccion = "" + Dim SBBody As New StringBuilder + Dim Icono As String = "/Imagenes/rsz_11rsz_car.png" + Dim Fecha, Vehiculo As String + + Dim ObjGPS As New ClsGPS + Try + Dim RowVehiculo As DataRow = GlobalDTDispositivos(CveCliente).FiltroPrimero($"CveDispositivo = {CveDispositivo}") + + If ObjGPS.UltimaPosicionEquipoGet(CveDispositivo, MinFecha, MaxFecha) Then + If ObjGPS.DtResultados.Rows.Count > 0 Then + Dim Coord As String = SQLToGmaps(ObjGPS.DtResultados.Rows(0)("Posicion").ToString, "POINT") + Fecha = ObjGPS.DtResultados.Rows(0)("FechaTrama").ToString + Vehiculo = ObjGPS.DtResultados.Rows(0)("Vehiculo").ToString + Info = InfoWindowCombustible($" Vehículo: {Vehiculo}", "-1", CveDispositivo, ObjGPS.DtResultados.Rows(0), False) + + If ObjGPS.DtResultados.Rows(0)("SPD").ToString.ToDouble > 1 Then + Icono = $"/Imagenes/{RowVehiculo("Icono")}green.png" + Else + Icono = $"/Imagenes/{RowVehiculo("Icono")}.png" + End If + + AddRowCoordenadasContinuas(Coord, CveDispositivo) + + Dim POLYPATH As String = "[" + + For Each RCC As DataRow In DtCoordenadasContinuas.FiltraParametros($"CveDispositivo = {CveDispositivo}", DistinctColumns:={"CveDispositivo", "Coord"}).Rows + POLYPATH = $"{POLYPATH}{RCC("Coord").ToString}," + Next + POLYPATH = $"{POLYPATH.Substring(0, POLYPATH.Length - 1)}]" + RegistraScript($"creaPolyline({POLYPATH}, '{RowVehiculo("ColorTrazo")}', '{Info}', {Coord}, '{RowVehiculo("NombreVehiculo")}', '{Icono}',{CveDispositivo}, 1)", $"{CveDispositivo}{DtCoordenadasContinuas.Rows.Count}") + + RegistraScript($"setTimeout(function(){{ CreaMarcador({Coord},'{RowVehiculo("NombreVehiculo").ToString()}', '{Info}', '{Icono}');}}, 1000);", CveDispositivo.ToString()) + AddRowPosiciones(Vehiculo, Coord, ObjGPS.DtResultados.Rows(0)("SPD").ToString.ToDouble, Fecha, CveDispositivo, ObjGPS.DtResultados(0)("TiempoDetenido").ToString.ToDouble) + End If + End If + + TimmerRefresh.Enabled = True + Catch ex As Exception + OnError("Ocurrió un error al rastrear equipo", ex) + End Try + End Sub + Private Sub RastrearEquipos() + Dim LastCoord As String = "" + Dim TmpDT As New DataTable + Dim Info = "" + Dim Direccion = "" + Dim SBBody As New StringBuilder + Dim Icono As String = "/Imagenes/rsz_11rsz_car.png" + Dim Fecha, Vehiculo As String + + Dim ObjGPS As New ClsGPS + Try + Dim RowVehiculo As DataRow = GlobalDTDispositivos(CveCliente).FiltroPrimero($"CveDispositivo = {CveDispositivo}") + + If ObjGPS.UltimaPosicionEquipoGet(CveDispositivo, MinFecha, MaxFecha) Then + If ObjGPS.DtResultados.Rows.Count > 0 Then + Dim Coord As String = SQLToGmaps(ObjGPS.DtResultados.Rows(0)("Posicion").ToString, "POINT") + Fecha = ObjGPS.DtResultados.Rows(0)("FechaTrama").ToString + Vehiculo = ObjGPS.DtResultados.Rows(0)("Vehiculo").ToString + Info = InfoWindowCombustible($" Vehículo: {Vehiculo}", "-1", CveDispositivo, ObjGPS.DtResultados.Rows(0), False) + + If ObjGPS.DtResultados.Rows(0)("SPD").ToString.ToDouble > 1 Then + Icono = $"/Imagenes/{RowVehiculo("Icono")}green.png" + Else + Icono = $"/Imagenes/{RowVehiculo("Icono")}.png" + End If + + AddRowCoordenadasContinuas(Coord, CveDispositivo) + + RegistraScript($"setTimeout(function(){{ CreaMarcador({Coord},'{RowVehiculo("NombreVehiculo").ToString()}', '{Info}', '{Icono}');}}, 1000);", CveDispositivo.ToString()) + AddRowPosiciones(Vehiculo, Coord, ObjGPS.DtResultados.Rows(0)("SPD").ToString.ToDouble, Fecha, CveDispositivo, ObjGPS.DtResultados(0)("TiempoDetenido").ToString.ToDouble) + End If + End If + + TimmerRefresh.Enabled = True + Catch ex As Exception + OnError("Ocurrió un error al rastrear equipo", ex) + End Try + ObjGPS.Dispose() + End Sub + + Private Sub CargaTabla() + If DtPosiciones IsNot Nothing Then + GvBarra.DataSource = DtPosiciones + GvBarra.DataBind() + End If + + If GvBarra.HeaderRow IsNot Nothing Then + GvBarra.HeaderRow.Cells(3).Style.Add("display", "") + GvBarra.HeaderRow.Cells(4).Style.Add("display", "none !important") + End If + End Sub + + Private Sub AddRowCoordenadasContinuas(Coord As String, CveDispositivo As Integer) + Dim dr As DataRow = DtCoordenadasContinuas.NewRow() + dr("CveDispositivo") = CveDispositivo + dr("Coord") = Coord + DtCoordenadasContinuas.Rows.Add(dr) + End Sub + Private Sub AddRowPosiciones(Vehiculo As String, Posicion As String, Velocidad As Double, Fecha As String, CveDispositivo As Integer, Optional TiempoDetenido As Double = 0, Optional Evento As String = "", Optional KMRecorridos As Double = 0, Optional Icono As String = "/Imagenes/rsz_11rsz_car.png") + Dim dr As DataRow = DtPosiciones.NewRow() + dr("Vehiculo") = Vehiculo + dr("Fecha") = Fecha + dr("TiempoDetenido") = TiempoDetenido + dr("Velocidad") = Velocidad + dr("Posicion") = Posicion + dr("CveDispositivo") = CveDispositivo + dr("Evento") = Evento + dr("KMRecorridos") = KMRecorridos + dr("Icono") = Icono + + DtPosiciones.Rows.Add(dr) + End Sub + Public Function InfoWindowCombustible(Header As String, ExtraBody As String, CveDispositivo As Integer, row As DataRow, Optional PermisoComandos As Boolean = True) As String + Dim SBuilder As New StringBuilder + SBuilder.Clear() + SBuilder.Append($"
") + SBuilder.Append($"
{Header}
") + SBuilder.Append($"
") + Try + SBuilder.Append($"") + SBuilder.Append($"") + If row.Table.Columns.Contains("Combustible") Then + SBuilder.Append($"") + End If + If row("SPD").ToString <> "-1" Then + SBuilder.Append($"") + End If + If ExtraBody <> "" AndAlso ExtraBody <> "-1" Then + SBuilder.Append(ExtraBody) + End If + SBuilder.AppendFormat("", row("Lat").ToString, row("Lng").ToString) + Catch ex As Exception + OnError("Ocurrió un error al consultar", ex) + End Try + SBuilder.Append($"
Fecha : {row("FechaTrama")}
Conductor : {row("Conductor").ToString}
Combustible : {IfNull(row("Combustible"), "NO DISPONIBLE", $"{row("Combustible").ToString.FormatoNumero} lts").ToString}
Velocidad : {row("SPD").ToString} KM/H
Ver en google maps
") + Return SBuilder.ToString + End Function + Protected Sub btnPagePrev_Click(sender As Object, e As EventArgs) + Dim TotalRegistros As Integer = DtPosiciones.Rows.Count + Dim TotalRowsPage As Integer = GvBarra.PageSize + Dim PrevIndex As Integer = HdnIndexPage.Value.ToEntero - 1 + Dim CurrentIndex As Integer = PrevIndex + 1 + + Dim PrevIndexDT As Integer = (TotalRowsPage) * PrevIndex + Dim CurrentIndexDT As Integer = (TotalRowsPage) * CurrentIndex + + HdnIndexPage.Value = PrevIndex.ToString + + If Not btnPageNext.Enabled Then + btnPageNext.Enabled = True + End If + + If PrevIndexDT <= 0 Then + btnPagePrev.Enabled = False + GvBarra.DataSource = DtPosiciones.FiltraPorIndices(0, CurrentIndexDT) + LblRegistros.Text = $"Distribución de datos desde 0 hasta {CurrentIndexDT.ToString.FormatoNumero(0)}. Total de registros: {DtPosiciones.Rows.Count.ToString.FormatoNumero(0)}" + Else + LblRegistros.Text = $"Distribución de datos desde {PrevIndexDT.ToString.FormatoNumero(0)} hasta {CurrentIndexDT.ToString.FormatoNumero(0)}. Total de registros: {DtPosiciones.Rows.Count.ToString.FormatoNumero(0)}" + GvBarra.DataSource = DtPosiciones.FiltraPorIndices(PrevIndexDT, CurrentIndexDT) + End If + + GvBarra.DataBind() + UPGV.Update() + + RegistraScript("setTimeout(function(){OpcionesHistorico();},500);") + End Sub + Protected Sub btnPageNext_Click(sender As Object, e As EventArgs) + Dim TotalRegistros As Integer = DtPosiciones.Rows.Count + Dim TotalRowsPage As Integer = GvBarra.PageSize + Dim Index As Integer = HdnIndexPage.Value.ToEntero + 1 + Dim NextIndex As Integer = Index + 1 + + Dim CurrentIndexDT As Integer = (TotalRowsPage) * Index + Dim NextIndexDT As Integer = (TotalRowsPage) * NextIndex + + HdnIndexPage.Value = Index.ToString + + If Not btnPagePrev.Enabled Then + btnPagePrev.Enabled = True + End If + + If NextIndexDT >= TotalRegistros Then + btnPageNext.Enabled = False + GvBarra.DataSource = DtPosiciones.FiltraPorIndices(CurrentIndexDT, TotalRegistros - 1) + LblRegistros.Text = $"Distribución de datos desde {CurrentIndexDT.ToString.FormatoNumero(0)} hasta {DtPosiciones.Rows.Count.ToString.FormatoNumero(0)}. Total de registros: {DtPosiciones.Rows.Count.ToString.FormatoNumero(0)}" + Else + GvBarra.DataSource = DtPosiciones.FiltraPorIndices(CurrentIndexDT, NextIndexDT) + LblRegistros.Text = $"Distribución de datos desde {CurrentIndexDT.ToString.FormatoNumero(0)} hasta {NextIndexDT.ToString.FormatoNumero(0)}. Total de registros: {DtPosiciones.Rows.Count.ToString.FormatoNumero(0)}" + End If + + GvBarra.DataBind() + UPGV.Update() + + RegistraScript("setTimeout(function(){OpcionesHistorico();},500);") + End Sub + + + Public Sub RegistraScript(Script As String, Optional valuetick As String = "") + Dim Rdm As Random = New Random() + ScriptManager.RegisterStartupScript(Page, Me.GetType(), String.Format("{0}{1}{2}", (DateTime.Now.Ticks + 1), Rdm.Next(), valuetick), String.Format("", Script), False) + End Sub + +End Class diff --git a/GPS/Trayectos.aspx b/GPS/Trayectos.aspx index 8a653600c..0d42e5047 100644 --- a/GPS/Trayectos.aspx +++ b/GPS/Trayectos.aspx @@ -1,400 +1,450 @@ -<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="Trayectos.aspx.vb" Inherits="GPS_Trayectos" EnableEventValidation="false" %> - - - - - - - - Reporte de Trayectos - - -
  • +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="Trayectos.aspx.vb" Inherits="GPS_Trayectos" EnableEventValidation="false" %> + + + + + + + + Reporte de Trayectos + + +
  • - -
  • -
  • + +
  • +
  • - -
  • -
    - - - -
    -
    -
    - -
    -
    -
      + + + + + + +
      +
      +
      + +
      +
      +
      • Vehículo: - - -
      • + + + +
      • Estatus: - - -
      • + + + +
      • Fecha Inicio: -
        - -
        -
      • + +
        + +
        +
      • Fecha Fin: -
        - -
        -
      • + +
        + +
        +
      • Mostrar Solo Activas: - -
      • -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      - " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> -
      -
      - - - - - - - - - - - - - - - - - - - - - - - - -
      -
      - - - - -
    +
    +
    +
    +
    +
    +
    +
    +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + + -
    - - + + + + + + + - - - + + + diff --git a/GPS/Trayectos.aspx.vb b/GPS/Trayectos.aspx.vb index b05d84872..a1977fccd 100644 --- a/GPS/Trayectos.aspx.vb +++ b/GPS/Trayectos.aspx.vb @@ -183,7 +183,9 @@ Partial Class GPS_Trayectos ObjGPS.IniciaTransacSQL() Try - Dim CveTrayecto As Integer = ObjGPS.AddTrayecto(Nombre, DateTime.Now, "", CveDispositivo, UsuarioActual.CveCliente) + Dim CveTrayecto As Integer = ObjGPS.AddTrayecto(Nombre, DateTime.Now, "", CveDispositivo, UsuarioActual.CveCliente, EnviarNotificacion:=ChkNotificacion.Checked, + CorreosNotificacion:=TxtCorreoNot.Text, Intervalo:=If(ChkNotificacion.Checked, 0, DdlIntervalo.SelectedValue.ToEntero()), + EnviarLiga:=ChkEnviarLiga.Checked) If CveTrayecto > 0 Then For Each Row As GridViewRow In GvEstatus.Rows @@ -401,6 +403,115 @@ Partial Class GPS_Trayectos ObjGPS.Dispose() End If Return Retorno - End Function - + End Function + + Protected Sub ChkNotificacion_CheckedChanged(sender As Object, e As EventArgs) + DivNotificaciones.Visible = ChkNotificacion.Checked + UpAgregar.Update() + End Sub + Protected Sub LnkEnviar_Click(sender As Object, e As EventArgs) + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + + Dim CveTrayecto As Integer = GvRow.DataKey("CveTrayecto").ToEntero() + Dim EnviarLiga As Boolean = CBool(GvRow.DataKey("EnviarLiga")) + If CveTrayecto > 0 Then + Dim DtInfoTrayecto As DataTable = Nothing + Using ObjGPS As New ClsGPS + If ObjGPS.GetTrayectosDatos(CveTrayecto) Then + DtInfoTrayecto = ObjGPS.DtSetResultados.Tables(0).Copy() + End If + End Using + If DtInfoTrayecto IsNot Nothing AndAlso DtInfoTrayecto.Rows.Count > 0 Then + Dim Row As DataRow = DtInfoTrayecto.Rows(0) + GeneraCorreo(CveTrayecto, EnviarLiga, Row) + End If + End If + End Sub + + Protected Function GeneraCorreo(CveTrayecto As Integer, EnviarLiga As Boolean, Row As DataRow) As String + Dim strBody As New StringBuilder + Try + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append("
    ") + strBody.Append(" ") + strBody.Append("
    ") + strBody.Append("
    Datos del Trayecto ") + strBody.Append(" ") + strBody.Append(" ") + strBody.AppendFormat(" ", Row("Trayecto")) + strBody.Append(" ") + strBody.Append(" ") + strBody.AppendFormat(" ", Row("Vehiculo")) + strBody.Append(" ") + strBody.Append(" ") + strBody.AppendFormat(" ", Row("Estatus")) + strBody.Append(" ") + If EnviarLiga Then + strBody.Append(" ") + strBody.AppendFormat(" ", String.Format("http://gps.signalsgps.com/GPS/RastreoTrayectos.aspx?P={0}", Encripta($"CveTrayecto={CveTrayecto}"))) + strBody.Append(" ") + End If + strBody.Append(" ") + strBody.AppendFormat(" ", Row("LigaImagen")) + strBody.Append(" ") + strBody.Append("
    Trayecto:{0}
    Vehículo:{0}
    Estatus:{0}
    Rastrea Equipo:{0}
    Posición:
    ") + strBody.Append("
    ") + strBody.Append("
    ") + strBody.Append(" ") + strBody.Append("
    ") + strBody.Append("
    ") + strBody.Append("") + Catch ex As Exception + OnError("Ocurrio un error al general el correo.", ex) + End Try + Return strBody.ToString() + End Function End Class diff --git a/SiteGPS.master b/SiteGPS.master index 7e7f433ff..f1aa06e3e 100644 --- a/SiteGPS.master +++ b/SiteGPS.master @@ -843,7 +843,7 @@ var request = { Metodo: "UpdateNotificacion", Params: { - Cve: <%= UsuarioActual.CveUsuario %>, + Cve: <%= If(UsuarioActual IsNot Nothing, UsuarioActual.CveUsuario, -1) %>, CveBitacora: -1 } } @@ -864,8 +864,6 @@ setTimeout(startTimer, 60000); // callback } - startTimer(); - // function ShowToast(text, header, type, footer, sound,persistencia,coords) { @@ -919,7 +917,7 @@ var request = { Metodo: "UpdateNotificacion", Params: { - Cve: <%= UsuarioActual.CveUsuario %>, + Cve: <%= If(UsuarioActual IsNot Nothing, UsuarioActual.CveUsuario, -1) %>, CveBitacora: CveNotificacionBitacora } } diff --git a/SiteGPS.master.vb b/SiteGPS.master.vb index d7770c0df..a0aa82fc9 100644 --- a/SiteGPS.master.vb +++ b/SiteGPS.master.vb @@ -127,19 +127,22 @@ Partial Class SiteGPS End If End If - CargarNotificaciones() + CargarNotificaciones() + + RegistraScript($"IniciarNotificaciones();startTimer();") Else Dim thisURL As String = Request.Url.Segments(Request.Url.Segments.Count - 1) If thisURL.Equals("WizardRegistro.aspx") OrElse thisURL.Equals("Registro.aspx") Then LitTit.Text = "AD  Soluciones en TI " - + ElseIf thisURL.Equals("RastreoTrayectos.aspx") Then + LitTit.Text = "Rastreo  Trayectos " End If 'Response.Redirect("/PortalGPS/LoginPortal.aspx") - End If + End If + + - - RegistraScript($"IniciarNotificaciones();") Else 'VALIDACION DE SEGURIDAD, EN LA QUE SE VALIDA QUE LA EMPRESA EN LA QUE SE GENERO LA PAGINA SEA LA MISMA A LA DE LA SESION, diff --git a/Ventas/Clientes.aspx b/Ventas/Clientes.aspx index d424233f7..ba8db1c2f 100644 --- a/Ventas/Clientes.aspx +++ b/Ventas/Clientes.aspx @@ -837,19 +837,22 @@
    -
    - - - - - - - - - - -
    +
    +
    + + + + + + + + + + +
    +
    @@ -859,6 +862,8 @@ %
    +
    +
    @@ -868,6 +873,8 @@ %
    +
    +
    diff --git a/Ventas/ClientesAbonar.aspx b/Ventas/ClientesAbonar.aspx index e697d1f14..2035e1abc 100644 --- a/Ventas/ClientesAbonar.aspx +++ b/Ventas/ClientesAbonar.aspx @@ -344,6 +344,11 @@   + + + + + Auxiliar @@ -506,6 +511,11 @@ } else { txt.value = ""; } + //if (typeof t2 === "undefined") { + + //} else { + + //} if (chkPesosBancos) { diff --git a/Ventas/ClientesAbonar.aspx.vb b/Ventas/ClientesAbonar.aspx.vb index 500f775dc..b392ba7ff 100644 --- a/Ventas/ClientesAbonar.aspx.vb +++ b/Ventas/ClientesAbonar.aspx.vb @@ -1,5 +1,7 @@ -Imports System.Data -Imports Extensiones +Imports Extensiones +Imports System.Data +Imports System.Linq + Partial Class Ventas_ClientesAbonar Inherits ClsPaginas @@ -459,7 +461,10 @@ Partial Class Ventas_ClientesAbonar TxtImporte.Text = "" TxtObservaciones.Text = "" If SumDescuentoProntoPago > 0.0 Then - GvCxC.Columns(14).Visible = True + GvCxC.Columns(14).Visible = True 'MOSTRAR DESCUENTO PRONTO PAGO + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + GvCxC.Columns(15).Visible = True 'HABILITAR NC + End If End If Mov.Dispose() @@ -635,6 +640,11 @@ Partial Class Ventas_ClientesAbonar e.Row.FCRangeValidator("RVComision").MinimumValue = 0.00 e.Row.FCRangeValidator("RVComision").MaximumValue = e.Row.DBCampo("Saldo") End If + + If e.Row.DBCampo("DescuentoProntoPago").ToDecimal() >= 0 Then + e.Row.FCCheckBox("ChkGenerarNC").Visible = True + End If + Else e.Row.FCTextBox("TxtAbonar").Visible = False e.Row.FCTextBox("TxtComision").Visible = False @@ -680,6 +690,8 @@ Partial Class Ventas_ClientesAbonar Next Dim MsgError As String = "" + Dim NCGeneradas As New List(Of Modelos.Factura.MMensajeFactura) + Dim ListaFacturasGenerarNC As New List(Of Modelos.Factura) 'comentada RMF 2018.09.28 'Dim Dep As New ClsGenerales @@ -1362,43 +1374,43 @@ Partial Class Ventas_ClientesAbonar If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(2)}" - End If - 'Case 92 - ' If RblTipoPago.SelectedValue = "3" Then ' cuando es ingreso por comprobar - ' ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal - ' importeMX = Math.Round(ImporteMovimiento * tipoCambioPago, 2) - ' CveSubProyectoContabilizar = CveSubProyecto - - ' If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(2)}" - - ' 'si la factura es en dólares y trae complementaria, el importemn debe ser igual al importe - ' If gvr.DataKey("CveMoneda").ToEntero <> 1 AndAlso (IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119) Then - ' importeMX = ImporteMovimiento - ' IdCtaContable = IdCtaContMonedaExtranjera - ' Else - ' IdCtaContable = IdCuentaCliente - ' CveCuenta = CveCuentaCliente - ' End If - - ' If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, Referencia, ConceptoContable, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE:=DdlIngreso.SelectedValue.ToEntero, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveCliente:=CveCliente, ImporteMX:=importeMX, CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar) Then - ' MsgError = "No se pudo insertar la póliza" - ' End If - - ' If gvr.DataKey("CveMoneda").ToEntero = 2 Then - ' IdCtaContable = IdCtaContComplementaria - ' CveCuenta = CveCuentaComplementaria - ' If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then - ' If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, 227, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE:=DdlIngreso.SelectedValue.ToEntero, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveCliente:=CveCliente, ImporteMX:=ImporteMovimiento * tipoCambioPago - ImporteMovimiento, CveCuenta:=CveCuenta, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioPago) Then - ' MsgError = "No se pudo insertar la póliza" - ' End If - ' importeMX = ImporteMovimiento - ' IdCtaContable = IdCtaContMonedaExtranjera - ' CveCuenta = CveCuentaMonedaExtranjera - ' End If - ' End If - - ' End If - ' ImporteMovimiento = 0 + End If + 'Case 92 + ' If RblTipoPago.SelectedValue = "3" Then ' cuando es ingreso por comprobar + ' ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal + ' importeMX = Math.Round(ImporteMovimiento * tipoCambioPago, 2) + ' CveSubProyectoContabilizar = CveSubProyecto + + ' If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(2)}" + + ' 'si la factura es en dólares y trae complementaria, el importemn debe ser igual al importe + ' If gvr.DataKey("CveMoneda").ToEntero <> 1 AndAlso (IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119) Then + ' importeMX = ImporteMovimiento + ' IdCtaContable = IdCtaContMonedaExtranjera + ' Else + ' IdCtaContable = IdCuentaCliente + ' CveCuenta = CveCuentaCliente + ' End If + + ' If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, Referencia, ConceptoContable, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE:=DdlIngreso.SelectedValue.ToEntero, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveCliente:=CveCliente, ImporteMX:=importeMX, CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar) Then + ' MsgError = "No se pudo insertar la póliza" + ' End If + + ' If gvr.DataKey("CveMoneda").ToEntero = 2 Then + ' IdCtaContable = IdCtaContComplementaria + ' CveCuenta = CveCuentaComplementaria + ' If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then + ' If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, 227, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE:=DdlIngreso.SelectedValue.ToEntero, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveCliente:=CveCliente, ImporteMX:=ImporteMovimiento * tipoCambioPago - ImporteMovimiento, CveCuenta:=CveCuenta, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioPago) Then + ' MsgError = "No se pudo insertar la póliza" + ' End If + ' importeMX = ImporteMovimiento + ' IdCtaContable = IdCtaContMonedaExtranjera + ' CveCuenta = CveCuentaMonedaExtranjera + ' End If + ' End If + + ' End If + ' ImporteMovimiento = 0 Case 134 'Pago Intermediario If RblTipoPago.SelectedValue = "2" Then ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal - gvr.FCTextBox("TxtComision").Text.ToDecimal @@ -1438,6 +1450,10 @@ Partial Class Ventas_ClientesAbonar End If Next End If + If gvr.FCCheckBox("ChkGenerarNC").Checked Then + ListaFacturasGenerarNC.Add(New Modelos.Factura(UsuarioActual, gvr.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa) With {.DescuentoProntoPago = gvr.DataKey("DescuentoProntoPago").ToDecimal()}) + End If + End If Next @@ -1565,7 +1581,16 @@ Partial Class Ventas_ClientesAbonar MsgError = "No se insertó el encabezado" End If - + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + If MsgError = "" Then + Dim Resp = GenerarNC(ObjIE.IniciaTransacSQL(), ObjConta, ListaFacturasGenerarNC) + If Resp.CveVenta > 0 Then + NCGeneradas.Add(Resp) + Else + MsgError = "No se pudo generar la nota de credito" + End If + End If + End If If MsgError = "" Then 'se agregan las pólizas de Armonización Contable @@ -1649,8 +1674,17 @@ Partial Class Ventas_ClientesAbonar Dim TextoComplementoPago = EmitirComplementoPago(CveIE, CveVentasPago, SeriesPago) + Dim SbMensaje As New StringBuilder + SbMensaje.Append(String.Format("Abono Registrado Correctamente.

    Poliza: {1}

    {2}", IDPoliza, FolioPoliza, TextoComplementoPago)) + + For Each NC In NCGeneradas + For Each msg In NC.Mensajes + SbMensaje.Append(msg) + Next + SbMensaje.Append("
    ") + Next - Alert(String.Format("Abono Registrado Correctamente.

    Poliza: {1}

    {2}", IDPoliza, FolioPoliza, TextoComplementoPago), TipoMensaje.MsgInformacion, If(ChkSeguirRegistrando.Checked, "location.href =""#""", "location.href =""/Bancos/RepCxCCliente.aspx""")) + Alert(SbMensaje.ToString()) Else ObjIE.RollBack() If ObjConta IsNot Nothing Then ObjConta.RollBack() @@ -1671,7 +1705,17 @@ Partial Class Ventas_ClientesAbonar If IDPoliza > 0 Then StrMsg.AppendFormat("
    Poliza: {1}", IDPoliza, FolioPoliza) - Dim TextoComplementoPago = EmitirComplementoPago(CveIE, CveVentasPago, SeriesPago) + Dim TextoComplementoPago = EmitirComplementoPago(CveIE, CveVentasPago, SeriesPago) + + Dim SbMensaje As New StringBuilder + SbMensaje.Append(String.Format("Abono Registrado Correctamente.

    Poliza: {1}

    {2}", IDPoliza, FolioPoliza, TextoComplementoPago)) + + For Each NC In NCGeneradas + For Each msg In NC.Mensajes + StrMsg.Append(msg) + Next + StrMsg.Append("
    ") + Next Alert($"{StrMsg.ToString}

    {TextoComplementoPago}", TipoMensaje.MsgInformacion, If(ChkSeguirRegistrando.Checked, "location.href =""#""", "location.href =""/Bancos/RepCxCCliente.aspx""")) End If @@ -1703,8 +1747,463 @@ Partial Class Ventas_ClientesAbonar ObjEvento.Dispose() LimpiaCampos() - End Sub + End Sub + +#Region " N O T A - D E - C R E D I T O" + + Private Function GenerarNC(Trasac As SqlClient.SqlTransaction, ObjConta As ClsContPAQi, ListaVentasGenerarNC As List(Of Modelos.Factura)) As Modelos.Factura.MMensajeFactura + Dim ObjFacturaDevolucion = New Modelos.Factura(UsuarioActual) + ObjFacturaDevolucion.TipoMensajeRespuesta = Modelos.TipoMensajeRespuesta.HTML + ObjFacturaDevolucion.CveUsuario = UsuarioActual.CveUsuario + ObjFacturaDevolucion.UsuarioCreo = UsuarioActual.Usuario + + 'If CveVentaPadre > 0 Then + ' ObjFacturaDevolucion.CveVentaPadre = CveVentaPadre + ' ObjFacturaDevolucion.CveVentaRelacion = CveVentaPadre + 'End If + + Dim Folio As String = "" + Dim Serie As String = "" + + Dim ObjFolios As New ClsGralFolios() + If ObjFolios.GetFolios("Egs", UsuarioActual.CveEmpresa) Then + Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format(" Estado = 'Activo' AND CveSubProyecto = {0}", Me.CveSubProyecto)) + If DT.Rows.Count > 0 Then + Serie = DT.Rows(0)("Serie").ToString() + Folio = DT.Rows(0)("FActual").ToString() + End If + DT.Dispose() + End If + ObjFolios.Dispose() + + ObjFacturaDevolucion.CveEmpresa = UsuarioActual.CveEmpresa + ObjFacturaDevolucion.TipoCambio = If(Me.CveMoneda = 1, 1, GlobalTipoCambio(Now).FormatoNumero(4).ToDecimal()) + ObjFacturaDevolucion.ConvertirPesos = False + ObjFacturaDevolucion.CveMoneda = Me.CveMoneda + ObjFacturaDevolucion.Moneda = GlobalDTMonedas.FiltroPrimeroValor("Moneda", $"CveMoneda = {Me.CveMoneda}") + ObjFacturaDevolucion.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", $"CveMoneda = {Me.CveMoneda}") + ObjFacturaDevolucion.Serie = Serie + ObjFacturaDevolucion.Folio = Folio + ObjFacturaDevolucion.Fecha = Now + ObjFacturaDevolucion.CvePrePoliza = -1 + ObjFacturaDevolucion.CveMetodoPago = 0 + ObjFacturaDevolucion.CondicionesPago = 0 ' 0 - Contado, 1 - Credito (CHECAR) + ObjFacturaDevolucion.FormaPago = 0 + + ObjFacturaDevolucion.TipoDocto = "Egs" + ObjFacturaDevolucion.Fecha = Now + + ObjFacturaDevolucion.Version = "3.3" + ObjFacturaDevolucion.CveMetodoPago33 = 1 + ObjFacturaDevolucion.MetodoPago33 = "Pago en una sola exhibición" + ObjFacturaDevolucion.ClaveMetodoPagoSAT = "PUE" + + ObjFacturaDevolucion.CveFormaPago33 = 21 + ObjFacturaDevolucion.FormaPago33 = "Aplicación de anticipos" + ObjFacturaDevolucion.FormaPagoSAT33 = "30" + + ObjFacturaDevolucion.MetodoPago = "" + ObjFacturaDevolucion.ClaveMetodoPagoSAT = GlobalDTMetodosPago.FiltroPrimeroValor("ClaveSAT", $"CveMetodoPago = {ObjFacturaDevolucion.CveMetodoPago33}") + + ObjFacturaDevolucion.CveSubProyecto = Me.CveSubProyecto + ObjFacturaDevolucion.SetSubProyecto() + + ObjFacturaDevolucion.CveCliente = Me.CveCliente + ObjFacturaDevolucion.SetCliente() + + Dim ObjCliente As New ClsClientes + If ObjCliente.GetClientes(ObjFacturaDevolucion.CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, -1, TipoCliente:=-1) Then + If ObjCliente.DtResultados.Rows.Count > 0 Then + + ObjFacturaDevolucion.CveUsoCFDI = ObjCliente.CveUsoCFDI + ObjFacturaDevolucion.UsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("Descripcion", String.Format("CveUsoCFDI = {0}", ObjCliente.CveUsoCFDI)) + ObjFacturaDevolucion.ClaveUsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("UsoCFDI", String.Format("CveUsoCFDI = {0}", ObjCliente.CveUsoCFDI)) + + ObjFacturaDevolucion.DtDetalle = CreaDTDetalleNC() + + CargaImpuestos(ObjFacturaDevolucion, ListaVentasGenerarNC, ObjCliente.DesglosaIEPS, ObjCliente.RetIVA, ObjCliente.RetISR) + + End If + End If + + If ObjCliente.GetSucursales(CveCliente) Then + If ObjCliente.DtResultados.Rows.Count > 0 Then + ObjFacturaDevolucion.CveClienteSucursal = If(String.IsNullOrEmpty(ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "Estatus = 'Activo'")), -1, ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "Estatus = 'Activo'").ToEntero()) + Else + ObjFacturaDevolucion.CveClienteSucursal = -1 + End If + End If + ObjCliente.Dispose() + + ObjFacturaDevolucion.CveTipoRelacion = 7 + ObjFacturaDevolucion.TipoRelacion = "07" + + Dim Fol As New List(Of String) + For Each Fac In ListaVentasGenerarNC + Fol.Add(Fac.FolioFiscal) + Next + ObjFacturaDevolucion.UUIDRelacionados = Fol + + Select Case ObjFacturaDevolucion.TipoDocto + Case "Ing" + ObjFacturaDevolucion.TipoDocumento = "Factura" + Case "REM" + ObjFacturaDevolucion.TipoDocumento = "Remision" + Case "Cot" + ObjFacturaDevolucion.TipoDocumento = "Cotizacion" + Case "Egs" + ObjFacturaDevolucion.TipoDocumento = "Nota de Crédito" + Case "Dev" + ObjFacturaDevolucion.TipoDocumento = "Nota de Devolución" + Case Else + ObjFacturaDevolucion.TipoDocumento = "" + End Select + + If ObjFacturaDevolucion.TipoDocto IsNot Nothing Then + ViewState("TipoDoctoDevolucion") = ObjFacturaDevolucion.TipoDocto + End If + + ObjFacturaDevolucion.FechaPago = Now + + ObjFacturaDevolucion.CveCorte = -1 + ObjFacturaDevolucion.CveMesa = -1 + ObjFacturaDevolucion.NumeroPersonas = 0 + ObjFacturaDevolucion.CveContrato = -1 + ObjFacturaDevolucion.DescripcionContrato = "" + ObjFacturaDevolucion.CveClienteSucursal = -1 + ObjFacturaDevolucion.Entrega = "" + ObjFacturaDevolucion.CveAlmacen = -1 + + Dim DtVentasNC = InicializaDTVentasNC() + + Dim TotalImporte As Decimal = ObjFacturaDevolucion.DtDetalle.SUM("TotalImporte").ToDecimal() + Dim ImporteIVA As Decimal = ObjFacturaDevolucion.DtDetalle.SUM("ImporteIVA").ToDecimal() + Dim ImporteRetIVA As Decimal = ObjFacturaDevolucion.DtDetalle.SUM("ImporteRetIVA").ToDecimal() + Dim ImporteRetISR As Decimal = ObjFacturaDevolucion.DtDetalle.SUM("ImporteRetISR").ToDecimal() + Dim ImporteIEPS As Decimal = ObjFacturaDevolucion.DtDetalle.SUM("ImporteIEPS").ToDecimal() + Dim Descuento As Decimal = ObjFacturaDevolucion.DtDetalle.SUM("Descuento").ToDecimal() + Dim Amortizacion As Decimal = 0 + + Dim Total As Decimal = (TotalImporte + ImporteIVA + ImporteIEPS) - (ImporteRetIVA + ImporteRetISR + Descuento + Amortizacion) + + 'DETALLES + ObjFacturaDevolucion.SubTotal = TotalImporte + ObjFacturaDevolucion.Descuento = Descuento + ObjFacturaDevolucion.Amortizacion = Amortizacion + ObjFacturaDevolucion.IVA = ImporteIVA + ObjFacturaDevolucion.RetIVA = ImporteRetIVA + ObjFacturaDevolucion.RetISR = ImporteRetISR + ObjFacturaDevolucion.IEPS = ImporteIEPS + ObjFacturaDevolucion.Total = Total + ObjFacturaDevolucion.TotalOtrosConceptos = 0 + + For Each Fac In ListaVentasGenerarNC + Dim Drt = DtVentasNC.NewRow + Drt("CveVenta") = Fac.CveVenta + Drt("Importe") = Fac.DescuentoProntoPago + Drt("FolioFiscal") = Fac.FolioFiscal + DtVentasNC.Rows.Add(Drt) + Next + + DtVentasNC.AcceptChanges() + + ObjFacturaDevolucion.DtVentasNC = DtVentasNC + + Dim Resp = ObjFacturaDevolucion.EmitirFactura(False, Trasac:=Trasac, ObjContPaqTransac:=ObjConta) + Return Resp + + End Function + + + Private Sub AgregaTempDTNC(ByRef TmpDT As DataTable, CvePS As Integer, PS As String, Codigo As String, CodigoPS As String, CveTipoPS As Integer, CveTipoInvPS As Integer, CveUM As Integer, UM As String, + CveClasificacion As Integer, Clasificacion As String, CveProyecto As Integer, CveSubProyecto As Integer, + Obs As String, Cantidad As Double, PU As Double, PorcentajeIVA As Double, ImporteIVA As Double, PorcentajeRetIVA As Double, ImporteRetIVA As Double, + PorcentajeRetISR As Double, ImporteRetISR As Double, PorcentajeIEPS As Double, ImporteIEPS As Double, TipoDescuento As Integer, Descuento As Double, + Total As Double, SerieLote As String, TiempoEntrega As String, CvePresupuestoIngreso As Integer, EntregaDirecta As Integer, SATClaveProdServ As String, + SATClaveUM As String, CveContratoDetalle As Integer, CveVentaDetalle As Integer, CveMovimientoDetallePedido As Integer, CveOrdenCompraDetalle As Integer, + CveVentaDetalleRemision As Integer, CveVentaDetalleCotizacion As Integer) + + Dim Row As DataRow = Nothing + Row = TmpDT.NewRow() + + Row("Consec") = TmpDT.Rows.Count + 1 + Row("Orden") = TmpDT.Rows.Count + 1 + + Row("CvePS") = CvePS + Row("PS") = PS + Row("Codigo") = Codigo + Row("CodigoPS") = CodigoPS + Row("CveTipoPS") = CveTipoPS + Row("CveTipoInvPS") = CveTipoInvPS + + Row("CveUM") = CveUM + Row("UM") = UM + + Row("CveClasificacion") = CveClasificacion + Row("Clasificacion") = Clasificacion + Row("CveProyecto") = CveProyecto + Row("Proyecto") = "" + Row("CveSubProyecto") = CveSubProyecto + Row("SubProyecto") = "" + + Row("Obs") = Obs + Row("Cantidad") = Cantidad + Row("PU") = Math.Round(PU, 6) + Row("PorcentajeIVA") = PorcentajeIVA + Row("IVA") = PorcentajeIVA + Row("ImporteIVA") = Math.Round(ImporteIVA, 2) + Row("PorcentajeRetIVA") = PorcentajeRetIVA + Row("ImporteRetIVA") = Math.Round(ImporteRetIVA, 2) + Row("PorcentajeRetISR") = PorcentajeRetISR + Row("ImporteRetISR") = Math.Round(ImporteRetISR, 2) + Row("PorcentajeIEPS") = PorcentajeIEPS + Row("ImporteIEPS") = Math.Round(ImporteIEPS, 2) + Row("IEPS") = Math.Round(ImporteIEPS, 2) + Row("TipoDescuento") = TipoDescuento + Row("Descuento") = Math.Round(Descuento, 2) + Row("Total") = Math.Round(Total, 2) + Row("TotalImporte") = Math.Round(Total, 2) + + Row("SerieLote") = SerieLote + Row("TiempoEntrega") = TiempoEntrega + Row("CvePresupuestoIngreso") = CvePresupuestoIngreso + Row("EntregaDirecta") = EntregaDirecta + Row("SATClaveProdServ") = SATClaveProdServ + Row("SATClaveUM") = SATClaveUM + + 'Contratos + Row("CveContratoDetalle") = CveContratoDetalle + Row("CveVentaDetalle") = CveVentaDetalle + Row("CveMovimientoDetallePedido") = CveMovimientoDetallePedido + Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle + Row("CveVentaDetalleRemision") = CveVentaDetalleRemision + Row("CveVentaDetalleCotizacion") = CveVentaDetalleCotizacion + + TmpDT.Rows.Add(Row) + End Sub + + Private Sub CargaImpuestos(ByRef ObjFacturaDevolucion As Modelos.Factura, ListaVentasGenerarNC As List(Of Modelos.Factura), ClienteDesglosaIEPS As Boolean, ClienteRetIVA As Decimal, ClienteRetISR As Decimal) + Dim DtImpuestos As New DataTable + DtImpuestos.Columns.Add("ImportePU", GetType(Decimal)) + DtImpuestos.Columns.Add("ImporteTotal", GetType(Decimal)) + DtImpuestos.Columns.Add("PorcentajeIVA", GetType(Decimal)) + DtImpuestos.Columns.Add("ImporteIVA", GetType(Decimal)) + DtImpuestos.Columns.Add("PorcentajeRetIVA", GetType(Decimal)) + DtImpuestos.Columns.Add("ImporteRetIVA", GetType(Decimal)) + DtImpuestos.Columns.Add("PorcentajeRetISR", GetType(Decimal)) + DtImpuestos.Columns.Add("ImporteRetISR", GetType(Decimal)) + DtImpuestos.Columns.Add("PorcentajeIEPS", GetType(Decimal)) + DtImpuestos.Columns.Add("ImporteIEPS", GetType(Decimal)) + DtImpuestos.Columns.Add("CveSubProyecto", GetType(Integer)) + DtImpuestos.AcceptChanges() + Dim AcumuladoNC As Decimal = 0 + + For Each Fac In ListaVentasGenerarNC + DtImpuestos.Merge(CargaDtImpuestosNC(Fac.CveVenta, Fac.DescuentoProntoPago), True, MissingSchemaAction.Ignore) + Next + + DtImpuestos = CargaTotalesImpuestos(DtImpuestos) + + Dim DrSubProyecto As DataRow = GlobalDTSubProyectos(-1, ObjFacturaDevolucion.CveSubProyecto).Rows(0) + + Dim Cantidad As Decimal = 1 + Dim CveProyecto As Integer = DrSubProyecto("CveProyecto").ToString().ToEntero() + Dim CveSubProyecto = DrSubProyecto("CveSubProyecto").ToString.ToEntero + Dim SubProyecto = DrSubProyecto("SubProyecto").ToString + Dim Proyecto = DrSubProyecto("Proyecto").ToString + + Dim CveSATNC = "84111506" + Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:=CveSATNC, AplicaParaVenta:=1).FiltroPrimero("") + + For Each Dr As DataRow In DtImpuestos.Rows + AgregaTempDTNC(ObjFacturaDevolucion.DtDetalle, DrPS("CvePS").ToString.ToEntero, DrPS("PS").ToString, DrPS("Codigo").ToString, DrPS("PSCodigo").ToString, DrPS("CveTipoPS").ToString.ToEntero, DrPS("Inv_CveMetodoInventario").ToString.ToEntero, + DrPS("CveUM").ToString.ToEntero, DrPS("UnidadMedida").ToString, DrPS("CveClasificacion").ToString.ToEntero, DrPS("Clasificacion").ToString, CveProyecto, CveSubProyecto, + "", Cantidad, Dr("ImportePU").ToString.ToDecimal, Dr("PorcentajeIVA").ToString.ToDecimal, Dr("ImporteIVA").ToString.ToDecimal, Dr("PorcentajeRetIVA").ToString.ToDecimal, Dr("ImporteRetIVA").ToString.ToDecimal, + Dr("PorcentajeRetISR").ToString.ToDecimal, Dr("ImporteRetISR").ToString.ToDecimal, Dr("PorcentajeIEPS").ToString.ToDecimal, Dr("ImporteIEPS").ToString.ToDecimal, -1, 0.0, Dr("ImporteTotal").ToString.ToDecimal, "", "", -1, -1, + DrPS("SATClavePS").ToString, DrPS("SATClaveUnidadMedida").ToString, -1, -1, -1, -1, -1, -1) + Next + + End Sub + + Private Function CargaDtImpuestosNC(CveVentaNC As Integer, Importe As Decimal) As DataTable + Dim Total As Decimal = 0, SubTotal As Decimal = 0, Saldo As Decimal = 0 + + Dim TmpDT As DataTable = Nothing + Dim ObjVentas As New ClsVentas + + If ObjVentas.GetVentaDetalle(CveVentaNC) Then + TmpDT = ObjVentas.DtResultados + TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) + TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer)) + End If + + If ObjVentas.GetVenta(CveVentaNC, UsuarioActual.CveEmpresa) Then + If ObjVentas.DtResultados.Rows.Count > 0 Then + Total = ObjVentas.DtResultados()(0)("Total").ToString.ToDecimal + SubTotal = ObjVentas.DtResultados()(0)("SubTotal").ToString.ToDecimal + End If + End If + ObjVentas.Dispose() + + Dim DtImpuestosLocal = TmpDT.FiltraParametros("", "", {"PorcentajeIVA", "PorcentajeRetIVA", "PorcentajeRetISR", "PorcentajeIEPS", "CveSubProyecto"}).Copy + DtImpuestosLocal.Columns.Add("ImportePU", GetType(Decimal)) + DtImpuestosLocal.Columns.Add("ImporteTotal", GetType(Decimal)) + DtImpuestosLocal.Columns.Add("ImporteIVA", GetType(Decimal)) + DtImpuestosLocal.Columns.Add("ImporteRetIVA", GetType(Decimal)) + DtImpuestosLocal.Columns.Add("ImporteRetISR", GetType(Decimal)) + DtImpuestosLocal.Columns.Add("ImporteIEPS", GetType(Decimal)) + + Dim ImporteReferencia As Decimal = Total + Dim Porcentaje As Decimal = ((Importe * 100) / ImporteReferencia) / 100 + Dim FiltroStr As String = "" + For Each Dr As DataRow In DtImpuestosLocal.Rows + FiltroStr = String.Format("ISNULL(PorcentajeIVA,0) = {0} AND ISNULL(PorcentajeRetIVA,0) = {1} AND ISNULL(PorcentajeRetISR,0) = {2} AND ISNULL(PorcentajeIEPS,0) = {3} AND ISNULL(CveSubProyecto,0) = {4} ", Dr("PorcentajeIVA").ToString.ToDecimal, Dr("PorcentajeRetIVA").ToString.ToDecimal, Dr("PorcentajeRetISR").ToString.ToDecimal, Dr("PorcentajeIEPS").ToString.ToDecimal, Dr("CveSubProyecto")) + Dr("ImporteTotal") = Math.Round(Porcentaje * (TmpDT.SUM("TotalImporte", FiltroStr) - TmpDT.SUM("Descuento", FiltroStr)), 2) + + Dr("ImporteIVA") = (Dr("ImporteTotal").ToString().ToDecimal() * Dr("PorcentajeIVA").ToString().ToDecimal()).RoundSQL(2) + Dr("ImporteRetIVA") = (Dr("ImporteTotal").ToString().ToDecimal() * Dr("PorcentajeRetIVA").ToString().ToDecimal()).RoundSQL(2) + Dr("ImporteRetISR") = (Dr("ImporteTotal").ToString().ToDecimal() * Dr("PorcentajeRetISR").ToString().ToDecimal()).RoundSQL(2) + Dr("ImporteIEPS") = (Dr("ImporteTotal").ToString().ToDecimal() * Dr("PorcentajeIEPS").ToString().ToDecimal()).RoundSQL(2) + + 'Dr("ImporteIVA") = Math.Round(Porcentaje * TmpDT.SUM("ImporteIVA", FiltroStr), 2) + 'Dr("ImporteRetIVA") = Math.Round(Porcentaje * TmpDT.SUM("ImporteRetIVA", FiltroStr), 2) + 'Dr("ImporteRetISR") = Math.Round(Porcentaje * TmpDT.SUM("ImporteRetISR", FiltroStr), 2) + 'Dr("ImporteIEPS") = Math.Round(Porcentaje * TmpDT.SUM("ImporteIEPS", FiltroStr), 2) + + Dr("ImportePU") = Dr("ImporteTotal").ToString.ToDecimal '(Dr("ImporteTotal").ToString.ToDecimal - Dr("ImporteIVA").ToString.ToDecimal - Dr("ImporteRetIVA").ToString.ToDecimal - Dr("ImporteRetISR").ToString.ToDecimal - Dr("ImporteIEPS").ToString.ToDecimal) + Next + 'codigo para ajuste de centavo, si el importe total no cuadra con los totales + Dim difTmp As Decimal = Importe - (DtImpuestosLocal.SUMD("ImporteTotal") + DtImpuestosLocal.SUMD("ImporteIVA") + DtImpuestosLocal.SUMD("ImporteIEPS") - DtImpuestosLocal.SUMD("ImporteRetIVA") - DtImpuestosLocal.SUMD("ImporteRetISR")) + If Math.Abs(difTmp) >= 0.01 Then + 'asusto la diferencia en el último concepto + Dim ImporteAjustado As Decimal = DtImpuestosLocal.Rows(DtImpuestosLocal.Rows.Count - 1)("ImporteTotal").ToString.ToDecimal + difTmp + DtImpuestosLocal.Rows(DtImpuestosLocal.Rows.Count - 1)("ImporteTotal") = ImporteAjustado + DtImpuestosLocal.Rows(DtImpuestosLocal.Rows.Count - 1)("ImportePU") = ImporteAjustado + End If + 'CARGA FACTURA A LA CUAL SE APLICA LA NC + 'CargaNCDT(CveVentaNC, Importe.ToDecimal) + Return DtImpuestosLocal + End Function + + Private Function CargaTotalesImpuestos(DtImpuestos As DataTable) As DataTable + Dim query = From dr In DtImpuestos + Group By PorcentajeIVA = dr("PorcentajeIVA").ToString.ToDecimal, + PorcentajeRetIVA = dr("PorcentajeRetIVA").ToString.ToDecimal, + PorcentajeRetISR = dr("PorcentajeRetISR").ToString.ToDecimal, + PorcentajeIEPS = dr("PorcentajeIEPS").ToString.ToDecimal + Into x = Group + Select ImportePU = x.Sum(Function(s) s("ImportePU").ToString.ToDecimal), + ImporteTotal = x.Sum(Function(s) s("ImporteTotal").ToString.ToDecimal), + ImporteIVA = x.Sum(Function(s) Math.Round(s("ImporteIVA").ToString.ToDecimal, 2)), ' Math.Round(s("ImporteIVA").ToString.ToDecimal, 2)) * (1 + PorcentajeIEPS) * PorcentajeIVA, + ImporteRetIVA = x.Sum(Function(s) Math.Round(s("ImporteRetIVA").ToString.ToDecimal, 2)),' Math.Round(s("ImportePU").ToString.ToDecimal, 2)) * PorcentajeRetIVA, + ImporteRetISR = x.Sum(Function(s) Math.Round(s("ImporteRetISR").ToString.ToDecimal, 2)),' Math.Round(s("ImportePU").ToString.ToDecimal, 2)) * PorcentajeRetISR, + ImporteIEPS = x.Sum(Function(s) Math.Round(s("ImporteIEPS").ToString.ToDecimal, 2)), 'Math.Round(s("ImportePU").ToString.ToDecimal, 2)) * PorcentajeIEPS, + PorcentajeIVA = PorcentajeIVA, + PorcentajeRetIVA = PorcentajeRetIVA, + PorcentajeRetISR = PorcentajeRetISR, + PorcentajeIEPS = PorcentajeIEPS + + Return query.QueryToDataTable(False) + End Function + + Protected Function CreaDTDetalleNC() 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("SerieLote", 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)) + TmpDT.Columns.Add("CveVentaDetallePadre", GetType(Integer)) + '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("CantidadFacturadaPed2", 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)) + TmpDT.Columns.Add("EsCargo", GetType(Boolean)) + Return TmpDT + End Function + Private Function InicializaDTVentasNC() As DataTable + Dim DtVentasNC = New DataTable + DtVentasNC.Columns.Add("CveVenta", GetType(Integer)) + DtVentasNC.Columns.Add("Importe", GetType(Decimal)) + DtVentasNC.Columns.Add("FolioFiscal", GetType(String)) + DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "TC", .DataType = GetType(Decimal), .DefaultValue = 1}) + DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "TCCambioValuacion", .DataType = GetType(Decimal), .DefaultValue = 1}) + DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "CveEstatusFactura", .DataType = GetType(Integer), .DefaultValue = -1}) + + Return DtVentasNC + End Function +#End Region + + Private Sub LimpiaCampos() TxtFolio.Text = "" TxtObservaciones.Text = "" diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index f4cac066a..8a00cd0f9 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -6494,7 +6494,7 @@ Partial Class Ventas 'Valida si en caso de que el detalle tenga llantas o polizas se agreguén kilometraje/serie en la parte de observaciones(solo para el caso de empresas llanteras) If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then - If txtkilometraje.text.toentero = 0 Then + If TxtKilometraje.Text.ToEntero = 0 Then 'cuando es la clasificacion de llantas Dim FaltaObservacion As Integer = TmpDT.FiltroPrimeroValor("CveClasificacion", "CveClasificacion = 20342").ToEntero If FaltaObservacion = 20342 Then @@ -6913,8 +6913,7 @@ Partial Class Ventas 'ENVIAR POLIZA VIRTUAL If ErrorList.Count = 0 Then If UsuarioActual.Empresa.Funcionalidad(576) = "1" Then - Dim TipoPoliza As Integer = 1 - GeneraPolizaVentaWS(ObjFactura, TipoPoliza) + GeneraPolizaVentaWS(ObjFactura) End If End If @@ -9167,7 +9166,7 @@ Partial Class Ventas CveVentaRelacion:=(If(factura.CveVentaRelacion.ToEntero > 0, factura.CveVentaRelacion, -1)), ImporteRelacion:=(If(factura.ImporteRelacion <> Nothing, factura.ImporteRelacion, -1)), CveTipoAmortizacionAnticipo:=factura.CveTipoAmortizacionAnticipo, CveEmpresaCRM:=CveEmpresaCRM, EsInterno:=EsInterno, CveAcercamientoCRM:=CveAcercamientoCRM, DiasCredito:=factura.DiasCredito, EsDiasCreditoFijo:=factura.EsDiasCreditoFijo, AnticipoEspecial:=If(TrAntEspecial.Visible, ChkAntEspecial.Checked, False), - Kilometraje:=TxtKilometraje.Text.todouble) Then + Kilometraje:=TxtKilometraje.Text.ToDouble) Then ErrorList.Add("Ocurrió un error al Generar la Venta.
    Revise su factura y cualquier detalle comuníquese a Soporte Técnico") @@ -10773,7 +10772,7 @@ Partial Class Ventas Exit For End If - If UsuarioActual.CveEmpresa.Contiene({72, 80, 119}) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing") Then + If UsuarioActual.CveEmpresa.Contiene({72, 80, 119}) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing") AndAlso Dr("EntregaDirecta").ToString.ToEntero < 1 Then Existencia = ObjInventario.GetExistenciasPS(CveProducto, CveUnidad, UsuarioActual.CveEmpresa, CveAlmacen, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero, CveVendedor:=DdlVendedor.SelectedValue.ToEntero, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeAdelantado:=1, RestringirAlmacenes:=1, ExcluyeApartados:=1) If Existencia < Cantidad Then OcurrioError = True @@ -15478,7 +15477,7 @@ Partial Class Ventas If ConSalida AndAlso Not OcurrioError Then If UsuarioActual.Empresa.Funcionalidad(573) = "1" Then - OcurrioError = GenerarMovimientoAlmacenVirtual(CveRemision, ObjInventario, ObjFactura) + OcurrioError = Not GenerarMovimientoAlmacenVirtual(CveRemision, ObjInventario, ObjFactura) End If If Not OcurrioError Then @@ -15803,7 +15802,7 @@ Partial Class Ventas OcurrioError = True End Try - Return OcurrioError + Return Not OcurrioError End Function Private Function SalidaAlmacenMateriales(ByRef ObjInventario As ClsInventarios, CveOS As Integer, ByRef ObjConta As ClsContabilidad, ConSalida As Boolean, ConceptoMovimiento As Integer) As Boolean @@ -23937,23 +23936,22 @@ Partial Class Ventas GvCodigosUnicos.DataBind() End If End Sub - Protected Sub GeneraPolizaVentaWS(ObjFactura As Modelos.Factura, TipoPoliza As Integer) - 'TipoPoliza: 01 Venta, 02 Ajuste, 03 Garantía + Protected Sub GeneraPolizaVentaWS(ObjFactura As Modelos.Factura) Try For Each Row As GridViewRow In GvCodigosUnicos.Rows If Row.RowType = DataControlRowType.DataRow Then Dim obj As New Modelos.MPolizaVentaWS 'DATOS DEL CLIENTE obj.customer_name = ObjFactura.Cliente.Nombre - obj.customer_last_name1 = "." + obj.customer_last_name1 = "" obj.customer_last_name2 = "" obj.customer_birthday = Nothing obj.customer_phone = ObjFactura.Cliente.Telefono obj.customer_email = ObjFactura.Cliente.Mail obj.customer_gender = "03" 'OTRO GENERO obj.customer_advertising = False - obj.customer_car_brand = "01" - obj.customer_car_model = "01" + obj.customer_car_brand = "00" + obj.customer_car_model = "00" obj.customer_car_year = ObjFactura.Fecha.Year 'DATOS DE VENTA @@ -23963,12 +23961,12 @@ Partial Class Ventas obj.sale_type_service = "02" 'COMERCIAL obj.sale_total = ObjFactura.Total obj.sale_discount = ObjFactura.Descuento - obj.sale_id = ObjFactura.CveVenta.ToString + obj.sale_id = String.Format("{0}{1}{2}", ObjFactura.Serie, ObjFactura.Folio, ObjFactura.CveVenta) 'DATOS DEL PRODUCTO obj.product_code = Row.DataKey("IdProductoPolizaVirtual").ToString() obj.product_unique_code = Row.FCTextBox("TxtCodigoUnico").Text 'se indique el código único de la batería. (SERIE LOTE) - obj.product_sale_type = "0" & TipoPoliza 'VENTA + obj.product_sale_type = "01 " 'VENTA Dim FechaUsado As DateTime = Row.DataKey("FechaAjuste").ToString().ToDateTime()