From 5c50de629dba399a5f8b898217719e5579773c77 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Thu, 17 Dec 2020 15:04:34 -0700 Subject: [PATCH 1/5] Cambios en NC --- App_Code/ClsAcumuladores.vb | 4 +- App_Code/Modelos.vb | 2 +- Ventas/Ventas.aspx | 35 ++--- Ventas/Ventas.aspx.vb | 278 +++++++++++++++++++++++++++++++----- 4 files changed, 264 insertions(+), 55 deletions(-) diff --git a/App_Code/ClsAcumuladores.vb b/App_Code/ClsAcumuladores.vb index d7134d6b8..c37e75652 100644 --- a/App_Code/ClsAcumuladores.vb +++ b/App_Code/ClsAcumuladores.vb @@ -898,7 +898,7 @@ Public Class ClsAcumuladores End Function #End Region - Public Function DistribuidorMovtosAdd(CveCliente As Integer, Cantidad As Integer, CveTamaño As Integer, CveConcepto As Integer, CveVenta As Integer, CveUsuario As Integer, + Public Function DistribuidorMovtosAdd(CveCliente As Integer, Cantidad As Decimal, CveTamaño As Integer, CveConcepto As Integer, CveVenta As Integer, CveUsuario As Integer, CveEmpresa As Integer, ImporteCompras As Decimal, Observaciones As String, Optional CveMovimiento As Integer = -1) As Boolean Dim Retorno As Boolean = False 'Data = New DataTable @@ -907,7 +907,7 @@ Public Class ClsAcumuladores With SqlAdapter.SelectCommand.Parameters .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@Cantidad", SqlDbType.Int).Value = Cantidad + .Add("@Cantidad", SqlDbType.Decimal).Value = Cantidad .Add("@CveTamaño", SqlDbType.Int).Value = CveTamaño .Add("@CveConcepto", SqlDbType.Int).Value = CveConcepto .Add("@CveVenta", SqlDbType.Int).Value = CveVenta diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 2a0131d71..bbe9ae2b3 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -5129,7 +5129,7 @@ Namespace Modelos For Each RowUsado As DataRow In DtPSVirtual.Rows Dim CvePS = RowUsado("CvePS").ToString().ToEntero() Dim CantidadUsado As Double = RowUsado("Cantidad").ToString().ToDouble() - Dim PU As Decimal = RowUsado("PUOriginal").ToString().ToDecimal() + Dim PU As Decimal = RowUsado("Cargo").ToString().ToDecimal() Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero() If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU, -1) Then diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 08553cbad..ccd51ab6e 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -4570,7 +4570,7 @@
Contrato:
- +
Moneda:
@@ -6038,6 +6038,15 @@

-
-
-
-
- - -
-
-
@@ -7235,13 +7235,14 @@ TxtImporte.value = FormatoNumero(Saldo, 2); } } else { - if (SaldoMaximoUtilizable > 0) { - TxtImporte.value = ""; - Chk.checked = false; - } else { - TxtImporte.value = FormatoNumero(Saldo, 2); - } - + TxtImporte.value = ""; + Chk.checked = false; + //if (SaldoMaximoUtilizable > 0) { + // TxtImporte.value = ""; + // Chk.checked = false; + //} else { + // TxtImporte.value = FormatoNumero(Saldo, 2); + //} } } else { diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 215665354..70a6134cf 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -2721,7 +2721,7 @@ Partial Class Ventas ImgOtrosConceptos.Visible = False TrFormaEntrega.Visible = False TabDetalleVentas.Visible = False - TabE.Visible = False + 'TabE.Visible = False LnkOCs.Visible = False GvPS.Columns(8).Visible = False TrEdit.Visible = True @@ -3526,6 +3526,8 @@ Partial Class Ventas End If End If + CalculaUsados() + CalculaTotalesVenta() LbAgregar.Visible = False UpPS.Update() @@ -5690,7 +5692,7 @@ Partial Class Ventas DivVentasUsados.Visible = True Dim ObjClientes As New ClsClientes - If ObjClientes.GetHistorialVentas(CveCliente, 1000, CveClienteSucursal:=-1, TipoDocto:="Ing", CveEstatusFactura:=-1, FechaI:=Now.AddMonths(-1)) Then + If ObjClientes.GetHistorialVentas(CveCliente, CveClienteSucursal:=-1, TipoDocto:="Ing", CveEstatusFactura:=-1, FechaI:=Now.AddMonths(-1)) Then DdlVentaUsado.DataSource = ObjClientes.DtResultados.FiltraParametros("UsadoMarcado = 0") End If ObjClientes.Dispose() @@ -5789,7 +5791,7 @@ Partial Class Ventas UpFacturasRelacionadas.Update() End Sub Protected Sub CreaTmpFacturasRelacionadas() - If CveVenta <= 0 Then + If CveVenta <= 0 OrElse EsCreaApartirDe Then Me.TmpDTFacturasRelacionadas = New DataTable() Me.TmpDTFacturasRelacionadas.Columns.Add(New DataColumn("CveVenta", GetType(Integer))) Me.TmpDTFacturasRelacionadas.Columns.Add(New DataColumn("SerieFolio", GetType(String))) @@ -5797,7 +5799,7 @@ Partial Class Ventas End If End Sub Protected Sub LnkAgregarFacturaRelacionada_Click(sender As Object, e As EventArgs) - If CveVenta <= 0 Then + If CveVenta <= 0 OrElse EsCreaApartirDe Then If Me.TmpDTFacturasRelacionadas Is Nothing Then CreaTmpFacturasRelacionadas() End If @@ -5827,7 +5829,7 @@ Partial Class Ventas End Sub Protected Sub BtnAgregarFacturasRelaciondas_Click(sender As Object, e As EventArgs) - If CveVenta <= 0 Then + If CveVenta <= 0 OrElse EsCreaApartirDe Then If Me.TmpDTFacturasRelacionadas Is Nothing OrElse Me.TmpDTFacturasRelacionadas.Rows.Count = 0 Then Me.AplicaRelacionManual = False Alert("No hay facturas para relacionar", TipoMensaje.MsgAdvertencia) @@ -7002,7 +7004,7 @@ Partial Class Ventas End If If (CveVenta > 0 And DdlTipoComprobante.SelectedValue <> "Cot") AndAlso Not AplicaDevolucion Then - If e.Row.DBCampo("CveConcepto").ToEntero() = 3 Then CveAlmacenDevolucion = e.Row.DBCampo("CveAlmacen").ToEntero() + If e.Row.DBCampo("CveConcepto").ToEntero().Contiene(3, 40) Then CveAlmacenDevolucion = e.Row.DBCampo("CveAlmacen").ToEntero() e.Row.FCCheckBox("cbInv").Visible = False End If @@ -8197,7 +8199,7 @@ Partial Class Ventas 'MUESTA ALERT OK ' si es elrol 1165-Ventas,EMp:80, o la empresa 119, recarga ventas, para seguir registrando-. - Dim Liga = If(UsuarioActual.CveRol = 1165 Or UsuarioActual.CveEmpresa = 119, "document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";", If(CveEmpresaCRM > 0, $"document.location.href=""/CRM/EmpresaCRM.aspx?CveEmpresaCRM={CveEmpresaCRM}"";", $"document.location.href=""/Ventas/Clientes.aspx?CveCliente={CveCliente}&Opt=3"";")) + Dim Liga = If(UsuarioActual.CveRol = 1165 Or UsuarioActual.CveEmpresa = 119, "document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";", If(CveEmpresaCRM > 0, $"document.location.href=""/CRM/EmpresaCRM.aspx?CveEmpresaCRM={CveEmpresaCRM}"";", $"document.location.href=""/Ventas/Clientes.aspx?CveCliente={CveCliente}&Opt=2"";")) Alert(MensajeAlert.ToString(), TipoMensaje.MsgInformacion, Liga) MensajeAlert.Clear() @@ -9677,7 +9679,7 @@ Partial Class Ventas If ObjFolios.GetFolios(TipoDoctoConsulta, UsuarioActual.CveEmpresa) Then Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format(" CveSubProyecto = {0} And Estado = 'Activo'", DdlSubProyectoDatos.SelectedValue)) If DT.Rows.Count > 0 Then - ObjFactura.Serie = DT.Rows(0)("Serie").ToString() + ObjFacturaDevolucion.Serie = DT.Rows(0)("Serie").ToString() End If DT.Dispose() End If @@ -10736,9 +10738,34 @@ Partial Class Ventas 'SI SE FACTURA UNA RNC SE MUESTRA If UsuarioActual.CveEmpresa = 140 AndAlso factura.TipoDocto = "Egs" Then If Row("CveVentaDetalleRNC").ToString().ToEntero() > 0 Then + If Not ObjVentas.AddVentaDetalleRNCFacturada(Row("CveVentaDetalleRNC").ToString().ToEntero(), ObjVentas.CveVentaDetalle, Row("Cantidad").ToString().ToDecimal()) Then ErrorList.Add("Ocurrió un error al agregar la venta detalle devolución.") End If + + 'SI SE FACTURAN RNC DE CARGO, SE AGREGA EL CONCEPTO DE ACREDITAMIENTO + If ClienteEsDistribuidor AndAlso RblRNCTipo.SelectedValue = "1" Then + Dim ObjAcum As New ClsAcumuladores(ObjVentas.IniciaTransacSQL()) + + Dim CvePSCargo As Integer = -1 + For Each RNC In ListaRemisionesNC + CvePSCargo = RNC.DtDetalle.FiltroPrimeroValor("CvePS", $"CveVentaDetalle={Row("CveVentaDetalleRNC").ToString()}").ToEntero() + If CvePSCargo > 0 Then + Exit For + End If + Next + + Dim CveTamanio As Integer = GlobalDTAcumTamaños().FiltroPrimeroValor("CveTamaño", $"CvePSCargo={CvePSCargo}").ToEntero() + + If CveTamanio > 0 Then + If Not ObjAcum.DistribuidorMovtosAdd(factura.CveCliente, Row("Cantidad").ToString().ToDecimal(), CveTamanio, 6, factura.CveVenta, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0D, "") Then + ErrorList.Add("Ocurrió un error al agregar la venta detalle devolución.") + Exit For + End If + End If + + End If + End If End If @@ -14666,7 +14693,7 @@ Partial Class Ventas 'MUESTA Alert OK 'MensajeAlert.Append("El Documento se generó correctamente") - Dim Liga = If(UsuarioActual.CveRol = 1165, "document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";", $"document.location.href=""/Ventas/Clientes.aspx?CveCliente={CveCliente}&Opt=3"";") + Dim Liga = If(UsuarioActual.CveRol = 1165, "document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";", $"document.location.href=""/Ventas/Clientes.aspx?CveCliente={CveCliente}&Opt=2"";") Alert(MensajeAlert.ToString(), TipoMensaje.MsgInformacion, Liga) TrEmitir.Visible = False @@ -15728,7 +15755,13 @@ Partial Class Ventas TrVistaPrevia.Visible = True UpFacturar.Update() Else - Alert("No tiene registrados Folios para " & DdlTipoComprobante.SelectedItem.Text & " en esta sucursal.", TipoMensaje.MsgAdvertencia) + + If DdlTipoComprobante.Items.Count > 0 Then + Alert("No tiene registrados Folios para " & DdlTipoComprobante.SelectedItem.Text & " en esta sucursal.", TipoMensaje.MsgAdvertencia) + Else + Alert("No tiene permisos para generar ningun tipo de documento.", TipoMensaje.MsgAdvertencia) + End If + TrEmitir.Visible = False TrVistaPrevia.Visible = False BtnCrearApartirDe.Enabled = False @@ -17718,6 +17751,7 @@ Partial Class Ventas DtRemConceptosSurtidos = Nothing Dim TieneMovimientosSinCosto As Boolean = False + Dim TieneMovimientosContrato As Boolean = False 'Obtenemos los movimientos detalle If ObjInventario.GetInv_Mov(CveRemision, UsuarioActual.CveEmpresa) Then @@ -17755,6 +17789,8 @@ Partial Class Ventas TieneMovimientosSinCosto = DtMovimientosDetalles.COUNT("CveTipoAlmacen", "CveTipoAlmacen=26") > 0 + TieneMovimientosContrato = DtMovimientosDetalles.COUNT("CveTipoAlmacen", "CveTipoAlmacen IN (11)") > 0 + For Each dr As DataRow In DtMovimientos.Rows 'Obtenemos los Movimientos de salida If ObjInventario.GetMovimientos(dr("CveMovimiento").ToString().ToEntero(), ConceptoMovimiento, -1, UsuarioActual.CveEmpresa) Then @@ -17777,7 +17813,12 @@ Partial Class Ventas If TieneMovimientosSinCosto Then MovDetalle = DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")}") Else - MovDetalle = CuadrarFacturaMovimientos(DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")} AND (TieneSalidaxFactura IS NULL OR SaldoAlmacen > 0)")) + If TieneMovimientosContrato Then + MovDetalle = CuadrarFacturaMovimientos(DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")}")) + Else + MovDetalle = CuadrarFacturaMovimientos(DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")} AND (TieneSalidaxFactura IS NULL OR SaldoAlmacen > 0)")) + End If + End If Else MovDetalle = DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")}") @@ -17831,10 +17872,6 @@ Partial Class Ventas 'Le damos salida normal If ConSalida AndAlso Not OcurrioError Then - If UsuarioActual.Empresa.Funcionalidad(573) = "1" Then - OcurrioError = Not GenerarMovimientoAlmacenVirtual(CveRemision, ObjInventario, ObjFactura, ObjConta:=ObjConta) - End If - If Not OcurrioError Then GeneroMovimientoAlmacen = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenParaSalida, CveConceptoSalidaAlmacen, CveMoneda, ObjFactura.CveVenta, AplicaMovimientoDetalleEntrada:=AplicaMovimientoDetalleEntrada, MovimientoPrePoliza:=True, ObjConta:=ObjConta) > 0 @@ -17842,6 +17879,10 @@ Partial Class Ventas OcurrioError = True Exit For End If + + If Not OcurrioError AndAlso UsuarioActual.Empresa.Funcionalidad(573) = "1" Then + OcurrioError = Not GenerarMovimientoAlmacenVirtual(CveRemision, ObjInventario, ObjFactura, ObjConta:=ObjConta) + End If End If End If @@ -18215,26 +18256,43 @@ Partial Class Ventas Dim CveConceptoMovimientoVirtual As Integer = 37 Dim DtPSVirtual As DataTable = Nothing Dim DtTamanios As DataTable = Nothing - Dim CveMovimientoEntradaDev As Integer = -1 - Dim CveSubProyecto As Integer = -1 + Dim CveMovimientoReferencia As Integer = -1 + 'SI LA REMISION SE SURTIO CON USADOS UTILIZAR ESTE MOVIMIENTO If ObjInventario.GetInv_Mov(CveRemision, UsuarioActual.CveEmpresa) Then - Dim RowMovimiento As DataRow = ObjInventario.DtResultados.FiltroPrimero("CvePS IS NULL AND ((CveTipoAlmacen = 24 AND CveConcepto = 2) OR (CveTipoAlmacen = 1 AND CveConcepto = 8)) AND CveVenta > 0") + Dim RowMovimiento As DataRow = ObjInventario.DtResultados.FiltroPrimero("CvePS IS NULL AND (CveTipoAlmacen = 24 AND CveConcepto = 2) AND CveVenta > 0") If RowMovimiento IsNot Nothing Then - CveMovimientoEntradaDev = RowMovimiento("CveMovimiento").ToString().ToEntero() + CveMovimientoReferencia = RowMovimiento("CveMovimiento").ToString().ToEntero() Dim tCveAlmacen = RowMovimiento("CveAlmacen").ToString().ToEntero() - CveSubProyecto = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen= {tCveAlmacen}").ToEntero() CveAlmacenVirtual = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=tCveAlmacen).FiltroPrimeroValor("CveAlmacenVirtual").ToEntero() - - Else - OcurrioError = True End If Else OcurrioError = True End If - If ObjInventario.GetMovimientosDetalleVirtual(CveMovimientoEntradaDev, UsuarioActual.CveEmpresa) Then + + 'SI NO SE SURTIO LA REMSION CON USADOS, UTILIZAR EL MOVIMIENTO DE SALIDA DEL INGRESO + If CveMovimientoReferencia <= 0 Then + If ObjInventario.GetInv_Mov(ObjFactura.CveVenta, UsuarioActual.CveEmpresa) Then + Dim RowMovimiento As DataRow = ObjInventario.DtResultados.FiltroPrimero("CvePS IS NULL AND ( (CveTipoAlmacen = 1 AND CveConcepto = 3) OR (CveTipoAlmacen = 10 AND CveConcepto = 40) ) AND CveVenta > 0") + + If RowMovimiento IsNot Nothing Then + CveMovimientoReferencia = RowMovimiento("CveMovimiento").ToString().ToEntero() + Dim tCveAlmacen = RowMovimiento("CveAlmacen").ToString().ToEntero() + CveAlmacenVirtual = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=tCveAlmacen).FiltroPrimeroValor("CveAlmacenVirtual").ToEntero() + + Else + OcurrioError = True + End If + + Else + OcurrioError = True + End If + End If + + + If ObjInventario.GetMovimientosDetalleVirtual(CveMovimientoReferencia, UsuarioActual.CveEmpresa) Then DtPSVirtual = ObjInventario.DtResultados.Copy() Else OcurrioError = True @@ -18242,13 +18300,13 @@ Partial Class Ventas If Not OcurrioError AndAlso DtPSVirtual.Rows.Count > 0 Then - CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, CveConceptoMovimientoVirtual, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, ObjFactura.CveVenta, -1, -1, Modulo:="Vta/VV", CveMovimientoRelacionado:=CveMovimientoEntradaDev) + CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, CveConceptoMovimientoVirtual, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, ObjFactura.CveVenta, -1, -1, Modulo:="Vta/VV", CveMovimientoRelacionado:=CveMovimientoReferencia) If CveMovimientoVirtual > 0 Then For Each RowUsado As DataRow In DtPSVirtual.Rows Dim CvePS = RowUsado("CvePS").ToString().ToEntero() Dim CantidadUsado As Double = RowUsado("Cantidad").ToString().ToDouble() - Dim PU As Decimal = RowUsado("PU").ToString().ToDecimal() + Dim PU As Decimal = RowUsado("Cargo").ToString().ToDecimal() Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero() If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU, -1) Then @@ -18318,6 +18376,123 @@ Partial Class Ventas OcurrioError = True End Try + Return Not OcurrioError + + End Function + Private Function GenerarMovimientoAlmacenVirtualConsignacion(CveVenta As Integer, CveAlmacenContrato As Integer, ByRef ObjInventario As ClsInventarios, ObjFactura As Modelos.Factura, Optional ByRef ObjConta As ClsContabilidad = Nothing) As Boolean + Dim OcurrioError As Boolean = False + + If UsuarioActual.Empresa.Funcionalidad(573) = "1" Then + Try + Dim CveMovimientoVirtual As Integer = -1 + Dim CveAlmacenVirtual As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=CveAlmacenContrato).FiltroPrimeroValor("CveAlmacenVirtual").ToEntero() + + Dim CveConceptoMovimientoVirtual As Integer = 37 + Dim DtPSVirtual As DataTable = Nothing + Dim DtTamanios As DataTable = Nothing + Dim CveMovimientoReferencia As Integer = -1 + Dim CveSubProyecto As Integer = -1 + + + If ObjInventario.GetInv_Mov(CveVenta, UsuarioActual.CveEmpresa) Then + Dim RowMovimiento As DataRow = ObjInventario.DtResultados.FiltroPrimero("CvePS IS NULL AND ((CveTipoAlmacen = 24 AND CveConcepto = 2) OR (CveTipoAlmacen = 17 AND CveConcepto = 8)) AND CveVenta > 0") + + If RowMovimiento IsNot Nothing Then + CveMovimientoReferencia = RowMovimiento("CveMovimiento").ToString().ToEntero() + Else + OcurrioError = True + End If + + Else + OcurrioError = True + End If + + If ObjInventario.GetMovimientosDetalleVirtual(CveMovimientoReferencia, UsuarioActual.CveEmpresa) Then + DtPSVirtual = ObjInventario.DtResultados.Copy() + Else + OcurrioError = True + End If + + If Not OcurrioError AndAlso DtPSVirtual.Rows.Count > 0 Then + + CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, CveConceptoMovimientoVirtual, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, ObjFactura.CveVenta, -1, -1, Modulo:="Vta/VV", CveMovimientoRelacionado:=CveMovimientoReferencia) + + If CveMovimientoVirtual > 0 Then + For Each RowUsado As DataRow In DtPSVirtual.Rows + Dim CvePS = RowUsado("CvePS").ToString().ToEntero() + Dim CantidadUsado As Double = RowUsado("Cantidad").ToString().ToDouble() + Dim PU As Decimal = RowUsado("Cargo").ToString().ToDecimal() + Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero() + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU, -1) Then + OcurrioError = True + Exit For + End If + Next + Else + OcurrioError = True + End If + + 'Agregamos las PrePolizas + If Not OcurrioError Then + If CveMovimientoVirtual > 0 Then + 'OcurrioError = Not GeneraPrePolizaMovimientoAlmacen(ObjInventario, ObjConta, ObjContPaq, ObjFactura, ObjFactura.CvePrePoliza, CveMovimientoInventario, CveAlmacen) + If ObjInventario.GetMovimientosDetalle(CveMovimientoVirtual, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then + Dim DtCostos = ObjInventario.DtResultados.Copy + Dim DtCostosDistinct As DataTable = ObjInventario.DtResultados.FiltraParametros("", "", {"CveClasificacion"}) + Dim IdCtaContable As Integer = 0 + Dim CveCuenta As Integer = 0 + Dim ValorInventario As Decimal + Dim TotalCostoAcumulado As Decimal = 0D + Dim Cont As Integer = 1 + Dim TotalCosto As Decimal = DtCostos.SUMD("Total").RoundSQL + + For Each RowInv As DataRow In DtCostosDistinct.Rows + ValorInventario = DtCostos.SUMD("Total", String.Format("CveClasificacion = {0}", RowInv("CveClasificacion"))).RoundSQL + IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero() + CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero() + TotalCostoAcumulado += ValorInventario + + 'cuando es el último movimiento y hay diferencias en los importes + If Cont = DtCostosDistinct.Rows.Count AndAlso TotalCosto <> TotalCostoAcumulado Then + ValorInventario = ValorInventario + (TotalCosto - TotalCostoAcumulado) + End If + + Try + 'If ValorInventario <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, ValorInventario, ObjFactura.SerieFolio, 69, ObjFactura.SerieFolio, ObjFactura.Fecha, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=ObjFactura.CveCliente, CveClasificacion:=RowInv("CveClasificacion").ToString().ToEntero(), CveMovimientoAlmacen:=CveMovimientoVirtual, ImporteMX:=ValorInventario, CveCuenta:=CveCuenta, CveSubProyecto:=ObjFactura.CveSubProyecto) Then + OcurrioError = True + Exit For + End If + 'End If + Catch ex As Exception + OcurrioError = True + Alert("Error inesperado (15148). Por favor comuniquese con atención SIG.", TipoMensaje.ToastError) + End Try + Cont += 1 + Next + + If Not OcurrioError Then + IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", CveAlmacenVirtual)).ToEntero() + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, TotalCosto, ObjFactura.SerieFolio, 68, ObjFactura.SerieFolio, ObjFactura.Fecha, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=ObjFactura.CveCliente, CveMovimientoAlmacen:=CveMovimientoVirtual, ImporteMX:=TotalCosto, CveCuenta:=CveCuenta, CveSubProyecto:=ObjFactura.CveSubProyecto) Then + OcurrioError = True + End If + End If + Else + OcurrioError = True + End If + End If + End If + + End If + + Catch ex As Exception + OnError("Ocurrió un error al generar el almacen virtual.", ex) + OcurrioError = True + End Try + End If + + Return Not OcurrioError End Function @@ -22349,7 +22524,7 @@ Partial Class Ventas Dim CveUnidad As Integer Dim Cantidad As Double Dim Existencia As Double - For Each Dr As DataRow In TmpDT.Rows + For Each Dr As DataRow In TmpDT.FiltraParametros("CveTipoPS=2").Rows CveProducto = Dr("CvePS").ToString().ToEntero() CveUnidad = Dr("CveUM").ToString().ToEntero() Cantidad = Dr("Cantidad").ToString().ToDouble @@ -22443,6 +22618,11 @@ Partial Class Ventas End If + If Not GenerarMovimientoAlmacenVirtualConsignacion(factura.CveVenta, CveAlmacenExistenciasContrato, ObjInventario, factura, ObjConta) Then + Return False + End If + + Return True End Function @@ -23910,10 +24090,18 @@ Partial Class Ventas If ObjAcum.GetMovimientosDistribuidorResumen(CveCliente, UsuarioActual.CveEmpresa) Then Dim RowUsadosNC As DataRow = ObjAcum.DtResultados.Rows(2) DivSMU.Visible = True - HdnSaldoMaximoUsados.Value = RowUsadosNC("ValorConImpuestos").ToString() - LtlSMU.Text = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal().FormatoNumero(2) + + Dim SaldoMaximo As Decimal = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal() + If SaldoMaximo > 0 Then + HdnSaldoMaximoUsados.Value = RowUsadosNC("ValorConImpuestos").ToString() + LtlSMU.Text = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal().FormatoNumero(2) + Else + HdnSaldoMaximoUsados.Value = "0" + LtlSMU.Text = "0" + End If + Else - DivSMU.Visible = False + 'DivSMU.Visible = False HdnSaldoMaximoUsados.Value = "0" LtlSMU.Text = "0" End If @@ -23953,8 +24141,15 @@ Partial Class Ventas DivSMU.Visible = True Dim FacUsado As New Modelos.Factura(UsuarioActual, CveVentaUsado, UsuarioActual.CveEmpresa) Dim SaldoMaximoUsados As Decimal = FacUsado.DtDetalle.SUM("Total", "EsCargo = True").ToDecimal() + FacUsado.DtDetalle.SUM("ImporteIVA", "EsCargo = True").ToDecimal() - HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString() - LtlSMU.Text = String.Format("{0:N2}", SaldoMaximoUsados) + + If SaldoMaximoUsados > 0 Then + HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString() + LtlSMU.Text = String.Format("{0:N2}", SaldoMaximoUsados) + Else + HdnSaldoMaximoUsados.Value = "0" + LtlSMU.Text = "0" + End If + Else Dim ObjAcum As New ClsAcumuladores If ObjAcum.GetMovimientosDistribuidorResumen(CveCliente, UsuarioActual.CveEmpresa) Then @@ -23963,7 +24158,7 @@ Partial Class Ventas HdnSaldoMaximoUsados.Value = RowUsadosNC("ValorConImpuestos").ToString() LtlSMU.Text = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal().FormatoNumero(2) Else - DivSMU.Visible = False + 'DivSMU.Visible = False HdnSaldoMaximoUsados.Value = "0" LtlSMU.Text = "0" End If @@ -23995,9 +24190,14 @@ Partial Class Ventas GvDescNCBonificaciones.DataBind() Dim SaldoMaximoUsados As Decimal = Me.TmpDT.SUM("Total", "EsCargo = True").ToDecimal() + Me.TmpDT.SUM("ImporteIVA", "EsCargo = True").ToDecimal() + If SaldoMaximoUsados > 0 Then + LblSaldoMaximoUsados.Text = String.Format("{0:N2}", SaldoMaximoUsados) + HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString() + Else + HdnSaldoMaximoUsados.Value = "0" + LtlSMU.Text = "0" + End If - LblSaldoMaximoUsados.Text = String.Format("{0:N2}", SaldoMaximoUsados) - HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString() UpDescNC.Update() End Sub @@ -27301,6 +27501,13 @@ Partial Class Ventas BloqueaCondiconesPago() + + DivDdlFacturaRela.Visible = True + BtnAgregarFacturasRelaciondas.Visible = True + DdlTipoRelacionARelacionar.Enabled = True + + GvFacturasRelacionadas.Columns(2).Visible = True + UpnTools.Update() UpCliente.Update() UpParametros.Update() @@ -27313,6 +27520,7 @@ Partial Class Ventas UpEstatus.Update() UpParametros.Update() UpINV.Update() + UpFacturasRelacionadas.Update() End Sub #End Region From 3efa6e6af000edf6ea4349ba96fb8e3229e98797 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Thu, 17 Dec 2020 15:05:20 -0700 Subject: [PATCH 2/5] Cambios en virtuales --- Inventarios/EntregaAlmacen.aspx.vb | 2 +- Inventarios/RecepcionAlmacen.aspx.vb | 62 ++++++++++++- Inventarios/TraspasoAlmacen.aspx.vb | 132 +++++++++++++-------------- 3 files changed, 126 insertions(+), 70 deletions(-) diff --git a/Inventarios/EntregaAlmacen.aspx.vb b/Inventarios/EntregaAlmacen.aspx.vb index 1ec5937e6..d0f0ebb22 100644 --- a/Inventarios/EntregaAlmacen.aspx.vb +++ b/Inventarios/EntregaAlmacen.aspx.vb @@ -2709,7 +2709,7 @@ Partial Class Inventarios_EntregaAlmacen For Each RowUsado As DataRow In DtPSVirtual.Rows Dim CvePS = RowUsado("CvePS").ToString().ToEntero() Dim CantidadUsado As Double = RowUsado("Cantidad").ToString().ToDouble() - Dim PU As Decimal = RowUsado("PU").ToString().ToDecimal() + Dim PU As Decimal = RowUsado("Cargo").ToString().ToDecimal() Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero() If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU) Then diff --git a/Inventarios/RecepcionAlmacen.aspx.vb b/Inventarios/RecepcionAlmacen.aspx.vb index 579a324c4..682d9e172 100644 --- a/Inventarios/RecepcionAlmacen.aspx.vb +++ b/Inventarios/RecepcionAlmacen.aspx.vb @@ -2377,7 +2377,7 @@ Partial Class Inventarios_RecepcionAlmacen Dim CveVendedorActual = -1 Dim CveClienteActual = -1 - Dim CveAlmacenDestino = CveAlmacen + Dim CveAlmacenDestino = CveAlmacenDevolucionProveedor Dim CveSeccionDestino As Integer = -1 'For Each RowAlmacen As DataRow In DtAlmacenesDevolucion.FiltraParametros("", DistinctColumns:={"CveAlmacenOrignal"}).Rows @@ -2884,6 +2884,66 @@ Partial Class Inventarios_RecepcionAlmacen End If Next End If + + If SumarImporteUsados Then + If ObjInventario.GetMovimientosDetalle(CveMovimientoVirtual, UsuarioActual.CveEmpresa) Then + ImporteIngresoAdicional = ObjInventario.DtResultados.SUMD("TotalOriginal") + End If + End If + + Else + If RealizarMovimientoVirtual Then + + Dim DtPSVirtual As New DataTable("DtTamanios") + + Dim CveMovimientoRef As Integer = -1 + If RealizarTraspasoAlmacenDevolucion Then + CveMovimientoRef = CveMovimientoSalidaTraspaso + Else + CveMovimientoRef = CveMovimiento + End If + + If ObjInventario.GetMovimientosDetalleVirtual(CveMovimientoRef, UsuarioActual.CveEmpresa) Then + DtPSVirtual = ObjInventario.DtResultados + End If + + If DtPSVirtual IsNot Nothing AndAlso DtPSVirtual.Rows.Count > 0 Then + + Dim CveTipoAlmacenFiltro As Integer = 24 + + Dim CveAlmacenVirtual As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacen.SelectedValue.ToEntero()).FiltroPrimeroValor("CveAlmacenVirtual").ToEntero() + + CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, 13, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompraSurtir, -1, -1, -1, CveMovimientoRelacionado:=CveMovimientoRef, Observaciones:=TxtObservaciones.Text.Trim, Modulo:="RA/VD") + + If CveMovimientoVirtual > 0 Then + FolioVirtual = ObjInventario.Folio + + For Each RowUsado As DataRow In DtPSVirtual.Rows + Dim CvePS = RowUsado("CvePS").ToString().ToEntero() + Dim CantidadUsado As Decimal = RowUsado("Cantidad").ToString().ToDecimal() + Dim PU As Decimal = RowUsado("Cargo").ToString().ToDecimal() + Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero() + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU, -1, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + ErrorMovInv = True + Exit For + End If + Next + + If SumarImporteUsados Then + If ObjInventario.GetMovimientosDetalle(CveMovimientoVirtual, UsuarioActual.CveEmpresa) Then + ImporteIngresoAdicional = ObjInventario.DtResultados.SUMD("TotalOriginal") + End If + End If + + Else + ErrorMovInv = True + End If + + Else + ErrorMovInv = True + End If + End If End If End If diff --git a/Inventarios/TraspasoAlmacen.aspx.vb b/Inventarios/TraspasoAlmacen.aspx.vb index 434eaf4fb..baac711d5 100644 --- a/Inventarios/TraspasoAlmacen.aspx.vb +++ b/Inventarios/TraspasoAlmacen.aspx.vb @@ -882,13 +882,13 @@ Partial Class Inventarios_TraspasoAlmacen dtvirtual = ObjInventario.DtResultados If dtvirtual.Rows.Count > 0 Then - CveMovimientoVirtualSalida = ObjInventario.AddMovimiento(CveAlmacenVirtual, 37, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Modulo:="TA/V", CveMovimientoRelacionado:=CveMovimientoSalida) + CveMovimientoVirtualSalida = ObjInventario.AddMovimiento(CveAlmacenVirtualSalida, 37, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Modulo:="TA/V", CveMovimientoRelacionado:=CveMovimientoSalida) FolioVirtualSalida = ObjInventario.Folio For Each RowVirtual As DataRow In dtvirtual.Rows Dim CvePS = RowVirtual("CvePS").ToString().ToEntero() Dim CantidadUsado As Double = RowVirtual("Cantidad").ToString().ToDouble() - Dim PU As Decimal = RowVirtual("PU").ToString().ToDecimal() + Dim PU As Decimal = RowVirtual("Cargo").ToString().ToDecimal() Dim CveUM As Integer = RowVirtual("CveUM").ToString().ToEntero() If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtualSalida, CantidadUsado, CveUM, CvePS, PU, -1, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then @@ -899,7 +899,7 @@ Partial Class Inventarios_TraspasoAlmacen End If Else ErrorMovInv = True - End If + End If End If AlmacenEntrada = If(ChkTransitorio.Checked, DdlAlmacenTransitorio.SelectedValue.ToEntero, DdlAlmacenDestino.SelectedValue.ToEntero) @@ -933,27 +933,23 @@ Partial Class Inventarios_TraspasoAlmacen If Not ChkTransitorio.Checked Then 'SI NO ES TRANSITORIO SE HACE LA RECEPCION DE INMEDIATO If Not ErrorMovInv Then - 'VIRTUAL ENTRADA If RealizarMovimientoVirtual Then - 'Dim CveSubProyecto As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen= {DdlAlmacenDestino.SelectedValue}").ToEntero() - 'SI EL ALMACEN DESTINO ES DE APOPYO LOGISTICO EL ALMACEN VIRTUAL DEBE SER DE APOYO LOGISTICO - Dim CveAlmacenVirtual As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=CveSubProyectoOrigen).FiltroPrimeroValor("CveAlmacenVirtual", "").ToEntero() Dim dtvirtual As DataTable = Nothing If ObjInventario.GetMovimientosDetalleVirtual(CveMovimientoEntrada, UsuarioActual.CveEmpresa) Then dtvirtual = ObjInventario.DtResultados If dtvirtual.Rows.Count > 0 Then ''hay que verificar que se se tengan movimeintos por registrar - CveMovimientoVirtualEntrada = ObjInventario.AddMovimiento(CveAlmacenVirtual, 36, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, CveMovimientoRelacionado:=CveMovimientoEntrada, Modulo:="TA/S3") + CveMovimientoVirtualEntrada = ObjInventario.AddMovimiento(CveAlmacenVirtualEntrada, 36, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, CveMovimientoRelacionado:=CveMovimientoEntrada, Modulo:="TA/S3") FolioVirtualEntrada = ObjInventario.Folio For Each RowVirtual As DataRow In dtvirtual.Rows Dim CvePS = RowVirtual("CvePS").ToString().ToEntero() Dim CantidadUsado As Double = RowVirtual("Cantidad").ToString().ToDouble() - Dim PU As Decimal = RowVirtual("PU").ToString().ToDecimal() + Dim PU As Decimal = RowVirtual("Cargo").ToString().ToDecimal() Dim CveUM As Integer = RowVirtual("CveUM").ToString().ToEntero() If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtualEntrada, CantidadUsado, CveUM, CvePS, PU, -1, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then @@ -965,70 +961,70 @@ Partial Class Inventarios_TraspasoAlmacen Else ErrorMovInv = True - End If - End If - Dim Concepto As String = TxtObservaciones.Text - If Concepto = "" Then Concepto = "Traspaso" - 'AGREGAMOS PREPOLIZAS TRASPASO DIRECTO: - If Not ErrorMovInv Then - Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/TraspasoAlmacen", 53, 0, 0, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - - Dim resultado As DataTable = ObjInventario.DtResultados - Dim importe As Decimal = resultado.SUMD("Total").RoundSQL - 'Dim IdCtaContableSalida As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenOrigen.SelectedValue.ToEntero)).ToEntero - 'Dim IdCtaContableEntrada As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenDestino.SelectedValue.ToEntero)).ToEntero - Dim Contabilizable As Boolean = True - - If IdCtaContableOrigen = IdCtaContableDestino And TipoAlmacenDestino <> 26 Then Contabilizable = False - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContableOrigen, -1, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=Contabilizable, ImporteMX:=importe) Then - ErrorMovInv = True - End If - - 'si el tipo de almacen de entrada es Almacen sin costo, se registra al costo, la salida. - If TipoAlmacenOrigen <> 26 AndAlso TipoAlmacenDestino = 26 Then - - Dim tCveClasificacion As Integer = DtMovimientos.MAX("CveClasificacion").ToEntero - Dim dr As DataRow = GlobalDTClasificaciones(UsuarioActual.CveEmpresa, CveClasificacion:=tCveClasificacion).FiltroPrimero("") - Dim IdCuentaCostos As Integer = -1 - If dr IsNot Nothing Then - IdCuentaCostos = dr("IdCuentaCostos").ToString.ToEntero End If - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, TxtObservaciones.Text, 69, TxtObservaciones.Text, Fecha, IdCuentaCostos, -1, CveClasificacion:=tCveClasificacion, CveSubProyecto:=CveSubProyectoOrigen, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=Contabilizable, ImporteMX:=importe) Then + End If + Dim Concepto As String = TxtObservaciones.Text + If Concepto = "" Then Concepto = "Traspaso" + 'AGREGAMOS PREPOLIZAS TRASPASO DIRECTO: + If Not ErrorMovInv Then + Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/TraspasoAlmacen", 53, 0, 0, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then + + Dim resultado As DataTable = ObjInventario.DtResultados + Dim importe As Decimal = resultado.SUMD("Total").RoundSQL + 'Dim IdCtaContableSalida As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenOrigen.SelectedValue.ToEntero)).ToEntero + 'Dim IdCtaContableEntrada As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenDestino.SelectedValue.ToEntero)).ToEntero + Dim Contabilizable As Boolean = True + + If IdCtaContableOrigen = IdCtaContableDestino And TipoAlmacenDestino <> 26 Then Contabilizable = False + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContableOrigen, -1, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=Contabilizable, ImporteMX:=importe) Then + ErrorMovInv = True + End If + + 'si el tipo de almacen de entrada es Almacen sin costo, se registra al costo, la salida. + If TipoAlmacenOrigen <> 26 AndAlso TipoAlmacenDestino = 26 Then + + Dim tCveClasificacion As Integer = DtMovimientos.MAX("CveClasificacion").ToEntero + Dim dr As DataRow = GlobalDTClasificaciones(UsuarioActual.CveEmpresa, CveClasificacion:=tCveClasificacion).FiltroPrimero("") + Dim IdCuentaCostos As Integer = -1 + If dr IsNot Nothing Then + IdCuentaCostos = dr("IdCuentaCostos").ToString.ToEntero + End If + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, TxtObservaciones.Text, 69, TxtObservaciones.Text, Fecha, IdCuentaCostos, -1, CveClasificacion:=tCveClasificacion, CveSubProyecto:=CveSubProyectoOrigen, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=Contabilizable, ImporteMX:=importe) Then + ErrorMovInv = True + End If + Contabilizable = False + importe = 0 + End If + + If Not ErrorMovInv AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContableDestino, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, Contabilizable:=Contabilizable, ImporteMX:=importe) Then + ErrorMovInv = True + End If + End If + End If + End If + Else + If Not ErrorMovInv Then + Dim Concepto As String = TxtObservaciones.Text + If Concepto = "" Then Concepto = "Traspaso" + Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/TraspasoAlmacen2", 53, 0, 0, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then + + Dim resultado As DataTable = ObjInventario.DtResultados + Dim importe As Decimal = resultado.SUMD("Total").RoundSQL + Dim IdCtaContable As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenTransitorio.SelectedValue.ToEntero)).ToEntero + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoSalida, ImporteMX:=importe, Contabilizable:=False) Then ErrorMovInv = True End If - Contabilizable = False - importe = 0 - End If - If Not ErrorMovInv AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContableDestino, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, Contabilizable:=Contabilizable, ImporteMX:=importe) Then - ErrorMovInv = True + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, ImporteMX:=importe, Contabilizable:=False) Then + ErrorMovInv = True + End If End If End If End If - End If - Else - If Not ErrorMovInv Then - Dim Concepto As String = TxtObservaciones.Text - If Concepto = "" Then Concepto = "Traspaso" - Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/TraspasoAlmacen2", 53, 0, 0, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - - Dim resultado As DataTable = ObjInventario.DtResultados - Dim importe As Decimal = resultado.SUMD("Total").RoundSQL - Dim IdCtaContable As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenTransitorio.SelectedValue.ToEntero)).ToEntero - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoSalida, ImporteMX:=importe, Contabilizable:=False) Then - ErrorMovInv = True - End If - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, ImporteMX:=importe, Contabilizable:=False) Then - ErrorMovInv = True - End If - End If - End If - End If @@ -1945,7 +1941,7 @@ Partial Class Inventarios_TraspasoAlmacen For Each RowVirtual As DataRow In dtvirtual.Rows Dim CvePS = RowVirtual("CvePS").ToString().ToEntero() Dim CantidadUsado As Decimal = RowVirtual("Cantidad").ToString().ToDecimal() - Dim PU As Decimal = RowVirtual("PU").ToString().ToDecimal() + Dim PU As Decimal = RowVirtual("Cargo").ToString().ToDecimal() Dim CveUM As Integer = RowVirtual("CveUM").ToString().ToEntero() If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtualEntrada, CantidadUsado, CveUM, CvePS, PU, -1, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then @@ -2851,7 +2847,7 @@ Partial Class Inventarios_TraspasoAlmacen Private Function ReadExcelFile(ByVal flatFilePath As String, ByVal firstRowHasHeaders As Boolean) As DataTable SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet) - Dim excelFile As ExcelFile = excelFile.Load(flatFilePath) + Dim excelFile As ExcelFile = ExcelFile.Load(flatFilePath) Dim unnamed As Integer = 0 Dim cols As Integer From 8212c08c89dfac18eed7dafff127aaf2ebe5dd92 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Thu, 17 Dec 2020 15:06:50 -0700 Subject: [PATCH 3/5] Cambios API Econo --- Ashx/E141.ashx | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/Ashx/E141.ashx b/Ashx/E141.ashx index 51b154202..ca6e8c319 100644 --- a/Ashx/E141.ashx +++ b/Ashx/E141.ashx @@ -49,7 +49,7 @@ Public Class E141 : Implements IHttpHandler Public ReadOnly Property TokenAutorizacion As String Get If EsProduccion Then - Return "$2y$10$8Mk3YeIkJESilIwD.U5dG.SsA4JloycJKbaGls8TNEw/AKBE1qane" + Return "$2y$10$EZlXnFrhUc4aRVwjy5/v0.3JPdFNjyeANDc64YXJ5eHD8pMsv93Q." Else Return "$2y$10$8Mk3YeIkJESilIwD.U5dG.SsA4JloycJKbaGls8TNEw/AKBE1qane" End If @@ -59,7 +59,7 @@ Public Class E141 : Implements IHttpHandler Public ReadOnly Property URLBase As String Get If EsProduccion Then - Return "https://econollantas-pruebas.fidelityapps.mx" + Return "https://services.fidelityapps.mx/" Else Return "https://econollantas-pruebas.fidelityapps.mx/" End If @@ -92,28 +92,31 @@ Public Class E141 : Implements IHttpHandler Else context.Response.ContentType = "text/html" - Dim FiltrarTodos = If(context.Request("FiltrarTodos") = Nothing, "", context.Request("FiltrarTodos").ToString()) + If Not String.IsNullOrEmpty(Metodo) Then + Dim FiltrarTodos = If(context.Request("FiltrarTodos") = Nothing, "", context.Request("FiltrarTodos").ToString()) - Dim respuesta As Boolean = False + Dim respuesta As Boolean = False - 'TAREAS PROGRAMADAS - Select Case Metodo - Case "CrearActualizarProductos" - respuesta = CrearActualizarProductos(If(FiltrarTodos = "1", True, False)) - Case "ActualizarPrecios" - respuesta = ActualizarPrecios(If(FiltrarTodos = "1", True, False)) - Case "ActualizarExistencias" - respuesta = ActualizarExistencias() - Case "ActualizarVendedores" - respuesta = ActualizarVendedores(If(FiltrarTodos = "1", True, False)) - End Select + 'TAREAS PROGRAMADAS + Select Case Metodo + Case "CrearActualizarProductos" + respuesta = CrearActualizarProductos(If(FiltrarTodos = "1", True, False)) + Case "ActualizarPrecios" + respuesta = ActualizarPrecios(If(FiltrarTodos = "1", True, False)) + Case "ActualizarExistencias" + respuesta = ActualizarExistencias() + Case "ActualizarVendedores" + respuesta = ActualizarVendedores(If(FiltrarTodos = "1", True, False)) + End Select - If respuesta Then - retorno = "True" - Else - retorno = "False" + If respuesta Then + retorno = "True" + Else + retorno = "False" + End If End If + End If context.Response.Write(retorno) @@ -202,7 +205,7 @@ Public Class E141 : Implements IHttpHandler Using httpClient = New HttpClient() httpClient.Timeout = New TimeSpan(0, 5, 0) Using request = New HttpRequestMessage(HttpMethod.Post, New Uri(url)) - request.Headers.Add("token", TokenAutorizacion) + request.Headers.Add("X-PUBLIC-AUTH", TokenAutorizacion) Using content = New StringContent(payload, Encoding.UTF8, "application/json") request.Content = content @@ -607,7 +610,7 @@ Public Class E141 : Implements IHttpHandler End Select If VendedorData.Length > 4 Then - Nombre = String.Concat(VendedorData(VendedorData.Length - 1), " ", VendedorData(VendedorData.Length)) + Nombre = String.Concat(VendedorData(VendedorData.Length - 2), " ", VendedorData(VendedorData.Length - 1)) Apellido = String.Concat(VendedorData(0), " ", VendedorData(1)) End If From 9947c5b92a9583c416e83b0666ff13343c8a1119 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Thu, 17 Dec 2020 15:07:12 -0700 Subject: [PATCH 4/5] aplica para venta --- Ventas/PV.aspx.vb | 1 + 1 file changed, 1 insertion(+) diff --git a/Ventas/PV.aspx.vb b/Ventas/PV.aspx.vb index 152d2e3cc..da4fa3f72 100644 --- a/Ventas/PV.aspx.vb +++ b/Ventas/PV.aspx.vb @@ -2705,6 +2705,7 @@ Partial Class PV Else Objeto.ddlWS.Attributes.Add("data-pagina", "-1") End If + Objeto.ddlWS.Attributes.Add("data-aplicaparaventa", "1") Objeto.ddlWS.Attributes.Add("data-Estatus", "1") End If End Sub From bec6a562d69c3e51fcc8faea1d24df87c1f8b921 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Thu, 17 Dec 2020 15:07:25 -0700 Subject: [PATCH 5/5] Cambios en saldos de usados --- Ventas/Clientes.aspx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Ventas/Clientes.aspx b/Ventas/Clientes.aspx index b168f7b82..2f20bd2b4 100644 --- a/Ventas/Clientes.aspx +++ b/Ventas/Clientes.aspx @@ -4179,8 +4179,10 @@ AutoGenerateColumns="False" AllowPaging="False" ShowFooter="False"> - - + + + + @@ -4290,7 +4292,7 @@ --%> - +