This commit is contained in:
rakcsle
2021-01-13 17:16:52 -07:00
63 changed files with 11672 additions and 9167 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1165,57 +1165,6 @@ Partial Class Compras_Compras
End Set
End Property
Private Property CveContratoObra As Integer
Get
If ViewState("CveContratoObra") Is Nothing Then
Return -1
Else
Return ViewState("CveContratoObra").ToString.ToEntero
End If
End Get
Set(value As Integer)
ViewState("CveContratoObra") = value
End Set
End Property
Private Property MaxIVAProcentaje As Decimal
Get
If ViewState("MaxIVAProcentaje") Is Nothing Then
Return 0
Else
Return ViewState("MaxIVAProcentaje").ToString.ToDecimal
End If
End Get
Set(value As Decimal)
ViewState("MaxIVAProcentaje") = value
End Set
End Property
Private Property MAXRetIVAPorcentaje As Decimal
Get
If ViewState("MAXRetIVAPorcentaje") Is Nothing Then
Return 0
Else
Return ViewState("MAXRetIVAPorcentaje").ToString.ToDecimal
End If
End Get
Set(value As Decimal)
ViewState("MAXRetIVAPorcentaje") = value
End Set
End Property
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
'ImgBtnBuscarOC.Attributes.Add("data-toggle", "tooltip")
@@ -1237,7 +1186,6 @@ Partial Class Compras_Compras
CveConceptoContableAlmacen = 0
EsNoDeducible = False
CveTipoConcepto = 1
'CargaContratos()
'******** Prorrateo ********************************************
If UsuarioActual.Empresa.Funcionalidad(117) <> "" Then
btnProrateo.Visible = True
@@ -1366,15 +1314,14 @@ Partial Class Compras_Compras
Dim ObjPersonal As New ClsRH
ObjPersonal.GetPersonal(-1, UsuarioActual.CveEmpresa)
DdlPersonal.DataSource = ObjPersonal.DtResultados
If UsuarioActual.CveEmpresa = 119 Then
DdlPersonalReembolso.DataSource = ObjPersonal.DtResultados
Else
DdlPersonalReembolso.DataSource = ObjPersonal.DtResultados.FiltraParametros("CveEstatusPersonal = 1")
End If
ObjPersonal.Dispose()
DdlPersonal.DataBind()
DdlPersonalReembolso.DataBind()
@@ -1502,8 +1449,6 @@ Partial Class Compras_Compras
DivEsNoDeducible.Visible = True
DivActualizarVincular.Visible = True
'LiAccionesContratos.Visible = False
Else
ViewState("CveProveedor") = -1
@@ -1828,17 +1773,6 @@ Partial Class Compras_Compras
Xml.Append(Replace(Replace(Replace(nodeconceptos.OuterXml, "<cfdi:", "<"), "</cfdi:", "</"), "xmlns:cfdi=""http://www.sat.gob.mx/cfd/3""", ""))
If ObjeFacturas.GetFacturasComparacionXML(Version, Xml.ToString, UsuarioActual.CveEmpresa) Then
TmpDT = ObjeFacturas.DtResultados
If ObjeFacturas.DtResultados.Rows.Count > 0 Then
MaxIVAProcentaje = ObjeFacturas.DtResultados.MAX("IVAPorcentaje").ToDecimal
MAXRetIVAPorcentaje = ObjeFacturas.DtResultados.MAX("RetIVAPorcentaje").ToDecimal
Else
MaxIVAProcentaje = 0
End If
'TmpDT.Columns.Add("IVAPorcentaje")
'TmpDT.Columns.Add("RetIVAPorcentaje")
'TmpDT.Columns.Add("RetISRPorcentaje")
@@ -1886,10 +1820,10 @@ Partial Class Compras_Compras
DdlTipoCompra.Items.Clear()
DdlTipoCompra.Items.Add(New ListItem("Seleccione", "-1"))
DdlTipoCompra.Items.Add(New ListItem("NC Con Productos", "6"))
DdlTipoCompra.Items.Add(New ListItem("Apoyo Logístico", "9"))
DdlTipoCompra.Items.Add(New ListItem("Apoyo Logístico", "9"))
DdlTipoCompra.Items.Add(New ListItem("NC Por Devolución", "11"))
LiAccionesContratos.Visible = True
End Select
'DIV ALIAS
@@ -2770,7 +2704,9 @@ Partial Class Compras_Compras
TmpDT.Columns.Add("CveContrato", GetType(Integer))
TmpDT.Columns.Add("DifPSSat", GetType(Integer))
If Not TmpDT.Columns.Contains("CveContratoDetalle") Then
TmpDT.Columns.Add("CveContratoDetalle", GetType(Integer))
End If
@@ -2781,10 +2717,6 @@ Partial Class Compras_Compras
End If
GvPS.DataSource = TmpDT
GvPS.DataBind()
@@ -4051,7 +3983,6 @@ Partial Class Compras_Compras
Protected Sub BtnGuardar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnGuardar.Click
'------------------INICIA VALIDACIONES------------------
Dim EstatusCredito As Integer = 0
Dim CveSubProyecto As Integer = 0
@@ -4651,7 +4582,7 @@ Partial Class Compras_Compras
'End If
'METODO DE PREPOLIZA DE ALMACEN
If UsuarioActual.CveEmpresa.Contiene(1, 119, 72, 80, 140, 141, 153) And UsuarioActual.Empresa.UsaInventarios And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" Then
If UsuarioActual.CveEmpresa.Contiene(1, 119, 72, 80, 140, 141, 152, 153, 159, 160, 161, 162, 163) And UsuarioActual.Empresa.UsaInventarios And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" Then
Dim ImporteAlmacen = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveTipoPS = 2").ToString.ToDecimal
If ImporteAlmacen > 0 Then
If Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then
@@ -4685,18 +4616,19 @@ Partial Class Compras_Compras
CveEstatusFactura = 6
End If
'hay amortización directa como descuento. RMF Temporal
If UsuarioActual.CveEmpresa = 119 Then
'If LblAmortizacion.Text.ToDouble > 0 AndAlso TxtDescuento.Text.ToDouble = 0 Then
' TxtDescuento.Text = LblAmortizacion.Text
' LblAmortizacion.Text = "0.00"
'End If
'If LblAmortizacion.Text.ToDouble > 0 AndAlso TxtDescuento.Text.ToDouble = 0 Then
' TxtDescuento.Text = LblAmortizacion.Text
' LblAmortizacion.Text = "0.00"
'End If
'o si el descuento es igual a la amortizacion
'If LblAmortizacion.Text.ToDouble = TxtDescuento.Text.ToDouble Then
' TxtDescuento.Text = LblAmortizacion.Text
' LblAmortizacion.Text = "0.00"
'End If
'o si el descuento es igual a la amortizacion
'If LblAmortizacion.Text.ToDouble = TxtDescuento.Text.ToDouble Then
' TxtDescuento.Text = LblAmortizacion.Text
' LblAmortizacion.Text = "0.00"
'End If
End If
'si el registro es manual, toma el mismo dato
If CveFactura <= 0 Then TotalOriginal = TxtTotal.Text.ToDecimal
@@ -4717,12 +4649,12 @@ Partial Class Compras_Compras
TxtRedondeo.Text.ToDouble, TxtTotal.Text.ToDouble, TxtFecha.Text.Trim.ToDate, DdlMoneda.SelectedValue.ToEntero, TipoCambio, TxtFechaPago.Text.Trim.ToDate, ChkAplicaNotaCredito.Checked, TxtObsFact.Text.Trim, CveEstatusFactura,
CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, IdPoliza, CveCajaChica:=CveCajaChica, CvePersonal:=CvePersonal, NumeroReembolso:=NumeroReembolso, CveProveedorSucursal:=DdlProveedorSucursal.SelectedValue.ToEntero,
AplicoPromocion:=ChkOCPromocion.Checked, PorcentajeIVA:=PorcentajeIVA, CveMetodoPago:=CveMetodoPago, CveRetIVAConcepto:=If(DdlRetIVAConcepto.Items.Count > 0, DdlRetIVAConcepto.SelectedValue.ToEntero, -1), CveConceptoContableAlmacen:=CveConceptoContableAlmacen,
CveRetISRConcepto:=If(DdlRetISRConcepto.Items.Count > 0, DdlRetISRConcepto.SelectedValue.ToEntero, -1), NoDeducible:=EsNoDeducible, CveTipoCompra:=DdlTipoCompra.SelectedValue.ToEntero, TotalOriginal:=TotalOriginal, CveTipoConcepto:=CveTipoConcepto, CveContrato:=CveContratoObra) Then
CveRetISRConcepto:=If(DdlRetISRConcepto.Items.Count > 0, DdlRetISRConcepto.SelectedValue.ToEntero, -1), NoDeducible:=EsNoDeducible, CveTipoCompra:=DdlTipoCompra.SelectedValue.ToEntero, TotalOriginal:=TotalOriginal, CveTipoConcepto:=CveTipoConcepto) Then
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
@@ -5110,7 +5042,7 @@ Partial Class Compras_Compras
Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1"
If UsuarioActual.CveEmpresa.Contiene(119, 158) AndAlso (DdlPersonalReembolso.SelectedValue.ToEntero > 0 Or DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero > 0 Or DdlTipoComprobante.SelectedValue = "Ant") Then
If UsuarioActual.CveEmpresa = 119 AndAlso (DdlPersonalReembolso.SelectedValue.ToEntero > 0 Or DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero > 0 Or DdlTipoComprobante.SelectedValue = "Ant") Then
AutoConta = False
End If
@@ -5313,7 +5245,7 @@ Partial Class Compras_Compras
If Not UsuarioActual.Empresa.UsaAC Then fecha = Now
folio = ObjInventario.GetFolioSiguiente(2, UsuarioActual.CveEmpresa)
cvemovimientoentrada = ObjInventario.AddMovimiento(tcvealmacen, 2, 1, fecha, folio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, TipoCambio:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, TipoCambioGuardar), Modulo:="Comp/G")
cvemovimientoentrada = ObjInventario.AddMovimiento(tcvealmacen, 2, 1, fecha, folio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, TipoCambio:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, TipoCambioGuardar), Modulo:="Comp/G4")
If cvemovimientoentrada <= 0 Then
ErrorMovInv = True
Exit For
@@ -5337,7 +5269,7 @@ Partial Class Compras_Compras
'agregamos la salida gasto
folio = ObjInventario.GetFolioSiguiente(3, UsuarioActual.CveEmpresa)
cvemovimientosalidagasto = ObjInventario.AddMovimiento(tcvealmacen, 3, DdlMoneda.SelectedValue.ToEntero, fecha.AddSeconds(1), folio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, Modulo:="Comp/G")
cvemovimientosalidagasto = ObjInventario.AddMovimiento(tcvealmacen, 3, DdlMoneda.SelectedValue.ToEntero, fecha.AddSeconds(1), folio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, Modulo:="Comp/G3")
If cvemovimientosalidagasto <= 0 Then
ErrorMovInv = True
Exit For
@@ -5394,7 +5326,7 @@ Partial Class Compras_Compras
Dim fecha As Date = TxtFecha.Text.ToDate
If Not UsuarioActual.Empresa.UsaAC Then fecha = Now
CveMovimientoInventario = ObjInventario.AddMovimiento(tCveAlmacen, 2, 1, fecha, 0, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, TipoCambio:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, TipoCambioGuardar), Modulo:="Comp/G")
CveMovimientoInventario = ObjInventario.AddMovimiento(tCveAlmacen, 2, 1, fecha, 0, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, TipoCambio:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, TipoCambioGuardar), Modulo:="Comp/G2")
If CveMovimientoInventario <= 0 Then
ErrorMovInv = True
@@ -6559,7 +6491,7 @@ Partial Class Compras_Compras
End If
Case 6 'Compra
Dim AgregaMercanciaInventario As Boolean = UsuarioActual.CveEmpresa.Contiene(1, 72, 80, 119, 140, 141) AndAlso UsuarioActual.Empresa.UsaInventarios AndAlso Not UsuarioActual.Empresa.Funcionalidad(126) = "1"
Dim AgregaMercanciaInventario As Boolean = UsuarioActual.CveEmpresa.Contiene(1, 72, 80, 119, 140, 141,152,159,160,161,162,163) andalso UsuarioActual.Empresa.UsaInventarios AndAlso Not UsuarioActual.Empresa.Funcionalidad(126) = "1"
Dim RegistraConcepto225 As Boolean = UsuarioActual.Empresa.UsaInventarios AndAlso DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") AndAlso Not UsuarioActual.Empresa.Funcionalidad(126) = "1"
@@ -6849,20 +6781,20 @@ Partial Class Compras_Compras
End If
End If
Case 6
PorcentajeImpuesto = TmpDT.MAX("IVAPorcentaje").ToDecimal
Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}"
For Each RowDetalle As DataRow In TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2", "", {"CveClasificacion", "CveSubProyecto", "IVAPorcentaje"}).Rows
For Each RowDetalle As DataRow In TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2", "", {"CveClasificacion", "CveSubProyecto"}).Rows
If ObjConta.GetRetCuenta(6, RowDetalle("CveClasificacion").ToString().ToEntero()) Then
If ObjConta.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero
CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaGastoSIG").ToString.ToEntero
End If
End If
If importeMN <> 0 Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMN, Referencia, 6, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual,
CveClasificacion:=RowDetalle("CveClasificacion").ToString().ToEntero(), CveSubProyecto:=RowDetalle("CveSubProyecto").ToString().ToEntero(), Contabilizable:=SeContabiliza, PorcentajeImpuesto:=RowDetalle("IVAPorcentaje").ToString.ToDecimal) Then
CveClasificacion:=RowDetalle("CveClasificacion").ToString().ToEntero(), CveSubProyecto:=RowDetalle("CveSubProyecto").ToString().ToEntero(), Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
End If
End If
@@ -6887,8 +6819,8 @@ Partial Class Compras_Compras
importeMovimiento = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 And ISNULL(CveAlmacen,0) = 0 And ISNULL(AplicaCostoIndirecto,0) <> 1 And ISNULL(CveTipoPS,0) = 2").ToString.ToDecimal
importeMN = importeMovimiento * tipoCambioActual * Multiplicador
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then 'cuando es emp acumuladora
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then 'cuando es emp acumuladora
Dim Valor = (From dr1 In GlobalDTAcumTamaños().FiltraParametros("CveEmpresa = 140").AsEnumerable()
Join dr2 In TmpDT.AsEnumerable On dr1.Field(Of Integer)("CvePSCargo") Equals dr2.Field(Of Integer)("CvePS")
@@ -6977,7 +6909,7 @@ Partial Class Compras_Compras
If Not RegistroCuentaPuente AndAlso Not ChkNCInvNC.Checked Then
'GASTO
If UsuarioActual.CveEmpresa.Contiene(119, 158) Then
If UsuarioActual.CveEmpresa = 119 Then
DT = TmpDT
Else
DT = TmpDT.FiltraParametros("ISNULL(AplicaCostoIndirecto,0) <> 1")
@@ -7075,7 +7007,7 @@ Partial Class Compras_Compras
End If
Dim usacomplementariaProveedor As Boolean = False
usacomplementariaProveedor = If(tipoCambioActual > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119), True, False)
usacomplementariaProveedor = If(tipoCambioActual > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119, 158), True, False)
If usacomplementariaProveedor AndAlso DdlTipoComprobante.SelectedValue = "Ant" Then
'importeMovimiento
@@ -7114,7 +7046,7 @@ Partial Class Compras_Compras
End If
Case 5 'Proveedores
If CveTipoConcepto = 2 Then ConceptoContable = 305 'cuando es acreedor
Dim UsaComplementaria As Boolean = UsuarioActual.CveEmpresa.Contiene(119, 158)
Dim UsaComplementaria As Boolean = UsuarioActual.CveEmpresa.Contiene(119, 158)
If tipoCambioActual <> 1 Then
Select Case ConceptoContable
Case 5
@@ -7140,7 +7072,7 @@ Partial Class Compras_Compras
Else
IdCtaContable = CtaProveedorComplementaria
CveCuenta = CveCuentaProveedorComplementaria
If importeMovimiento <> 0 AndAlso (IdCtaContable > 0 Or CveCuenta > 0 OrElse UsaComplementaria) Then 'Cuando tiene complementaria lo dividimos en dos Then
If importeMovimiento <> 0 AndAlso (IdCtaContable > 0 Or CveCuenta > 0 Or UsaComplementaria) Then 'Cuando tiene complementaria lo dividimos en dos Then
importeMN = importeMovimiento
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, Referencia, CveConceptoContableComplementaria, Concepto, FechaMovimiento, IdCtaContable, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, ImporteMX:=importeMovimiento * tipoCambioActual - importeMovimiento, ImporteME:=importeMovimiento, CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
@@ -7150,6 +7082,11 @@ Partial Class Compras_Compras
CveCuenta = CveCuentaProveedorExtranjera
End If
End If
If CveCompraRefacturacion > 0 Then
importeMovimiento = 0
importeMN = 0
End If
Case 59 'Documentos
@@ -8299,6 +8236,16 @@ Partial Class Compras_Compras
End If
End If
Next
For Each Gvr As GridViewRow In GVNCInvAlmacen.Rows
If Gvr.FCTextBox("TxtCantidadNCInv").Text.ToDouble > 0 Then
If Not ObjCompras.ComprasDetalleDevolucionesAdd(Gvr.DataKey("CveCompraDetalle").ToEntero, CveCompra, Gvr.FCTextBox("TxtCantidadNCInv").Text.ToDouble, UsuarioActual.CveEmpresa) Then
ErrorMovInv = True
Exit For
End If
End If
Next
End If
@@ -13141,7 +13088,7 @@ Partial Class Compras_Compras
End If
'CONTADO
Select Case RBLContado.SelectedValue
Select Case RBLContado.SelectedValue
Case "1" ' Bancos
PnlContadoBancos.Visible = True
TxtDocumentoImporte.Text = (TxtTotal.Text.ToDecimal - LblAmortizacion.Text.ToDecimal).FormatoNumero
@@ -13190,7 +13137,7 @@ Partial Class Compras_Compras
End Sub
Protected Sub BtnContado_Click(sender As Object, e As EventArgs)
TxtRembolsoNumero.Text = TxtNumeroReembolso.Text
TxtRembolsoNumero.Text = TxtNumeroReembolso.Text
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivContadoModal"))
End Sub
@@ -14266,7 +14213,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
@@ -14274,6 +14221,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
@@ -14289,18 +14237,28 @@ Partial Class Compras_Compras
'si el subtotal es iwal a la nc lo guardo si no marco error
If subtotal > subtotaldevolucion - 1 AndAlso subtotal < subtotaldevolucion + 1 Then
CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacen, 13, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, Modulo:="Comp/G")
CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacen, 13, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, Modulo:="Comp/G1")
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
@@ -14407,10 +14365,19 @@ 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
Dim IVAPorcentajeCompra As Decimal = Math.Round((IVACompra / SubTotalCompra), 2)
Dim Contador As Integer = 0
Dim Consec As Integer = 0
For Each gvr As GridViewRow In GVDevolucion.Rows
If gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Then
Contador += 1
End If
Next
'Iteramos el GridView de la OC
For Each gvr As GridViewRow In GVDevolucion.Rows
@@ -14436,6 +14403,19 @@ Partial Class Compras_Compras
Dim IVA As Decimal = IVAPorcentajeCompra 'Math.Round(Total * IVAPorcentajeCompra, 2)
Dim Descuento As Decimal = 0
Acumulado += (PU * Cantidad)
Consec += 1
If Consec = Contador Then 'SubTotalCompra < Acumulado Then
'ajusta el valor
Dim dif As Decimal = SubTotalCompra - Acumulado
If dif <> 0 Then
PU = ((PU * Cantidad) + dif) / Cantidad
Total = Cantidad * PU
End If
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
@@ -15303,7 +15283,7 @@ Partial Class Compras_Compras
'SI PUEDE RECIBIR POR OC Y COMPRA
' si usa almacen, si tiene activado que reciba por OC, y que si la compra tipo Proveedor. que lo muestre
If UsuarioActual.CveEmpresa.Contiene(119, 158) AndAlso UsuarioActual.Empresa.UsaInventarios And UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 AndAlso CveTipoConcepto = 1 Then
If UsuarioActual.CveEmpresa = 119 AndAlso UsuarioActual.Empresa.UsaInventarios And UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 AndAlso CveTipoConcepto = 1 Then
DivOCVinculaInv.Visible = True
End If
@@ -15345,7 +15325,7 @@ Partial Class Compras_Compras
'PROMOCIONES
LtOCPromocion.Text = StrPromos.ToString
If LtOCPromocion.Text.Length > 0 And UsuarioActual.CveEmpresa.Contiene(119, 158) Then
If LtOCPromocion.Text.Length > 0 And UsuarioActual.CveEmpresa = 119 Then
DivOCPromocion.Visible = True
End If
@@ -15619,6 +15599,12 @@ Partial Class Compras_Compras
'If DdlOCVinculaInv.SelectedValue.ToEntero = 237 And Not CveFlete > 0 Then Alert("Necesita vincular un flete si selecciona Factura de Flete", TipoMensaje.MsgAdvertencia) : Exit Sub
'If DdlOCVinculaInv.SelectedValue.ToEntero = 240 And Not CveImportacion > 0 Then Alert("Necesita vincular una Importación si selecciona Factura de Importación", TipoMensaje.MsgAdvertencia) : Exit Sub
'If UsuarioActual.CveEmpresa = 119 And DdlTipoComprobante.SelectedValue = "Fac" Then
' If Not VerificarProductosCompraConOC() Then
' Exit Sub
' End If
'End If
Dim SubTotalGV = 0.0D
Dim Amortizacion As Decimal = TmpDT.SUMD("Total")
If ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 Then
@@ -15681,7 +15667,7 @@ Partial Class Compras_Compras
'SI PUEDE RECIBIR POR OC Y COMPRA
If UsuarioActual.CveEmpresa.Contiene(119, 158) AndAlso UsuarioActual.Empresa.UsaInventarios And UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 AndAlso CveTipoConcepto = 1 Then
If UsuarioActual.CveEmpresa = 119 AndAlso UsuarioActual.Empresa.UsaInventarios And UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 AndAlso CveTipoConcepto = 1 Then
If DdlOCVinculaInv.SelectedValue.ToEntero <= 0 Then
Alert("El campo <b>Tipo de recepción almacén</b> es necesario. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
@@ -16672,19 +16658,12 @@ Partial Class Compras_Compras
Protected Sub DdlTipoComprobante_SelectedIndexChanged(sender As Object, e As EventArgs)
LiAccionesContratos.Visible = False
If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then
If DdlTipoComprobante.SelectedValue = "NC" Then
DivReembolso.Visible = False
RBLPago.Items(2).Enabled = False
If Not CveCompra > 0 Then
LiAccionesContratos.Visible = True
End If
Else
DivReembolso.Visible = True
RBLPago.Items(2).Enabled = True
@@ -16708,8 +16687,6 @@ Partial Class Compras_Compras
End If
UpAccionesContratos.Update()
UPCondicionesPago.Update()
End Sub
@@ -17353,7 +17330,7 @@ Partial Class Compras_Compras
LblAmortizacion.Text = "0.00"
End If
If UsuarioActual.CveEmpresa.Contiene(119, 158) AndAlso TieneAmortizacion Then
If UsuarioActual.CveEmpresa = 119 AndAlso TieneAmortizacion Then
Amortizacion = LblAmortizacion.Text.Trim.ToDecimal
TxtSubTotal.Text = (TxtSubTotal.Text.ToDouble + Amortizacion).ToString
End If
@@ -18799,6 +18776,7 @@ Partial Class Compras_Compras
HLAplicaNCFact.Visible = True
LblTotalNC.Text = TxtTotal.Text.FormatoNumero
CargaCuentasXPagar()
TabModoNC_ActiveTabChanged(TabModoNC, EventArgs.Empty)
End Sub
Private Sub CargaCuentasXPagar()
@@ -18932,6 +18910,9 @@ Partial Class Compras_Compras
ChkNCInv.Visible = True
GVNCInv.DataSource = DtPendientesAlmacen
GVNCInv.DataBind()
GVNCInvAlmacen.DataSource = DtPendientesAlmacen
GVNCInvAlmacen.DataBind()
End If
End If
@@ -18940,7 +18921,7 @@ Partial Class Compras_Compras
CargaAnticipos(CveProveedor, If(ChkNCInv.Checked, "NC", "-1"))
UpAnticipos.Update()
End Sub
Private Sub CargaNCINV()
Private Sub CargaNCINV()
Dim SaldoAnticipo = 0.0
Dim CveCompras As String = ""
@@ -18961,20 +18942,22 @@ Partial Class Compras_Compras
SaldoAnticipo += gvr.FCTextBox("TxtAnticipo").Text.ToDouble
End If
Next
If SaldoAnticipo <= 0 Then
Alert("No hay movimientos seleccionados para aplicar", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
If SaldoAnticipo <= 0 Then
Alert("No hay movimientos seleccionados para aplicar", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
LbNCInvSaldo.Text = SaldoAnticipo.FormatoNumero()
LbNCInvSaldoAlmacen.Text = SaldoAnticipo.FormatoNumero()
If ChkNCInvNC.Checked Then
Dim ObjInventarios As New ClsInventarios
If ObjInventarios.RecepcionAlmacenGet(-1, -1, UsuarioActual.CveEmpresa, CveProveedor) AndAlso ObjInventarios.DtResultados.FiltraParametros($"CveCompra IN ({CveCompras}) AND CantidadF > 0").Rows.Count > 0 Then
DtPendientesAlmacen = ObjInventarios.DtResultados.FiltraParametros($"CveCompra IN ({CveCompras}) AND CantidadF > 0").Copy
If ObjInventarios.RecepcionAlmacenGet(-1, -1, UsuarioActual.CveEmpresa, CveProveedor) AndAlso ObjInventarios.DtResultados.FiltraParametros($"CantidadF > 0").Rows.Count > 0 Then
DtPendientesAlmacen = ObjInventarios.DtResultados.FiltraParametros($"CantidadF > 0").Copy
End If
ObjInventarios.Dispose()
End If
@@ -18983,10 +18966,12 @@ Partial Class Compras_Compras
If ChkNCInvNC.Checked Then
GVNCInv.DataSource = DtPendientesAlmacen
GVNCInv.DataBind()
UpNCInv.Update()
RegistraScript("$('#FacturaNC').modal('hide');", "FacturaNC")
GVNCInvAlmacen.DataSource = DtPendientesAlmacen
GVNCInvAlmacen.DataBind()
End If
RegistraScript("$('#ModalNCInv').modal('show');", "ModalNCInv")
Else
If ChkNCInvNC.Checked Then
Alert("Niguna de las facturas seleccionadas cuenta con productos pendientes de darles entrada.", TipoMensaje.MsgAdvertencia)
@@ -18999,14 +18984,22 @@ Partial Class Compras_Compras
End If
UpNCInv.Update()
UpFacturaNC.Update()
End Sub
Protected Sub GVNCInv_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVNCInv.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
'e.Row.FCCheckBox("cbInv").Attributes.Add("onclick", "FnCambiaInvNC(this);")
e.Row.FCTextBox("TxtCantidadNCInv").Attributes.Add("onkeyup", $"ValidarCantidad(this,{e.Row.DBCampo("CantidadF")});FnCambiaInvNC(this);")
End If
End Sub
Protected Sub GVNCInvAlmacen_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVNCInvAlmacen.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
'e.Row.FCCheckBox("cbInv").Attributes.Add("onclick", "FnCambiaInvNC(this);")
e.Row.FCTextBox("TxtCantidadNCInv").Attributes.Add("onkeyup", $"ValidarCantidad(this,{e.Row.DBCampo("CantidadF")});FnCambiaInvNC(this);")
End If
End Sub
Protected Sub BtnNCInv_Click(sender As Object, e As EventArgs)
If ChkNCInvNC.Checked Then
@@ -19064,6 +19057,34 @@ Partial Class Compras_Compras
Protected Sub BtnNCConfirmacion_Click(sender As Object, e As EventArgs)
GuardaAnticipos(Nothing, Nothing)
End Sub
Protected Sub BtnNCInvAlmacen_Click(sender As Object, e As EventArgs)
'Dim ObjCompras As New ClsCompras
'Dim ObjConta As New ClsContabilidad(ObjCompras.IniciaTransacSQL)
'Dim TieneError = False
'For Each Gvr As GridViewRow In GVNCInvAlmacen.Rows
' If Gvr.FCTextBox("TxtCantidadNCInv").Text.ToDouble > 0 Then
' If Not ObjCompras.ComprasDetalleDevolucionesAdd(Gvr.DataKey("CveCompraDetalle").ToEntero, Gvr.DataKey("CveCompra").ToEntero, Gvr.FCTextBox("TxtCantidadNCInv").Text.ToDouble, UsuarioActual.CveEmpresa) Then
' TieneError = True
' Exit For
' End If
' End If
'Next
'If Not TieneError Then
' Alert("Se guardo la devolución correctamente", TipoMensaje.MsgInformacion)
' ObjCompras.Commit()
'Else
' Alert("Ocurrió un error al guardar la devolución", TipoMensaje.MsgError)
' ObjCompras.RollBack()
'End If
'ObjCompras.Dispose()
RegistraScript("$('#FacturaNC').modal('hide');", "ModalNCInv")
End Sub
#End Region
#Region " INVENTARIO: MOVIMIENTOS DE LA COMPRA "
@@ -19685,8 +19706,8 @@ Partial Class Compras_Compras
Dim Multiplicador = If(DdlTipoComprobante.SelectedValue = "NC", -1, 1)
If DdlMoneda.SelectedValue.ToString.ToEntero = 2 Then
'tipoCambioActual = GlobalTipoCambio(TxtFecha.Text.ToDate).ToString.ToDecimal
tipoCambioActual = TxtTC.Text.ToDecimal
tipoCambioActual = GlobalTipoCambio(TxtFecha.Text.ToDate).ToString.ToDecimal
tipoCambioActual = If(DivTC.Visible, TipoCambio.ToDecimal, tipoCambioActual)
Else
tipoCambioActual = 1
End If
@@ -20211,6 +20232,10 @@ Partial Class Compras_Compras
Protected Sub BtnFacturaNC_Click(sender As Object, e As EventArgs)
If ChkNCInvNC.Checked Then
CargaNCINV()
TabModoNC.ActiveTabIndex = 1
TabModoNC_ActiveTabChanged(TabModoNC, EventArgs.Empty)
UpFacturaNC.Update()
Else
RegistraScript("$('#FacturaNC').modal('hide');", "FacturaNC")
End If
@@ -20526,184 +20551,32 @@ Partial Class Compras_Compras
Return True
End Function
Protected Sub TabModoNC_ActiveTabChanged(sender As Object, e As EventArgs)
Select Case TabModoNC.ActiveTabIndex
Case 0
BtnFacturaNC.Visible = True
BtnNCInvAlmacen.Visible = False
TabNCAlmacen.Enabled = False
Case 1
BtnFacturaNC.Visible = False
BtnNCInvAlmacen.Visible = True
TabNCAlmacen.Enabled = True
End Select
'Private Sub CargaContratos()
' DdlContrato.DataSource = GlobalDTContratos.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveContratoTipo IN(30,31) ")
' DdlContrato.DataBind()
' DdlContrato.Items.Insert(0, New System.Web.UI.WebControls.ListItem("Todos", "-1"))
'End Sub
'Protected Sub BtnModalContratos_Click(sender As Object, e As EventArgs)
' RegistraScript("$('#DvModalContratos').modal('hide');")
' CveContratoObra = DdlContrato.SelectedValue.ToEntero
'End Sub
UpFooterFacturaNC.Update()
End Sub
Protected Sub LnkContratos_Click(sender As Object, e As EventArgs)
'RegistraScript("$('#DvModalContratos').modal('show');")
DdlContratosObra.Items.Clear()
DdlContratosObra.DataSource = GlobalDTContratos.FiltraParametros(String.Format($"CveContratoTipo in (30,31) AND CveEmpresa = {UsuarioActual.CveEmpresa}"))
DdlContratosObra.DataBind()
'DdlContratosObra.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlTipoGastoObra.Items.Clear()
DdlTipoGastoObra.DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa)
DdlTipoGastoObra.DataBind()
DdlTipoGastoObra.Items.Insert(0, New ListItem("Seleccione", "-1"))
RegistraScript($"$('#DivmodalConmtrato').modal('show'); $( '#BtnAplicarContrato' ).prop( 'disabled', true ); ValidaBotonContrato({TxtSubTotal2.Text.ToDecimal});")
UpModalContrato.Update()
End Sub
Protected Sub DdlContratosCompras_SelectedIndexChanged(sender As Object, e As EventArgs)
If DdlContratosObra.SelectedValue.ToEntero > 0 Then
Dim ObjContratos As New ClsContratos()
If ObjContratos.GetContratosObraCompras(DdlContratosObra.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
If ObjContratos.DtResultados.Rows.Count > 0 Then
GvContratosControl.DataSource = ObjContratos.DtResultados
'BtnAplicarContrato.Visible = True
Else
GvContratosControl.DataSource = Nothing
'BtnAplicarContrato.Visible = False
End If
End If
ObjContratos.Dispose()
GvContratosControl.DataBind()
UpModalContrato.Update()
End If
RegistraScript("$( '#BtnAplicarContrato' ).prop( 'disabled', true );")
Protected Sub DdlContratosObra_SelectedIndexChanged(sender As Object, e As EventArgs)
End Sub
Protected Sub BtnAplicarContrato_Click(sender As Object, e As EventArgs)
TmpDT.Rows.Clear()
Dim CveTipoGastoObra As Integer = DdlTipoGasto.SelectedValue.ToEntero
For Each GvRow As GridViewRow In GvContratosControl.Rows
Dim CveContratoDetalle As Integer = GvRow.DataKey("CveContratoDetalle").ToEntero
Dim Cantidad As Double = GvRow.FCTextBox("TxtCantidad").Text.ToDouble
Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero
Dim PS As String = GvRow.DataKey("PS")
Dim PU As Double = GvRow.FCTextBox("TxtPU").Text.ToDouble
Dim TotalPS As Double = GvRow.FCTextBox("TxtImporte").Text.ToDouble
Dim CveUnidadMedida As Integer = GvRow.DataKey("CveUnidadMedida").ToEntero
Dim UMAbreviatura As String = GvRow.DataKey("Abreviatura").ToString
Dim SubProyecto As String = GvRow.DataKey("SubProyecto")
Dim CveSubProyecto As Integer = GvRow.DataKey("CveSubProyecto").ToEntero
Dim Codigo As String = "" 'GvRow.DataKey("Codigo")
Dim Proyecto As String = GvRow.DataKey("Proyecto")
Dim CveProyecto As Integer = GvRow.DataKey("CveProyecto").ToEntero
Dim RetISR As Double = GvRow.DataKey("RetISR").ToString.ToDouble
Dim RetIVA As Double = MAXRetIVAPorcentaje 'GvRow.DataKey("RetIVA").ToString.ToDouble
Dim IvaPS As Double = MaxIVAProcentaje
Dim CveClasificacion As Integer = GvRow.DataKey("CveClasificacion").ToString.ToEntero
Dim Clasificacion As String = GvRow.DataKey("Clasificacion")
Dim IEPSPS As Double = GvRow.DataKey("IEPSPorcentaje").ToString.ToDouble
Dim IEPSPSIVA As Double = If(GvRow.DataKey("IEPSGrabaIVA").ToString = "True", IEPSPS, 0)
Dim CveTipoPS As Integer = GvRow.DataKey("CveTipoPS").ToEntero
Dim CveSATPS As Integer = GvRow.DataKey("CveSATPS").ToEntero
Dim IdCuentaPorEjercer As Integer = -1
Dim IdCuentaComprometido As Integer = -1
Dim TotalRow As Decimal = (PU * Cantidad).RoundSQL(2).ToDecimal
If Cantidad > 0 Then
AddPS(Cantidad, CveUnidadMedida, UMAbreviatura, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyecto.ToString, SubProyecto, Proyecto, CveProyecto.ToString, "", PU, TotalRow, IvaPS, RetIVA, RetISR, IEPSPS, IEPSPSIVA, 0, -1, False,
CantidadF:=0, EntregaDirecta:=0, CveSATPS:=CveSATPS, CveTipoGasto:=DdlTipoGastoObra.SelectedValue.ToEntero, TipoGasto:=DdlTipoGastoObra.SelectedItem.Text, CveContratoDetalle:=CveContratoDetalle, CveCultivoCuadroDetalle:=-1)
'AddPS(Cantidad, CvePS, PS, PS, PU, 0, TotalPS,
'CveUnidadMedida, IvaPS, IEPSPS, IEPSPSIVA, CveClasificacion, UMAbreviatura, Clasificacion, CveProyecto, Proyecto,
'CveSubProyecto, SubProyecto, Codigo, -1, 0, -1, -1, IdCuentaPorEjercer,
'IdCuentaComprometido, -1, -1, -1, -1,
'-1, RetIVA, RetISR, CveContratoDetalle:=CveContratoDetalle, CveTipoGastoObra:=CveTipoGastoObra, CveCultivoCuadroDetalle:=-1, Cuadro:="")
'' ContratoObraAplciado = True
End If
Next
'CargaSuperior()
'CargaDatosDetalles()
GvPS.DataSource = TmpDT
GvPS.DataBind()
UpPS.Update()
RegistraScript("$('#DivmodalConmtrato').modal('hide')")
' UPPDetalle.Update()
End Sub
Private Sub GvContratosControl_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvContratosControl.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim CveContratoDetalle As Integer = e.Row.DataKey("CveContratoDetalle").ToEntero
e.Row.FCTextBox("TxtCantidad").CssClass = $"CssCantidad{CveContratoDetalle}"
e.Row.FCTextBox("TxtCantidad").Attributes.Add("onkeyup", $"ValidateCant('{CveContratoDetalle}',{TxtSubTotal2.Text.ToDecimal})")
e.Row.FCTextBox("TxtPU").CssClass = $"CssPU{CveContratoDetalle}"
e.Row.FCTextBox("TxtPU").Attributes.Add("onkeyup", $"ValidateCant('{CveContratoDetalle}',{TxtSubTotal2.Text.ToDecimal})")
e.Row.FCTextBox("TxtImporte").CssClass = $"ImporteCSS CssImporte{CveContratoDetalle}"
End If
End Sub
End Class
Public Class MMensajeDevolucion

View File

@@ -1152,6 +1152,29 @@ Partial Class PopUpVerFactura
Vta.DtDocumentosRelacionados = ObjVentas.DtResultados.FiltraParametros("FolioFiscal IS NOT NULL")
End If
End If
If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso (Vta.DtDocumentosRelacionados Is Nothing OrElse Vta.DtDocumentosRelacionados.Rows.Count = 0) Then
If ObjVentas.GetVentasRelacionadas(CveVenta, UsuarioActual.CveEmpresa) Then
Vta.DtNCVinculadas = ObjVentas.DtResultados
Vta.DtDocumentosRelacionados = ObjVentas.DtResultados '.FiltraParametros("FolioFiscal IS NOT NULL")
If Vta.DtDocumentosRelacionados.Rows.Count > 0 Then
If Vta.TipoDocto.Contiene("Ing") Then
Vta.Timbre.CFDIRelacionados.TipoRelacion = "01"
Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Nota de Crédito aplicada a Ingreso"
End If
If Vta.TipoDocto.Contiene("Egs") Then
Vta.Timbre.CFDIRelacionados.TipoRelacion = "01"
Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Nota de Crédito aplicada a Ingreso"
End If
If Vta.TipoDocto.Contiene("Dev") Then
Vta.Timbre.CFDIRelacionados.TipoRelacion = "03"
Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Devolución aplicada a Ingreso"
End If
End If
End If
End If
End If

View File

@@ -763,6 +763,9 @@ Partial Class Compras_RepCxP
TxtRF.Text = ""
RFVRF.Enabled = True
End If
UpBodyEdit.Update()
End Sub
Protected Sub BtnGuardarPersonalizarRangoEditar_Click(sender As Object, e As EventArgs)
If Not ChkMayor.Checked And TxtRI.Text.ToDouble > TxtRF.Text.ToDouble Then
@@ -771,6 +774,9 @@ Partial Class Compras_RepCxP
End If
If Modalidad = "A" Then
If Not ValidarRangosAgregar() Then
Exit Sub
End If
Dim Dt As DataRow = Nothing
Dt = DtPersonalizarRango.NewRow
Dt("RangoInicial") = TxtRI.Text.ToDouble
@@ -783,6 +789,61 @@ Partial Class Compras_RepCxP
Exit Sub
End If
DtPersonalizarRango.Rows(Index)("RangoInicial") = TxtRI.Text.ToDouble
DtPersonalizarRango.Rows(Index)("RangoFinal") = TxtRF.Text.ToDouble
DtPersonalizarRango.Rows(Index)("Tipo") = DdlTipo.SelectedValue
DtPersonalizarRango.Rows(Index)("TipoEscrito") = DdlTipo.SelectedItem.Text
DtPersonalizarRango.AcceptChanges()
End If
DtPersonalizarRango = DtPersonalizarRango.FiltraParametros("", "Tipo,RangoInicial,RangoFinal")
CargaGv()
RegistraScript("$('#DivPersonalizarRangoEditar').modal('hide')")
RegistraScript("$('#DivPersonalizarRango').modal()", "SDSD")
End Sub
Private Function ValidarRangosAgregar() As Boolean
Dim UltimoRango As DataTable = DtPersonalizarRango.FiltraParametros(String.Format("Tipo = {0}", DdlTipo.SelectedValue), "RangoInicial")
Dim TieneNullRow As DataRow = UltimoRango.Rows(UltimoRango.Rows.Count - 1)
Dim aux As String = TieneNullRow.Item("RangoFinal").ToString
'Dim TieneNull As DataTable = UltimoRango.FiltraParametros(String.Format("RangoFinal < 0"))
If aux = "" Then
Alert("Falta indicar el valor maximo del rango anterior", TipoMensaje.MsgAdvertencia)
Return False
End If
Dim ValorMinimoPosible As Double = UltimoRango.MAX("RangoFinal").ToDouble
If Not TxtRI.Text.ToDouble > ValorMinimoPosible Then
Alert("El rango inicial no puede ser inferior al rango final anterior", TipoMensaje.MsgAdvertencia)
End If
Return TxtRI.Text.ToDouble > ValorMinimoPosible
End Function
Private Function ValidarRangosEditar() As Boolean
Dim TablaDeDatosAux As DataTable = DtPersonalizarRango.FiltraParametros(String.Format("Tipo = {0}", DdlTipo.SelectedValue))
'Valida que hay datos en el row anterior
Dim valorMinimo As Double = 0.0
If Index > 0 Then
'Validar que el RowAnterior sea del mismo tipo
Dim RowAnterior As GridViewRow = GvPersonalizarRango.Rows(Index - 1)
If RowAnterior.DataKey("Tipo") = DdlTipo.SelectedValue Then
'Validar que el valor final del row anterior no sea null
valorMinimo = If(RowAnterior.DataKey("RangoFinal") IsNot Nothing, RowAnterior.DataKey("RangoFinal").ToDouble, -1.0)
End If
End If
'Valida que datos en e row siguiente
Dim valorMaximo As Double = 1000000.0
If Index < (GvPersonalizarRango.Rows.Count - 1) Then
'Validamos que el row siguiente sea del mismo tipo
Dim RowSiguiente As GridViewRow = GvPersonalizarRango.Rows(Index + 1)
If RowSiguiente.DataKey("Tipo") = DdlTipo.SelectedValue Then
'Validamos que el valor inicial del row siguiente no sea NULL
valorMaximo = If(RowSiguiente.DataKey("RangoInicial") IsNot Nothing, RowSiguiente.DataKey("RangoInicial").ToDouble, 1000000.0)
End If
End If
If Not TxtRI.Text.ToDouble > valorMinimo Then
Alert("El rango inicial no puede ser inferior al rango final anterior", TipoMensaje.MsgAdvertencia)
Return False
End If
If Not TxtRF.Text.ToDouble < valorMaximo Then