--BDH. Promociones lubricantes
This commit is contained in:
@@ -9411,6 +9411,8 @@ Partial Class Ventas
|
||||
TmpDT.Rows(e.RowIndex)("CantidadConversion") = CantidadConversion
|
||||
End If
|
||||
|
||||
CalculaPSPromocionFiltrosLubricantes(TmpDT.Rows(e.RowIndex))
|
||||
|
||||
|
||||
DrPS = Nothing
|
||||
|
||||
@@ -9454,6 +9456,17 @@ Partial Class Ventas
|
||||
End If
|
||||
End If
|
||||
|
||||
'SI SE ELIMINA EL LUBRICANTE, ELIMINAR LOS FILTROS CON PROMOCION
|
||||
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
|
||||
If TmpDT.Rows(e.RowIndex)("CveClasificacion").ToString().ToString().Contiene("20516") Then
|
||||
Dim RowsFiltros = TmpDT.Select("CveClasificacion IN(20515) AND Descuento > 0")
|
||||
For Each Row As DataRow In RowsFiltros
|
||||
TmpDT.Rows.Remove(Row)
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
Dim DbRow As DataRow = Nothing
|
||||
DbRow = TmpDT.Rows(e.RowIndex)
|
||||
TmpDT.Rows.Remove(DbRow)
|
||||
@@ -18749,7 +18762,7 @@ Partial Class Ventas
|
||||
CargaListasPreciosSubProyectos(If(DdlPS.SelectedValue.ToEntero() <= 0, -1, DdlPS.SelectedValue.ToEntero()))
|
||||
|
||||
If DdlTipoComprobante.SelectedValue = "Ant" AndAlso UsuarioActual.CveEmpresa = 189 Then
|
||||
Dim DatarowPS = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:="84111506").FiltroPrimero("")
|
||||
Dim DatarowPS = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:="84111506").FiltroPrimero("CodigoPS LIKE '%ANTICIPO%' OR CodigoPS LIKE '%anticipo%' OR CodigoPS LIKE '%Anticipo%'")
|
||||
If DatarowPS IsNot Nothing Then
|
||||
DdlPS.SelectedValue = DatarowPS("CvePS").ToString()
|
||||
DdlPS.SelectedText = DatarowPS("CodigoPS").ToString()
|
||||
@@ -19791,6 +19804,9 @@ Partial Class Ventas
|
||||
ListaDescuentos.Add(ObjDescuento)
|
||||
End If
|
||||
|
||||
'CALCULA EN BASE AL ULTIMO AGREGADO
|
||||
CalculaPSPromocionFiltrosLubricantes(TmpDT.Rows(TmpDT.Rows.Count - 1))
|
||||
|
||||
CalculaTotalesVenta()
|
||||
|
||||
LimpiaAgregar()
|
||||
@@ -19813,6 +19829,87 @@ Partial Class Ventas
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub CalculaPSPromocionFiltrosLubricantes(ByRef RowEdit As DataRow)
|
||||
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
|
||||
Dim CantidadMinValidaPromoFiltro As Decimal = 4
|
||||
Dim CantidadMinValidaPromoLubricantes As Decimal = 5
|
||||
|
||||
'DESCUENTO EN LUBRICANTES
|
||||
If RowEdit IsNot Nothing AndAlso RowEdit("CveClasificacion").ToString().Contiene("20516") Then
|
||||
Dim Cantidad As Decimal = RowEdit("Cantidad").ToString().ToDecimal()
|
||||
'CALCULA LA CANTIDAD DE DESCUENTO, REDONDEO HACIA ABAJO
|
||||
Dim CantidadDescuento As Decimal = Math.DivRem(Cantidad.ToString().ToEntero(), CantidadMinValidaPromoLubricantes.ToString().ToEntero(), 1).ToString().ToDecimal()
|
||||
|
||||
Dim Descuentos = CantidadDescuento * RowEdit("PU").ToString().ToDecimal()
|
||||
|
||||
Dim PU As Decimal = RowEdit("PU").ToString().ToDecimal()
|
||||
Dim TotalCalculableImpuestos As Decimal = ((Cantidad * PU) - (Descuentos))
|
||||
Dim TotalCalculableImpuestosIVA As Decimal = 0
|
||||
TotalCalculableImpuestosIVA = TotalCalculableImpuestos * (1 + RowEdit("PorcentajeIEPS").ToString().ToDecimal)
|
||||
|
||||
RowEdit("Cantidad") = Cantidad
|
||||
RowEdit("Descuento") = Descuentos
|
||||
RowEdit("ImporteIVA") = (RowEdit("PorcentajeIVA").ToString().ToDecimal * TotalCalculableImpuestosIVA).RoundSQL(NumeroDecimales)
|
||||
|
||||
RowEdit("Descuento") = Descuentos
|
||||
RowEdit("Total") = (Cantidad * PU)
|
||||
RowEdit("TotalImporte") = (Cantidad * PU).RoundSQL(NumeroDecimales)
|
||||
RowEdit("TotalConImpuestos") = (RowEdit("Total").ToString().ToDecimal() - RowEdit("Descuento").ToString().ToDecimal() + RowEdit("ImporteIVA").ToString().ToDecimal()).RoundSQL(2)
|
||||
|
||||
'VERIFICA SI TIENE FILTROS AGREGADOS, ELIMINAR SI YA NO CUMPLE LA PROMOCION
|
||||
If CantidadDescuento <= 0 Then
|
||||
Dim RowsFiltros = TmpDT.Select("CveClasificacion IN(20515) AND Descuento > 0")
|
||||
For Each Row As DataRow In RowsFiltros
|
||||
TmpDT.Rows.Remove(Row)
|
||||
Next
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
' DESCUENTO EN FILTROS
|
||||
If RowEdit IsNot Nothing AndAlso RowEdit("CveClasificacion").ToString().Contiene("20515") Then
|
||||
Dim TotalLubricantes = TmpDT.SUMD("Cantidad", "CveClasificacion IN(20516)")
|
||||
Dim TotalFiltros = TmpDT.SUMD("Cantidad", "CveClasificacion IN(20515) AND Descuento = 0")
|
||||
Dim TotalFiltrosDescuento = TmpDT.SUMD("Cantidad", "CveClasificacion IN(20515) AND Descuento > 0")
|
||||
|
||||
'SI HAY LUBRICANTES, 1 FILTRO DEBE SER GRATIS
|
||||
If TotalLubricantes >= CantidadMinValidaPromoFiltro Then
|
||||
'CALCULA LA CANTIDAD DE DESCUENTO, REDONDEO HACIA ABAJO
|
||||
Dim CantidadDescuento As Decimal = Math.DivRem(TotalLubricantes.ToString().ToEntero(), CantidadMinValidaPromoFiltro.ToString().ToEntero(), 1).ToString().ToDecimal()
|
||||
|
||||
'VERIFICA QUE AUN SE PUEDA APLICAR DESCUENTO
|
||||
If TotalFiltrosDescuento < CantidadDescuento Then
|
||||
Dim Cantidad As Decimal = RowEdit("Cantidad").ToString().ToDecimal()
|
||||
|
||||
'AJUSTA PARA QUE DEL DESCUENTO NO SUPERA EL VALOR DEL FILTRO
|
||||
If CantidadDescuento > Cantidad Then
|
||||
CantidadDescuento = Cantidad
|
||||
End If
|
||||
|
||||
Dim Descuentos = CantidadDescuento * RowEdit("PU").ToString().ToDecimal()
|
||||
|
||||
Dim PU As Decimal = RowEdit("PU").ToString().ToDecimal()
|
||||
Dim TotalCalculableImpuestos As Decimal = ((Cantidad * PU) - (Descuentos))
|
||||
Dim TotalCalculableImpuestosIVA As Decimal = 0
|
||||
TotalCalculableImpuestosIVA = TotalCalculableImpuestos * (1 + RowEdit("PorcentajeIEPS").ToString().ToDecimal)
|
||||
|
||||
RowEdit("Cantidad") = Cantidad
|
||||
RowEdit("Descuento") = Descuentos
|
||||
RowEdit("ImporteIVA") = (RowEdit("PorcentajeIVA").ToString().ToDecimal * TotalCalculableImpuestosIVA).RoundSQL(NumeroDecimales)
|
||||
|
||||
RowEdit("Descuento") = Descuentos
|
||||
RowEdit("Total") = (Cantidad * PU)
|
||||
RowEdit("TotalImporte") = (Cantidad * PU).RoundSQL(NumeroDecimales)
|
||||
RowEdit("TotalConImpuestos") = (RowEdit("Total").ToString().ToDecimal() - RowEdit("Descuento").ToString().ToDecimal() + RowEdit("ImporteIVA").ToString().ToDecimal()).RoundSQL(2)
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub CalculaLineasAdicionales()
|
||||
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "PA") AndAlso UsuarioActual.Empresa.Funcionalidad(705) = "1" Then
|
||||
DdlLineaAdicional.DataSource = Nothing
|
||||
|
||||
Reference in New Issue
Block a user