-- al aplicar NC sobre un ingreso, recalcula el ajuste, si hay diferencia, considerando que no tenga impuestos, tenga iva o ieps

This commit is contained in:
rrene
2020-09-22 12:15:40 -07:00
parent e2aedeed0d
commit 92f8ba4aab

View File

@@ -21048,7 +21048,7 @@ Partial Class Ventas
If CveMovimientoEntradaGeneral > 0 Then If CveMovimientoEntradaGeneral > 0 Then
If ObjInventario.GetMovimientosDetalle(CveMovimientoSalidaConsignacion, UsuarioActual.CveEmpresa) Then If ObjInventario.GetMovimientosDetalle(CveMovimientoSalidaConsignacion, UsuarioActual.CveEmpresa) Then
For Each Dr As DataRow In ObjInventario.DtResultados.Rows For Each Dr As DataRow In ObjInventario.DtResultados.Rows
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaGeneral, Dr("Cantidad").ToString().ToDouble, Dr("CveUM").ToString().ToEntero(), Dr("CvePS").ToString().ToEntero(), Dr("PU").ToString().ToDecimal, CveAF:=Dr("CveAF").ToString().ToEntero(), CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString().ToEntero(), Serie:=Dr("Serie").ToString(), Lote:=Dr("Lote").ToString(), CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString().ToEntero(), CveVentaDetalle:=Dr("CveVentaDetalle").ToString().ToEntero()) Then If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaGeneral, Dr("Cantidad").ToString().ToDouble, Dr("CveUM").ToString().ToEntero(), Dr("CvePS").ToString().ToEntero(), Dr("PU").ToString().ToDecimal, CveAF:=Dr("CveAF").ToString().ToEntero(), CveSeccionAlmacen:=-3, Serie:=Dr("Serie").ToString(), Lote:=Dr("Lote").ToString(), CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString().ToEntero(), CveVentaDetalle:=Dr("CveVentaDetalle").ToString().ToEntero()) Then
Return False Return False
End If End If
Next Next
@@ -22843,12 +22843,55 @@ Partial Class Ventas
'codigo para ajuste de centavo, si el importe total no cuadra con los totales 'codigo para ajuste de centavo, si el importe total no cuadra con los totales
Dim difTmp As Decimal = Importe - importeNC Dim difTmp As Decimal = Importe - importeNC
'el ajuste procede si no tiene iva,ni ieps, con iva sin ieps,
If Math.Abs(difTmp) > 0.00D Then If Math.Abs(difTmp) > 0.00D Then
'asusto la diferencia en el último concepto 'filtro si hay renglon sin impuestos.
Dim ImporteAjustado As Decimal = DtImpuestosLocal.Rows(DtImpuestosLocal.Rows.Count - 1)("ImporteTotal").ToString().ToDecimal + difTmp Dim drDIF As DataRow() = DtImpuestosLocal.Select("ImporteIVA = 0 AND ImporteIEPS = 0")
DtImpuestosLocal.Rows(DtImpuestosLocal.Rows.Count - 1)("ImporteTotal") = ImporteAjustado
DtImpuestosLocal.Rows(DtImpuestosLocal.Rows.Count - 1)("ImportePU") = ImporteAjustado If drDIF IsNot Nothing AndAlso drDIF.Length > 0 Then
Dim ImporteAjustado0 As Decimal = drDIF(0)("ImporteTotal").ToString().ToDecimal + difTmp
drDIF(0)("ImporteTotal") = ImporteAjustado0
drDIF(0)("ImportePU") = ImporteAjustado0
Else
'filtro si hay renglon sin impuestos.
Dim drDIF2 As DataRow() = DtImpuestosLocal.Select("ImporteIVA > 0 AND ImporteIEPS = 0")
If drDIF2 IsNot Nothing AndAlso drDIF2.Length > 0 Then
Dim PorIVA As Decimal = drDIF2(0)("PorcentajeIVA").ToString().ToDecimal
Dim ImporteAjustado1 As Decimal = drDIF2(0)("ImporteTotal").ToString().ToDecimal + (difTmp / (1 + PorIVA)) 'saco el PU sin iva
drDIF2(0)("ImportePU") = ImporteAjustado1
drDIF2(0)("ImporteTotal") = ImporteAjustado1
drDIF2(0)("ImporteIVA") = (ImporteAjustado1) * drDIF2(0)("PorcentajeIVA").ToString().ToDecimal
Else
' ajustar cuando tiene ieps y no iva
Dim drDIF3 As DataRow() = DtImpuestosLocal.Select("ImporteIVA = 0 AND ImporteIEPS > 0")
If drDIF3 IsNot Nothing AndAlso drDIF3.Length > 0 Then
Dim PorIEPS As Decimal = drDIF3(0)("PorcentajeIEPS").ToString().ToDecimal
Dim ImporteAjustado1 As Decimal = drDIF3(0)("ImporteTotal").ToString().ToDecimal + (difTmp / (1 + PorIEPS)) 'saco el PU sin iva
drDIF3(0)("ImportePU") = ImporteAjustado1
drDIF3(0)("ImporteTotal") = ImporteAjustado1
drDIF3(0)("ImporteIEPS") = (ImporteAjustado1) * drDIF3(0)("PorcentajeIEPS").ToString().ToDecimal
Else
' ajustar cuando tiene ieps e iva
Dim drDIF4 As DataRow() = DtImpuestosLocal.Select("ImporteIVA > 0 AND ImporteIEPS > 0")
If drDIF4 IsNot Nothing AndAlso drDIF4.Length > 0 Then
Dim PorIEPS As Decimal = drDIF4(0)("PorcentajeIEPS").ToString().ToDecimal
Dim PorIVA As Decimal = drDIF4(0)("PorcentajeIVA").ToString().ToDecimal
Dim ImporteAntesIVA As Decimal = (difTmp / (1 + PorIVA))
Dim ImporteAjustado1 As Decimal = drDIF4(0)("ImporteTotal").ToString().ToDecimal + +(ImporteAntesIVA / (1 + PorIEPS)) 'saco el PU sin iva
drDIF4(0)("ImportePU") = ImporteAjustado1
drDIF4(0)("ImporteTotal") = ImporteAjustado1
drDIF4(0)("ImporteIEPS") = (ImporteAjustado1) * drDIF4(0)("PorcentajeIEPS").ToString().ToDecimal
drDIF4(0)("ImporteIVA") = (ImporteAjustado1 + drDIF4(0)("ImporteIEPS").ToString.ToDecimal) * drDIF4(0)("PorcentajeIVA").ToString().ToDecimal
End If
End If
End If
End If
End If End If
If Not NCDescuento Then If Not NCDescuento Then