Compras Actualizar Conceptos Retencion IVA, Retencion ISR
This commit is contained in:
@@ -273,10 +273,12 @@ Public Class ClsCompras
|
|||||||
Public Function UpdateCompra(Descripcion As String, FolioSecundario As String, FechaVencimiento As Date, AplicaNotaCredito As Boolean, Observaciones As String, CveEstatusCompra As Integer,
|
Public Function UpdateCompra(Descripcion As String, FolioSecundario As String, FechaVencimiento As Date, AplicaNotaCredito As Boolean, Observaciones As String, CveEstatusCompra As Integer,
|
||||||
Descuento As Double, SubTotal As Double, IVA As Double, Total As Double, CveUsuario As Integer, CveCompra As Integer, Optional CveCajaChica As Integer = -1, Optional CvePersonal As Integer = -1,
|
Descuento As Double, SubTotal As Double, IVA As Double, Total As Double, CveUsuario As Integer, CveCompra As Integer, Optional CveCajaChica As Integer = -1, Optional CvePersonal As Integer = -1,
|
||||||
Optional CveProveedorSucursal As Integer = -1, Optional PorcentajeIVA As Double = 0, Optional NumeroReembolso As String = "", Optional CveTipoCompra As Integer = -1, Optional NoDeducible As Boolean = False,
|
Optional CveProveedorSucursal As Integer = -1, Optional PorcentajeIVA As Double = 0, Optional NumeroReembolso As String = "", Optional CveTipoCompra As Integer = -1, Optional NoDeducible As Boolean = False,
|
||||||
Optional CveFactura As Integer = -1, Optional CveContrato As Integer = -1) As Boolean
|
Optional CveFactura As Integer = -1, Optional CveContrato As Integer = -1, Optional CveRetIVAConcepto As Integer = -1, Optional CveRetISRConcepto As Integer = -1) As Boolean
|
||||||
|
|
||||||
Dim Retorno As Boolean = False
|
Dim Retorno As Boolean = False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DataAdapter("PA_Comp_CompraUpdate")
|
DataAdapter("PA_Comp_CompraUpdate")
|
||||||
|
|
||||||
With SqlAdapter.SelectCommand.Parameters
|
With SqlAdapter.SelectCommand.Parameters
|
||||||
@@ -301,6 +303,9 @@ Public Class ClsCompras
|
|||||||
.Add("@NoDeducible", SqlDbType.Bit).Value = NoDeducible
|
.Add("@NoDeducible", SqlDbType.Bit).Value = NoDeducible
|
||||||
.Add("@CveFactura", SqlDbType.Int).Value = CveFactura
|
.Add("@CveFactura", SqlDbType.Int).Value = CveFactura
|
||||||
.Add("@CveContrato", SqlDbType.Int).Value = CveContrato
|
.Add("@CveContrato", SqlDbType.Int).Value = CveContrato
|
||||||
|
|
||||||
|
.Add("@CveRetIVAConcepto", SqlDbType.Int).Value = CveRetIVAConcepto
|
||||||
|
.Add("@CveRetISRConcepto", SqlDbType.Int).Value = CveRetISRConcepto
|
||||||
End With
|
End With
|
||||||
|
|
||||||
Try
|
Try
|
||||||
@@ -3294,6 +3299,45 @@ Public Class ClsCompras
|
|||||||
Return Retorno
|
Return Retorno
|
||||||
End Function
|
End Function
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Public Function GetComprasPrepolizasRetIvaRetISRActualiza(CveCompra As Integer, CveRetIVAConcepto As Integer, CveRetISRConcepto As Integer) As Boolean
|
||||||
|
Dim Retorno As Boolean = False
|
||||||
|
DataAdapter("PA_Comp_ComprasPrepolizasRetIvaRetISRActualizaGet")
|
||||||
|
With SqlAdapter.SelectCommand.Parameters
|
||||||
|
.Add("@CveCompra", SqlDbType.Int).Value = CveCompra
|
||||||
|
.Add("@CveRetIVAConcepto", SqlDbType.Int).Value = CveRetIVAConcepto
|
||||||
|
.Add("@CveRetISRConcepto", SqlDbType.Int).Value = CveRetISRConcepto
|
||||||
|
End With
|
||||||
|
Try
|
||||||
|
SqlAdapter.Fill(Data)
|
||||||
|
Retorno = True
|
||||||
|
Catch ex As Exception
|
||||||
|
OnError("Ocurrió un error al Obtener los datos de retención de IVA y retención ISR.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||||
|
End Try
|
||||||
|
Return Retorno
|
||||||
|
End Function
|
||||||
|
|
||||||
|
|
||||||
|
Public Function UpdateComprasPrepolizasRetIvaRetISRActualiza(CvePrePolizaDetalle As Integer, CveConceptoContable As Integer) As Boolean
|
||||||
|
Dim Retorno As Boolean = False
|
||||||
|
DataAdapter("PA_Comp_ComprasPrepolizasRetIvaRetISRActualizaUpdate")
|
||||||
|
With SqlAdapter.SelectCommand.Parameters
|
||||||
|
.Add("@CvePrePolizaDetalle", SqlDbType.Int).Value = CvePrePolizaDetalle
|
||||||
|
.Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable
|
||||||
|
End With
|
||||||
|
Try
|
||||||
|
SqlAdapter.Fill(Data)
|
||||||
|
Retorno = True
|
||||||
|
Catch ex As Exception
|
||||||
|
OnError("Ocurrió un error al actualizar el concepto de la prepoliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||||
|
End Try
|
||||||
|
Return Retorno
|
||||||
|
End Function
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1126,6 +1126,37 @@ Partial Class Compras_Compras
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Private Property CveRetISRConceptoOriginal As Integer
|
||||||
|
Get
|
||||||
|
|
||||||
|
If ViewState("CveRetISRConceptoOriginal") Is Nothing Then
|
||||||
|
ViewState("CveRetISRConceptoOriginal") = -1
|
||||||
|
End If
|
||||||
|
|
||||||
|
Return ViewState("CveRetISRConceptoOriginal").ToString.ToEntero
|
||||||
|
|
||||||
|
End Get
|
||||||
|
Set(value As Integer)
|
||||||
|
ViewState("CveRetISRConceptoOriginal") = value
|
||||||
|
End Set
|
||||||
|
End Property
|
||||||
|
Private Property CveRetIVAConceptoOriginal As Integer
|
||||||
|
Get
|
||||||
|
If ViewState("CveRetIVAConceptoOriginal") Is Nothing Then
|
||||||
|
ViewState("CveRetIVAConceptoOriginal") = -1
|
||||||
|
End If
|
||||||
|
Return ViewState("CveRetIVAConceptoOriginal").ToString.ToEntero
|
||||||
|
End Get
|
||||||
|
Set(value As Integer)
|
||||||
|
ViewState("CveRetIVAConceptoOriginal") = value
|
||||||
|
End Set
|
||||||
|
End Property
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
||||||
If Not IsPostBack Then
|
If Not IsPostBack Then
|
||||||
'ImgBtnBuscarOC.Attributes.Add("data-toggle", "tooltip")
|
'ImgBtnBuscarOC.Attributes.Add("data-toggle", "tooltip")
|
||||||
@@ -2576,6 +2607,11 @@ Partial Class Compras_Compras
|
|||||||
|
|
||||||
DdlRetIVAConcepto.SelectedValueExist(dr("CveRetIVAConcepto").ToString)
|
DdlRetIVAConcepto.SelectedValueExist(dr("CveRetIVAConcepto").ToString)
|
||||||
DdlRetISRConcepto.SelectedValueExist(dr("CveRetISRConcepto").ToString)
|
DdlRetISRConcepto.SelectedValueExist(dr("CveRetISRConcepto").ToString)
|
||||||
|
|
||||||
|
CveRetIVAConceptoOriginal = If(dr("CveRetIVAConcepto").ToString.ToEntero > 0, dr("CveRetIVAConcepto").ToString.ToEntero, -1)
|
||||||
|
CveRetISRConceptoOriginal = If(dr("CveRetISRConcepto").ToString.ToEntero > 0, dr("CveRetISRConcepto").ToString.ToEntero, -1)
|
||||||
|
|
||||||
|
|
||||||
If dr("CveTipoConcepto").ToString.ToEntero = 1 Then LblProveedor.Text = "Proveedor:" Else LblProveedor.Text = "Acreedor:"
|
If dr("CveTipoConcepto").ToString.ToEntero = 1 Then LblProveedor.Text = "Proveedor:" Else LblProveedor.Text = "Acreedor:"
|
||||||
|
|
||||||
HdnCveEstatusFactura.Value = dr("CveEstatusFactura").ToString
|
HdnCveEstatusFactura.Value = dr("CveEstatusFactura").ToString
|
||||||
@@ -2844,6 +2880,16 @@ Partial Class Compras_Compras
|
|||||||
TxtObsPS.Enabled = True
|
TxtObsPS.Enabled = True
|
||||||
LbAgregar.Enabled = True
|
LbAgregar.Enabled = True
|
||||||
LnkUpdateFechaPago.Visible = True
|
LnkUpdateFechaPago.Visible = True
|
||||||
|
|
||||||
|
If DdlRetIVAConcepto.SelectedValue.ToEntero > 0 Then
|
||||||
|
DdlRetIVAConcepto.Enabled = True
|
||||||
|
End If
|
||||||
|
|
||||||
|
If DdlRetISRConcepto.SelectedValue.ToEntero > 0 Then
|
||||||
|
DdlRetISRConcepto.Enabled = True
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
BtnGuardar.Visible = False
|
BtnGuardar.Visible = False
|
||||||
@@ -9840,10 +9886,14 @@ Partial Class Compras_Compras
|
|||||||
'PORCENTAJE IVA
|
'PORCENTAJE IVA
|
||||||
Dim PorcentajeIVA As Decimal = TmpDT.MAX("IVAPorcentaje").ToDecimal
|
Dim PorcentajeIVA As Decimal = TmpDT.MAX("IVAPorcentaje").ToDecimal
|
||||||
|
|
||||||
|
|
||||||
|
Dim TmpCveRetIVAConcepto As Integer = If(CveRetIVAConceptoOriginal <> DdlRetIVAConcepto.SelectedValue.ToEntero, DdlRetIVAConcepto.SelectedValue.ToEntero, -1)
|
||||||
|
Dim TmpCveRetISRConcepto As Integer = If(CveRetISRConceptoOriginal <> DdlRetISRConcepto.SelectedValue.ToEntero, DdlRetISRConcepto.SelectedValue.ToEntero, -1)
|
||||||
|
|
||||||
If ObjCompra.UpdateCompra(TxtDescripcion.Text.Trim, TxtFolioSecundario.Text.Trim, TxtFechaPago.Text.ToDate, ChkAplicaNotaCredito.Checked, TxtObsFact.Text.Trim, CveEstatusFactura,
|
If ObjCompra.UpdateCompra(TxtDescripcion.Text.Trim, TxtFolioSecundario.Text.Trim, TxtFechaPago.Text.ToDate, ChkAplicaNotaCredito.Checked, TxtObsFact.Text.Trim, CveEstatusFactura,
|
||||||
TxtDescuento.Text.ToDouble, TxtSubTotal.Text.ToDouble, TxtIVA.Text.ToDouble, TxtTotal.Text.ToDouble,
|
TxtDescuento.Text.ToDouble, TxtSubTotal.Text.ToDouble, TxtIVA.Text.ToDouble, TxtTotal.Text.ToDouble,
|
||||||
UsuarioActual.CveUsuario, CveCompra, CveCajaChica:=DdlRembolsoCajaChica.SelectedValue.ToEntero, CvePersonal:=DdlRembolsoPersonal.SelectedValue.ToEntero, CveProveedorSucursal:=If(DdlProveedorSucursal.SelectedValue.ToEntero > 0, DdlProveedorSucursal.SelectedValue.ToEntero, -1), PorcentajeIVA:=PorcentajeIVA, NumeroReembolso:=TxtRembolsoNumero.Text,
|
UsuarioActual.CveUsuario, CveCompra, CveCajaChica:=DdlRembolsoCajaChica.SelectedValue.ToEntero, CvePersonal:=DdlRembolsoPersonal.SelectedValue.ToEntero, CveProveedorSucursal:=If(DdlProveedorSucursal.SelectedValue.ToEntero > 0, DdlProveedorSucursal.SelectedValue.ToEntero, -1), PorcentajeIVA:=PorcentajeIVA, NumeroReembolso:=TxtRembolsoNumero.Text,
|
||||||
CveTipoCompra:=DdlTipoCompra.SelectedValue.ToEntero, NoDeducible:=EsNoDeducible) Then
|
CveTipoCompra:=DdlTipoCompra.SelectedValue.ToEntero, NoDeducible:=EsNoDeducible, CveRetIVAConcepto:=TmpCveRetIVAConcepto, CveRetISRConcepto:=TmpCveRetISRConcepto) Then
|
||||||
|
|
||||||
If Not ComparaDatatables() Then
|
If Not ComparaDatatables() Then
|
||||||
|
|
||||||
@@ -10336,6 +10386,155 @@ Partial Class Compras_Compras
|
|||||||
Alert("La compra no se puede actualizar debido a que los totales no son iguales, verifique sus cambios", TipoMensaje.MsgError)
|
Alert("La compra no se puede actualizar debido a que los totales no son iguales, verifique sus cambios", TipoMensaje.MsgError)
|
||||||
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
If Retorno AndAlso (CveRetIVAConceptoOriginal <> DdlRetIVAConcepto.SelectedValue.ToEntero Or CveRetISRConceptoOriginal <> DdlRetISRConcepto.SelectedValue.ToEntero) Then
|
||||||
|
If ObjCompra.GetComprasPrepolizasRetIvaRetISRActualiza(CveCompra, CveRetIVAConceptoOriginal, CveRetISRConceptoOriginal) Then
|
||||||
|
|
||||||
|
Dim DTPRePolizaDesbloquedo As DataTable = ObjCompra.DtResultados.FiltraParametros("", "", {"CvePrePoliza", "Bloqueado"})
|
||||||
|
Dim DTPRePolizaDes As DataTable = ObjCompra.DtResultados
|
||||||
|
|
||||||
|
If DTPRePolizaDesbloquedo IsNot Nothing Then
|
||||||
|
|
||||||
|
For Each dr1 As DataRow In DTPRePolizaDesbloquedo.Rows
|
||||||
|
|
||||||
|
If Boolean.Parse(dr1("Bloqueado").ToString) Then
|
||||||
|
|
||||||
|
If Not ObjContabilidad.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then
|
||||||
|
Retorno = False
|
||||||
|
End If
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
Next
|
||||||
|
|
||||||
|
If Retorno Then
|
||||||
|
|
||||||
|
For Each dr2 As DataRow In DTPRePolizaDes.Rows
|
||||||
|
|
||||||
|
Dim CveConceptoContableOriginal As Integer = dr2("CveConceptoContable").ToString.ToEntero
|
||||||
|
Dim CveConceptoContableNuvo As Integer = -1
|
||||||
|
|
||||||
|
If dr2("Tipo").ToString = "IVA" Then
|
||||||
|
|
||||||
|
Select Case DdlRetIVAConcepto.SelectedValue.ToEntero
|
||||||
|
Case 1
|
||||||
|
|
||||||
|
If CveConceptoContableOriginal.Contiene(184, 186, 249, 286) Then
|
||||||
|
CveConceptoContableNuvo = 15
|
||||||
|
ElseIf CveConceptoContableOriginal.Contiene(183, 185, 248, 285) Then
|
||||||
|
CveConceptoContableNuvo = 22
|
||||||
|
End If
|
||||||
|
|
||||||
|
Exit Select
|
||||||
|
Case 2
|
||||||
|
|
||||||
|
If CveConceptoContableOriginal.Contiene(22, 186, 249, 286) Then
|
||||||
|
CveConceptoContableNuvo = 184
|
||||||
|
ElseIf CveConceptoContableOriginal.Contiene(15, 185, 248, 285) Then
|
||||||
|
CveConceptoContableNuvo = 183
|
||||||
|
End If
|
||||||
|
|
||||||
|
Exit Select
|
||||||
|
Case 3
|
||||||
|
|
||||||
|
If CveConceptoContableOriginal.Contiene(22, 184, 249, 286) Then
|
||||||
|
CveConceptoContableNuvo = 186
|
||||||
|
ElseIf CveConceptoContableOriginal.Contiene(15, 183, 248, 285) Then
|
||||||
|
CveConceptoContableNuvo = 187
|
||||||
|
End If
|
||||||
|
|
||||||
|
Exit Select
|
||||||
|
Case 4
|
||||||
|
|
||||||
|
If CveConceptoContableOriginal.Contiene(22, 184, 186, 286) Then
|
||||||
|
CveConceptoContableNuvo = 249
|
||||||
|
ElseIf CveConceptoContableOriginal.Contiene(15, 183, 185, 285) Then
|
||||||
|
CveConceptoContableNuvo = 248
|
||||||
|
End If
|
||||||
|
|
||||||
|
Exit Select
|
||||||
|
Case 5
|
||||||
|
|
||||||
|
If CveConceptoContableOriginal.Contiene(22, 184, 186, 249) Then
|
||||||
|
CveConceptoContableNuvo = 286
|
||||||
|
ElseIf CveConceptoContableOriginal.Contiene(15, 183, 185, 248) Then
|
||||||
|
CveConceptoContableNuvo = 285
|
||||||
|
End If
|
||||||
|
|
||||||
|
Exit Select
|
||||||
|
End Select
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
If dr2("Tipo").ToString = "ISR" Then
|
||||||
|
Select Case DdlRetISRConcepto.SelectedValue.ToEntero
|
||||||
|
Case 1
|
||||||
|
|
||||||
|
If CveConceptoContableOriginal.Contiene(244, 328) Then
|
||||||
|
CveConceptoContableNuvo = 23
|
||||||
|
ElseIf CveConceptoContableOriginal.Contiene(243, 327) Then
|
||||||
|
CveConceptoContableNuvo = 16
|
||||||
|
End If
|
||||||
|
|
||||||
|
Exit Select
|
||||||
|
Case 2
|
||||||
|
|
||||||
|
If CveConceptoContableOriginal.Contiene(23, 328) Then
|
||||||
|
CveConceptoContableNuvo = 244
|
||||||
|
ElseIf CveConceptoContableOriginal.Contiene(16, 327) Then
|
||||||
|
CveConceptoContableNuvo = 243
|
||||||
|
End If
|
||||||
|
|
||||||
|
Exit Select
|
||||||
|
Case 3
|
||||||
|
|
||||||
|
If CveConceptoContableOriginal.Contiene(23, 244) Then
|
||||||
|
CveConceptoContableNuvo = 328
|
||||||
|
ElseIf CveConceptoContableOriginal.Contiene(16, 243) Then
|
||||||
|
CveConceptoContableNuvo = 327
|
||||||
|
End If
|
||||||
|
|
||||||
|
Exit Select
|
||||||
|
End Select
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
If Not (CveConceptoContableNuvo > 0 AndAlso ObjCompra.UpdateComprasPrepolizasRetIvaRetISRActualiza(dr2("CvePrePolizaDetalle").ToString.ToEntero, CveConceptoContableNuvo)) Then
|
||||||
|
Retorno = False
|
||||||
|
If CveConceptoContableNuvo <= 0 Then
|
||||||
|
Alert("Se presento un error al asiganar el nuevo concepto de retención", TipoMensaje.MsgAdvertencia)
|
||||||
|
End If
|
||||||
|
Exit For
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
Next
|
||||||
|
|
||||||
|
For Each dr1 As DataRow In DTPRePolizaDesbloquedo.Rows
|
||||||
|
|
||||||
|
If Boolean.Parse(dr1("Bloqueado").ToString) Then
|
||||||
|
If Not ObjContabilidad.UpdatePrePolizasDetalleBloquear(CvePrePoliza, True) Then
|
||||||
|
Retorno = False
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
Next
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
Else
|
||||||
|
Retorno = False
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
Alert("Ocurrió un error al actualizar la compra", TipoMensaje.MsgError)
|
Alert("Ocurrió un error al actualizar la compra", TipoMensaje.MsgError)
|
||||||
ObjCompra.RollBack()
|
ObjCompra.RollBack()
|
||||||
|
|||||||
Reference in New Issue
Block a user