diff --git a/Compras/RepComprasDetalle.aspx.vb b/Compras/RepComprasDetalle.aspx.vb index db2c11126..060289af1 100644 --- a/Compras/RepComprasDetalle.aspx.vb +++ b/Compras/RepComprasDetalle.aspx.vb @@ -397,8 +397,8 @@ Partial Class Compras_RepComprasDetalle ImprimirPDF(String.Format("{0}Formatos\Remesa.rdlc", UsuarioActual.Empresa.Ruta), DtDatos.FiltraParametros("CveCompra > 0"), params, "Remesa", RDSName:="DsCompras") End Sub Protected Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click - 'GvDatos.ExportToExcel("ReporteComprasClasificacion" & Now.ToShortDateString) - GenerarPDF("EXCEL") + GvDatos.ExportToExcel("ReporteComprasDetalles" & Now.ToShortDateString) + 'GenerarPDF("EXCEL") End Sub Protected Sub LnkPdf_Click(sender As Object, e As EventArgs) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 73e90ead8..b6bc26f8b 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -12379,14 +12379,20 @@ Partial Class Ventas ' Exit Sub 'End If Dim TotalCalculableImpuestos As Decimal = 0 - Dim Cantidad, PU, Descuento As Decimal + Dim TotalDescuentosRound As Decimal = 0 + Dim Cantidad, PU, Descuento, DescuentoRound As Decimal + For Each dr As DataRow In TmpDT.Rows Cantidad = dr("Cantidad").ToString.ToDecimal PU = dr("PU").ToString.ToDecimal 'proporcional la mortización al concepto - Descuento = PU * Cantidad / LblSubTotal1.Text.ToDecimal * Amortizacion + Descuento = (PU * Cantidad / LblSubTotal1.Text.ToDecimal * Amortizacion) + DescuentoRound = Descuento.RoundSQL(NumeroDecimales) + + TotalDescuentosRound += DescuentoRound + TotalCalculableImpuestos = (Cantidad * (PU)) - Descuento - dr("Descuento") = Descuento + dr("Descuento") = DescuentoRound dr("TotalImporte") = Math.Round(Cantidad * PU, NumeroDecimales) dr("ImporteIVA") = Math.Round(dr("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) dr("ImporteIEPS") = Math.Round(dr("PorcentajeIEPS").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) @@ -12395,6 +12401,19 @@ Partial Class Ventas dr("PorcentajeRetIVA") = ClienteRetIVA dr("PorcentajeRetISR") = ClienteRetISR Next + + 'REVISA SI EXISTEN DIFERENCIAS ENTRE EL DESCUENTO Y LO AMORTIZADO PARA REALIZAR UN AJUSTE EN EL ULTIMO CONCEPTO AGREGADO + Dim diff As Decimal = Math.Abs(TotalDescuentosRound - Amortizacion) + Dim DrUltimo As DataRow = TmpDT.Rows(TmpDT.Rows.Count - 1) + 'SI EL DESCUENTO SUPERA LO AMORTIZADO RESTA LA DIFERENCIA AL ULTIMO DESCUENTO + If TotalDescuentosRound > Amortizacion Then + DrUltimo("Descuento") = DrUltimo("Descuento").ToString().ToDecimal() - diff + End If + 'SI EL DESCUENTO ES MENOR A LO AMORTIZADO SUMA LA DIFERENCIA AL ULTIMO DESCUENTO + If TotalDescuentosRound < Amortizacion Then + DrUltimo("Descuento") = DrUltimo("Descuento").ToString().ToDecimal() + diff + End If + GvPS.DataSource = TmpDT GvPS.DataBind()