From d918a76ad371abe74766eba3de2822c50bda40dd Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 29 Jun 2022 09:26:52 -0700 Subject: [PATCH 1/3] Concepto de entrada ExA al generar la prepoliza --- App_Code/Modelos.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 37ac787cc..e60e23e27 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -4305,7 +4305,7 @@ Namespace Modelos Dim TipoMovto68 As Boolean = True Dim TipoMovto69 As Boolean = False - If CveConcepto.Contiene(18) Then + If CveConcepto.Contiene(18, 9) Then TipoMovto68 = False TipoMovto69 = True End If From a929cb71396e915ed71056e5ae2d213f19268f76 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 29 Jun 2022 09:27:19 -0700 Subject: [PATCH 2/3] Cambio de nombre metodo BASF_POG40 --- Ashx/E119.ashx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ashx/E119.ashx b/Ashx/E119.ashx index 2c1abbc0b..782584b41 100644 --- a/Ashx/E119.ashx +++ b/Ashx/E119.ashx @@ -100,7 +100,7 @@ Public Class E119 : Implements IHttpHandler Try Dim Metodo = If(context.Request("Metodo") = Nothing, "", context.Request("Metodo").ToString()) 'OBTENER EXISTENCIAS - If Metodo = "ConsultaBASF_POG" Then + If Metodo = "BASF_POG40" Then context.Response.ContentType = "application/json" Dim Auth = ValidarSolicitud(context) From ee75258ef23edd15940e02d89b8600b3fcd13c80 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 29 Jun 2022 09:28:18 -0700 Subject: [PATCH 3/3] Optimizacion de carga de obj factura en ventas --- Ventas/Ventas.aspx.vb | 148 ++++++++++++++++++++++++------------------ 1 file changed, 84 insertions(+), 64 deletions(-) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 0bb525ab2..c2dbb51a0 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -9578,7 +9578,7 @@ Partial Class Ventas Try 'MANDA CORREO Dim strURLHOST = String.Format("{0}://{1}:{2}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port) - Dim Factura = New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, EsCancelacion:=False) + Dim Factura = New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, EsCancelacion:=False, CargaDTDetalle:=False, CargaDatosCliente:=False, CargaDatosRelacionados:=False) Dim Hilo As New System.Threading.Thread(Sub() GeneraPDFFactura(ChkEnviarFactura.Checked, Factura, UsuarioActual, strURLHOST)) Hilo.Start() Catch ex As Exception @@ -15195,7 +15195,7 @@ Partial Class Ventas End Try If CveVenta > 0 Then - ObjFactura = New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, EsCancelacion:=False) + ObjFactura = New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, EsCancelacion:=False, CargaDTDetalle:=False, CargaDatosCliente:=False, CargaDatosRelacionados:=False) End If LocalSerieFolio = ObjFactura.SerieFolio @@ -16433,7 +16433,7 @@ Partial Class Ventas Try 'MANDA CORREO Dim strURLHOST = String.Format("{0}://{1}:{2}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port) - Dim Factura = New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, EsCancelacion:=False) + Dim Factura = New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, EsCancelacion:=False, CargaDTDetalle:=False, CargaDatosCliente:=False, CargaDatosRelacionados:=False) Dim Hilo As New System.Threading.Thread(Sub() GeneraPDFFactura(ChkEnviarFactura.Checked, Factura, UsuarioActual, strURLHOST)) Hilo.Start() Catch ex As Exception @@ -23693,7 +23693,7 @@ Partial Class Ventas End Function Public Sub EnviarPDFCancelacion(CveVenta As Integer) - Dim FacturaRef As New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa) + Dim FacturaRef As New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, CargaDTDetalle:=False, CargaDatosRelacionados:=False) If FacturaRef IsNot Nothing Then Dim ObjetoPDF As Byte() = DescargarPDF(Encripta(String.Format("OP=CAN&CVEVTA={0}", CveVenta))) @@ -26942,10 +26942,20 @@ Partial Class Ventas If CveVentaUsado > 0 Then 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) + 'Dim FacUsado As New Modelos.Factura(UsuarioActual, CveVentaUsado, UsuarioActual.CveEmpresa, CargaDatosCliente:=False, CargaDatosRelacionados:=False) + Dim DtDetalleUsado As DataTable = Nothing + Using ObjVentas As New ClsVentas + If ObjVentas.GetVentaDetalle(CveVentaUsado) Then + DtDetalleUsado = ObjVentas.DtResultados.Copy() + End If + End Using + + If DtDetalleUsado IsNot Nothing Then + Dim SaldoMaximoUsados As Decimal = DtDetalleUsado.SUM("Total", "EsCargo = True").ToDecimal() + DtDetalleUsado.SUM("ImporteIVA", "EsCargo = True").ToDecimal() + HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString() + LtlSMU.Text = String.Format("{0:N2}", SaldoMaximoUsados) + End If + Else If CargarSoloGarantias Then Dim SaldoMaximo As Decimal = DtNC.SUMD("Saldo", "TipoRNC = 1 AND EsGarantia = True") @@ -27062,17 +27072,27 @@ Partial Class Ventas If CveVentaUsado > 0 Then 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() + 'Dim FacUsado As New Modelos.Factura(UsuarioActual, CveVentaUsado, UsuarioActual.CveEmpresa) + Dim DtDetalleUsado As DataTable = Nothing + Using ObjVentas As New ClsVentas + If ObjVentas.GetVentaDetalle(CveVentaUsado) Then + DtDetalleUsado = ObjVentas.DtResultados.Copy() + End If + End Using - If SaldoMaximoUsados > 0 Then - HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString() - LtlSMU.Text = String.Format("{0:N2}", SaldoMaximoUsados) - Else - HdnSaldoMaximoUsados.Value = "0" - LtlSMU.Text = "0" + If DtDetalleUsado IsNot Nothing Then + Dim SaldoMaximoUsados As Decimal = DtDetalleUsado.SUM("Total", "EsCargo = True").ToDecimal() + DtDetalleUsado.SUM("ImporteIVA", "EsCargo = True").ToDecimal() + + If SaldoMaximoUsados > 0 Then + HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString() + LtlSMU.Text = String.Format("{0:N2}", SaldoMaximoUsados) + Else + HdnSaldoMaximoUsados.Value = "0" + LtlSMU.Text = "0" + End If End If + Else If CargaSoloGarantias Then Dim SaldoMaximo As Decimal = TmpDTRNCDetalle.SUMD("Total", "TipoRNC = 1") @@ -30196,59 +30216,59 @@ Partial Class Ventas UpParametros.Update() End Sub - Private Function AjustarTotalCotizacionFacturada(CveCotizacion As Integer, TotalAjustar As Decimal) As Boolean - Dim ErrorAjuste As Boolean = False + 'Private Function AjustarTotalCotizacionFacturada(CveCotizacion As Integer, TotalAjustar As Decimal) As Boolean + ' Dim ErrorAjuste As Boolean = False - Dim ObjCotizacion As New Modelos.Factura(UsuarioActual, CveCotizacion, UsuarioActual.CveEmpresa) + ' Dim ObjCotizacion As New Modelos.Factura(UsuarioActual, CveCotizacion, UsuarioActual.CveEmpresa) - If ObjCotizacion.CveMoneda = 1 Then - Dim TotalNuevoDocumento As Decimal = TotalAjustar + ' If ObjCotizacion.CveMoneda = 1 Then + ' Dim TotalNuevoDocumento As Decimal = TotalAjustar - Dim Diferencia As Decimal = (ObjCotizacion.Total - TotalNuevoDocumento) + ' Dim Diferencia As Decimal = (ObjCotizacion.Total - TotalNuevoDocumento) - If Diferencia <> 0 Then - 'AJUSTAR EN EL IVA - For Each RowNuevoDocumento As DataRow In TmpDT.Rows - Dim CveVentaDetalleCotizacion As Integer = RowNuevoDocumento("CveVentaDetalleCotizacion").ToString().ToEntero() + ' If Diferencia <> 0 Then + ' 'AJUSTAR EN EL IVA + ' For Each RowNuevoDocumento As DataRow In TmpDT.Rows + ' Dim CveVentaDetalleCotizacion As Integer = RowNuevoDocumento("CveVentaDetalleCotizacion").ToString().ToEntero() - Dim ImporteIVANuevoDocumento As Decimal = RowNuevoDocumento("ImporteIVA").ToString().ToDecimal() - Dim ImporteIEPSNuevoDocumento As Decimal = RowNuevoDocumento("ImporteIEPS").ToString().ToDecimal() + ' Dim ImporteIVANuevoDocumento As Decimal = RowNuevoDocumento("ImporteIVA").ToString().ToDecimal() + ' Dim ImporteIEPSNuevoDocumento As Decimal = RowNuevoDocumento("ImporteIEPS").ToString().ToDecimal() - If CveVentaDetalleCotizacion > 0 Then - 'AJUSTAR IVA - If ImporteIVANuevoDocumento > 0 Then - Dim ImporteIVACotizacion As Decimal = ObjCotizacion.DtDetalle.FiltroPrimeroValor("ImporteIVA", $"CveVentaDetalle={CveVentaDetalleCotizacion}").ToDecimal + ' If CveVentaDetalleCotizacion > 0 Then + ' 'AJUSTAR IVA + ' If ImporteIVANuevoDocumento > 0 Then + ' Dim ImporteIVACotizacion As Decimal = ObjCotizacion.DtDetalle.FiltroPrimeroValor("ImporteIVA", $"CveVentaDetalle={CveVentaDetalleCotizacion}").ToDecimal - If ImporteIVANuevoDocumento <> ImporteIVACotizacion Then - RowNuevoDocumento("ImporteIVA") = ImporteIVACotizacion - End If - End If + ' If ImporteIVANuevoDocumento <> ImporteIVACotizacion Then + ' RowNuevoDocumento("ImporteIVA") = ImporteIVACotizacion + ' End If + ' End If - 'AJUSTAR IEPS - If ImporteIEPSNuevoDocumento > 0 Then - Dim ImporteIEPSCotizacion As Decimal = ObjCotizacion.DtDetalle.FiltroPrimeroValor("ImporteIEPS", $"CveVentaDetalle={CveVentaDetalleCotizacion}").ToDecimal + ' 'AJUSTAR IEPS + ' If ImporteIEPSNuevoDocumento > 0 Then + ' Dim ImporteIEPSCotizacion As Decimal = ObjCotizacion.DtDetalle.FiltroPrimeroValor("ImporteIEPS", $"CveVentaDetalle={CveVentaDetalleCotizacion}").ToDecimal - If ImporteIEPSNuevoDocumento <> ImporteIEPSCotizacion Then - RowNuevoDocumento("ImporteIEPS") = ImporteIEPSCotizacion - End If - End If + ' If ImporteIEPSNuevoDocumento <> ImporteIEPSCotizacion Then + ' RowNuevoDocumento("ImporteIEPS") = ImporteIEPSCotizacion + ' End If + ' End If - End If - Next - End If + ' End If + ' Next + ' End If - CalculaTotalesVenta(RecalculaImpuestosLocales:=False) + ' CalculaTotalesVenta(RecalculaImpuestosLocales:=False) - If Math.Abs(ObjCotizacion.Total - TotalAjustar) > 0 OrElse Math.Abs(TxtTotal.Text.ToDecimal - TotalAjustar) > 0 Then - ErrorAjuste = True - End If + ' If Math.Abs(ObjCotizacion.Total - TotalAjustar) > 0 OrElse Math.Abs(TxtTotal.Text.ToDecimal - TotalAjustar) > 0 Then + ' ErrorAjuste = True + ' End If - End If - ObjCotizacion.Dispose() + ' End If + ' ObjCotizacion.Dispose() - Return Not ErrorAjuste - End Function + ' Return Not ErrorAjuste + 'End Function Private Class MVentaDetalleCotizacion Public Property CveVentaDetalle As Integer @@ -32135,7 +32155,7 @@ Partial Class Ventas Dim TerminarCiclo As Boolean = False For Each Dr As DataRow In TmpDTRNCDetalleSelecciondas.FiltraParametros("", DistinctColumns:={"CveVenta"}).Rows - Dim RemNC As New Modelos.Factura(UsuarioActual, Dr("CveVenta").ToString().ToEntero(), UsuarioActual.CveEmpresa) + Dim RemNC As New Modelos.Factura(UsuarioActual, Dr("CveVenta").ToString().ToEntero(), UsuarioActual.CveEmpresa, CargaDatosCliente:=False, CargaDatosRelacionados:=False) Dim TotalRNC As Decimal = 0 For Each GvRow As GridViewRow In GvRemisionesNCDetalle.Rows @@ -32191,7 +32211,7 @@ Partial Class Ventas For Each GvRow As GridViewRow In GvRemisionesNC.Rows If GvRow.RowType = DataControlRowType.DataRow Then If GvRow.FCCheckBox("ChkAplicar").Checked Then - Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa) + Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa, CargaDatosCliente:=False, CargaDatosRelacionados:=False) RemNC.TotalRemNCAplicado = GvRow.FCTextBox("TxtImporte").Text.ToDecimal() 'MARCA LA VENTA QUE FUE USADA PARA EL FILTRO RemNC.Num3 = DdlVentaUsado.SelectedValue.ToEntero() @@ -32255,7 +32275,7 @@ Partial Class Ventas Dim TerminarCiclo As Boolean = False For Each Dr As DataRow In TmpDTRNCDetalleSelecciondas.FiltraParametros("", DistinctColumns:={"CveVenta"}).Rows - Dim RemNC As New Modelos.Factura(UsuarioActual, Dr("CveVenta").ToString().ToEntero(), UsuarioActual.CveEmpresa) + Dim RemNC As New Modelos.Factura(UsuarioActual, Dr("CveVenta").ToString().ToEntero(), UsuarioActual.CveEmpresa, CargaDatosCliente:=False, CargaDatosRelacionados:=False) Dim TotalRNC As Decimal = 0 For Each GvRow As GridViewRow In GvRemisionesNCBonDetalle.Rows @@ -32311,7 +32331,7 @@ Partial Class Ventas For Each GvRow As GridViewRow In GvRemisionesNCBon.Rows If GvRow.RowType = DataControlRowType.DataRow Then If GvRow.FCCheckBox("ChkAplicar").Checked Then - Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa) + Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa, CargaDatosCliente:=False, CargaDatosRelacionados:=False) RemNC.TotalRemNCAplicado = GvRow.FCTextBox("TxtImporte").Text.ToDecimal() RemNC.CveVentaRNCCargo = GvRow.DataKey("CveVentaRNCCargo").ToEntero() TotalRemNCAplicado += RemNC.TotalRemNCAplicado @@ -32436,7 +32456,7 @@ Partial Class Ventas Dim TerminarCiclo As Boolean = False For Each Dr As DataRow In TmpDTRNCDetalleSelecciondas.FiltraParametros("", DistinctColumns:={"CveVenta"}).Rows - Dim RemNC As New Modelos.Factura(UsuarioActual, Dr("CveVenta").ToString().ToEntero(), UsuarioActual.CveEmpresa) + Dim RemNC As New Modelos.Factura(UsuarioActual, Dr("CveVenta").ToString().ToEntero(), UsuarioActual.CveEmpresa, CargaDatosCliente:=False, CargaDatosRelacionados:=False) Dim TotalRNC As Decimal = 0 For Each GvRow As GridViewRow In GvDescNCCargosDetalle.Rows @@ -32507,7 +32527,7 @@ Partial Class Ventas For Each GvRow As GridViewRow In GvDescNCCargos.Rows If GvRow.RowType = DataControlRowType.DataRow Then If GvRow.FCCheckBox("ChkAplicar").Checked Then - Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa) + Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa, CargaDatosCliente:=False, CargaDatosRelacionados:=False) RemNC.TotalRemNCAplicado = GvRow.FCTextBox("TxtImporte").Text.ToDecimal() TotalRemNCAplicado += RemNC.TotalRemNCAplicado @@ -32591,7 +32611,7 @@ Partial Class Ventas Dim TerminarCiclo As Boolean = False For Each Dr As DataRow In TmpDTRNCBonificacionDetalleSeleccionadas.FiltraParametros("", DistinctColumns:={"CveVenta"}).Rows - Dim RemNC As New Modelos.Factura(UsuarioActual, Dr("CveVenta").ToString().ToEntero(), UsuarioActual.CveEmpresa) + Dim RemNC As New Modelos.Factura(UsuarioActual, Dr("CveVenta").ToString().ToEntero(), UsuarioActual.CveEmpresa, CargaDatosCliente:=False, CargaDatosRelacionados:=False) Dim TotalRNC As Decimal = 0 For Each GvRow As GridViewRow In GvDescNCBonDetalle.Rows @@ -32647,7 +32667,7 @@ Partial Class Ventas For Each GvRow As GridViewRow In GvDescNCBonificaciones.Rows If GvRow.RowType = DataControlRowType.DataRow Then If GvRow.FCCheckBox("ChkAplicar").Checked Then - Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa) + Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa, CargaDatosCliente:=False, CargaDatosRelacionados:=False) RemNC.TotalRemNCAplicado = GvRow.FCTextBox("TxtImporte").Text.ToDecimal() RemNC.CveVentaRNCCargo = GvRow.DataKey("CveVentaRNCCargo").ToEntero() TotalRemNCAplicado += RemNC.TotalRemNCAplicado @@ -32669,7 +32689,7 @@ Partial Class Ventas For Each GvRow As GridViewRow In GvDescNCBonificaciones.Rows If GvRow.RowType = DataControlRowType.DataRow Then If GvRow.FCCheckBox("ChkAplicar").Checked Then - Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa) + Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa, CargaDatosCliente:=False, CargaDatosRelacionados:=False) RemNC.TotalRemNCAplicado = GvRow.FCTextBox("TxtImporte").Text.ToDecimal() RemNC.CveVentaRNCCargo = GvRow.DataKey("CveVentaRNCCargo").ToEntero() TotalRemNCAplicado += RemNC.TotalRemNCAplicado @@ -33915,7 +33935,7 @@ Partial Class Ventas For Each GvRow As GridViewRow In GvRNCDevoluciones.Rows If GvRow.RowType = DataControlRowType.DataRow Then If GvRow.FCCheckBox("ChkAplicar").Checked Then - Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa) + Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa, CargaDatosCliente:=False, CargaDatosRelacionados:=False) RemNC.TotalRemNCAplicado = GvRow.FCTextBox("TxtImporte").Text.ToDecimal() TotalRemNCAplicado += RemNC.TotalRemNCAplicado