From 2fa9cc5713de1c1ace66786cd22a2d27fda6dd7b Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Fri, 6 Nov 2020 20:02:37 -0700 Subject: [PATCH] Usados entregados como descuentos --- Ventas/PV.aspx | 2 +- Ventas/PV.aspx.vb | 139 +++++++++++++++++++++++++++++++++------------- 2 files changed, 101 insertions(+), 40 deletions(-) diff --git a/Ventas/PV.aspx b/Ventas/PV.aspx index af87d4902..2cb3354f2 100644 --- a/Ventas/PV.aspx +++ b/Ventas/PV.aspx @@ -2707,7 +2707,7 @@
+ DataKeyNames="CvePSCargo,CveUM,Cargo,CveTamaño,CodigoPS"> diff --git a/Ventas/PV.aspx.vb b/Ventas/PV.aspx.vb index d16917935..b628ad122 100644 --- a/Ventas/PV.aspx.vb +++ b/Ventas/PV.aspx.vb @@ -4657,7 +4657,28 @@ Partial Class PV DdlPSIndexChange(DdlPS.SelectedValue.ToEntero, DdlPS) DdlUnidadMedida.SelectedValueExist(GvRow.DataKey("CveUM")) TxtCantidad.Text = GvRow.DataKey("Cantidad") - TxtObsPS.Text = GvRow.DataKey("Obs") + + 'Dim TotalCargos As Decimal = 0 + 'Dim StrTamanios As New StringBuilder() + 'StrTamanios.Append("Se recibierón los siguientes usados:") + + 'For Each Gvr As GridViewRow In GvRecepcionUsados.Rows + ' If Gvr.RowType = DataControlRowType.DataRow Then + ' If Gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal > 0 Then + ' TotalCargos += Gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal * Gvr.DataKey("Cargo").ToDecimal + ' StrTamanios.AppendFormat("{0},", Gvr.DataKey("CodigoPS")) + ' End If + ' End If + 'Next + + 'If TotalCargos > 0 Then + ' StrTamanios.Remove(StrTamanios.Length - 1, 1) + 'Else + ' StrTamanios.Clear() + 'End If + + TxtObsPS.Text = GvRow.DataKey("Obs") '.Replace(StrTamanios.ToString(), "") + TxtPrecio.Text = GvRow.DataKey("PU") TxtDescuento.Text = GvRow.DataKey("Descuento") LblTotalPS.Text = GvRow.DataKey("Total") @@ -6681,12 +6702,16 @@ Partial Class PV Dim TotalCargos As Decimal = 0 Dim TotalCantidad As Decimal = 0 + Dim StrTamanios As New StringBuilder() + StrTamanios.Append("Se recibierón los siguientes usados:") + For Each Gvr As GridViewRow In Gv.Rows If Gvr.RowType = DataControlRowType.DataRow Then If Gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal > 0 Then TotalCargos += Gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal * Gvr.DataKey("Cargo").ToDecimal TotalCantidad += Gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal + StrTamanios.AppendFormat("{0},", Gvr.DataKey("CodigoPS")) Dim Row As DataRow = TmpDTRecepcionUsados.NewRow() Row("CvePS") = Gvr.DataKey("CvePSCargo").ToEntero @@ -6703,9 +6728,15 @@ Partial Class PV End If Next + If TotalCargos > 0 Then + StrTamanios.Remove(StrTamanios.Length - 1, 1) + Else + StrTamanios.Clear() + End If + Dim StrCargos As New StringBuilder For Each CvePSCargo As Integer In ListaPSCargo - StrCargos.AppendFormat("{0},", CvePSCargo) + StrCargos.AppendFormat(" {0},", CvePSCargo) Next StrCargos.Remove(StrCargos.Length - 1, 1) @@ -6720,28 +6751,38 @@ Partial Class PV For Each Dr As DataRow In TmpDT.FiltraParametros($"EsCargo = True AND EliminarDB = False AND CvePS IN ({StrCargos})").Rows Dim TotalAnterior As Decimal = Dr("Cantidad").ToString.ToDecimal * Dr("PU").ToString.ToDecimal - Dim PUActual As Decimal = (TotalAnterior - TotalCargos) / Dr("Cantidad").ToString.ToDecimal - Dim Descuento As Decimal = Dr("Descuento").ToString.ToDecimal - Dim TotalCalculableImpuestos As Decimal = (Dr("Cantidad").ToString.ToDecimal * (PUActual)) - Descuento - TotalCargos -= TotalAnterior - - If PUActual <= 0 Then - Dim drt As DataRow() = TmpDT.Select("Consec = " & Dr("Consec").ToString) - TmpDT.Rows.Remove(drt(0)) - Else - Dim drt As DataRow() = TmpDT.Select("Consec = " & Dr("Consec").ToString) - Dim drr As DataRow = drt(0) - drr("PU") = PUActual - drr("ImporteIVA") = Math.Round(Dr("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) - drr("ImporteRetIVA") = Math.Round(ClienteRetIVA * TotalCalculableImpuestos, NumeroDecimales) - drr("ImporteRetISR") = Math.Round(ClienteRetISR * TotalCalculableImpuestos, NumeroDecimales) - drr("ImporteIEPS") = Math.Round(Dr("PorcentajeIEPS").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) - drr("IEPS") = Dr("ImporteIEPS") - drr("Total") = (Dr("Cantidad").ToString.ToDecimal * PUActual) - drr("TotalImporte") = Math.Round(Dr("Cantidad").ToString.ToDecimal * PUActual, NumeroDecimales) + 'Dim PUActual As Decimal = (TotalAnterior - TotalCargos) / Dr("Cantidad").ToString.ToDecimal + Dim DescuentoCargo As Decimal = (TotalCargos / Dr("Cantidad").ToString.ToDecimal) + If DescuentoCargo > (TotalAnterior - Dr("Descuento").ToString.ToDecimal()) Then + DescuentoCargo = (TotalAnterior - Dr("Descuento").ToString.ToDecimal()) End If + Dim Descuento As Decimal = Dr("Descuento").ToString.ToDecimal + DescuentoCargo + Dim TotalCalculableImpuestos As Decimal = (Dr("Cantidad").ToString.ToDecimal * (Dr("PU").ToString.ToDecimal)) - Descuento + TotalCargos -= DescuentoCargo + + 'If PUActual <= 0 Then + ' Dim drt As DataRow() = TmpDT.Select("Consec = " & Dr("Consec").ToString) + ' TmpDT.Rows.Remove(drt(0)) + 'Else + + + 'End If + + Dim drt As DataRow() = TmpDT.Select("Consec = " & Dr("Consec").ToString) + Dim drr As DataRow = drt(0) + 'drr("PU") = PUActual + drr("ImporteIVA") = Math.Round(Dr("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) + drr("ImporteRetIVA") = Math.Round(ClienteRetIVA * TotalCalculableImpuestos, NumeroDecimales) + drr("ImporteRetISR") = Math.Round(ClienteRetISR * TotalCalculableImpuestos, NumeroDecimales) + drr("ImporteIEPS") = Math.Round(Dr("PorcentajeIEPS").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) + drr("IEPS") = Dr("ImporteIEPS") + drr("Descuento") = Descuento + drr("Obs") = StrTamanios.ToString() + Dr("Obs").ToString() + 'drr("Total") = (Dr("Cantidad").ToString.ToDecimal * PUActual) + 'drr("TotalImporte") = Math.Round(Dr("Cantidad").ToString.ToDecimal * PUActual, NumeroDecimales) + If TotalCargos <= 0 Then Exit For End If @@ -6752,27 +6793,47 @@ Partial Class PV For Each Dr As DataRow In TmpDT.FiltraParametros($"EsCargo = False AND EliminarDB = False AND CvePS={CvePS}").Rows Dim PUAnterior As Decimal = Dr("Cantidad").ToString.ToDecimal * Dr("PU").ToString.ToDecimal - Dim PUActual As Decimal = PUAnterior - (TotalCargos / Dr("Cantidad").ToString.ToDecimal) - Dim Descuento As Decimal = Dr("Descuento").ToString.ToDecimal - Dim TotalCalculableImpuestos As Decimal = (Dr("Cantidad").ToString.ToDecimal * (PUActual)) - Descuento - TotalCargos += -(TotalCargos / Dr("Cantidad").ToString.ToDecimal) + Dim DescuentoCargo As Decimal = (TotalCargos / Dr("Cantidad").ToString.ToDecimal) - If PUActual <= 0 Then - Dim drt As DataRow() = TmpDT.Select("Consec = " & Dr("Consec").ToString) - TmpDT.Rows.Remove(drt(0)) - Else - Dim drt As DataRow() = TmpDT.Select("Consec = " & Dr("Consec").ToString) - Dim drr As DataRow = drt(0) - drr("PU") = PUActual - drr("ImporteIVA") = Math.Round(Dr("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) - drr("ImporteRetIVA") = Math.Round(ClienteRetIVA * TotalCalculableImpuestos, NumeroDecimales) - drr("ImporteRetISR") = Math.Round(ClienteRetISR * TotalCalculableImpuestos, NumeroDecimales) - drr("ImporteIEPS") = Math.Round(Dr("PorcentajeIEPS").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) - drr("IEPS") = Dr("ImporteIEPS") - drr("Total") = (Dr("Cantidad").ToString.ToDecimal * PUActual) - drr("TotalImporte") = Math.Round(Dr("Cantidad").ToString.ToDecimal * PUActual, NumeroDecimales) + If DescuentoCargo > (PUAnterior - Dr("Descuento").ToString.ToDecimal()) Then + DescuentoCargo = (PUAnterior - Dr("Descuento").ToString.ToDecimal()) End If + 'Dim PUActual As Decimal = PUAnterior - DescuentoCargo + Dim Descuento As Decimal = Dr("Descuento").ToString.ToDecimal + DescuentoCargo + + Dim TotalCalculableImpuestos As Decimal = (Dr("Cantidad").ToString.ToDecimal * (PUAnterior)) - Descuento + TotalCargos += -DescuentoCargo + + Dim drt As DataRow() = TmpDT.Select("Consec = " & Dr("Consec").ToString) + Dim drr As DataRow = drt(0) + + drr("ImporteIVA") = Math.Round(Dr("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) + drr("ImporteRetIVA") = Math.Round(ClienteRetIVA * TotalCalculableImpuestos, NumeroDecimales) + drr("ImporteRetISR") = Math.Round(ClienteRetISR * TotalCalculableImpuestos, NumeroDecimales) + drr("ImporteIEPS") = Math.Round(Dr("PorcentajeIEPS").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) + drr("IEPS") = Dr("ImporteIEPS") + drr("Descuento") = Descuento + 'drr("Obs") = StrTamanios.ToString() + Dr("Obs").ToString() + 'drr("Total") = (Dr("Cantidad").ToString.ToDecimal * PUActual) + 'drr("TotalImporte") = Math.Round(Dr("Cantidad").ToString.ToDecimal * PUActual, NumeroDecimales) + + 'If PUActual <= 0 Then + ' Dim drt As DataRow() = TmpDT.Select("Consec = " & Dr("Consec").ToString) + ' TmpDT.Rows.Remove(drt(0)) + 'Else + ' Dim drt As DataRow() = TmpDT.Select("Consec = " & Dr("Consec").ToString) + ' Dim drr As DataRow = drt(0) + ' 'drr("PU") = PUActual + ' drr("ImporteIVA") = Math.Round(Dr("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) + ' drr("ImporteRetIVA") = Math.Round(ClienteRetIVA * TotalCalculableImpuestos, NumeroDecimales) + ' drr("ImporteRetISR") = Math.Round(ClienteRetISR * TotalCalculableImpuestos, NumeroDecimales) + ' drr("ImporteIEPS") = Math.Round(Dr("PorcentajeIEPS").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) + ' drr("IEPS") = Dr("ImporteIEPS") + ' 'drr("Total") = (Dr("Cantidad").ToString.ToDecimal * PUActual) + ' 'drr("TotalImporte") = Math.Round(Dr("Cantidad").ToString.ToDecimal * PUActual, NumeroDecimales) + 'End If + If TotalCargos <= 0 Then Exit For End If