diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx
index f72859039..38d20fbab 100644
--- a/Ventas/Ventas.aspx
+++ b/Ventas/Ventas.aspx
@@ -4370,7 +4370,7 @@
+ DataKeyNames="ISTotal,Saldo,CveIE,Folio,Tipo,CveVenta,CveConceptoContable,CveConceptoContableAmor, TotalAnticipo, SubTotalAnticipo, IVAAnticipo,IEPS, ImpuestosLocalesAnticipo, SubTotalAmortizacion, SubTotal, Original, IVA, RetIVA, RetISR, IdCtaContableNC,FolioFiscal, CveClasificacionNC, TipoCambio,TipoCambioPago,TipoCambioHoy, CveMoneda,Fecha,SaldoSubTotal,SaldoConImpuestos,RegresarImpuesto,DevolucionImportePagado,CveCliente,Descuentos">
diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb
index 059d0372e..6996f5a11 100644
--- a/Ventas/Ventas.aspx.vb
+++ b/Ventas/Ventas.aspx.vb
@@ -6954,7 +6954,8 @@ Partial Class Ventas
If UsuarioActual.Empresa.Funcionalidad(381).Trim() = CveCliente.ToString() Then
Dim DeshabilitarAutorizacion As Boolean = CBool(GlobalDTSubProyectos(-1, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("DeshabilitaAutorizacion"))
- If DdlTipoComprobante.SelectedValue = "PA" AndAlso DeshabilitarAutorizacion Then
+ 'SI ESTA BLOQUEADO POR AUTORZACION O QUE TENGA LA OPCION DE AUTORIZACIONES Y NO SEA DEL MODULO DE COTIZACIONES
+ If (DdlTipoComprobante.SelectedValue.Contiene("PA") OrElse (DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso DdlTipoComprobante.Items.FindByValue("PA") IsNot Nothing AndAlso Not IfNull(Request("Op"), "").ToString() = "Cot")) AndAlso DeshabilitarAutorizacion Then
If DdlTipoComprobante.Items.FindByValue("Rem") Is Nothing Then
DdlTipoComprobante.Items.Insert(0, New ListItem("Remisión", "Rem"))
End If
@@ -11377,7 +11378,7 @@ Partial Class Ventas
End If
'SI LA APLICACION DE ANTICIPO SE HACE A NIVEL TOTAL, FORZAR EL AJUSTE POR REDONDEO
- DtImpuestos = CargaDtImpuestosNC(gvrt.DataKey("CveVenta").ToString().ToEntero(), gvrt.FCTextBox(String.Format("TxtAnticipo{0}", gvrt.RowIndex)).Text.ToDecimal, AplicaImpuestosLocales:=True, NCDescuento:=False, NivelTotal:=tTipoAmortizacion, ForzarAjuste:=ForzarAjuste)
+ DtImpuestos = CargaDtImpuestosNC(gvrt.DataKey("CveVenta").ToString().ToEntero(), gvrt.FCTextBox(String.Format("TxtAnticipo{0}", gvrt.RowIndex)).Text.ToDecimal, AplicaImpuestosLocales:=True, NCDescuento:=False, NivelTotal:=tTipoAmortizacion, ForzarAjuste:=ForzarAjuste, AplicaDescuentos:=True)
Dim query = From ddr In DtImpuestos
Group By PorcentajeIVA = ddr("PorcentajeIVA").ToString().ToDecimal,
@@ -11391,6 +11392,7 @@ Partial Class Ventas
ImporteRetIVA = x.Sum(Function(s) s("ImporteRetIVA").ToString().ToDecimal()).RoundSQL(2),' Math.Round(s("ImportePU").ToString().ToDecimal, 2)) * PorcentajeRetIVA,
ImporteRetISR = x.Sum(Function(s) s("ImporteRetISR").ToString().ToDecimal()).RoundSQL(2),' Math.Round(s("ImportePU").ToString().ToDecimal, 2)) * PorcentajeRetISR,
ImporteIEPS = x.Sum(Function(s) s("ImporteIEPS").ToString().ToDecimal()).RoundSQL(2), 'Math.Round(s("ImportePU").ToString().ToDecimal, 2)) * PorcentajeIEPS,
+ Descuento = x.Sum(Function(s) s("Descuento").ToString().ToDecimal()).RoundSQL(2),
PorcentajeIVA = PorcentajeIVA,
PorcentajeRetIVA = PorcentajeRetIVA,
PorcentajeRetISR = PorcentajeRetISR,
@@ -11423,7 +11425,7 @@ Partial Class Ventas
dr("IEPS") = Drr("ImporteIEPS").ToString().ToDecimal
- dr("Descuento") = Math.Round(0, NumeroDecimales)
+ dr("Descuento") = Drr("Descuento").ToString().ToDecimal
dr("TipoDescuento") = HdnTipoDescuento.Value
dr("Total") = Drr("ImporteTotal").ToString().ToDecimal
dr("CveClasificacion") = drpss("CveClasificacion")
@@ -11452,7 +11454,7 @@ Partial Class Ventas
Total = (TotalSubTotal - TotalDescuentos + TotalIVA + TotalIEPS - TotalRetIVA - TotalRetISR - TotalImpuestosLocales)
factura.SubTotal = TotalSubTotal
- factura.Descuento = 0
+ factura.Descuento = TotalDescuentos
factura.IVA = TotalIVA
factura.IEPS = TotalIEPS
factura.RetIVA = TotalRetIVA
@@ -14238,13 +14240,18 @@ Partial Class Ventas
If row2.DataKey("CveConceptoContable").ToString().ToEntero() = 3 Then
If row2.FCCheckBox("Chk" & row2.RowIndex).Checked Then
CveIEAnticipo = row2.DataKey("CveIE").ToString().ToEntero()
+
importeMovimiento = row2.FCTextBox("TxtAnticipo" & row2.RowIndex).Text.ToDecimal '- ((row2.FCTextBox("TxtAnticipo" & row2.RowIndex).Text.ToDecimal / row2.DataKey("TotalAnticipo").ToDecimal) * row2.DataKey("IVAAnticipo").ToDecimal)
+
Dim ImporteAnticipo As Decimal = importeMovimiento
Dim CveMonedaAnticipo As Integer = row2.DataKey("CveMoneda").ToString().ToEntero()
If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
- If DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then ImporteAnticipo = row2.FCTextBox("TxtAnticipo" & row2.RowIndex).Text.ToDecimal / row2.DataKey("TotalAnticipo").ToDecimal * row2.DataKey("SubTotalAnticipo").ToDecimal
+ If DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then
+ Dim DescuentosAnticipos As Decimal = row2.DataKey("Descuentos").ToDecimal
+ ImporteAnticipo = row2.FCTextBox("TxtAnticipo" & row2.RowIndex).Text.ToDecimal / (row2.DataKey("TotalAnticipo").ToDecimal - DescuentosAnticipos) * row2.DataKey("SubTotalAnticipo").ToDecimal
+ End If
Dim Importe11MX As Decimal = ImporteAnticipo
@@ -14903,6 +14910,10 @@ Partial Class Ventas
If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
'Nota cuando es Nota de crédiot, debe de tomar el devoluciones y rebajas
If ObjFactura.TipoDocto.Contiene("Egs") Then
+ If EsNCAmortizacion Then
+ TipoMovimiento = Not TipoMovimiento
+ End If
+
IdCtaContable = GlobalDTClasificaciones(ObjFactura.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToEntero()
Else
IdCtaContable = GlobalDTClasificaciones(ObjFactura.CveEmpresa).FiltroPrimeroValor("IdCuentaDescuento", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToEntero()
@@ -30041,7 +30052,7 @@ Partial Class Ventas
Next
End Sub
- Private Function CargaDtImpuestosNC(CveVentaNC As Integer, Importe As Decimal, Optional NCDescuento As Boolean = False, Optional AplicaImpuestosLocales As Boolean = True, Optional NivelTotal As Integer = 1, Optional AplicaNCUsado As Boolean = False, Optional ForzarAjuste As Boolean = False) As DataTable
+ Private Function CargaDtImpuestosNC(CveVentaNC As Integer, Importe As Decimal, Optional NCDescuento As Boolean = False, Optional AplicaImpuestosLocales As Boolean = True, Optional NivelTotal As Integer = 1, Optional AplicaNCUsado As Boolean = False, Optional ForzarAjuste As Boolean = False, Optional AplicaDescuentos As Boolean = False) As DataTable
Dim Total As Decimal = 0, SubTotal As Decimal = 0, Saldo As Decimal = 0
Dim TmpDT As DataTable = Nothing
@@ -30090,6 +30101,10 @@ Partial Class Ventas
DtImpuestosLocal.Columns.Add("ImporteRetIVA", GetType(Decimal))
DtImpuestosLocal.Columns.Add("ImporteRetISR", GetType(Decimal))
DtImpuestosLocal.Columns.Add("ImporteIEPS", GetType(Decimal))
+ If AplicaDescuentos Then
+ DtImpuestosLocal.Columns.Add("Descuento", GetType(Decimal))
+ End If
+
Dim ImporteReferencia As Decimal = If(NivelTotal = 1, Total, SubTotal)
Dim Porcentaje As Decimal = ((Importe * 100) / ImporteReferencia) / 100
@@ -30113,7 +30128,12 @@ Partial Class Ventas
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"))
- Dim importePuTemp As Decimal = (Porcentaje * (TmpDT.SUMD("TotalImporte", FiltroStr) - TmpDT.SUMD("Descuento", FiltroStr)))
+ Dim importePuTemp As Decimal = 0
+ If AplicaDescuentos Then
+ importePuTemp = (Porcentaje * (TmpDT.SUMD("TotalImporte", FiltroStr)))
+ Else
+ importePuTemp = (Porcentaje * (TmpDT.SUMD("TotalImporte", FiltroStr) - TmpDT.SUMD("Descuento", FiltroStr)))
+ End If
If Not AplicaImpuestosLocales Then
importePuTemp = importePuTemp - TotalImpuestosLocalesVentaOriginal
@@ -30134,12 +30154,20 @@ Partial Class Ventas
Dr("ImporteRetISR") = (importePuTemp * Dr("PorcentajeRetISR").ToString().ToDecimal())
Dr("ImportePU") = importePuTemp
+ If AplicaDescuentos Then
+ Dr("Descuento") = Porcentaje * TmpDT.SUMD("Descuento", FiltroStr)
+ End If
+
If AplicaRedondeo Then
Dr("ImporteIEPS") = Dr("ImporteIEPS").ToString().ToDecimal().RoundSQL(2)
Dr("ImporteIVA") = Dr("ImporteIVA").ToString().ToDecimal().RoundSQL(2)
Dr("ImporteRetIVA") = Dr("ImporteRetIVA").ToString().ToDecimal().RoundSQL(2)
Dr("ImporteRetISR") = Dr("ImporteRetISR").ToString().ToDecimal().RoundSQL(2)
Dr("ImportePU") = Dr("ImportePU").ToString().ToDecimal().RoundSQL(6)
+
+ If AplicaDescuentos Then
+ Dr("Descuento") = Dr("Descuento").ToString().ToDecimal().RoundSQL(2)
+ End If
End If