--Facturacion de activos fijos

This commit is contained in:
2023-05-15 18:51:52 -07:00
parent 8affec437f
commit 10dc0daf8f
7 changed files with 528 additions and 65 deletions

View File

@@ -259,12 +259,17 @@ Public Class ClsAF
Return Retorno Return Retorno
End Function End Function
Public Function GetRepActivosFijosDepreciacion(CveEmpresa As Integer, Fecha As Date) As Boolean Public Function GetRepActivosFijosDepreciacion(CveEmpresa As Integer, Fecha As Date, Optional Depreciados As Integer = 1, Optional CveTipoAF As Integer = -1, Optional CveSubTipoAF As Integer = -1, Optional CveSubProyecto As Integer = -1, Optional CveEstadoActivoFijo As Integer = -1) As Boolean
Dim Retorno As Boolean = False Dim Retorno As Boolean = False
DataAdapter("PA_AF_DepreciacionesGetRep") DataAdapter("PA_AF_DepreciacionesGetRep")
With SqlAdapter.SelectCommand.Parameters With SqlAdapter.SelectCommand.Parameters
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
.Add("@Fecha", SqlDbType.Date).Value = Fecha .Add("@Fecha", SqlDbType.Date).Value = Fecha
.Add("@Depreciados", SqlDbType.Int).Value = Depreciados
.Add("@CveTipoAF", SqlDbType.Int).Value = CveTipoAF
.Add("@CveSubTipoAF", SqlDbType.Int).Value = CveSubTipoAF
.Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto
.Add("@CveEstadoActivoFijo", SqlDbType.Int).Value = CveEstadoActivoFijo
End With End With
Try Try
SqlAdapter.Fill(Data) SqlAdapter.Fill(Data)
@@ -276,6 +281,23 @@ Public Class ClsAF
Return Retorno Return Retorno
End Function End Function
Public Function GetActivosFijosVenta(CveVenta As Integer, CveEmpresa As Integer) As Boolean
Dim Retorno As Boolean = False
DataAdapter("PA_AF_ActivosFijosVentaGet")
With SqlAdapter.SelectCommand.Parameters
.Add("@CveVenta", SqlDbType.Int).Value = CveVenta
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
End With
Try
SqlAdapter.Fill(Data)
Retorno = True
Catch ex As Exception
OnError("Ocurrió un error al obtener el los activos fijos de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
End Try
Return Retorno
End Function
Public Function GetActivosFijos(CveActivoFijo As Integer, CveEmpresa As Integer, Codigo As String, Descripcion As String, CveTipoActivoFijo As Integer, CveSubTipoActivoFijo As Integer, NoSerie As String, Año As Integer, CvePersonaResponsable As Integer, CveProyecto As Integer, CveSubProyecto As Integer, CveEstadoActivoFijo As Integer, CaracteristicaValor As String, CveCliente As Integer, Optional BuscaGrupoEmpresa As Integer = -1, Optional BuscaPorAFPadre As Integer = -1, Optional CveGrupo As Integer = -1) As Boolean Public Function GetActivosFijos(CveActivoFijo As Integer, CveEmpresa As Integer, Codigo As String, Descripcion As String, CveTipoActivoFijo As Integer, CveSubTipoActivoFijo As Integer, NoSerie As String, Año As Integer, CvePersonaResponsable As Integer, CveProyecto As Integer, CveSubProyecto As Integer, CveEstadoActivoFijo As Integer, CaracteristicaValor As String, CveCliente As Integer, Optional BuscaGrupoEmpresa As Integer = -1, Optional BuscaPorAFPadre As Integer = -1, Optional CveGrupo As Integer = -1) As Boolean
Dim Retorno As Boolean = False Dim Retorno As Boolean = False
DataAdapter("PA_AF_ActivosFijosGet") DataAdapter("PA_AF_ActivosFijosGet")

View File

@@ -1196,13 +1196,14 @@ Public Class ClsContabilidad
Return Concepto Return Concepto
End Function End Function
Public Function GetPrePolizasDetalle(CvePrePoliza As Integer, CveEmpresa As Integer, Optional CveIE As Integer = -1) As Boolean Public Function GetPrePolizasDetalle(CvePrePoliza As Integer, CveEmpresa As Integer, Optional CveIE As Integer = -1, Optional CveVenta As Integer = -1) As Boolean
Dim Retorno As Boolean = False Dim Retorno As Boolean = False
DataAdapter("PA_Conta_PrePolizasDetalleGet") DataAdapter("PA_Conta_PrePolizasDetalleGet")
With SqlAdapter.SelectCommand.Parameters With SqlAdapter.SelectCommand.Parameters
.Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza
.Add("@CveIE", SqlDbType.Int).Value = CveIE .Add("@CveIE", SqlDbType.Int).Value = CveIE
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
.Add("@CveVenta", SqlDbType.Int).Value = CveVenta
End With End With
Try Try

View File

@@ -1325,7 +1325,7 @@ Public Class ClsVentas
CvePresupuestoIngreso As Integer, Optional TiempoEntrega As String = "", Optional CveVentaDetallePadre As Integer = -1, CvePresupuestoIngreso As Integer, Optional TiempoEntrega As String = "", Optional CveVentaDetallePadre As Integer = -1,
Optional CveContratoDetalle As Integer = -1, Optional PorcentajeIVA As Decimal = 0, Optional IEPS As Double = -1, Optional PorcentajeIEPS As Double = 0, Optional CvePromocionDetalle As Integer = -1, Optional CveContratoDetalle As Integer = -1, Optional PorcentajeIVA As Decimal = 0, Optional IEPS As Double = -1, Optional PorcentajeIEPS As Double = 0, Optional CvePromocionDetalle As Integer = -1,
Optional CveMovimientoDetallePedido As Integer = -1, Optional ImporteRetIVA As Double = 0, Optional PorcentajeRetIVA As Double = 0, Optional CveMovimientoDetallePedido As Integer = -1, Optional ImporteRetIVA As Double = 0, Optional PorcentajeRetIVA As Double = 0,
Optional ImporteRetISR As Double = 0, Optional PorcentajeRetISR As Double = 0, Optional CuentaPredial As String = "", Optional CvePrecioLista As Integer = -1) As Boolean Optional ImporteRetISR As Double = 0, Optional PorcentajeRetISR As Double = 0, Optional CuentaPredial As String = "", Optional CvePrecioLista As Integer = -1, Optional CveActivoFijo As Integer = -1) As Boolean
Dim Retorno As Boolean = False Dim Retorno As Boolean = False
DataAdapter("PA_VentasDetalleAdd") DataAdapter("PA_VentasDetalleAdd")
@@ -1356,6 +1356,7 @@ Public Class ClsVentas
.Add("@CveMovimientoDetallePedido", SqlDbType.Int).Value = CveMovimientoDetallePedido .Add("@CveMovimientoDetallePedido", SqlDbType.Int).Value = CveMovimientoDetallePedido
.Add("@CuentaPredial", SqlDbType.VarChar).Value = CuentaPredial .Add("@CuentaPredial", SqlDbType.VarChar).Value = CuentaPredial
.Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista .Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista
.Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo
End With End With
Try Try
@@ -5783,6 +5784,26 @@ Public Class ClsVentas
End Function End Function
Public Function UpdateEstatusAFVendido(CveActivoFijo As Integer, CveEmpresa As Integer, Optional CveEstadoActivoFijo As Integer = -1) As Boolean
Dim Retorno As Boolean = False
DataAdapter("PA_AF_EstatusAFUpdate")
With SqlAdapter.SelectCommand.Parameters
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
.Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo
.Add("@CveEstadoActivoFijo", SqlDbType.Int).Value = CveEstadoActivoFijo
End With
Try
SqlAdapter.Fill(Data)
Retorno = True
Catch ex As Exception
OnError("Ocurrió un error al guardar los cambios del estatus de AF.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
End Try
Return Retorno
End Function
#Region "IDisposable Support" #Region "IDisposable Support"

View File

@@ -2421,6 +2421,13 @@ Namespace Modelos
Dim IdCtaIVAXTrasladar As Integer = 0 Dim IdCtaIVAXTrasladar As Integer = 0
Dim IdCtaIVATrasladado As Integer = 0 Dim IdCtaIVATrasladado As Integer = 0
Dim SeContabiliza As Boolean = True Dim SeContabiliza As Boolean = True
Dim DtPrePolizasAFCancelar As DataTable = Nothing
If ValorMultiplicador = -1 AndAlso ObjFactura.DtDetalle IsNot Nothing AndAlso ObjFactura.DtDetalle.COUNT("CveActivoFijo", "CveActivoFijo > 0") > 0 Then
If ObjConta.GetPrePolizasDetalle(-1, UsuarioActual.CveEmpresa, CveVenta:=ObjFactura.CveVenta) Then
DtPrePolizasAFCancelar = ObjConta.DtResultados.FiltraParametros("CveConceptoContable IN (271,49,4)")
End If
End If
If (UsuarioActual.Empresa.Funcionalidad(343) = "1" AndAlso ObjFactura.TipoDocto = "Ant") Then If (UsuarioActual.Empresa.Funcionalidad(343) = "1" AndAlso ObjFactura.TipoDocto = "Ant") Then
SeContabiliza = False SeContabiliza = False
@@ -2527,6 +2534,16 @@ Namespace Modelos
importeMovimiento = 0 importeMovimiento = 0
End If End If
If ValorMultiplicador = -1 AndAlso DtPrePolizasAFCancelar IsNot Nothing Then
For Each RowAF As DataRow In DtPrePolizasAFCancelar.FiltraParametros("CveConceptoContable = 271").Rows
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, CBool(RowAF("TipoMovto")), RowAF("Importe").ToString().ToDecimal() * -1, RowAF("Referencia").ToString(), 271, RowAF("Concepto").ToString(), FechaMovimiento, -1, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=-1, ImporteMX:=RowAF("ImporteMN").ToString().ToDecimal() * -1, ImporteME:=RowAF("ImporteME").ToString().ToDecimal() * -1, TipoCambio:=RowAF("TC").ToString().ToDecimal(), CveSubProyecto:=RowAF("CveSubProyecto").ToString().ToEntero(), Contabilizable:=CBool(RowAF("Contabilizable"))) Then
ErrorPrepoliza = True
End If
Next
End If
End If End If
Case 3 'Cliente Case 3 'Cliente
@@ -3317,53 +3334,71 @@ Namespace Modelos
importeMovimiento = 0 importeMovimiento = 0
Case 4 'Venta Clasificacion Case 4 'Venta Clasificacion
If Not ObjFactura.TipoDocto.Contiene("Rem", "Ant", "Egs", "Dev", "RNC") Then
Dim ConceptoContableAplicar = 4 If ValorMultiplicador = -1 AndAlso DtPrePolizasAFCancelar IsNot Nothing Then
Dim CveVentaAplicar = ObjFactura.CveVenta
Dim CveVentaAmortizacionAplicar = -1
If ObjFactura.TipoDocto.Contiene("Egs") And ObjFactura.TipoDocto = "Ant" And CveDevolucion > 0 And NuevaFactura = 1 Then For Each RowAF As DataRow In DtPrePolizasAFCancelar.FiltraParametros("CveConceptoContable IN(4,49)").Rows
ConceptoContableAplicar = 11 If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, CBool(RowAF("TipoMovto")), RowAF("Importe").ToString().ToDecimal() * -1, RowAF("Referencia").ToString(), RowAF("CveConceptoContable").ToString().ToEntero(), RowAF("Concepto").ToString(), FechaMovimiento, -1, -1, CveVenta:=ObjFactura.CveVenta, CveVentaAmortizacion:=RowAF("CveVentaAmortizacion").ToString().ToEntero(), CveClasificacion:=RowAF("CveClasificacion").ToString().ToEntero(), PorcentajeImpuesto:=RowAF("PorcentajeImpuesto").ToString().ToDecimal(), CveCliente:=ObjFactura.CveCliente, CveIE:=RowAF("CveIE").ToString().ToEntero(), ImporteMX:=RowAF("ImporteMN").ToString().ToDecimal() * -1, ImporteME:=RowAF("ImporteME").ToString().ToDecimal() * -1, TipoCambio:=RowAF("TC").ToString().ToDecimal(), CveSubProyecto:=RowAF("CveSubProyecto").ToString().ToEntero(), CveActivoFijo:=RowAF("CveActivoFijo").ToString().ToEntero(), Contabilizable:=CBool(RowAF("Contabilizable"))) Then
CveVentaAplicar = CveDevolucion ErrorPrepoliza = True
CveVentaAmortizacionAplicar = ObjFactura.CveVenta End If
End If 'REGRESAR EL ACTIVO FIJO A ACTIVO
If RowAF("CveActivoFijo").ToString().ToEntero() > 0 Then
DT = TmpDTDetalle.FiltraParametros($"CvePS <> {ObjFactura.CvePSAmortizacion}", "", {"CveClasificacion", "CveSubProyecto", "PorcentajeIVA"}) If Not ObjVentas.UpdateEstatusAFVendido(RowAF("CveActivoFijo").ToString().ToEntero(), UsuarioActual.CveEmpresa, 1) Then
ErrorPrepoliza = True
If DT.Rows.Count > 0 Then
'Se agrega movimiento separado por la cuenta de ventas (ER)
For Each Row2 As DataRow In DT.Rows
importeMovimiento = ((TmpDTDetalle.SUM("TotalImporte", String.Format("CveClasificacion = {0} AND CveSubProyecto = {1} AND PorcentajeIVA = {2}", Row2("CveClasificacion"), Row2("CveSubProyecto"), Row2("PorcentajeIVA"))).ToString.ToDecimal) * ValorMultiplicador)
importeMX = importeMovimiento * tipoCambio * Multiplicador
FechaMovimiento = ObjFactura.FechaPago
Concepto = $"{ObjFactura.SerieFolio} {If(Row2("CveClasificacion").ToString.ToEntero > 0, ClsPaginas.GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString}"), "")} - {If(Row2("CveSubProyecto").ToString.ToEntero > 0, ClsPaginas.GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa).FiltroPrimeroValor("SubProyecto", $"CveSubProyecto = {Row2("CveSubProyecto").ToString}"), "Sin SubProyecto Asignado")}"
If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
'Nota cuando es Nota de crédiot, debe de tomar el devoluciones y rebajas
If ObjFactura.TipoDocto.Contiene("Egs") Then
IdCtaContable = ClsPaginas.GlobalDTClasificaciones(ObjFactura.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToEntero
Else
IdCtaContable = ClsPaginas.GlobalDTClasificaciones(ObjFactura.CveEmpresa).FiltroPrimeroValor("IdCuentaIngresos", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToEntero
End If End If
End If
Next
If importeMovimiento <> 0 Then Else
If Not ObjFactura.TipoDocto.Contiene("Rem", "Ant", "Egs", "Dev", "RNC") Then
If IdCtaContable <= 0 Then Dim ConceptoContableAplicar = 4
CuentasContablesInvalidas.Append("<br>" & ClsPaginas.GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString + ClsPaginas.GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString}")) Dim CveVentaAplicar = ObjFactura.CveVenta
idCuentaContabilizacion = 0 Dim CveVentaAmortizacionAplicar = -1
End If
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContableAplicar, Concepto, ObjFactura.Fecha, IdCtaContable, -1, CveVenta:=CveVentaAplicar, CveVentaAmortizacion:=CveVentaAmortizacionAplicar, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), TipoCambio:=tipoCambio, PorcentajeImpuesto:=Row2("PorcentajeIVA").ToString().ToDecimal) Then If ObjFactura.TipoDocto.Contiene("Egs") And ObjFactura.TipoDocto = "Ant" And CveDevolucion > 0 And NuevaFactura = 1 Then
ErrorPrepoliza = True ConceptoContableAplicar = 11
CveVentaAplicar = CveDevolucion
CveVentaAmortizacionAplicar = ObjFactura.CveVenta
End If
DT = TmpDTDetalle.FiltraParametros($"CvePS <> {ObjFactura.CvePSAmortizacion}", "", {"CveClasificacion", "CveSubProyecto", "PorcentajeIVA"})
If DT.Rows.Count > 0 Then
'Se agrega movimiento separado por la cuenta de ventas (ER)
For Each Row2 As DataRow In DT.Rows
importeMovimiento = ((TmpDTDetalle.SUM("TotalImporte", String.Format("CveClasificacion = {0} AND CveSubProyecto = {1} AND PorcentajeIVA = {2}", Row2("CveClasificacion"), Row2("CveSubProyecto"), Row2("PorcentajeIVA"))).ToString.ToDecimal) * ValorMultiplicador)
importeMX = importeMovimiento * tipoCambio * Multiplicador
FechaMovimiento = ObjFactura.FechaPago
Concepto = $"{ObjFactura.SerieFolio} {If(Row2("CveClasificacion").ToString.ToEntero > 0, ClsPaginas.GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString}"), "")} - {If(Row2("CveSubProyecto").ToString.ToEntero > 0, ClsPaginas.GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa).FiltroPrimeroValor("SubProyecto", $"CveSubProyecto = {Row2("CveSubProyecto").ToString}"), "Sin SubProyecto Asignado")}"
If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
'Nota cuando es Nota de crédiot, debe de tomar el devoluciones y rebajas
If ObjFactura.TipoDocto.Contiene("Egs") Then
IdCtaContable = ClsPaginas.GlobalDTClasificaciones(ObjFactura.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToEntero
Else Else
ObjFactura.SeGuardoPrePoliza = True IdCtaContable = ClsPaginas.GlobalDTClasificaciones(ObjFactura.CveEmpresa).FiltroPrimeroValor("IdCuentaIngresos", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToEntero
End If End If
End If
Next If importeMovimiento <> 0 Then
If IdCtaContable <= 0 Then
CuentasContablesInvalidas.Append("<br>" & ClsPaginas.GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString + ClsPaginas.GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString}"))
idCuentaContabilizacion = 0
End If
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContableAplicar, Concepto, ObjFactura.Fecha, IdCtaContable, -1, CveVenta:=CveVentaAplicar, CveVentaAmortizacion:=CveVentaAmortizacionAplicar, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), TipoCambio:=tipoCambio, PorcentajeImpuesto:=Row2("PorcentajeIVA").ToString().ToDecimal) Then
ErrorPrepoliza = True
Else
ObjFactura.SeGuardoPrePoliza = True
End If
End If
Next
End If
End If End If
End If End If
importeMovimiento = 0 importeMovimiento = 0
Case 150 'Descuento sobre ventas Case 150 'Descuento sobre ventas
If ObjFactura.TipoDocto.Contiene("Egs", "Dev") AndAlso Not EsNCAmortizacion Then If ObjFactura.TipoDocto.Contiene("Egs", "Dev") AndAlso Not EsNCAmortizacion Then

View File

@@ -122,7 +122,14 @@ Partial Class ProductosyServicios
End Set End Set
End Property End Property
Private Property GeneraServicioAF As Integer
Get
Return ViewState("GeneraServicioAF").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("GeneraServicioAF") = value
End Set
End Property
#End Region #End Region
Private ReadOnly Property PermiteClasificacion2 As Boolean Private ReadOnly Property PermiteClasificacion2 As Boolean
@@ -308,6 +315,22 @@ Partial Class ProductosyServicios
LtlScripts.Text = $"<script>function setPoscicion(){{{posiciontipo}}}</script>" LtlScripts.Text = $"<script>function setPoscicion(){{{posiciontipo}}}</script>"
If Not CvePS > 0 Then MuestraPanel(True) If Not CvePS > 0 Then MuestraPanel(True)
If Request("GeneraServicioAF") IsNot Nothing AndAlso IsNumeric(Request("GeneraServicioAF")) AndAlso Request("GeneraServicioAF").ToEntero() = 1 Then
GeneraServicioAF = 1
TxtPS.Text = "Servicio de facturación de activos fijos"
DdlTipoPS.SelectedValueExist("1")
DdlTipoPS.Enabled = False
ChkAplicaParaVenta.Checked = True
Dim DrSAT = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:="84111506", AplicaParaVenta:=1).FiltroPrimero("") ', SATClavePS:=CveSATNC
DdlSATPS.SelectedValue = DrSAT("CveSATPS").ToString()
DdlSATPS.SelectedText = DrSAT("SATClaveProductoServicio").ToString()
End If
End If End If
End Sub End Sub
@@ -1403,6 +1426,7 @@ Partial Class ProductosyServicios
Dim ObjProductosServicios As New ClsProductosServicios() Dim ObjProductosServicios As New ClsProductosServicios()
Dim ObjInv As New ClsInventarios(ObjProductosServicios.IniciaTransacSQL()) Dim ObjInv As New ClsInventarios(ObjProductosServicios.IniciaTransacSQL())
Dim ObjEmpresas As New ClsSisEmpresas(ObjProductosServicios.IniciaTransacSQL())
Dim TieneError = False Dim TieneError = False
Dim AccionJS = "" Dim AccionJS = ""
@@ -1435,6 +1459,7 @@ Partial Class ProductosyServicios
TxtFechaVigenciaRSCO.Text = "01/01/1900" TxtFechaVigenciaRSCO.Text = "01/01/1900"
End If End If
If CvePS = -1 Then If CvePS = -1 Then
Dim PSS As String = TxtPS.Text.Trim.Replace("|", "") Dim PSS As String = TxtPS.Text.Trim.Replace("|", "")
If UsuarioActual.CveEmpresa.Contiene(1, 72, 80) Then PSS = PSS.ToUpper If UsuarioActual.CveEmpresa.Contiene(1, 72, 80) Then PSS = PSS.ToUpper
@@ -1478,6 +1503,24 @@ Partial Class ProductosyServicios
TieneError = GuardarProductoEnFranquicia(ObjProductosServicios, PSS, CveMetodoInv, EsPaquete, True) TieneError = GuardarProductoEnFranquicia(ObjProductosServicios, PSS, CveMetodoInv, EsPaquete, True)
End If End If
If GeneraServicioAF = 1 Then
Dim RowFuncionalidad380 As DataRow = Nothing
If ObjEmpresas.GetEmpresasFuncionalidades(UsuarioActual.CveEmpresa) Then
RowFuncionalidad380 = ObjEmpresas.DtResultados.FiltroPrimero("CveFuncionalidad = 380")
Else
TieneError = True
End If
'SI NO TIENE LA FUNCIONALIDAD 380 GUARDAR LA FUNCIONALIDAD
If Not TieneError AndAlso RowFuncionalidad380 Is Nothing Then
If Not ObjEmpresas.AddUpdateEmpresaFuncionalidades(UsuarioActual.CveEmpresa, 380, $"{Me.CvePS}") Then
TieneError = True
End If
End If
End If
Else Else
TieneError = True TieneError = True
Alert("Ocurrió un Error al agregar el Producto o Servicio. Por favor vuelva a intentar.", TipoMensaje.MsgError) Alert("Ocurrió un Error al agregar el Producto o Servicio. Por favor vuelva a intentar.", TipoMensaje.MsgError)
@@ -1595,7 +1638,7 @@ Partial Class ProductosyServicios
If Not TieneError Then If Not TieneError Then
ObjProductosServicios.Commit() ObjProductosServicios.Commit()
Alert("El Producto/Servicio se guardo correctamente.", TipoMensaje.MsgInformacion, AccionJS) Alert("El Producto/Servicio se guardo correctamente." + If(GeneraServicioAF = 1, " Recargue la pagina de ventas para poder utilizar el servicio", ""), TipoMensaje.MsgInformacion, AccionJS)
Else Else
ObjProductosServicios.RollBack() ObjProductosServicios.RollBack()
End If End If

View File

@@ -1065,7 +1065,7 @@
</ContentTemplate> </ContentTemplate>
</asp:UpdatePanel> </asp:UpdatePanel>
</th> </th>
<th style="width:120px;"> <th style="width: 120px;">
<div class="row" id="DivPrecioLista" runat="server" visible="false"> <div class="row" id="DivPrecioLista" runat="server" visible="false">
<div class="col-md-12"> <div class="col-md-12">
<asp:DropDownList ID="DdlPrecioLista" runat="server" Width="100%" CssClass="select2me" DataValueField="CvePrecioLista" DataTextField="PrecioLista" OnSelectedIndexChanged="DdlPrecioLista_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList> <asp:DropDownList ID="DdlPrecioLista" runat="server" Width="100%" CssClass="select2me" DataValueField="CvePrecioLista" DataTextField="PrecioLista" OnSelectedIndexChanged="DdlPrecioLista_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
@@ -3114,26 +3114,129 @@
</ContentTemplate> </ContentTemplate>
</ajax:TabPanel> </ajax:TabPanel>
<ajax:TabPanel ID="TabVentaAF" runat="server" HeaderText="Venta de Activos Fijos" Enabled="False"> <ajax:TabPanel ID="TabVentaAF" runat="server" HeaderText="Activos Fijos">
<ContentTemplate> <ContentTemplate>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <asp:UpdatePanel ID="UpActivosFijos" runat="server" UpdateMode="Conditional">
<ContentTemplate> <ContentTemplate>
<table border="0" cellpadding="0" cellspacing="0" class="TextTab"> <div class="row" id="DivAgregarAF" runat="server" visible="false">
<tr valign="top"> <div class="col-md-12">
<td> <div class="portlet light xspadding bordered whitoutcol" style="width: 100%">
<div> <div class="portlet-title">
<fieldset> <div class="caption font-green">
<legend><b>Venta de Activos Fijos</b></legend> <i class="icon-pin font-green"></i>
<table border="0"> <span class="caption-subject bold uppercase">Venta de Activos Fijos</span>
<tr align="left"> </div>
<td></td> <div class="actions">
</tr> <div class="btn-group">
</table> </div>
</fieldset> </div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
</div>
</div> </div>
</td> <div class="portlet-body ">
</tr> <div class="portlet solid grey-cascade portlet-filter" style="">
</table> <div class="portlet-title portlet-filterT portletfiltrostitlee">
<div class="tools">
<asp:UpdatePanel runat="server" style="display: inline-block;">
<ContentTemplate>
<asp:Button ID="BtnFiltrarAF" runat="server" Text="Filtrar" class="btn btn-primary" OnClick="BtnFiltrarAF_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div class="titlefiltros caption">
<div class="row">
<div class="col-md-1 truncate">Tipo Activo Fijo:</div>
<div class="col-md-2">
<asp:DropDownList ID="DdlTipoActivoFiltro" CssClass="form-control input-sm select2me" Width="100%" runat="server" DataTextField="TipoActivoFijo" DataValueField="CveTipoActivoFijo" OnSelectedIndexChanged="DdlTipoActivo_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
</div>
<div class="col-md-1 truncate">SubTipo Activo Fijo:</div>
<div class="col-md-2">
<asp:DropDownList ID="DdlSubTipoActivoFiltro" CssClass="form-control input-sm select2me" Width="100%" runat="server" DataTextField="SubTipoActivoFijo" DataValueField="CveSubTipoActivoFijo"></asp:DropDownList>
</div>
<div class="col-md-1 truncate">Sub Proyecto:</div>
<div class="col-md-2">
<asp:DropDownList ID="DdlSubProyectoFiltroAF" CssClass="form-control input-sm select2me" Width="100%" runat="server" DataTextField="SubProyecto" DataValueField="CveSubProyecto"></asp:DropDownList>
</div>
</div>
</div>
</div>
</div>
<div class="row form-group">
<div class="col-md-1">
Concepto:
</div>
<div class="col-md-3">
<asp:DropDownList ID="DdlPSAF" runat="server" DataTextField="PSCodigo" DataValueField="CvePS" Width="100%" CssClass="select2me"></asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVPSAF" runat="server" InitialValue="-1" ControlToValidate="DdlPSAF" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Concepto''</b> es necesario, por favor ingréselo." ValidationGroup="GrpValidarAF"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCEPSAF" runat="server" HighlightCssClass="vco" TargetControlID="RFVPSAF" Width="350px"></ajax:ValidatorCalloutExtender>
</div>
<div class="col-md-3 text-center">
<asp:HyperLink ID="LnkGenerarPSAF" runat="server" Visible="false" Target="_blank" Text="Crear servicio de facturación de activos fijos" CssClass="btn btn-sm btn-circle btn-primary" NavigateUrl="/Ventas/ProductosServicios.aspx?GeneraServicioAF=1"></asp:HyperLink>
</div>
<div class="col-md-4"></div>
<div class="col-md-1 text-center">
<asp:Button ID="BtnGuardarAF" runat="server" CssClass="btn btn-success" Text="Aceptar" OnClick="BtnGuardarAF_Click" ValidationGroup="GrpValidarAF" />
</div>
</div>
<div class="rowpadding">
<asp:GridView ID="GvVentaAF" runat="server" GridLines="None" DataKeyNames="CveActivoFijo,Descripcion,DepreciacionAcumulada,MOI,Observaciones" CssClass="table table-striped table-advance table-hover Widthall ScrollAD" data-sort="true" BorderWidth="1" BorderColor="#D3D3D3" CellSpacing="0" Width="100%" AutoGenerateColumns="False" data-heighterror="600" EmptyDataText="No se encontraron registros">
<Columns>
<asp:TemplateField ItemStyle-HorizontalAlign="center" ItemStyle-Width="5%" ItemStyle-CssClass="NoClick">
<HeaderTemplate>
<asp:CheckBox runat="server" ID="chkSelectAllAF" CssClass="ChkAllClickAF" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox runat="server" ID="chkAF" CssClass="ChkAllEvtAF" />
</ItemTemplate>
</asp:TemplateField>
<asp:HyperLinkField DataTextField="NoSerie" DataNavigateUrlFormatString="/AF/AF.aspx?CveActivoFijo={0}" DataNavigateUrlFields="CveActivoFijo" Target="_blank" ItemStyle-Width="20%" HeaderText="No. Serie" ItemStyle-HorizontalAlign="Left" />
<asp:HyperLinkField DataTextField="Descripcion" DataNavigateUrlFormatString="/AF/AF.aspx?CveActivoFijo={0}" DataNavigateUrlFields="CveActivoFijo" Target="_blank" ItemStyle-Width="25%" HeaderText="Activo fijo" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="MOI" ItemStyle-Width="15%" HeaderText="Valor de compra" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:N2}" />
<asp:BoundField DataField="DepreciacionAcumulada" ItemStyle-Width="15%" HeaderText="Depreciación" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:N2}" />
<asp:TemplateField ItemStyle-HorizontalAlign="Right" ItemStyle-Width="20%" HeaderText="Importe de venta">
<ItemTemplate>
<asp:TextBox ID="TxtPrecioAF" runat="server" CausesValidation="true" lang="nb" Text="0.00" MaxLength="12" Width="100%" Height="24px" CssClass="form-control input-sm"></asp:TextBox>
<ajax:FilteredTextBoxExtender ID="FTBEPrecioAF" runat="server" TargetControlID="TxtPrecioAF" FilterType="Custom, Numbers" ValidChars="." />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</div>
</div>
</div>
</div>
<div class="row" id="DivVentasAF" runat="server" visible="false">
<div class="col-md-12">
<div class="portlet light xspadding bordered whitoutcol" style="width: 100%">
<div class="portlet-title">
<div class="caption font-green">
<i class="icon-pin font-green"></i>
<span class="caption-subject bold uppercase">Venta de Activos Fijos</span>
</div>
<div class="actions">
<div class="btn-group">
</div>
</div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
</div>
</div>
<div class="portlet-body ">
<div class="rowpadding">
<asp:GridView ID="GvAF" runat="server" GridLines="None" CssClass="table table-striped table-advance table-hover Widthall ScrollAD" data-sort="true" BorderWidth="1" BorderColor="#D3D3D3" CellSpacing="0" Width="100%" AutoGenerateColumns="False" data-heighterror="600" EmptyDataText="No se encontraron registros">
<Columns>
<asp:HyperLinkField DataTextField="NoSerie" DataNavigateUrlFormatString="/AF/AF.aspx?CveActivoFijo={0}" DataNavigateUrlFields="CveActivoFijo" ItemStyle-Width="20%" Target="_blank" HeaderText="No. Serie" ItemStyle-HorizontalAlign="Left" />
<asp:HyperLinkField DataTextField="Descripcion" DataNavigateUrlFormatString="/AF/AF.aspx?CveActivoFijo={0}" DataNavigateUrlFields="CveActivoFijo" ItemStyle-Width="25%" Target="_blank" HeaderText="Activo fijo" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="Total" ItemStyle-Width="15%" HeaderText="Valor de venta" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:N2}" />
</Columns>
</asp:GridView>
</div>
</div>
</div>
</div>
</div>
</ContentTemplate> </ContentTemplate>
</asp:UpdatePanel> </asp:UpdatePanel>
</ContentTemplate> </ContentTemplate>
@@ -9515,6 +9618,8 @@
step: 30 step: 30
}); });
$('body').on('click', '.ChkAllClickAF input', function () { $(".ChkAllEvtAF input").not(this).prop('checked', $('.ChkAllClickAF input').is(':checked')); });
if(HdnCargarInventario.value == 'True'){ if(HdnCargarInventario.value == 'True'){
$("#TabAlmacen_tab .ajax__tab_inner").click(function () { $("#TabAlmacen_tab .ajax__tab_inner").click(function () {
CargaMovimientosInventario(); CargaMovimientosInventario();

View File

@@ -2736,6 +2736,9 @@ Partial Class Ventas
TmpDT.Columns.Add("CveMarca", GetType(Integer)) TmpDT.Columns.Add("CveMarca", GetType(Integer))
TmpDT.Columns.Add("CvePrecioLista", GetType(Integer)) TmpDT.Columns.Add("CvePrecioLista", GetType(Integer))
TmpDT.Columns.Add("PrecioLista", GetType(String)) TmpDT.Columns.Add("PrecioLista", GetType(String))
TmpDT.Columns.Add("CveActivoFijo", GetType(Integer))
TmpDT.Columns.Add("AFDepreciacion", GetType(Decimal))
TmpDT.Columns.Add("AFValorInicial", GetType(Decimal))
GvPS.DataSource = ObjVentas.DtResultados GvPS.DataSource = ObjVentas.DtResultados
GvPS.DataBind() GvPS.DataBind()
@@ -2763,6 +2766,9 @@ Partial Class Ventas
TmpDT.Columns.Add("CveMarca", GetType(Integer)) TmpDT.Columns.Add("CveMarca", GetType(Integer))
TmpDT.Columns.Add("CvePrecioLista", GetType(Integer)) TmpDT.Columns.Add("CvePrecioLista", GetType(Integer))
TmpDT.Columns.Add("PrecioLista", GetType(String)) TmpDT.Columns.Add("PrecioLista", GetType(String))
TmpDT.Columns.Add("CveActivoFijo", GetType(Integer))
TmpDT.Columns.Add("AFDepreciacion", GetType(Decimal))
TmpDT.Columns.Add("AFValorInicial", GetType(Decimal))
GvPS.DataSource = ObjVentas.DtResultados GvPS.DataSource = ObjVentas.DtResultados
GvPS.DataBind() GvPS.DataBind()
@@ -3291,7 +3297,12 @@ Partial Class Ventas
DivAddUMPyME.Visible = False DivAddUMPyME.Visible = False
End If End If
TabVentaAF.Visible = False TabVentaAF.Visible = (UsuarioActual.CveRol = 1)
DivAgregarAF.Visible = (CveVenta <= 0 AndAlso UsuarioActual.CveRol = 1)
If DivAgregarAF.Visible Then
CargaDatosAF()
End If
'CARGA VALORES INICIALES PARA AGREGAR PS DESDE MODAL 'CARGA VALORES INICIALES PARA AGREGAR PS DESDE MODAL
CargaMetodosPSModal() CargaMetodosPSModal()
@@ -4637,6 +4648,8 @@ Partial Class Ventas
TmpDT.Columns.Add("ImporteProntoPago", GetType(Decimal)) TmpDT.Columns.Add("ImporteProntoPago", GetType(Decimal))
End If End If
CargaAFVenta()
'CargaFirmas 'CargaFirmas
If ObjVentas.GetVentasFirmas(CveVenta) Then If ObjVentas.GetVentasFirmas(CveVenta) Then
If ObjVentas.DtResultados.Rows.Count > 0 Then If ObjVentas.DtResultados.Rows.Count > 0 Then
@@ -7658,12 +7671,20 @@ Partial Class Ventas
dtt = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) dtt = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1)
DdlSubProyectoDatos.DataSource = dtt.FiltraParametros("EsSucursal = True ") DdlSubProyectoDatos.DataSource = dtt.FiltraParametros("EsSucursal = True ")
DdlSubProyectoDatos.DataBind() DdlSubProyectoDatos.DataBind()
DdlSubProyectoCobranza.DataSource = dtt.FiltraParametros("EsSucursal = True ") DdlSubProyectoCobranza.DataSource = dtt.FiltraParametros("EsSucursal = True ")
DdlSubProyectoCobranza.DataBind() DdlSubProyectoCobranza.DataBind()
DdlSubProyectoEjecucion.DataSource = dtt.FiltraParametros("EsSucursal = True ") DdlSubProyectoEjecucion.DataSource = dtt.FiltraParametros("EsSucursal = True ")
DdlSubProyectoEjecucion.DataBind() DdlSubProyectoEjecucion.DataBind()
DdlSubProyectoPyME.DataSource = dtt DdlSubProyectoPyME.DataSource = dtt
DdlSubProyectoPyME.DataBind() DdlSubProyectoPyME.DataBind()
DdlSubProyectoFiltroAF.DataSource = dtt
DdlSubProyectoFiltroAF.DataBind()
DdlSubProyectoFiltroAF.Items.Insert(0, New ListItem("Todos", "-1"))
dtt.Dispose() dtt.Dispose()
End Sub End Sub
Private Sub CargaClasificaciones() Private Sub CargaClasificaciones()
@@ -13336,7 +13357,7 @@ Partial Class Ventas
Row("PU").ToString().ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Row("ImporteIVA").ToString().ToDouble, Math.Round((Row("Total").ToString().ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)) * (1 + Row("PorcentajeIVA").ToString().ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)))), 6), Row("PU").ToString().ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Row("ImporteIVA").ToString().ToDouble, Math.Round((Row("Total").ToString().ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)) * (1 + Row("PorcentajeIVA").ToString().ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)))), 6),
Row("Obs").ToString(), Row("Descuento").ToString().ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Row("TipoDescuento").ToString().ToEntero(), Row("CveSubProyecto").ToString().ToEntero(), Row("CvePresupuestoIngreso").ToString().ToEntero(), TiempoEntrega:=Row("TiempoEntrega").ToString(), CveVentaDetallePadre:=Row("CveVentaDetalle").ToString().ToEntero(), Row("Obs").ToString(), Row("Descuento").ToString().ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Row("TipoDescuento").ToString().ToEntero(), Row("CveSubProyecto").ToString().ToEntero(), Row("CvePresupuestoIngreso").ToString().ToEntero(), TiempoEntrega:=Row("TiempoEntrega").ToString(), CveVentaDetallePadre:=Row("CveVentaDetalle").ToString().ToEntero(),
CveContratoDetalle:=Row("CveContratoDetalle").ToString().ToEntero(), CvePromocionDetalle:=Row("CvePromocionDetalle").ToString().ToEntero(), IEPS:=Row("ImporteIEPS").ToString().ToDouble, CveMovimientoDetallePedido:=Row("CveMovimientoDetallePedido").ToString().ToEntero(), ImporteRetIVA:=Row("ImporteRetIVA").ToString().ToDouble, ImporteRetISR:=Row("ImporteRetISR").ToString().ToDouble, CveContratoDetalle:=Row("CveContratoDetalle").ToString().ToEntero(), CvePromocionDetalle:=Row("CvePromocionDetalle").ToString().ToEntero(), IEPS:=Row("ImporteIEPS").ToString().ToDouble, CveMovimientoDetallePedido:=Row("CveMovimientoDetallePedido").ToString().ToEntero(), ImporteRetIVA:=Row("ImporteRetIVA").ToString().ToDouble, ImporteRetISR:=Row("ImporteRetISR").ToString().ToDouble,
PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().ToDouble, PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString().ToDouble, PorcentajeRetISR:=Row("PorcentajeRetISR").ToString().ToDouble, CuentaPredial:=Row("CuentaPredial").ToString(), CvePrecioLista:=Row("CvePrecioLista").ToString().ToEntero()) Then PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().ToDouble, PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString().ToDouble, PorcentajeRetISR:=Row("PorcentajeRetISR").ToString().ToDouble, CuentaPredial:=Row("CuentaPredial").ToString(), CvePrecioLista:=Row("CvePrecioLista").ToString().ToEntero(), CveActivoFijo:=Row("CveActivoFijo").ToString().ToEntero()) Then
ErrorList.Add("Ocurrió un error al agregar un Producto o Servicio a la Factura.<br />Revise su factura y cualquier detalle comuníquese a Soporte Técnico") ErrorList.Add("Ocurrió un error al agregar un Producto o Servicio a la Factura.<br />Revise su factura y cualquier detalle comuníquese a Soporte Técnico")
Exit For Exit For
Else Else
@@ -13913,6 +13934,25 @@ Partial Class Ventas
IdCtaContable = ObjFactura.Cliente.IdCtaContMonedaExtranjera IdCtaContable = ObjFactura.Cliente.IdCtaContMonedaExtranjera
End If End If
IdCtaContableCliente = IdCtaContable IdCtaContableCliente = IdCtaContable
Dim DtAF As DataTable = TmpDT.FiltraParametros("CveActivoFijo > 0")
If DtAF.Rows.Count > 0 Then
For Each RowAF As DataRow In DtAF.FiltraParametros("", "", {"CveActivoFijo", "Obs"}).Rows
Dim ImporteDepreciado As Decimal = DtAF.SUMD("AFDepreciacion", $"CveActivoFijo = {RowAF("CveActivoFijo")}").RoundSQL(2)
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, ImporteDepreciado, Referencia, 271, $"Depreciación {RowAF("Obs")}", FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=(ImporteDepreciado).RoundSQL, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), TipoCambio:=tipoCambio, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
End If
'MARCAR EL ACTIVO FIJO COMO VENDEDIDO
If Not ErrorPrepoliza AndAlso RowAF("CveActivoFijo").ToString().ToEntero() > 0 Then
If Not ObjVentas.UpdateEstatusAFVendido(RowAF("CveActivoFijo").ToString().ToEntero(), UsuarioActual.CveEmpresa, 5) Then
ErrorPrepoliza = True
End If
End If
Next
End If
End If End If
'Case 7 'descuentos 'Case 7 'descuentos
@@ -14774,12 +14814,12 @@ Partial Class Ventas
CveVentaAmortizacionAplicar = ObjFactura.CveVenta CveVentaAmortizacionAplicar = ObjFactura.CveVenta
End If End If
DT = TmpDTDetalle.FiltraParametros($"CvePS <> {CvePSAmortizacion}", "", {"CveClasificacion", "CveSubProyecto", "PorcentajeIVA"}) DT = TmpDTDetalle.FiltraParametros($"CvePS <> {CvePSAmortizacion}", "", {"CveClasificacion", "CveSubProyecto", "PorcentajeIVA", "CveActivoFijo"})
If DT.Rows.Count > 0 Then If DT.Rows.Count > 0 Then
'Se agrega movimiento separado por la cuenta de ventas (ER) 'Se agrega movimiento separado por la cuenta de ventas (ER)
For Each Row2 As DataRow In DT.Rows For Each Row2 As DataRow In DT.Rows
importeMovimiento = (TmpDTDetalle.SUM("TotalImporte", String.Format("CveClasificacion = {0} And CveSubProyecto = {1} AND PorcentajeIVA = {2}", Row2("CveClasificacion"), Row2("CveSubProyecto"), Row2("PorcentajeIVA"))).ToString().ToDecimal()) * ValorMultiplicador importeMovimiento = (TmpDTDetalle.SUM("TotalImporte", String.Format("CveClasificacion = {0} And CveSubProyecto = {1} AND PorcentajeIVA = {2} AND CveActivoFijo = {3}", Row2("CveClasificacion"), Row2("CveSubProyecto"), Row2("PorcentajeIVA"), Row2("CveActivoFijo"))).ToString().ToDecimal()) * ValorMultiplicador
importeMX = importeMovimiento * tipoCambio * Multiplicador importeMX = importeMovimiento * tipoCambio * Multiplicador
FechaMovimiento = ObjFactura.FechaPago FechaMovimiento = ObjFactura.FechaPago
Concepto = $"{ObjFactura.SerieFolio} {If(Row2("CveClasificacion").ToString().ToEntero() > 0, GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString()}"), "")} - {If(Row2("CveSubProyecto").ToString().ToEntero() > 0, GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa).FiltroPrimeroValor("SubProyecto", $"CveSubProyecto = {Row2("CveSubProyecto").ToString()}"), "Sin SubProyecto Asignado")}" Concepto = $"{ObjFactura.SerieFolio} {If(Row2("CveClasificacion").ToString().ToEntero() > 0, GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString()}"), "")} - {If(Row2("CveSubProyecto").ToString().ToEntero() > 0, GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa).FiltroPrimeroValor("SubProyecto", $"CveSubProyecto = {Row2("CveSubProyecto").ToString()}"), "Sin SubProyecto Asignado")}"
@@ -14795,6 +14835,26 @@ Partial Class Ventas
If importeMovimiento <> 0 Then If importeMovimiento <> 0 Then
If Row2("CveActivoFijo").ToString().ToEntero() > 0 Then
Dim DtAF As DataTable = TmpDT.FiltraParametros($"CveActivoFijo = {Row2("CveActivoFijo")}")
If DtAF.Rows.Count > 0 Then
For Each RowAF As DataRow In DtAF.FiltraParametros("", "", {"CveActivoFijo", "Obs"}).Rows
Dim ImporteCosto As Decimal = DtAF.SUMD("AFValorInicial", $"CveActivoFijo = {RowAF("CveActivoFijo")}").RoundSQL(2)
Dim ImporteDepreciacion As Decimal = DtAF.SUMD("AFDepreciacion", $"CveActivoFijo = {RowAF("CveActivoFijo")}").RoundSQL(2)
Dim ImporteC4 As Decimal = importeMovimiento
Dim ImporteC4MX As Decimal = importeMX
importeMovimiento = ImporteC4 - ImporteCosto + ImporteDepreciacion
importeMX = ImporteC4MX - ImporteCosto + ImporteDepreciacion
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, ImporteCosto, Referencia, 49, $"COSTO {RowAF("Obs")}", FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=(ImporteCosto).RoundSQL, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), TipoCambio:=tipoCambio, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), CveActivoFijo:=Row2("CveActivoFijo").ToString().ToEntero(), Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
End If
Next
End If
End If
If IdCtaContable <= 0 Then If IdCtaContable <= 0 Then
CuentasContablesInvalidas.Append("<br>" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString() + GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString()}")) CuentasContablesInvalidas.Append("<br>" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString() + GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString()}"))
idCuentaContabilizacion = 0 idCuentaContabilizacion = 0
@@ -19031,7 +19091,8 @@ Partial Class Ventas
Optional EntregaDirecta As Integer = 0, Optional CveContratoDetalle As Integer = 0, Optional CveVentaDetalle As Integer = 0, Optional CveMovimientoDetallePedido As Integer = 0, Optional EntregaDirecta As Integer = 0, Optional CveContratoDetalle As Integer = 0, Optional CveVentaDetalle As Integer = 0, Optional CveMovimientoDetallePedido As Integer = 0,
Optional CveOrdenCompraDetalle As Integer = 0, Optional CveVentaDetalleRemision As Integer = 0, Optional CveVentaDetalleCotizacion As Integer = 0, Optional CuentaPredial As String = "", Optional CveOrdenCompraDetalle As Integer = 0, Optional CveVentaDetalleRemision As Integer = 0, Optional CveVentaDetalleCotizacion As Integer = 0, Optional CuentaPredial As String = "",
Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0, Optional SeActualiza As Boolean = False, Optional CvePromocionDetalle As Integer = -1, Optional EsCargo As Boolean = False, Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0, Optional SeActualiza As Boolean = False, Optional CvePromocionDetalle As Integer = -1, Optional EsCargo As Boolean = False,
Optional ImporteProntoPago As Decimal = 0, Optional ByRef ObjDescuento As Modelos.VentaDescuentos = Nothing, Optional CvePrecioLista As Integer = -1, Optional PrecioLista As String = "") As Boolean Optional ImporteProntoPago As Decimal = 0, Optional ByRef ObjDescuento As Modelos.VentaDescuentos = Nothing, Optional CvePrecioLista As Integer = -1, Optional PrecioLista As String = "",
Optional CveActivoFijo As Integer = -1, Optional AFDepreciacion As Decimal = 0D, Optional AFValorInicial As Decimal = 0D) As Boolean
Dim Retorno As Boolean = False Dim Retorno As Boolean = False
Try Try
@@ -19127,6 +19188,10 @@ Partial Class Ventas
End If End If
End If End If
If CveUM <= 0 Then
CveUM = DrPS("CveUnidadMedida").ToString().ToEntero()
End If
Row("Cantidad") = Cantidad Row("Cantidad") = Cantidad
Row("CveUM") = CveUM Row("CveUM") = CveUM
Row("UM") = DrPS("UnidadMedida") Row("UM") = DrPS("UnidadMedida")
@@ -19290,6 +19355,11 @@ Partial Class Ventas
Row("CvePrecioLista") = CvePrecioLista Row("CvePrecioLista") = CvePrecioLista
Row("PrecioLista") = PrecioLista Row("PrecioLista") = PrecioLista
Row("CveActivoFijo") = CveActivoFijo
Row("AFDepreciacion") = AFDepreciacion
Row("AFValorInicial") = AFValorInicial
If UsuarioActual.CveEmpresa.Contiene(119, 13, 83) Then If UsuarioActual.CveEmpresa.Contiene(119, 13, 83) Then
If Not RemisionesLista.Count > 0 Then 'SI VIENE DE REMISION NO SE CONSIDERA If Not RemisionesLista.Count > 0 Then 'SI VIENE DE REMISION NO SE CONSIDERA
@@ -19527,6 +19597,10 @@ Partial Class Ventas
TmpDT.Columns.Add("CvePrecioLista", GetType(Integer)) TmpDT.Columns.Add("CvePrecioLista", GetType(Integer))
TmpDT.Columns.Add("PrecioLista", GetType(String)) TmpDT.Columns.Add("PrecioLista", GetType(String))
TmpDT.Columns.Add("CveActivoFijo", GetType(Integer))
TmpDT.Columns.Add("AFDepreciacion", GetType(Decimal))
TmpDT.Columns.Add("AFValorInicial", GetType(Decimal))
TmpDT.Columns("EsOutSourcing").DefaultValue = False TmpDT.Columns("EsOutSourcing").DefaultValue = False
TmpDT.Columns("EsCargo").DefaultValue = False TmpDT.Columns("EsCargo").DefaultValue = False
@@ -22253,7 +22327,7 @@ Partial Class Ventas
Row("PU").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("ImporteIVA").ToString().ToDouble, Math.Round((Row("Total").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)) * (1 + Row("PorcentajeIVA").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)))), 6), Row("PU").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("ImporteIVA").ToString().ToDouble, Math.Round((Row("Total").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)) * (1 + Row("PorcentajeIVA").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)))), 6),
Row("Obs").ToString(), Row("Descuento").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("TipoDescuento").ToString().ToEntero(), Row("CveSubProyecto").ToString().ToEntero(), Row("CvePresupuestoIngreso").ToString().ToEntero(), PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, IEPS:=Row("ImporteIEPS").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().ToDouble, TiempoEntrega:=Row("TiempoEntrega").ToString(), Row("Obs").ToString(), Row("Descuento").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("TipoDescuento").ToString().ToEntero(), Row("CveSubProyecto").ToString().ToEntero(), Row("CvePresupuestoIngreso").ToString().ToEntero(), PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, IEPS:=Row("ImporteIEPS").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().ToDouble, TiempoEntrega:=Row("TiempoEntrega").ToString(),
CveVentaDetallePadre:=Row("CveVentaDetalle").ToString().ToEntero(), CveContratoDetalle:=Row("CveContratoDetalle").ToString().ToEntero(), CvePromocionDetalle:=If(DtPromociones IsNot Nothing, DtPromociones.FiltroPrimeroValor("CvePromocionDetalle", $"CvePS={Row("CvePS").ToString()}").ToEntero(), -1), CveVentaDetallePadre:=Row("CveVentaDetalle").ToString().ToEntero(), CveContratoDetalle:=Row("CveContratoDetalle").ToString().ToEntero(), CvePromocionDetalle:=If(DtPromociones IsNot Nothing, DtPromociones.FiltroPrimeroValor("CvePromocionDetalle", $"CvePS={Row("CvePS").ToString()}").ToEntero(), -1),
ImporteRetIVA:=Row("ImporteRetIVA").ToString().ToDouble, ImporteRetISR:=Row("ImporteRetISR").ToString().ToDouble, PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString().ToDouble, PorcentajeRetISR:=Row("PorcentajeRetISR").ToString().ToDouble, CuentaPredial:=Row("CuentaPredial").ToString(), CvePrecioLista:=Row("CvePrecioLista").ToString().ToEntero()) Then ImporteRetIVA:=Row("ImporteRetIVA").ToString().ToDouble, ImporteRetISR:=Row("ImporteRetISR").ToString().ToDouble, PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString().ToDouble, PorcentajeRetISR:=Row("PorcentajeRetISR").ToString().ToDouble, CuentaPredial:=Row("CuentaPredial").ToString(), CvePrecioLista:=Row("CvePrecioLista").ToString().ToEntero(), CveActivoFijo:=Row("CveActivoFijo").ToString().ToEntero()) Then
OcurrioError = True OcurrioError = True
Exit For Exit For
Else Else
@@ -29985,6 +30059,9 @@ Partial Class Ventas
TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer)) TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer))
TmpDT.Columns.Add("TieneProntoPago", GetType(String)) TmpDT.Columns.Add("TieneProntoPago", GetType(String))
TmpDT.Columns.Add("ImporteProntoPago", GetType(Decimal)) TmpDT.Columns.Add("ImporteProntoPago", GetType(Decimal))
TmpDT.Columns.Add("CveActivoFijo", GetType(Integer))
TmpDT.Columns.Add("AFDepreciacion", GetType(Decimal))
TmpDT.Columns.Add("AFValorInicial", GetType(Decimal))
End If End If
Dim FechaFactura As DateTime = Now Dim FechaFactura As DateTime = Now
@@ -35308,6 +35385,10 @@ Partial Class Ventas
TmpDT.Columns.Add("CveMarca", GetType(Integer)) TmpDT.Columns.Add("CveMarca", GetType(Integer))
TmpDT.Columns.Add("CvePrecioLista", GetType(Integer)) TmpDT.Columns.Add("CvePrecioLista", GetType(Integer))
TmpDT.Columns.Add("PrecioLista", GetType(String)) TmpDT.Columns.Add("PrecioLista", GetType(String))
TmpDT.Columns.Add("CveActivoFijo", GetType(Integer))
TmpDT.Columns.Add("AFDepreciacion", GetType(Decimal))
TmpDT.Columns.Add("AFValorInicial", GetType(Decimal))
Return TmpDT Return TmpDT
End Function End Function
Private Function InicializaDTVentasNCProntoPago() As DataTable Private Function InicializaDTVentasNCProntoPago() As DataTable
@@ -36772,5 +36853,160 @@ Partial Class Ventas
End If End If
End Sub End Sub
#Region " A C T I V O S - F I J O S"
Protected Sub CargaDatosAF()
CargarTipoActivoFijo()
CargaDdlAF()
DdlTipoActivo_SelectedIndexChanged(DdlTipoActivoFiltro, EventArgs.Empty)
End Sub
Protected Sub CargarTipoActivoFijo()
DdlTipoActivoFiltro.DataSource = GlobalDTTipoActivoFijo(UsuarioActual.CveEmpresa).FiltraParametros("", "TipoActivoFijo")
DdlTipoActivoFiltro.DataBind()
DdlTipoActivoFiltro.Items.Insert(0, New ListItem("Todos", "-1"))
End Sub
Protected Sub DdlTipoActivo_SelectedIndexChanged(sender As Object, e As EventArgs)
DdlSubTipoActivoFiltro.Items.Clear()
DdlSubTipoActivoFiltro.DataSource = GlobalDTSubTipoActivoFijo(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveTipoActivoFijo = {0}", DdlTipoActivoFiltro.SelectedValue), "SubTipoActivoFijo")
DdlSubTipoActivoFiltro.DataBind()
DdlSubTipoActivoFiltro.Items.Insert(0, New ListItem("Todos", "-1"))
End Sub
#End Region
Protected Sub BtnFiltrarAF_Click(sender As Object, e As EventArgs)
Using ObjAF As New ClsAF
If ObjAF.GetRepActivosFijosDepreciacion(UsuarioActual.CveEmpresa, Now, Depreciados:=1, CveTipoAF:=DdlTipoActivoFiltro.SelectedValue.ToEntero(), CveSubTipoAF:=DdlSubTipoActivoFiltro.SelectedValue.ToEntero(), CveSubProyecto:=DdlSubProyectoFiltroAF.SelectedValue.ToEntero()) Then
GvVentaAF.DataSource = ObjAF.DtResultados.FiltraParametros("CveActivoFijo > 0 AND CveEstadoActivoFijo <> 5")
End If
End Using
GvVentaAF.DataBind()
UpActivosFijos.Update()
End Sub
Private Sub CargaAFVenta()
If CveVenta > 0 AndAlso TmpDT IsNot Nothing AndAlso TmpDT.COUNT("CveActivoFijo", "CveActivoFijo > 0") > 0 Then
DivVentasAF.Visible = True
Using ObjAF As New ClsAF
If ObjAF.GetActivosFijosVenta(Me.CveVenta, UsuarioActual.CveEmpresa) Then
GvAF.DataSource = ObjAF.DtResultados
End If
End Using
GvAF.DataBind()
UpActivosFijos.Update()
End If
End Sub
Public Sub CargaDdlAF()
Dim strAF = UsuarioActual.Empresa.Funcionalidad(380)
Dim CvePSAF As Integer = -1
If String.IsNullOrEmpty(strAF) Then
Dim RowFuncionalidad380 As DataRow = Nothing
Using ObjEmpresas As New ClsSisEmpresas
If ObjEmpresas.GetEmpresasFuncionalidades(UsuarioActual.CveEmpresa) Then
RowFuncionalidad380 = ObjEmpresas.DtResultados.FiltroPrimero("CveFuncionalidad = 380")
End If
End Using
If RowFuncionalidad380 IsNot Nothing Then
CvePSAF = RowFuncionalidad380("Valor").ToString().ToEntero()
End If
Else
CvePSAF = strAF.ToEntero()
End If
If CvePSAF > 0 Then
Dim dtt = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSAF, AplicaParaVenta:=1) ', SATClavePS:=CveSATNC
If dtt IsNot Nothing Then
DdlPSAF.DataSource = dtt
DdlPSAF.DataBind()
End If
Else
LnkGenerarPSAF.Visible = True
DdlPSAF.Items.Insert(0, New ListItem("Seleccione", "-1"))
End If
End Sub
Protected Sub BtnGuardarAF_Click(sender As Object, e As EventArgs)
Dim Cantidad As Decimal = 1
Dim CvePS = DdlPSAF.SelectedValue.ToEntero()
Dim CveUnidadMedida As Integer = -1
Dim UnidadMedida As String = ""
Dim CveClasificacion As Integer = -1
Dim Clasificacion As String = ""
Dim Obs As String = ""
Dim PrecioVenta As Decimal = 0.0D
Dim CveProyecto As Integer = -1
Dim Proyecto As String = ""
Dim CveSubProyecto As Integer = DdlSubProyectoDatos.SelectedValue.ToEntero()
Dim SubProyecto As String = DdlSubProyectoDatos.SelectedItem.Text
If CveSubProyecto > 0 Then
Dim RowSP = GlobalDTSubProyectos(-1, CveSubProyecto:=CveSubProyecto, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("")
If RowSP IsNot Nothing Then
CveProyecto = RowSP("CveProyecto").ToString().ToEntero()
Proyecto = RowSP("Proyecto").ToString()
End If
End If
TmpDT.Rows.Clear()
Dim CveAF As Integer = -1
Dim AFDepreciacion As Decimal = 0
Dim AFValorInicial As Decimal = 0
For Each GvRow As GridViewRow In GvVentaAF.Rows
If GvRow.RowType = DataControlRowType.DataRow Then
'LIMPIA VARIABLES
Obs = ""
CveAF = -1
AFDepreciacion = 0
AFValorInicial = 0
PrecioVenta = 0D
If GvRow.FCCheckBox("chkAF").Checked Then
Obs = GvRow.DataKey("Observaciones")
CveAF = GvRow.DataKey("CveActivoFijo").ToEntero()
AFDepreciacion = GvRow.DataKey("DepreciacionAcumulada").ToDecimal()
AFValorInicial = GvRow.DataKey("MOI").ToDecimal()
PrecioVenta = GvRow.FCTextBox("TxtPrecioAF").Text.ToDecimal()
If PrecioVenta < 1D Then
Alert($"El activo fijo '{GvRow.DataKey("Descripcion")}' debe tener un importe para venta.", TipoMensaje.MsgAdvertencia)
TmpDT.Rows.Clear()
Exit Sub
End If
AgregarProductoServicio(Cantidad, CveUnidadMedida, UnidadMedida, CveClasificacion, Clasificacion, CvePS, "", Obs, PrecioVenta, 0,
CveProyecto, Proyecto, CveSubProyecto, SubProyecto, CveActivoFijo:=CveAF, AFDepreciacion:=AFDepreciacion, AFValorInicial:=AFValorInicial)
End If
End If
Next
DdlMoneda.SelectedValue = "1"
DdlMoneda.Enabled = False
CalculaTotalesVenta()
Tab.ActiveTabIndex = 0
Updatetabs.Update()
End Sub
End Class End Class