From 9a56961b18fbca77acaa6b5326c28472d0882d3f Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Sat, 9 Jul 2022 00:29:28 -0700 Subject: [PATCH] Cancelacion de RNC de bonificacion automaticamente, descarga de PDF de stimulsoft --- Compras/PopUpVerFactura.aspx.vb | 61 ++++++------ Ventas/Ventas.aspx | 47 +++++---- Ventas/Ventas.aspx.vb | 167 ++++++++++++++++++++++++++------ 3 files changed, 198 insertions(+), 77 deletions(-) diff --git a/Compras/PopUpVerFactura.aspx.vb b/Compras/PopUpVerFactura.aspx.vb index 3dbb9b2f6..34a145d8f 100644 --- a/Compras/PopUpVerFactura.aspx.vb +++ b/Compras/PopUpVerFactura.aspx.vb @@ -1079,7 +1079,9 @@ Partial Class PopUpVerFactura Dim AplicaPagare As String = If(UrlParametros("PAG") IsNot Nothing AndAlso UrlParametros("PAG").ToString <> "", UrlParametros("PAG").ToString, "0") Dim Guardar As Boolean = UrlParametros("GUARDAR") IsNot Nothing AndAlso UrlParametros("GUARDAR").ToString() = "1" Dim RegenerarPDF As Boolean = UrlParametros("REGENERAR") IsNot Nothing AndAlso UrlParametros("REGENERAR").ToString() = "1" - imprimirFacturaVenta(UrlParametros("CVEVENTA").ToString.ToEntero, AplicaPagare, GuardarPDF:=Guardar, RegenerarPDF:=RegenerarPDF) + Dim STIMULSOFT As Boolean = UrlParametros("STIMULSOFT") IsNot Nothing AndAlso UrlParametros("STIMULSOFT").ToString() = "1" + + imprimirFacturaVenta(UrlParametros("CVEVENTA").ToString.ToEntero, AplicaPagare, GuardarPDF:=Guardar, RegenerarPDF:=RegenerarPDF, UsarStimulsoft:=STIMULSOFT) End If End If @@ -2694,7 +2696,7 @@ Partial Class PopUpVerFactura Archivo = Nothing End If End Sub - Public Sub imprimirFacturaVenta(CveVenta As Integer, AplicaPagare As String, Optional GuardarPDF As Boolean = False, Optional RegenerarPDF As Boolean = False) + Public Sub imprimirFacturaVenta(CveVenta As Integer, AplicaPagare As String, Optional GuardarPDF As Boolean = False, Optional RegenerarPDF As Boolean = False, Optional UsarStimulsoft As Boolean = False) Dim ObjVentas As New ClsVentas Dim Vta As Modelos.Factura = Nothing @@ -2723,7 +2725,7 @@ Partial Class PopUpVerFactura Dim Archivo As New System.IO.FileInfo(PathArchivo) 'SI EL ARCHIVO NO EXISTE O SE VA REGENERA EL PDF, SE DEBEN LLENAR LOS DATOS - If Not Archivo.Exists OrElse RegenerarPDF Then + If Not Archivo.Exists OrElse RegenerarPDF OrElse UsarStimulsoft Then Vta.MonedaAbreviatura = dtVentas(0)("Abreviatura").ToString 'se rellena la sucursal 'Vta.Subproyecto = ObjVentas.DtResultados.Rows(0).DataRowToObject(Of Modelos.SucursalModel) @@ -3028,7 +3030,7 @@ Partial Class PopUpVerFactura Dim CveTimbreCartaPorteVenta As Integer = -1 Dim CartaPorte As Modelos.MSubReportData = Nothing 'SI EL ARCHIVO NO EXISTE O SE VA REGENERA EL PDF, SE DEBEN LLENAR LOS DATOS - If Not Archivo.Exists OrElse RegenerarPDF Then + If Not Archivo.Exists OrElse RegenerarPDF OrElse UsarStimulsoft Then If UsuarioActual.CveEmpresa = 13 AndAlso Vta.TipoDocto = "Ing" Then Using ObjGral As New ClsGenerales If ObjGral.GetGralTimbre(-1, "Ing", MinFecha, MaxFecha, 0, UsuarioActual.CveEmpresa, -1, CveVenta:=CveVenta) AndAlso ObjGral.DtResultados.Rows.Count > 0 Then @@ -3046,37 +3048,42 @@ Partial Class PopUpVerFactura End If End If - If Archivo.Exists Then - If RegenerarPDF Then - Archivo.Delete() + If UsarStimulsoft Then + ImprimirbytesPDF(PdfFactura(Vta, AplicaPagare:=AplicaPagare, Guardar:=True, SubReportData:=CartaPorte, UsarStimulsoft:=UsarStimulsoft), Vta.SerieFolio, "PDF") + Else + If Archivo.Exists Then + If RegenerarPDF Then + Archivo.Delete() + If UsuarioActual.Empresa.CvePlataforma = 2 Then + GeneraPDFVtaPyMe(Vta, "PDF") + Else + ImprimirbytesPDF(PdfFactura(Vta, AplicaPagare:=AplicaPagare, Guardar:=True, SubReportData:=CartaPorte), Vta.SerieFolio, "PDF") + Vta = Nothing + End If + Else + HttpContext.Current.Response.Clear() + HttpContext.Current.Response.ClearContent() + HttpContext.Current.Response.ContentType = If(IO.Path.GetExtension(Archivo.Name) = ".txt", "text/plain", "application/pdf") + HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" & Archivo.Name) + HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString()) + HttpContext.Current.Response.TransmitFile(PathArchivo) + 'HttpContext.Current.Response.Flush() + HttpContext.Current.Response.End() + Archivo = Nothing + End If + Else + + '04/05/2018 - Se agrega seccion pruebas para generar factura venta .mrt para PyME If UsuarioActual.Empresa.CvePlataforma = 2 Then GeneraPDFVtaPyMe(Vta, "PDF") Else - ImprimirbytesPDF(PdfFactura(Vta, AplicaPagare:=AplicaPagare, Guardar:=True, SubReportData:=CartaPorte), Vta.SerieFolio, "PDF") + ImprimirbytesPDF(PdfFactura(Vta, AplicaPagare:=AplicaPagare, Guardar:=Guardar, SubReportData:=CartaPorte), Vta.SerieFolio, "PDF") Vta = Nothing End If - Else - HttpContext.Current.Response.Clear() - HttpContext.Current.Response.ClearContent() - HttpContext.Current.Response.ContentType = If(IO.Path.GetExtension(Archivo.Name) = ".txt", "text/plain", "application/pdf") - HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" & Archivo.Name) - HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString()) - HttpContext.Current.Response.TransmitFile(PathArchivo) - 'HttpContext.Current.Response.Flush() - HttpContext.Current.Response.End() - Archivo = Nothing - End If - Else - - '04/05/2018 - Se agrega seccion pruebas para generar factura venta .mrt para PyME - If UsuarioActual.Empresa.CvePlataforma = 2 Then - GeneraPDFVtaPyMe(Vta, "PDF") - Else - ImprimirbytesPDF(PdfFactura(Vta, AplicaPagare:=AplicaPagare, Guardar:=Guardar, SubReportData:=CartaPorte), Vta.SerieFolio, "PDF") - Vta = Nothing End If End If + End If End Sub diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 3801acf57..07dd3e8e0 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -200,6 +200,12 @@
  • Imprimir PDF
  • +
  • + Regenerar PDF +
  • +
  • + Imprimir PDF Stimulsoft +
  • Imprimir Acuse Cancelación
  • @@ -282,8 +288,8 @@ Retiro de Efectivo -
  • - +
  • +
  • @@ -7788,17 +7794,20 @@
    +
    +
    + " 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"> -
    +
    ').prop('readonly', DisabledTxtTotal); - $('#C_Tab_TabComplementos_TxtFechaLlegadaCP').datetimepicker({ - dayOfWeekStart: 1, - lang: 'es', - format: 'd/m/Y H:i', - formatDate: 'd/m/Y H:i', - step: 30 + $('#C_Tab_TabComplementos_TxtFechaLlegadaCP').datetimepicker({ + dayOfWeekStart: 1, + lang: 'es', + format: 'd/m/Y H:i', + formatDate: 'd/m/Y H:i', + step: 30 }); - $('#C_Tab_TabComplementos_TxtFechaEntregaCP').datetimepicker({ - dayOfWeekStart: 1, - lang: 'es', - format: 'd/m/Y H:i', - formatDate: 'd/m/Y H:i', - step: 30 + $('#C_Tab_TabComplementos_TxtFechaEntregaCP').datetimepicker({ + dayOfWeekStart: 1, + lang: 'es', + format: 'd/m/Y H:i', + formatDate: 'd/m/Y H:i', + step: 30 }); } diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 6e265c459..a9ce792cd 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -8905,6 +8905,13 @@ Partial Class Ventas If (Archivo.Exists Or Archivo2.Exists) And IfNull(CveVenta, 0).ToString().ToEntero() > 0 Then HplDownPDF.Visible = True HplDownPDF.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1", CveVenta))) + If UsuarioActual.CveRol = 1 Then + HplRenerarPDF.Visible = True + HplRenerarPDF.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1®ENERAR=1", CveVenta))) + + HplImprimirPDFStimulsoft.Visible = True + HplImprimirPDFStimulsoft.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=0&STIMULSOFT=1", CveVenta))) + End If End If 'NO DEBE IMPRIMIR PDF DE COTIZACION @@ -19242,22 +19249,28 @@ Partial Class Ventas End If If UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso ListaDescuentos IsNot Nothing AndAlso ListaDescuentos.Count > 0 Then - TxtObsFact.Text = "" + Dim Titulo As String = ListaDescuentos.FirstOrDefault().NombrePromo Dim strPromos As New StringBuilder If Not String.IsNullOrEmpty(Titulo) Then For Each Promo As Descuentos In ListaDescuentos - strPromos.AppendFormat("{0}, ", Promo.ObsDescuento) + If Not String.IsNullOrEmpty(Promo.ObsDescuento) Then + strPromos.AppendFormat("{0}, ", Promo.ObsDescuento) + End If Next If strPromos.Length > 2 Then strPromos.Remove(strPromos.Length - 2, 2) End If + If strPromos.Length > 0 Then + TxtObsFact.Text = "" + TxtObsFact.Text = String.Format("{0} {1}", Titulo, strPromos.ToString()) + End If + End If - TxtObsFact.Text = String.Format("{0} {1}", Titulo, strPromos.ToString()) End If UPObservaciones.Update() @@ -23793,7 +23806,36 @@ Partial Class Ventas ', "document.location.href=""/Ventas/Ventas.aspx?CveVenta=" & CveVenta End If ObjVentas.Dispose() + ElseIf DdlTipoComprobante.SelectedValue.Contiene("RNC") Then + LblCancelarDocumento.Text = "¿Desea cancelar la remisión de nota de crédito?
    " + Dim sbExtra As New StringBuilder + + Using ObjAcum As New ClsAcumuladores + If ObjAcum.DistribuidorMovtosGet(Me.CveCliente, UsuarioActual.CveEmpresa, CveVentaRNCCargo:=Me.CveVenta, CveConcepto:=1) Then + Dim DtBon As DataTable = ObjAcum.DtResultados.FiltraParametros("CveVentaBonificacion > 0", DistinctColumns:={"SerieFolioBonificacion", "CveVentaBonificacion"}) + If DtBon IsNot Nothing AndAlso DtBon.Rows.Count > 0 Then + sbExtra.Append("*Se cancelaran las siguientes remisiones de nota de crédito de bonificación.
    ") + For Each RowBon As DataRow In DtBon.Rows + sbExtra.AppendFormat("     {1}
    ", RowBon("CveVentaBonificacion"), RowBon("SerieFolioBonificacion")) + Next + DtBon.Dispose() + End If + End If + End Using + + LbCancelarDescripcion.Text = sbExtra.ToString() + DivRelacionadasCancelacion.Visible = False + BtnCancelarDocumento.Visible = True + DivMotivoCancelacion.Visible = False + DivMotivoCancelacionTxt.Visible = False + DivCanRem.Visible = False + DivDevAlm.Visible = False + + UpCancelarDocumento.Update() + + RegistraScript("$('#ModalCancelarDocumento').modal();") Else + CancelarDocumento() End If @@ -23963,7 +24005,7 @@ Partial Class Ventas Dim ObjFacturaCancelacion As New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, EsCancelacion:=True) Try Dim resp As Modelos.Factura.MCancelacionVentaMensaje = Nothing - + Dim strMensaje As New StringBuilder() If ObjFacturaCancelacion IsNot Nothing AndAlso ObjFacturaCancelacion.CveVenta > 0 Then Dim SWatch As New Stopwatch SWatch.Start() @@ -23976,6 +24018,7 @@ Partial Class Ventas 'ObjE.Dispose() resp = ObjFacturaCancelacion.CancelarPorRefacturacion(DdlMotivoRefacturacion.SelectedValue.ToEntero(), TxtMotivoRefac.Text.Trim(), CveEstadoCancelacion:=Me.CveEstadoCancelacion) + strMensaje.Append(resp.Mensaje) Else Dim ListaRemisionesCancelar As New List(Of Integer) If ChkCanRem.Checked Then @@ -23993,6 +24036,41 @@ Partial Class Ventas End If resp = ObjFacturaCancelacion.CancelarFactura(ChkDevAlm.Checked, ListaRemisionesCancelar, CveMotivoCancelacion:=DdlMotivoCancelacion.SelectedValue.ToEntero(), Motivo:=TxtMotivoCancelacion.Text.Trim(), CveEstadoCancelacion:=Me.CveEstadoCancelacion) + strMensaje.Append(resp.Mensaje) + Dim DtBonificaciones As DataTable = Nothing + + 'SI ES RNC DE CARGO DEBE CANCELAR LAS BON + If Not resp.HuboError AndAlso ObjFacturaCancelacion.TipoDocto.Contiene("RNC") AndAlso ObjFacturaCancelacion.Num1 = 1 Then + Using ObjAcum As New ClsAcumuladores + If ObjAcum.DistribuidorMovtosGet(ObjFacturaCancelacion.CveCliente, UsuarioActual.CveEmpresa, CveVentaRNCCargo:=ObjFacturaCancelacion.CveVenta, CveConcepto:=1) Then + DtBonificaciones = ObjAcum.DtResultados.FiltraParametros("CveVentaBonificacion > 0", DistinctColumns:={"CveVentaBonificacion"}) + End If + End Using + + + If DtBonificaciones IsNot Nothing AndAlso DtBonificaciones.Rows.Count > 0 Then + For Each RowBon As DataRow In DtBonificaciones.Rows + Try + 'VERIFICA SI TIENE RNC DE BONIFICACION + Dim Bon = New Modelos.Factura(UsuarioActual, RowBon("CveVentaBonificacion").ToString().ToEntero(), UsuarioActual.CveEmpresa, VerificaAlmacen:=False) + Dim respBon = Bon.CancelarFactura(False, ListaRemisionesCancelar, CveMotivoCancelacion:=DdlMotivoCancelacion.SelectedValue.ToEntero(), Motivo:=TxtMotivoCancelacion.Text.Trim(), CveEstadoCancelacion:=Me.CveEstadoCancelacion) + If respBon.HuboError Then + strMensaje.AppendFormat("
    Ocurrió un error al cancelar la remisión de NC de bonificación {0} .", Bon.SerieFolio) + Else + strMensaje.AppendFormat("
    La remisión de nota de credito de bonificación {0} fue cancelada correctamente.", Bon.SerieFolio) + End If + strMensaje.AppendFormat("
    {0}", resp.Mensaje) + Catch ex As Exception + OnError("Ocurrió un error al cancelar la bonificación", ex) + strMensaje.Append("
    Ocurrió un error al cancelar la bonificación") + End Try + + Next + DtBonificaciones.Dispose() + End If + + End If + End If SWatch.Stop() @@ -24005,10 +24083,10 @@ Partial Class Ventas End If If resp.HuboError Then - Alert(resp.Mensaje, resp.TipoMensaje, JSBtnAceptar:="BtnRefrescarPagina();") + Alert(strMensaje.ToString(), resp.TipoMensaje, JSBtnAceptar:="BtnRefrescarPagina();") Else If resp.CveEstatus = 5 AndAlso Not EsRefacturacion Then - Alert(resp.Mensaje, resp.TipoMensaje, JSBtnAceptar:=$"BtnEnviarMailCancelacion({CveVenta});", TextoConfirmacion:="    Si    ", TextoCancelacion:="    No    ") + Alert(strMensaje.ToString(), resp.TipoMensaje, JSBtnAceptar:=$"BtnEnviarMailCancelacion({CveVenta});", TextoConfirmacion:="    Si    ", TextoCancelacion:="    No    ") Else If EsRefacturacion Then If resp.CveEstatus = 20 Then @@ -24016,10 +24094,10 @@ Partial Class Ventas ElseIf resp.CveEstatus.Contiene(4, 5, 23) Then LigaRedirigir = $"Ventas.aspx?CveDevolucion={CveVenta}&NuevaFactura=1" Else - Alert(resp.Mensaje, resp.TipoMensaje, JSBtnAceptar:="BtnRefrescarPagina();") + Alert(strMensaje.ToString(), resp.TipoMensaje, JSBtnAceptar:="BtnRefrescarPagina();") End If Else - Alert(resp.Mensaje, resp.TipoMensaje, JSBtnAceptar:="BtnRefrescarPagina();") + Alert(strMensaje.ToString(), resp.TipoMensaje, JSBtnAceptar:="BtnRefrescarPagina();") End If End If End If @@ -26891,14 +26969,15 @@ Partial Class Ventas End If GvDescNCCargos.DataBind() - Dim SaldoMaximoUtilizable As Decimal = 0 + Dim SaldoMaximoCliente As Decimal = 0 + Dim SaldoEntregado As Decimal = 0 If CargarSoloGarantias Then Dim SaldoMaximo As Decimal = DtNC.SUMD("Saldo", "TipoRNC = 1 AND EsGarantia = True") If SaldoMaximo > 0 Then - SaldoMaximoUtilizable = SaldoMaximo + SaldoMaximoCliente = SaldoMaximo Else - SaldoMaximoUtilizable = 0 + SaldoMaximoCliente = 0 End If Else Dim ObjAcum As New ClsAcumuladores @@ -26908,25 +26987,32 @@ Partial Class Ventas Dim SaldoMaximo As Decimal = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal() If SaldoMaximo > 0 Then - SaldoMaximoUtilizable = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal() + SaldoMaximoCliente = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal() Else - SaldoMaximoUtilizable = 0 + SaldoMaximoCliente = 0 End If - + Dim RowEntregado As DataRow = ObjAcum.DtResultados.Rows(1) + SaldoEntregado = RowEntregado("ValorConImpuestos").ToString().ToDecimal() Else - SaldoMaximoUtilizable = 0 + SaldoMaximoCliente = 0 End If ObjAcum.Dispose() End If Dim SaldoMaximoUsadosFactura As Decimal = Me.TmpDT.SUM("Total", "EsCargo = True").ToDecimal() + Me.TmpDT.SUM("ImporteIVA", "EsCargo = True").ToDecimal() - If SaldoMaximoUtilizable < SaldoMaximoUsadosFactura Then + If SaldoMaximoCliente > 0 AndAlso SaldoMaximoCliente < SaldoMaximoUsadosFactura Then + SaldoMaximoUsadosFactura = SaldoMaximoCliente + End If + + Dim SaldoMaximoUtilizable = If(SaldoMaximoUsadosFactura < SaldoEntregado, SaldoMaximoUsadosFactura, SaldoEntregado) + + If SaldoMaximoUtilizable > 0 Then HdnSaldoMaximoUsados.Value = SaldoMaximoUtilizable.ToString() LblSaldoMaximoUsados.Text = String.Format("{0:N2}", SaldoMaximoUtilizable) Else - HdnSaldoMaximoUsados.Value = SaldoMaximoUsadosFactura.ToString() - LblSaldoMaximoUsados.Text = String.Format("{0:N2}", SaldoMaximoUsadosFactura) + HdnSaldoMaximoUsados.Value = "0" + LblSaldoMaximoUsados.Text = String.Format("{0:N2}", 0) End If Else @@ -27042,14 +27128,14 @@ Partial Class Ventas End If GvDescNCCargosDetalle.DataBind() - Dim SaldoMaximoUtilizable As Decimal = 0 - + Dim SaldoMaximoCliente As Decimal = 0 + Dim SaldoEntregado As Decimal = 0 If CargarSoloGarantias Then Dim SaldoMaximo As Decimal = TmpDTRNCDetalle.SUMD("Saldo", "TipoRNC = 1 AND EsGarantia = True") If SaldoMaximo > 0 Then - SaldoMaximoUtilizable = SaldoMaximo + SaldoMaximoCliente = SaldoMaximo Else - SaldoMaximoUtilizable = 0 + SaldoMaximoCliente = 0 End If Else Dim ObjAcum As New ClsAcumuladores @@ -27059,27 +27145,36 @@ Partial Class Ventas Dim SaldoMaximo As Decimal = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal() If SaldoMaximo > 0 Then - SaldoMaximoUtilizable = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal() + SaldoMaximoCliente = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal() Else - SaldoMaximoUtilizable = 0 + SaldoMaximoCliente = 0 End If + Dim RowEntregado As DataRow = ObjAcum.DtResultados.Rows(1) + SaldoEntregado = RowEntregado("ValorConImpuestos").ToString().ToDecimal() Else - SaldoMaximoUtilizable = 0 + SaldoMaximoCliente = 0 End If ObjAcum.Dispose() End If - Dim SaldoMaximoUsados As Decimal = Me.TmpDT.SUM("Total", "EsCargo = True").ToDecimal() + Me.TmpDT.SUM("ImporteIVA", "EsCargo = True").ToDecimal() + Dim SaldoMaximoUsadosFactura As Decimal = Me.TmpDT.SUM("Total", "EsCargo = True").ToDecimal() + Me.TmpDT.SUM("ImporteIVA", "EsCargo = True").ToDecimal() - If SaldoMaximoUtilizable < SaldoMaximoUsados Then + If SaldoMaximoCliente > 0 AndAlso SaldoMaximoCliente < SaldoMaximoUsadosFactura Then + SaldoMaximoUsadosFactura = SaldoMaximoCliente + End If + + Dim SaldoMaximoUtilizable = If(SaldoMaximoUsadosFactura < SaldoEntregado, SaldoMaximoUsadosFactura, SaldoEntregado) + + If SaldoMaximoUtilizable > 0 Then HdnSaldoMaximoUsados.Value = SaldoMaximoUtilizable.ToString() LblSaldoMaximoUsados.Text = String.Format("{0:N2}", SaldoMaximoUtilizable) Else - HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString() - LblSaldoMaximoUsados.Text = String.Format("{0:N2}", SaldoMaximoUsados) + HdnSaldoMaximoUsados.Value = "0" + LblSaldoMaximoUsados.Text = String.Format("{0:N2}", 0) End If + UpDescNC.Update() End Sub Private Sub CargaRNCDetalleBonificacion(Optional CveVentaUsado As Integer = -1) @@ -27827,8 +27922,17 @@ Partial Class Ventas DtImpuestos = query.QueryToDataTable(False) DtImpuestosBonificacion = queryBonificacion.QueryToDataTable(False) + Dim TieneMultiplesSubProyectos As Boolean = False + 'VERIFICA SI EN LA FACTURA ACTUAL TUVO MULTIPLES SUBPROYECTOS, PARA CUADRAR AL FINAL EL IMPORTE ACUMULADO + If Not AplicaNCMasiva AndAlso AplicoNCFacturaActual Then + TieneMultiplesSubProyectos = TmpDT.FiltraParametros("", "", {"CveSubProyecto"}).COUNT("CveSubProyecto", "CveSubProyecto > 0") > 1 + If TieneMultiplesSubProyectos Then + AcumuladoNC = TxtNCImporte.Text.Trim.ToDecimal + End If + End If + 'ASUSTO LA DIFERENCIA EN EL ÚLTIMO CONCEPTO - If TipoDoctoNC = "Egs" AndAlso (Not AplicaNuevoDocumento) AndAlso AplicaNCMasiva AndAlso (Not NCDescuento) AndAlso AcumuladoNC > 0 Then + If TipoDoctoNC = "Egs" AndAlso (Not AplicaNuevoDocumento) AndAlso (AplicaNCMasiva OrElse TieneMultiplesSubProyectos) AndAlso (Not NCDescuento) AndAlso AcumuladoNC > 0 Then 'CODIGO PARA AJUSTE DE CENTAVO, SI EL IMPORTE TOTAL NO CUADRA CON LOS TOTALES Dim ImporteNC As Decimal = DtImpuestos.SUMD("ImporteTotal") + DtImpuestos.SUMD("ImporteIVA") + DtImpuestos.SUMD("ImporteIEPS") - DtImpuestos.SUMD("ImporteRetIVA") - DtImpuestos.SUMD("ImporteRetISR") @@ -28608,8 +28712,9 @@ Partial Class Ventas End If Dim AplicaRedondeo As Boolean = True + Dim TieneMultiplesSubProyectos As Boolean = TmpDT.FiltraParametros("", "", {"CveSubProyecto"}).COUNT("CveSubProyecto", "CveSubProyecto > 0") > 1 - If AplicaNCMasiva AndAlso Not NCDescuento Then + If AplicaNCMasiva AndAlso Not NCDescuento OrElse TieneMultiplesSubProyectos Then AplicaRedondeo = False End If