Facturación Cíclica
This commit is contained in:
@@ -383,7 +383,7 @@ Public Class ClsContratos
|
|||||||
Optional CveContratosEstatus As Integer = -1, Optional CveContratoTipo As Integer = -1, Optional TipoCambio As Double = 1.0, Optional CveSucursalCliente As Integer = -1, Optional CveAlmacenOrigen As Integer = -1, Optional CveAlmacenDestino As Integer = -1, Optional PorcentajeComision As Integer = -1,
|
Optional CveContratosEstatus As Integer = -1, Optional CveContratoTipo As Integer = -1, Optional TipoCambio As Double = 1.0, Optional CveSucursalCliente As Integer = -1, Optional CveAlmacenOrigen As Integer = -1, Optional CveAlmacenDestino As Integer = -1, Optional PorcentajeComision As Integer = -1,
|
||||||
Optional TipoGarantia As Integer = -1, Optional Folio As Integer = -1, Optional FechaVenc As Date = Nothing, Optional EstatusFianza As Integer = -1, Optional CveContratoPlantilla As Integer = -1, Optional CveCuentaEquipo As Integer = -1,
|
Optional TipoGarantia As Integer = -1, Optional Folio As Integer = -1, Optional FechaVenc As Date = Nothing, Optional EstatusFianza As Integer = -1, Optional CveContratoPlantilla As Integer = -1, Optional CveCuentaEquipo As Integer = -1,
|
||||||
Optional CveVendedor As Integer = -1, Optional Observaciones As String = "", Optional CveDireccionEnvio As Integer = -1, Optional AplicaImpuestosLocales As Boolean = False, Optional CorreoNotificacionPedDev As String = "", Optional FacturacionCicilica As Boolean = False, Optional FacturacionCiclicaAutomatico As Boolean = False,
|
Optional CveVendedor As Integer = -1, Optional Observaciones As String = "", Optional CveDireccionEnvio As Integer = -1, Optional AplicaImpuestosLocales As Boolean = False, Optional CorreoNotificacionPedDev As String = "", Optional FacturacionCicilica As Boolean = False, Optional FacturacionCiclicaAutomatico As Boolean = False,
|
||||||
Optional DiaMesFacturacion As Integer = 1) As Boolean
|
Optional DiaMesFacturacion As Integer = 1, Optional CvePeriodo As Integer = -1) As Boolean
|
||||||
Dim Retorno = False
|
Dim Retorno = False
|
||||||
|
|
||||||
DataAdapter("PA_Con_ContratosUpdate")
|
DataAdapter("PA_Con_ContratosUpdate")
|
||||||
@@ -437,6 +437,7 @@ Public Class ClsContratos
|
|||||||
.Add("@FacturacionCicilica", SqlDbType.Bit).Value = FacturacionCicilica
|
.Add("@FacturacionCicilica", SqlDbType.Bit).Value = FacturacionCicilica
|
||||||
.Add("@FacturacionCiclicaAutomatico", SqlDbType.Bit).Value = FacturacionCiclicaAutomatico
|
.Add("@FacturacionCiclicaAutomatico", SqlDbType.Bit).Value = FacturacionCiclicaAutomatico
|
||||||
.Add("@DiaMesFacturacion", SqlDbType.TinyInt).Value = DiaMesFacturacion
|
.Add("@DiaMesFacturacion", SqlDbType.TinyInt).Value = DiaMesFacturacion
|
||||||
|
.Add("@CvePeriodo", SqlDbType.Int).Value = CvePeriodo
|
||||||
End With
|
End With
|
||||||
|
|
||||||
Try
|
Try
|
||||||
@@ -728,7 +729,7 @@ Public Class ClsContratos
|
|||||||
|
|
||||||
Return Retorno
|
Return Retorno
|
||||||
End Function
|
End Function
|
||||||
Public Function CicloComercialUpdate(CveCicloComercial As Integer, FueFacturado As Boolean, CveEmpresa As Integer) As Boolean
|
Public Function CicloComercialUpdate(CveCicloComercial As Integer, FueFacturado As Boolean, CveEmpresa As Integer, Optional CveVenta As Integer = -1) As Boolean
|
||||||
Dim Retorno As Boolean = False
|
Dim Retorno As Boolean = False
|
||||||
DataAdapter("PA_Con_CicloComercialUpdate")
|
DataAdapter("PA_Con_CicloComercialUpdate")
|
||||||
|
|
||||||
@@ -736,6 +737,7 @@ Public Class ClsContratos
|
|||||||
.Add("@FueFacturado", SqlDbType.Bit).Value = FueFacturado
|
.Add("@FueFacturado", SqlDbType.Bit).Value = FueFacturado
|
||||||
.Add("@CveCicloComercial", SqlDbType.Int).Value = CveCicloComercial
|
.Add("@CveCicloComercial", SqlDbType.Int).Value = CveCicloComercial
|
||||||
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
|
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
|
||||||
|
.Add("@CveVenta", SqlDbType.Int).Value = CveVenta
|
||||||
|
|
||||||
End With
|
End With
|
||||||
Try
|
Try
|
||||||
|
|||||||
@@ -855,7 +855,7 @@ Namespace Modelos
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
If CveCicloComercial > 0 AndAlso ErrorList.Count = 0 Then
|
If CveCicloComercial > 0 AndAlso ErrorList.Count = 0 Then
|
||||||
If Not ObjContr.CicloComercialUpdate(Me.CveCicloComercial, True, UsuarioActual.CveEmpresa) Then
|
If Not ObjContr.CicloComercialUpdate(Me.CveCicloComercial, True, UsuarioActual.CveEmpresa, CveVenta:=CveVenta) Then
|
||||||
ErrorList.Add("No se pudo actualizar ")
|
ErrorList.Add("No se pudo actualizar ")
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|||||||
709
Ashx/SIGFacturacionCiclica.ashx
Normal file
709
Ashx/SIGFacturacionCiclica.ashx
Normal file
@@ -0,0 +1,709 @@
|
|||||||
|
<%@ WebHandler Language="VB" Class="SIGFacturacionCiclica" %>
|
||||||
|
'Option Explicit On
|
||||||
|
'Option Strict On
|
||||||
|
|
||||||
|
Imports System
|
||||||
|
Imports System.Web
|
||||||
|
Imports System.Data
|
||||||
|
Imports Newtonsoft.Json.Linq
|
||||||
|
Imports Extensiones
|
||||||
|
Imports System.IO
|
||||||
|
Imports Microsoft.AspNet.SignalR
|
||||||
|
|
||||||
|
Public Class SIGFacturacionCiclica : Implements IHttpHandler, IRequiresSessionState
|
||||||
|
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
|
||||||
|
context.Response.ContentType = "text/plain"
|
||||||
|
Dim retorno = False
|
||||||
|
Try
|
||||||
|
If context.Request("Metodo") IsNot Nothing Then
|
||||||
|
Select Case context.Request("Metodo")
|
||||||
|
Case "EjecutaServicio"
|
||||||
|
ModExtensiones.GuardaLogAD("Servicio Ejecutado...........", "LogFacturacionCiclica")
|
||||||
|
retorno = IniciaFacturacionMasiva()
|
||||||
|
End Select
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
Catch ex As Exception
|
||||||
|
ex.GuardaLog(ex.Message)
|
||||||
|
End Try
|
||||||
|
|
||||||
|
If retorno Then
|
||||||
|
context.Response.Write("True")
|
||||||
|
Else
|
||||||
|
context.Response.Write("False")
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
|
||||||
|
Get
|
||||||
|
Return False
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
|
Private Function Parametros(Cadena As String) As Hashtable
|
||||||
|
Dim P1() As String = Cadena.Split("&"c)
|
||||||
|
Dim Tmp As String
|
||||||
|
Dim P2() As String
|
||||||
|
|
||||||
|
Dim URLParametros As New Hashtable
|
||||||
|
|
||||||
|
For Each Tmp In P1
|
||||||
|
P2 = Tmp.Replace("%26%", "&").Split("="c)
|
||||||
|
URLParametros.Add(P2(0).ToString.ToUpper, P2(1))
|
||||||
|
Next
|
||||||
|
Return URLParametros
|
||||||
|
End Function
|
||||||
|
|
||||||
|
#Region "V A L I D A - D A T O S"
|
||||||
|
Private Function ValidaUsuarioSistema(CveEmpresa As Integer) As Usuario
|
||||||
|
Dim UsuarioActual As Usuario = Nothing
|
||||||
|
Dim ObjUsuarios As New ClsSisUsuarios
|
||||||
|
If ObjUsuarios.GetUsuarios(100) Then
|
||||||
|
If ObjUsuarios.DtResultados.Rows.Count > 0 Then
|
||||||
|
Dim Usuario = ObjUsuarios.DtResultados.Rows(0)("Usuario").ToString()
|
||||||
|
Dim Contrasenia = ObjUsuarios.DtResultados.Rows(0)("Contraseña").ToString()
|
||||||
|
UsuarioActual = ObjUsuarios.ValidaUsuario(Usuario, Contrasenia, IMEI, CveEmpresa)
|
||||||
|
UsuarioActual.CveEmpresa = CveEmpresa
|
||||||
|
CreaObjetoEmpresa(UsuarioActual)
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
ObjUsuarios.Dispose()
|
||||||
|
Return UsuarioActual
|
||||||
|
End Function
|
||||||
|
Private Sub CreaObjetoEmpresa(ByRef UsuarioActual As Usuario)
|
||||||
|
|
||||||
|
Dim ObjEmpresa As New ClsSisEmpresas()
|
||||||
|
If ObjEmpresa.GetEmpresas(UsuarioActual.CveEmpresa, "-1", "-1", "-1", "-1") Then
|
||||||
|
If ObjEmpresa.GetEmpresasFuncionalidades(UsuarioActual.CveEmpresa) Then
|
||||||
|
Dim dttmp As Data.DataTable = ObjEmpresa.DtResultados
|
||||||
|
|
||||||
|
Dim EmpresasFuncionalidades As New HybridDictionary
|
||||||
|
For Each Row As Data.DataRow In dttmp.Rows
|
||||||
|
EmpresasFuncionalidades.Add(Convert.ToInt32(Row("CveFuncionalidad")), Row("Valor").ToString)
|
||||||
|
Next
|
||||||
|
ObjEmpresa.Empresa.SetFuncionalidades(EmpresasFuncionalidades)
|
||||||
|
End If
|
||||||
|
|
||||||
|
UsuarioActual.Empresa = ObjEmpresa.Empresa
|
||||||
|
End If
|
||||||
|
ObjEmpresa.Dispose()
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
#End Region
|
||||||
|
|
||||||
|
Private Function IniciaFacturacionMasiva() As Boolean
|
||||||
|
Dim Retorno As Boolean = True
|
||||||
|
Dim FechaRef As DateTime = DateTime.Now
|
||||||
|
Dim DTCicloComercial As DataTable = Nothing
|
||||||
|
|
||||||
|
Using ObjContratos As New ClsContratos
|
||||||
|
If ObjContratos.CicloComercialGet(-1, -1, -1, -1, FechaRef, FechaRef, -1) Then
|
||||||
|
DTCicloComercial = ObjContratos.DtResultados.FiltraParametros("FueFacturado = 0 AND FacturacionCiclicaAutomatico = 1")
|
||||||
|
End If
|
||||||
|
End Using
|
||||||
|
|
||||||
|
If DTCicloComercial IsNot Nothing Then
|
||||||
|
For Each RowEmpresa As DataRow In DTCicloComercial.FiltraParametros("", DistinctColumns:={"CveEmpresa"}).Rows
|
||||||
|
Dim CveEmpresa As Integer = RowEmpresa("CveEmpresa").ToString().ToEntero()
|
||||||
|
Dim UsuarioActual = ValidaUsuarioSistema(CveEmpresa)
|
||||||
|
If UsuarioActual IsNot Nothing Then
|
||||||
|
Retorno = EjecutarFacturacionMasiva(UsuarioActual, DTCicloComercial.FiltraParametros($"CveEmpresa = {CveEmpresa}"))
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
|
||||||
|
Return Retorno
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Function EjecutarFacturacionMasiva(UsuarioActual As Usuario, DTCicloComercial As DataTable) As Boolean
|
||||||
|
Dim Retorno As Boolean = False
|
||||||
|
|
||||||
|
If DTCicloComercial IsNot Nothing Then
|
||||||
|
For Each Row As DataRow In DTCicloComercial.Rows
|
||||||
|
|
||||||
|
If Row("Observaciones").ToString().Contains("{DIA}") Then
|
||||||
|
Row("Observaciones") = Row("Observaciones").ToString().Replace("{DIA}", DateTime.Now.Day.ToString())
|
||||||
|
End If
|
||||||
|
|
||||||
|
If Row("Observaciones").ToString().Contains("{MES}") Then
|
||||||
|
Dim fecha As DateTime = DateTime.Now
|
||||||
|
Dim formatoFecha = Globalization.CultureInfo.CurrentCulture.DateTimeFormat
|
||||||
|
Dim nombreMes = formatoFecha.GetMonthName(fecha.Month).ToUpper()
|
||||||
|
|
||||||
|
Row("Observaciones") = Row("Observaciones").ToString().Replace("{MES}", nombreMes)
|
||||||
|
End If
|
||||||
|
|
||||||
|
If Row("Observaciones").ToString().Contains("{AÑO}") Then
|
||||||
|
Row("Observaciones") = Row("Observaciones").ToString().Replace("{AÑO}", DateTime.Now.Year.ToString())
|
||||||
|
End If
|
||||||
|
|
||||||
|
If Row("Observaciones").ToString().Contains("{TC}") Then
|
||||||
|
Row("Observaciones") = Row("Observaciones").ToString().Replace("{TC}", GlobalTipoCambio(Now).FormatoNumero)
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim Resp = EmitirImprimir(UsuarioActual, Row)
|
||||||
|
|
||||||
|
If Resp.CveVenta > 0 Then
|
||||||
|
Retorno = True
|
||||||
|
End If
|
||||||
|
|
||||||
|
Next
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
Return Retorno
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Function EmitirImprimir(UsuarioActual As Usuario, RowCiclo As DataRow) As Modelos.Factura.MMensajeFactura
|
||||||
|
Dim Resp As New Modelos.Factura.MMensajeFactura
|
||||||
|
|
||||||
|
Dim ObjFactura = CreaObjetosVenta(UsuarioActual, RowCiclo)
|
||||||
|
|
||||||
|
If ObjFactura Is Nothing Then
|
||||||
|
Resp.Mensajes.Add("Ocurrió un error al procesar los datos de la Venta ")
|
||||||
|
ObjFactura = Nothing
|
||||||
|
Return Resp
|
||||||
|
End If
|
||||||
|
|
||||||
|
If ObjFactura.CveCliente > 0 Then
|
||||||
|
If ObjFactura.DtDetalle.Rows.Count > 0 Then
|
||||||
|
Resp = ObjFactura.EmitirFactura()
|
||||||
|
Else
|
||||||
|
Resp.Mensajes.Add("No se pudo completar facturación por que no se encontraron partidas ")
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
Resp.Mensajes.Add("No se pudo completar facturación por que no se encontraro el cliente ")
|
||||||
|
End If
|
||||||
|
|
||||||
|
Return Resp
|
||||||
|
End Function
|
||||||
|
|
||||||
|
#Region "P R E P A R A - V E N T A"
|
||||||
|
Private Function CreaDTVentas() As DataTable
|
||||||
|
Dim TmpDT = New DataTable
|
||||||
|
TmpDT.Columns.Add("CveVenta", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("Consec", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("Cantidad", GetType(Decimal))
|
||||||
|
TmpDT.Columns.Add("Codigo", GetType(String))
|
||||||
|
TmpDT.Columns.Add("CveUM", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("UM", GetType(String))
|
||||||
|
TmpDT.Columns.Add("SATClaveUM", GetType(String))
|
||||||
|
TmpDT.Columns.Add("CveClasificacion", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("Clasificacion", GetType(String))
|
||||||
|
TmpDT.Columns.Add("CvePS", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("PS", GetType(String))
|
||||||
|
TmpDT.Columns.Add("CodigoPS", GetType(String))
|
||||||
|
TmpDT.Columns.Add("SATClaveProdServ", GetType(String))
|
||||||
|
TmpDT.Columns.Add("NoIdentificacion", GetType(String))
|
||||||
|
TmpDT.Columns.Add("CveTipoPS", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("CveTipoInvPS", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("Serie", GetType(String))
|
||||||
|
TmpDT.Columns.Add("CuentaPredial", GetType(String))
|
||||||
|
TmpDT.Columns.Add("Obs", GetType(String))
|
||||||
|
TmpDT.Columns.Add("TiempoEntrega", GetType(String))
|
||||||
|
TmpDT.Columns.Add("PU", GetType(Decimal))
|
||||||
|
TmpDT.Columns.Add("IVA", GetType(Decimal))
|
||||||
|
TmpDT.Columns.Add("ImporteIVA", GetType(Decimal))
|
||||||
|
TmpDT.Columns.Add("PorcentajeIVA", GetType(Decimal))
|
||||||
|
TmpDT.Columns.Add("ImporteRetIVA", GetType(Decimal))
|
||||||
|
TmpDT.Columns.Add("ImporteRetISR", GetType(Decimal))
|
||||||
|
TmpDT.Columns.Add("PorcentajeRetIVA", GetType(Decimal))
|
||||||
|
TmpDT.Columns.Add("PorcentajeRetISR", GetType(Decimal))
|
||||||
|
TmpDT.Columns.Add("ImporteIEPS", GetType(Decimal))
|
||||||
|
TmpDT.Columns.Add("IEPS", GetType(Decimal))
|
||||||
|
TmpDT.Columns.Add("PorcentajeIEPS", GetType(Decimal))
|
||||||
|
TmpDT.Columns.Add("Descuento", GetType(Decimal))
|
||||||
|
TmpDT.Columns.Add("TipoDescuento", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("TotalImporte", GetType(Decimal))
|
||||||
|
TmpDT.Columns.Add("Total", GetType(Decimal))
|
||||||
|
'Para uso del módulo contable
|
||||||
|
TmpDT.Columns.Add("AsientoContableVentas", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("IdCtaContVentas", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("AplicaParaConcepto", GetType(Boolean))
|
||||||
|
TmpDT.Columns.Add("CveProyecto", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("Proyecto", GetType(String))
|
||||||
|
TmpDT.Columns.Add("CveSubProyecto", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("SubProyecto", GetType(String))
|
||||||
|
TmpDT.Columns.Add("CveVentaDetallePadre", GetType(Integer))
|
||||||
|
|
||||||
|
'TipoDescuento: 1 = Descuento * PU; 2 = Descuento por Total del concepto
|
||||||
|
TmpDT.Columns.Add("CvePresupuestoIngreso", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("CveFuenteRecaudacion", GetType(Integer))
|
||||||
|
'Contratos
|
||||||
|
TmpDT.Columns.Add("CveContratoDetalle", GetType(Integer))
|
||||||
|
'Remisiones a Facturas
|
||||||
|
TmpDT.Columns.Add("CveVentaDetalle", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("CveVentaDetalleRemision", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("CveVentaDetalleCotizacion", GetType(Integer))
|
||||||
|
|
||||||
|
'Pedido2 a Facturas
|
||||||
|
TmpDT.Columns.Add("CveVentaDetallePedido2", GetType(Integer))
|
||||||
|
|
||||||
|
TmpDT.Columns.Add("Origen", GetType(Integer))
|
||||||
|
'Ordenes Servicio
|
||||||
|
TmpDT.Columns.Add("CveOS", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("CveOSDetalle", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("SeFacturara", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("Folio", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("Estatus", GetType(String))
|
||||||
|
'Ordenamiento
|
||||||
|
TmpDT.Columns.Add("Orden", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("TipoDocto", GetType(String))
|
||||||
|
'OC
|
||||||
|
TmpDT.Columns.Add("CveOrdenCompraDetalle", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
|
||||||
|
|
||||||
|
TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("CantidadFacturadaRem", GetType(Decimal))
|
||||||
|
TmpDT.Columns.Add("CantidadFacturadaCot", GetType(Decimal))
|
||||||
|
TmpDT.Columns.Add("CantidadFacturadaPed2", GetType(Decimal))
|
||||||
|
TmpDT.Columns.Add("CantidadInventario", GetType(Decimal))
|
||||||
|
|
||||||
|
TmpDT.Columns.Add("ClaveSATFraccionArancelaria", GetType(String))
|
||||||
|
TmpDT.Columns.Add("ClaveSATUnidadAduana", GetType(String))
|
||||||
|
TmpDT.Columns.Add("ClaveSATFraccionArancelariaDescripcion", GetType(String))
|
||||||
|
TmpDT.Columns.Add("ClaveSATUnidadAduanaDescripcion", GetType(String))
|
||||||
|
|
||||||
|
TmpDT.Columns.Add("CveTamaño", GetType(Integer))
|
||||||
|
TmpDT.Columns.Add("EsCargo", GetType(Boolean))
|
||||||
|
|
||||||
|
Return TmpDT
|
||||||
|
End Function
|
||||||
|
Private Function CreaObjetosVenta(UsuarioActual As Usuario, DR As DataRow) As Modelos.Factura
|
||||||
|
Dim ObjFactura = New Modelos.Factura(UsuarioActual)
|
||||||
|
Try
|
||||||
|
ObjFactura.DirectorioServidor = HttpContext.Current.Server.MapPath("/")
|
||||||
|
|
||||||
|
Dim CveProyecto As String = ""
|
||||||
|
Dim CveSubProyecto As String = ""
|
||||||
|
Dim Proyecto As String = ""
|
||||||
|
Dim SubProyecto As String = ""
|
||||||
|
Dim CveCicloComercial = DR("CveCicloComercial").ToString().ToEntero()
|
||||||
|
|
||||||
|
ObjFactura.CveCicloComercial = CveCicloComercial
|
||||||
|
|
||||||
|
Dim TmpDT As DataTable = CreaDTVentas()
|
||||||
|
|
||||||
|
ObjFactura.Version = "3.3"
|
||||||
|
ObjFactura.CveUsuario = UsuarioActual.CveUsuario
|
||||||
|
ObjFactura.CveEmpresa = UsuarioActual.CveEmpresa
|
||||||
|
ObjFactura.ConvertirPesos = False
|
||||||
|
ObjFactura.CveMoneda = DR("CveMoneda").ToString.ToEntero
|
||||||
|
ObjFactura.Moneda = GlobalDTMonedas.FiltroPrimeroValor("Moneda", $"CveMoneda = {ObjFactura.CveMoneda} ")
|
||||||
|
ObjFactura.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", $"CveMoneda = {DR("CveMoneda").ToString.ToEntero}")
|
||||||
|
ObjFactura.TipoCambio = If(ObjFactura.CveMoneda = 1, 1, GlobalTipoCambio(Now))
|
||||||
|
ObjFactura.TipoDocto = "Ing"
|
||||||
|
ObjFactura.RefDocto = ""
|
||||||
|
ObjFactura.Folio = -1
|
||||||
|
ObjFactura.Serie = "-1"
|
||||||
|
ObjFactura.CveMesa = -1
|
||||||
|
ObjFactura.Fecha = DR("FechaVenc").ToString.ToDate
|
||||||
|
ObjFactura.CvePrePoliza = -1
|
||||||
|
ObjFactura.CveMetodoPago = 1
|
||||||
|
ObjFactura.MetodoPago = "Efectivo"
|
||||||
|
ObjFactura.FechaPago = DateTime.Today
|
||||||
|
ObjFactura.MotivoDescuento = ""
|
||||||
|
ObjFactura.Observaciones = DR("Observaciones").ToString
|
||||||
|
ObjFactura.FechaEjecucion = DateTime.Today
|
||||||
|
'ObjFactura.ClaveMetodoPagoSAT = GlobalDTMetodosPago.FiltroPrimeroValor("ClaveSAT", $"CveMetodoPago = {1}")
|
||||||
|
ObjFactura.UsuarioCreo = UsuarioActual.Usuario
|
||||||
|
ObjFactura.CveCondicionEntrega = -1
|
||||||
|
ObjFactura.CondicionEntrega = ""
|
||||||
|
ObjFactura.NumeroCuenta = ""
|
||||||
|
'ObjFactura.CveSucursal = GlobalDTSucursales.FiltroPrimeroValor("CveSucursal", $"CveEmpresa = {UsuarioActual.CveEmpresa}").ToEntero
|
||||||
|
'ObjFactura.Cliente.NumCtaPago = TxtNumCtaPago.Text.Trim
|
||||||
|
ObjFactura.CondicionesPago = 0
|
||||||
|
ObjFactura.FormaPago = 0
|
||||||
|
'ObjFactura.SerieFolio = String.Format("{0}-{1}", LblSerie.Text, TxtFolio.Text)
|
||||||
|
ObjFactura.PedidoContrato = ""
|
||||||
|
ObjFactura.NumeroContrato = DR("NumeroContrato").ToString
|
||||||
|
ObjFactura.DescripcionContrato = DR("DescripcionContrato").ToString
|
||||||
|
ObjFactura.CveCorte = -1
|
||||||
|
ObjFactura.TipoDocumento = "Factura"
|
||||||
|
ObjFactura.Alfa1 = ""
|
||||||
|
ObjFactura.Alfa2 = ""
|
||||||
|
ObjFactura.Alfa3 = ""
|
||||||
|
'Totales, Y se llena TmpDTImpuestos
|
||||||
|
ObjFactura.Descuento = 0
|
||||||
|
ObjFactura.Amortizacion = 0
|
||||||
|
ObjFactura.CveContrato = DR("CveContrato").ToString.ToEntero
|
||||||
|
CveProyecto = DR("CveProyecto").ToString
|
||||||
|
Proyecto = DR("ProyectoContrato").ToString
|
||||||
|
CveSubProyecto = DR("CveSubProyecto").ToString
|
||||||
|
ObjFactura.CveSubProyecto = CveSubProyecto.ToEntero
|
||||||
|
ObjFactura.CveSubProyectoCobranza = CveSubProyecto.ToEntero
|
||||||
|
ObjFactura.CveSubProyectoEjecucion = CveSubProyecto.ToEntero
|
||||||
|
|
||||||
|
ObjFactura.SubProyecto = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1).FiltroPrimero(String.Format("CveSubProyecto = {0}", ObjFactura.CveSubProyecto)))
|
||||||
|
ObjFactura.SubProyectoMatriz = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1, CveSubProyecto:=-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("TipoSucursal=1"))
|
||||||
|
|
||||||
|
|
||||||
|
SubProyecto = DR("SubProyectoContrato").ToString
|
||||||
|
|
||||||
|
Dim DtDetalle As DataTable = Nothing
|
||||||
|
Dim objContratos As New ClsContratos
|
||||||
|
If objContratos.GetContratosDetalle(DR("CveContrato").ToString.ToEntero) Then
|
||||||
|
DtDetalle = objContratos.DtResultados
|
||||||
|
Else
|
||||||
|
DtDetalle = Nothing
|
||||||
|
End If
|
||||||
|
objContratos.Dispose()
|
||||||
|
|
||||||
|
Dim DtR As DataRow
|
||||||
|
ObjFactura.SubTotal = SUM(DtDetalle, "Total").ToDecimal
|
||||||
|
ObjFactura.IVA = SUM(DtDetalle, "ImporteIVA").ToDecimal
|
||||||
|
ObjFactura.RetIVA = SUM(DtDetalle, "ImporteRetIVA").ToDecimal
|
||||||
|
ObjFactura.RetISR = SUM(DtDetalle, "ImporteRetISR").ToDecimal
|
||||||
|
ObjFactura.IEPS = SUM(DtDetalle, "ImporteIEPS").ToDecimal
|
||||||
|
ObjFactura.Total = ObjFactura.SubTotal + ObjFactura.IVA + ObjFactura.IEPS - (ObjFactura.RetIVA + ObjFactura.RetISR)
|
||||||
|
|
||||||
|
For Each row As DataRow In DtDetalle.Rows
|
||||||
|
Dim drPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=row("CvePS").ToString().ToEntero()).FiltroPrimero("")
|
||||||
|
|
||||||
|
DtR = TmpDT.NewRow
|
||||||
|
DtR("CveVenta") = -1
|
||||||
|
DtR("Codigo") = row("Codigo")
|
||||||
|
DtR("Consec") = TmpDT.Rows.Count + 1
|
||||||
|
DtR("Cantidad") = row("CantidadContratada")
|
||||||
|
DtR("CveUM") = row("CveUM")
|
||||||
|
DtR("UM") = row("UM")
|
||||||
|
DtR("SATClaveUM") = row("SATClaveUM")
|
||||||
|
DtR("CveClasificacion") = row("CveClasificacion")
|
||||||
|
DtR("Clasificacion") = row("Clasificacion")
|
||||||
|
DtR("CvePS") = row("CvePS")
|
||||||
|
DtR("PS") = row("PS")
|
||||||
|
DtR("CodigoPS") = row("CodigoPS")
|
||||||
|
DtR("SATClaveProdServ") = row("SATClaveProdServ")
|
||||||
|
DtR("NoIdentificacion") = row("NoIdentificacion")
|
||||||
|
DtR("CveTipoPS") = drPS("CveTipoPS")
|
||||||
|
DtR("CveTipoInvPS") = drPS("Inv_CveMetodoInventario")
|
||||||
|
DtR("Obs") = row("Observacion").ToString
|
||||||
|
DtR("PU") = row("PU")
|
||||||
|
DtR("IVA") = row("PorcentajeIVA")
|
||||||
|
DtR("PorcentajeIVA") = row("PorcentajeIVA")
|
||||||
|
DtR("ImporteIVA") = row("ImporteIVA")
|
||||||
|
DtR("PorcentajeIEPS") = row("PorcentajeIEPS")
|
||||||
|
DtR("ImporteIEPS") = row("ImporteIEPS")
|
||||||
|
DtR("PorcentajeRetIVA") = row("PorcentajeRetIVA")
|
||||||
|
DtR("ImporteRetIVA") = row("ImporteRetIVA")
|
||||||
|
DtR("PorcentajeRetISR") = row("PorcentajeRetISR")
|
||||||
|
DtR("ImporteRetISR") = row("ImporteRetISR")
|
||||||
|
DtR("Descuento") = 0
|
||||||
|
DtR("TipoDescuento") = 0
|
||||||
|
DtR("CveProyecto") = CveProyecto
|
||||||
|
DtR("Proyecto") = Proyecto
|
||||||
|
DtR("CveSubProyecto") = CveSubProyecto
|
||||||
|
DtR("SubProyecto") = SubProyecto
|
||||||
|
DtR("CveVentaDetalle") = 0
|
||||||
|
DtR("CveContratoDetalle") = row("CveContratoDetalle")
|
||||||
|
DtR("CuentaPredial") = row("CuentaPredial")
|
||||||
|
DtR("TotalImporte") = row("Total")
|
||||||
|
|
||||||
|
TmpDT.Rows.Add(DtR)
|
||||||
|
Next
|
||||||
|
|
||||||
|
'DETALLES
|
||||||
|
ObjFactura.DtDetalle = TmpDT
|
||||||
|
|
||||||
|
'CLIENTE
|
||||||
|
ObjFactura.CveCliente = DR("CveCliente").ToString.ToEntero
|
||||||
|
ObjFactura.SetCliente()
|
||||||
|
|
||||||
|
Dim ObjCliente As New ClsClientes
|
||||||
|
If ObjCliente.GetClientes(ObjFactura.CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, -1, TipoCliente:=-1) Then
|
||||||
|
If ObjCliente.DtResultados.Rows.Count > 0 Then
|
||||||
|
ObjFactura.CveFormaPago33 = ObjCliente.CveFormaPago33
|
||||||
|
ObjFactura.FormaPago33 = GlobalDTVtaFormaPago.FiltroPrimeroValor("FormaPago", String.Format("CveFormaPago = {0}", ObjCliente.CveFormaPago33))
|
||||||
|
ObjFactura.FormaPagoSAT33 = GlobalDTVtaFormaPago.FiltroPrimeroValor("ClaveFormaPagoSAT", String.Format("CveFormaPago = {0}", ObjCliente.CveFormaPago33))
|
||||||
|
|
||||||
|
ObjFactura.CveMetodoPago33 = ObjCliente.CveMetodoPago33
|
||||||
|
ObjFactura.MetodoPago33 = GlobalDTVtaMetodoPago.FiltroPrimeroValor("MetodoPago", String.Format("CveMetodoPago = {0}", ObjCliente.CveMetodoPago33))
|
||||||
|
ObjFactura.ClaveMetodoPagoSAT = GlobalDTVtaMetodoPago.FiltroPrimeroValor("ClaveMetodoPagoSAT", String.Format("CveMetodoPago = {0}", ObjCliente.CveMetodoPago33))
|
||||||
|
|
||||||
|
ObjFactura.CveUsoCFDI = ObjCliente.CveUsoCFDI
|
||||||
|
ObjFactura.UsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("Descripcion", String.Format("CveUsoCFDI = {0}", ObjCliente.CveUsoCFDI))
|
||||||
|
ObjFactura.ClaveUsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("UsoCFDI", String.Format("CveUsoCFDI = {0}", ObjCliente.CveUsoCFDI))
|
||||||
|
|
||||||
|
ObjFactura.CveMetodoPago = ObjCliente.CveMetodoPago
|
||||||
|
|
||||||
|
If GlobalDTMetodosPago.FiltraParametros(String.Format("CveMetodoPago = {0}", ObjCliente.CveMetodoPago)).Rows.Count > 0 Then
|
||||||
|
ObjFactura.MetodoPago = GlobalDTMetodosPago.FiltraParametros(String.Format("CveMetodoPago = {0}", ObjCliente.CveMetodoPago)).Rows(0)("MetodoPago").ToString
|
||||||
|
Else
|
||||||
|
ObjFactura.CveMetodoPago = 1
|
||||||
|
ObjFactura.MetodoPago = "Efectivo"
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
If ObjCliente.GetSucursales(ObjFactura.CveCliente) Then
|
||||||
|
If ObjCliente.DtResultados.Rows.Count > 0 Then
|
||||||
|
ObjFactura.CveClienteSucursal = If(String.IsNullOrEmpty(ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "Estatus = 'Activo'")), -1, ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "Estatus = 'Activo'").ToEntero())
|
||||||
|
Else
|
||||||
|
ObjFactura.CveClienteSucursal = -1
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
ObjCliente.Dispose()
|
||||||
|
|
||||||
|
'SUBPROYECTO
|
||||||
|
'ObjFactura.SetSubProyectoMatriz(Me)
|
||||||
|
'ObjFactura.SetSubProyecto(Me)
|
||||||
|
|
||||||
|
ObjFactura.Timbre = PreParaTimbre(ObjFactura, UsuarioActual)
|
||||||
|
Catch ex As Exception
|
||||||
|
ObjFactura = Nothing
|
||||||
|
OnError("Ocurrió un error al generar la factura", ex)
|
||||||
|
End Try
|
||||||
|
|
||||||
|
|
||||||
|
Return ObjFactura
|
||||||
|
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Function PreParaTimbre(Obj As Modelos.Factura, UsuarioActual As Usuario) As CFDITimbre
|
||||||
|
Dim Timbre As New CFDITimbre
|
||||||
|
Timbre.Comprobante.TipoComprobante = If(Obj.TipoDocto.Contiene("Ing", "Ant"), "I", If(Obj.TipoDocto.Contiene("Egs", "Dev"), "E", ""))
|
||||||
|
Timbre.Comprobante.Folio = Obj.Folio.ToString
|
||||||
|
Timbre.Comprobante.Serie = Obj.Serie
|
||||||
|
Timbre.Comprobante.Fecha = Obj.FechaCP
|
||||||
|
Timbre.Comprobante.FormadePago = Obj.FormaPagoSAT33
|
||||||
|
Timbre.Comprobante.CondicionesdePago = Obj.FormaPago33
|
||||||
|
Timbre.Comprobante.MetodoPago = Obj.ClaveMetodoPagoSAT
|
||||||
|
Timbre.Comprobante.Subtotal = Obj.SubTotal
|
||||||
|
Timbre.Comprobante.Descuentos = Obj.Descuento
|
||||||
|
Timbre.Comprobante.Moneda = Obj.MonedaSAT
|
||||||
|
Timbre.Comprobante.TipoCambio = If(Obj.CveMoneda = 1, "1", Obj.TipoCambio.ToString)
|
||||||
|
Timbre.Comprobante.Total = Obj.Total
|
||||||
|
|
||||||
|
Timbre.Comprobante.LugarExpedicion = Obj.SubProyecto.CP
|
||||||
|
Timbre.Comprobante.Confirmacion = ""
|
||||||
|
|
||||||
|
Timbre.Receptor.RFC = Obj.Cliente.RFC
|
||||||
|
Timbre.Receptor.Nombre = Obj.Cliente.Nombre
|
||||||
|
Timbre.Receptor.ResidenciaFiscal = ""
|
||||||
|
Timbre.Receptor.NumeroRegistroTributario = ""
|
||||||
|
Timbre.Receptor.UsoCFDI = Obj.ClaveUsoCFDI
|
||||||
|
|
||||||
|
|
||||||
|
If Obj.CveTipoRelacion > 0 Then
|
||||||
|
Select Case Obj.CveTipoRelacion
|
||||||
|
Case 1
|
||||||
|
Timbre.CFDIRelacionados.TipoRelacion = "01"
|
||||||
|
Timbre.CFDIRelacionados.TipoRelacionTexto = "01-Nota de Crédito aplicada a Ingreso"
|
||||||
|
Case 2
|
||||||
|
Timbre.CFDIRelacionados.TipoRelacion = "02"
|
||||||
|
Timbre.CFDIRelacionados.TipoRelacionTexto = "02-Nota de débito de los documentos relacionados"
|
||||||
|
Case 3
|
||||||
|
Timbre.CFDIRelacionados.TipoRelacion = "03"
|
||||||
|
Timbre.CFDIRelacionados.TipoRelacionTexto = "03-Devolución aplicada a Ingreso"
|
||||||
|
Case 4
|
||||||
|
Timbre.CFDIRelacionados.TipoRelacion = "04"
|
||||||
|
Timbre.CFDIRelacionados.TipoRelacionTexto = "04-Refacturación de Ingreso"
|
||||||
|
Case 7
|
||||||
|
Timbre.CFDIRelacionados.TipoRelacion = "07"
|
||||||
|
Timbre.CFDIRelacionados.TipoRelacionTexto = "07-CFDI por aplicación de anticipo"
|
||||||
|
Case 8
|
||||||
|
Timbre.CFDIRelacionados.TipoRelacion = "08"
|
||||||
|
Timbre.CFDIRelacionados.TipoRelacionTexto = "08-Factura generada por pagos en parcialidades "
|
||||||
|
Case 9
|
||||||
|
Timbre.CFDIRelacionados.TipoRelacion = "09"
|
||||||
|
Timbre.CFDIRelacionados.TipoRelacionTexto = "09-Factura generada por pagos diferidos"
|
||||||
|
|
||||||
|
End Select
|
||||||
|
|
||||||
|
'If DtVentasNC IsNot Nothing AndAlso DtVentasNC.Rows.Count > 0 Then
|
||||||
|
' For Each Dr As DataRow In DtVentasNC.Rows
|
||||||
|
' Timbre.CFDIRelacionados.UUID.Add(Dr("FolioFiscal").ToString)
|
||||||
|
' Next
|
||||||
|
'Else
|
||||||
|
' Timbre.CFDIRelacionados.UUID.Add(HdnFolioFiscalNC.Value)
|
||||||
|
'End If
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
Dim totSubTotal As Decimal = Obj.SubTotal
|
||||||
|
Dim totIVA As Decimal = Obj.IVA
|
||||||
|
Dim totRetIVA As Decimal = Obj.RetIVA
|
||||||
|
Dim totRetISR As Decimal = Obj.RetISR
|
||||||
|
Dim i As Integer = 1
|
||||||
|
|
||||||
|
'detalles
|
||||||
|
Dim tPS As String = ""
|
||||||
|
|
||||||
|
For Each drr As DataRow In Obj.DtDetalle.Rows
|
||||||
|
If drr("PS").ToString.Length = 1 Then
|
||||||
|
tPS = drr("Obs").ToString
|
||||||
|
Else
|
||||||
|
If drr("PS").ToString.Length = 0 Then
|
||||||
|
tPS = ""
|
||||||
|
Else
|
||||||
|
tPS = String.Format("{0} {1}", drr("PS"), drr("Obs"))
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
'condicionante, especial
|
||||||
|
If UsuarioActual.CveEmpresa = 15 Then drr("UM") = "" ' les comentan que no debe de ir la etiqueta de "unidad" en el producto
|
||||||
|
|
||||||
|
Dim concepto As New CFDIConceptos With {.Cantidad = drr("Cantidad").ToString.ToDecimal,
|
||||||
|
.Descripcion = tPS,
|
||||||
|
.ValorUnitario = drr("PU").ToString.ToDecimal,
|
||||||
|
.Importe = drr("TotalImporte").ToString.ToDecimal,
|
||||||
|
.Descuento = drr("Descuento").ToString.ToDecimal,
|
||||||
|
.Unidad = drr("UM").ToString,
|
||||||
|
.ClaveUnidad = drr("SATClaveUM").ToString,
|
||||||
|
.ClaveProdServ = drr("SATClaveProdServ").ToString,
|
||||||
|
.Noidentificacion = drr("Noidentificacion").ToString,
|
||||||
|
.CuentaPredial = drr("CuentaPredial").ToString}
|
||||||
|
'verifica suma subtotales
|
||||||
|
If i = Obj.DtDetalle.Rows.Count AndAlso totSubTotal <> concepto.Importe Then 'proceso de ajusta de decimales
|
||||||
|
concepto.Importe = totSubTotal
|
||||||
|
End If
|
||||||
|
totSubTotal = totSubTotal - concepto.Importe
|
||||||
|
|
||||||
|
'siempre estaremos agregando el iva, auqnue sea en importe cero o tasa cero, para que se emita la factura
|
||||||
|
' If drr("ImporteIVA").ToString.ToDouble > 0 Then
|
||||||
|
concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeIVA").ToString.ToDecimal, .Impuesto = "002", .Importe = drr("ImporteIVA").ToString.ToDecimal})
|
||||||
|
' End If
|
||||||
|
|
||||||
|
If drr("ImporteIEPS").ToString.ToDouble > 0 Then
|
||||||
|
concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeIEPS").ToString.ToDecimal, .Impuesto = "003", .Importe = drr("ImporteIEPS").ToString.ToDecimal})
|
||||||
|
End If
|
||||||
|
|
||||||
|
If drr("ImporteRetIVA").ToString.ToDouble > 0 Then 'si hay retenciones
|
||||||
|
concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "R", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeRetIVA").ToString.ToDecimal, .Impuesto = "002", .Importe = drr("ImporteRetIVA").ToString.ToDecimal})
|
||||||
|
End If
|
||||||
|
|
||||||
|
If drr("ImporteRetISR").ToString.ToDouble > 0 Then 'retención de ISR
|
||||||
|
concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "R", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeRetISR").ToString.ToDecimal, .Impuesto = "001", .Importe = drr("ImporteRetISR").ToString.ToDecimal})
|
||||||
|
End If
|
||||||
|
|
||||||
|
Timbre.Conceptos.Add(concepto)
|
||||||
|
i += 1
|
||||||
|
Next
|
||||||
|
Return Timbre
|
||||||
|
End Function
|
||||||
|
#End Region
|
||||||
|
|
||||||
|
|
||||||
|
#Region "G L O B A L - D T"
|
||||||
|
Public Property GlobalTipoCambio(Optional Fecha As Date = MinFecha) As Double
|
||||||
|
Get
|
||||||
|
If GlobalTipoCambio <= 0 Then
|
||||||
|
'sino tiene dato lo recargo por si ya esta insertado
|
||||||
|
If Fecha = MinFecha Then Fecha = Now
|
||||||
|
|
||||||
|
Dim ObjGral As New ClsGenerales
|
||||||
|
If ObjGral.GetTipoCambio(-1, Fecha) AndAlso ObjGral.DtResultados.Rows.Count > 0 Then
|
||||||
|
|
||||||
|
HttpContext.Current.Application("GlobalTipoCambio") = ObjGral.DtResultados.Rows(0)("TipoCambio").ToString.ToDouble
|
||||||
|
Else
|
||||||
|
HttpContext.Current.Application("GlobalTipoCambio") = 0
|
||||||
|
End If
|
||||||
|
ObjGral.Dispose()
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
Return HttpContext.Current.Application("GlobalTipoCambio").ToString.ToDouble
|
||||||
|
End Get
|
||||||
|
Set(value As Double)
|
||||||
|
HttpContext.Current.Application("GlobalTipoCambio") = value
|
||||||
|
End Set
|
||||||
|
|
||||||
|
End Property
|
||||||
|
Property GlobalDTMonedas() As DataTable
|
||||||
|
Get
|
||||||
|
GlobalDTMonedas = DirectCast(HttpContext.Current.Application("GlobalDTMonedas"), DataTable)
|
||||||
|
End Get
|
||||||
|
Set(value As DataTable)
|
||||||
|
HttpContext.Current.Application("GlobalDTMonedas") = value
|
||||||
|
End Set
|
||||||
|
End Property
|
||||||
|
ReadOnly Property GlobalDTPS(CveEmpresa As Integer, Optional CvePS As Integer = -1, Optional SATClavePS As String = "-1", Optional AplicaParaVenta As Integer = -1, Optional Estatus As Integer = -1, Optional Codigo As String = "-1") As DataTable
|
||||||
|
Get
|
||||||
|
Dim ObjPS As New ClsProductosServicios
|
||||||
|
|
||||||
|
If ObjPS.GetPS(CvePS, -1, CveEmpresa, Codigo:=Codigo, SATClavePS:=SATClavePS, pAplicaParaVenta:=AplicaParaVenta, pEstado:=Estatus) Then
|
||||||
|
GlobalDTPS = ObjPS.DtResultados
|
||||||
|
Else
|
||||||
|
GlobalDTPS = Nothing
|
||||||
|
End If
|
||||||
|
|
||||||
|
ObjPS.Dispose()
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
Public Property GlobalDTVtaFormaPago() As DataTable
|
||||||
|
Get
|
||||||
|
GlobalDTVtaFormaPago = DirectCast(HttpContext.Current.Application("GlobalDTVtaFormaPago"), DataTable)
|
||||||
|
End Get
|
||||||
|
Set(value As DataTable)
|
||||||
|
HttpContext.Current.Application("GlobalDTVtaFormaPago") = value
|
||||||
|
End Set
|
||||||
|
End Property
|
||||||
|
Property GlobalDTVtaMetodoPago() As DataTable
|
||||||
|
Get
|
||||||
|
GlobalDTVtaMetodoPago = DirectCast(HttpContext.Current.Application("GlobalDTVtaMetodoPago"), DataTable)
|
||||||
|
End Get
|
||||||
|
Set(value As DataTable)
|
||||||
|
HttpContext.Current.Application("GlobalDTVtaMetodoPago") = value
|
||||||
|
End Set
|
||||||
|
End Property
|
||||||
|
Property GlobalDTSATUsosCFDI(Optional EsPersonaFisica As Integer = -1) As DataTable
|
||||||
|
Get
|
||||||
|
If EsPersonaFisica <> -1 Then
|
||||||
|
Dim Tipo As String = ""
|
||||||
|
If EsPersonaFisica = 1 Then Tipo = "AplicaPersonaFisica = 1" Else Tipo = "AplicaPersonaMoral = 1"
|
||||||
|
|
||||||
|
Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTSATUsosCFDI"), DataTable), Tipo, " UsoCFDIDescripcion", DataViewRowState.CurrentRows)
|
||||||
|
GlobalDTSATUsosCFDI = Dv.ToTable
|
||||||
|
Dv.Dispose()
|
||||||
|
Else
|
||||||
|
GlobalDTSATUsosCFDI = DirectCast(HttpContext.Current.Application("GlobalDTSATUsosCFDI"), DataTable)
|
||||||
|
End If
|
||||||
|
|
||||||
|
End Get
|
||||||
|
Set(ByVal value As DataTable)
|
||||||
|
HttpContext.Current.Application("GlobalDTSATUsosCFDI") = value
|
||||||
|
End Set
|
||||||
|
End Property
|
||||||
|
|
||||||
|
Property GlobalDTMetodosPago() As DataTable
|
||||||
|
Get
|
||||||
|
GlobalDTMetodosPago = DirectCast(HttpContext.Current.Application("GlobalDTMetodosPago"), DataTable)
|
||||||
|
End Get
|
||||||
|
Set(value As DataTable)
|
||||||
|
HttpContext.Current.Application("GlobalDTMetodosPago") = value
|
||||||
|
End Set
|
||||||
|
End Property
|
||||||
|
Public Property GlobalDTSubProyectos(CveProyecto As Integer, Optional CveSubProyecto As Integer = -1, Optional CveEmpresa As Integer = -1, Optional Estatus As Integer = 1) As DataTable
|
||||||
|
Get
|
||||||
|
Dim AppNombre As String = String.Format("GlobalDTSubProyectos-{0}", CveEmpresa)
|
||||||
|
'sino existe, recarga los datos
|
||||||
|
If DirectCast(HttpContext.Current.Application(AppNombre), DataTable) Is Nothing Or (DirectCast(HttpContext.Current.Application(AppNombre), DataTable) IsNot Nothing AndAlso DirectCast(HttpContext.Current.Application(AppNombre), DataTable).Rows.Count = 0) Then
|
||||||
|
Dim P As New ClsSubProyectos
|
||||||
|
If P.GetSubProyectos(CveEmpresa:=CveEmpresa) Then HttpContext.Current.Application(AppNombre) = P.DtResultados
|
||||||
|
P.Dispose()
|
||||||
|
End If
|
||||||
|
|
||||||
|
If CveProyecto <> -1 OrElse CveSubProyecto <> -1 OrElse CveEmpresa <> -1 OrElse Estatus <> -1 Then
|
||||||
|
Dim StrSQL As New StringBuilder
|
||||||
|
If CveProyecto <> -1 Then StrSQL.AppendFormat(" AND CveProyecto = {0}", CveProyecto)
|
||||||
|
If CveSubProyecto <> -1 Then StrSQL.AppendFormat(" AND CveSubProyecto = {0}", CveSubProyecto)
|
||||||
|
If Estatus <> -1 Then StrSQL.AppendFormat(" AND CveEstatus = {0}", Estatus)
|
||||||
|
If CveEmpresa <> -1 Then StrSQL.AppendFormat(" AND CveEmpresa = {0}", CveEmpresa)
|
||||||
|
|
||||||
|
Dim Dv As New DataView(DirectCast(HttpContext.Current.Application(AppNombre), DataTable), StrSQL.ToString.Trim.TrimStart("A"c, "N"c, "D"c), "", DataViewRowState.CurrentRows)
|
||||||
|
GlobalDTSubProyectos = Dv.ToTable
|
||||||
|
Dv.Dispose()
|
||||||
|
|
||||||
|
Else
|
||||||
|
GlobalDTSubProyectos = DirectCast(HttpContext.Current.Application(AppNombre), DataTable)
|
||||||
|
End If
|
||||||
|
|
||||||
|
End Get
|
||||||
|
Set(ByVal value As DataTable)
|
||||||
|
Dim AppNombre As String = String.Format("GlobalDTSubProyectos-{0}", CveEmpresa)
|
||||||
|
HttpContext.Current.Application(AppNombre) = value
|
||||||
|
End Set
|
||||||
|
End Property
|
||||||
|
#End Region
|
||||||
|
End Class
|
||||||
@@ -487,14 +487,14 @@
|
|||||||
</asp:DropDownList>
|
</asp:DropDownList>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row" id="TrPeriodo" runat="server" visible="False">
|
<%-- <div class="row" id="TrPeriodo" runat="server" visible="False">
|
||||||
<label class="col-md-2 truncate">
|
<label class="col-md-2 truncate">
|
||||||
<asp:Label ID="Label5" runat="server" Text="Periodo:"></asp:Label></label><div class="col-md-10">
|
<asp:Label ID="Label5" runat="server" Text="Periodo:"></asp:Label></label><div class="col-md-10">
|
||||||
<asp:DropDownList ID="DdlPeriodo" runat="server" AppendDataBoundItems="True" DataTextField="Nombre" DataValueField="CvePeriodo" Class="table-group-action-input form-control input-inline input-sm select2me" Width="75%">
|
<asp:DropDownList ID="DdlPeriodo" runat="server" AppendDataBoundItems="True" DataTextField="Nombre" DataValueField="CvePeriodo" Class="table-group-action-input form-control input-inline input-sm select2me" Width="75%">
|
||||||
<asp:ListItem Selected="True" Text="Seleccione" Value="-1"></asp:ListItem>
|
<asp:ListItem Selected="True" Text="Seleccione" Value="-1"></asp:ListItem>
|
||||||
</asp:DropDownList>
|
</asp:DropDownList>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>--%>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<label class="col-md-2 truncate">Fecha Inicial:</label>
|
<label class="col-md-2 truncate">Fecha Inicial:</label>
|
||||||
@@ -575,14 +575,6 @@
|
|||||||
<asp:TextBox ID="TxtTotal" runat="server" MaxLength="12" Width="100px"></asp:TextBox><ajax:FilteredTextBoxExtender ID="FilteredTextBoxExtender8" runat="server" TargetControlID="TxtTotal" FilterType="Custom, Numbers" ValidChars=",." BehaviorID="_content_SoloNumeros" />
|
<asp:TextBox ID="TxtTotal" runat="server" MaxLength="12" Width="100px"></asp:TextBox><ajax:FilteredTextBoxExtender ID="FilteredTextBoxExtender8" runat="server" TargetControlID="TxtTotal" FilterType="Custom, Numbers" ValidChars=",." BehaviorID="_content_SoloNumeros" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="row" id="DvObservaciones" runat="server" visible="false">
|
|
||||||
<label class="col-md-2 truncate ">Observación de Facturación:</label>
|
|
||||||
<div class="col-md-10">
|
|
||||||
<asp:TextBox ID="TxtObservaciones" runat="server" Width="400px" TextMode="MultiLine" Rows="2"></asp:TextBox>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -816,12 +808,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="row" style="display: none;">
|
<div class="row" style="display: none;">
|
||||||
<label class="col-md-2 truncate">Importe:</label>
|
<label class="col-md-2 truncate">Importe:</label>
|
||||||
<div class="col-md-10">
|
<div class="col-md-10">
|
||||||
@@ -1933,7 +1919,110 @@
|
|||||||
</asp:GridView>
|
</asp:GridView>
|
||||||
</ContentTemplate>
|
</ContentTemplate>
|
||||||
</ajax:TabPanel>
|
</ajax:TabPanel>
|
||||||
|
<ajax:TabPanel ID="TabFacCiclica" runat="server" HeaderText="Facturación Ciclica">
|
||||||
|
<ContentTemplate>
|
||||||
|
<asp:UpdatePanel ID="UpFacCiclica" runat="server" UpdateMode="Conditional">
|
||||||
|
<ContentTemplate>
|
||||||
|
<br />
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="portlet smmallpadding light bordered">
|
||||||
|
<div class="portlet-title">
|
||||||
|
<div class="tools">
|
||||||
|
<a href="javascript;" data-idchekbox="C_chkexpand" class=" collapse" data-original-title="" title=""></a><span class="hidden">
|
||||||
|
<input id="C_chkexpand" type="checkbox" name="ctl00$C$chkexpand" checked="checked"></span>
|
||||||
|
</div>
|
||||||
|
<div class="caption uppercase" style="position: relative;"><i class="fa fa-info-circle"></i>Datos de Facturación</div>
|
||||||
|
</div>
|
||||||
|
<div class="portlet-body rowpadding">
|
||||||
|
<div class="row">
|
||||||
|
<label class="col-md-3 truncate ">Aplica Facturación Ciclica:</label>
|
||||||
|
<div class="col-md-9">
|
||||||
|
<asp:CheckBox ID="ChkAplicaFacCiclica" AutoPostBack="True" OnCheckedChanged="ChkAplicaFacCiclica_CheckedChanged" runat="server"></asp:CheckBox>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row" id="DivFacCiclica" runat="server" visible="false">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="row">
|
||||||
|
<label class="col-md-3 truncate">
|
||||||
|
<asp:Label ID="Label6" runat="server" Text="Periodo:"></asp:Label></label>
|
||||||
|
<div class="col-md-9">
|
||||||
|
<asp:DropDownList ID="DdlPeriodo" runat="server" AppendDataBoundItems="True" AutoPostBack="true" OnSelectedIndexChanged="DdlPeriodo_SelectedIndexChanged" DataTextField="Nombre" DataValueField="CvePeriodo" Class="table-group-action-input form-control input-inline input-sm select2me" Width="75%">
|
||||||
|
<asp:ListItem Selected="True" Text="Seleccione" Value="-1"></asp:ListItem>
|
||||||
|
</asp:DropDownList>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
<div class="row">
|
||||||
|
<label class="col-md-3 truncate">
|
||||||
|
<asp:Label ID="Label5" runat="server" Text="Dia del mes:"></asp:Label></label>
|
||||||
|
<div class="col-md-9">
|
||||||
|
<asp:DropDownList ID="DdlDiaFact" runat="server" AppendDataBoundItems="True" Class="table-group-action-input form-control input-inline input-sm select2me" Width="75%">
|
||||||
|
<asp:ListItem Selected="True" Text="Seleccione" Value="-1"></asp:ListItem>
|
||||||
|
</asp:DropDownList>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
<div class="row">
|
||||||
|
<label class="col-md-3 truncate ">Facturación Automatica:</label>
|
||||||
|
<div class="col-md-9">
|
||||||
|
<asp:CheckBox ID="ChkFacAutomatica" runat="server"></asp:CheckBox>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
<div class="row">
|
||||||
|
<label class="col-md-3 truncate ">Observación de Facturación:</label>
|
||||||
|
<div class="col-md-9">
|
||||||
|
<asp:TextBox ID="TxtObservaciones" runat="server" Width="400px" TextMode="MultiLine" Rows="2"></asp:TextBox>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="portlet smmallpadding light bordered" id="DivCiclosComerciales" runat="server" visible="false">
|
||||||
|
<div class="portlet-title">
|
||||||
|
<div class="tools">
|
||||||
|
<a href="javascript;" data-idchekbox="C_chkexpand" class=" collapse" data-original-title="" title=""></a><span class="hidden">
|
||||||
|
<input id="C_chkexpand" type="checkbox" name="ctl00$C$chkexpand" checked="checked"></span>
|
||||||
|
</div>
|
||||||
|
<div class="caption uppercase" style="position: relative;"><i class="fa fa-info-circle"></i>Ciclos de facturación</div>
|
||||||
|
</div>
|
||||||
|
<div class="portlet-body rowpadding">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12" align="right">
|
||||||
|
<input type="text" id="TxtFiltraCiclos" class="form-control input-sm" onkeyup="<%= String.Format("FiltrarTabla('TxtFiltraCiclos','{0}')", GvCiclosComerciales.ClientID) %>" style="display: inline-block; margin-right: -20px; width: 150px;" />
|
||||||
|
<a href="javascript:;" onclick="<%= String.Format("FiltrarTabla('TxtFiltraCiclos','{0}')", GvDatosAvance.ClientID) %>" style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"><i class="icon-magnifier"></i></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<asp:GridView ID="GvCiclosComerciales" ClientIDMode="Static" ShowHeader="true" runat="server" AutoGenerateColumns="false" EmptyDataText="No se encontraron documentos." CssClass="table table-striped table-hover Widthall" BorderColor="#D3D3D3" GridLines="None">
|
||||||
|
<Columns>
|
||||||
|
<asp:BoundField HeaderText="Fecha Vencimiento" DataField="FechaVenc" ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Center" DataFormatString="{0:d}" />
|
||||||
|
<asp:BoundField HeaderText="Fue Facturado" DataField="FueFacturadoTexto" ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Center" />
|
||||||
|
<%-- <asp:BoundField HeaderText="Periodo" DataField="Periodo" ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Center" />--%>
|
||||||
|
<asp:HyperLinkField HeaderText="Serie-Folio" DataTextField="VentaFacturada" Target="_blank" ItemStyle-Width="10%" ItemStyle-CssClass="Texto Izquierda" DataNavigateUrlFields="CveVentaFacturada" DataNavigateUrlFormatString="/Ventas/Ventas.aspx?CveVenta={0}" />
|
||||||
|
<asp:BoundField HeaderText="Moneda" DataField="MonedaVenta" ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Center" />
|
||||||
|
<asp:BoundField HeaderText="Fecha Facturación" DataField="FechaIngVenta" ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Center" DataFormatString="{0:d}" />
|
||||||
|
<%-- <asp:BoundField HeaderText="SubTotal" DataField="SubTotalVenta" ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:N2}" />
|
||||||
|
<asp:BoundField HeaderText="IVA" DataField="IVAVenta" ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:N2}" />
|
||||||
|
<asp:BoundField HeaderText="IEPS" DataField="IVAVenta" ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:N2}" />--%>
|
||||||
|
<asp:BoundField HeaderText="Total" DataField="TotalVenta" ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:N2}" />
|
||||||
|
</Columns>
|
||||||
|
</asp:GridView>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ContentTemplate>
|
||||||
|
</asp:UpdatePanel>
|
||||||
|
</ContentTemplate>
|
||||||
|
</ajax:TabPanel>
|
||||||
<ajax:TabPanel ID="TabSistema" runat="server" HeaderText="Sistema">
|
<ajax:TabPanel ID="TabSistema" runat="server" HeaderText="Sistema">
|
||||||
<ContentTemplate>
|
<ContentTemplate>
|
||||||
|
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ Partial Class Contratos_Default
|
|||||||
'TxtArchivo.Visible = True
|
'TxtArchivo.Visible = True
|
||||||
|
|
||||||
CargaDatos()
|
CargaDatos()
|
||||||
|
CargaCiclosComerciales()
|
||||||
CargaDatosAvance()
|
CargaDatosAvance()
|
||||||
CargaDatosAvancePorDocumento()
|
CargaDatosAvancePorDocumento()
|
||||||
CargaInventarios()
|
CargaInventarios()
|
||||||
@@ -812,9 +812,12 @@ Partial Class Contratos_Default
|
|||||||
CargaContratista()
|
CargaContratista()
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
CargaPeriodos()
|
||||||
|
DdlPeriodo_SelectedIndexChanged(DdlPeriodo, EventArgs.Empty)
|
||||||
|
|
||||||
If DdlTipoContrato.SelectedValue = "14" Then
|
If DdlTipoContrato.SelectedValue = "14" Then
|
||||||
TrCtaEquipo.Visible = True
|
TrCtaEquipo.Visible = True
|
||||||
TrPeriodo.Visible = True
|
'TrPeriodo.Visible = True
|
||||||
RFVEstatus.ValidationGroup = ""
|
RFVEstatus.ValidationGroup = ""
|
||||||
RequiredFieldValidator1.ValidationGroup = ""
|
RequiredFieldValidator1.ValidationGroup = ""
|
||||||
DvMin.Visible = True
|
DvMin.Visible = True
|
||||||
@@ -824,34 +827,31 @@ Partial Class Contratos_Default
|
|||||||
RowEstatus.Visible = False
|
RowEstatus.Visible = False
|
||||||
RowPorcentajeComision.Visible = False
|
RowPorcentajeComision.Visible = False
|
||||||
dvAddendum.Visible = False
|
dvAddendum.Visible = False
|
||||||
CargaPeriodos()
|
|
||||||
CargaPlantillas()
|
CargaPlantillas()
|
||||||
TrContratoPlantilla.Visible = True
|
TrContratoPlantilla.Visible = True
|
||||||
TabPres.HeaderText = "Partidas"
|
TabPres.HeaderText = "Partidas"
|
||||||
Else
|
|
||||||
DtPeriodo = Nothing
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
|
||||||
If DdlTipoContrato.SelectedValue = "25" Then
|
'If DdlTipoContrato.SelectedValue = "25" Then
|
||||||
trLicitacion.Visible = False
|
' trLicitacion.Visible = False
|
||||||
divResponsable.Visible = False
|
' divResponsable.Visible = False
|
||||||
TrPeriodo.Visible = True
|
' 'TrPeriodo.Visible = True
|
||||||
CargaPeriodos()
|
' trIva.Visible = False
|
||||||
trIva.Visible = False
|
' trAnticipo.Visible = False
|
||||||
trAnticipo.Visible = False
|
' trAmortizacion.Visible = False
|
||||||
trAmortizacion.Visible = False
|
' trPorGarantia.Visible = False
|
||||||
trPorGarantia.Visible = False
|
' DvMin.Visible = False
|
||||||
DvMin.Visible = False
|
' RowFlexible.Visible = False
|
||||||
RowFlexible.Visible = False
|
' RowPorcentajeComision.Visible = False
|
||||||
RowPorcentajeComision.Visible = False
|
' DvMax.Visible = False
|
||||||
DvMax.Visible = False
|
' DvTotal.Visible = False
|
||||||
DvTotal.Visible = False
|
' RowEstatus.Visible = False
|
||||||
RowEstatus.Visible = False
|
' TabPres.HeaderText = "Partidas"
|
||||||
TabPres.HeaderText = "Partidas"
|
' DdlSubProyectoContrato.AutoPostBack = True
|
||||||
DdlSubProyectoContrato.AutoPostBack = True
|
' 'DvObservaciones.Visible = True
|
||||||
DvObservaciones.Visible = True
|
'End If
|
||||||
End If
|
|
||||||
|
|
||||||
Dim CveTipoContrato = DdlTipoContrato.SelectedValue
|
Dim CveTipoContrato = DdlTipoContrato.SelectedValue
|
||||||
|
|
||||||
@@ -935,10 +935,11 @@ Partial Class Contratos_Default
|
|||||||
CargaContratoPadre()
|
CargaContratoPadre()
|
||||||
CargaContratoAddendum()
|
CargaContratoAddendum()
|
||||||
|
|
||||||
|
|
||||||
If ObjContratos.DtResultados.Rows(0)("CveContratoTipo").ToString.ToEntero = 14 Then
|
If ObjContratos.DtResultados.Rows(0)("CveContratoTipo").ToString.ToEntero = 14 Then
|
||||||
CargaPeriodos()
|
|
||||||
TrCtaEquipo.Visible = True
|
TrCtaEquipo.Visible = True
|
||||||
TrPeriodo.Visible = True
|
'TrPeriodo.Visible = True
|
||||||
RFVEstatus.ValidationGroup = ""
|
RFVEstatus.ValidationGroup = ""
|
||||||
RequiredFieldValidator1.ValidationGroup = ""
|
RequiredFieldValidator1.ValidationGroup = ""
|
||||||
DvMin.Visible = True
|
DvMin.Visible = True
|
||||||
@@ -957,54 +958,69 @@ Partial Class Contratos_Default
|
|||||||
TabPres.HeaderText = "Partidas"
|
TabPres.HeaderText = "Partidas"
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If ObjContratos.DtResultados.Rows(0)("CveContratoTipo").ToString.ToEntero = 25 Then
|
'If ObjContratos.DtResultados.Rows(0)("CveContratoTipo").ToString.ToEntero = 25 Then
|
||||||
trLicitacion.Visible = False
|
' trLicitacion.Visible = False
|
||||||
divResponsable.Visible = False
|
' divResponsable.Visible = False
|
||||||
TrPeriodo.Visible = True
|
' 'TrPeriodo.Visible = True
|
||||||
CargaPeriodos()
|
' CargaPeriodos()
|
||||||
trIva.Visible = False
|
' trIva.Visible = False
|
||||||
trAnticipo.Visible = False
|
' trAnticipo.Visible = False
|
||||||
trAmortizacion.Visible = False
|
' trAmortizacion.Visible = False
|
||||||
trPorGarantia.Visible = False
|
' trPorGarantia.Visible = False
|
||||||
DvMin.Visible = False
|
' DvMin.Visible = False
|
||||||
DvMax.Visible = False
|
' DvMax.Visible = False
|
||||||
DvTotal.Visible = False
|
' DvTotal.Visible = False
|
||||||
TabPVInsumos.Visible = False
|
' TabPVInsumos.Visible = False
|
||||||
RowEstatus.Visible = False
|
' RowEstatus.Visible = False
|
||||||
TabPres.HeaderText = "Partidas"
|
' TabPres.HeaderText = "Partidas"
|
||||||
thOcCliente.Style.Add("display", "none")
|
' thOcCliente.Style.Add("display", "none")
|
||||||
tdOcCliente.Style.Add("display", "none")
|
' tdOcCliente.Style.Add("display", "none")
|
||||||
thNoIdentificacionv.Style.Add("display", "none")
|
' thNoIdentificacionv.Style.Add("display", "none")
|
||||||
thLimitar.Style.Add("display", "none")
|
' thLimitar.Style.Add("display", "none")
|
||||||
tdLimitar2.Style.Add("display", "none")
|
' tdLimitar2.Style.Add("display", "none")
|
||||||
tdNoIdentificacionv.Style.Add("display", "none")
|
' tdNoIdentificacionv.Style.Add("display", "none")
|
||||||
RowFlexible.Visible = False
|
' RowFlexible.Visible = False
|
||||||
TableDatosCabecera.Visible = False
|
' TableDatosCabecera.Visible = False
|
||||||
TabAvanveDocumento.Visible = False
|
' TabAvanveDocumento.Visible = False
|
||||||
TabSistema.Visible = False
|
' TabSistema.Visible = False
|
||||||
RowPorcentajeComision.Visible = False
|
' RowPorcentajeComision.Visible = False
|
||||||
TabContratosGastos.Visible = False
|
' TabContratosGastos.Visible = False
|
||||||
tdCveInterna.Text = ""
|
' tdCveInterna.Text = ""
|
||||||
tdLimitar.Text = ""
|
' tdLimitar.Text = ""
|
||||||
tdOC.Text = ""
|
' tdOC.Text = ""
|
||||||
THAvance.Visible = False
|
' THAvance.Visible = False
|
||||||
THAvance.Style.Add("display", "none")
|
' THAvance.Style.Add("display", "none")
|
||||||
TDAvance.Style.Add("display", "none")
|
' TDAvance.Style.Add("display", "none")
|
||||||
TxtOCInterna.Visible = False
|
' TxtOCInterna.Visible = False
|
||||||
TxtNoIdentificacionv.Visible = False
|
' TxtNoIdentificacionv.Visible = False
|
||||||
ChkLimitarVenta.Visible = False
|
' ChkLimitarVenta.Visible = False
|
||||||
DvObservaciones.Visible = True
|
' 'DvObservaciones.Visible = True
|
||||||
TDObservacion.Visible = True
|
' TDObservacion.Visible = True
|
||||||
tdObservaciones.Visible = True
|
' tdObservaciones.Visible = True
|
||||||
TxtObservaciones.Text = ObjContratos.DtResultados.Rows(0)("Observaciones").ToString
|
' TxtObservaciones.Text = ObjContratos.DtResultados.Rows(0)("Observaciones").ToString
|
||||||
Gv.Columns(6).Visible = True
|
' Gv.Columns(6).Visible = True
|
||||||
DdlPeriodo.SelectedValueExist(ObjContratos.DtResultados.Rows(0)("CvePeriodo").ToString)
|
' DdlPeriodo.SelectedValueExist(ObjContratos.DtResultados.Rows(0)("CvePeriodo").ToString)
|
||||||
End If
|
'End If
|
||||||
|
|
||||||
If ObjContratos.DtResultados.Rows(0)("CveVendedor").ToString.ToEntero > 0 Then
|
If ObjContratos.DtResultados.Rows(0)("CveVendedor").ToString.ToEntero > 0 Then
|
||||||
DdlVendedor.SelectedValueExist(ObjContratos.DtResultados.Rows(0)("CveVendedor"))
|
DdlVendedor.SelectedValueExist(ObjContratos.DtResultados.Rows(0)("CveVendedor"))
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
ChkAplicaFacCiclica.Checked = CBool(ObjContratos.DtResultados.Rows(0)("FacturacionCicilica"))
|
||||||
|
|
||||||
|
If ChkAplicaFacCiclica.Checked Then
|
||||||
|
CargaPeriodos()
|
||||||
|
|
||||||
|
ChkFacAutomatica.Checked = CBool(ObjContratos.DtResultados.Rows(0)("FacturacionCiclicaAutomatico"))
|
||||||
|
|
||||||
|
DdlPeriodo.SelectedValueExist(ObjContratos.DtResultados.Rows(0)("CvePeriodo"))
|
||||||
|
DdlPeriodo_SelectedIndexChanged(DdlPeriodo, EventArgs.Empty)
|
||||||
|
|
||||||
|
DdlDiaFact.SelectedValueExist(ObjContratos.DtResultados.Rows(0)("DiaMesFacturacion").ToString())
|
||||||
|
TxtObservaciones.Text = ObjContratos.DtResultados.Rows(0)("Observaciones").ToString
|
||||||
|
ChkAplicaFacCiclica_CheckedChanged(ChkAplicaFacCiclica, EventArgs.Empty)
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
If (DdlAlmacenDestino.Items.FindByValue(ObjContratos.CveAlmacen.ToString()) Is Nothing) Then
|
If (DdlAlmacenDestino.Items.FindByValue(ObjContratos.CveAlmacen.ToString()) Is Nothing) Then
|
||||||
Dim dr As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", ObjContratos.CveAlmacen))
|
Dim dr As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", ObjContratos.CveAlmacen))
|
||||||
@@ -1224,10 +1240,10 @@ Partial Class Contratos_Default
|
|||||||
Maximo = txtMaximo.Text.ToDouble
|
Maximo = txtMaximo.Text.ToDouble
|
||||||
Total = TxtTotal.Text.ToDouble
|
Total = TxtTotal.Text.ToDouble
|
||||||
|
|
||||||
If DdlTipoContrato.SelectedValue = "25" AndAlso DdlPeriodo.SelectedValue.ToEntero() <= 0 Then
|
'If DdlTipoContrato.SelectedValue = "25" AndAlso DdlPeriodo.SelectedValue.ToEntero() <= 0 Then
|
||||||
Alert("Debe seleccionar el periodo de facturación.", TipoMensaje.MsgAdvertencia)
|
' Alert("Debe seleccionar el periodo de facturación.", TipoMensaje.MsgAdvertencia)
|
||||||
Exit Sub
|
' Exit Sub
|
||||||
End If
|
'End If
|
||||||
|
|
||||||
If DdlMoneda.SelectedIndex > 0 Then
|
If DdlMoneda.SelectedIndex > 0 Then
|
||||||
If TxtTipoCambio.Text.Trim.Length = 0 Or TxtTipoCambio.Text.Trim.ToDouble = 0.0 Then
|
If TxtTipoCambio.Text.Trim.Length = 0 Or TxtTipoCambio.Text.Trim.ToDouble = 0.0 Then
|
||||||
@@ -1246,159 +1262,35 @@ Partial Class Contratos_Default
|
|||||||
Dim ObjContratos As New ClsContratos
|
Dim ObjContratos As New ClsContratos
|
||||||
Dim ObjInventarios As New ClsInventarios(ObjContratos.IniciaTransacSQL)
|
Dim ObjInventarios As New ClsInventarios(ObjContratos.IniciaTransacSQL)
|
||||||
|
|
||||||
'Crear Contrato
|
Try
|
||||||
If Not CveContrato > 0 Then
|
'Crear Contrato
|
||||||
|
If Not CveContrato > 0 Then
|
||||||
|
|
||||||
CveContrato = ObjContratos.AddContratos(TxtNumeroContrato.Text, TxtDescripcionContrato.Text, TxtNumeroLicitacion.Text.Trim, DdlContratista.SelectedValue.ToEntero, DdlCliente.SelectedValue.ToEntero, -1, TxtFechaInicial.Text.ToDate, TxtFechaFinal.Text.ToDate,
|
CveContrato = ObjContratos.AddContratos(TxtNumeroContrato.Text, TxtDescripcionContrato.Text, TxtNumeroLicitacion.Text.Trim, DdlContratista.SelectedValue.ToEntero, DdlCliente.SelectedValue.ToEntero, -1, TxtFechaInicial.Text.ToDate, TxtFechaFinal.Text.ToDate,
|
||||||
TxtUbicacion.Text, TxtResponsable.Text, DdlSubProyectoContrato.SelectedValue.ToEntero, TxtPorIVA.Text.ToDouble, TxtPorAnticipo.Text.ToDouble, TxtPorAmortizacionAnticipo.Text.ToDouble,
|
TxtUbicacion.Text, TxtResponsable.Text, DdlSubProyectoContrato.SelectedValue.ToEntero, TxtPorIVA.Text.ToDouble, TxtPorAnticipo.Text.ToDouble, TxtPorAmortizacionAnticipo.Text.ToDouble,
|
||||||
TxtPorGarantia.Text.ToDouble, "." & Session("FileExtension").ToString, "", DdlContratoPadre.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, False, Minimo, Maximo, Total,
|
TxtPorGarantia.Text.ToDouble, "." & Session("FileExtension").ToString, "", DdlContratoPadre.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, False, Minimo, Maximo, Total,
|
||||||
DdlMoneda.SelectedValue.ToEntero, ModalidadDetalle, If(DdlTipoContrato.SelectedValue.ToEntero = 25 OrElse UsuarioActual.Empresa.CvePlataforma = 3, 1, DdlEstatus.SelectedValue.ToEntero), TipoContrato,
|
DdlMoneda.SelectedValue.ToEntero, ModalidadDetalle, If(DdlTipoContrato.SelectedValue.ToEntero = 25 OrElse UsuarioActual.Empresa.CvePlataforma = 3, 1, DdlEstatus.SelectedValue.ToEntero), TipoContrato,
|
||||||
TxtTipoCambio.Text.ToDouble, CveSucursalCliente:=DdlSucursalCliente.SelectedValue.ToEntero, CveAlmacenOrigen:=DdlAlmacenOrigen.SelectedValue.ToEntero, CveAlmacenDestino:=DdlAlmacenDestino.SelectedValue.ToEntero,
|
TxtTipoCambio.Text.ToDouble, CveSucursalCliente:=DdlSucursalCliente.SelectedValue.ToEntero, CveAlmacenOrigen:=DdlAlmacenOrigen.SelectedValue.ToEntero, CveAlmacenDestino:=DdlAlmacenDestino.SelectedValue.ToEntero,
|
||||||
PorcentajeComision:=TxtPorcentajeComision.Text.ToEntero, TipoGarantia:=DdlTipoGarantia.SelectedValue.ToEntero, Folio:=TxtFolio.Text.ToEntero, FechaVenc:=txtFechaVenc.Text.ToDate, EstatusFianza:=DdlEstatusFianza.SelectedValue.ToEntero,
|
PorcentajeComision:=TxtPorcentajeComision.Text.ToEntero, TipoGarantia:=DdlTipoGarantia.SelectedValue.ToEntero, Folio:=TxtFolio.Text.ToEntero, FechaVenc:=txtFechaVenc.Text.ToDate, EstatusFianza:=DdlEstatusFianza.SelectedValue.ToEntero,
|
||||||
CvePeriodo:=DdlPeriodo.SelectedValue.ToEntero, CveCuentaEquipo:=DdlCuentaEquipo.SelectedValue.ToEntero, CveContratoPlantilla:=DdlPlantillaContrato.SelectedValue.ToEntero, CveVendedor:=DdlVendedor.SelectedValue.ToEntero,
|
CvePeriodo:=DdlPeriodo.SelectedValue.ToEntero, CveCuentaEquipo:=DdlCuentaEquipo.SelectedValue.ToEntero, CveContratoPlantilla:=DdlPlantillaContrato.SelectedValue.ToEntero, CveVendedor:=DdlVendedor.SelectedValue.ToEntero,
|
||||||
Observaciones:=TxtObservaciones.Text, CveDireccionEnvio:=DdlClienteDireccionEnvio.SelectedValue.ToEntero, AplicaImpuestosLocales:=ChkImpuestosLocales.Checked, CorreoNotificacionPedDev:=TxtCorreoNotificacion.Text.Trim())
|
Observaciones:=TxtObservaciones.Text, CveDireccionEnvio:=DdlClienteDireccionEnvio.SelectedValue.ToEntero, AplicaImpuestosLocales:=ChkImpuestosLocales.Checked, CorreoNotificacionPedDev:=TxtCorreoNotificacion.Text.Trim(),
|
||||||
|
FacturacionCicilica:=ChkAplicaFacCiclica.Checked, FacturacionCiclicaAutomatico:=ChkFacAutomatica.Checked, DiaMesFacturacion:=DdlDiaFact.SelectedValue.ToEntero())
|
||||||
|
|
||||||
TieneError = Not GuardaFianzas(ObjContratos)
|
|
||||||
|
|
||||||
|
|
||||||
If CveContrato > 0 AndAlso Not TieneError Then
|
|
||||||
'Renombrar archivo
|
|
||||||
If ViewState("extencion") IsNot Nothing Then
|
|
||||||
If ViewState("FUrl").ToString.Length > 0 AndAlso ViewState("extencion").ToString.Length > 0 Then
|
|
||||||
If Not Directory.Exists(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & UsuarioActual.CveEmpresa & "\Contratos") Then
|
|
||||||
Directory.CreateDirectory(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & UsuarioActual.CveEmpresa & "\Contratos")
|
|
||||||
End If
|
|
||||||
Ruta = ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & UsuarioActual.CveEmpresa & "\Contratos\"
|
|
||||||
|
|
||||||
'ViewState("extencion") = FileExtension
|
|
||||||
'ViewState("FUrl") = Path.Combine(UsuarioActual.Empresa.Ruta, "Contratos", "Temp", ViewState("FName").ToString)
|
|
||||||
Try
|
|
||||||
If File.Exists(String.Format("{0}{1}.{2}", Ruta, CveContrato.ToString, ViewState("extencion").ToString)) Then
|
|
||||||
File.Delete(String.Format("{0}{1}.{2}", Ruta, CveContrato.ToString, ViewState("extencion").ToString))
|
|
||||||
End If
|
|
||||||
System.IO.File.Move(ViewState("FUrl").ToString, String.Format("{0}{1}.{2}", Ruta, CveContrato.ToString, ViewState("extencion").ToString))
|
|
||||||
Catch ex As Exception
|
|
||||||
|
|
||||||
End Try
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
If UsuarioActual.Empresa.CvePlataforma = 3 AndAlso DdlTipoContrato.SelectedValue = "14" Then
|
|
||||||
Dim FechaI As DateTime = TxtFechaInicial.Text.ToDateTime
|
|
||||||
Dim FechaF As DateTime = TxtFechaFinal.Text.ToDateTime
|
|
||||||
Dim Periodo As Integer = DtPeriodo.FiltraParametros($"CvePeriodo = {DdlPeriodo.SelectedValue.ToEntero}").Rows(0)("Dias").ToString.ToEntero
|
|
||||||
Dim VigenciaEnDias As Double = DateDiff(DateInterval.Day, FechaI, FechaF)
|
|
||||||
Dim CiclosComerciales As Integer = Math.Round(VigenciaEnDias / Periodo).ToEntero
|
|
||||||
For Ciclo As Integer = 1 To CiclosComerciales
|
|
||||||
If Not ObjContratos.CicloComercialAdd(CveContrato, -1, DdlCliente.SelectedValue.ToEntero, False, -1, 1, UsuarioActual.CveEmpresa, FechaI.AddDays(Periodo * Ciclo)) Then TieneError = True : Exit For
|
|
||||||
Next
|
|
||||||
ElseIf DdlTipoContrato.SelectedValue = "25" Then
|
|
||||||
Dim FechaI As DateTime = TxtFechaInicial.Text.ToDateTime
|
|
||||||
Dim FechaF As DateTime = TxtFechaFinal.Text.ToDateTime
|
|
||||||
If FechaI >= DateTime.Today Then
|
|
||||||
If Not ObjContratos.CicloComercialAdd(CveContrato, -1, DdlCliente.SelectedValue.ToEntero, False, -1, 1, UsuarioActual.CveEmpresa, FechaI) Then TieneError = True
|
|
||||||
End If
|
|
||||||
Dim Periodo As Integer = DtPeriodo.FiltroPrimeroValor("Meses", $"CvePeriodo = {DdlPeriodo.SelectedValue.ToEntero}").ToEntero
|
|
||||||
Dim VigenciaMeses As Double = DateDiff(DateInterval.Month, FechaI, FechaF)
|
|
||||||
Dim CiclosComerciales As Integer = Math.Ceiling(VigenciaMeses / Periodo).ToEntero
|
|
||||||
For Ciclo As Integer = 1 To CiclosComerciales
|
|
||||||
If Not ObjContratos.CicloComercialAdd(CveContrato, -1, DdlCliente.SelectedValue.ToEntero, False, -1, 1, UsuarioActual.CveEmpresa, If(FechaI.AddMonths(Periodo * Ciclo) > FechaF, FechaF, FechaI.AddMonths(Periodo * Ciclo))) Then TieneError = True : Exit For
|
|
||||||
Next
|
|
||||||
End If
|
|
||||||
|
|
||||||
If TxtNumeroContrato.Text = FolioSugerido Then
|
|
||||||
Dim ObjFolios As New ClsGralFolios
|
|
||||||
If Not ObjFolios.UpdateFolioActual(DdlSubProyectoContrato.SelectedValue.ToEntero, "Con", True, UsuarioActual.CveEmpresa) Then
|
|
||||||
TieneError = True
|
|
||||||
End If
|
|
||||||
ObjFolios.Dispose()
|
|
||||||
End If
|
|
||||||
|
|
||||||
If ChkImpuestosLocales.Checked Then
|
|
||||||
Dim count As Integer = 0
|
|
||||||
|
|
||||||
For Each GVR As GridViewRow In GvImpuestosLocales.Rows
|
|
||||||
If GVR.FCCheckBox("ChkDeduccion").Checked Then
|
|
||||||
count = count + 1
|
|
||||||
ObjContratos.AddContratoImpuestosLocales(CveContrato, GVR.DataKey("CveImpuestoLocal").ToEntero)
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
|
|
||||||
If count = 0 Then
|
|
||||||
Alert("Debe seleccionar un Impuesto Local", TipoMensaje.MsgAdvertencia)
|
|
||||||
TieneError = True
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
Else
|
|
||||||
TieneError = True
|
|
||||||
End If
|
|
||||||
|
|
||||||
Else
|
|
||||||
Modificado = True
|
|
||||||
|
|
||||||
Dim ArchivoUpdate As String = "-1"
|
|
||||||
|
|
||||||
If Session("FileExtension").ToString <> "" Then
|
|
||||||
ArchivoUpdate = "." & Session("FileExtension").ToString
|
|
||||||
Else
|
|
||||||
|
|
||||||
End If
|
|
||||||
|
|
||||||
If ObjContratos.UpdateContratos(CveContrato, TxtNumeroContrato.Text, TxtDescripcionContrato.Text, TxtNumeroLicitacion.Text.Trim, DdlContratista.SelectedValue.ToEntero, DdlCliente.SelectedValue.ToEntero, -1, TxtFechaInicial.Text.ToDate, TxtFechaFinal.Text.ToDate,
|
|
||||||
TxtUbicacion.Text, TxtResponsable.Text, DdlSubProyectoContrato.SelectedValue.ToEntero, TxtPorIVA.Text.ToDouble, TxtPorAnticipo.Text.ToDouble, TxtPorAmortizacionAnticipo.Text.ToDouble,
|
|
||||||
TxtPorGarantia.Text.ToDouble, ArchivoUpdate, "", DdlContratoPadre.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, False, Minimo, Maximo, Total, DdlMoneda.SelectedValue.ToEntero,
|
|
||||||
ModalidadDetalle, If(UsuarioActual.Empresa.CvePlataforma = 3 OrElse CveTipoContrato = 25, 1, DdlEstatus.SelectedValue.ToEntero), TipoContrato, TxtTipoCambio.Text.ToDouble, CveSucursalCliente:=DdlSucursalCliente.SelectedValue.ToEntero,
|
|
||||||
CveAlmacenOrigen:=DdlAlmacenOrigen.SelectedValue.ToEntero, CveAlmacenDestino:=DdlAlmacenDestino.SelectedValue.ToEntero, PorcentajeComision:=TxtPorcentajeComision.Text.ToEntero,
|
|
||||||
TipoGarantia:=DdlTipoGarantia.SelectedValue.ToEntero, Folio:=TxtFolio.Text.ToEntero, FechaVenc:=txtFechaVenc.Text.ToDate, EstatusFianza:=DdlEstatusFianza.SelectedValue.ToEntero, CveContratoPlantilla:=DdlPlantillaContrato.SelectedValue.ToEntero,
|
|
||||||
CveCuentaEquipo:=DdlCuentaEquipo.SelectedValue.ToEntero, CveVendedor:=DdlVendedor.SelectedValue.ToEntero, Observaciones:=TxtObservaciones.Text, CveDireccionEnvio:=DdlClienteDireccionEnvio.SelectedValue.ToEntero, AplicaImpuestosLocales:=ChkImpuestosLocales.Checked,
|
|
||||||
CorreoNotificacionPedDev:=TxtCorreoNotificacion.Text.Trim()) Then
|
|
||||||
|
|
||||||
|
|
||||||
TieneError = Not GuardaFianzas(ObjContratos)
|
TieneError = Not GuardaFianzas(ObjContratos)
|
||||||
|
|
||||||
'Renombrar archivo
|
|
||||||
If Not TieneError Then
|
|
||||||
|
|
||||||
If UsuarioActual.Empresa.CvePlataforma = 3 AndAlso DdlTipoContrato.SelectedValue = "14" Then
|
|
||||||
Dim FechaIN As DateTime = TxtFechaInicial.Text.ToDateTime
|
|
||||||
Dim FechaFN As DateTime = TxtFechaFinal.Text.ToDateTime
|
|
||||||
Dim Periodo As Integer = DtPeriodo.FiltraParametros($"CvePeriodo = {DdlPeriodo.SelectedValue.ToEntero}").Rows(0)("Dias").ToString.ToEntero
|
|
||||||
Dim VigenciaEnDias As Double = DateDiff(DateInterval.Day, FechaI, FechaF)
|
|
||||||
Dim CiclosComerciales As Integer = Math.Round(VigenciaEnDias / Periodo).ToEntero
|
|
||||||
For Ciclo As Integer = 1 To CiclosComerciales
|
|
||||||
If Not ObjContratos.CicloComercialAdd(CveContrato, -1, DdlCliente.SelectedValue.ToEntero, False, -1, 1, UsuarioActual.CveEmpresa, FechaI.AddDays(Periodo * Ciclo)) Then TieneError = True : Exit For
|
|
||||||
Next
|
|
||||||
ElseIf CveTipoContrato = 25 Then
|
|
||||||
Dim FechaIN As DateTime = TxtFechaInicial.Text.ToDateTime
|
|
||||||
Dim FechaFN As DateTime = TxtFechaFinal.Text.ToDateTime
|
|
||||||
If FechaFN <> FechaF OrElse FechaI <> FechaIN Then
|
|
||||||
If Not ObjContratos.CicloComercialDelete(CveContrato, False, UsuarioActual.CveEmpresa) Then
|
|
||||||
TieneError = True
|
|
||||||
End If
|
|
||||||
If Not TieneError Then
|
|
||||||
If FechaIN >= DateTime.Today Then
|
|
||||||
If Not ObjContratos.CicloComercialAdd(CveContrato, -1, DdlCliente.SelectedValue.ToEntero, False, -1, 1, UsuarioActual.CveEmpresa, FechaIN) Then TieneError = True
|
|
||||||
End If
|
|
||||||
Dim Periodo As Integer = DtPeriodo.FiltroPrimeroValor("Meses", $"CvePeriodo = {DdlPeriodo.SelectedValue.ToEntero}").ToEntero
|
|
||||||
Dim VigenciaMeses As Double = DateDiff(DateInterval.Month, FechaI, FechaF)
|
|
||||||
Dim CiclosComerciales As Integer = Math.Ceiling(VigenciaMeses / Periodo).ToEntero
|
|
||||||
For Ciclo As Integer = 1 To CiclosComerciales
|
|
||||||
If Not ObjContratos.CicloComercialAdd(CveContrato, -1, DdlCliente.SelectedValue.ToEntero, False, -1, 1, UsuarioActual.CveEmpresa, If(FechaIN.AddMonths(Periodo * Ciclo) > FechaFN, FechaFN, FechaIN.AddMonths(Periodo * Ciclo))) Then TieneError = True : Exit For
|
|
||||||
Next
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
|
If CveContrato > 0 AndAlso Not TieneError Then
|
||||||
|
'Renombrar archivo
|
||||||
If ViewState("extencion") IsNot Nothing Then
|
If ViewState("extencion") IsNot Nothing Then
|
||||||
|
|
||||||
If ViewState("FUrl").ToString.Length > 0 AndAlso ViewState("extencion").ToString.Length > 0 Then
|
If ViewState("FUrl").ToString.Length > 0 AndAlso ViewState("extencion").ToString.Length > 0 Then
|
||||||
If Not Directory.Exists(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & UsuarioActual.CveEmpresa & "\Contratos") Then
|
If Not Directory.Exists(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & UsuarioActual.CveEmpresa & "\Contratos") Then
|
||||||
Directory.CreateDirectory(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & UsuarioActual.CveEmpresa & "\Contratos")
|
Directory.CreateDirectory(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & UsuarioActual.CveEmpresa & "\Contratos")
|
||||||
End If
|
End If
|
||||||
Ruta = ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & UsuarioActual.CveEmpresa & "\Contratos\"
|
Ruta = ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & UsuarioActual.CveEmpresa & "\Contratos\"
|
||||||
|
|
||||||
|
'ViewState("extencion") = FileExtension
|
||||||
|
'ViewState("FUrl") = Path.Combine(UsuarioActual.Empresa.Ruta, "Contratos", "Temp", ViewState("FName").ToString)
|
||||||
Try
|
Try
|
||||||
If File.Exists(String.Format("{0}{1}.{2}", Ruta, CveContrato.ToString, ViewState("extencion").ToString)) Then
|
If File.Exists(String.Format("{0}{1}.{2}", Ruta, CveContrato.ToString, ViewState("extencion").ToString)) Then
|
||||||
File.Delete(String.Format("{0}{1}.{2}", Ruta, CveContrato.ToString, ViewState("extencion").ToString))
|
File.Delete(String.Format("{0}{1}.{2}", Ruta, CveContrato.ToString, ViewState("extencion").ToString))
|
||||||
@@ -1407,13 +1299,34 @@ Partial Class Contratos_Default
|
|||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
|
|
||||||
End Try
|
End Try
|
||||||
' System.IO.File.Move(Archivo, String.Format("{0}{1}{2}", Ruta, CveContrato.ToString, Extension))
|
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
'If UsuarioActual.Empresa.CvePlataforma = 3 AndAlso DdlTipoContrato.SelectedValue = "14" Then
|
||||||
|
' Dim FechaI As DateTime = TxtFechaInicial.Text.ToDateTime
|
||||||
|
' Dim FechaF As DateTime = TxtFechaFinal.Text.ToDateTime
|
||||||
|
' Dim Periodo As Integer = DtPeriodo.FiltraParametros($"CvePeriodo = {DdlPeriodo.SelectedValue.ToEntero}").Rows(0)("Dias").ToString.ToEntero
|
||||||
|
' Dim VigenciaEnDias As Double = DateDiff(DateInterval.Day, FechaI, FechaF)
|
||||||
|
' Dim CiclosComerciales As Integer = Math.Round(VigenciaEnDias / Periodo).ToEntero
|
||||||
|
' For Ciclo As Integer = 1 To CiclosComerciales
|
||||||
|
' If Not ObjContratos.CicloComercialAdd(CveContrato, -1, DdlCliente.SelectedValue.ToEntero, False, -1, 1, UsuarioActual.CveEmpresa, FechaI.AddDays(Periodo * Ciclo)) Then TieneError = True : Exit For
|
||||||
|
' Next
|
||||||
|
'End If
|
||||||
|
|
||||||
|
If ChkAplicaFacCiclica.Checked Then
|
||||||
|
TieneError = Not GenerarCiclosComerciales(CveContrato, False, ObjContratos)
|
||||||
|
End If
|
||||||
|
|
||||||
|
If TxtNumeroContrato.Text = FolioSugerido Then
|
||||||
|
Dim ObjFolios As New ClsGralFolios
|
||||||
|
If Not ObjFolios.UpdateFolioActual(DdlSubProyectoContrato.SelectedValue.ToEntero, "Con", True, UsuarioActual.CveEmpresa) Then
|
||||||
|
TieneError = True
|
||||||
|
End If
|
||||||
|
ObjFolios.Dispose()
|
||||||
|
End If
|
||||||
|
|
||||||
If ChkImpuestosLocales.Checked Then
|
If ChkImpuestosLocales.Checked Then
|
||||||
Dim count As Integer = 0
|
Dim count As Integer = 0
|
||||||
ObjContratos.LimpiaImpuestosLocales(CveContrato)
|
|
||||||
|
|
||||||
For Each GVR As GridViewRow In GvImpuestosLocales.Rows
|
For Each GVR As GridViewRow In GvImpuestosLocales.Rows
|
||||||
If GVR.FCCheckBox("ChkDeduccion").Checked Then
|
If GVR.FCCheckBox("ChkDeduccion").Checked Then
|
||||||
@@ -1426,27 +1339,118 @@ Partial Class Contratos_Default
|
|||||||
Alert("Debe seleccionar un Impuesto Local", TipoMensaje.MsgAdvertencia)
|
Alert("Debe seleccionar un Impuesto Local", TipoMensaje.MsgAdvertencia)
|
||||||
TieneError = True
|
TieneError = True
|
||||||
End If
|
End If
|
||||||
Else
|
|
||||||
ObjContratos.LimpiaImpuestosLocales(CveContrato)
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
Else
|
||||||
|
TieneError = True
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Else
|
Else
|
||||||
TieneError = True
|
Modificado = True
|
||||||
|
|
||||||
|
Dim ArchivoUpdate As String = "-1"
|
||||||
|
|
||||||
|
If Session("FileExtension").ToString <> "" Then
|
||||||
|
ArchivoUpdate = "." & Session("FileExtension").ToString
|
||||||
|
Else
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
If ObjContratos.UpdateContratos(CveContrato, TxtNumeroContrato.Text, TxtDescripcionContrato.Text, TxtNumeroLicitacion.Text.Trim, DdlContratista.SelectedValue.ToEntero, DdlCliente.SelectedValue.ToEntero, -1, TxtFechaInicial.Text.ToDate, TxtFechaFinal.Text.ToDate,
|
||||||
|
TxtUbicacion.Text, TxtResponsable.Text, DdlSubProyectoContrato.SelectedValue.ToEntero, TxtPorIVA.Text.ToDouble, TxtPorAnticipo.Text.ToDouble, TxtPorAmortizacionAnticipo.Text.ToDouble,
|
||||||
|
TxtPorGarantia.Text.ToDouble, ArchivoUpdate, "", DdlContratoPadre.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, False, Minimo, Maximo, Total, DdlMoneda.SelectedValue.ToEntero,
|
||||||
|
ModalidadDetalle, If(UsuarioActual.Empresa.CvePlataforma = 3 OrElse CveTipoContrato = 25, 1, DdlEstatus.SelectedValue.ToEntero), TipoContrato, TxtTipoCambio.Text.ToDouble, CveSucursalCliente:=DdlSucursalCliente.SelectedValue.ToEntero,
|
||||||
|
CveAlmacenOrigen:=DdlAlmacenOrigen.SelectedValue.ToEntero, CveAlmacenDestino:=DdlAlmacenDestino.SelectedValue.ToEntero, PorcentajeComision:=TxtPorcentajeComision.Text.ToEntero,
|
||||||
|
TipoGarantia:=DdlTipoGarantia.SelectedValue.ToEntero, Folio:=TxtFolio.Text.ToEntero, FechaVenc:=txtFechaVenc.Text.ToDate, EstatusFianza:=DdlEstatusFianza.SelectedValue.ToEntero, CveContratoPlantilla:=DdlPlantillaContrato.SelectedValue.ToEntero,
|
||||||
|
CveCuentaEquipo:=DdlCuentaEquipo.SelectedValue.ToEntero, CveVendedor:=DdlVendedor.SelectedValue.ToEntero, Observaciones:=TxtObservaciones.Text, CveDireccionEnvio:=DdlClienteDireccionEnvio.SelectedValue.ToEntero, AplicaImpuestosLocales:=ChkImpuestosLocales.Checked,
|
||||||
|
CorreoNotificacionPedDev:=TxtCorreoNotificacion.Text.Trim(), FacturacionCicilica:=ChkAplicaFacCiclica.Checked, FacturacionCiclicaAutomatico:=ChkFacAutomatica.Checked, DiaMesFacturacion:=DdlDiaFact.SelectedValue.ToEntero(), CvePeriodo:=DdlPeriodo.SelectedValue.ToEntero()) Then
|
||||||
|
|
||||||
|
|
||||||
|
TieneError = Not GuardaFianzas(ObjContratos)
|
||||||
|
|
||||||
|
'Renombrar archivo
|
||||||
|
If Not TieneError Then
|
||||||
|
|
||||||
|
'If UsuarioActual.Empresa.CvePlataforma = 3 AndAlso DdlTipoContrato.SelectedValue = "14" Then
|
||||||
|
|
||||||
|
' If Not ObjContratos.CicloComercialDelete(CveContrato, False, UsuarioActual.CveEmpresa) Then
|
||||||
|
' TieneError = True
|
||||||
|
' End If
|
||||||
|
|
||||||
|
' Dim FechaIN As DateTime = TxtFechaInicial.Text.ToDateTime
|
||||||
|
' Dim FechaFN As DateTime = TxtFechaFinal.Text.ToDateTime
|
||||||
|
' Dim Periodo As Integer = DtPeriodo.FiltraParametros($"CvePeriodo = {DdlPeriodo.SelectedValue.ToEntero}").Rows(0)("Dias").ToString.ToEntero
|
||||||
|
' Dim VigenciaEnDias As Double = DateDiff(DateInterval.Day, FechaI, FechaF)
|
||||||
|
' Dim CiclosComerciales As Integer = Math.Round(VigenciaEnDias / Periodo).ToEntero
|
||||||
|
' For Ciclo As Integer = 1 To CiclosComerciales
|
||||||
|
' If Not ObjContratos.CicloComercialAdd(CveContrato, -1, DdlCliente.SelectedValue.ToEntero, False, -1, 1, UsuarioActual.CveEmpresa, FechaI.AddDays(Periodo * Ciclo)) Then TieneError = True : Exit For
|
||||||
|
' Next
|
||||||
|
'End If
|
||||||
|
|
||||||
|
If ChkAplicaFacCiclica.Checked Then
|
||||||
|
TieneError = Not GenerarCiclosComerciales(CveContrato, True, ObjContratos)
|
||||||
|
Else
|
||||||
|
|
||||||
|
If Not ObjContratos.CicloComercialDelete(CveContrato, False, UsuarioActual.CveEmpresa) Then
|
||||||
|
TieneError = True
|
||||||
|
End If
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
If ViewState("extencion") IsNot Nothing Then
|
||||||
|
|
||||||
|
If ViewState("FUrl").ToString.Length > 0 AndAlso ViewState("extencion").ToString.Length > 0 Then
|
||||||
|
If Not Directory.Exists(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & UsuarioActual.CveEmpresa & "\Contratos") Then
|
||||||
|
Directory.CreateDirectory(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & UsuarioActual.CveEmpresa & "\Contratos")
|
||||||
|
End If
|
||||||
|
Ruta = ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & UsuarioActual.CveEmpresa & "\Contratos\"
|
||||||
|
|
||||||
|
Try
|
||||||
|
If File.Exists(String.Format("{0}{1}.{2}", Ruta, CveContrato.ToString, ViewState("extencion").ToString)) Then
|
||||||
|
File.Delete(String.Format("{0}{1}.{2}", Ruta, CveContrato.ToString, ViewState("extencion").ToString))
|
||||||
|
End If
|
||||||
|
System.IO.File.Move(ViewState("FUrl").ToString, String.Format("{0}{1}.{2}", Ruta, CveContrato.ToString, ViewState("extencion").ToString))
|
||||||
|
Catch ex As Exception
|
||||||
|
|
||||||
|
End Try
|
||||||
|
' System.IO.File.Move(Archivo, String.Format("{0}{1}{2}", Ruta, CveContrato.ToString, Extension))
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
If ChkImpuestosLocales.Checked Then
|
||||||
|
Dim count As Integer = 0
|
||||||
|
ObjContratos.LimpiaImpuestosLocales(CveContrato)
|
||||||
|
|
||||||
|
For Each GVR As GridViewRow In GvImpuestosLocales.Rows
|
||||||
|
If GVR.FCCheckBox("ChkDeduccion").Checked Then
|
||||||
|
count = count + 1
|
||||||
|
ObjContratos.AddContratoImpuestosLocales(CveContrato, GVR.DataKey("CveImpuestoLocal").ToEntero)
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
|
||||||
|
If count = 0 Then
|
||||||
|
Alert("Debe seleccionar un Impuesto Local", TipoMensaje.MsgAdvertencia)
|
||||||
|
TieneError = True
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
ObjContratos.LimpiaImpuestosLocales(CveContrato)
|
||||||
|
End If
|
||||||
|
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
TieneError = True
|
||||||
|
End If
|
||||||
End If
|
End If
|
||||||
|
Catch ex As Exception
|
||||||
|
TieneError = True
|
||||||
|
OnError("Ocurrió un error al guardar el contrato.", ex)
|
||||||
|
End Try
|
||||||
|
|
||||||
|
|
||||||
End If
|
|
||||||
|
|
||||||
If TieneError Then
|
If TieneError Then
|
||||||
ObjContratos.RollBack()
|
ObjContratos.RollBack()
|
||||||
Else
|
Else
|
||||||
ObjContratos.Commit()
|
ObjContratos.Commit()
|
||||||
|
|
||||||
If ObjContratos.GetContratos(-1, -1) Then
|
|
||||||
Application("GlobalDTContratos") = ObjContratos.DtResultados
|
|
||||||
End If
|
|
||||||
|
|
||||||
Limpiar()
|
Limpiar()
|
||||||
If Modificado Then
|
If Modificado Then
|
||||||
Alert("El Contrato se modificó Correctamente.", TipoMensaje.MsgInformacion, String.Format("document.location.href=""/Contratos/Contrato.aspx?CveContrato={0}""", CveContrato))
|
Alert("El Contrato se modificó Correctamente.", TipoMensaje.MsgInformacion, String.Format("document.location.href=""/Contratos/Contrato.aspx?CveContrato={0}""", CveContrato))
|
||||||
@@ -1456,8 +1460,102 @@ Partial Class Contratos_Default
|
|||||||
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
UpGral.Update()
|
|
||||||
ObjContratos.Dispose()
|
ObjContratos.Dispose()
|
||||||
|
UpGral.Update()
|
||||||
|
|
||||||
|
RecargaGlobalContratos()
|
||||||
|
End Sub
|
||||||
|
Private Function GenerarCiclosComerciales(CveContrato As Integer, EsActualizacion As Boolean, ByRef ObjContratos As ClsContratos) As Boolean
|
||||||
|
Dim TieneError As Boolean = False
|
||||||
|
|
||||||
|
Dim FechaI As DateTime = TxtFechaInicial.Text.ToDateTime
|
||||||
|
Dim FechaF As DateTime = TxtFechaFinal.Text.ToDateTime
|
||||||
|
|
||||||
|
If EsActualizacion Then
|
||||||
|
Dim DtCiclos As DataTable = Nothing
|
||||||
|
If ObjContratos.CicloComercialGet(Me.CveContrato, -1, -1, UsuarioActual.CveEmpresa, MinFecha, MaxFecha) Then
|
||||||
|
Dim RowCiclo As DataRow = ObjContratos.DtResultados.FiltroPrimero("FueFacturado = 1", Orderby:="FechaVenc DESC")
|
||||||
|
If RowCiclo IsNot Nothing Then
|
||||||
|
FechaI = RowCiclo("FechaVenc").ToString().ToDateTime()
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
TieneError = True
|
||||||
|
End If
|
||||||
|
|
||||||
|
If Not ObjContratos.CicloComercialDelete(CveContrato, False, UsuarioActual.CveEmpresa) Then
|
||||||
|
TieneError = True
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
Dim PeriodoMeses As Integer = DtPeriodo.FiltroPrimeroValor("Meses", $"CvePeriodo = {DdlPeriodo.SelectedValue.ToEntero}").ToEntero
|
||||||
|
|
||||||
|
Dim PeriodoDias As Integer = DtPeriodo.FiltraParametros($"CvePeriodo = {DdlPeriodo.SelectedValue.ToEntero}").Rows(0)("Dias").ToString.ToEntero
|
||||||
|
|
||||||
|
If PeriodoMeses > 0 AndAlso PeriodoDias <= 0 Then
|
||||||
|
Dim VigenciaMeses As Double = DateDiff(DateInterval.Month, FechaI, FechaF)
|
||||||
|
Dim CiclosComercialesEnMeses As Integer = Math.Ceiling(VigenciaMeses / PeriodoMeses).ToEntero
|
||||||
|
|
||||||
|
For Ciclo As Integer = 1 To CiclosComercialesEnMeses
|
||||||
|
Dim FechaRef As DateTime = FechaI.AddMonths(PeriodoMeses * Ciclo)
|
||||||
|
Dim lastDayOfMonth = DateTime.DaysInMonth(FechaRef.Year, FechaRef.Month)
|
||||||
|
Dim DiaMes As Integer = If(FechaRef.Day < DdlDiaFact.SelectedValue.ToEntero(), lastDayOfMonth, DdlDiaFact.SelectedValue.ToEntero())
|
||||||
|
|
||||||
|
Dim FechaFact = New DateTime(FechaRef.Year, FechaRef.Month, DiaMes)
|
||||||
|
FechaFact = If(FechaFact > FechaF, FechaF, FechaFact)
|
||||||
|
|
||||||
|
If Not ObjContratos.CicloComercialAdd(CveContrato, -1, DdlCliente.SelectedValue.ToEntero, False, -1, 1, UsuarioActual.CveEmpresa, FechaFact) Then TieneError = True : Exit For
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
If PeriodoDias > 0 AndAlso PeriodoMeses <= 0 Then
|
||||||
|
Dim VigenciaEnMeses As Double = DateDiff(DateInterval.Month, FechaI, FechaF)
|
||||||
|
Dim CiclosComercialesEnDias As Integer = VigenciaEnMeses.ToEntero()
|
||||||
|
|
||||||
|
'RECORRE LOS MESES QUE VA A FACTURAR
|
||||||
|
For CicloMes As Integer = 1 To CiclosComercialesEnDias
|
||||||
|
|
||||||
|
Dim FechaRef As DateTime = FechaI.AddMonths(CicloMes)
|
||||||
|
Dim CiclosPorMesDecimal As Double = (FechaRef.LastDayOfMonth().Day.ToString().ToDouble() / PeriodoDias.ToString().ToDouble())
|
||||||
|
|
||||||
|
Dim CiclosPorMes As Integer = Math.Truncate(CiclosPorMesDecimal).ToEntero()
|
||||||
|
Dim DecimalPart As Double = CiclosPorMesDecimal - CiclosPorMes.ToString().ToDouble()
|
||||||
|
|
||||||
|
If DecimalPart > 0.7D Then
|
||||||
|
CiclosPorMes += 1
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim DiaAnterior As Integer = 0
|
||||||
|
|
||||||
|
For CicloDias = 1 To CiclosPorMes
|
||||||
|
Dim DiaMes As Integer = 0
|
||||||
|
|
||||||
|
If CicloDias = 1 Then
|
||||||
|
DiaMes = DdlDiaFact.SelectedValue.ToEntero()
|
||||||
|
Else
|
||||||
|
DiaMes = DiaAnterior + PeriodoDias
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim FechaFact As DateTime = New DateTime(FechaRef.Year, FechaRef.Month, If(DiaMes > FechaRef.LastDayOfMonth().Day, FechaRef.LastDayOfMonth().Day, DiaMes))
|
||||||
|
|
||||||
|
DiaAnterior = FechaFact.Day
|
||||||
|
|
||||||
|
If Not ObjContratos.CicloComercialAdd(CveContrato, -1, DdlCliente.SelectedValue.ToEntero, False, -1, 1, UsuarioActual.CveEmpresa, FechaFact) Then TieneError = True : Exit For
|
||||||
|
Next
|
||||||
|
Next
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
Return Not TieneError
|
||||||
|
End Function
|
||||||
|
Private Sub RecargaGlobalContratos()
|
||||||
|
Using ObjContratos As New ClsContratos
|
||||||
|
If ObjContratos.GetContratos(-1, -1) Then
|
||||||
|
Application("GlobalDTContratos") = ObjContratos.DtResultados
|
||||||
|
End If
|
||||||
|
End Using
|
||||||
End Sub
|
End Sub
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
@@ -3468,9 +3566,50 @@ Partial Class Contratos_Default
|
|||||||
End If
|
End If
|
||||||
DdlPeriodo.DataSource = DtPeriodo
|
DdlPeriodo.DataSource = DtPeriodo
|
||||||
ObjContratos.Dispose()
|
ObjContratos.Dispose()
|
||||||
|
|
||||||
DdlPeriodo.DataBind()
|
DdlPeriodo.DataBind()
|
||||||
UpGral.Update()
|
UpGral.Update()
|
||||||
End Sub
|
End Sub
|
||||||
|
Protected Sub DdlPeriodo_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||||
|
|
||||||
|
If DtPeriodo IsNot Nothing Then
|
||||||
|
If DdlPeriodo.SelectedValue.ToEntero() > 0 Then
|
||||||
|
Dim PeriodoDias As Integer = DtPeriodo.FiltraParametros($"CvePeriodo = {DdlPeriodo.SelectedValue.ToEntero}").Rows(0)("Dias").ToString.ToEntero
|
||||||
|
If PeriodoDias > 0 Then
|
||||||
|
CargaDiasMes(PeriodoDias)
|
||||||
|
Else
|
||||||
|
CargaDiasMes()
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
CargaDiasMes()
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
CargaDiasMes()
|
||||||
|
End If
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
Private Sub CargaDiasMes(Optional NumMaxDias As Integer = 31)
|
||||||
|
DdlDiaFact.Items.Clear()
|
||||||
|
For i = 1 To NumMaxDias
|
||||||
|
DdlDiaFact.Items.Add(New ListItem(i.ToString(), i.ToString()))
|
||||||
|
Next
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub CargaCiclosComerciales()
|
||||||
|
If ChkAplicaFacCiclica.Checked Then
|
||||||
|
DivCiclosComerciales.Visible = True
|
||||||
|
Using ObjContratos As New ClsContratos
|
||||||
|
If ObjContratos.CicloComercialGet(Me.CveContrato, -1, -1, UsuarioActual.CveEmpresa, MinFecha, MaxFecha) Then
|
||||||
|
GvCiclosComerciales.DataSource = ObjContratos.DtResultados.FiltraParametros("", Orderby:="FechaVenc ASC")
|
||||||
|
End If
|
||||||
|
End Using
|
||||||
|
Else
|
||||||
|
DivCiclosComerciales.Visible = False
|
||||||
|
End If
|
||||||
|
GvCiclosComerciales.DataBind()
|
||||||
|
UpFacCiclica.Update()
|
||||||
|
End Sub
|
||||||
|
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
#Region " IMPRESION "
|
#Region " IMPRESION "
|
||||||
@@ -4348,6 +4487,13 @@ Partial Class Contratos_Default
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Protected Sub ChkAplicaFacCiclica_CheckedChanged(sender As Object, e As EventArgs)
|
||||||
|
DivFacCiclica.Visible = ChkAplicaFacCiclica.Checked
|
||||||
|
DivCiclosComerciales.Visible = ChkAplicaFacCiclica.Checked
|
||||||
|
|
||||||
|
UpFacCiclica.Update()
|
||||||
|
End Sub
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -195,7 +195,10 @@ Partial Class Contratos_FacturacionMasiva
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Protected Sub btnConsultar_Click(sender As Object, e As EventArgs) Handles BtnCargaAsignados.Click
|
Protected Sub btnConsultar_Click(sender As Object, e As EventArgs) Handles BtnCargaAsignados.Click
|
||||||
CargaDatos(DdlContrato.SelectedValue.ToEntero, DdlCliente.SelectedValue.ToEntero)
|
Dim CveContrato As Integer = If(DdlContrato.SelectedValue.ToEntero <= 0, -1, DdlContrato.SelectedValue.ToEntero)
|
||||||
|
Dim CveCliente As Integer = If(DdlCliente.SelectedValue.ToEntero <= 0, -1, DdlCliente.SelectedValue.ToEntero)
|
||||||
|
|
||||||
|
CargaDatos(CveContrato, CveCliente)
|
||||||
RegistraScript("$('#ex').removeClass('expand');$('#ex').addClass('collapse');$('.portlet-body').css('display', '');")
|
RegistraScript("$('#ex').removeClass('expand');$('#ex').addClass('collapse');$('.portlet-body').css('display', '');")
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -232,7 +235,10 @@ Partial Class Contratos_FacturacionMasiva
|
|||||||
Alert("No se generaron facturas", TipoMensaje.MsgAdvertencia)
|
Alert("No se generaron facturas", TipoMensaje.MsgAdvertencia)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
CargaDatos(DdlContrato.SelectedValue.ToEntero, DdlCliente.SelectedValue.ToEntero)
|
Dim CveContrato As Integer = If(DdlContrato.SelectedValue.ToEntero <= 0, -1, DdlContrato.SelectedValue.ToEntero)
|
||||||
|
Dim CveCliente As Integer = If(DdlCliente.SelectedValue.ToEntero <= 0, -1, DdlCliente.SelectedValue.ToEntero)
|
||||||
|
|
||||||
|
CargaDatos(CveContrato, CveCliente)
|
||||||
RegistraScript("$('#divAgregar').modal('hide')")
|
RegistraScript("$('#divAgregar').modal('hide')")
|
||||||
UpBodyEstatus.Update()
|
UpBodyEstatus.Update()
|
||||||
End Sub
|
End Sub
|
||||||
@@ -245,6 +251,7 @@ Partial Class Contratos_FacturacionMasiva
|
|||||||
Dim Resp As New Modelos.Factura.MMensajeFactura
|
Dim Resp As New Modelos.Factura.MMensajeFactura
|
||||||
ViewState("CveCicloComercial") = pCveCicloComercial
|
ViewState("CveCicloComercial") = pCveCicloComercial
|
||||||
CreaObjetosVenta()
|
CreaObjetosVenta()
|
||||||
|
|
||||||
If ObjFactura Is Nothing Or ObjFactura.Cliente Is Nothing Then
|
If ObjFactura Is Nothing Or ObjFactura.Cliente Is Nothing Then
|
||||||
Alert("Ocurrió un error al procesar los datos de la Venta.", TipoMensaje.MsgError)
|
Alert("Ocurrió un error al procesar los datos de la Venta.", TipoMensaje.MsgError)
|
||||||
ObjFactura = Nothing
|
ObjFactura = Nothing
|
||||||
@@ -253,7 +260,7 @@ Partial Class Contratos_FacturacionMasiva
|
|||||||
|
|
||||||
|
|
||||||
If ObjFactura.CveCliente > 0 Then
|
If ObjFactura.CveCliente > 0 Then
|
||||||
If DTDetalle.Rows.Count > 0 Then
|
If ObjFactura.DtDetalle.Rows.Count > 0 Then
|
||||||
|
|
||||||
Resp = ObjFactura.EmitirFactura()
|
Resp = ObjFactura.EmitirFactura()
|
||||||
|
|
||||||
@@ -468,9 +475,7 @@ Partial Class Contratos_FacturacionMasiva
|
|||||||
TmpDT.Columns.Add("EsCargo", GetType(Boolean))
|
TmpDT.Columns.Add("EsCargo", GetType(Boolean))
|
||||||
End Sub
|
End Sub
|
||||||
Private Sub CreaObjetosVenta(Optional VistaPrevia As Boolean = False)
|
Private Sub CreaObjetosVenta(Optional VistaPrevia As Boolean = False)
|
||||||
Dim ObjFolios As New ClsGralFolios()
|
|
||||||
Dim Folio As String = ""
|
|
||||||
Dim Serie As String = ""
|
|
||||||
Dim CveProyecto As String = ""
|
Dim CveProyecto As String = ""
|
||||||
Dim CveSubProyecto As String = ""
|
Dim CveSubProyecto As String = ""
|
||||||
Dim Proyecto As String = ""
|
Dim Proyecto As String = ""
|
||||||
@@ -479,21 +484,21 @@ Partial Class Contratos_FacturacionMasiva
|
|||||||
ObjFactura = New Modelos.Factura(UsuarioActual)
|
ObjFactura = New Modelos.Factura(UsuarioActual)
|
||||||
ObjFactura.DirectorioServidor = Server.MapPath("/")
|
ObjFactura.DirectorioServidor = Server.MapPath("/")
|
||||||
ObjFactura.CveCicloComercial = CveCicloComercial
|
ObjFactura.CveCicloComercial = CveCicloComercial
|
||||||
|
|
||||||
Dim DR As DataRow = DTCicloComercial.FiltroPrimero($"CveCicloComercial = {CveCicloComercial}")
|
Dim DR As DataRow = DTCicloComercial.FiltroPrimero($"CveCicloComercial = {CveCicloComercial}")
|
||||||
|
|
||||||
ObjFactura.Version = "3.3"
|
ObjFactura.Version = "3.3"
|
||||||
ObjFactura.CveUsuario = UsuarioActual.CveUsuario
|
ObjFactura.CveUsuario = UsuarioActual.CveUsuario
|
||||||
ObjFactura.CveEmpresa = UsuarioActual.CveEmpresa
|
ObjFactura.CveEmpresa = UsuarioActual.CveEmpresa
|
||||||
ObjFactura.TipoCambio = 20
|
ObjFactura.TipoCambio = 1
|
||||||
ObjFactura.ConvertirPesos = False
|
ObjFactura.ConvertirPesos = False
|
||||||
ObjFactura.CveMoneda = DR("CveMoneda").ToString.ToEntero
|
ObjFactura.CveMoneda = DR("CveMoneda").ToString.ToEntero
|
||||||
ObjFactura.Moneda = GlobalDTMonedas.FiltroPrimeroValor("Moneda", $"CveMoneda = {ObjFactura.CveMoneda} ")
|
ObjFactura.Moneda = GlobalDTMonedas.FiltroPrimeroValor("Moneda", $"CveMoneda = {ObjFactura.CveMoneda} ")
|
||||||
ObjFactura.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", $"CveMoneda = {DR("CveMoneda").ToString.ToEntero}")
|
ObjFactura.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", $"CveMoneda = {DR("CveMoneda").ToString.ToEntero}")
|
||||||
ObjFactura.TipoDocto = "Ing"
|
ObjFactura.TipoDocto = "Ing"
|
||||||
ObjFactura.RefDocto = ""
|
ObjFactura.RefDocto = ""
|
||||||
ObjFactura.Folio = Folio.ToEntero
|
ObjFactura.Folio = -1
|
||||||
'ObjFactura.Folio = If(ExFolioFactura, FolioXML.ToEntero, -1)
|
ObjFactura.Serie = "-1"
|
||||||
ObjFactura.Serie = Serie
|
|
||||||
ObjFactura.CveMesa = -1
|
ObjFactura.CveMesa = -1
|
||||||
ObjFactura.Fecha = DR("FechaVenc").ToString.ToDate
|
ObjFactura.Fecha = DR("FechaVenc").ToString.ToDate
|
||||||
ObjFactura.CvePrePoliza = -1
|
ObjFactura.CvePrePoliza = -1
|
||||||
@@ -535,17 +540,6 @@ Partial Class Contratos_FacturacionMasiva
|
|||||||
|
|
||||||
SubProyecto = DR("SubProyectoContrato").ToString
|
SubProyecto = DR("SubProyectoContrato").ToString
|
||||||
|
|
||||||
|
|
||||||
If ObjFolios.GetFolios("Ing", UsuarioActual.CveEmpresa) Then
|
|
||||||
Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format($" Estado = 'Activo' AND CveSubProyecto = {CveSubProyecto} "))
|
|
||||||
If DT.Rows.Count > 0 Then
|
|
||||||
Serie = DT.Rows(0)("Serie").ToString
|
|
||||||
Folio = DT.Rows(0)("FActual").ToString
|
|
||||||
End If
|
|
||||||
DT.Dispose()
|
|
||||||
End If
|
|
||||||
ObjFolios.Dispose()
|
|
||||||
|
|
||||||
Dim objContratos As New ClsContratos
|
Dim objContratos As New ClsContratos
|
||||||
If objContratos.GetContratosDetalle(DR("CveContrato").ToString.ToEntero) Then
|
If objContratos.GetContratosDetalle(DR("CveContrato").ToString.ToEntero) Then
|
||||||
DTDetalle = objContratos.DtResultados
|
DTDetalle = objContratos.DtResultados
|
||||||
@@ -561,8 +555,6 @@ Partial Class Contratos_FacturacionMasiva
|
|||||||
ObjFactura.RetISR = SUM(DTDetalle, "ImporteRetISR").ToDecimal
|
ObjFactura.RetISR = SUM(DTDetalle, "ImporteRetISR").ToDecimal
|
||||||
ObjFactura.IEPS = SUM(DTDetalle, "ImporteIEPS").ToDecimal
|
ObjFactura.IEPS = SUM(DTDetalle, "ImporteIEPS").ToDecimal
|
||||||
ObjFactura.Total = ObjFactura.SubTotal + ObjFactura.IVA + ObjFactura.IEPS - (ObjFactura.RetIVA + ObjFactura.RetISR)
|
ObjFactura.Total = ObjFactura.SubTotal + ObjFactura.IVA + ObjFactura.IEPS - (ObjFactura.RetIVA + ObjFactura.RetISR)
|
||||||
ObjFactura.Serie = Serie
|
|
||||||
ObjFactura.Folio = Folio.ToEntero
|
|
||||||
|
|
||||||
For Each row As DataRow In DTDetalle.Rows
|
For Each row As DataRow In DTDetalle.Rows
|
||||||
Dim drPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=row("CvePS").ToString().ToEntero()).FiltroPrimero("")
|
Dim drPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=row("CvePS").ToString().ToEntero()).FiltroPrimero("")
|
||||||
|
|||||||
@@ -7462,7 +7462,7 @@ Partial Class Ventas
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
If CveCicloComercial > 0 AndAlso ErrorList.Count = 0 Then
|
If CveCicloComercial > 0 AndAlso ErrorList.Count = 0 Then
|
||||||
If Not ObjContr.CicloComercialUpdate(CveCicloComercial, True, UsuarioActual.CveEmpresa) Then
|
If Not ObjContr.CicloComercialUpdate(CveCicloComercial, True, UsuarioActual.CveEmpresa, CveVenta:=ObjFactura.CveVenta) Then
|
||||||
ErrorList.Add("No se pudo actualizar ")
|
ErrorList.Add("No se pudo actualizar ")
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|||||||
Reference in New Issue
Block a user