-- mejoras en devoluciones

This commit is contained in:
2021-01-05 18:54:25 -07:00
parent 8f992a4af8
commit c48c0d8583

View File

@@ -1837,25 +1837,25 @@ Partial Class Compras_Compras
'TmpDT.Columns.Add("IEPSPSPorcentaje")
'TmpDT.Columns.Add("IEPSPSIVAPorcentaje")
SubTotalConceptos = Math.Round(TmpDT.SUM("Total"), 2).ToDecimal
AddPS2(False)
AddPS2(False)
'VALIDA QUE EL XML SI VIENE CON EL CODIGO SAT 01010101
Dim ProductosCodigoSATNoPermitidos As New StringBuilder("")
For Each drr As DataRow In TmpDT.FiltraParametros("ClaveProdServ = '01010101'").Rows
'VALIDA QUE EL XML SI VIENE CON EL CODIGO SAT 01010101
Dim ProductosCodigoSATNoPermitidos As New StringBuilder("")
For Each drr As DataRow In TmpDT.FiltraParametros("ClaveProdServ = '01010101'").Rows
ProductosCodigoSATNoPermitidos.AppendFormat("{0}</br>", drr("PS"))
ProductosCodigoSATNoPermitidos.AppendFormat("{0}</br>", drr("PS"))
Next
Next
If ProductosCodigoSATNoPermitidos.ToString.Length > 0 Then
Dim mensajeAdvertencia As String = String.Format("El comprobante contiene productos con código SAT '01010101', revise los productos:</br></br>{0}", ProductosCodigoSATNoPermitidos.ToString)
Alert(mensajeAdvertencia, TipoMensaje.MsgAdvertencia)
End If
If ProductosCodigoSATNoPermitidos.ToString.Length > 0 Then
Dim mensajeAdvertencia As String = String.Format("El comprobante contiene productos con código SAT '01010101', revise los productos:</br></br>{0}", ProductosCodigoSATNoPermitidos.ToString)
Alert(mensajeAdvertencia, TipoMensaje.MsgAdvertencia)
End If
Else
End If
Else
CargaConceptosXML(XMLDoc)
End If
@@ -4714,7 +4714,7 @@ Partial Class Compras_Compras
ViewState("CveCompra") = ObjCompras.CveCompra
If ObjCompras.DtResultados.Rows.Count > 0 Then ViewState("CompraFolio") = ObjCompras.DtResultados.Rows(0)("vFolio").ToString
If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then
Devolucion = guardardevolucion(ObjInventario, ObjCompras.CveCompra, TxtSubTotal.Text.ToDouble, TxtFecha.Text.Trim.ToDate)
Devolucion = guardardevolucion(ObjInventario, ObjCompras.CveCompra, TxtSubTotal.Text.ToDecimal, TxtFecha.Text.Trim.ToDate)
TieneError = Devolucion.TieneError
End If
@@ -7143,6 +7143,10 @@ Partial Class Compras_Compras
End If
End If
If CveCompraRefacturacion > 0 Then
importeMovimiento = 0
importeMN = 0
End If
Case 59 'Documentos
importeMovimiento = importeCreditos
@@ -14258,7 +14262,7 @@ Partial Class Compras_Compras
'*se envia true si hubo un error*'
Private Function guardardevolucion(ObjInventario As ClsInventarios, CveCompra As Integer, subtotal As Double, Fecha As Date) As MMensajeDevolucion
Private Function guardardevolucion(ObjInventario As ClsInventarios, CveCompra As Integer, subtotal As Decimal, Fecha As Date) As MMensajeDevolucion
Dim ErrorMovInv As Boolean = False
Dim CveAlmacen As Integer = DdlAlmacenDevolucion.SelectedValue.ToEntero()
Dim subtotaldevolucion As Double = 0
@@ -14266,6 +14270,7 @@ Partial Class Compras_Compras
Dim CveMovimientoEntrada As Integer = -1
'Calculo los subtotales para comparar con la NC
Dim cantidad As Double = 0.0
Dim TotalAlmacen As Decimal = 0
For Each Dr As GridViewRow In GVDevolucion.Rows
'CveAlmacen = Dr.DataKey("CveAlmacen").ToString.ToEntero
@@ -14285,14 +14290,24 @@ Partial Class Compras_Compras
If CveMovimientoEntrada <= 0 Then
ErrorMovInv = True
Else
Dim Acumulado As Decimal = 0
Dim PU As Decimal = 0
For Each Dr As GridViewRow In GVDevolucion.Rows
If Dr.FCTextBox("TxtCantidad").Text.ToDouble > 0 Then
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr.FCTextBox("TxtCantidad").Text.ToDouble, Dr.DataKey("CveUM").ToString.ToEntero, Dr.DataKey("CvePS").ToString.ToEntero, Dr.DataKey("PU").ToString.ToDecimal, -1, CveMovimientoDetalleEntrada:=Dr.DataKey("CveMovimientoDetalle").ToString.ToEntero) Then
Acumulado += (Dr.FCTextBox("TxtCantidad").Text.ToDecimal * Dr.DataKey("PU").ToString.ToDecimal)
PU = Dr.DataKey("PU").ToString.ToDecimal
If subtotal < Acumulado Then
Dim dif As Decimal = subtotal - Acumulado
PU = (((Dr.FCTextBox("TxtCantidad").Text.ToDecimal * Dr.DataKey("PU").ToString.ToDecimal)) + dif) / Dr.FCTextBox("TxtCantidad").Text.ToDecimal
End If
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr.FCTextBox("TxtCantidad").Text.ToDouble, Dr.DataKey("CveUM").ToString.ToEntero, Dr.DataKey("CvePS").ToString.ToEntero, PU, -1, CveMovimientoDetalleEntrada:=Dr.DataKey("CveMovimientoDetalle").ToString.ToEntero) Then
ErrorMovInv = True
Exit For
End If
End If
Next
End If
Else
ErrorMovInv = True
@@ -14354,18 +14369,18 @@ Partial Class Compras_Compras
'End Sub
Protected Sub BtnVinculaDevolucion_Click(sender As Object, e As EventArgs)
Try
Dim subtotaldevolucion As Double = 0
Dim subtotaldevolucion As Decimal = 0
Dim realizadevolucion As Boolean = False
'Calculo los subtotales para comparar con la NC
Dim cantidad As Double = 0.0
Dim cantidad As Decimal = 0
For Each Dr As GridViewRow In GVDevolucion.Rows
cantidad = Dr.FCTextBox("TxtCantidad").Text.ToDouble
cantidad = Dr.FCTextBox("TxtCantidad").Text.ToDecimal
If cantidad > 0 Then
realizadevolucion = True
subtotaldevolucion += Dr.DataKey("PU").ToString.ToDouble * cantidad
subtotaldevolucion += Dr.DataKey("PU").ToString.ToDecimal * cantidad
End If
Next
@@ -14399,6 +14414,7 @@ Partial Class Compras_Compras
Dim IEPSCompra As Decimal = TxtIEPS.Text.ToDecimal()
Dim RetIVACompra As Decimal = TxtRetIVA.Text.ToDecimal()
Dim RetISRCompra As Decimal = TxtRetISR.Text.ToDecimal()
Dim Acumulado As Decimal = 0
'Dim TotalCalculable As Decimal = TotalCompra - IEPSCompra + RetIVACompra + RetISRCompra
@@ -14428,6 +14444,15 @@ Partial Class Compras_Compras
Dim IVA As Decimal = IVAPorcentajeCompra 'Math.Round(Total * IVAPorcentajeCompra, 2)
Dim Descuento As Decimal = 0
Acumulado += (PU * Cantidad)
If SubTotalCompra < Acumulado Then
'ajusta el valor
Dim dif As Decimal = SubTotalCompra - Acumulado
PU = ((PU * Cantidad) + dif) / Cantidad
Total = Cantidad * PU
End If
AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, 0, 0, 0, 0, Descuento, -1, False)
End If