Validacion de prepolizas al actualizar compra, buscar a nivel compra
This commit is contained in:
@@ -1199,6 +1199,25 @@ Public Class ClsContabilidad
|
|||||||
Return Retorno
|
Return Retorno
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Public Function GetPrePolizasDetalleCompra(CveCompra As Integer, CveEmpresa As Integer, Optional CveIE As Integer = -1) As Boolean
|
||||||
|
Dim Retorno As Boolean = False
|
||||||
|
DataAdapter("PA_Conta_PrePolizasDetalleCompraGet")
|
||||||
|
With SqlAdapter.SelectCommand.Parameters
|
||||||
|
.Add("@CveCompra", SqlDbType.Int).Value = CveCompra
|
||||||
|
.Add("@CveIE", SqlDbType.Int).Value = CveIE
|
||||||
|
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
|
||||||
|
End With
|
||||||
|
|
||||||
|
Try
|
||||||
|
SqlAdapter.Fill(Data)
|
||||||
|
Retorno = True
|
||||||
|
Catch ex As Exception
|
||||||
|
OnError("Ocurrió un error al obtener movimientos prepolizas de la compra.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
|
||||||
|
End Try
|
||||||
|
|
||||||
|
Return Retorno
|
||||||
|
End Function
|
||||||
|
|
||||||
Public Function UpdatePrePolizasDetalleBloquear(CvePrePoliza As Integer, Bloquear As Boolean) As Boolean
|
Public Function UpdatePrePolizasDetalleBloquear(CvePrePoliza As Integer, Bloquear As Boolean) As Boolean
|
||||||
Dim Retorno As Boolean = False
|
Dim Retorno As Boolean = False
|
||||||
DataAdapter("PA_Conta_PrePolizasDetalleBloquearUpdate")
|
DataAdapter("PA_Conta_PrePolizasDetalleBloquearUpdate")
|
||||||
|
|||||||
@@ -9235,8 +9235,7 @@ Partial Class Compras_Compras
|
|||||||
tipoCambioPago = 1
|
tipoCambioPago = 1
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
Dim DtPrePolizas As DataTable = Nothing
|
||||||
|
|
||||||
|
|
||||||
If ObjConta.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPrePoliza) Then
|
If ObjConta.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPrePoliza) Then
|
||||||
For Each Row As DataRow In ObjConta.DtResultados.Rows
|
For Each Row As DataRow In ObjConta.DtResultados.Rows
|
||||||
@@ -9252,13 +9251,16 @@ Partial Class Compras_Compras
|
|||||||
Select Case ConceptoContable
|
Select Case ConceptoContable
|
||||||
|
|
||||||
Case 6
|
Case 6
|
||||||
|
|
||||||
Dim CveProveedorConcepto As Integer = 0, CveIE As Integer = 0, CveCreditoDetalle As Integer = 0
|
Dim CveProveedorConcepto As Integer = 0, CveIE As Integer = 0, CveCreditoDetalle As Integer = 0
|
||||||
Dim ConceptoPersonal As String = "", Concepto As String = ""
|
Dim ConceptoPersonal As String = "", Concepto As String = ""
|
||||||
|
|
||||||
If Not ObjConta.GetPrePolizasDetalle(CvePrePoliza, UsuarioActual.CveEmpresa) Then
|
If Not ObjConta.GetPrePolizasDetalleCompra(CveCompra, UsuarioActual.CveEmpresa) Then
|
||||||
ErrorPrepoliza = True
|
ErrorPrepoliza = True
|
||||||
Else
|
Else
|
||||||
If ObjConta.DtResultados.FiltraParametros("CveConceptoContable IN (6,68,49,205,176)").Rows.Count > 0 Then
|
DtPrePolizas = ObjConta.DtResultados.FiltraParametros("CveConceptoContable IN (6,68,49,205,176)")
|
||||||
|
|
||||||
|
If DtPrePolizas.Rows.Count > 0 Then
|
||||||
CveProveedorConcepto = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("CveProveedor").ToString.ToEntero
|
CveProveedorConcepto = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("CveProveedor").ToString.ToEntero
|
||||||
CveIE = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("CveIE").ToString.ToEntero
|
CveIE = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("CveIE").ToString.ToEntero
|
||||||
CveCreditoDetalle = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("CveCreditoDetalle").ToString.ToEntero
|
CveCreditoDetalle = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("CveCreditoDetalle").ToString.ToEntero
|
||||||
@@ -9270,6 +9272,11 @@ Partial Class Compras_Compras
|
|||||||
CveProveedorConcepto = DdlProveedor.SelectedValue.ToEntero
|
CveProveedorConcepto = DdlProveedor.SelectedValue.ToEntero
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
If Not ErrorPrepoliza Then
|
||||||
|
For Each RowPrePoliza As DataRow In DtPrePolizas.FiltraParametros("", DistinctColumns:={"CvePrePoliza"}).Rows
|
||||||
|
|
||||||
|
Dim CvePrePoliza As Integer = RowPrePoliza("CvePrePoliza").ToString().ToEntero()
|
||||||
|
|
||||||
'Removemos los conceptos de la prepoliza
|
'Removemos los conceptos de la prepoliza
|
||||||
If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 6, CveCompra, 1) Then ErrorPrepoliza = True 'GASTO
|
If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 6, CveCompra, 1) Then ErrorPrepoliza = True 'GASTO
|
||||||
If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 68, CveCompra, 1) Then ErrorPrepoliza = True 'ALMACEN
|
If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 68, CveCompra, 1) Then ErrorPrepoliza = True 'ALMACEN
|
||||||
@@ -9451,11 +9458,93 @@ Partial Class Compras_Compras
|
|||||||
'LIMPIA
|
'LIMPIA
|
||||||
importeMovimiento = 0
|
importeMovimiento = 0
|
||||||
IdCtaContable = 0
|
IdCtaContable = 0
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
|
||||||
|
'LIMPIA
|
||||||
|
importeMovimiento = 0
|
||||||
|
IdCtaContable = 0
|
||||||
|
|
||||||
|
' Case 5 'Proveedores
|
||||||
|
' Dim TieneConceptoProveedorAcreedor As Boolean = False
|
||||||
|
' Dim CveIE As Integer = -1
|
||||||
|
|
||||||
|
' 'If Not ObjConta.GetPrePolizasDetalleCompra(CveCompra, UsuarioActual.CveEmpresa) Then
|
||||||
|
' ' ErrorPrepoliza = True
|
||||||
|
' 'Else
|
||||||
|
' ' If ObjConta.DtResultados.FiltraParametros("CveConceptoContable IN (5,305)").Rows.Count > 0 Then
|
||||||
|
' ' TieneConceptoProveedorAcreedor = True
|
||||||
|
' ' CveIE = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("CveIE").ToString.ToEntero
|
||||||
|
' ' End If
|
||||||
|
' 'End If
|
||||||
|
|
||||||
|
' If TieneConceptoProveedorAcreedor Then
|
||||||
|
' If CveTipoConcepto = 2 Then ConceptoContable = 305 'cuando es acreedor
|
||||||
|
' Dim UsaComplementaria As Boolean = True
|
||||||
|
' If tipoCambioActual <> 1 Then
|
||||||
|
' Select Case ConceptoContable
|
||||||
|
' Case 5
|
||||||
|
' ConceptoContable = 311
|
||||||
|
' Case 305
|
||||||
|
' ConceptoContable = 306
|
||||||
|
' Case Else
|
||||||
|
' End Select
|
||||||
|
' End If
|
||||||
|
|
||||||
|
' Dim importeProv As Decimal = 0
|
||||||
|
' importeProv = TxtTotal.Text.ToDecimal
|
||||||
|
|
||||||
|
' If Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then
|
||||||
|
|
||||||
|
' importeMovimiento = importeProv
|
||||||
|
' importeMN = importeMovimiento * tipoCambioActual * Multiplicador
|
||||||
|
|
||||||
|
' If tipoCambioActual > 1 Then Referencia += $" TC{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}"
|
||||||
|
' Dim CveConceptoContableComplementaria As Integer = 201
|
||||||
|
' If CveTipoConcepto = 2 Then CveConceptoContableComplementaria = 307
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
' If tipoCambioActual = 1 Then
|
||||||
|
' IdCtaContable = If(CveTipoConcepto = 2, CtaProveedorAcreedores, CtaProveedor)
|
||||||
|
' Dim Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}"
|
||||||
|
|
||||||
|
' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveSubProyecto:=-1, CveProveedor:=CveProveedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=-1, ImporteMX:=Math.Round(importeMN, 2, MidpointRounding.AwayFromZero), ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual) Then
|
||||||
|
' ErrorPrepoliza = True
|
||||||
|
' Exit For
|
||||||
|
' End If
|
||||||
|
|
||||||
|
' Else
|
||||||
|
' IdCtaContable = CtaProveedorComplementaria
|
||||||
|
' If importeMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsaComplementaria) Then 'Cuando tiene complementaria lo dividimos en dos Then
|
||||||
|
' importeMN = importeMovimiento
|
||||||
|
' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, Referencia, CveConceptoContableComplementaria, Referencia, FechaMovimiento, IdCtaContable, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, ImporteMX:=importeMovimiento * tipoCambioActual - importeMovimiento, ImporteME:=importeMovimiento, TipoCambio:=tipoCambioActual) Then
|
||||||
|
' ErrorPrepoliza = True
|
||||||
|
' End If
|
||||||
|
' End If
|
||||||
|
' IdCtaContable = CtaProveedorExtranjera
|
||||||
|
' End If
|
||||||
|
' End If
|
||||||
|
' End If
|
||||||
|
|
||||||
End Select
|
End Select
|
||||||
Next
|
Next
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
If DtPrePolizas IsNot Nothing Then
|
||||||
|
For Each RowPrePoliza As DataRow In DtPrePolizas.FiltraParametros("", DistinctColumns:={"CvePrePoliza"}).Rows
|
||||||
|
If ObjConta.ValidacionPrePolizaCuadre(RowPrePoliza("CvePrePoliza").ToString().ToEntero(), 4) Then
|
||||||
|
If ObjConta.ValorPolizaDescuadre > 0 Then
|
||||||
|
ErrorPrepoliza = True
|
||||||
|
Alert("Error en validacion de prepoliza cuadre", TipoMensaje.MsgAdvertencia)
|
||||||
|
GuardaLogAD($"Compras/Compras-Actualizar | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
|
||||||
|
Exit For
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
|
||||||
|
'VALIDAR PREPOLIZA DE COMPRA
|
||||||
If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, 4) Then
|
If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, 4) Then
|
||||||
If ObjConta.ValorPolizaDescuadre > 0 Then
|
If ObjConta.ValorPolizaDescuadre > 0 Then
|
||||||
ErrorPrepoliza = True
|
ErrorPrepoliza = True
|
||||||
|
|||||||
Reference in New Issue
Block a user