merge en ventas.pv

This commit is contained in:
2020-01-27 13:33:20 -07:00
32 changed files with 1686 additions and 1310 deletions

View File

@@ -13929,21 +13929,21 @@ Partial Class Ventas
Dim PorcentajeProducto2 = RowPorcentaje("PorcentajeProducto2").ToString().ToDecimal() / 100D
Dim PorcentajeProducto3 = RowPorcentaje("PorcentajeProducto3").ToString().ToDecimal() / 100D
Dim TotalInicial = (Cantidad * (PU)) - Descuento
Dim TotalInicial As Decimal = (Cantidad * (PU)) - Descuento
Dim TotalFinal = TotalInicial
'SI APLICA EL PRIMER DESCUENTO
If PorcentajeProducto > 0 Then
Dim Descuento1 = TotalInicial * PorcentajeProducto
Dim Descuento1 As Decimal = (TotalInicial * PorcentajeProducto).RoundSQL(2)
Dim Total2 = (TotalInicial - Descuento1)
'SI APLICA EL SEGUNDO DESCUENTO
If PorcentajeProducto2 > 0 Then
Dim Descuento2 = Total2 * PorcentajeProducto2
Dim Descuento2 As Decimal = (Total2 * PorcentajeProducto2).RoundSQL(2)
Dim Total3 = (Total2 - Descuento2)
'SI APLICA EL TERCER DESCUENTO
If PorcentajeProducto3 > 0 Then
Dim Descuento3 = Total3 * PorcentajeProducto3
Dim Descuento3 As Decimal = (Total3 * PorcentajeProducto3).RoundSQL(2)
TotalFinal = Total3 - Descuento3
Else
TotalFinal = Total3
@@ -15756,17 +15756,21 @@ Partial Class Ventas
Try
Dim CveMovimientoVirtual As Integer = -1
Dim CveAlmacenVirtual As Integer = -1
Dim CveConceptoMovimientoVirtual As Integer = 36
Dim CveConceptoMovimientoVirtual As Integer = 37
Dim DtPSVirtual As DataTable = Nothing
Dim DtTamanios As DataTable = Nothing
Dim CveMovimientoEntradaDev As Integer = -1
Dim CveSubProyecto As Integer = -1
If ObjInventario.GetInv_Mov(CveRemision, UsuarioActual.CveEmpresa) Then
Dim RowMovimiento As DataRow = ObjInventario.DtResultados.FiltroPrimero("CvePS IS NULL AND ((CveTipoAlmacen = 24 AND CveConcepto = 2) OR (CveTipoAlmacen = 1 AND CveConcepto = 8)) AND CveVenta > 0")
If RowMovimiento IsNot Nothing Then
CveMovimientoEntradaDev = RowMovimiento("CveMovimiento").ToString().ToEntero()
CveAlmacenVirtual = RowMovimiento("CveAlmacen").ToString().ToEntero()
Dim tCveAlmacen = RowMovimiento("CveAlmacen").ToString().ToEntero()
CveSubProyecto = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen= {tCveAlmacen}").ToEntero()
CveAlmacenVirtual = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $" CveTipoAlmacen = 24 AND CveSubProyecto={CveSubProyecto}").ToEntero()
Else
OcurrioError = True
End If
@@ -15780,16 +15784,9 @@ Partial Class Ventas
OcurrioError = True
End If
'CARGA CONCEPTOS DEVUELTOS EN LA VENTA
'If ObjInventario.GetMovimientosDetalle(CveMovimientoEntradaDev, UsuarioActual.CveEmpresa) Then
' DtPSVirtual = ObjInventario.DtResultados.Copy()
'Else
' OcurrioError = True
'End If
If Not OcurrioError AndAlso DtPSVirtual.Rows.Count > 0 Then
CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, CveConceptoMovimientoVirtual, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, ObjFactura.CveVenta, -1, -1, Modulo:="Vta/V", CveMovimientoRelacionado:=CveMovimientoEntradaDev)
CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, CveConceptoMovimientoVirtual, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, ObjFactura.CveVenta, -1, -1, Modulo:="Vta/VV", CveMovimientoRelacionado:=CveMovimientoEntradaDev)
If CveMovimientoVirtual > 0 Then
For Each RowUsado As DataRow In DtPSVirtual.Rows
@@ -21247,20 +21244,24 @@ Partial Class Ventas
Dim ImporteReferencia As Decimal = If(DdlNCNivelImporte.SelectedValue.ToEntero = 1, Total, SubTotal)
Dim Porcentaje As Decimal = ((Importe * 100) / ImporteReferencia) / 100
Dim FiltroStr As String = ""
Dim importePuTemp As Decimal = 0
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"))
Dr("ImporteTotal") = Math.Round(Porcentaje * (TmpDT.SUM("TotalImporte", FiltroStr) - TmpDT.SUM("Descuento", FiltroStr)), 2)
importePuTemp = (Porcentaje * (TmpDT.SUM("TotalImporte", FiltroStr) - TmpDT.SUM("Descuento", FiltroStr))).ToDecimal
Dr("ImporteTotal") = importePuTemp.RoundSQL()
'Dr("ImporteIVA") = (Dr("ImporteTotal").ToString().ToDecimal() * Dr("PorcentajeIVA").ToString().ToDecimal()).RoundSQL(2)
'Dr("ImporteRetIVA") = (Dr("ImporteTotal").ToString().ToDecimal() * Dr("PorcentajeRetIVA").ToString().ToDecimal()).RoundSQL(2)
'Dr("ImporteRetISR") = (Dr("ImporteTotal").ToString().ToDecimal() * Dr("PorcentajeRetISR").ToString().ToDecimal()).RoundSQL(2)
'Dr("ImporteIEPS") = (Dr("ImporteTotal").ToString().ToDecimal() * Dr("PorcentajeIEPS").ToString().ToDecimal()).RoundSQL(2)
Dr("ImporteIVA") = Math.Round(Porcentaje * TmpDT.SUM("ImporteIVA", FiltroStr), 2)
Dr("ImporteRetIVA") = Math.Round(Porcentaje * TmpDT.SUM("ImporteRetIVA", FiltroStr), 2)
Dr("ImporteRetISR") = Math.Round(Porcentaje * TmpDT.SUM("ImporteRetISR", FiltroStr), 2)
Dr("ImporteIEPS") = Math.Round(Porcentaje * TmpDT.SUM("ImporteIEPS", FiltroStr), 2)
Dr("ImportePU") = Dr("ImporteTotal").ToString.ToDecimal '(Dr("ImporteTotal").ToString.ToDecimal - Dr("ImporteIVA").ToString.ToDecimal - Dr("ImporteRetIVA").ToString.ToDecimal - Dr("ImporteRetISR").ToString.ToDecimal - Dr("ImporteIEPS").ToString.ToDecimal)
Dr("ImporteIEPS") = (importePuTemp * Dr("PorcentajeIEPS").ToString().ToDecimal()).RoundSQL(2)
Dr("ImporteIVA") = ((importePuTemp + Dr("ImporteIEPS").ToString.ToDecimal) * Dr("PorcentajeIVA").ToString.ToDecimal)
Dr("ImporteRetIVA") = (importePuTemp * Dr("PorcentajeRetIVA").ToString().ToDecimal()).RoundSQL(2)
Dr("ImporteRetISR") = (importePuTemp * Dr("PorcentajeRetISR").ToString().ToDecimal()).RoundSQL(2)
'Dr("ImporteIVA") = (Porcentaje * TmpDT.SUM("ImporteIVA", FiltroStr)).RoundSQL(2)
'Dr("ImporteRetIVA") = Math.Round(Porcentaje * TmpDT.SUM("ImporteRetIVA", FiltroStr), 2)
'Dr("ImporteRetISR") = Math.Round(Porcentaje * TmpDT.SUM("ImporteRetISR", FiltroStr), 2)
'Dr("ImporteIEPS") = Math.Round(Porcentaje * TmpDT.SUM("ImporteIEPS", FiltroStr), 2)
Dr("ImportePU") = Dr("ImporteTotal").ToString.ToDecimal.RoundSQL(2) '(Dr("ImporteTotal").ToString.ToDecimal - Dr("ImporteIVA").ToString.ToDecimal - Dr("ImporteRetIVA").ToString.ToDecimal - Dr("ImporteRetISR").ToString.ToDecimal - Dr("ImporteIEPS").ToString.ToDecimal)
Next
'codigo para ajuste de centavo, si el importe total no cuadra con los totales
Dim difTmp As Decimal = Importe - (DtImpuestosLocal.SUMD("ImporteTotal") + DtImpuestosLocal.SUMD("ImporteIVA") + DtImpuestosLocal.SUMD("ImporteIEPS") - DtImpuestosLocal.SUMD("ImporteRetIVA") - DtImpuestosLocal.SUMD("ImporteRetISR"))
@@ -24122,39 +24123,45 @@ Partial Class Ventas
#End Region
Protected Sub DdlTipoRetencion_SelectedIndexChanged(sender As Object, e As EventArgs)
If UsuarioActual.Empresa.Funcionalidad(579) = "1" Then
If TmpDT IsNot Nothing AndAlso TmpDT.Rows.Count > 0 Then
For Each RowServicio As DataRow In TmpDT.Rows
Dim tClienteRetIVA = ClienteRetIVA
If tClienteRetIVA <= 0 Then
If DdlTipoRetencion.SelectedValue.Contiene("1", "2") Then
tClienteRetIVA = 0.106667D
ElseIf DdlTipoRetencion.SelectedValue.Contiene("3") Then
tClienteRetIVA = 0.04D
ElseIf DdlTipoRetencion.SelectedValue.Contiene("4") AndAlso CBool(RowServicio("EsOutSourcing").ToString()) Then
tClienteRetIVA = 0.06D
If CveVenta <= 0 Then
If UsuarioActual.Empresa.Funcionalidad(579) = "1" Then
If TmpDT IsNot Nothing AndAlso TmpDT.Rows.Count > 0 Then
For Each RowServicio As DataRow In TmpDT.Rows
Dim tClienteRetIVA = ClienteRetIVA
If tClienteRetIVA <= 0 Then
If DdlTipoRetencion.SelectedValue.Contiene("1", "2") Then
tClienteRetIVA = 0.106667D
ElseIf DdlTipoRetencion.SelectedValue.Contiene("3") Then
tClienteRetIVA = 0.04D
ElseIf DdlTipoRetencion.SelectedValue.Contiene("4") AndAlso CBool(RowServicio("EsOutSourcing").ToString()) Then
tClienteRetIVA = 0.06D
End If
ViewState("ClienteRetIVA") = tClienteRetIVA
End If
ViewState("ClienteRetIVA") = tClienteRetIVA
Dim TotalCalculableImpuestos As Decimal = (RowServicio("Cantidad").ToString().ToDecimal() * RowServicio("PU").ToString().ToDecimal()) - RowServicio("Descuento").ToString().ToDecimal()
RowServicio("ImporteRetIVA") = (TotalCalculableImpuestos * ClienteRetIVA).RoundSQL()
RowServicio("PorcentajeRetIVA") = ClienteRetIVA
Next
TxtRetIVA.Text = TmpDT.SUM("ImporteRetIVA").ToDecimal().FormatoNumero(2)
Dim PorcentajeRetIVA = (TmpDT.MAX("PorcentajeRetIVA").ToDecimal() * 100)
LblRetIVA.Text = PorcentajeRetIVA.FormatoNumero(2)
If PorcentajeRetIVA > 0 Then
DdlTipoRetencion.Visible = True
End If
Dim TotalCalculableImpuestos As Decimal = (RowServicio("Cantidad").ToString().ToDecimal() * RowServicio("PU").ToString().ToDecimal()) - RowServicio("Descuento").ToString().ToDecimal()
RowServicio("ImporteRetIVA") = (TotalCalculableImpuestos * ClienteRetIVA).RoundSQL()
RowServicio("PorcentajeRetIVA") = ClienteRetIVA
GvPS.DataSource = TmpDT
GvPS.DataBind()
Next
TxtRetIVA.Text = TmpDT.SUM("ImporteRetIVA").ToDecimal().FormatoNumero(2)
Dim PorcentajeRetIVA = (TmpDT.MAX("PorcentajeRetIVA").ToDecimal() * 100)
LblRetIVA.Text = PorcentajeRetIVA.FormatoNumero(2)
If PorcentajeRetIVA > 0 Then
DdlTipoRetencion.Visible = True
UpPS.Update()
End If
GvPS.DataSource = TmpDT
GvPS.DataBind()
UpPS.Update()
End If
End If
End Sub