4378 lines
210 KiB
VB.net
4378 lines
210 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports System.Data.SqlClient
|
|
Imports ClsPaginas
|
|
Imports System.IO
|
|
Imports System.Xml
|
|
Imports DocumentFormat.OpenXml.ExtendedProperties
|
|
Imports Extensiones
|
|
Imports Microsoft.Reporting.WebForms
|
|
Partial Class Bancos_ProveedoresAbonar
|
|
Inherits ClsPaginas
|
|
|
|
#Region "Propiedades"
|
|
'Configuración
|
|
Private Property CveProveedor As Integer
|
|
Get
|
|
Return ViewState("CveProveedor").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveProveedor") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property FechaI As String
|
|
Get
|
|
Return ViewState("FechaI").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("FechaI") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property FechaF As String
|
|
Get
|
|
Return ViewState("FechaF").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("FechaF") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveUsuarioProgramo As Integer
|
|
Get
|
|
Return IfNull(ViewState("CveUsuarioProgramo"), "-1").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveUsuarioProgramo") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property TipoPago As Integer
|
|
Get
|
|
Return ViewState("TipoPago").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("TipoPago") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveUsuarioRegistro As Integer
|
|
Get
|
|
Return ViewState("CveUsuarioRegistro").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveUsuarioRegistro") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveUsuarioResponsable As Integer
|
|
Get
|
|
Return ViewState("CveUsuarioResponsable").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveUsuarioResponsable") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveClasificacionProveedor As Integer
|
|
Get
|
|
Return ViewState("CveClasificacionProveedor").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveClasificacionProveedor") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveAplicaNC As Integer
|
|
Get
|
|
Return ViewState("CveAplicaNC").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveAplicaNC") = value
|
|
End Set
|
|
End Property
|
|
Private Property ProveedorPlazoPago As Integer
|
|
Get
|
|
Return ViewState("ProveedorPlazoPago").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("ProveedorPlazoPago") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveMoneda As Integer
|
|
Get
|
|
Return If(IsNothing(ViewState("CveMoneda")), -1, ViewState("CveMoneda").ToString.ToEntero)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveMoneda") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property FiltrarCuentas As Integer
|
|
Get
|
|
Return If(IsNothing(ViewState("FiltrarCuentas")), 1, ViewState("FiltrarCuentas").ToString.ToEntero)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("FiltrarCuentas") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveMonedaFiltro As Integer
|
|
Get
|
|
Return ViewState("CveMonedaFiltro").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveMonedaFiltro") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveEstatus As Integer
|
|
Get
|
|
Return ViewState("CveEstatus").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveEstatus") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property Serie As String
|
|
Get
|
|
Return ViewState("Serie").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("Serie") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveProveedorSucursal As Integer
|
|
Get
|
|
Return ViewState("CveProveedorSucursal").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveProveedorSucursal") = value
|
|
End Set
|
|
End Property
|
|
Private Property PermiteModificarImporte As Boolean
|
|
Get
|
|
Return CType(ViewState("PermiteModificarImporte").ToString, Boolean)
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("PermiteModificarImporte") = value
|
|
End Set
|
|
End Property
|
|
Private Property ComprobanteIE As String
|
|
Get
|
|
Return ViewState("ComprobanteIE").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("ComprobanteIE") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CodigoProgramacion As String
|
|
Get
|
|
Return ViewState("CodigoProgramacion").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("CodigoProgramacion") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private Property CveSubProyectoFiltro As Integer
|
|
Get
|
|
If ViewState("CveSubProyectoFiltro") Is Nothing Then
|
|
ViewState("CveSubProyectoFiltro") = -1
|
|
End If
|
|
Return ViewState("CveSubProyectoFiltro").ToString.ToEntero
|
|
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveSubProyectoFiltro") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private Property DtDatos As DataTable
|
|
Get
|
|
Return DirectCast(ViewState("DtDatos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtDatos") = value
|
|
End Set
|
|
End Property
|
|
Private Property OriReferenciaCIE As String
|
|
Get
|
|
If ViewState("OriReferenciaCIE") Is Nothing Then
|
|
Return ""
|
|
Else
|
|
Return ViewState("OriReferenciaCIE").ToString
|
|
End If
|
|
|
|
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("OriReferenciaCIE") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property OriConceptoCIE As String
|
|
Get
|
|
If ViewState("OriConceptoCIE") Is Nothing Then
|
|
Return ""
|
|
Else
|
|
Return ViewState("OriConceptoCIE").ToString
|
|
End If
|
|
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("OriConceptoCIE") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveTipoProveedor As Integer
|
|
Get
|
|
If ViewState("CveTipoProveedor") Is Nothing Then
|
|
ViewState("CveTipoProveedor") = -1
|
|
End If
|
|
Return ViewState("CveTipoProveedor").ToString.ToEntero
|
|
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveTipoProveedor") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveTipoConceptoProveedor As Integer
|
|
Get
|
|
If ViewState("CveTipoConceptoProveedor") Is Nothing Then
|
|
ViewState("CveTipoConceptoProveedor") = -1
|
|
End If
|
|
Return ViewState("CveTipoConceptoProveedor").ToString.ToEntero
|
|
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveTipoConceptoProveedor") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
|
|
'temporal
|
|
If UsuarioActual.CveUsuario.Contiene(1803, 100) Then
|
|
ChkNoValidaSAT.Visible = True
|
|
End If
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
|
|
HplCambiarProveedor.Visible = True
|
|
|
|
DdlProveedores.setEsWebService(True)
|
|
DdlProveedores.Attributes.Add("data-metodo", "getproveedores")
|
|
DdlProveedores.SelectedText = "Todos"
|
|
DdlProveedores.SelectedValue = "-1"
|
|
End If
|
|
|
|
PermiteModificarImporte = True
|
|
TxtFechaIncobrable.Text = NowADS().ToShortDateString
|
|
|
|
If Request("CveProveedor") IsNot Nothing AndAlso Request("CveProveedor").ToString.ToEntero > 0 Then
|
|
|
|
CveProveedor = IfNull(Request("CveProveedor"), "-1").ToString.ToEntero
|
|
FechaI = IfNull(Request("FechaI"), "-1").ToString
|
|
FechaF = IfNull(Request("FechaF"), "-1").ToString
|
|
CveUsuarioProgramo = IfNull(Request("CveUsuarioProgramo"), "-1").ToString.ToEntero
|
|
TipoPago = IfNull(Request("TipoPago"), "-1").ToString.ToEntero
|
|
CveUsuarioRegistro = IfNull(Request("CveUsuarioRegistro"), "-1").ToString.ToEntero
|
|
CveUsuarioResponsable = IfNull(Request("CveUsuarioResponsable"), "-1").ToString.ToEntero
|
|
CveClasificacionProveedor = IfNull(Request("CveClasificacion"), "-1").ToString.ToEntero
|
|
CveMoneda = IfNull(Request("CveMoneda"), "-1").ToString.ToEntero
|
|
CveMonedaFiltro = IfNull(Request("CveMoneda"), "-1").ToString.ToEntero
|
|
FiltrarCuentas = IfNull(Request("FiltrarCuentas"), "1").ToString.ToEntero
|
|
CveEstatus = IfNull(Request("CveEstatus"), "-1").ToString.ToEntero
|
|
Serie = IfNull(Request("Serie"), "").ToString
|
|
CveAplicaNC = IfNull(Request("CveAplicaNC"), "-1").ToString.ToEntero
|
|
CveProveedorSucursal = IfNull(Request("CveProveedorSucursal"), "-1").ToString.ToEntero
|
|
CodigoProgramacion = IfNull(Request("CodigoProgramacion"), "-1").ToString
|
|
CveSubProyectoFiltro = IfNull(Request("CveSubProyecto"), -1).ToString.ToEntero
|
|
|
|
TxtOtrosImportes.Attributes.Add("onKeyUp", String.Format("FnSuma(this,{0},{1});", "TxtTotal", 0))
|
|
|
|
'proceso para que solo pague lo que este programada
|
|
If UsuarioActual.TienePermisoProceso(98) Then
|
|
PermiteModificarImporte = False
|
|
End If
|
|
Calendario.StartDate = NowADS().AddMonths(-48)
|
|
'proceso que restringue solo el pago de apartir del dia de hoy y como limite fin de mes
|
|
If UsuarioActual.TienePermisoProceso(105) Then
|
|
Calendario.StartDate = NowADS()
|
|
Calendario.EndDate = NowADS().LastDayOfMonth
|
|
MEVCalendario.MinimumValue = NowADS().ToShortDateString
|
|
MEVCalendario.MaximumValue = NowADS().LastDayOfMonth.ToShortDateString
|
|
MEVCalendario.Enabled = True
|
|
End If
|
|
|
|
CargaProveedor(Request("CveProveedor").ToString.ToEntero)
|
|
End If
|
|
|
|
' If UsuarioActual.Empresa.Funcionalidad(142) = "1" Then
|
|
trNotificar.Visible = True
|
|
UpDatos.Visible = True
|
|
'End If
|
|
|
|
If UsuarioActual.Empresa.UsaAC Then
|
|
PnlAC.Visible = True
|
|
' Dim AC As New ClsAC
|
|
' If AC.GetPresupuestoEgresos(-1, True, usuarioactual.Empresa.EjercicioActual, UsuarioActual.CveEmpresa) Then
|
|
' 'DdlProgramaOperativo.DataSource = AC.DtResultados
|
|
' 'DdlProgramaOperativo.DataBind()
|
|
' GvAC.DataSource = AC.DtResultados
|
|
' GvAC.DataBind()
|
|
' End If
|
|
' AC.Dispose()
|
|
End If
|
|
|
|
'BANDERA DE SURTIDO
|
|
If UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 Or UsuarioActual.Empresa.Funcionalidad(134).ToEntero > 0 Then
|
|
GvCxP.Columns(3).Visible = True
|
|
End If
|
|
|
|
If CveMoneda > 0 Then
|
|
LbTipoMoneda.Text = String.Format("Pago en {0}", GlobalDTMonedas.FiltraParametros(String.Format("CveMoneda = {0}", CveMoneda)).Rows(0)("Moneda"))
|
|
End If
|
|
|
|
'SI NO ES GDIAZ, NO PERMITIR LA MEZCLA DE CUENTAS
|
|
If UsuarioActual.Empresa.Funcionalidad(382) <> "1" AndAlso FiltrarCuentas = 0 Then
|
|
FiltrarCuentas = 1
|
|
End If
|
|
|
|
If FiltrarCuentas = 0 Then
|
|
ChkPagarPesos.Visible = False
|
|
ChkPagarDolares.Visible = False
|
|
|
|
CveMonedaFiltro = -1
|
|
Else
|
|
If CveMoneda = 2 Then
|
|
ChkPagarPesos.Visible = True
|
|
TxtTC.Text = GlobalTipoCambio(NowADS()).FormatoNumero(4)
|
|
TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);")
|
|
Else
|
|
ChkPagarDolares.Visible = True
|
|
TxtTC.Text = GlobalTipoCambio(NowADS()).FormatoNumero(4)
|
|
End If
|
|
End If
|
|
|
|
RegistraScript($"TipoCambioActual = {GlobalTipoCambio(NowADS()).FormatoNumero(4)}")
|
|
UpDatos.Update()
|
|
|
|
If UsuarioActual.TienePermisoProceso(215) Or UsuarioActual.TienePermisoProceso(204) Then
|
|
HlSaldarCuentasSinPagar.Visible = True
|
|
End If
|
|
|
|
If UsuarioActual.CveEmpresa.Contiene(119, 158) And CveUsuarioProgramo <> -1 Then
|
|
LnkPDFSolicitud.Visible = True
|
|
LnkExcelSolicitud.Visible = True
|
|
End If
|
|
|
|
If UsuarioActual.TienePermisoProceso(361) Then
|
|
'GvCxP.Columns(11).Visible = True
|
|
chkaplicaDescuento.Visible = True
|
|
End If
|
|
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
|
|
If Not UsuarioActual.TienePermisoProceso(404) Then
|
|
TxtFechaDocumento.Enabled = False
|
|
ImgCalendario.Visible = False
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Protected Sub BtnCambiaTipoMoneda_Click(sender As Object, e As EventArgs)
|
|
CambiaTipoMoneda()
|
|
End Sub
|
|
Private Sub CambiaTipoMoneda()
|
|
|
|
If DivTC.Visible Then
|
|
|
|
TxtTC.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4)
|
|
|
|
If ChkPagarDolares.Checked Then
|
|
'RegistraScript("CambiaPesosDolares();")
|
|
RegistraScript("CambiaDolaresPesos();")
|
|
|
|
End If
|
|
|
|
If ChkPagarPesos.Checked Then
|
|
'RegistraScript("CambiaDolaresPesos();")
|
|
RegistraScript("CambiaPesosDolares();")
|
|
|
|
End If
|
|
|
|
End If
|
|
UpDatos.Update()
|
|
End Sub
|
|
#Region " CARGA DATOS "
|
|
Private Sub CargaDatos(Optional tCveMoneda As Integer = -1) 'pCveProveedor As Integer, tCveMoneda As Integer, FechaVencimientoInicio As String, FechaVencimientoFin As String, CveUsuarioRegistro As Integer, CveUsuarioPrograma As Integer, Serie As String)
|
|
If tCveMoneda = -1 Then tCveMoneda = CveMoneda
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(382) = "1" AndAlso FiltrarCuentas = 0 Then
|
|
tCveMoneda = -1
|
|
End If
|
|
|
|
TxtObservaciones.Text = ""
|
|
TxtImporte.Text = ""
|
|
TxtTotal.Text = ""
|
|
|
|
Dim ObjMov As New ClsMovimientos
|
|
If ObjMov.GetCxPProveedor(CveProveedor, FechaI, FechaF, CveUsuarioProgramo, CveUsuarioRegistro, CveUsuarioResponsable, CveClasificacionProveedor, tCveMoneda, CveEstatus, CveProveedorSucursal, CveAplicaNC, "-1", "-1", CodigoProgramacion, CveSubProyecto:=CveSubProyectoFiltro) Then
|
|
|
|
If FiltrarCuentas = 1 Then
|
|
DtDatos = ObjMov.DtResultados.FiltraParametros("Tipo = 'Act' AND Saldo > 0", "Fecha,SerieFolio")
|
|
Else
|
|
DtDatos = ObjMov.DtResultados.FiltraParametros("CveCompra > 0 AND Saldo > 0", "Fecha,SerieFolio")
|
|
End If
|
|
|
|
GvCxP.DataSource = DtDatos
|
|
|
|
DtDatos.Columns.Add("Movimiento")
|
|
If DtDatos.Rows.Count > 0 Then
|
|
DVBusqueda.Visible = True
|
|
DtDatos.Rows(0)("Movimiento") = "FACTURA DE ACREEDOR"
|
|
End If
|
|
End If
|
|
ObjMov.Dispose()
|
|
|
|
|
|
GvCxP.DataBind()
|
|
UPCompras.Update()
|
|
UpBusqueda.Update()
|
|
End Sub
|
|
Private Sub CargaProveedor(tCveProveedor As Integer)
|
|
Dim ObjProveedor As New ClsCompProveedores()
|
|
If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, tCveProveedor, "-1", "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then
|
|
If ObjProveedor.DtResultados.Rows.Count > 0 Then
|
|
'Campos para Modificación
|
|
|
|
'GeneralesLblEncabezado
|
|
|
|
CargaTipoTransaccion()
|
|
CargaCuentas(DdlTipoTransaccion.SelectedValue.ToEntero)
|
|
TxtFechaDocumento.Text = NowADS().ToShortDateString
|
|
|
|
TxtPagueseA.Enabled = False
|
|
|
|
HplProveedor.Text = ObjProveedor.RazonSocial
|
|
HplProveedor.NavigateUrl = String.Format("/Compras/Proveedores.aspx?CveProveedor={0}", tCveProveedor)
|
|
TxtPagueseA.Text = ObjProveedor.RazonSocial
|
|
TxtImporte.Attributes.Add("disabled", "disabled")
|
|
If DdlTipoTransaccion.SelectedValue = "1" Then RFVFolio.Enabled = True Else RFVFolio.Enabled = False
|
|
TxtNotificarA.Text = $"{ObjProveedor.NotificarA.Trim}"
|
|
ProveedorPlazoPago = ObjProveedor.PlazoPago
|
|
If ObjProveedor.CorreoCobranza.Trim <> "" Then TxtNotificarA.Text = $"{TxtNotificarA.Text};{ObjProveedor.CorreoCobranza.Trim}"
|
|
|
|
'Sección de pago a proveedor
|
|
LtlNombreProveedor.Text = ObjProveedor.RazonSocial
|
|
LtlRFCProveedor.Text = ObjProveedor.RFC
|
|
If Serie <> "" AndAlso Serie <> "-1" Then
|
|
Dim dr As DataRow = GlobalDTProveedorSucursales(CveProveedor, UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("Serie = '{0}'", Serie))
|
|
If dr IsNot Nothing Then
|
|
TxtObservaciones.Text = String.Format("Suc. {0}", dr("ProveedorSucursal"))
|
|
HdnObs.Value = TxtObservaciones.Text
|
|
End If
|
|
End If
|
|
|
|
CveTipoProveedor = ObjProveedor.CveTipoProveedor
|
|
CveTipoConceptoProveedor = ObjProveedor.CveTipoProveedor
|
|
|
|
CargaDatos() '(tCveProveedor, CveMoneda, FechaI, FechaF, CveUsuarioRegistro, CveUsuarioProgramo, Serie)
|
|
CargaCuentasDepositos()
|
|
|
|
'CUANDO VIENE PROGRAMADO LLENA EL TEXTO OBSERVACIONES
|
|
If CveUsuarioProgramo <> -1 Then RegistraScript("SumaValores();")
|
|
|
|
Else
|
|
Alert("El Proveedor Solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia)
|
|
|
|
End If
|
|
End If
|
|
ObjProveedor.Dispose()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region " GV CXP "
|
|
Protected Sub GvCxP_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvCxP.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Right
|
|
e.Row.Cells(7).HorizontalAlign = HorizontalAlign.Right
|
|
e.Row.Cells(8).HorizontalAlign = HorizontalAlign.Right
|
|
e.Row.Cells(9).HorizontalAlign = HorizontalAlign.Right
|
|
e.Row.Cells(10).HorizontalAlign = HorizontalAlign.Right
|
|
|
|
e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format(" RNCAutocheck = true; FnSuma(this,{0},{1},'{2}');", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo"), e.Row.FCTextBox("TxtDescuento").ClientID))
|
|
|
|
If FiltrarCuentas = 1 AndAlso e.Row.RowIndex = 0 Then
|
|
e.Row.FCHyperLink("HplF").Text = (CType(GvCxP.DataSource, DataTable).Rows.Count - 1).ToString
|
|
e.Row.BackColor = Drawing.Color.LightGray
|
|
End If
|
|
|
|
If e.Row.DBCampo("CveCompra") = "" Then
|
|
e.Row.FCTextBox("TxtAbonar").Visible = False
|
|
e.Row.FCCheckBox("Chk").Visible = False
|
|
e.Row.FCTextBox("TxtComision").Visible = False
|
|
Else
|
|
e.Row.FCTextBox("TxtAbonar").Attributes.Add("onblur", String.Format(" RNCAutocheck = true; FnCambia({0},this,{1},1,'{2}',1);", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), "El Importe no debe de exceder el saldo"))
|
|
e.Row.FCTextBox("TxtComision").Attributes.Add("onblur", String.Format(" RNCAutocheck = true;FnCambia({0},this,{1},2,'{2}',2);", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), "El Importe no debe de exceder el saldo"))
|
|
End If
|
|
'si el vencimiento es diferente al configurado en el proveedor, se pone en rojo
|
|
If UsuarioActual.Empresa.Funcionalidad(382) = "1" AndAlso DateDiff(DateInterval.Day, e.Row.DBCampo("Fecha").ToDate, e.Row.DBCampo("FechaVencimiento").ToDate) <> ProveedorPlazoPago Then
|
|
e.Row.Cells(6).ForeColor = Drawing.Color.Red
|
|
e.Row.Cells(6).ToolTip = $"Dias de Vencimiento ({DateDiff(DateInterval.Day, e.Row.DBCampo("Fecha").ToDate, e.Row.DBCampo("FechaVencimiento").ToDate)}) diferente al configurado en el proveedor ({ProveedorPlazoPago})"
|
|
End If
|
|
|
|
If e.Row.DBCampo("Saldo").ToDouble < 0 Then e.Row.Cells(7).ForeColor = Drawing.Color.Red
|
|
If e.Row.DBCampo("DiasVencidos").ToDouble > 0 AndAlso CType(sender, GridView).ID = "GvCxC" Then e.Row.Cells(4).ForeColor = Drawing.Color.Red
|
|
If e.Row.DBCampo("TotalOriginal").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlSaldoOriginal"), Literal).Text = ""
|
|
If e.Row.DBCampo("Abonado").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlAbonado"), Literal).Text = ""
|
|
If e.Row.DBCampo("Saldo").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlSaldo"), Literal).Text = ""
|
|
|
|
If e.Row.DBCampo("Folio") = "N/D" Then
|
|
e.Row.FCLiteral("LtlFactura").Text = e.Row.DBCampo("Folio")
|
|
End If
|
|
|
|
e.Row.FCTextBox("TxtAbonar").Attributes.Add("CveMoneda", e.Row.DBCampo("CveMoneda"))
|
|
|
|
If e.Row.DBCampo("CveCompra").ToEntero > 0 Then
|
|
|
|
Dim FiltroInv As String = ""
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(134).ToEntero > 0 Then ' valores 1 - permite pago proporcional, valor 2. paga solo si se recibio el 100%
|
|
'se bloquean las opciones
|
|
e.Row.FCCheckBox("Chk").Enabled = False
|
|
e.Row.FCTextBox("TxtAbonar").Enabled = False
|
|
|
|
Dim Str As New StringBuilder
|
|
Str.AppendFormat("Importe Almacen: ${0} ({1}%) <br/>", e.Row.DBCampo("ImporteAlmacen").FormatoNumero, e.Row.DBCampo("ImporteAlmacenPorcentaje"))
|
|
If e.Row.DBCampo("ImporteServicios").ToDouble > 0 Then Str.AppendFormat("Importe Servicios: ${0} ({1}%) <br/>", e.Row.DBCampo("ImporteServicios").FormatoNumero, e.Row.DBCampo("ImporteServiciosPorcentaje"))
|
|
If e.Row.DBCampo("ImporteDevolucion").ToDouble > 0 Then Str.AppendFormat("Importe Devuelto: ${0} ({1}%) <br/>", e.Row.DBCampo("ImporteDevolucion").FormatoNumero, e.Row.DBCampo("ImporteDevolucionPorcentaje"))
|
|
Str.AppendFormat(" <i> Importes <b> SIN</b> IVA</i>")
|
|
e.Row.FCLabel("LbEstatusInv").Attributes.Add("title", Str.ToString)
|
|
|
|
Dim PorcentajeAlmacen As Decimal = e.Row.DBCampo("ImporteAlmacenPorcentaje").ToString.ToDecimal + e.Row.DBCampo("ImporteServiciosPorcentaje").ToString.ToDecimal + e.Row.DBCampo("ImporteDevolucionPorcentaje").ToString.ToDecimal
|
|
Dim SaldoInv As Decimal = (e.Row.DBCampo("Saldo").ToString.ToDecimal * (PorcentajeAlmacen / 100))
|
|
If UsuarioActual.Empresa.Funcionalidad(134) = "1" Then 'cuando es proporcional
|
|
FiltroInv = $"FnCambia({e.Row.FCCheckBox("Chk").ClientID},this,{SaldoInv},1,'{"El importe no debe exceder lo recibido en almacén"}',1);"
|
|
ElseIf UsuarioActual.Empresa.Funcionalidad(134) = "2" Then
|
|
FiltroInv = "" 'queno considera lo proporcional
|
|
End If
|
|
|
|
If PorcentajeAlmacen = 0 Then ' sin recibir
|
|
e.Row.FCLabel("LbEstatusInv").Text = "<i Class='fa fa-flag-o' aria-hidden='true'></i>"
|
|
e.Row.FCLabel("LbEstatusInv").ForeColor = Drawing.Color.Red
|
|
|
|
ElseIf PorcentajeAlmacen > 99.0 OrElse e.Row.DBCampo("ImporteAlmacen").ToDecimal >= e.Row.DBCampo("Saldo").ToString.ToDecimal Then 'recibido completo ' si tiene un porcentaje mayor ingresado, que este halla sido por OC, debe de permitirlo
|
|
' NOTA. si la factura tiene devoluciones, debera comparar el saldo de la factura con lo recibido en el almacen
|
|
e.Row.FCLabel("LbEstatusInv").Text = "<i Class='fa fa-flag' aria-hidden='true'></i>"
|
|
e.Row.FCLabel("LbEstatusInv").ForeColor = Drawing.Color.Green
|
|
e.Row.FCCheckBox("Chk").Enabled = True
|
|
e.Row.FCTextBox("TxtAbonar").Enabled = True
|
|
Else ' parcial
|
|
|
|
e.Row.FCLabel("LbEstatusInv").Text = "<i Class='fa fa-flag-checkered' aria-hidden='true'></i>"
|
|
e.Row.FCLabel("LbEstatusInv").ForeColor = Drawing.Color.DarkOrange
|
|
If UsuarioActual.Empresa.Funcionalidad(134).ToEntero = 1 Then ' si es la opcion ,de pagar lo proporcional
|
|
e.Row.FCCheckBox("Chk").Enabled = True
|
|
e.Row.FCTextBox("TxtAbonar").Enabled = True
|
|
End If
|
|
End If
|
|
End If
|
|
e.Row.FCLiteral("LtlAux").Text = String.Format("<a Class=""Texto thickbox"" href=""/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxPProveedor&CveProveedor={0}&CveCompra={1}&TB_iframe=true&height=370&width=900"" />Ir</a>", e.Row.DBCampo("CveProveedor"), e.Row.DBCampo("CveCompra"))
|
|
e.Row.FCTextBox("TxtAbonar").Attributes.Add("onblur", String.Format(" RNCAutocheck = true; FnCambia({0},this,{1},1,'{2}',1);{3}", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), "El Importe no debe de exceder el saldo", FiltroInv))
|
|
|
|
If Not PermiteModificarImporte Then e.Row.FCTextBox("TxtAbonar").Enabled = False
|
|
If e.Row.DBCampo("CveCompraNC").ToEntero > 0 Then
|
|
e.Row.FCHyperLink("HplNC").Visible = True
|
|
e.Row.FCHyperLink("HplNC").ImageUrl = "/Imagenes/flag_green.png"
|
|
e.Row.FCHyperLink("HplNC").ToolTip = "Notas de Crédito Aplicadas"
|
|
End If
|
|
If e.Row.DBCampo("ImporteProgramo").ToDouble > 0 Then
|
|
e.Row.FCCheckBox("chk").Checked = True
|
|
|
|
e.Row.FCTextBox("TxtAbonar").Text = e.Row.DBCampo("ImporteProgramo").ToDouble.FormatoNumero()
|
|
' N O T A: si el importe programado es mayor al Saldo de la factura, se pone el saldo
|
|
If e.Row.DBCampo("ImporteProgramo").ToDouble > e.Row.DBCampo("Saldo").ToDouble Then
|
|
e.Row.FCTextBox("TxtAbonar").ToolTip = "El importe programado es mayor al saldo. El Importe visible es el saldo "
|
|
'e.Row.FCTextBox("TxtAbonar").BackColor = Drawing.Color.OrangeRed
|
|
e.Row.FCTextBox("TxtAbonar").CssClass = "bg-yellow-gold"
|
|
e.Row.FCTextBox("TxtAbonar").Text = e.Row.DBCampo("Saldo").FormatoNumero()
|
|
'se va acumulando el importe de cada renglon para sacar el pago del IE
|
|
TxtImporte.Text = (TxtImporte.Text.ToDouble + e.Row.DBCampo("Saldo").ToDouble).FormatoNumero()
|
|
Else
|
|
'se va acumulando el importe de cada renglon para sacar el pago del IE
|
|
TxtImporte.Text = (TxtImporte.Text.ToDouble + e.Row.DBCampo("ImporteProgramo").ToDouble).FormatoNumero()
|
|
End If
|
|
End If
|
|
|
|
'si está bloqueada y es refacturación, debe de permitirlo, sin importar lo que se halla ingresado
|
|
If e.Row.DBCampo("CveCompraRefacturacion").ToEntero > 0 AndAlso Not e.Row.FCCheckBox("Chk").Enabled Then
|
|
e.Row.FCCheckBox("Chk").Enabled = True
|
|
e.Row.FCTextBox("TxtAbonar").Enabled = True
|
|
End If
|
|
If UsuarioActual.Empresa.Funcionalidad(306) = "1" And e.Row.DBCampo("AplicaNotaCredito").ToString = "True" Then
|
|
e.Row.FCCheckBox("Chk").Enabled = False
|
|
End If
|
|
e.Row.FCTextBox("TxtDescuento").Attributes.Add("onkeyup", $" calculaDescuentoEscalonado({e.Row.DBCampo("Saldo")},'{e.Row.FCTextBox("TxtDescuento").ClientID}',{e.Row.FCTextBox("TxtAbonar").ClientID},{e.Row.FCCheckBox("Chk").ClientID},'El Importe no debe de exceder el saldo',1)")
|
|
Else
|
|
e.Row.FCTextBox("TxtDescuento").Visible = False
|
|
End If
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " GUARDAR "
|
|
|
|
Protected Sub BtnIEGuardar_Click(sender As Object, e As EventArgs) Handles BtnIEGuardar.Click
|
|
|
|
|
|
Dim ValFechaDocumento As Boolean = False
|
|
Dim FoliosFechasValFechaDocumento As New StringBuilder
|
|
Dim sbRNC As New StringBuilder
|
|
|
|
FoliosFechasValFechaDocumento.AppendLine("Se seleccionaron facturas con fecha de mes superior al mes del pago: <br/>")
|
|
|
|
Dim sbDescuentos As New StringBuilder
|
|
|
|
For Each gvRowVal As GridViewRow In GvCxP.Rows
|
|
|
|
If gvRowVal.FCCheckBox("Chk").Checked Then
|
|
|
|
Dim FechaFactura As Date = gvRowVal.DataKey("Fecha").ToDate
|
|
Dim FechaDocumento As Date = TxtFechaDocumento.Text.ToDate
|
|
|
|
Dim AnioFactura As Integer = FechaFactura.Year
|
|
Dim MesFactura As Integer = FechaFactura.Month
|
|
|
|
Dim AnioDocumento As Integer = FechaDocumento.Year
|
|
Dim MesDocumento As Integer = FechaDocumento.Month
|
|
|
|
If UsuarioActual.Empresa.UsaAC = False Then
|
|
If AnioFactura > AnioDocumento Then
|
|
FoliosFechasValFechaDocumento.AppendLine($"Folio: { gvRowVal.DataKey("SerieFolio") } fecha: {gvRowVal.DataKey("Fecha").ToDate.ToString("dd/MM/yyyy") } <br/>")
|
|
ValFechaDocumento = True
|
|
ElseIf AnioFactura = AnioDocumento And MesFactura > MesDocumento Then
|
|
FoliosFechasValFechaDocumento.AppendLine($"Folio: { gvRowVal.DataKey("SerieFolio") } fecha: {gvRowVal.DataKey("Fecha").ToDate.ToString("dd/MM/yyyy") } <br/>")
|
|
ValFechaDocumento = True
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
Next
|
|
|
|
|
|
If ValFechaDocumento Then
|
|
Alert(FoliosFechasValFechaDocumento.ToString, TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
If DdlTipoTransaccion.SelectedValue.ToEntero < 0 Then
|
|
Alert("Seleccione un tipo de transacción", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
If DdlCuenta.SelectedValue.ToEntero < 0 Then
|
|
Alert("Seleccione una cuenta bancaria", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
If CveMoneda <= 0 Then
|
|
Alert("Seleccione la Moneda del pago", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim dtc As DataTable = GlobalDTProveedoresCuentas(UsuarioActual.CveEmpresa, CveProveedor:=CveProveedor)
|
|
If dtc IsNot Nothing Then
|
|
Dim Row As DataRow = dtc.FiltroPrimero(String.Format("CveCuentaDeposito = {0}", DdlCuentaDeposito.SelectedValue.ToEntero))
|
|
If Row IsNot Nothing AndAlso Row("Estatus").ToString = "False" Then
|
|
Alert("La cuenta depósito del proveedor esta inactiva.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
'proceso que restringue solo el pago de apartir del dia de hoy y como limite fin de mes
|
|
If UsuarioActual.TienePermisoProceso(105) AndAlso (TxtFechaDocumento.Text.ToDate < NowADS().Date Or TxtFechaDocumento.Text.ToDate > NowADS().LastDayOfMonth) Then
|
|
Alert("Fecha No permitida", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim ImporteSeleccionado As Decimal = 0
|
|
Dim ValidaSAT As Boolean = True
|
|
If UsuarioActual.Empresa.Funcionalidad(529) = "1" OrElse ChkNoValidaSAT.Checked Then ValidaSAT = False
|
|
|
|
If Not EsProduccion Then
|
|
ValidaSAT = False
|
|
End If
|
|
|
|
If ValidaSAT Then
|
|
Dim Validada As Boolean = False
|
|
Dim MsgValidadas As New StringBuilder
|
|
Dim Valida As New ClsValidaCFDi()
|
|
'verifico ante el SAT las compras que voy a pagar
|
|
For Each gvr As GridViewRow In GvCxP.Rows
|
|
If gvr.FCCheckBox("Chk").Checked Then
|
|
|
|
ImporteSeleccionado += gvr.FCTextBox("TxtAbonar").Text.ToDecimal
|
|
If gvr.DataKey("UUID") <> "" Then
|
|
|
|
Valida.Verificar(gvr.DataKey("UUID"), gvr.DataKey("RFC"), UsuarioActual.Empresa.RFC, gvr.DataKey("TotalOriginal").ToDecimal)
|
|
|
|
If Not UsuarioActual.Empresa.FacturaProduccion OrElse UsuarioActual.CveEmpresa < 2 Then
|
|
Valida.EsValida = 1
|
|
End If
|
|
|
|
If Valida.EsValida <> 1 Then
|
|
|
|
Validada = False
|
|
If Valida.EsValida = 2 Then 'Cancelada
|
|
'estatus inventario, no surtida
|
|
If gvr.DataKey("EstatusInventario") = "1" Then
|
|
MsgValidadas.AppendFormat("Factura Cancelada: {0} - {1} , relacione su factura nueva para descontar saldo<br>", gvr.DataKey("SerieFolio"), gvr.DataKey("Descripcion"))
|
|
Else
|
|
MsgValidadas.AppendFormat("Factura Cancelada: {0} - {1} con movimientos de almacen, relacione su factura nueva para descontar saldo<br>", gvr.DataKey("SerieFolio"), gvr.DataKey("Descripcion"))
|
|
End If
|
|
Else
|
|
MsgValidadas.AppendFormat("Factura No se pudo Validar: {0} - {1}<br>", gvr.DataKey("SerieFolio"), gvr.DataKey("Descripcion"))
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
Valida.Dispose()
|
|
|
|
'verificacion doble, si no la han cancelado, ya tiene una validaci[on para que llegue aqui
|
|
|
|
If MsgValidadas.Length > 0 Then
|
|
Alert(String.Format("<br>Las Facturas presentan la siguiente situación ante el SAT. <br>{0}", MsgValidadas.ToString), TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
Else
|
|
For Each gvr As GridViewRow In GvCxP.Rows
|
|
If gvr.FCCheckBox("Chk").Checked Then
|
|
ImporteSeleccionado += gvr.FCTextBox("TxtAbonar").Text.ToDecimal
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
If ImporteSeleccionado <= 0 Then
|
|
Alert("Seleccione facturas", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim ObjIE As New ClsBancos()
|
|
Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL)
|
|
Dim ObjComp As New ClsCompras(ObjIE.IniciaTransacSQL)
|
|
Dim ObjConta As ClsContPAQi = Nothing
|
|
If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaContabilidad Then
|
|
ObjConta = New ClsContPAQi(UsuarioActual.Empresa)
|
|
ObjConta.IniciaTransacSQL()
|
|
End If
|
|
Dim MsgError As String = ""
|
|
Dim IDPoliza As Integer = 0
|
|
Dim FolioPoliza As Integer = 0
|
|
Dim CveCuentaDeposito As Integer = 0
|
|
Dim CveConceptoCompra As Integer = 6
|
|
Dim CvePrePoliza As Integer = 0
|
|
Dim CveSubProyecto As Integer = -1
|
|
|
|
If DdlCuentaDeposito.Items.Count > 0 Then
|
|
CveCuentaDeposito = DdlCuentaDeposito.SelectedValue.ToEntero
|
|
End If
|
|
|
|
'Saca moneda en que se va a pagar segun metodo de pago
|
|
|
|
If DdlCuenta.SelectedValue.ToEntero > 0 Then
|
|
CveMoneda = GlobalDTBancosCuentas(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveMoneda", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveCuenta = {DdlCuenta.SelectedValue.ToEntero}").ToEntero
|
|
End If
|
|
|
|
If TxtImporte.Text.ToDouble > 0 Then
|
|
If TxtFolio.Text.Trim <> "" Then
|
|
|
|
Dim Fecha As Date = TxtFechaDocumento.Text.ToDate
|
|
Dim filesgral As List(Of Archivo) = Anexo.getfiles().Archivos
|
|
Dim filemove As String = ""
|
|
Dim Comprobante As String = ""
|
|
ComprobanteIE = ""
|
|
For Each fileItem As Archivo In filesgral
|
|
Comprobante = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
|
|
filemove = fileItem.filename
|
|
Next
|
|
Dim ConceptoPoliza As String = String.Format("{0} {1}", HplProveedor.Text, TxtObservaciones.Text)
|
|
Dim FolioFijo As Integer = 0
|
|
Dim TipoCambio As Decimal = 0
|
|
|
|
'cheque
|
|
If DdlTipoTransaccion.SelectedValue = "1" AndAlso UsuarioActual.CveEmpresa.Contiene(13, 83) Then FolioFijo = TxtFolio.Text.ToEntero
|
|
|
|
CvePrePoliza = ObjMov.AddPrePolizas("Bancos/ProveedoresAbonar", 2, ImporteSeleccionado, ImporteSeleccionado, 1, TxtFechaDocumento.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo:=FolioFijo, ReglaFolioPoliza:=ObjComp.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, Nothing, UsuarioActual.CveEmpresa), CveTipoPoliza:=ObjMov.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, "-1", UsuarioActual.CveEmpresa))
|
|
|
|
If CveMoneda = 2 Then
|
|
TipoCambio = TxtTC.Text.ToDecimal
|
|
Else
|
|
If TxtTC.Visible Then
|
|
TipoCambio = TxtTC.Text.ToDecimal
|
|
End If
|
|
End If
|
|
|
|
Dim CveIE As Integer = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFechaDocumento.Text.Trim.ToDate, TxtFolio.Text.Trim, TxtPagueseA.Text.Trim, TxtImporte.Text.ToDecimal, GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveMoneda", "CveCuenta = " & DdlCuenta.SelectedValue).ToEntero, TipoCambio, TxtObservaciones.Text.Trim, TxtNotificarA.Text.Trim, ChkAbonoCuenta.Checked, True, -1, CvePrePoliza, Comprobante, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCuentaDeposito:=CveCuentaDeposito, Referencia:=If(TxtReferenciaCIE.Visible, TxtReferenciaCIE.Text, "-1"), CveCuentaTarjeta:=If(DivTarjeta.Visible, DdlTarjeta.SelectedValue.ToEntero, -1), ConceptoCIE:=TxtConceptoCIE.Text)
|
|
|
|
If CveIE > 0 Then
|
|
ComprobanteIE = $"{CveIE}.{Comprobante}"
|
|
|
|
If DdlCuentaDeposito.SelectedValue.ToEntero > 0 And DdlTipoTransaccion.SelectedValue = "17" Then
|
|
|
|
If TxtReferenciaCIE.Text <> OriReferenciaCIE Or TxtConceptoCIE.Text <> OriConceptoCIE Then
|
|
|
|
Dim ObjGrales As New ClsGenerales(ObjIE.IniciaTransacSQL)
|
|
If Not ObjGrales.UpdateCuentasDepositosEstatusPagoElectronicoGrupos(DdlCuentaDeposito.SelectedValue.ToEntero, -1, -1, "-1", TxtReferenciaCIE.Text.Trim, TxtConceptoCIE.Text.Trim) Then
|
|
MsgError = "Error al actualizar cuenta Referencia y Concepto Deposito."
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
'guardo el archivo
|
|
If filemove <> "" Then
|
|
filemove.FilesMove(CveIE.ToString, String.Format("{0}IE", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False)
|
|
End If
|
|
|
|
Anexo.Text = ""
|
|
'inserto los movimientos de la conta para abonar al saldo
|
|
|
|
If CvePrePoliza > 0 Then
|
|
Dim Pago As New CompraPago
|
|
Pago.Fecha = TxtFechaDocumento.Text.ToDate
|
|
Pago.CveIE = CveIE
|
|
Pago.CveMonedaPago = CveMoneda
|
|
|
|
'inserto las compras que voy a pagar
|
|
Dim nRow As Integer = 1
|
|
For Each gvr As GridViewRow In GvCxP.Rows
|
|
If gvr.FCCheckBox("Chk").Checked Then
|
|
|
|
Dim CompraActual As New Compra
|
|
CompraActual.CveCompra = gvr.DataKey("CveCompra").ToEntero
|
|
CompraActual.CveTipoConceptoProveedor = gvr.DataKey("CveTipoConcepto").ToEntero
|
|
CompraActual.CveProveedor = gvr.DataKey("CveProveedor").ToEntero
|
|
CompraActual.CveMoneda = gvr.DataKey("CveMoneda").ToEntero
|
|
CompraActual.Fecha = gvr.DataKey("Fecha").ToDate
|
|
CompraActual.SerieFolio = gvr.DataKey("SerieFolio").ToString
|
|
CompraActual.ProveedorNombre = HplProveedor.Text
|
|
CompraActual.TC = gvr.DataKey("TipoCambioOriginal").ToDecimal
|
|
CompraActual.Total = gvr.DataKey("Total").ToDecimal
|
|
CompraActual.IVA = gvr.DataKey("IVA").ToDecimal
|
|
CompraActual.IVADeducible = gvr.DataKey("IVADeducible").ToDecimal
|
|
CompraActual.IVANoDeducible = gvr.DataKey("IVANoDeducible").ToDecimal
|
|
CompraActual.IVADeducible08 = gvr.DataKey("IVADeducible08").ToDecimal
|
|
CompraActual.IVANoDeducible08 = gvr.DataKey("IVANoDeducible08").ToDecimal
|
|
CompraActual.CompraNoDeducible = gvr.DataKey("NoDeducible").ToEntero
|
|
CompraActual.IEPS = gvr.DataKey("IEPS").ToDecimal
|
|
CompraActual.RetIVA = gvr.DataKey("RetIVA").ToDecimal
|
|
CompraActual.RetISR = gvr.DataKey("RetISR").ToDecimal
|
|
CompraActual.CveConceptoRetISR = gvr.DataKey("CveRetISRConcepto").ToEntero
|
|
CompraActual.CveConceptoRetIVA = gvr.DataKey("CveRetIVAConcepto").ToEntero
|
|
CompraActual.PorcentajeIVA = gvr.DataKey("PorcentajeIVA").ToDecimal
|
|
CompraActual.EsImportacion = gvr.DataKey("EsImportacion") = "1"
|
|
CompraActual.UsuarioActual = UsuarioActual
|
|
CompraActual.CveSubProyecto = gvr.DataKey("CveSubProyecto").ToEntero
|
|
|
|
|
|
|
|
'Importe de pago
|
|
Pago.ImportePago = gvr.FCTextBox("TxtAbonar").Text.ToDecimal
|
|
'Tipos de cambio
|
|
If Pago.CveMonedaPago = 1 AndAlso CompraActual.CveMoneda = 2 Then 'Si la venta viene en Dolares y se va a pagar en Pesos
|
|
Pago.TCPago = 1 ' TxtTC.Text.ToDecimal
|
|
Pago.ImportePago = (gvr.FCTextBox("TxtAbonar").Text.ToDecimal * TxtTC.Text.ToDecimal).RoundSQL
|
|
ElseIf Pago.CveMonedaPago = 2 AndAlso CompraActual.CveMoneda = 2 Then 'Si la venta viene en Dolares y se va a pagar en DOLARES
|
|
Pago.TCPago = TxtTC.Text.ToDecimal
|
|
ElseIf Pago.CveMonedaPago = 2 AndAlso CompraActual.CveMoneda = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
|
|
Pago.TCPago = TxtTC.Text.ToDecimal
|
|
Pago.ImportePago = (gvr.FCTextBox("TxtAbonar").Text.ToDecimal / TxtTC.Text.ToDecimal)
|
|
End If
|
|
|
|
If ChkPagarPesos.Checked Then
|
|
If CompraActual.CveMoneda = 1 Then
|
|
Pago.TCCambioMoneda = 1
|
|
Else
|
|
Pago.TCCambioMoneda = 1 / TxtTC.Text.ToDecimal
|
|
End If
|
|
End If
|
|
|
|
If ChkPagarDolares.Checked Then
|
|
Pago.TCCambioMoneda = TxtTC.Text.ToDecimal
|
|
End If
|
|
|
|
|
|
If gvr.FCTextBox("TxtComision").Text.ToDecimal <> 0 Then
|
|
Pago.OtroGastoIngreso = gvr.FCTextBox("TxtComision").Text.ToDecimal
|
|
Else
|
|
Pago.OtroGastoIngreso = 0
|
|
End If
|
|
|
|
If AplicaPrePolizaPagoCompra(CompraActual, Pago, CvePrePoliza, ObjMov) Then
|
|
MsgError = "No se pudo insertar la póliza"
|
|
Exit For
|
|
End If
|
|
|
|
'DESPROGRAMA LO PROGRAMADO DESPUES DE HACERLE UN PAGO
|
|
' If DdlTipoTransaccion.SelectedValue <> "9" Then 'SI ES LAYOUT SE DESPROGRAMA EN BANCOS/PAGOELECTRONICO, se comentó, 2018.07.31 peticion marilú.
|
|
If MsgError = "" AndAlso gvr.DataKey("ImporteProgramo").ToDouble > 0 Then
|
|
ObjComp.ProgramarCompra(gvr.DataKey("CveCompra").ToEntero, 0, UsuarioActual.CveUsuario, -1)
|
|
End If
|
|
|
|
|
|
'INICIO Descuento Remision Nota de credito
|
|
If UsuarioActual.Empresa.Funcionalidad(382) = "1" AndAlso UsuarioActual.Empresa.Funcionalidad(574) = "1" And ChkGeneraRNC.Checked Then
|
|
Dim descuentoParts As String() = gvr.FCTextBox("TxtDescuento").Text.Split("+"c)
|
|
Dim Descuento As Decimal = 0
|
|
Dim TotalTemp As Decimal = gvr.DataKey("Saldo").ToDecimal
|
|
|
|
If descuentoParts.Length = 0 Then
|
|
Descuento = 0
|
|
Else
|
|
Descuento = gvr.DataKey("Saldo").ToString.ToDecimal - gvr.FCTextBox("TxtAbonar").Text.ToDecimal
|
|
'For i As Integer = 0 To descuentoParts.Length - 1
|
|
' Dim descuentoPart As Decimal = descuentoParts(i).Trim().ToDecimal
|
|
' If descuentoPart > 0 Then
|
|
' Descuento = Descuento + ((TotalTemp - Descuento) * (descuentoPart / 100))
|
|
' Else
|
|
' Continue For
|
|
' End If
|
|
'Next
|
|
|
|
End If
|
|
|
|
If Descuento > 0 Then
|
|
|
|
Dim PorcentajeIVA As Decimal = gvr.DataKey("PorcentajeIVA").ToDecimal
|
|
Dim serieFolioArray As String() = gvr.DataKey("SerieFolio").ToString.Split("-"c)
|
|
Dim SerieRNC As String = ""
|
|
Dim FolioRNC As String = ""
|
|
|
|
Dim SerieFolioRNC As String = serieFolioArray(0)
|
|
If serieFolioArray.Length = 2 Then
|
|
SerieRNC = serieFolioArray(0)
|
|
FolioRNC = serieFolioArray(1)
|
|
SerieFolioRNC = $"D-{SerieRNC}-{ FolioRNC}"
|
|
|
|
Else
|
|
FolioRNC = serieFolioArray(0)
|
|
End If
|
|
|
|
'Descuento = Descuento.RoundSQL(2)
|
|
If PorcentajeIVA > 0 Then
|
|
|
|
Descuento = ((Descuento) / (1 + PorcentajeIVA))
|
|
'Descuento = ((Descuento) / (1 + PorcentajeIVA)).RoundSQL(2)
|
|
|
|
Dim saldo As Decimal = gvr.DataKey("Saldo").ToDecimal
|
|
Dim abonado As Decimal = gvr.FCTextBox("TxtAbonar").Text.ToDecimal
|
|
Dim TotalRNC = Descuento + (Descuento * PorcentajeIVA).RoundSQL
|
|
Dim dif As Decimal = saldo - (TotalRNC + abonado)
|
|
|
|
If dif.Abs() >= 0.01 Then
|
|
If dif > 0 Then
|
|
'Descuento = Descuento + 0.01D
|
|
End If
|
|
|
|
If dif < 0 Then
|
|
'Descuento = Descuento - 0.01D
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
|
|
Dim ExisteRNC As Boolean = False
|
|
If ObjComp.GetCompras(-1, $"D-{SerieRNC}", FolioRNC, CveProveedor, -1, UsuarioActual.CveEmpresa) Then
|
|
Dim dtRNC As DataTable = ObjComp.DtResultados.FiltraParametros(" TipoDocto ='RNC' ")
|
|
If dtRNC.Rows.Count > 0 Then
|
|
ExisteRNC = True
|
|
SerieFolioRNC = $"D{nRow}-{SerieRNC}-{ FolioRNC}"
|
|
End If
|
|
|
|
End If
|
|
|
|
Dim CveCompraRNC As Integer = GeneraRNC(Descuento, ObjComp.IniciaTransacSQL, gvr.DataKey("CveCompra").ToEntero, CompraActual, ObjMov, CvePrePoliza, CveProveedor, HplProveedor.Text, TxtFechaDocumento.Text.ToDate,
|
|
$"Remisión Nota de Crédito pago {gvr.DataKey("SerieFolio").ToString}", gvr.DataKey("CveMoneda").ToEntero, TxtTC.Text.ToDecimal, SerieRNC, FolioRNC, PorcentajeIVA:=PorcentajeIVA,
|
|
CveSubProyecto:=gvr.DataKey("CveSubProyecto").ToEntero, nRow:=nRow, ExisteRNC:=ExisteRNC)
|
|
|
|
If CveCompraRNC > 0 Then
|
|
|
|
sbRNC.AppendLine($"<a class='Texto' href='../Compras/Compras.aspx?CveCompra={CveCompraRNC}' > {SerieFolioRNC}</a><br>")
|
|
|
|
Else
|
|
'TieneError = True
|
|
MsgError = $"Error al Generar Remisión de Nota de Crédito de factura {gvr.DataKey("SerieFolio").ToString}"
|
|
Exit For
|
|
End If
|
|
End If
|
|
End If
|
|
'FIN Descuento Remision Nota de credito
|
|
|
|
|
|
|
|
End If
|
|
nRow = nRow + 1
|
|
Next
|
|
|
|
Dim UsaComplementariaBancos As Boolean = Not UsuarioActual.CveEmpresa.Contiene(7, 11, 122, 145, 13, 83)
|
|
Dim ConceptoMovimiento As String = $"{TxtPagueseA.Text.Trim} - {TxtObservaciones.Text} {If(Pago.TCPago > 1, $" TC:{Pago.TCPago}", "")}"
|
|
Dim Referencia As String = $"{HdnTipoTransaccionAbreviatura.Value}: {TxtFolio.Text.Trim}"
|
|
Dim tImporteMN As Decimal = TxtImporte.Text.ToDecimal
|
|
Pago.ImportePago = tImporteMN
|
|
|
|
Dim ImporteME As Decimal = 0
|
|
If Pago.CveMonedaPago = 2 Then ImporteME = Pago.ImportePago
|
|
If Not UsaComplementariaBancos And Pago.CveMonedaPago = 2 Then
|
|
ImporteME = tImporteMN
|
|
tImporteMN = (tImporteMN * Pago.TCPago).RoundSQL
|
|
End If
|
|
|
|
If MsgError = "" AndAlso Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePago, tImporteMN, 30, Referencia, ConceptoMovimiento, CveIE:=CveIE, CveProveedor:=CveProveedor, TipoCambio:=Pago.TCPago, CveSubProyecto:=CveSubProyecto, ImporteME:=ImporteME) Then
|
|
MsgError = "No se pudo insertar la póliza"
|
|
End If
|
|
|
|
If Pago.CveMonedaPago = 2 AndAlso UsaComplementariaBancos Then
|
|
If MsgError = "" AndAlso Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePago, (Pago.ImportePago * Pago.TCPago - Pago.ImportePago).RoundSQL, 204, Referencia, ConceptoMovimiento, CveIE:=CveIE, CveProveedor:=CveProveedor, ImporteME:=Pago.ImportePago, TipoCambio:=Pago.TCPago, CveSubProyecto:=CveSubProyecto) Then
|
|
MsgError = "No se pudo insertar la póliza"
|
|
End If
|
|
End If
|
|
|
|
If MsgError = "" AndAlso ObjMov.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual, Opcion:=5) Then
|
|
If ObjMov.ValorPolizaDescuadre > 0 Then
|
|
MsgError = ObjMov.MensajePolizaDescuadre + " " + ObjMov.ValorDiferencia
|
|
GuardaLogAD($"Bancos/ProveedoresAbonar | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
|
|
End If
|
|
End If
|
|
Else
|
|
MsgError = "No se pudo insertar la póliza"
|
|
End If
|
|
|
|
Else
|
|
MsgError = "No se insertó el encabezado"
|
|
End If
|
|
|
|
If MsgError = "" Then
|
|
'Alert("El Documento se guardó correctamente.", TipoMensaje.MsgInformacion, "window.close();")
|
|
|
|
Dim TieneError As Boolean = False
|
|
|
|
If UsuarioActual.Empresa.UsaAC Then
|
|
|
|
Dim Total As Double = TxtImporte.Text.ToDouble
|
|
|
|
If ChkACEjercer.Checked Then
|
|
Total = Total * 3
|
|
Else
|
|
Total = Total * 2
|
|
End If
|
|
|
|
Dim TipoChq As String = ""
|
|
If DdlTipoTransaccion.SelectedValue = "1" Then TipoChq = "CHQ"
|
|
'se multiplica por dos, porque se esta juntando el ejercido y el pagado al mismo tiempo
|
|
|
|
IDPoliza = ObjConta.AddPoliza(2, "Pagado " & TxtPagueseA.Text.Trim, Total, Total, UsuarioActual.CveUsuario, Fecha, TxtFolio.Text, TipoChq)
|
|
If IDPoliza > 0 Then
|
|
FolioPoliza = ObjConta.Folio
|
|
Dim ConceptoRenglon, Referencia As String
|
|
ConceptoRenglon = ""
|
|
Referencia = TxtFolio.Text
|
|
|
|
'NECESITO SACAR LAS PARTIDAS DE CADA PRESUPUESTO DE LAS FACTURAS PARA AFECTARLAS CON EL PAGO
|
|
Dim dtAC As New DataTable
|
|
dtAC.Columns.Add("PorcentajePago", Type.GetType("System.Double"))
|
|
Dim PorcentajePago As Double = 1
|
|
'Dim ComprasAC As New ClsCompras
|
|
For Each gvr As GridViewRow In GvCxP.Rows
|
|
If gvr.FCCheckBox("Chk").Checked Then
|
|
'obtengo su poliza para ver que presupuestos afecto
|
|
If gvr.DataKey("TotalOriginal").ToDouble > 0 Then PorcentajePago = gvr.FCTextBox("TxtAbonar").Text.ToDouble / gvr.DataKey("TotalOriginal").ToDouble Else PorcentajePago = 1
|
|
|
|
If ObjComp.GetPresupuestosCompras(gvr.DataKey("CveCompra").ToEntero) Then
|
|
dtAC.Merge(ObjComp.DtResultados)
|
|
|
|
If Not gvr.DataKey("Fecha").ToString.ToDate.Year < Fecha.Year Then ' SI ES EJERCICIO ANTERIOR LA COMPRA QUE EL EJERCICIO DEL PAGO NO AGREGA MOVIMIENTOS PRESUPUESTALES
|
|
For Each dr As DataRow In ObjComp.DtResultados.Rows
|
|
Total = dr("TotalPresupuesto").ToString.ToDouble * PorcentajePago
|
|
|
|
If Total > 0 Then
|
|
|
|
'EJERCIDO
|
|
If ChkACEjercer.Checked Then
|
|
|
|
ConceptoRenglon = String.Format("GE {0} Fact:{1}", TxtPagueseA.Text.Trim, gvr.DataKey("SerieFolio"))
|
|
If ObjConta.AddMovimiento(IDPoliza, dr("IdCuentaEjercido").ToString.ToEntero, False, Total, Referencia, ConceptoRenglon, 0, Fecha, "") Then
|
|
'actualizo el idcuenta del presupuesto
|
|
If Not ObjConta.AddMovimiento(IDPoliza, dr("IdCuentaDevengado").ToString.ToEntero, True, Total, Referencia, ConceptoRenglon, 0, Fecha, "") Then
|
|
TieneError = True : Exit For
|
|
End If
|
|
|
|
Else
|
|
TieneError = True : Exit For
|
|
End If
|
|
End If
|
|
|
|
'PAGADO
|
|
ConceptoRenglon = String.Format("GP {0} Fact:{1}", TxtPagueseA.Text.Trim, gvr.DataKey("SerieFolio"))
|
|
If ObjConta.AddMovimiento(IDPoliza, dr("IdCuentaPagado").ToString.ToEntero, False, Total, Referencia, ConceptoRenglon, 0, Fecha, "") Then
|
|
'actualizo el idcuenta del presupuesto
|
|
If Not ObjConta.AddMovimiento(IDPoliza, dr("IdCuentaEjercido").ToString.ToEntero, True, Total, Referencia, ConceptoRenglon, 0, Fecha, "") Then
|
|
TieneError = True : Exit For
|
|
End If
|
|
Else
|
|
TieneError = True : Exit For
|
|
End If
|
|
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
'AFECTA PROVEEDOR
|
|
Total = gvr.FCTextBox("TxtAbonar").Text.ToDouble
|
|
If Not ObjConta.AddMovimiento(IDPoliza, 0, False, Total, Referencia, ConceptoRenglon, 0, Fecha, "") Then
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
If Not TieneError Then
|
|
ConceptoRenglon = String.Format("GP {0} {1}", TxtPagueseA.Text.Trim, TxtObservaciones.Text)
|
|
Total = TxtImporte.Text.ToDouble
|
|
If Not ObjConta.AddMovimiento(IDPoliza, 0, True, Total, Referencia, ConceptoRenglon, 0, Fecha, "") Then
|
|
TieneError = True
|
|
End If
|
|
End If
|
|
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
End If
|
|
|
|
If Not TieneError AndAlso IDPoliza > 0 Then
|
|
'actualizar la conta del IE
|
|
ObjIE.UpdateIEPrePoliza(Fecha, FolioPoliza.ToString, IDPoliza, CvePrePoliza, CveIE, 0)
|
|
Else
|
|
IDPoliza = 0
|
|
End If
|
|
|
|
|
|
If Not TieneError Then
|
|
|
|
ObjIE.Commit()
|
|
If ObjConta IsNot Nothing Then ObjConta.Commit()
|
|
Anexo.Text = "[]"
|
|
|
|
Dim Msg As New StringBuilder
|
|
Msg.AppendFormat(" Folio: <a class=""Texto"" target='_blank' href=""/Bancos/IE.aspx?CveIE={0}"">{1}</a><br/> <br/> ", CveIE, TxtFolio.Text)
|
|
|
|
Msg.AppendFormat(" <a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Imprimir movimiento</a><br/> ", Encripta(String.Format("OP=IECHEQUE&CVEIE={0}", CveIE)))
|
|
|
|
Msg.AppendFormat(" <a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Listado</a><br/> ", Encripta(String.Format("OP=ImprimeMov&CveIE={0}", CveIE)))
|
|
If IDPoliza > 0 AndAlso UsuarioActual.Empresa.TipoContabilidad = 2 Then Msg.AppendFormat(" <a class=""Texto"" target='_blank' href=""/Contabilidad/RegPoliza.aspx?IdPoliza={0}"">Póliza</a><br/> ", IDPoliza)
|
|
|
|
If UsuarioActual.TienePermisoProceso(354) Then 'visualizar la póliza al registros
|
|
Msg.AppendFormat("<a Class=""Texto"" target='_blank' href=""/Contabilidad/RegPrePolizaS.aspx?CvePrePoliza={0}"">Ver Póliza</a> ", CvePrePoliza)
|
|
End If
|
|
|
|
|
|
If sbRNC.Length > 0 Then
|
|
Msg.AppendFormat($"<br>Remisiones de Nota de Crédito Generadas y Aplicadas<BR>{sbRNC.ToString}")
|
|
End If
|
|
|
|
Dim Mensaje As String = String.Format("El Documento se generó correctamente.<br /><br /> {0} ", Msg.ToString)
|
|
|
|
'LIMPIA
|
|
TxtFolio.Text = ""
|
|
TxtObservaciones.Text = ""
|
|
TxtImporte.Text = ""
|
|
TxtTotal.Text = ""
|
|
TxtFechaDocumento.Text = NowADS().ToShortDateString
|
|
DdlSelectedValue(DdlCuenta, "-1")
|
|
DdlSelectedValue(DdlTipoTransaccion, "-1")
|
|
Anexo.Text = "[]"
|
|
UpDatos.Update()
|
|
'upanexo.Update()
|
|
CargaDatos()
|
|
|
|
Alert(Mensaje.ToString, TipoMensaje.MsgInformacion, If(ChkSeguirRegistrando.Checked And GvCxP.Rows.Count > 0, "location.href =""#""", "location.href =""RepProveedoresPagos.aspx"""))
|
|
|
|
'Notificación de Pago
|
|
If TxtNotificarA.Text.Trim <> "" AndAlso ChkEnviarCorreo.Checked Then
|
|
'NotificacionPago(CveIE, TxtNotificarA.Text.Trim)
|
|
EnviarCorreoNotificacion(CveIE, TxtNotificarA.Text.Trim, "", UsuarioActual, False)
|
|
End If
|
|
|
|
End If
|
|
|
|
Else
|
|
ObjIE.RollBack()
|
|
If ObjConta IsNot Nothing Then ObjConta.RollBack()
|
|
Alert(MsgError, TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
ObjIE.Dispose()
|
|
ObjMov.Dispose()
|
|
ObjComp.Dispose()
|
|
If ObjConta IsNot Nothing Then ObjConta.Dispose()
|
|
Else
|
|
Alert("Debe de llevar un folio", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
Else
|
|
Alert("Debe de llevar un importe", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub DdlSelectedValue(Ddl As DropDownList, Valor As String)
|
|
If Ddl.Items.FindByValue(Valor) IsNot Nothing Then
|
|
Ddl.SelectedValue = Valor
|
|
Else
|
|
Ddl.SelectedIndex = 0
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " TIPO TRANSACCION "
|
|
Private Sub CargaTipoTransaccion()
|
|
If TipoPago = 1 Then
|
|
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo = 'Egs' AND CveTipoTransaccion IN (1, 2) and Estatus = 1 ")
|
|
DdlTipoTransaccion.DataBind()
|
|
DdlTipoTransaccion.SelectedValue = TipoPago.ToString
|
|
ElseIf TipoPago = 2 Then
|
|
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo = 'Egs' AND CveTipoTransaccion IN (1, 2) and Estatus = 1 ")
|
|
DdlTipoTransaccion.DataBind()
|
|
DdlTipoTransaccion.SelectedValue = TipoPago.ToString
|
|
RecargaCuentasDepositos()
|
|
ElseIf TipoPago = 3 Then
|
|
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo = 'Egs' AND CveTipoTransaccion IN (1, 2) and Estatus = 1 ")
|
|
DdlTipoTransaccion.DataBind()
|
|
DdlTipoTransaccion.SelectedValue = TipoPago.ToString
|
|
RecargaCuentasDepositos()
|
|
Else
|
|
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo = 'Egs' and Estatus = 1")
|
|
DdlTipoTransaccion.DataBind()
|
|
End If
|
|
|
|
If DdlTipoTransaccion.Items.Count > 1 Then DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1"))
|
|
End Sub
|
|
Protected Sub DdlTipoTransaccion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoTransaccion.SelectedIndexChanged
|
|
BtnIEGuardar.Enabled = True
|
|
|
|
'cuando es cheque
|
|
If DdlTipoTransaccion.SelectedValue = "1" Then
|
|
ChkAbonoCuenta.Visible = True
|
|
TxtPagueseA.Enabled = True
|
|
Else
|
|
ChkAbonoCuenta.Visible = False
|
|
TxtPagueseA.Enabled = False
|
|
End If
|
|
|
|
If DdlTipoTransaccion.SelectedValue.ToEntero.Contiene(9, 17) Then
|
|
ChkEnviarCorreo.Enabled = False
|
|
ChkEnviarCorreo.Checked = False
|
|
Else
|
|
ChkEnviarCorreo.Enabled = True
|
|
ChkEnviarCorreo.Checked = True
|
|
End If
|
|
|
|
CargaCuentas(DdlTipoTransaccion.SelectedValue.ToEntero)
|
|
RecargaCuentasDepositos()
|
|
|
|
ValidaFechaDocumentoDiasPosteriores()
|
|
|
|
UpGuardar.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " CUENTAS MOVTO "
|
|
Private Sub CargaCuentas(tTipoTransaccion As Integer)
|
|
DdlCuenta.Items.Clear()
|
|
Dim dt As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa)
|
|
|
|
If FiltrarCuentas = 1 Then
|
|
If ChkPagarPesos.Checked Then
|
|
dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", 1))
|
|
RegistraScript("CambiaPesosDolares();")
|
|
ElseIf ChkPagarDolares.Checked Then
|
|
dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", 2))
|
|
RegistraScript("CambiaDolaresPesos();")
|
|
Else
|
|
If CveMonedaFiltro > 0 Then
|
|
dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", CveMonedaFiltro))
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
If TipoPago = 3 Then
|
|
dt = dt.FiltraParametros("CveTipoCuenta = 7")
|
|
End If
|
|
|
|
'cuando es layout
|
|
If tTipoTransaccion = 9 Then
|
|
dt = dt.FiltraParametros("UsaLayout = 1")
|
|
End If
|
|
|
|
If tTipoTransaccion = 17 Then
|
|
dt = dt.FiltraParametros("UsaLayoutGrupos = 1")
|
|
End If
|
|
|
|
DdlCuenta.DataSource = dt
|
|
DdlCuenta.DataBind()
|
|
DdlCuenta.Items.Insert(0, New ListItem("Seleccione cuenta", "-1"))
|
|
End Sub
|
|
|
|
Protected Sub DdlCuenta_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuenta.SelectedIndexChanged
|
|
Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCuenta = {0}", DdlCuenta.SelectedValue))
|
|
|
|
If FiltrarCuentas = 0 Then
|
|
|
|
If dr("CveMoneda").ToString() = "2" Then
|
|
ChkPagarDolares.Visible = True
|
|
ChkPagarDolares.Checked = True
|
|
ChkPagarDolares.Enabled = False
|
|
|
|
ChkPagarPesos.Visible = False
|
|
ChkPagarPesos.Checked = False
|
|
Else
|
|
ChkPagarPesos.Visible = True
|
|
ChkPagarPesos.Checked = True
|
|
ChkPagarPesos.Enabled = False
|
|
|
|
ChkPagarDolares.Visible = False
|
|
ChkPagarDolares.Checked = False
|
|
End If
|
|
|
|
TxtTC.Text = GlobalTipoCambio(NowADS()).FormatoNumero(4)
|
|
TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);")
|
|
End If
|
|
|
|
'recargo la moneda con la que se va a pagar
|
|
|
|
If dr IsNot Nothing Then
|
|
TxtFechaDocumento.Attributes.Remove("onchange")
|
|
UpDatos.Update()
|
|
|
|
If ChkPagarPesos.Checked Then
|
|
CveMoneda = 2
|
|
RegistraScript("CambiaPesosDolares();")
|
|
Else
|
|
CveMoneda = dr("CveMoneda").ToString.ToEntero
|
|
If CveMoneda = 1 Then
|
|
RegistraScript("CambiaDolaresPesos();")
|
|
End If
|
|
|
|
End If
|
|
If CveMoneda = 2 Then
|
|
DivTC.Visible = True
|
|
TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);")
|
|
TxtTC.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4)
|
|
End If
|
|
End If
|
|
|
|
' si no tiene CveMoneda, o es -1, cuando cambia de cuenta filtra las facturas
|
|
If IfNull(Request("CveMoneda"), "-1").ToString.ToEntero = -1 Then CargaDatos(CveMoneda)
|
|
|
|
If HdnTipoTransaccion.Value = "Egs" AndAlso UsuarioActual.Empresa.Funcionalidad(505) <> "1" Then
|
|
Dim Folio As Long
|
|
Dim Banco As New ClsBancos
|
|
Folio = Banco.GetNextFolio(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero)
|
|
Banco.Dispose()
|
|
TxtFolio.Text = Folio.ToString
|
|
Else
|
|
TxtFolio.Text = ""
|
|
End If
|
|
|
|
'ValidaCuentasDepositoLayouts()
|
|
|
|
CargaCuentasDepositos()
|
|
|
|
'Dim dr2 As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("CveCuenta = " & DdlCuenta.SelectedValue)
|
|
'If dr2 IsNot Nothing Then
|
|
|
|
' If dr("UsaTarjeta").ToString = "True" Then
|
|
' CargaGridTarjetas()
|
|
' Else
|
|
' DivTarjeta.Visible = False
|
|
' End If
|
|
'End If
|
|
End Sub
|
|
|
|
'Function ValidaCuentasDepositoLayouts() As Boolean
|
|
|
|
' Dim Respuesta As Boolean = False
|
|
' Dim OpBanco As Integer = 1
|
|
|
|
' Dim CuentaBanco As String = DdlCuenta.SelectedItem.Text.ToUpper
|
|
|
|
' If CuentaBanco.Contains("BBVA") Or CuentaBanco.Contains("BANCOMER") Then
|
|
' OpBanco = 1
|
|
' 'ElseIf CuentaBanco.Contains("BAJIO") Then
|
|
' ' OpBanco = 2
|
|
' ElseIf CuentaBanco.Contains("SCOTIA") Then
|
|
' OpBanco = 3
|
|
' End If
|
|
|
|
|
|
' Dim dtc As DataTable = GlobalDTProveedoresCuentas(UsuarioActual.CveEmpresa, CveProveedor:=CveProveedor)
|
|
|
|
' If dtc IsNot Nothing Then
|
|
|
|
' If DdlTipoTransaccion.SelectedValue = "9" Then
|
|
|
|
' If OpBanco = 1 Then
|
|
' If dtc.Rows.Count > 0 Then
|
|
' DdlCuentaDeposito.DataSource = dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'")
|
|
' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
|
|
' End If
|
|
|
|
' If dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'").Rows.Count > 0 Then
|
|
' trCuentaDeposito.Visible = True
|
|
' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
|
|
' Else
|
|
' BtnIEGuardar.Enabled = False
|
|
' Alert("El Beneficiario no tiene una cuenta activa en BBVA, dela de alta o seleccione otro método de pago", TipoMensaje.MsgAdvertencia)
|
|
' End If
|
|
|
|
' ElseIf OpBanco = 3 Then
|
|
' If dtc.Rows.Count > 0 Then
|
|
' DdlCuentaDeposito.DataSource = dtc.FiltraParametros("EstatusPagoElectronicoScotia = 'True' AND Estatus ='True'")
|
|
' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
|
|
' End If
|
|
|
|
' If dtc.FiltraParametros("EstatusPagoElectronicoScotia = 'True' AND Estatus ='True'").Rows.Count > 0 Then
|
|
' trCuentaDeposito.Visible = True
|
|
' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
|
|
' Else
|
|
' BtnIEGuardar.Enabled = False
|
|
' Alert("El Beneficiario no tiene una cuenta activa en Scotiabank, dela de alta o seleccione otro método de pago", TipoMensaje.MsgAdvertencia)
|
|
' End If
|
|
' End If
|
|
' ElseIf DdlTipoTransaccion.SelectedValue = "17" Then
|
|
|
|
' If OpBanco = 1 Then
|
|
' If dtc.FiltraParametros(" EstatusPagoElectronicoGrupos = 'True' Estatus ='True'").Rows.Count > 0 Then
|
|
' DdlCuentaDeposito.DataSource = dtc.FiltraParametros(" EstatusPagoElectronicoGrupos = 'True' Estatus ='True'")
|
|
' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
|
|
' trCuentaDeposito.Visible = True
|
|
' BtnIEGuardar.ToolTip = ""
|
|
' Else
|
|
' BtnIEGuardar.Enabled = False
|
|
' BtnIEGuardar.ToolTip = "El proveedor no tiene cuentas deposito"
|
|
' Alert("El proveedor no tiene cuentas deposito.", TipoMensaje.MsgAdvertencia)
|
|
' End If
|
|
' 'ElseIf OpBanco = 3 Then
|
|
' ' If dtc.FiltraParametros(" EstatusPagoElectronicoGrupos = 'True' Estatus ='True'").Rows.Count > 0 Then
|
|
' ' DdlCuentaDeposito.DataSource = dtc.FiltraParametros(" EstatusPagoElectronicoGrupos = 'True' Estatus ='True'")
|
|
' ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
|
|
' ' trCuentaDeposito.Visible = True
|
|
' ' BtnIEGuardar.ToolTip = ""
|
|
' ' Else
|
|
' ' BtnIEGuardar.Enabled = False
|
|
' ' BtnIEGuardar.ToolTip = "El proveedor no tiene cuentas deposito"
|
|
' ' Alert("El proveedor no tiene cuentas deposito.", TipoMensaje.MsgAdvertencia)
|
|
' ' End If
|
|
' Else
|
|
' BtnIEGuardar.Enabled = False
|
|
' BtnIEGuardar.ToolTip = "El proveedor no tiene cuentas deposito para layout grupos"
|
|
' Alert("El proveedor no tiene cuentas deposito para layout grupos.", TipoMensaje.MsgAdvertencia)
|
|
' End If
|
|
|
|
|
|
|
|
' Else
|
|
' Respuesta = True
|
|
' DdlCuentaDeposito.DataSource = dtc.FiltraParametros("Estatus ='True'")
|
|
' If dtc.Rows.Count > 0 Then
|
|
' trCuentaDeposito.Visible = True
|
|
' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
|
|
' End If
|
|
' End If
|
|
' End If
|
|
|
|
|
|
|
|
' UpGuardar.Update()
|
|
|
|
' Return Respuesta
|
|
|
|
'End Function
|
|
|
|
|
|
|
|
'Private Sub CargaGridTarjetas()
|
|
' Dim ObjCreditos As New ClsBancos
|
|
' ObjCreditos.GetTarjetasCreditos(DdlCuenta.SelectedValue.ToEntero)
|
|
' DdlTarjeta.Items.Clear()
|
|
' DdlTarjeta.DataSource = ObjCreditos.DtResultados
|
|
' DdlTarjeta.DataBind()
|
|
' DdlTarjeta.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
' ObjCreditos.Dispose()
|
|
' DivTarjeta.Visible = True
|
|
'End Sub
|
|
#End Region
|
|
|
|
#Region " CUENTAS DEPOSITOS"
|
|
Private Sub CargaCuentasDepositos()
|
|
|
|
DdlCuentaDeposito.ClearSelection()
|
|
DdlCuentaDeposito.SelectedValue = Nothing
|
|
DdlCuentaDeposito.Items.Clear()
|
|
|
|
trCuentaDeposito.Visible = False
|
|
|
|
'Dim dtc As DataTable = GlobalDTProveedoresCuentas(UsuarioActual.CveEmpresa, CveProveedor:=CveProveedor)
|
|
'If dtc IsNot Nothing Then
|
|
|
|
' If dtc.FiltraParametros("Estatus ='True'").Rows.Count > 0 Then
|
|
|
|
' If DdlTipoTransaccion.SelectedValue = "9" Then
|
|
|
|
' If dtc.Rows.Count > 0 Then
|
|
' DdlCuentaDeposito.DataSource = dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'")
|
|
' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
|
|
' End If
|
|
|
|
' If dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'").Rows.Count > 0 Then
|
|
' trCuentaDeposito.Visible = True
|
|
' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
|
|
' Else
|
|
' 'BtnIEGuardar.Enabled = False
|
|
' 'Alert("El Beneficiario no tiene una cuenta activa en BBVA, dela de alta o seleccione otro método de pago", TipoMensaje.MsgAdvertencia)
|
|
' End If
|
|
|
|
' ElseIf DdlTipoTransaccion.SelectedValue = "17" Then
|
|
|
|
' If dtc.Rows.Count > 0 Then
|
|
' DdlCuentaDeposito.DataSource = dtc.FiltraParametros(" Estatus ='True'")
|
|
' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
|
|
' trCuentaDeposito.Visible = True
|
|
' BtnIEGuardar.ToolTip = ""
|
|
' Else
|
|
' 'BtnIEGuardar.Enabled = False
|
|
' 'BtnIEGuardar.ToolTip = "El proveedor no tiene cuentas deposito"
|
|
' 'Alert("El proveedor no tiene cuentas deposito.", TipoMensaje.MsgAdvertencia)
|
|
' End If
|
|
' UpGuardar.Update()
|
|
' Else
|
|
' DdlCuentaDeposito.DataSource = dtc.FiltraParametros("Estatus ='True'")
|
|
' If dtc.Rows.Count > 0 Then
|
|
' trCuentaDeposito.Visible = True
|
|
' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
|
|
' End If
|
|
' End If
|
|
' DdlCuentaDeposito.DataBind()
|
|
' Else
|
|
|
|
' If DdlTipoTransaccion.SelectedValue.Contiene("9", "17") Then
|
|
' 'BtnIEGuardar.Enabled = False
|
|
' 'BtnIEGuardar.ToolTip = "El proveedor no tiene cuentas deposito"
|
|
' 'Alert("El proveedor no tiene cuentas deposito.", TipoMensaje.MsgAdvertencia)
|
|
' Else
|
|
' trCuentaDeposito.Visible = True
|
|
' BtnIEGuardar.Enabled = True
|
|
' BtnIEGuardar.ToolTip = ""
|
|
' End If
|
|
' UpGuardar.Update()
|
|
' End If
|
|
'Else
|
|
|
|
' If DdlTipoTransaccion.SelectedValue = "17" Then
|
|
' BtnIEGuardar.Enabled = False
|
|
' BtnIEGuardar.ToolTip = "El proveedor no tiene cuentas deposito"
|
|
' Else
|
|
' trCuentaDeposito.Visible = True
|
|
' BtnIEGuardar.Enabled = True
|
|
' BtnIEGuardar.ToolTip = ""
|
|
' End If
|
|
|
|
' UpGuardar.Update()
|
|
'End If
|
|
|
|
'Else
|
|
' trCuentaDeposito.Visible = False
|
|
' DdlCuentaDeposito.Items.Clear()
|
|
'End If
|
|
'RecargaGlobalCuentasBancarias()
|
|
|
|
|
|
Dim OpBanco As Integer = 1
|
|
|
|
Dim CuentaBanco As String = DdlCuenta.SelectedItem.Text.ToUpper
|
|
|
|
If CuentaBanco.Contains("BBVA") Or CuentaBanco.Contains("BANCOMER") Then
|
|
OpBanco = 1
|
|
'ElseIf CuentaBanco.Contains("BAJIO") Then
|
|
' OpBanco = 2
|
|
ElseIf CuentaBanco.Contains("SCOTIA") Then
|
|
OpBanco = 3
|
|
End If
|
|
|
|
If DdlCuenta.SelectedValue = "-1" Then
|
|
BtnIEGuardar.Enabled = False
|
|
trCuentaDeposito.Visible = False
|
|
DdlCuentaDeposito.Items.Clear()
|
|
UpnCuentasPago.Update()
|
|
UpCuentaDeposito.Update()
|
|
Return
|
|
End If
|
|
|
|
|
|
Dim dtc As DataTable = GlobalDTProveedoresCuentas(UsuarioActual.CveEmpresa, CveProveedor:=CveProveedor)
|
|
|
|
If dtc IsNot Nothing Then
|
|
|
|
If DdlTipoTransaccion.SelectedValue = "9" Then
|
|
|
|
If OpBanco = 1 Then
|
|
If dtc.Rows.Count > 0 Then
|
|
DdlCuentaDeposito.DataSource = dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'")
|
|
DdlCuentaDeposito.DataBind()
|
|
End If
|
|
|
|
If dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'").Rows.Count > 0 Then
|
|
trCuentaDeposito.Visible = True
|
|
DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
|
|
Else
|
|
BtnIEGuardar.Enabled = False
|
|
Alert("El Beneficiario no tiene una cuenta activa en BBVA, dela de alta o seleccione otro método de pago", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
|
|
ElseIf OpBanco = 3 Then
|
|
If dtc.Rows.Count > 0 Then
|
|
DdlCuentaDeposito.DataSource = dtc.FiltraParametros("EstatusPagoElectronicoScotia = 'True' AND Estatus ='True'")
|
|
DdlCuentaDeposito.DataBind()
|
|
DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
|
|
End If
|
|
|
|
If dtc.FiltraParametros("EstatusPagoElectronicoScotia = 'True' AND Estatus ='True'").Rows.Count > 0 Then
|
|
trCuentaDeposito.Visible = True
|
|
DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
|
|
Else
|
|
BtnIEGuardar.Enabled = False
|
|
Alert("El Beneficiario no tiene una cuenta activa en Scotiabank, dela de alta o seleccione otro método de pago", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
ElseIf DdlTipoTransaccion.SelectedValue = "17" Then
|
|
|
|
If OpBanco = 1 Then
|
|
If dtc.FiltraParametros(" EstatusPagoElectronicoGrupos = 'True' AND Estatus ='True'").Rows.Count > 0 Then
|
|
DdlCuentaDeposito.DataSource = dtc.FiltraParametros(" EstatusPagoElectronicoGrupos = 'True' AND Estatus ='True'")
|
|
DdlCuentaDeposito.DataBind()
|
|
DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
|
|
trCuentaDeposito.Visible = True
|
|
BtnIEGuardar.ToolTip = ""
|
|
Else
|
|
BtnIEGuardar.Enabled = False
|
|
BtnIEGuardar.ToolTip = "El proveedor no tiene cuentas deposito"
|
|
Alert("El proveedor no tiene cuentas deposito.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
'ElseIf OpBanco = 3 Then
|
|
' If dtc.FiltraParametros(" EstatusPagoElectronicoGrupos = 'True' Estatus ='True'").Rows.Count > 0 Then
|
|
' DdlCuentaDeposito.DataSource = dtc.FiltraParametros(" EstatusPagoElectronicoGrupos = 'True' Estatus ='True'")
|
|
' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
|
|
' trCuentaDeposito.Visible = True
|
|
' BtnIEGuardar.ToolTip = ""
|
|
' Else
|
|
' BtnIEGuardar.Enabled = False
|
|
' BtnIEGuardar.ToolTip = "El proveedor no tiene cuentas deposito"
|
|
' Alert("El proveedor no tiene cuentas deposito.", TipoMensaje.MsgAdvertencia)
|
|
' End If
|
|
Else
|
|
BtnIEGuardar.Enabled = False
|
|
BtnIEGuardar.ToolTip = "El proveedor no tiene cuentas deposito para layout grupos"
|
|
Alert("El proveedor no tiene cuentas deposito para layout grupos.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
|
|
|
|
|
|
Else
|
|
'Respuesta = True
|
|
DdlCuentaDeposito.DataSource = dtc.FiltraParametros("Estatus ='True'")
|
|
DdlCuentaDeposito.DataBind()
|
|
|
|
If dtc.Rows.Count > 0 Then
|
|
trCuentaDeposito.Visible = True
|
|
DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
|
|
End If
|
|
BtnIEGuardar.Enabled = True
|
|
End If
|
|
End If
|
|
|
|
UpGuardar.Update()
|
|
UpnCuentasPago.Update()
|
|
UpCuentaDeposito.Update()
|
|
End Sub
|
|
Private Sub RecargaCuentasDepositos()
|
|
|
|
Dim dr As DataRow = GlobalDTTipoTransacciones.FiltroPrimero(String.Format("CveTipoTransaccion = {0}", DdlTipoTransaccion.SelectedValue)) 'Egs o Ing
|
|
If dr IsNot Nothing Then
|
|
HdnTipoTransaccion.Value = dr("Tipo").ToString
|
|
HdnTipoTransaccionAbreviatura.Value = dr("Abreviatura").ToString
|
|
End If
|
|
'cuando es transferencia bancaria, debe de solicitar a que cuenta se va a depositar
|
|
CargaCuentasDepositos()
|
|
End Sub
|
|
|
|
Protected Sub DdlCuentaDeposito_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
|
|
Dim dtc As DataTable = GlobalDTProveedoresCuentas(UsuarioActual.CveEmpresa, CveProveedor:=CveProveedor, CveCuentaDeposito:=DdlCuentaDeposito.SelectedValue.ToEntero)
|
|
If dtc IsNot Nothing AndAlso dtc.Rows.Count = 1 Then
|
|
|
|
If dtc.Rows.Count > 0 Then
|
|
|
|
If dtc.Rows(0)("TieneCIE").ToString.ToEntero = 1 Then
|
|
|
|
TrReferenciaCIE.Visible = True
|
|
|
|
TxtReferenciaCIE.Text = dtc.Rows(0)("Referencia").ToString
|
|
TxtConceptoCIE.Text = dtc.Rows(0)("ConceptoCIE").ToString
|
|
|
|
OriReferenciaCIE = dtc.Rows(0)("Referencia").ToString
|
|
OriConceptoCIE = dtc.Rows(0)("ConceptoCIE").ToString
|
|
|
|
Else
|
|
TrReferenciaCIE.Visible = False
|
|
End If
|
|
|
|
|
|
If Boolean.Parse(dtc.Rows(0)("EstatusPagoElectronicoGrupos").ToString) = True AndAlso dtc.Rows(0)("CveSATBanco").ToString.ToEntero <= 0 Then
|
|
|
|
Alert("Es necesario establecer el banco de la cuenta deposito", TipoMensaje.MsgAdvertencia)
|
|
BtnIEGuardar.Enabled = False
|
|
|
|
Else
|
|
BtnIEGuardar.Enabled = True
|
|
End If
|
|
|
|
Else
|
|
TrReferenciaCIE.Visible = False
|
|
End If
|
|
|
|
Else
|
|
TrReferenciaCIE.Visible = False
|
|
End If
|
|
|
|
UpCuentaDeposito.Update()
|
|
UpGuardar.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
Protected Sub DdllOtrosPagos_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlOtrosPagos.SelectedIndexChanged
|
|
|
|
If DdlOtrosPagos.SelectedValue <> "-1" Then
|
|
DdlProsepago.Visible = False
|
|
TxtOtrosImportes.Visible = True
|
|
TxtTotal.Visible = True
|
|
GvCxP.Columns(13).Visible = True
|
|
Else
|
|
DdlProsepago.Visible = False
|
|
TxtOtrosImportes.Visible = False
|
|
TxtTotal.Visible = False
|
|
GvCxP.Columns(13).Visible = False
|
|
TxtOtrosImportes.Text = ""
|
|
TxtTotal.Text = ""
|
|
RegistraScript("$get('TxtImporte').value = FormatoNumero(SumaValores(), 2);")
|
|
End If
|
|
|
|
UpDatos.Update()
|
|
UPCompras.Update()
|
|
End Sub
|
|
|
|
|
|
#Region " PAGAR CON PESOS "
|
|
Protected Sub ChkPagarPesos_CheckedChanged(sender As Object, e As EventArgs)
|
|
If ChkPagarPesos.Checked Then
|
|
DivTC.Visible = True
|
|
CargaCuentas(DdlTipoTransaccion.SelectedValue.ToEntero)
|
|
TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);")
|
|
TxtTC.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4)
|
|
TxtTC.Attributes.Add("onblur", "CambiaPesosDolares()")
|
|
Else
|
|
DivTC.Visible = False
|
|
CargaCuentas(DdlTipoTransaccion.SelectedValue.ToEntero)
|
|
TxtFechaDocumento.Attributes.Remove("onchange")
|
|
End If
|
|
UpDatos.Update()
|
|
|
|
RegistraScript("CambiaPesosDolares();")
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "PAGAR CON DOLARES"
|
|
Protected Sub ChkPagarDolares_CheckedChanged(sender As Object, e As EventArgs)
|
|
If ChkPagarDolares.Checked Then
|
|
|
|
'DivDolaresDolares.Visible = False
|
|
CargaCuentas(DdlTipoTransaccion.SelectedValue.ToEntero)
|
|
TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);")
|
|
TxtTC.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4)
|
|
TxtTC.Attributes.Add("onblur", "CambiaDolaresPesos()")
|
|
Else
|
|
'DivDolaresDolares.Visible = False
|
|
CargaCuentas(DdlTipoTransaccion.SelectedValue.ToEntero)
|
|
TxtFechaDocumento.Attributes.Remove("onchange")
|
|
End If
|
|
UpDatos.Update()
|
|
|
|
RegistraScript("CambiaDolaresPesos();")
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " NOTIFICACION PAGO "
|
|
|
|
|
|
Private Sub EnviarCorreoNotificacion(CveIENotificar As Integer, CorreoNotificarA As String, CopiaPara As String, UsuarioActualNotificar As Usuario, MostarAlert As Boolean)
|
|
|
|
Try
|
|
EnviarCorreoNotificacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar)
|
|
'Dim Hilo As New Threading.Thread(Sub() EnviarCorreoNotificacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar))
|
|
'Dim Hilo As New Threading.Thread( EnviarCorreoNotifiMandaCorreocacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar))
|
|
'Hilo.Start()
|
|
|
|
If MostarAlert Then
|
|
Alert("El correo se envió correctamente", TipoMensaje.ToastInformacion)
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
If MostarAlert Then
|
|
Alert("No se pudo enviar el correo electrónico.", TipoMensaje.MsgError)
|
|
End If
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub EnviarCorreoNotificacionHilo(CveIENotificar As Integer, CorreoNotificarA As String, CopiaPara As String, UsuarioActualNotificar As Usuario)
|
|
|
|
Try
|
|
Dim ObjBancos As New ClsBancos()
|
|
|
|
If ObjBancos.NotificacionPago(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar) Then
|
|
Alert("El correo se envió correctamente", TipoMensaje.ToastInformacion)
|
|
Else
|
|
Alert("No se pudo enviar el correo electrónico.", TipoMensaje.MsgError)
|
|
End If
|
|
ObjBancos.Dispose()
|
|
Catch ex As Exception
|
|
GuardaLog("Error al enviar notificación de pago ProveedoresAbonar --> " & ex.StackTrace.ToString)
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "SALDAR CUENTAS"
|
|
|
|
Private Sub BtnSaldarCuentasSinPagar_Click(sender As Object, e As EventArgs) Handles BtnSaldarCuentasSinPagar.Click
|
|
Dim ObjConta As New ClsContabilidad
|
|
ObjConta.IniciaTransacSQL()
|
|
Dim CvePrePoliza As Integer = 0
|
|
Dim MsgError As String = ""
|
|
Dim FuncionalidadFluctuacionImpuestos As Boolean = If(UsuarioActual.Empresa.Funcionalidad(159) = "1", True, False)
|
|
|
|
Dim EsContabilizable As Boolean = If(UsuarioActual.CveEmpresa.Contiene(13, 83), False, True)
|
|
|
|
CvePrePoliza = ObjConta.AddPrePolizas("Bancos/ProveedoresAbonar/Saldar", 98, 0, 0, 1, TxtFechaIncobrable.Text.ToDate, "Saldado de facturas", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
For Each gr As GridViewRow In GvCxP.Rows
|
|
If gr.FCCheckBox("Chk").Checked Then
|
|
Dim Saldo As Decimal = gr.FCTextBox("TxtAbonar").Text.ToDecimal 'gr.DataKey("Saldo").ToDecimal
|
|
Dim TCCompra As Decimal = gr.DataKey("TipoCambio").ToDecimal
|
|
Dim TCPago As Decimal = GlobalTipoCambio(TxtFechaIncobrable.Text.ToDate).ToDecimal
|
|
Dim CveMoneda As Integer = gr.DataKey("CveMoneda").ToEntero
|
|
Dim FechaCompra As Date = gr.DataKey("Fecha").ToDate
|
|
Dim CveSubProyecto As Integer = gr.DataKey("CveSubProyecto").ToEntero
|
|
|
|
Dim CveConceptoContablePago As Integer = 17
|
|
If gr.DataKey("CveTipoConcepto").ToEntero = 2 Then CveConceptoContablePago = 308 'cuando es acreedor
|
|
If CveMoneda <> 1 Then
|
|
Select Case CveConceptoContablePago
|
|
Case 17
|
|
CveConceptoContablePago = 312
|
|
Case 308
|
|
CveConceptoContablePago = 309
|
|
Case Else
|
|
End Select
|
|
End If
|
|
|
|
Dim CveConceptoContableComplementaria As Integer = 206
|
|
If gr.DataKey("CveTipoConcepto").ToEntero = 2 Then CveConceptoContableComplementaria = 310 'cuando es acreedor
|
|
|
|
Dim ConceptoPartida As String = String.Format("Saldar compra {0}", gr.DataKey("SerieFolio").ToString)
|
|
|
|
|
|
If CveMoneda > 1 Then
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Saldo, Saldo, CveConceptoContablePago, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, TipoCambio:=TCCompra, ImporteME:=If(CveMoneda > 1, Saldo, 0), Contabilizable:=EsContabilizable) Then
|
|
MsgError = "Ocurrio un error al saldar el movimiento"
|
|
End If
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, 0.00D, (Saldo * TCCompra - Saldo).RoundSQL, CveConceptoContableComplementaria, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, ImporteME:=Saldo, TipoCambio:=TCCompra, Contabilizable:=EsContabilizable) Then
|
|
MsgError = "No se pudo insertar la póliza"
|
|
End If
|
|
Else
|
|
TCPago = 1
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Saldo, If(CveMoneda = 1, Saldo, Saldo * TCCompra), CveConceptoContablePago, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, ImporteME:=If(CveMoneda > 1, Saldo, 0), TipoCambio:=TCCompra, Contabilizable:=EsContabilizable) Then
|
|
MsgError = "Ocurrio un error al saldar el movimiento"
|
|
End If
|
|
End If
|
|
Dim PorcentajePago As Decimal = Saldo / gr.DataKey("TotalOriginal").ToDecimal
|
|
|
|
If MsgError = "" AndAlso gr.DataKey("IVA").ToDecimal > 0 Then
|
|
Dim PorcentajeImpuesto As Decimal = gr.DataKey("PorcentajeIVA").ToDecimal
|
|
Dim IVA As Decimal = PorcentajePago * gr.DataKey("IVA").ToDecimal
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IVA, If(CveMoneda = 1, IVA, IVA * If(FuncionalidadFluctuacionImpuestos, TCPago, TCCompra)), 14, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, PorcentajeImpuesto:=PorcentajeImpuesto, Contabilizable:=EsContabilizable) Then
|
|
MsgError = "Ocurrio un error al saldar el movimiento"
|
|
End If
|
|
Saldo = Saldo - IVA
|
|
End If
|
|
|
|
If MsgError = "" AndAlso gr.DataKey("IEPS").ToDecimal > 0 Then
|
|
|
|
Dim IEPS As Decimal = PorcentajePago * gr.DataKey("IEPS").ToDecimal
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IEPS, If(CveMoneda = 1, IEPS, IEPS * If(FuncionalidadFluctuacionImpuestos, TCPago, TCCompra)), 25, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, Contabilizable:=EsContabilizable) Then
|
|
MsgError = "Ocurrio un error al saldar el movimiento"
|
|
End If
|
|
Saldo = Saldo - IEPS
|
|
End If
|
|
|
|
' se manda al ot ingresos, los impuestos por acreditar
|
|
If MsgError = "" Then
|
|
Dim tcvecon As Integer = 78
|
|
Dim tTipoMovto As Boolean = True
|
|
If Saldo < 0 Then
|
|
tcvecon = 211
|
|
tTipoMovto = False
|
|
End If
|
|
If MsgError = "" AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, tTipoMovto, Saldo, (Saldo * TCPago).RoundSQL, tcvecon, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, TipoCambio:=TCCompra, TipoCambioPago:=TCPago, CveSubProyecto:=CveSubProyecto, Contabilizable:=EsContabilizable) Then
|
|
MsgError = "Ocurrio un error al saldar el movimiento"
|
|
End If
|
|
End If
|
|
|
|
'fluctuación.
|
|
If CveMoneda > 1 Then
|
|
Dim ImporteFluctuacion As Decimal = 0
|
|
ImporteFluctuacion = Saldo * (TCPago - TCCompra)
|
|
|
|
If CveSubProyecto <= 0 Then MsgError = "No se pudo obtener el sub proyecto o centro de costo"
|
|
|
|
If TCCompra > TCPago Then
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Math.Abs(ImporteFluctuacion), Math.Abs(ImporteFluctuacion), 64, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveSubProyecto:=CveSubProyecto, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, TipoCambio:=TCCompra, TipoCambioPago:=TCPago, Contabilizable:=EsContabilizable) Then
|
|
MsgError = "Ocurrio un error al saldar el movimiento"
|
|
End If
|
|
Else
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Math.Abs(ImporteFluctuacion), Math.Abs(ImporteFluctuacion), 65, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveSubProyecto:=CveSubProyecto, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, TipoCambio:=TCCompra, TipoCambioPago:=TCPago, Contabilizable:=EsContabilizable) Then
|
|
MsgError = "Ocurrio un error al saldar el movimiento"
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
If MsgError.Trim.Length = 0 AndAlso CvePrePoliza > 0 Then
|
|
If MsgError = "" AndAlso ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual, 5) Then
|
|
If ObjConta.ValorPolizaDescuadre > 0 Then
|
|
MsgError = ObjConta.MensajePolizaDescuadre + " " + ObjConta.ValorDiferencia
|
|
GuardaLogAD($"Bancos/ProveedoresAbonar | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
If MsgError = "" Then
|
|
ObjConta.Commit()
|
|
CargaDatos(CveMoneda)
|
|
RegistraScript("$('#ModalSaldarCuentaSinPagar').modal('hide')")
|
|
Dim Msg As New StringBuilder
|
|
Msg.Append("Los movimientos se saldaron correctamente.</br>")
|
|
|
|
If UsuarioActual.TienePermisoProceso(354) Then 'visualizar la póliza al registros
|
|
Msg.AppendFormat("<a Class=""Texto"" target='_blank' href=""/Contabilidad/RegPrePolizaS.aspx?CvePrePoliza={0}"">Ver Póliza</a> ", CvePrePoliza)
|
|
End If
|
|
Alert(Msg.ToString)
|
|
|
|
Else
|
|
ObjConta.RollBack()
|
|
Alert(MsgError, TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjConta.Dispose()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "GENERAR SOLICITUD"
|
|
Protected Sub LnkPDFSolicitud_Click(sender As Object, e As EventArgs)
|
|
GenerarPDFSolicitud("PDF")
|
|
End Sub
|
|
Protected Sub LnkExcelSolicitud_Click(sender As Object, e As EventArgs)
|
|
GenerarPDFSolicitud("EXCEL")
|
|
End Sub
|
|
Private Sub GenerarPDFSolicitud(Opcion As String)
|
|
If DtDatos.Rows.Count > 0 Then
|
|
Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
|
|
|
|
Dim StrImporte As String = DtDatos.Rows(0)("Saldo").ToString.FormatoNumero
|
|
Dim params As New List(Of ReportParameter)
|
|
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
|
params.Add(New ReportParameter("FechaImpresion", NowADS().ToDateTime.ToString))
|
|
params.Add(New ReportParameter("Sucursal", DtDatos.Rows(1)("SubProyecto").ToString))
|
|
params.Add(New ReportParameter("Importe", $"${StrImporte}"))
|
|
params.Add(New ReportParameter("RazonSocial", TxtPagueseA.Text))
|
|
params.Add(New ReportParameter("Fecha", TxtFechaDocumento.Text))
|
|
Dim Transferencia As String = "", Banco As String = "", CLABE As String = "", Cuenta As String = "", Correo As String = ""
|
|
If DdlTipoTransaccion.SelectedValue.Contiene("2", "8") Then Transferencia = "Si" Else Transferencia = "No"
|
|
If DdlCuentaDeposito.SelectedValue.ToEntero > 0 Then
|
|
Dim dtt As DataTable = GlobalDTProveedoresCuentas(UsuarioActual.CveEmpresa, CveProveedor, CveCuentaDeposito:=DdlCuentaDeposito.SelectedValue.ToEntero)
|
|
If dtt.Rows.Count > 0 Then
|
|
Banco = dtt.Rows(0)("BancoNombre").ToString
|
|
CLABE = dtt.Rows(0)("CLABE").ToString
|
|
Cuenta = dtt.Rows(0)("Cuenta").ToString
|
|
Correo = dtt.Rows(0)("Correo").ToString
|
|
End If
|
|
End If
|
|
|
|
params.Add(New ReportParameter("Transferencia", Transferencia))
|
|
params.Add(New ReportParameter("Banco", Banco))
|
|
params.Add(New ReportParameter("CLABE", CLABE))
|
|
params.Add(New ReportParameter("Cuenta", Cuenta))
|
|
params.Add(New ReportParameter("Correo", Correo))
|
|
params.Add(New ReportParameter("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", "")))
|
|
Dim NombreArchivo As String = "SolicitudPago" ''String.Format("SolicitudPago{0}.pdf", TxtPagueseA.Text).Replace(" ", "")
|
|
ImprimirPDF("Empresas/Grales/Formatos/Solicitud.rdlc", DtDatos, params, NombreArchivo, Opcion)
|
|
Else
|
|
Alert("No se encontraron datos.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
Private Sub RVTxtFechaDocumento_Init(sender As Object, e As EventArgs) Handles RVTxtFechaDocumento.Init
|
|
RVTxtFechaDocumento.MaximumValue = NowADS().AddDays(2).ToShortDateString
|
|
RVTxtFechaDocumento.MinimumValue = NowADS().AddMonths(-38).ToShortDateString
|
|
'RVTxtFechaDocumentoMenor.MinimumValue = NowADS().AddMonths(-38).ToShortDateString
|
|
'RVTxtFechaDocumentoMenor.MaximumValue = NowADS().AddDays(2).ToShortDateString
|
|
Calendario.EndDate = NowADS().AddDays(2)
|
|
|
|
End Sub
|
|
|
|
Private Sub ValidaFechaDocumentoDiasPosteriores()
|
|
|
|
|
|
RVTxtFechaDocumento.MaximumValue = NowADS().AddDays(3).ToShortDateString
|
|
'RVTxtFechaDocumentoMenor.MaximumValue = NowADS().AddDays(3).ToShortDateString
|
|
RVTxtFechaDocumento.ErrorMessage = "<b><span style='text-decoration: underline'>ERROR:</span></b> <br/> La fecha del documento no puede ser superior a 3 días de la fecha actual"
|
|
|
|
Calendario.EndDate = NowADS().AddDays(3)
|
|
|
|
If DdlTipoTransaccion.SelectedValue.Contiene("1", "16") Then 'cheques, 3meses
|
|
RVTxtFechaDocumento.MaximumValue = NowADS().AddMonths(3).ToShortDateString
|
|
RVTxtFechaDocumento.ErrorMessage = "<b><span style='text-decoration: underline'>ERROR:</span></b> <br/> La fecha del documento no puede ser superior a 3 meses de la fecha actual"
|
|
Calendario.EndDate = NowADS().AddMonths(3)
|
|
End If
|
|
If DdlTipoTransaccion.SelectedValue = "2" Then 'transfer, 3semanas
|
|
RVTxtFechaDocumento.MaximumValue = NowADS().AddDays(21).ToShortDateString
|
|
RVTxtFechaDocumento.ErrorMessage = "<b><span style='text-decoration: underline'>ERROR:</span></b> <br/> La fecha del documento no puede ser superior a 3 semanas de la fecha actual"
|
|
Calendario.EndDate = NowADS().AddDays(21)
|
|
End If
|
|
|
|
UpDatos.Update()
|
|
UpGuardar.Update()
|
|
|
|
End Sub
|
|
|
|
|
|
Protected Sub chkaplicaDescuento_CheckedChanged(sender As Object, e As EventArgs)
|
|
|
|
GvCxP.Columns(11).Visible = chkaplicaDescuento.Checked
|
|
TxtDescuenoMasivo.Visible = chkaplicaDescuento.Checked
|
|
ChkGeneraRNC.Visible = chkaplicaDescuento.Checked
|
|
UPCompras.Update()
|
|
End Sub
|
|
|
|
|
|
|
|
Private Sub tmpValida()
|
|
|
|
Dim ValidaSAT As Boolean = True
|
|
Dim ImporteSeleccionado As Decimal = 0
|
|
'If UsuarioActual.Empresa.Funcionalidad(529) = "1" OrElse ChkNoValidaSAT.Checked Then ValidaSAT = False
|
|
|
|
If ValidaSAT Then
|
|
Dim Validada As Boolean = False
|
|
Dim MsgValidadas As New StringBuilder
|
|
Dim Valida As New ClsValidaCFDi()
|
|
'verifico ante el SAT las compras que voy a pagar
|
|
For Each gvr As GridViewRow In GvCxP.Rows
|
|
If gvr.FCCheckBox("Chk").Checked Then
|
|
|
|
ImporteSeleccionado += gvr.FCTextBox("TxtAbonar").Text.ToDecimal
|
|
If gvr.DataKey("UUID") <> "" Then
|
|
|
|
Valida.Verificar(gvr.DataKey("UUID"), gvr.DataKey("RFC"), UsuarioActual.Empresa.RFC, gvr.DataKey("TotalOriginal").ToDecimal)
|
|
|
|
If Not UsuarioActual.Empresa.FacturaProduccion OrElse UsuarioActual.CveEmpresa < 2 Then
|
|
Valida.EsValida = 1
|
|
End If
|
|
|
|
If Valida.EsValida <> 1 Then
|
|
|
|
Validada = False
|
|
If Valida.EsValida = 2 Then 'Cancelada
|
|
'estatus inventario, no surtida
|
|
If gvr.DataKey("EstatusInventario") = "1" Then
|
|
MsgValidadas.AppendFormat("Factura Cancelada: {0} - {1} , relacione su factura nueva para descontar saldo<br>", gvr.DataKey("SerieFolio"), gvr.DataKey("Descripcion"))
|
|
Else
|
|
MsgValidadas.AppendFormat("Factura Cancelada: {0} - {1} con movimientos de almacen, relacione su factura nueva para descontar saldo<br>", gvr.DataKey("SerieFolio"), gvr.DataKey("Descripcion"))
|
|
End If
|
|
Else
|
|
MsgValidadas.AppendFormat("Factura No se pudo Validar: {0} - {1}<br>", gvr.DataKey("SerieFolio"), gvr.DataKey("Descripcion"))
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
Valida.Dispose()
|
|
|
|
'verificacion doble, si no la han cancelado, ya tiene una validaci[on para que llegue aqui
|
|
|
|
If MsgValidadas.Length > 0 Then
|
|
Alert(String.Format("<br>Las Facturas presentan la siguiente situación ante el SAT. <br>{0}", MsgValidadas.ToString), TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
Else
|
|
For Each gvr As GridViewRow In GvCxP.Rows
|
|
If gvr.FCCheckBox("Chk").Checked Then
|
|
ImporteSeleccionado += gvr.FCTextBox("TxtAbonar").Text.ToDecimal
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
If ImporteSeleccionado <= 0 Then
|
|
Alert("Seleccione facturas", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Protected Sub BtnCambiarProveedor_Click(sender As Object, e As EventArgs)
|
|
If DdlProveedores.SelectedValue.ToEntero() <= 0 Then
|
|
Alert("Debe seleccionar un proveedor", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
Dim url As String = String.Format("/Bancos/ProveedoresAbonar.aspx?CveProveedor={0}&FechaI={1}&FechaF={2}&CveUsuarioProgramo={3}&TipoPago={4}&CveUsuarioRegistro={5}&CveUsuarioResponsable={6}&CveClasificacion={7}&CveMoneda={8}&CveEstatus={9}&CveProveedorSucursal={10}&CveAplicaNC={11}&CodigoProgramacion={12}&CveSubProyecto={13}", DdlProveedores.SelectedValue, Request("FechaI").ToString(), Request("FechaF").ToString(), Request("CveUsuarioProgramo").ToString(), -1, Request("CveUsuarioRegistro").ToString(), Request("CveUsuarioResponsable").ToString(), Request("CveClasificacion").ToString(), Request("CveMoneda").ToString(), Request("CveEstatus").ToString(), Request("CveProveedorSucursal").ToString(), Request("CveAplicaNC").ToString(), Request("CodigoProgramacion").ToString(), Request("CveSubProyecto").ToString())
|
|
Response.Redirect(url)
|
|
End Sub
|
|
|
|
|
|
Public Function GeneraRNC(ImporteRNC As Decimal, ByRef sqltransaccion As SqlTransaction, CveCompraAmortizada As Integer, ByRef CompraActual As Compra, ByRef ObjConta As ClsContabilidad, CvePrePoliza As Integer,
|
|
CveProveedor As Integer, NombreProveedor As String, Fecha As Date, Descripcion As String, CveMoneda As Integer, TipoCambio As Decimal, Serie As String, Folio As String, Optional EsDRMN As Boolean = False,
|
|
Optional TmpListadoPS As DataTable = Nothing, Optional PorcentajeIVA As Decimal = 0, Optional CveSubProyecto As Integer = -1, Optional nRow As Integer = -1, Optional ExisteRNC As Boolean = False) As Integer
|
|
Dim CveCompraRNC As Integer = -1
|
|
Dim respuesta As Boolean = True
|
|
'Dim PorcentajeIVA As Decimal = TmpDT.MAX("IVAPorcentaje").ToDecimal
|
|
|
|
Dim CvePS_RNC As Integer = UsuarioActual.Empresa.Funcionalidad(580).ToEntero
|
|
Dim PSRow As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=CvePS_RNC).FiltroPrimero("")
|
|
Dim CveSubProyectoPrincipal As Integer = CveSubProyecto 'AsignarSubProyectoPrincipal()
|
|
Dim SubProyecto As String = ""
|
|
|
|
If Not CvePS_RNC > 0 Then
|
|
Alert("No esta definido el producto de Remisión de Nota de Crédito.", TipoMensaje.MsgAdvertencia)
|
|
Return -1
|
|
End If
|
|
|
|
If Not CveSubProyectoPrincipal > 0 Then
|
|
Alert("No esta definido el Sub Proyecto.", TipoMensaje.MsgAdvertencia)
|
|
Return -1
|
|
End If
|
|
|
|
SubProyecto = GlobalDTSubProyectos(UsuarioActual.CveEmpresa, CveSubProyecto:=CveSubProyectoPrincipal).FiltroPrimeroValor("SubProyecto")
|
|
|
|
If PSRow IsNot Nothing Then
|
|
|
|
Dim CompraRNC As New ClsCompraManagerComprasCA(UsuarioActual) With {
|
|
.TipoDocto = "RNC",
|
|
.CveProveedor = CveProveedor,
|
|
.CveTipoProveedor = CveTipoProveedor,
|
|
.CveTipoConceptoProveedor = CveTipoConceptoProveedor,
|
|
.Descripcion = Descripcion,
|
|
.NombreProveedor = NombreProveedor,
|
|
.Fecha = Fecha,
|
|
.CveMoneda = CveMoneda,
|
|
.TipoCambio = If(CveMoneda = 1, 1, TipoCambio),
|
|
.Serie = If(ExisteRNC, $"D{nRow}-{Serie}", $"D-{Serie}"),
|
|
.Folio = Folio,
|
|
.CveCompraAmortizacion = CveCompraAmortizada,
|
|
.CveCompraRelacionada = CveCompraAmortizada
|
|
}
|
|
|
|
'Dim CveTipoPS As Integer = PSRow("CveTipoPS").ToString.ToEntero
|
|
'If PSRow("CvePSCargo").ToString <> "" Then
|
|
' CveTipoPS = 2
|
|
'End If
|
|
|
|
Dim CveClasificacion As Integer = PSRow("CveClasificacion").ToString.ToEntero
|
|
Dim Clasificacion As String = PSRow("Clasificacion").ToString
|
|
Dim PS As String = PSRow("PSCodigo").ToString
|
|
Dim CveUM As Integer = PSRow("CveUnidadMedida").ToString.ToEntero
|
|
Dim UM As String = PSRow("UnidadMedida").ToString
|
|
|
|
Dim IVARNC As Decimal = (ImporteRNC * PorcentajeIVA).RoundSQL(2)
|
|
Dim TotalRNC As Decimal = (ImporteRNC + IVARNC).RoundSQL(2)
|
|
|
|
CompraRNC.ConfiguraRegistroRapido(CvePS_RNC, CveUM, UM, CveClasificacion, Clasificacion, PS, CveSubProyectoPrincipal, SubProyecto, ImporteRNC, IVARNC, TotalRNC, PorcentajeIVA)
|
|
|
|
If CompraRNC.AddCompra(sqltransaccion) Then
|
|
'Dim tImporteRNC = (ImporteRNC + IVARNC).RoundSQL(2) ' le agrego el importe del iva
|
|
Dim Pago As New CompraPago
|
|
Pago.ImportePago = TotalRNC
|
|
Pago.CveMonedaPago = CompraActual.CveMoneda
|
|
Pago.CveCompraAmortizacion = CompraRNC.CveCompra
|
|
Pago.Referencia = CompraRNC.SerieFolio
|
|
Pago.TCPago = CompraActual.TC
|
|
Pago.AplicaAcreditable = False
|
|
Pago.TipoPago = "RNC"
|
|
Pago.Fecha = CompraActual.Fecha 'toma la misma fecha de la provisión en el pago de NC
|
|
CveCompraRNC = CompraRNC.CveCompra
|
|
respuesta = Not AplicaPrePolizaPagoCompra(CompraActual, Pago, CvePrePoliza, ObjConta)
|
|
|
|
If Not respuesta Then
|
|
Dim error_ As Boolean = True
|
|
End If
|
|
Else
|
|
respuesta = False
|
|
End If
|
|
|
|
'If respuesta AndAlso ImporteRNCProntoPago > 0 Then
|
|
|
|
' Dim CompraRNCProntoPago As New ClsCompraManagerCompras(UsuarioActual) With {
|
|
' .TipoDocto = "RNC",
|
|
' .CveProveedor = CveProveedor,
|
|
' .CveTipoProveedor = CveTipoProveedor,
|
|
' .CveTipoConceptoProveedor = CveTipoConcepto,
|
|
' .Descripcion = Descripcion,
|
|
' .NombreProveedor = NombreProveedor,
|
|
' .Fecha = Fecha,
|
|
' .CveMoneda = CveMoneda,
|
|
' .TipoCambio = If(CveMoneda = 1, 1, TipoCambio),
|
|
' .Serie = $"PP-{Serie}",
|
|
' .Folio = $"{Folio}",
|
|
' .CveCompraAmortizacion = CveCompraRegistrada
|
|
' }
|
|
' Dim IVARNCProntoPago As Decimal = (ImporteRNCProntoPago * PorcentajeIVA).RoundSQL(2)
|
|
|
|
' CompraRNCProntoPago.ConfiguraRegistroRapido(CvePS_RNC, CveUM, UM, CveClasificacion, Clasificacion, PS, CveSubProyectoPrincipal, SubProyecto, ImporteRNCProntoPago, (ImporteRNCProntoPago + IVARNCProntoPago), IVARNCProntoPago, PorcentajeIVA)
|
|
' If CompraRNCProntoPago.AddCompra(sqltransaccion) Then
|
|
' Dim tImporteRNCProntoPago = ImporteRNCProntoPago + IVARNCProntoPago ' le agrego el importe del iva
|
|
' Dim Pago As New CompraPago
|
|
' Pago.ImportePago = tImporteRNCProntoPago
|
|
' Pago.CveMonedaPago = CompraActual.CveMoneda
|
|
' Pago.CveCompraAmortizacion = CompraRNCProntoPago.CveCompra
|
|
' Pago.Referencia = CompraRNCProntoPago.SerieFolio
|
|
' Pago.TCPago = CompraActual.TC
|
|
' Pago.AplicaAcreditable = False
|
|
' Pago.TipoPago = "RNC"
|
|
' Pago.Fecha = CompraActual.Fecha 'toma la misma fecha de la provisión en el pago de NC
|
|
' respuesta = Not AplicaPrePolizaPagoCompra(CompraActual, Pago, CvePrePoliza, ObjConta)
|
|
' Else
|
|
' respuesta = False
|
|
' End If
|
|
'End If
|
|
End If
|
|
|
|
Return If(respuesta, CveCompraRNC, -1)
|
|
|
|
End Function
|
|
|
|
|
|
End Class
|
|
|
|
|
|
|
|
|
|
|
|
Public Class MMensajeDevolucion
|
|
Public Property CveMovimiento As Integer
|
|
Public Property TieneError As Boolean
|
|
Public Property DebeRealizarDevolucion As Boolean
|
|
Public Property Total As Decimal
|
|
End Class
|
|
|
|
|
|
|
|
Public Class ClsCompraManagerComprasCA
|
|
|
|
Enum EnumCargaCompra
|
|
DesdeXML
|
|
DesdeArchivo
|
|
SinXML
|
|
End Enum
|
|
Public Enum EnumCFDIVersion
|
|
v32
|
|
v33
|
|
v40
|
|
End Enum
|
|
Public Enum EnumTipoCompra
|
|
SinDefinir = -1
|
|
Gasto_con_almacen = 10
|
|
Activo_Fijo = 1
|
|
'Costo_Indirecto = 2
|
|
Almacen = 3
|
|
Almacen_con_costo_indirecto = 8
|
|
Costo_Indirecto = 4
|
|
Importación = 5
|
|
NC_Con_Productos = 6
|
|
Apoyo_Logístico = 9
|
|
NC_Por_Devolución = 11
|
|
Garantia = 12
|
|
End Enum
|
|
|
|
|
|
Public Enum EnumModalidadAccionPS
|
|
Agregar
|
|
Actualizar
|
|
End Enum
|
|
|
|
Public Property CveCompra As Integer = -1
|
|
Public Property CveProveedor As Integer
|
|
Public Property CveTipoConceptoProveedor As Integer
|
|
Public Property CveMoneda As Integer
|
|
Public Property Fecha As Date
|
|
Public ReadOnly Property SerieFolio As String
|
|
Get
|
|
If Serie.Length > 0 Then
|
|
Return $"{Serie}-{Folio}"
|
|
Else
|
|
Return $"{Folio}"
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Public Property Serie As String = ""
|
|
Public Property Folio As String = ""
|
|
Public Property FolioSecundario As String = ""
|
|
Public Property Descripcion As String = ""
|
|
Public Property CFDIVersion As EnumCFDIVersion = EnumCFDIVersion.v40
|
|
Public Property ProveedorNombre As String = ""
|
|
Public Property EsImportacion As Boolean = False
|
|
Public Property TC As Decimal = 1
|
|
Public Property SubTotal As Decimal = 0D
|
|
Public Property SubTotal2 As Decimal = 0D
|
|
Public Property Descuento As Decimal = 0D
|
|
Public Property Total As Decimal = 0D
|
|
Public Property Moneda As String = ""
|
|
Public Property TipoComprobante As String
|
|
Public Property TipoDocto As String = "Fac"
|
|
Public Property TipoCambio As Decimal = 1
|
|
Public Property CompraNoDeducible As Integer = 0
|
|
Public Property IVA As Decimal = 0D
|
|
Public Property IVADeducible As Decimal = 0D
|
|
Public Property IVANoDeducible As Decimal = 0
|
|
Public Property IEPS As Decimal = 0D
|
|
Public Property RetIVA As Decimal = 0D
|
|
Public Property RetISR As Decimal = 0D
|
|
Public Property PorcentajeIVA As Decimal = 0
|
|
Public Property PorcentajeISR As Decimal = 0
|
|
Public Property CveRetIVAConcepto As Integer = -1
|
|
Public Property CveRetISRConcepto As Integer = -1
|
|
Public Property CveSubProyecto As Integer = -1
|
|
Public Property UsuarioActual As Usuario
|
|
Public ReadOnly Property ConceptoPrePolizaIVA As ClsPaginas.ConceptosRetenciones
|
|
Get
|
|
Dim Ret As New ClsPaginas.ConceptosRetenciones
|
|
If EsImportacion Then
|
|
Ret.CveConceptoAcreditable = 288
|
|
Ret.CveConceptoxAcreditar = 287
|
|
Else
|
|
Ret.CveConceptoAcreditable = 19
|
|
Ret.CveConceptoxAcreditar = 14
|
|
End If
|
|
Return Ret
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property ConceptoPrePolizaRetIVA As ClsPaginas.ConceptosRetenciones
|
|
Get
|
|
Dim Ret As New ClsPaginas.ConceptosRetenciones
|
|
Dim Funcionalidad, FuncionalidadxAcred As Integer
|
|
If CveRetIVAConcepto = 1 Then
|
|
Funcionalidad = 308 : FuncionalidadxAcred = 307
|
|
Ret.CveConceptoAcreditable = 22
|
|
Ret.CveConceptoxAcreditar = 15
|
|
ElseIf CveRetIVAConcepto = 2 Then
|
|
Funcionalidad = 310 : FuncionalidadxAcred = 309
|
|
Ret.CveConceptoAcreditable = 184
|
|
Ret.CveConceptoxAcreditar = 183
|
|
ElseIf CveRetIVAConcepto = 3 Then
|
|
Funcionalidad = 312 : FuncionalidadxAcred = 311
|
|
Ret.CveConceptoAcreditable = 186
|
|
Ret.CveConceptoxAcreditar = 185
|
|
ElseIf CveRetIVAConcepto = 4 Then
|
|
Funcionalidad = 314 : FuncionalidadxAcred = 313
|
|
Ret.CveConceptoAcreditable = 249
|
|
Ret.CveConceptoxAcreditar = 248
|
|
ElseIf CveRetIVAConcepto = 5 Then
|
|
Funcionalidad = 578 : FuncionalidadxAcred = 578
|
|
Ret.CveConceptoAcreditable = 286
|
|
Ret.CveConceptoxAcreditar = 285
|
|
ElseIf CveRetIVAConcepto = 6 Then
|
|
Funcionalidad = 578 : FuncionalidadxAcred = 578
|
|
Ret.CveConceptoAcreditable = 333
|
|
Ret.CveConceptoxAcreditar = 334
|
|
End If
|
|
Return Ret
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property ConceptoPrePolizaRetISR As ClsPaginas.ConceptosRetenciones
|
|
Get
|
|
Dim Ret As New ClsPaginas.ConceptosRetenciones
|
|
Dim Funcionalidad, FuncionalidadxAcred As Integer
|
|
If CveRetISRConcepto = 1 Then
|
|
Funcionalidad = 316 : FuncionalidadxAcred = 315
|
|
Ret.CveConceptoAcreditable = 23
|
|
Ret.CveConceptoxAcreditar = 16
|
|
ElseIf CveRetISRConcepto = 2 Then
|
|
Funcionalidad = 318 : FuncionalidadxAcred = 317
|
|
Ret.CveConceptoAcreditable = 244
|
|
Ret.CveConceptoxAcreditar = 243
|
|
ElseIf CveRetISRConcepto = 3 Then
|
|
Funcionalidad = 349 : FuncionalidadxAcred = 348
|
|
Ret.CveConceptoAcreditable = 328
|
|
Ret.CveConceptoxAcreditar = 327
|
|
End If
|
|
Return Ret
|
|
End Get
|
|
End Property
|
|
|
|
Public Property CveMetodoPago As Integer
|
|
Public Property MetodoPago As String
|
|
Public Property DocumentosRelacionadosUUIDSList As List(Of String) = New List(Of String)
|
|
Public ReadOnly Property DocumentosRelacionadosUUIDSString As String
|
|
Get
|
|
Return GeneraStringDoctosRelacionados()
|
|
End Get
|
|
End Property
|
|
|
|
Public Property DocumentosRelacionadosAnticiposUUIDList As List(Of String) = New List(Of String)
|
|
Public Property TieneAnticiposXML As Boolean = False
|
|
Public Property EmisorRFC As String
|
|
Public Property ReceptorRFC As String
|
|
Public Property UUID As String = ""
|
|
Public Property TotalRetenciones As Decimal = 0D
|
|
Public Property RetencionIVA As Decimal = 0D
|
|
Public Property RetencionISR As Decimal = 0D
|
|
Public Property SumaTotalRetenciones As Decimal = 0D
|
|
Public Property TotalTraslados As Decimal = 0D
|
|
Public Property TrasladoIVA As Decimal = 0D
|
|
Public Property TrasladoIEPS As Decimal = 0D
|
|
Public Property SumaTotalTraslados As Decimal = 0D
|
|
Public Property OtrosImpuestos As Decimal = 0D
|
|
Private Property OtrosImpuestosRetenciones As Decimal = 0D
|
|
Public Property Amortizacion As Decimal = 0D
|
|
Public Property FechaPago As Date 'FIX ME corregir usando fecha interna calculada por los dias de credito del proveedor
|
|
Public Property AplicaNotaCredito As Boolean = False
|
|
Public Property XMlStr As String
|
|
Public Property XMLCargaExistosa As Boolean = True
|
|
Public Property Observaciones As String = ""
|
|
Public Property CveEstatusFactura As Integer = 1
|
|
Public Property CvePrePoliza As Integer = -1
|
|
Public Property Redondeo As Decimal = 0
|
|
Public Property IdPoliza As Integer = -1
|
|
Public Property CveCajaChica As Integer = -1
|
|
Public Property CvePersonal As Integer = -1
|
|
Public Property NumeroReembolso As String = ""
|
|
Public Property CveProveedorSucursal As Integer = -1
|
|
Public Property AplicoPromocion As Boolean = False
|
|
Public Property CveConceptoContableAlmacen As Integer = -1
|
|
Public Property NoDeducible As Integer = 0
|
|
Public Property CveTipoCompra As Integer = -1
|
|
Public Property TotalOriginal As Decimal = 0D
|
|
Public Property CveTipoConcepto As Integer = 1 'FIX ME Esto tiene que ver con el CveTipoProveedor 1 y 3 es CveTipoConcepto 1 y 2 es CveTipoConcepto 2
|
|
Public Property CveSubProyectoPrincipal As Integer = -1
|
|
Public Property CveFactura As Integer = -1
|
|
Public Property CveFolioGarantia As Integer = -1
|
|
Public Property TmpDT As DataTable = New DataTable
|
|
Public Property SubTotalConceptos As Decimal = 0D
|
|
|
|
Private Errores As StringBuilder = New StringBuilder
|
|
|
|
Public ReadOnly Property MensajeError As String
|
|
Get
|
|
Return Errores.ToString()
|
|
End Get
|
|
End Property
|
|
|
|
Public Property CompraSaldo As Decimal = 0D
|
|
Public Property SubTotalOriginal As Decimal = 0D
|
|
Public Property SubTotal2Original As Double = 0D
|
|
Public Property IVAOriginal As Decimal = 0D
|
|
Public Property RetIVAOriginal As Decimal = 0D
|
|
Public Property RetISROriginal As Decimal = 0D
|
|
Public Property Proyecto As String = ""
|
|
Public Property CveProyecto As Integer = -1
|
|
Public Property SubProyecto As String = ""
|
|
Public Property TipoCompra As EnumTipoCompra = EnumTipoCompra.SinDefinir
|
|
Private Property DTTiposGastos() As DataTable
|
|
Public Property CveTipoProveedor As Integer = -1
|
|
Public Property IEPSGasto As Boolean = False
|
|
Public Property OtrosImpuestosGasto As Boolean = False
|
|
Public Property OCVinculada As Boolean = False
|
|
Public Property NumNoDed As Integer = 0
|
|
Public Property CveTipoPoliza As Integer = -1
|
|
Public Property NombreProveedor As Object
|
|
Public Property CveCreditoDetalle As Integer = -1
|
|
Public Property CveIE As Integer = -1
|
|
Public Property CveCompraAmortizacion As Integer = -1
|
|
Public Property CveCompraRelacionada As Integer = -1
|
|
|
|
|
|
Public Sub New(UsuarioActual As Usuario)
|
|
|
|
Errores = New StringBuilder
|
|
|
|
Me.UsuarioActual = UsuarioActual
|
|
|
|
End Sub
|
|
|
|
Public Sub New(XmlFuente As String, OpcionCarga As EnumCargaCompra, DTTiposGastos As DataTable, UsuarioActual As Usuario)
|
|
|
|
Errores = New StringBuilder
|
|
Me.DTTiposGastos = DTTiposGastos
|
|
Me.UsuarioActual = UsuarioActual
|
|
|
|
If OpcionCarga = EnumCargaCompra.SinXML Then
|
|
|
|
Else
|
|
If OpcionCarga = EnumCargaCompra.DesdeArchivo Then
|
|
CargaDesdeArchivo(XmlFuente)
|
|
Else
|
|
CargaDesdeString(XmlFuente)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
#Region "C A R G A S D E F U E N T E S "
|
|
|
|
Private Sub CargaDesdeArchivo(XmlFuenteRuta As String)
|
|
|
|
Dim XMLDoc As New XmlDocument
|
|
|
|
If IO.File.Exists(XmlFuenteRuta) Then
|
|
XMlStr = File.ReadAllText(XmlFuenteRuta).Replace("<br>", "").Replace("<", "").Replace("o;?", "")
|
|
Try
|
|
XMLDoc.LoadXml(XMlStr)
|
|
XMLCargaExistosa = True
|
|
Catch ex As Exception
|
|
Try
|
|
Dim oReader As New StreamReader(XmlFuenteRuta, Encoding.GetEncoding("ISO-8859-1"))
|
|
XMLDoc.Load(oReader)
|
|
oReader.Dispose()
|
|
XMLCargaExistosa = True
|
|
Catch ex2 As Exception
|
|
GuardaLog("Error al intentar leer el XML del SAT. Error:" & ex2.ToString())
|
|
Errores.AppendLine("Error al intentar leer el XML. Error:" & ex2.ToString())
|
|
XMLCargaExistosa = False
|
|
End Try
|
|
End Try
|
|
End If
|
|
|
|
If XMLCargaExistosa Then
|
|
CargaComprobanteXML(XMLDoc)
|
|
End If
|
|
|
|
End Sub
|
|
Private Sub CargaDesdeString(XmlFuente As String)
|
|
XMlStr = XmlFuente.Replace("<br>", "").Replace("<", "").Replace("o;?", "")
|
|
Dim XMLDoc As New XmlDocument
|
|
Try
|
|
XMLDoc.LoadXml(XMlStr)
|
|
XMLCargaExistosa = True
|
|
Catch ex As Exception
|
|
GuardaLog("Error al intentar leer . Error:" & ex.ToString())
|
|
Errores.AppendLine("Error al intentar leer el XML. Error:" & ex.ToString())
|
|
XMLCargaExistosa = False
|
|
End Try
|
|
|
|
If XMLCargaExistosa Then
|
|
CargaComprobanteXML(XMLDoc)
|
|
End If
|
|
|
|
End Sub
|
|
Private Sub CargaComprobanteXML(XMLDoc As XmlDocument)
|
|
Dim nodo As XmlNode = XMLDoc.DocumentElement
|
|
|
|
Serie = ValorXML(nodo, "serie")
|
|
|
|
Dim StrCFDIVerion As String = ValorXML(nodo, "version")
|
|
|
|
If StrCFDIVerion = "3.2" Then
|
|
CFDIVersion = EnumCFDIVersion.v32
|
|
ElseIf StrCFDIVerion = "3.3" Then
|
|
CFDIVersion = EnumCFDIVersion.v33
|
|
ElseIf StrCFDIVerion = "4.0" Then
|
|
CFDIVersion = EnumCFDIVersion.v40
|
|
Else
|
|
GuardaLog($"CFDI Versión {StrCFDIVerion} no soportada")
|
|
Errores.AppendLine($"CFDI Versión {StrCFDIVerion} no soportada")
|
|
XMLCargaExistosa = False
|
|
Exit Sub
|
|
End If
|
|
|
|
Folio = ValorXML(nodo, "folio")
|
|
Fecha = ValorXML(nodo, "fecha").ToDate
|
|
SubTotal = ValorXML(nodo, "subTotal").ToDecimal
|
|
Total = ValorXML(nodo, "total").ToDecimal
|
|
Descuento = ValorXML(nodo, "descuento").ToDecimal
|
|
Moneda = ValorXML(nodo, "Moneda")
|
|
|
|
CveMoneda = ClsPaginas.GlobalDTMonedas().FiltroPrimeroValor("CveMoneda", $" AbreviaturaSAT = '{Moneda}' ").ToEntero
|
|
If Not CveMoneda > 0 Then
|
|
GuardaLog($"Moneda {Moneda} no se obtuvo la clabe")
|
|
Errores.AppendLine($"Moneda {Moneda} no se obtuvo la clabe")
|
|
XMLCargaExistosa = False
|
|
Exit Sub
|
|
End If
|
|
|
|
TipoComprobante = ValorXML(nodo, "tipoDeComprobante")
|
|
TipoCambio = ValorXML(nodo, "TipoCambio", "1").ToDecimal
|
|
|
|
If CFDIVersion = EnumCFDIVersion.v33 Or CFDIVersion = EnumCFDIVersion.v40 Then
|
|
Dim drm As DataRow = ClsPaginas.GlobalDTVtaMetodoPago.FiltroPrimero(String.Format("ClaveMetodoPagoSAT = '{0}'", ValorXML(nodo, "MetodoPago")))
|
|
If drm IsNot Nothing Then
|
|
CveMetodoPago = drm("CveMetodoPago").ToString.ToEntero
|
|
MetodoPago = drm("MetodoPagoSAT").ToString
|
|
End If
|
|
End If
|
|
|
|
Dim namespaces As New XmlNamespaceManager(XMLDoc.NameTable)
|
|
Dim Prefijo As String = If(XMLDoc.DocumentElement.Prefix = "", "cfd", XMLDoc.DocumentElement.Prefix)
|
|
Dim cfdVer As String = ""
|
|
|
|
If CFDIVersion = EnumCFDIVersion.v32 Then
|
|
Prefijo = "cfd"
|
|
cfdVer = "http://www.sat.gob.mx/cfd/2"
|
|
ElseIf CFDIVersion = EnumCFDIVersion.v33 Then
|
|
cfdVer = "http://www.sat.gob.mx/cfd/3"
|
|
Else ' se considera que es la version 4.0
|
|
cfdVer = "http://www.sat.gob.mx/cfd/4"
|
|
End If
|
|
namespaces.AddNamespace(Prefijo, cfdVer)
|
|
namespaces.AddNamespace("aerolineas", "http://www.sat.gob.mx/aerolineas")
|
|
namespaces.AddNamespace("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital")
|
|
namespaces.AddNamespace("implocal", "http://www.sat.gob.mx/implocal")
|
|
namespaces.AddNamespace("registrofiscal", "http://www.sat.gob.mx/registrofiscal")
|
|
|
|
If TipoComprobante.ToUpper = "E" AndAlso (CFDIVersion = EnumCFDIVersion.v33 OrElse CFDIVersion = EnumCFDIVersion.v40) Then
|
|
Dim UUIDS As String = ""
|
|
|
|
Dim UUIDSLista As New List(Of String)
|
|
Dim nodeCFDIRelacionados As XmlNode
|
|
nodeCFDIRelacionados = XMLDoc.SelectSingleNode(String.Format("//{0}:CfdiRelacionados", Prefijo), namespaces)
|
|
|
|
If nodeCFDIRelacionados IsNot Nothing Then
|
|
For Each CFDIRelacionados As XmlNode In nodeCFDIRelacionados
|
|
UUIDSLista.Add("" & CFDIRelacionados.Attributes("UUID").Value.ToString & "")
|
|
Next
|
|
End If
|
|
DocumentosRelacionadosUUIDSList = UUIDSLista
|
|
|
|
End If
|
|
|
|
Dim node As XmlNode
|
|
node = XMLDoc.SelectSingleNode(String.Format("//{0}:Emisor", Prefijo), namespaces)
|
|
|
|
If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then
|
|
EmisorRFC = ValorXML(node, "RFC")
|
|
End If
|
|
|
|
node = XMLDoc.SelectSingleNode(String.Format("//{0}:Receptor", Prefijo), namespaces)
|
|
|
|
If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then
|
|
ReceptorRFC = ValorXML(node, "RFC")
|
|
End If
|
|
|
|
If UsuarioActual.CveEmpresa.Contiene(119, 7) Then
|
|
node = XMLDoc.SelectSingleNode(String.Format("//{0}:CfdiRelacionados", Prefijo), namespaces)
|
|
If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then
|
|
If ValorXML(node, "TipoRelacion").ToString.Contiene("07") Then
|
|
Dim nodeDocumentosRelacionados As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:CfdiRelacionado", Prefijo), namespaces)
|
|
For Each documento As XmlNode In nodeDocumentosRelacionados
|
|
If documento.Attributes("UUID").Value <> "" Then
|
|
DocumentosRelacionadosAnticiposUUIDList.Add(documento.Attributes("UUID").Value)
|
|
End If
|
|
TieneAnticiposXML = True
|
|
Next
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
node = XMLDoc.SelectSingleNode(String.Format("//{0}:Impuestos", Prefijo), namespaces)
|
|
If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then
|
|
Dim nodeRetenciones As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:Comprobante/{0}:Impuestos/{0}:Retenciones/{0}:Retencion", Prefijo), namespaces)
|
|
|
|
TotalRetenciones = ValorXML(node, "totalImpuestosRetenidos", "0").ToDecimal
|
|
|
|
If CFDIVersion = EnumCFDIVersion.v33 OrElse CFDIVersion = EnumCFDIVersion.v40 Then
|
|
|
|
For Each retencion As XmlNode In nodeRetenciones
|
|
If retencion.Attributes("Impuesto").Value = "002" Then RetencionIVA += retencion.Attributes("Importe").Value.ToDecimal
|
|
If retencion.Attributes("Impuesto").Value = "001" Then RetencionISR += retencion.Attributes("Importe").Value.ToDecimal
|
|
Next
|
|
|
|
Else
|
|
|
|
For Each retencion As XmlNode In nodeRetenciones
|
|
If retencion.Attributes("impuesto").Value = "IVA" Then RetencionIVA += retencion.Attributes("importe").Value.ToDecimal
|
|
If retencion.Attributes("impuesto").Value = "ISR" Then RetencionISR += retencion.Attributes("importe").Value.ToDecimal
|
|
Next
|
|
End If
|
|
SumaTotalRetenciones += RetencionIVA
|
|
SumaTotalRetenciones += RetencionISR
|
|
|
|
TotalTraslados = ValorXML(node, "totalImpuestosTrasladados", "0").ToDecimal
|
|
Dim nodeTraslados As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:Comprobante/{0}:Impuestos/{0}:Traslados/{0}:Traslado", Prefijo), namespaces)
|
|
|
|
If CFDIVersion = EnumCFDIVersion.v33 OrElse CFDIVersion = EnumCFDIVersion.v40 Then
|
|
|
|
For Each traslado As XmlNode In nodeTraslados
|
|
|
|
If traslado.Attributes("Importe") IsNot Nothing Then
|
|
If traslado.Attributes("Impuesto").Value = "002" Then TrasladoIVA += traslado.Attributes("Importe").Value.ToDecimal
|
|
If traslado.Attributes("Impuesto").Value = "003" Then TrasladoIEPS += traslado.Attributes("Importe").Value.ToDecimal
|
|
End If
|
|
Next
|
|
Else
|
|
|
|
For Each traslado As XmlNode In nodeTraslados
|
|
If traslado.Attributes("Importe") IsNot Nothing Then
|
|
If traslado.Attributes("impuesto").Value = "IVA" Then TrasladoIVA += traslado.Attributes("importe").Value.ToDecimal
|
|
|
|
If traslado.Attributes("impuesto").Value = "IEPS" Then TrasladoIEPS += traslado.Attributes("importe").Value.ToDecimal
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
SumaTotalTraslados += TrasladoIVA
|
|
SumaTotalTraslados += TrasladoIEPS
|
|
End If
|
|
|
|
Dim nodeComp As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Complemento", Prefijo), namespaces)
|
|
If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then
|
|
|
|
Dim nodeTFD As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:TimbreFiscalDigital", "tfd"), namespaces)
|
|
|
|
UUID = ValorXML(nodeTFD, "UUID", "")
|
|
|
|
Dim nodeRF As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:CFDIRegistroFiscal ", "registrofiscal"), namespaces)
|
|
If nodeRF IsNot Nothing Then
|
|
Folio = ValorXML(nodeRF, "folio").TrimStart("0"c)
|
|
End If
|
|
|
|
node = node.SelectSingleNode(String.Format("//{0}:ImpuestosLocales", "implocal"), namespaces)
|
|
|
|
If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then
|
|
OtrosImpuestos = ValorXML(node, "TotaldeTraslados", "0").ToDecimal
|
|
'2022.06.04-- se quitan los datos de retenciones de impuestos locales, generan conflicto. RMF
|
|
'OtrosImpuestosRetenciones = ValorXML(node, "TotaldeRetenciones", "0").ToDecimal
|
|
End If
|
|
End If
|
|
|
|
|
|
If XMLCargaExistosa Then
|
|
If Not ValidateUUID(UUID) Then
|
|
GuardaLog($"UUID Invalido {UUID} .")
|
|
Errores.AppendLine($"UUID Invalido {UUID} .")
|
|
XMLCargaExistosa = False
|
|
End If
|
|
End If
|
|
|
|
|
|
#Region "DETALLES"
|
|
|
|
Dim ObjeFacturas As New ClsCompras
|
|
Dim AjustaUltimoConcepto As Boolean = False
|
|
|
|
Dim nodeconceptos As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Conceptos", Prefijo), namespaces)
|
|
Dim XML As String = Replace(nodeconceptos.OuterXml, "<cfdi:", "<")
|
|
XML = XML.Replace("</cfdi:", "</")
|
|
XML = XML.Replace("xmlns:cfdi=""http://www.sat.gob.mx/cfd/3""", "")
|
|
XML = XML.Replace("xmlns:cfdi=""http://www.sat.gob.mx/cfd/4""", "")
|
|
XML = XML.Replace(""", "") 'comillas
|
|
XML = System.Web.HttpUtility.HtmlDecode(XML.ToString)
|
|
XML = XML.Replace(Chr(13), "") 'salto de linea
|
|
XML = XML.Replace(Chr(10), "")
|
|
XML = XML.Replace("<br />", "") 'salto de linea html
|
|
XML = XML.Replace("<br>", "")
|
|
XML = XML.Replace("<", "")
|
|
|
|
XML = XML.Replace("&", "") 'adicional, si hay otros
|
|
|
|
If ObjeFacturas.GetFacturasComparacionXML(StrCFDIVerion, XML, UsuarioActual.CveEmpresa) Then
|
|
TmpDT = ObjeFacturas.DtResultados
|
|
TmpDT.Columns.Add("CveSATPSActualizado")
|
|
SubTotalConceptos = TmpDT.SUMD("Total").RoundSQL
|
|
|
|
If Not TmpDT.Columns.Contains("Amortizacion") Then TmpDT.Columns.Add("Amortizacion", GetType(Decimal))
|
|
|
|
If Not TmpDT.Columns.Contains("AplicaLote") Then TmpDT.Columns.Add("AplicaLote", GetType(Boolean))
|
|
|
|
If Not TmpDT.Columns.Contains("AplicaCaducidad") Then TmpDT.Columns.Add("AplicaCaducidad", GetType(Boolean))
|
|
|
|
If Not TmpDT.Columns.Contains("Lote") Then TmpDT.Columns.Add("Lote", GetType(String))
|
|
|
|
If Not TmpDT.Columns.Contains("FechaCaducidad") Then TmpDT.Columns.Add("FechaCaducidad", GetType(Date))
|
|
|
|
'VALIDA QUE EL XML SI VIENE CON EL CODIGO SAT 01010101
|
|
Dim ProductosCodigoSATNoPermitidos As New StringBuilder("")
|
|
For Each drr As DataRow In TmpDT.FiltraParametros("ClaveProdServ = '01010101'").Rows
|
|
ProductosCodigoSATNoPermitidos.AppendFormat("{0}</br>", drr("PS"))
|
|
Next
|
|
|
|
If ProductosCodigoSATNoPermitidos.ToString.Length > 0 Then
|
|
Errores.AppendLine($"El comprobante contiene productos con código SAT '01010101', revise los productos:</br></br>{ProductosCodigoSATNoPermitidos.ToString}")
|
|
End If
|
|
Else
|
|
GuardaLog($"Error al cargar detalles GetFacturasComparacionXML.")
|
|
Errores.AppendLine($"Error al cargar detalles GetFacturasComparacionXML.")
|
|
XMLCargaExistosa = False
|
|
End If
|
|
|
|
ObjeFacturas.Dispose()
|
|
|
|
If CFDIVersion = EnumCFDIVersion.v33 OrElse CFDIVersion = EnumCFDIVersion.v40 Then
|
|
If Not TmpDT.Columns.Contains("Amortizacion") Then
|
|
TmpDT.Columns.Add("Amortizacion", GetType(Decimal))
|
|
End If
|
|
TmpDT.AcceptChanges()
|
|
ValidacionesTotalesXml()
|
|
End If
|
|
|
|
Me.PorcentajeIVA = TmpDT.MAX("IVAPorcentaje").ToDecimal
|
|
|
|
#End Region
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
Public Function ConfiguraRegistroRapidoReembolso(CvePS As Integer, CveSubProyecto As Integer, CveCajaChica As Integer, CvePersonal As Integer, CveRetIVAConcepto As Integer, CveRetISRConcepto As Integer, NumeroReembolso As String) As Boolean
|
|
|
|
Dim respuesta As Boolean = True
|
|
Me.CveSubProyecto = CveSubProyecto
|
|
Me.CveSubProyectoPrincipal = CveSubProyecto
|
|
Me.CveCajaChica = CveCajaChica
|
|
Me.CvePersonal = CvePersonal
|
|
Me.CveRetIVAConcepto = CveRetIVAConcepto
|
|
Me.CveRetISRConcepto = CveRetISRConcepto
|
|
Me.CveTipoPoliza = 3
|
|
Me.NumeroReembolso = NumeroReembolso
|
|
|
|
Dim dRowSubProyecto As DataRow = GlobalDTSubProyectos(UsuarioActual.CveEmpresa, CveSubProyecto:=CveSubProyecto).FiltroPrimero("")
|
|
|
|
If dRowSubProyecto IsNot Nothing Then
|
|
Me.Proyecto = dRowSubProyecto("Proyecto").ToString
|
|
Me.CveProyecto = (dRowSubProyecto("CveProyecto").ToString).ToEntero
|
|
Me.SubProyecto = dRowSubProyecto("SubProyecto").ToString
|
|
Else
|
|
Errores.AppendLine($"Error al cargar el Sub Proyecto CveSubProyecto: {CveSubProyecto}")
|
|
Return False
|
|
End If
|
|
|
|
Dim DTIndex As DataTable = TmpDT.FiltraParametros("", DistinctColumns:={"Consec"})
|
|
|
|
For Each dRowIndex As DataRow In DTIndex.Rows
|
|
If Not UpdatePSReembolso(dRowIndex("Consec").ToString.ToEntero, CvePS) Then
|
|
respuesta = False
|
|
End If
|
|
Next
|
|
|
|
If respuesta AndAlso IEPS > 0 Then
|
|
If Not AgregaIEPSReembolso(CvePS:=CvePS) Then
|
|
respuesta = False
|
|
Else
|
|
IEPS = 0
|
|
End If
|
|
End If
|
|
|
|
If Not AjustesValidacion() Then
|
|
respuesta = False
|
|
End If
|
|
|
|
Return respuesta
|
|
|
|
End Function
|
|
Public Function ConfiguraRegistroRapido(CvePS As Integer, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, PS As String, CveSubProyecto As Integer, SubProyecto As String,
|
|
SubTotal As Decimal, IVA As Decimal, Total As Decimal, PorcentajeIVA As Decimal) As Boolean
|
|
|
|
Dim respuesta As Boolean = True
|
|
Me.CveSubProyecto = CveSubProyecto
|
|
Me.CveSubProyectoPrincipal = CveSubProyecto
|
|
Me.CveCajaChica = -1
|
|
Me.CvePersonal = -1
|
|
Me.CveRetIVAConcepto = -1
|
|
Me.CveRetISRConcepto = -1
|
|
Me.CveTipoPoliza = 3
|
|
Me.NumeroReembolso = ""
|
|
Me.SubTotal = SubTotal.RoundSQL
|
|
Me.IVA = IVA
|
|
Me.Total = Total
|
|
Me.PorcentajeIVA = PorcentajeIVA
|
|
|
|
Dim dRowSubProyecto As DataRow = GlobalDTSubProyectos(UsuarioActual.CveEmpresa, CveSubProyecto:=CveSubProyecto).FiltroPrimero("")
|
|
|
|
If dRowSubProyecto IsNot Nothing Then
|
|
Me.Proyecto = dRowSubProyecto("Proyecto").ToString
|
|
Me.CveProyecto = (dRowSubProyecto("CveProyecto").ToString).ToEntero
|
|
Me.SubProyecto = dRowSubProyecto("SubProyecto").ToString
|
|
Else
|
|
Errores.AppendLine($"Error al cargar el Sub Proyecto CveSubProyecto: {CveSubProyecto}")
|
|
Return False
|
|
End If
|
|
|
|
CreaDTCompras()
|
|
AddPS(1, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, 1, CveSubProyecto.ToString, SubProyecto, "", "-1", "", SubTotal, Total, 0, 0, 0, 0, 0, 0, PorcentajeIVA:=PorcentajeIVA)
|
|
|
|
'If respuesta AndAlso IEPS > 0 Then
|
|
' If Not AgregaIEPSReembolso(CvePS:=CvePS) Then
|
|
' respuesta = False
|
|
' Else
|
|
' IEPS = 0
|
|
' End If
|
|
'End If
|
|
|
|
'If Not AjustesValidacion() Then
|
|
' respuesta = False
|
|
'End If
|
|
|
|
Return respuesta
|
|
|
|
End Function
|
|
|
|
|
|
Private Sub CreaDTCompras()
|
|
|
|
TmpDT = New DataTable
|
|
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("CveClasificacion", GetType(Integer))
|
|
TmpDT.Columns.Add("Clasificacion", GetType(String))
|
|
TmpDT.Columns.Add("CveClasificacionActualizar", GetType(Integer))
|
|
TmpDT.Columns.Add("CvePS", GetType(Integer))
|
|
TmpDT.Columns.Add("PS", GetType(String))
|
|
TmpDT.Columns.Add("Obs", GetType(String))
|
|
TmpDT.Columns.Add("PU", GetType(Decimal))
|
|
TmpDT.Columns.Add("IVA", GetType(Decimal))
|
|
TmpDT.Columns.Add("IVAPorcentaje", GetType(Decimal))
|
|
TmpDT.Columns.Add("RetIVA", GetType(Decimal))
|
|
TmpDT.Columns.Add("RetIVAPorcentaje", GetType(Decimal))
|
|
TmpDT.Columns.Add("RetISR", GetType(Decimal))
|
|
TmpDT.Columns.Add("RetISRPorcentaje", GetType(Decimal))
|
|
TmpDT.Columns.Add("IEPSPS", GetType(Double))
|
|
TmpDT.Columns.Add("IEPSPSPorcentaje", GetType(Double))
|
|
TmpDT.Columns.Add("IEPSPSIVA", GetType(Double))
|
|
TmpDT.Columns.Add("IEPSPSIVAPorcentaje", GetType(Double))
|
|
TmpDT.Columns.Add("Descuento", GetType(Decimal))
|
|
TmpDT.Columns.Add("OtrosGastos", GetType(Decimal))
|
|
TmpDT.Columns.Add("Total", GetType(Decimal))
|
|
TmpDT.Columns.Add("AsientoContableCompras", GetType(Integer))
|
|
TmpDT.Columns.Add("Proyecto", GetType(String))
|
|
TmpDT.Columns.Add("CveProyecto", GetType(Integer))
|
|
TmpDT.Columns.Add("CveSubProyecto", GetType(Integer))
|
|
TmpDT.Columns.Add("CveContrato", GetType(Integer))
|
|
TmpDT.Columns.Add("SubProyecto", GetType(String))
|
|
'TmpDT.Columns.Add("CveEq", GetType(Integer))
|
|
TmpDT.Columns.Add("CveAlmacen", GetType(Integer))
|
|
TmpDT.Columns.Add("CvePersonal", GetType(String))
|
|
TmpDT.Columns.Add("Referencia", GetType(String))
|
|
|
|
'AC
|
|
TmpDT.Columns.Add("CveTipoGastoAC", GetType(Integer))
|
|
TmpDT.Columns.Add("CvePresupuestoEgreso", GetType(Integer))
|
|
TmpDT.Columns.Add("CveProgramaOperativo", GetType(Integer))
|
|
TmpDT.Columns.Add("CveUnidadAdministrativa", GetType(Integer))
|
|
TmpDT.Columns.Add("CveFuenteFinanciamiento", GetType(Integer))
|
|
TmpDT.Columns.Add("CveClasificacionOG", GetType(Integer))
|
|
|
|
TmpDT.Columns.Add("IdCuentaComprometido", GetType(Integer))
|
|
TmpDT.Columns.Add("IdCuentaPorEjercer", GetType(Integer))
|
|
TmpDT.Columns.Add("IdCuentaDevengado", GetType(Integer))
|
|
TmpDT.Columns.Add("IdCuentaMatriz", GetType(Integer))
|
|
|
|
'INVENTARIO SERIE/LOTE
|
|
TmpDT.Columns.Add("CveMetodoInventario", GetType(Integer))
|
|
|
|
TmpDT.Columns.Add("CveConcepto", GetType(Integer))
|
|
|
|
'AF
|
|
TmpDT.Columns.Add("CveActivoFijo", GetType(Integer))
|
|
TmpDT.Columns.Add("CodAF", GetType(String))
|
|
TmpDT.Columns.Add("TipoAF", GetType(Integer))
|
|
TmpDT.Columns.Add("AFMedida", GetType(Integer))
|
|
TmpDT.Columns.Add("AFTipoMantenimiento", GetType(Integer))
|
|
|
|
'PS
|
|
TmpDT.Columns.Add("CveTipoPS", GetType(Integer))
|
|
TmpDT.Columns.Add("CodigoPS", GetType(String))
|
|
TmpDT.Columns.Add("PSDescripcion", GetType(String))
|
|
'CAMPO ESPECIAL PARA GLUYAS - LEE EL DEL XML - A GLUYAS LE INTERESA EL CODIGO DEL PROVEEDOR
|
|
TmpDT.Columns.Add("PSCodigo", GetType(String))
|
|
|
|
|
|
'OC
|
|
TmpDT.Columns.Add("CveOrdenCompraDetalle", GetType(Integer))
|
|
TmpDT.Columns.Add("ProductoOC", GetType(String))
|
|
TmpDT.Columns.Add("CantidadF", GetType(Double))
|
|
|
|
'Consignaciones
|
|
TmpDT.Columns.Add("CveAlmacenConsignacion", GetType(Integer))
|
|
TmpDT.Columns.Add("NoConsignacion", GetType(Integer))
|
|
TmpDT.Columns.Add("CveConsignacion", GetType(Integer))
|
|
TmpDT.Columns.Add("HdnPS", GetType(String))
|
|
TmpDT.Columns.Add("HdnCvePS", GetType(String))
|
|
TmpDT.Columns.Add("HdnClasificacion", GetType(String))
|
|
TmpDT.Columns.Add("HdnCveClasificacion", GetType(String))
|
|
TmpDT.Columns.Add("HdnCveAlmacen", GetType(String))
|
|
|
|
'Fletes y Servicios
|
|
TmpDT.Columns.Add("AplicaCostoIndirecto", GetType(Integer))
|
|
TmpDT.Columns.Add("CostoIndirectoAlmacen", GetType(Decimal))
|
|
TmpDT.Columns.Add("CveCompraDetalle", GetType(Integer))
|
|
|
|
TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
|
|
|
|
'SAT
|
|
TmpDT.Columns.Add("CveSATPS", GetType(Integer))
|
|
TmpDT.Columns.Add("SATClaveProductoServicio", GetType(String))
|
|
TmpDT.Columns.Add("CveUnidadMedidaSAT", GetType(Integer))
|
|
TmpDT.Columns.Add("SATClaveUnidadMedida", GetType(String))
|
|
TmpDT.Columns.Add("CveSATPSActualizado", GetType(Integer))
|
|
|
|
|
|
'Tipo de Gasto
|
|
TmpDT.Columns.Add("CveTipoGasto", GetType(Integer))
|
|
TmpDT.Columns.Add("TipoGasto", GetType(String))
|
|
|
|
TmpDT.Columns.Add("ImporteSinImpuestos", GetType(Double))
|
|
TmpDT.Columns.Add("ImporteConImpuestos", GetType(Double))
|
|
TmpDT.Columns.Add("NoDeducible", GetType(Boolean))
|
|
|
|
TmpDT.Columns.Add("DifPSSat", GetType(Integer))
|
|
|
|
|
|
TmpDT.Columns.Add("CveContratoDetalle", GetType(Integer))
|
|
TmpDT.Columns.Add("CveCultivoCuadroDetalle", GetType(Integer))
|
|
TmpDT.Columns.Add("TemporadaCuadro", GetType(String))
|
|
|
|
TmpDT.Columns.Add("NoIdentificacion", GetType(String))
|
|
|
|
TmpDT.Columns.Add("AplicaLote", GetType(Boolean))
|
|
TmpDT.Columns.Add("AplicaCaducidad", GetType(Boolean))
|
|
|
|
TmpDT.Columns.Add("Lote", GetType(String))
|
|
TmpDT.Columns.Add("FechaCaducidad", GetType(Date))
|
|
|
|
|
|
TmpDT.AcceptChanges()
|
|
|
|
|
|
End Sub
|
|
Private Function AjustesValidacion() As Boolean
|
|
Dim respuesta As Boolean = True
|
|
'VALIDA IMPORTES
|
|
If Not ValidaTotalesGuardar() Then
|
|
respuesta = False
|
|
End If
|
|
|
|
If Not AjustaCombustibles() Then
|
|
respuesta = False
|
|
End If
|
|
|
|
If Not AjustaIVA() Then
|
|
respuesta = False
|
|
End If
|
|
|
|
If Not AjustaRetIVA() Then
|
|
respuesta = False
|
|
End If
|
|
|
|
If Not AjustaRetISR() Then
|
|
respuesta = False
|
|
End If
|
|
|
|
Return respuesta
|
|
|
|
End Function
|
|
|
|
Private Function ValidaTotalesGuardar() As Boolean
|
|
Dim EsValido As Boolean = True
|
|
|
|
'VALIDA IMPORTES
|
|
'VALIDA TOTAL CON LOS IMPORTES TOTALES
|
|
Dim TempSubTotal, TempDescuentos, TempIVA, TempSubTotal2, TempRetIVA, TempRetISR, TempTotal, DifTotales, TempIEPS As Decimal
|
|
|
|
Dim Amortizacion As Decimal = 0
|
|
Dim TieneAmortizacion As Boolean = False
|
|
If DocumentosRelacionadosAnticiposUUIDList IsNot Nothing AndAlso DocumentosRelacionadosAnticiposUUIDList.Count > 0 Then 'Fix me
|
|
' AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 Then
|
|
'TieneAmortizacion = True
|
|
End If
|
|
|
|
'If CveCompra < 0 AndAlso Not TieneAmortizacion Then
|
|
' LblAmortizacion.Text = "0.00"
|
|
'End If
|
|
|
|
'If UsuarioActual.CveEmpresa = 119 AndAlso TieneAmortizacion Then
|
|
' Amortizacion = LblAmortizacion.Text.Trim.ToDecimal
|
|
' TxtSubTotal.Text = (TxtSubTotal.Text.ToDouble + Amortizacion).ToString
|
|
'End If
|
|
|
|
|
|
TempSubTotal = SubTotal
|
|
SubTotalOriginal = SubTotal
|
|
SubTotal2Original = SubTotal2
|
|
TempDescuentos = Descuento + Amortizacion
|
|
TempSubTotal2 = TempSubTotal - TempDescuentos
|
|
TempIVA = IVA
|
|
TempIEPS = IEPS
|
|
TempRetIVA = RetIVA
|
|
TempRetISR = RetISR
|
|
TempTotal = Math.Round(TempSubTotal2 + TempIVA + TempIEPS - TempRetIVA - TempRetISR + OtrosImpuestos - Amortizacion, 2)
|
|
DifTotales = Total - TempTotal
|
|
Dim DiferenciaPermitida As Decimal = 0.6D
|
|
|
|
If Math.Abs(DifTotales) > DiferenciaPermitida Then
|
|
Errores.AppendLine($"Los importes de los conceptos (Productos/Servicios) no cuadran con el total. Por favor verifique y vuelva a intentar.[{Math.Abs(DifTotales) - DiferenciaPermitida}]")
|
|
EsValido = False
|
|
ElseIf DifTotales <> 0 Then
|
|
SubTotal2 = (SubTotal2 + DifTotales)
|
|
SubTotal = (SubTotal + DifTotales)
|
|
SubTotalOriginal = SubTotal
|
|
SubTotal2Original = SubTotal2
|
|
End If
|
|
|
|
Dim DiferenciaSubtotales As Decimal = 0
|
|
If CveCompra > 0 Or CveFactura > 0 Or OCVinculada Then
|
|
|
|
If SubTotalOriginal = Nothing Then
|
|
SubTotalOriginal = 0
|
|
End If
|
|
|
|
If SubTotal2Original = Nothing Then
|
|
SubTotal2Original = 0
|
|
End If
|
|
|
|
DiferenciaSubtotales = SubTotal2Original.ToString.ToDecimal - TmpDT.SUM("Total").ToString.ToDecimal
|
|
'[IPP] PARCHE: Factura TELMEX para APH 12/ENERO/2018
|
|
If CveFactura = 286290 Then
|
|
DiferenciaSubtotales += Descuento
|
|
End If
|
|
If Math.Abs(DiferenciaSubtotales) > 1 And Not CompraNoDeducible = 1 Then 'EsNoDeducible
|
|
Errores.AppendLine("Los importes de los conceptos (Productos/Servicios) no cuadran con el total. Por favor verifique y vuelva a intentar.")
|
|
EsValido = False
|
|
Else
|
|
AjustaImporteUltimoConcepto(DiferenciaSubtotales)
|
|
End If
|
|
Else
|
|
DiferenciaSubtotales = (SubTotal2 - TmpDT.SUMD("Total")).ToString.ToDecimal
|
|
If Math.Abs(DiferenciaSubtotales) > 1 Then
|
|
Errores.AppendLine("Los importes de los conceptos (Productos/Servicios) no cuadran con el total. Por favor verifique y vuelva a intentar.")
|
|
EsValido = False
|
|
Else
|
|
AjustaImporteUltimoConcepto(DiferenciaSubtotales)
|
|
End If
|
|
End If
|
|
|
|
Return EsValido
|
|
End Function
|
|
|
|
|
|
|
|
Private Function AjustaCombustibles() As Boolean
|
|
|
|
Dim Respuesta As Boolean = False
|
|
|
|
Dim IVADetalles As Decimal = TmpDT.SUMD("IVA", " IVA > 0 ")
|
|
Dim DiferenciaIVas As Decimal = IVA - IVADetalles
|
|
|
|
|
|
If Not TmpDT.Columns.Contains("AplicaIEPS") Then
|
|
TmpDT.Columns.Add(New DataColumn("AplicaIEPS", GetType(Boolean)))
|
|
End If
|
|
|
|
If Not TmpDT.Columns.Contains("IEPSGrabaIVA") Then
|
|
TmpDT.Columns.Add(New DataColumn("IEPSGrabaIVA", GetType(Boolean)))
|
|
End If
|
|
|
|
For Each dRow As DataRow In TmpDT.Rows
|
|
Dim DttPS As DataTable = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=dRow("CvePS").ToString.ToEntero)
|
|
If DttPS IsNot Nothing AndAlso DttPS.Rows.Count > 0 Then
|
|
Dim DrPS As DataRow = DttPS.Rows(0)
|
|
dRow("AplicaIEPS") = Boolean.Parse(DrPS("AplicaIEPS").ToString)
|
|
dRow("IEPSGrabaIVA") = Boolean.Parse(DrPS("IEPSGrabaIVA").ToString)
|
|
Else
|
|
dRow("AplicaIEPS") = False
|
|
dRow("IEPSGrabaIVA") = False
|
|
End If
|
|
Next
|
|
|
|
Dim DTConsulta As New DataTable
|
|
DTConsulta = TmpDT.FiltraParametros(" AplicaIEPS = 'True' AND IEPSGrabaIVA = 'False' AND IVA > 0 ")
|
|
|
|
If DTConsulta.Rows.Count > 0 Then
|
|
|
|
Dim IndiceContador As Integer = 0
|
|
Dim IndiceUltimo As Integer = 0
|
|
Dim CantidadRegistroConIVA As Decimal
|
|
|
|
For Each dRow As DataRow In TmpDT.Rows
|
|
If Boolean.Parse(dRow("AplicaIEPS").ToString) And Boolean.Parse(dRow("IEPSGrabaIVA").ToString) = False And dRow("IVA").ToString.ToDecimal > 0 Then
|
|
IndiceUltimo = IndiceContador
|
|
CantidadRegistroConIVA = CantidadRegistroConIVA + 1
|
|
End If
|
|
IndiceContador = IndiceContador + 1
|
|
Next
|
|
|
|
IVADetalles = TmpDT.SUMD("IVA", " IVA > 0 ")
|
|
DiferenciaIVas = IVA - IVADetalles
|
|
|
|
If Math.Abs(DiferenciaIVas) > 0.01D Then
|
|
|
|
If (TmpDT.Rows(IndiceUltimo)("IVA").ToString.ToDecimal + DiferenciaIVas) < 0 Then
|
|
|
|
Dim AjusteteDividido As Decimal = Math.Abs(DiferenciaIVas) / CantidadRegistroConIVA
|
|
|
|
For Each dRow As DataRow In TmpDT.Rows
|
|
If Boolean.Parse(dRow("AplicaIEPS").ToString) And Boolean.Parse(dRow("IEPSGrabaIVA").ToString) = False And dRow("IVA").ToString.ToDecimal > 0 Then
|
|
dRow("IVA") = dRow("IVA").ToString.ToDecimal - AjusteteDividido
|
|
End If
|
|
Next
|
|
Else
|
|
TmpDT.Rows(IndiceUltimo)("IVA") = TmpDT.Rows(IndiceUltimo)("IVA").ToString.ToDecimal + DiferenciaIVas
|
|
End If
|
|
TmpDT.AcceptChanges()
|
|
End If
|
|
|
|
End If
|
|
|
|
'Revalidacion de ajuste
|
|
IVADetalles = TmpDT.SUMD("IVA", " IVA > 0 ")
|
|
DiferenciaIVas = IVA - IVADetalles
|
|
|
|
If Math.Abs(DiferenciaIVas) > 0.01D Then
|
|
Respuesta = False
|
|
If IVADetalles > 0 Then
|
|
|
|
For Each dRow As DataRow In TmpDT.Rows
|
|
If dRow("IVA").ToString.ToDecimal > 0 Then
|
|
dRow("IVA") = dRow("IVA").ToString.ToDecimal + DiferenciaIVas
|
|
TmpDT.AcceptChanges()
|
|
Respuesta = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
Else
|
|
Alert("Los productos especificados en el listado no tienen asignado impuesto IVA, favor de realizar la corrección en el producto que aplique el impuesto.", TipoMensaje.MsgAdvertencia)
|
|
Respuesta = False
|
|
End If
|
|
Else
|
|
Respuesta = True
|
|
End If
|
|
|
|
If Respuesta Then
|
|
|
|
Dim IEPSPSDetalles As Decimal = TmpDT.SUMD("IEPSPS", " IEPSPS > 0 ")
|
|
Dim DiferenciaIEPSPS As Decimal = IEPS - IEPSPSDetalles
|
|
|
|
Dim DTConsultaIEPSPS As New DataTable
|
|
DTConsultaIEPSPS = TmpDT.FiltraParametros(" AplicaIEPS = 'True'")
|
|
Dim IndiceContador As Integer = 0
|
|
Dim IndicePrimero As Integer = 0
|
|
|
|
For Each dRow As DataRow In TmpDT.Rows
|
|
If Boolean.Parse(dRow("AplicaIEPS").ToString) And dRow("IEPSPS").ToString.ToDecimal > 0 Then
|
|
IndicePrimero = IndiceContador
|
|
Exit For
|
|
End If
|
|
IndiceContador = IndiceContador + 1
|
|
Next
|
|
If DiferenciaIEPSPS.RoundSQL(2) <> 0 Then
|
|
|
|
TmpDT.Rows(IndicePrimero)("IEPSPS") = TmpDT.Rows(IndicePrimero)("IEPSPS").ToString.ToDecimal + DiferenciaIEPSPS
|
|
TmpDT.AcceptChanges()
|
|
End If
|
|
|
|
For Each dRow As DataRow In TmpDT.Rows
|
|
If dRow("IEPSPSPorcentaje").ToString.ToDecimal > 0 AndAlso dRow("IEPSPS").ToString.ToDecimal = 0 Then
|
|
dRow("IEPSPSPorcentaje") = 0
|
|
End If
|
|
Next
|
|
TmpDT.AcceptChanges()
|
|
End If
|
|
|
|
Return Respuesta
|
|
|
|
End Function
|
|
|
|
|
|
Private Function AjustaIVA() As Boolean
|
|
|
|
Dim Respuesta As Boolean = False
|
|
|
|
Dim IVADetalles As Decimal = TmpDT.SUMD("IVA", " IVA > 0 ")
|
|
Dim DiferenciaIVas As Decimal = IVA - IVADetalles
|
|
|
|
If Math.Abs(DiferenciaIVas) > 0 Then
|
|
If Math.Abs(DiferenciaIVas) <= 0.05 Then
|
|
|
|
Dim DTConsulta As New DataTable
|
|
DTConsulta = TmpDT.FiltraParametros(" IVA > 0 ")
|
|
|
|
If DTConsulta.Rows.Count > 0 Then
|
|
|
|
Dim IndiceContador As Integer = 0
|
|
Dim IndiceUltimo As Integer = 0
|
|
Dim CantidadRegistroConIVA As Decimal
|
|
|
|
For Each dRow As DataRow In TmpDT.Rows
|
|
If dRow("IVA").ToString.ToDecimal > 0 Then
|
|
IndiceUltimo = IndiceContador
|
|
CantidadRegistroConIVA = CantidadRegistroConIVA + 1
|
|
End If
|
|
IndiceContador = IndiceContador + 1
|
|
Next
|
|
|
|
IVADetalles = TmpDT.SUMD("IVA", " IVA > 0 ")
|
|
DiferenciaIVas = IVA - IVADetalles
|
|
|
|
If Math.Abs(DiferenciaIVas) > 0.0D Then
|
|
|
|
If (TmpDT.Rows(IndiceUltimo)("IVA").ToString.ToDecimal + DiferenciaIVas) < 0 Then
|
|
|
|
Dim AjusteteDividido As Decimal = Math.Abs(DiferenciaIVas) / CantidadRegistroConIVA
|
|
|
|
For Each dRow As DataRow In TmpDT.Rows
|
|
dRow("IVA") = dRow("IVA").ToString.ToDecimal - AjusteteDividido
|
|
Next
|
|
Else
|
|
TmpDT.Rows(IndiceUltimo)("IVA") = TmpDT.Rows(IndiceUltimo)("IVA").ToString.ToDecimal + DiferenciaIVas
|
|
End If
|
|
TmpDT.AcceptChanges()
|
|
End If
|
|
End If
|
|
|
|
'Revalidacion de ajuste
|
|
IVADetalles = TmpDT.SUMD("IVA", " IVA > 0 ")
|
|
DiferenciaIVas = IVA - IVADetalles
|
|
|
|
If Math.Abs(DiferenciaIVas) > 0.01D Then
|
|
Respuesta = False
|
|
If IVADetalles > 0 Then
|
|
|
|
For Each dRow As DataRow In TmpDT.Rows
|
|
If dRow("IVA").ToString.ToDecimal > 0 Then
|
|
dRow("IVA") = dRow("IVA").ToString.ToDecimal + DiferenciaIVas
|
|
TmpDT.AcceptChanges()
|
|
Respuesta = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
Else
|
|
Errores.AppendLine("Los productos especificados en el listado no tienen asignado impuesto IVA, favor de realizar la corrección en el producto que aplique el impuesto.")
|
|
Respuesta = False
|
|
End If
|
|
Else
|
|
Respuesta = True
|
|
End If
|
|
|
|
Else
|
|
Errores.AppendLine($"existe una diferencia de {DiferenciaIVas} entre el IVA de la compra y los detalles.")
|
|
Respuesta = False
|
|
End If
|
|
Else
|
|
Respuesta = True
|
|
End If
|
|
|
|
Return Respuesta
|
|
|
|
End Function
|
|
|
|
Private Function AjustaRetIVA() As Boolean
|
|
|
|
Dim Respuesta As Boolean = False
|
|
|
|
Dim RetIVADetalles As Decimal = TmpDT.SUMD("RetIVA", " RetIVA > 0 ")
|
|
Dim DiferenciaRetIVA As Decimal = RetIVA - RetIVADetalles
|
|
|
|
If Math.Abs(DiferenciaRetIVA) > 0 Then
|
|
If Math.Abs(DiferenciaRetIVA) <= 0.05 Then
|
|
|
|
Dim DTConsulta As New DataTable
|
|
DTConsulta = TmpDT.FiltraParametros(" RetIVA > 0 ")
|
|
|
|
If DTConsulta.Rows.Count > 0 Then
|
|
|
|
Dim IndiceContador As Integer = 0
|
|
Dim IndiceUltimo As Integer = 0
|
|
Dim CantidadRegistroConRetIVA As Decimal
|
|
|
|
For Each dRow As DataRow In TmpDT.Rows
|
|
If dRow("RetIVA").ToString.ToDecimal > 0 Then
|
|
IndiceUltimo = IndiceContador
|
|
CantidadRegistroConRetIVA = CantidadRegistroConRetIVA + 1
|
|
End If
|
|
IndiceContador = IndiceContador + 1
|
|
Next
|
|
|
|
RetIVADetalles = TmpDT.SUMD("RetIVA", " RetIVA > 0 ")
|
|
DiferenciaRetIVA = RetIVA - RetIVADetalles
|
|
|
|
If Math.Abs(DiferenciaRetIVA) > 0.0D Then
|
|
|
|
If (TmpDT.Rows(IndiceUltimo)("RetIVA").ToString.ToDecimal + DiferenciaRetIVA) < 0 Then
|
|
|
|
Dim AjusteteDividido As Decimal = Math.Abs(DiferenciaRetIVA) / CantidadRegistroConRetIVA
|
|
|
|
For Each dRow As DataRow In TmpDT.Rows
|
|
dRow("RetIVA") = dRow("RetIVA").ToString.ToDecimal - AjusteteDividido
|
|
Next
|
|
|
|
Else
|
|
TmpDT.Rows(IndiceUltimo)("RetIVA") = TmpDT.Rows(IndiceUltimo)("RetIVA").ToString.ToDecimal + DiferenciaRetIVA
|
|
End If
|
|
|
|
TmpDT.AcceptChanges()
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
'Revalidacion de ajuste
|
|
RetIVADetalles = TmpDT.SUMD("RetIVA", " RetIVA > 0 ")
|
|
DiferenciaRetIVA = RetIVA - RetIVADetalles
|
|
|
|
If Math.Abs(DiferenciaRetIVA) > 0.01D Then
|
|
Respuesta = False
|
|
If RetIVADetalles > 0 Then
|
|
|
|
For Each dRow As DataRow In TmpDT.Rows
|
|
If dRow("RetIVA").ToString.ToDecimal > 0 Then
|
|
dRow("RetIVA") = dRow("RetIVA").ToString.ToDecimal + DiferenciaRetIVA
|
|
TmpDT.AcceptChanges()
|
|
Respuesta = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
Else
|
|
Errores.AppendLine("Los productos especificados en el listado no tienen asignado impuesto RetIVA, favor de realizar la corrección en el producto que aplique el impuesto.")
|
|
Respuesta = False
|
|
End If
|
|
Else
|
|
Respuesta = True
|
|
End If
|
|
|
|
Else
|
|
Errores.AppendLine($"existe una diferencia de {DiferenciaRetIVA} entre el RetIVA de la compra y los detalles.")
|
|
End If
|
|
Else
|
|
Respuesta = True
|
|
|
|
End If
|
|
|
|
Return Respuesta
|
|
|
|
End Function
|
|
|
|
Private Function AjustaRetISR() As Boolean
|
|
|
|
Dim Respuesta As Boolean = False
|
|
|
|
Dim RetISRDetalles As Decimal = TmpDT.SUMD("RetISR", " RetISR > 0 ")
|
|
Dim DiferenciaRetISR As Decimal = RetISR - RetISRDetalles
|
|
|
|
If Math.Abs(DiferenciaRetISR) > 0 Then
|
|
If Math.Abs(DiferenciaRetISR) <= 0.05 Then
|
|
|
|
Dim DTConsulta As New DataTable
|
|
DTConsulta = TmpDT.FiltraParametros(" RetISR > 0 ")
|
|
|
|
If DTConsulta.Rows.Count > 0 Then
|
|
|
|
Dim IndiceContador As Integer = 0
|
|
Dim IndiceUltimo As Integer = 0
|
|
Dim CantidadRegistroConRetISR As Decimal
|
|
|
|
For Each dRow As DataRow In TmpDT.Rows
|
|
If dRow("RetISR").ToString.ToDecimal > 0 Then
|
|
IndiceUltimo = IndiceContador
|
|
CantidadRegistroConRetISR = CantidadRegistroConRetISR + 1
|
|
End If
|
|
IndiceContador = IndiceContador + 1
|
|
Next
|
|
|
|
RetISRDetalles = TmpDT.SUMD("RetISR", " RetISR > 0 ")
|
|
DiferenciaRetISR = RetISR - RetISRDetalles
|
|
|
|
If Math.Abs(DiferenciaRetISR) > 0.0D Then
|
|
|
|
If (TmpDT.Rows(IndiceUltimo)("RetISR").ToString.ToDecimal + DiferenciaRetISR) < 0 Then
|
|
|
|
Dim AjusteteDividido As Decimal = Math.Abs(DiferenciaRetISR) / CantidadRegistroConRetISR
|
|
|
|
For Each dRow As DataRow In TmpDT.Rows
|
|
dRow("RetISR") = dRow("RetISR").ToString.ToDecimal - AjusteteDividido
|
|
Next
|
|
|
|
Else
|
|
TmpDT.Rows(IndiceUltimo)("RetISR") = TmpDT.Rows(IndiceUltimo)("RetISR").ToString.ToDecimal + DiferenciaRetISR
|
|
End If
|
|
|
|
TmpDT.AcceptChanges()
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
'Revalidacion de ajuste
|
|
RetISRDetalles = TmpDT.SUMD("RetISR", " RetISR > 0 ")
|
|
DiferenciaRetISR = RetISR - RetISRDetalles
|
|
|
|
If Math.Abs(DiferenciaRetISR) > 0.01D Then
|
|
Respuesta = False
|
|
If RetISRDetalles > 0 Then
|
|
|
|
For Each dRow As DataRow In TmpDT.Rows
|
|
If dRow("RetISR").ToString.ToDecimal > 0 Then
|
|
dRow("RetISR") = dRow("RetISR").ToString.ToDecimal + DiferenciaRetISR
|
|
TmpDT.AcceptChanges()
|
|
Respuesta = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
Else
|
|
Errores.AppendLine("Los productos especificados en el listado no tienen asignado impuesto RetISR, favor de realizar la corrección en el producto que aplique el impuesto.")
|
|
Respuesta = False
|
|
End If
|
|
Else
|
|
Respuesta = True
|
|
End If
|
|
|
|
Else
|
|
Errores.AppendLine($"existe una diferencia de {DiferenciaRetISR} entre el RetISR de la compra y los detalles.")
|
|
Respuesta = False
|
|
End If
|
|
Else
|
|
Respuesta = True
|
|
End If
|
|
|
|
Return Respuesta
|
|
|
|
End Function
|
|
|
|
Private Function AgregaIEPSReembolso(CvePS As Integer) As Boolean
|
|
|
|
Dim respuesta As Boolean = True
|
|
|
|
If IEPSGasto Or OtrosImpuestosGasto Then
|
|
|
|
'AGREGA IEPS COMO CONCEPTO
|
|
If IEPSGasto Then
|
|
AgregarConceptoIEPS(TrasladoIEPS, CvePS)
|
|
For Each Dr As DataRow In TmpDT.Rows
|
|
Dr("IEPSPS") = 0
|
|
Dr("IEPSPSPorcentaje") = 0
|
|
Next
|
|
TmpDT.AcceptChanges()
|
|
End If
|
|
'AGREGA OTROS IMPUESTOS COMO CONCEPTO
|
|
If OtrosImpuestosGasto Then
|
|
AgregarConceptoIEPS(OtrosImpuestos, CvePS)
|
|
End If
|
|
Else
|
|
respuesta = False
|
|
Errores.AppendLine("Debe seleccionar al menos un impuesto. ")
|
|
End If
|
|
CalculaTotales()
|
|
|
|
Return respuesta
|
|
|
|
End Function
|
|
|
|
|
|
Private Sub AgregarConceptoIEPS(IEPS As Decimal, CvePS1 As Integer)
|
|
Dim SubTotalR As Decimal = TmpDT.SUM("Total").ToString.ToDecimal
|
|
|
|
Dim PSS As DataTable = GlobalDTPS(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CvePS = {0} ", CvePS1), "PS")
|
|
Dim PSS2 As DataTable = TmpDT.FiltraParametros(String.Format("CvePS = {0} ", CvePS1), "PS")
|
|
|
|
If PSS.Rows.Count > 0 Or PSS2.Rows.Count > 0 Then
|
|
Dim CveUM As Integer = 0
|
|
Dim UM As String = ""
|
|
Dim CveClasificacion As Integer = 0
|
|
Dim Clasificacion As String = ""
|
|
Dim CvePS As Integer = 0
|
|
Dim PS As String = ""
|
|
Dim CveTipoPS As Integer = 0
|
|
|
|
If PSS.Rows.Count > 0 Then
|
|
CveUM = PSS.Rows(0)("CveUM").ToString.ToEntero
|
|
UM = PSS.Rows(0)("UnidadMedida").ToString
|
|
CveClasificacion = PSS.Rows(0)("CveClasificacion").ToString.ToEntero
|
|
Clasificacion = PSS.Rows(0)("Clasificacion").ToString
|
|
CvePS = PSS.Rows(0)("CvePS").ToString.ToEntero
|
|
PS = PSS.Rows(0)("PS").ToString
|
|
CveTipoPS = PSS.Rows(0)("CveTipoPS").ToString.ToEntero
|
|
End If
|
|
|
|
Dim Cantidad As Decimal = 1
|
|
Dim CveSubProyectoContrato As String = "-1"
|
|
Dim CveProyecto As String = "-1"
|
|
Dim SubProyecto As String = "SE"
|
|
Dim Proyecto As String = "SE"
|
|
Dim Obs As String = ""
|
|
Dim PU As Decimal = IEPS
|
|
Dim Total As Decimal = Cantidad * PU
|
|
Dim IVA As Decimal = 0
|
|
Dim Descuento As Decimal = 0
|
|
|
|
If PSS2.Rows.Count > 0 Then
|
|
CveUM = PSS2.Rows(0)("CveUM").ToString.ToEntero
|
|
UM = PSS2.Rows(0)("UM").ToString
|
|
CveClasificacion = PSS2.Rows(0)("CveClasificacion").ToString.ToEntero
|
|
Clasificacion = PSS2.Rows(0)("Clasificacion").ToString
|
|
CvePS = PSS2.Rows(0)("CvePS").ToString.ToEntero
|
|
PS = PSS2.Rows(0)("PS").ToString
|
|
CveTipoPS = PSS2.Rows(0)("CveTipoPS").ToString.ToEntero
|
|
|
|
CveSubProyectoContrato = PSS2.Rows(0)("CveSubProyecto").ToString
|
|
CveProyecto = PSS2.Rows(0)("CveProyecto").ToString
|
|
SubProyecto = PSS2.Rows(0)("SubProyecto").ToString
|
|
Proyecto = PSS2.Rows(0)("Proyecto").ToString
|
|
Obs = PSS2.Rows(0)("Obs").ToString
|
|
|
|
Dim CveTipoGasto As Integer = PSS2.Rows(0)("CveTipoGasto").ToString.ToEntero
|
|
Dim TipoGasto As String = PSS2.Rows(0)("TipoGasto").ToString
|
|
|
|
AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, 0, 0, 0, 0, Descuento, TCalculaTotales:=False, CveTipoGasto:=CveTipoGasto,
|
|
TipoGasto:=TipoGasto, ModalidadAccionPS:=EnumModalidadAccionPS.Agregar)
|
|
|
|
Else
|
|
AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, 0, 0, 0, 0, Descuento, TCalculaTotales:=False)
|
|
End If
|
|
End If
|
|
|
|
Dim SubTotalIEPS As Decimal = TmpDT.SUMD("Total")
|
|
|
|
Me.SubTotal = Math.Round(SubTotalIEPS, 2)
|
|
Me.SubTotalConceptos = Math.Round(SubTotalIEPS, 2)
|
|
|
|
PSS.Dispose()
|
|
End Sub
|
|
|
|
Private Function AddPS(Cantidad As Decimal, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, CvePS As Integer, PS As String, CveTipoPS As Integer, CveSubProyectoContrato As String, SubProyecto As String, Proyecto As String, CveProyecto As String,
|
|
Obs As String, PU As Decimal, Total As Decimal, IVA As Decimal, RetIVA As Decimal, RetISR As Decimal, IEPSPS As Decimal, IEPSPSIVA As Decimal, Descuento As Decimal, Optional CveOrdenCompraDetalle As Integer = -1, Optional TCalculaTotales As Boolean = True,
|
|
Optional PSCodigo As String = "-", Optional PSDescripcion As String = "-", Optional CantidadF As Double = -1, Optional EntregaDirecta As Integer = -1, Optional OtrosGastos As Decimal = 0,
|
|
Optional CveSATPS As Integer = -1, Optional CargaXml As Boolean = False, Optional CveTipoGasto As Integer = -1, Optional TipoGasto As String = "", Optional PorcentajeIVA As Decimal = 0,
|
|
Optional PorcentajeIEPS As Decimal = 0, Optional PorcentajeRetIVA As Decimal = 0, Optional PorcentajeRetISR As Decimal = 0, Optional NoDeducible As Boolean = False, Optional CveContratoDetalle As Integer = -1, Optional CveCultivoCuadroDetalle As Integer = -1,
|
|
Optional CveSATPSActualizado As Boolean = False, Optional TemporadaCuadro As String = "", Optional ModalidadAccionPS As EnumModalidadAccionPS = EnumModalidadAccionPS.Agregar, Optional Con As Integer = -1,
|
|
Optional CveProgramaOperativo As Integer = -1, Optional CveUnidadAdministrativa As Integer = -1, Optional CveFuenteFinanciamiento As Integer = -1, Optional CveTipoGastoAC As Integer = -1, Optional CveClasificacionOG As Integer = -1) As Integer
|
|
|
|
Dim Row As DataRow = Nothing
|
|
|
|
Row = TmpDT.NewRow()
|
|
Dim Retorno As Integer = 0
|
|
Dim CveContrato As Integer = -1
|
|
Dim CveSubProyecto As Integer = -1
|
|
Dim Valores As String()
|
|
|
|
''CONTRATOS
|
|
If CveSubProyectoContrato.Contains("|"c) Then
|
|
Valores = CveSubProyectoContrato.Split("|"c)
|
|
CveContrato = Valores(1).ToEntero
|
|
CveSubProyecto = Valores(0).ToEntero
|
|
Else
|
|
CveSubProyecto = CveSubProyectoContrato.ToEntero
|
|
End If
|
|
|
|
'DR PS
|
|
Dim DrPS As DataRow = Nothing
|
|
If CvePS > 0 Then
|
|
DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).Rows(0)
|
|
End If
|
|
|
|
If DrPS IsNot Nothing Then
|
|
Row("PSCodigo") = If(PSCodigo = "", DrPS("PSCodigo").ToString, PSCodigo)
|
|
Row("CveMetodoInventario") = DrPS("Inv_CveMetodoInventario").ToString.ToEntero
|
|
|
|
If CveTipoCompra = EnumTipoCompra.Garantia AndAlso DrPS("AplicaSerie").ToString = "True" Then
|
|
Row("CveMetodoInventario") = "1"
|
|
End If
|
|
|
|
Else
|
|
Row("PSCodigo") = PSCodigo
|
|
Row("CveMetodoInventario") = 0
|
|
End If
|
|
|
|
If ModalidadAccionPS = EnumModalidadAccionPS.Actualizar Then
|
|
Row("Consec") = Con
|
|
Else
|
|
Row("Consec") = TmpDT.Rows.Count + 1
|
|
End If
|
|
|
|
If (CFDIVersion = EnumCFDIVersion.v33 Or CFDIVersion = EnumCFDIVersion.v40) And CveSATPS > 0 Then
|
|
Dim DrPSSAT As DataRow = Nothing
|
|
If CargaXml Then
|
|
DrPSSAT = GlobalDTPSATPS("-1", CveSATPS.ToString).FiltroPrimero("")
|
|
Else
|
|
DrPSSAT = GlobalDTPSATPS("-1", CveSATPS.ToString).FiltroPrimero("")
|
|
End If
|
|
If DrPSSAT IsNot Nothing Then
|
|
Row("SATClaveProductoServicio") = DrPSSAT("SATClaveProductoServicio").ToString
|
|
Row("CveSATPS") = DrPSSAT("CveSATPS").ToString
|
|
If CveSATPSActualizado Then
|
|
Row("CveSATPSActualizado") = 1
|
|
Else
|
|
Row("CveSATPSActualizado") = 0
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
Try
|
|
If (DrPS("CvePSCargo").ToString <> "") Then 'si es un producto de usado. que se registre contablemente como alamcen(como producto)
|
|
CveTipoPS = 2
|
|
End If
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
|
|
Dim DecimalesPermitidos As Integer = 6
|
|
|
|
Row("CveConcepto") = TmpDT.Rows.Count + 1
|
|
Row("Cantidad") = Math.Round(Cantidad, DecimalesPermitidos)
|
|
Row("CantidadF") = If(CantidadF = -1, Math.Round(Cantidad, DecimalesPermitidos), Math.Round(CantidadF, DecimalesPermitidos))
|
|
Row("CveUM") = CveUM
|
|
Row("UM") = UM
|
|
Row("CveClasificacion") = CveClasificacion
|
|
Row("CveClasificacionActualizar") = CveClasificacion
|
|
Row("Clasificacion") = Clasificacion
|
|
Row("CvePS") = CvePS
|
|
Row("PS") = PS
|
|
Row("CveTipoPS") = CveTipoPS
|
|
|
|
Row("PSDescripcion") = PSDescripcion
|
|
Row("CveSubProyecto") = CveSubProyecto.ToEntero
|
|
Row("CveProyecto") = CveProyecto.ToEntero
|
|
Row("CveContrato") = CveContrato.ToEntero
|
|
Row("SubProyecto") = If(SubProyecto = "Seleccione", "Sin Sub Proyecto", SubProyecto)
|
|
Row("Proyecto") = If(Proyecto = "Seleccione", "Sin Proyecto", Proyecto)
|
|
Row("CveActivoFijo") = -1
|
|
Row("Obs") = Obs
|
|
Row("CveActivoFijo") = -1
|
|
Row("CodAF") = "-1"
|
|
Row("TipoAF") = -1
|
|
Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle
|
|
Row("EntregaDirecta") = EntregaDirecta
|
|
|
|
Row("NoDeducible") = NoDeducible
|
|
|
|
|
|
Total = Math.Round(PU, DecimalesPermitidos) * Cantidad - Descuento
|
|
Row("PU") = Math.Round(PU, DecimalesPermitidos)
|
|
If CargaXml And (CFDIVersion = EnumCFDIVersion.v33 Or CFDIVersion = EnumCFDIVersion.v40) Then
|
|
|
|
If CveFactura > 0 And IVA = 0 Then
|
|
Row("IVA") = 0
|
|
Row("IVAPorcentaje") = 0
|
|
Else
|
|
Row("IVA") = Math.Round(IVA, DecimalesPermitidos)
|
|
Row("IVAPorcentaje") = PorcentajeIVA
|
|
End If
|
|
|
|
Row("RetIVA") = Math.Round(RetIVA, DecimalesPermitidos)
|
|
Row("RetIVAPorcentaje") = PorcentajeRetIVA
|
|
Row("RetISR") = Math.Round(RetISR, DecimalesPermitidos)
|
|
Row("RetISRPorcentaje") = PorcentajeRetISR
|
|
Row("IEPSPS") = Math.Round(IEPSPS, DecimalesPermitidos)
|
|
Row("IEPSPSPorcentaje") = PorcentajeIEPS
|
|
Else
|
|
'If DdlIVA.SelectedValue.ToDouble = 0 Then Row("IVA") = 0 Else Row("IVA") = Math.Round(IVA * Total, DecimalesPermitidos)
|
|
|
|
If CveFactura > 0 And IVA = 0 Then
|
|
Row("IVA") = 0
|
|
Row("IVAPorcentaje") = 0
|
|
Else
|
|
Row("IVA") = (PorcentajeIVA * Total).RoundSQL
|
|
Row("IVAPorcentaje") = PorcentajeIVA
|
|
End If
|
|
|
|
Row("RetIVA") = (PorcentajeRetIVA * Total).RoundSQL
|
|
Row("RetIVAPorcentaje") = PorcentajeRetIVA
|
|
Row("RetISR") = (PorcentajeRetISR * Total).RoundSQL
|
|
Row("RetISRPorcentaje") = PorcentajeRetISR
|
|
Row("IEPSPS") = (PorcentajeIEPS * Total).RoundSQL
|
|
Row("IEPSPSPorcentaje") = PorcentajeIEPS
|
|
End If
|
|
|
|
Row("ImporteConImpuestos") = (Row("Cantidad").ToString.ToDecimal * Row("PU").ToString.ToDecimal) + Row("IVA").ToString.ToDecimal + Row("IEPSPS").ToString.ToDecimal - (Row("RetIVA").ToString.ToDecimal + Row("RetISR").ToString.ToDecimal)
|
|
Row("ImporteSinImpuestos") = Row("Cantidad").ToString.ToDecimal * Row("PU").ToString.ToDecimal
|
|
|
|
Row("IEPSPSIVA") = Math.Round(IEPSPSIVA * Total, DecimalesPermitidos)
|
|
Row("IEPSPSIVAPorcentaje") = IEPSPSIVA
|
|
Row("Descuento") = Math.Round(Descuento, DecimalesPermitidos)
|
|
Row("OtrosGastos") = Math.Round(OtrosGastos, DecimalesPermitidos)
|
|
Row("Total") = Math.Round(Total, DecimalesPermitidos)
|
|
|
|
Row("CveTipoGasto") = CveTipoGasto
|
|
Row("TipoGasto") = If(CveTipoGasto > 0, TipoGasto, "")
|
|
|
|
Row("CveContratoDetalle") = CveContratoDetalle
|
|
|
|
Row("CveCultivoCuadroDetalle") = CveCultivoCuadroDetalle
|
|
Row("TemporadaCuadro") = TemporadaCuadro
|
|
|
|
If UsuarioActual.Empresa.UsaAC Then
|
|
Row("CveProgramaOperativo") = CveProgramaOperativo
|
|
Row("CveUnidadAdministrativa") = CveUnidadAdministrativa
|
|
Row("CveFuenteFinanciamiento") = CveFuenteFinanciamiento
|
|
Row("CveTipoGastoAC") = CveTipoGastoAC
|
|
Row("CveClasificacionOG") = CveClasificacionOG
|
|
End If
|
|
'Esta parte es para validar cuando la factura tenga ieps en o se asignara el ieps como una partida ya no se considere
|
|
If (CveFactura > 0 Or CveCompra > 0) And IEPS = 0 Then
|
|
Row("IEPSPS") = 0
|
|
Row("IEPSPSPorcentaje") = 0
|
|
End If
|
|
TmpDT.Rows.Add(Row)
|
|
TmpDT.Rows.IndexOf(Row)
|
|
|
|
If TCalculaTotales Then
|
|
CalculaTotales(True)
|
|
End If
|
|
|
|
Return Retorno
|
|
End Function
|
|
|
|
Private Sub CalculaTotales(Optional CalculaIVA As Boolean = False, Optional EsNoDeducible As Boolean = False)
|
|
'VARIABLES DE CALCULO
|
|
Dim LocalSubTotal, LocalDescuentos, LocalAmortizacion, LocalIVA, LocalSubTotal2, LocalRetIVA, LocalRetISR, LocalIEPSPS, LocalTotal, LocalSubTotalIVA, LocalSubTotalIEPSIVA As Decimal
|
|
|
|
'HACEMOS CALCULOS
|
|
LocalSubTotalIVA = TmpDT.SUMD("IVA")
|
|
LocalSubTotalIEPSIVA = TmpDT.SUMD("IEPSPSIVA")
|
|
LocalSubTotal = (TmpDT.SUMD("Total") + TmpDT.SUMD("Descuento")).RoundSQL(2)
|
|
LocalRetIVA = TmpDT.SUMD("RetIVA")
|
|
LocalRetISR = TmpDT.SUMD("RetISR")
|
|
LocalIEPSPS = TmpDT.SUMD("IEPSPS")
|
|
|
|
If CveCompra > 0 AndAlso CveFactura > 0 Then
|
|
LocalIVA = IVA
|
|
Else
|
|
LocalIVA = If(TmpDT.SUM("IVA") > 0, LocalSubTotalIVA + LocalSubTotalIEPSIVA, 0)
|
|
End If
|
|
|
|
LocalDescuentos = TmpDT.SUMD("Descuento")
|
|
|
|
If Not CveCompra > 0 Then
|
|
LocalAmortizacion = Me.Amortizacion
|
|
End If
|
|
|
|
'RETENCIONES
|
|
Dim Retenciones As Decimal = 0
|
|
Retenciones = LocalRetIVA
|
|
Retenciones += LocalRetISR
|
|
|
|
|
|
LocalSubTotal2 = LocalSubTotal - LocalDescuentos
|
|
LocalTotal = LocalSubTotal2 + LocalIVA + LocalIEPSPS - Retenciones
|
|
|
|
'ASIGNAMOS VALORES A VISTA
|
|
If CveCompra > 0 Or CveFactura > 0 Or Me.OCVinculada Then
|
|
SubTotal = LocalSubTotal
|
|
SubTotal2 = LocalSubTotal2
|
|
Descuento = LocalDescuentos
|
|
|
|
If EsNoDeducible Then
|
|
IVA = LocalIVA
|
|
RetIVA = LocalRetIVA
|
|
RetISR = LocalRetISR
|
|
IEPS = LocalIEPSPS
|
|
End If
|
|
|
|
Total = LocalTotal
|
|
Else
|
|
SubTotal = LocalSubTotal
|
|
SubTotal2 = LocalSubTotal2
|
|
IVA = LocalIVA
|
|
Descuento = LocalDescuentos
|
|
RetIVA = LocalRetIVA
|
|
RetISR = LocalRetISR
|
|
IEPS = LocalIEPSPS
|
|
Total = LocalTotal
|
|
'VALORES PROPIEDAD
|
|
CompraSaldo = LocalTotal
|
|
|
|
End If
|
|
Me.NumNoDed = TmpDT.COUNT("CvePS", "NoDeducible = True ")
|
|
|
|
End Sub
|
|
|
|
Private Function UpdatePSReembolso(Index As Integer, CvePS As Integer) As Boolean
|
|
|
|
Dim Respuesta As Boolean = True
|
|
|
|
Dim DrPS As DataRow = Nothing
|
|
Try
|
|
DrPS = TmpDT.Select($"Consec = {Index}")(0)
|
|
If DrPS Is Nothing Then
|
|
Errores.AppendLine($"No se encontrol el producto con index {Index}")
|
|
Return False
|
|
End If
|
|
Catch ex As Exception
|
|
Errores.AppendLine($"No se encontrol el producto con index {Index}")
|
|
Return False
|
|
End Try
|
|
|
|
'DATOS GENERALES
|
|
DrPS("Obs") = ""
|
|
DrPS("Proyecto") = Proyecto
|
|
DrPS("CveProyecto") = CveProyecto
|
|
DrPS("SubProyecto") = SubProyecto
|
|
DrPS("CveSubProyecto") = CveSubProyecto
|
|
DrPS("CveContratoDetalle") = -1
|
|
|
|
'IMPORTES - [CANTIDAD Y PRECIO]
|
|
Dim Cantidad As Double = DrPS("Cantidad").ToString.ToDouble
|
|
Dim PU As Double = DrPS("PU").ToString.ToDouble
|
|
Dim Descuento As Double = DrPS("Descuento").ToString.ToDouble
|
|
Dim Total As Double = (Cantidad * PU) - Descuento
|
|
DrPS("NoDeducible") = NoDeducible
|
|
|
|
Dim PSRow As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
|
|
If PSRow IsNot Nothing Then
|
|
Dim CveTipoPS As Integer = PSRow("CveTipoPS").ToString.ToEntero
|
|
If PSRow("CvePSCargo").ToString <> "" Then 'si es un producto de usado. que se registre contablemente como alamcen(como producto)
|
|
CveTipoPS = 2
|
|
End If
|
|
|
|
DrPS("CveClasificacion") = PSRow("CveClasificacion").ToString
|
|
DrPS("Clasificacion") = PSRow("Clasificacion").ToString
|
|
DrPS("CvePS") = CvePS
|
|
DrPS("PS") = PSRow("PS").ToString
|
|
DrPS("CveTipoPS") = CveTipoPS
|
|
DrPS("CveSATPS") = PSRow("CveSATPS").ToString.ToEntero
|
|
DrPS("SATClaveProductoServicio") = PSRow("SATClaveProductoServicio").ToString
|
|
DrPS("CveSATPSActualizado") = 0
|
|
|
|
DrPS("CveUM") = PSRow("CveUnidadMedida").ToString.ToEntero
|
|
DrPS("UM") = PSRow("UnidadMedida").ToString
|
|
|
|
Dim DrTipoGasto As DataRow = Me.DTTiposGastos.FiltroPrimero("")
|
|
|
|
DrPS("CveTipoGasto") = DrTipoGasto("CveTipoGasto")
|
|
DrPS("TipoGasto") = DrTipoGasto("TipoGasto")
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(562).ToEntero > 0 Then
|
|
DrPS("AplicaCostoIndirecto") = "0"
|
|
End If
|
|
|
|
DrPS("CveCultivoCuadroDetalle") = -1
|
|
DrPS("TemporadaCuadro") = ""
|
|
|
|
Else
|
|
Errores.AppendLine($"No se encontrol el producto con CvePS {CvePS}")
|
|
Respuesta = False
|
|
End If
|
|
TmpDT.AcceptChanges()
|
|
Return Respuesta
|
|
End Function
|
|
|
|
Private Sub ValidacionesTotalesXml()
|
|
|
|
If Not TmpDT.Columns.Contains("Amortizacion") Then
|
|
TmpDT.Columns.Add("Amortizacion", GetType(Decimal))
|
|
End If
|
|
|
|
Dim Msg As String = ""
|
|
Dim SubtotalTemp As Decimal = TmpDT.SUMD("Total") + Math.Round(TmpDT.SUM("Descuento") + Math.Round(TmpDT.SUM("Amortizacion")), 2)
|
|
Dim DescuentosTemp As Decimal = TmpDT.SUMD("Descuento")
|
|
Dim Subtotal2Temp As Decimal = TmpDT.SUMD("Total")
|
|
Dim IVATemp As Decimal = TmpDT.SUMD("IVA")
|
|
Dim IEPSTemp As Decimal = TmpDT.SUMD("IEPSPS")
|
|
Dim RetIVATemp As Decimal = TmpDT.SUMD("RetIVA")
|
|
Dim RetISRTemp As Decimal = TmpDT.SUMD("RetISR")
|
|
Dim TotalTemp As Decimal = Subtotal2Temp - RetIVATemp - RetISRTemp + Math.Round(IVATemp, 6) + IEPSTemp + OtrosImpuestos - OtrosImpuestosRetenciones
|
|
|
|
If Math.Abs(Math.Round(DescuentosTemp, 6) - Math.Round(Descuento, 6)) > 0.01 Then
|
|
Msg &= String.Format("- Los descuentos del detalle no coinciden con el descuento general <br>")
|
|
End If
|
|
|
|
If Math.Abs(Math.Round(IVATemp, 6) - Math.Round(TrasladoIVA, 6)) > 0.01 Then
|
|
Msg &= String.Format("- Los IVAS del detalle no coinciden con el IVA general <br>")
|
|
End If
|
|
|
|
If Math.Abs(Math.Round(IEPSTemp, 6) - Math.Round(TrasladoIEPS, 6)) > 0.01 Then
|
|
Msg &= String.Format("- Los IEPS del detalle no coinciden con el IEPS general <br>")
|
|
End If
|
|
|
|
If Math.Abs(Math.Round(RetIVATemp, 6) - Math.Round(RetencionIVA, 6)) > 0.01 Then
|
|
Msg &= String.Format("- Los RetIVA del detalle no coinciden con el RetIVA general <br>")
|
|
End If
|
|
|
|
If Math.Abs(Math.Round(RetISRTemp, 6) - Math.Round(RetencionISR, 6)) > 0.01 Then
|
|
Msg &= String.Format("- Las RetISR del detalle no coinciden con el RetIVA general <br>")
|
|
End If
|
|
|
|
If Math.Abs(Math.Round(TotalTemp, 2) - Math.Round(Total, 2)) > 0.01 Then
|
|
Msg &= String.Format("- El total generado por los detalles no coincide con el total general <br> ({0}-{1})", Math.Round(TotalTemp, 2), Math.Round(Total, 2))
|
|
End If
|
|
|
|
If Msg <> "" Then
|
|
Errores.AppendLine($" El comprobante XML presenta las siguientes inconsistencias:{Msg}. ")
|
|
Else
|
|
|
|
DescuentosTemp = Descuento
|
|
IVATemp = TrasladoIVA
|
|
TotalTemp = Total
|
|
RetIVATemp = RetencionIVA
|
|
RetISRTemp = RetencionISR
|
|
IEPSTemp = TrasladoIEPS
|
|
End If
|
|
|
|
Me.SubTotal = SubtotalTemp
|
|
Me.Descuento = DescuentosTemp
|
|
Me.SubTotal2 = Subtotal2Temp
|
|
Me.IVA = IVATemp
|
|
Me.Total = TotalTemp
|
|
Me.RetIVA = RetIVATemp
|
|
Me.RetISR = RetISRTemp
|
|
Me.IEPS = IEPSTemp
|
|
CompraSaldo = TotalTemp
|
|
|
|
AsignaValoresOriginales(SubtotalTemp, Subtotal2Temp, IVATemp, RetIVATemp, RetISRTemp, Total)
|
|
|
|
End Sub
|
|
|
|
Private Sub AsignaValoresOriginales(SubTotal As Decimal, SubTotal2 As Double, IVA As Decimal, RetIVA As Decimal, RetISR As Decimal, Total As Decimal)
|
|
SubTotalOriginal = SubTotal
|
|
SubTotal2Original = SubTotal2
|
|
IVAOriginal = IVA
|
|
RetIVAOriginal = RetIVA
|
|
RetISROriginal = RetISR
|
|
TotalOriginal = Total
|
|
End Sub
|
|
|
|
Private Sub AjustaImporteUltimoConcepto(ImporteAjuste As Decimal, Optional EsCarga As Boolean = False)
|
|
|
|
If ImporteAjuste = 0 Then Exit Sub
|
|
|
|
Dim Amortizacion As Decimal = 0
|
|
|
|
If TmpDT.Rows.Count > 0 Then ' si hay movimientos y si esta afectando al total, que se haga el ajuste
|
|
Dim Indice As Integer = If(TmpDT.Rows(TmpDT.Rows.Count - 1)("CvePS").ToString = UsuarioActual.Empresa.Funcionalidad(112).ToString, TmpDT.Rows.Count - 2, TmpDT.Rows.Count - 1)
|
|
Dim tPU As Decimal
|
|
|
|
If TmpDT.Rows(Indice)("Cantidad").ToString.ToDecimal > 0 Then
|
|
tPU = ImporteAjuste / TmpDT.Rows(Indice)("Cantidad").ToString.ToDecimal
|
|
Else
|
|
tPU = 0
|
|
End If
|
|
|
|
If TmpDT.Rows(Indice)("PU").ToString.ToDecimal + tPU < 0 Then 'si es negativo, que tome el dato anterior
|
|
Indice = Indice - 1
|
|
If TmpDT.Rows(Indice)("Cantidad").ToString.ToDecimal > 0 Then
|
|
tPU = ImporteAjuste / TmpDT.Rows(Indice)("Cantidad").ToString.ToDecimal
|
|
Else
|
|
tPU = 0
|
|
End If
|
|
End If
|
|
|
|
TmpDT.Rows(Indice)("PU") = TmpDT.Rows(Indice)("PU").ToString.ToDecimal + tPU
|
|
TmpDT.Rows(Indice)("Total") = TmpDT.Rows(Indice)("Total").ToString.ToDecimal + ImporteAjuste
|
|
TmpDT.Rows(Indice)("IEPSPS") = (TmpDT.Rows(Indice)("Total").ToString.ToDecimal() * TmpDT.Rows(Indice)("IEPSPSPorcentaje").ToString.ToDecimal()).RoundAD(2)
|
|
TmpDT.Rows(Indice)("IVA") = (TmpDT.Rows(Indice)("PU").ToString.ToDecimal * TmpDT.Rows(Indice)("Cantidad").ToString.ToDecimal - TmpDT.Rows(Indice)("Descuento").ToString.ToDecimal) * TmpDT.Rows(Indice)("IVAPorcentaje").ToString.ToDecimal
|
|
TmpDT.AcceptChanges()
|
|
End If
|
|
|
|
SubTotal = TmpDT.SUMD("Total")
|
|
If Not EsCarga Then
|
|
Descuento = TmpDT.SUMD("Descuento")
|
|
End If
|
|
|
|
SubTotalConceptos = SubTotal
|
|
|
|
End Sub
|
|
|
|
Public Function ValidateUUID(ByVal uuid As String) As Boolean
|
|
Dim pattern As String = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
|
|
Dim regex As New Regex(pattern)
|
|
Return regex.IsMatch(uuid)
|
|
End Function
|
|
Private Function GeneraStringDoctosRelacionados() As String
|
|
|
|
Dim DoctosRelacionados As String = "-1"
|
|
Dim listaUUIDSRelacionados As New List(Of String)
|
|
|
|
If DocumentosRelacionadosUUIDSList.Count > 0 Then
|
|
For Each s As String In DocumentosRelacionadosUUIDSList
|
|
If s.Trim.Length > 0 Then
|
|
listaUUIDSRelacionados.Add(s.Trim)
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
If listaUUIDSRelacionados.Count > 0 Then
|
|
DoctosRelacionados = String.Join(",", listaUUIDSRelacionados.ToArray())
|
|
End If
|
|
|
|
Return DoctosRelacionados
|
|
End Function
|
|
Private Function ValorXML(n As XmlNode, Campo As String, Optional Retorno As String = "") As String
|
|
Dim o As XmlNode = n.Attributes.Cast(Of XmlAttribute)().SingleOrDefault(Function(a) String.Compare(a.Name, Campo, True) = 0)
|
|
If o Is Nothing Then
|
|
Return Retorno
|
|
Else
|
|
Return o.Value
|
|
End If
|
|
End Function
|
|
|
|
Public Function AddCompra(Optional ByRef transacccion As SqlTransaction = Nothing) As Boolean
|
|
|
|
If Not AjustesValidacion() Then Return False
|
|
|
|
Dim respuesta As Boolean = True
|
|
Dim ObjCompras As ClsCompras
|
|
|
|
If transacccion IsNot Nothing Then
|
|
ObjCompras = New ClsCompras(transacccion)
|
|
Else
|
|
ObjCompras = New ClsCompras
|
|
End If
|
|
Dim ObjConta As New ClsContabilidad(ObjCompras.IniciaTransacSQL())
|
|
|
|
If Not AddPrePolizaCabecera(ObjConta) Then
|
|
respuesta = False
|
|
End If
|
|
|
|
If respuesta AndAlso ObjCompras.AddCompra(Me.TipoDocto, Me.Descripcion, Me.Serie, Me.Folio, Me.FolioSecundario, Me.CveProveedor, Me.SubTotal, Me.Descuento,
|
|
Me.Amortizacion, Me.IVA, Me.RetIVA, Me.RetISR, Me.IEPS, Me.OtrosImpuestos,
|
|
Me.Redondeo, Me.Total, Me.Fecha, Me.CveMoneda, Me.TipoCambio, If(Me.FechaPago = Nothing, Me.Fecha, Me.FechaPago), Me.AplicaNotaCredito, Me.Observaciones, Me.CveEstatusFactura,
|
|
Me.CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Me.IdPoliza, CveCajaChica:=Me.CveCajaChica, CvePersonal:=Me.CvePersonal, NumeroReembolso:=Me.NumeroReembolso, CveProveedorSucursal:=Me.CveProveedorSucursal,
|
|
AplicoPromocion:=Me.AplicoPromocion, PorcentajeIVA:=Me.PorcentajeIVA, CveMetodoPago:=Me.CveMetodoPago, CveRetIVAConcepto:=Me.CveRetIVAConcepto,
|
|
CveConceptoContableAlmacen:=Me.CveConceptoContableAlmacen,
|
|
CveRetISRConcepto:=Me.CveRetISRConcepto, NoDeducible:=Me.NoDeducible, CveTipoCompra:=Me.CveTipoCompra, TotalOriginal:=Me.TotalOriginal, CveTipoConcepto:=Me.CveTipoConcepto,
|
|
EsImportacion:=Me.EsImportacion, CveFactura:=Me.CveFactura, CveSubProyecto:=Me.CveSubProyectoPrincipal, DoctosRelacionados:=Me.DocumentosRelacionadosUUIDSString, CveFolioGarantia:=Me.CveFolioGarantia,
|
|
CveCompraRelacionada:=CveCompraRelacionada) Then
|
|
Me.CveCompra = ObjCompras.CveCompra
|
|
Else
|
|
respuesta = False
|
|
End If
|
|
|
|
If respuesta AndAlso Me.CveCompra > 0 Then
|
|
|
|
For Each Row As DataRow In Me.TmpDT.Rows
|
|
|
|
Dim TipoRecepcion As Integer = -1
|
|
Dim Referencia As String = ""
|
|
Dim EsNoDeducible As Boolean = False
|
|
Dim CveAF As Integer = If(Row("CveActivoFijo").ToString.ToEntero > 0 AndAlso Row("TipoAF").ToString.ToEntero = 1, Row("CveActivoFijo").ToString.ToEntero, -1)
|
|
Dim CveAFC As Integer = If(Row("CveActivoFijo").ToString.ToEntero > 0 AndAlso Row("TipoAF").ToString.ToEntero = 2, Row("CveActivoFijo").ToString.ToEntero, -1)
|
|
|
|
If Not ObjCompras.AddCompraDetalle(Me.CveCompra, Row("CveUM").ToString.ToEntero, Row("CvePS").ToString.ToEntero, Row("CveSubProyecto").ToString.ToEntero, -1, CveAF,
|
|
Row("Cantidad").ToString.ToDecimal, Row("PU").ToString.ToDecimal, Row("IVA").ToString.ToDecimal, Row("Total").ToString.ToDecimal, Row("Descuento").ToString.ToDecimal,
|
|
Row("Obs").ToString, Row("CveOrdenCompraDetalle").ToString.ToEntero, TipoRecepcion, Row("CveContrato").ToString.ToEntero, Row("CvePresupuestoEgreso").ToString.ToEntero,
|
|
AplicaCostoIndirecto:=Row("AplicaCostoIndirecto").ToString.ToEntero, EstatusAlmacen:=Row("EntregaDirecta").ToString.ToEntero, CvePersonal:=CvePersonal,
|
|
CveTipoGasto:=Row("CveTipoGasto").ToString.ToEntero, AF_Medida:=Row("AFMedida").ToString.ToEntero, AF_TipoMantenimiento:=Row("AFTipoMantenimiento").ToString.ToEntero, Referencia:=Referencia, OtrosGastos:=Row("OtrosGastos").ToString.ToDecimal,
|
|
RetIVA:=Row("RetIVA").ToString.ToDecimal, RetISR:=Row("RetISR").ToString.ToDecimal, IEPSPS:=Row("IEPSPS").ToString.ToDecimal.RoundSQL, IEPSPSIVA:=Row("IEPSPSIVA").ToString.ToDecimal,
|
|
IVAPorcentaje:=Row("IVAPorcentaje").ToString.ToDecimal, RetIVAPorcentaje:=Row("RetIVAPorcentaje").ToString.ToDecimal, RetISRPorcentaje:=Row("RetISRPorcentaje").ToString.ToDecimal,
|
|
IEPSPSPorcentaje:=Row("IEPSPSPorcentaje").ToString.ToDecimal, IEPSPSIVAPorcentaje:=Row("IEPSPSIVAPorcentaje").ToString.ToDecimal, NoDeducible:=If((Row("NoDeducible").ToString().ToUpper().Contiene("TRUE", "1")) AndAlso EsNoDeducible, True, False),
|
|
CveContratoDetalle:=Row("CveContratoDetalle").ToString.ToEntero, CveCultivoCuadroDetalle:=Row("CveCultivoCuadroDetalle").ToString.ToEntero, CveActivoFijoCompra:=CveAFC) Then
|
|
|
|
respuesta = False
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
If respuesta Then
|
|
If Not AddPrePolizaDetalles(ObjConta) Then respuesta = False
|
|
End If
|
|
|
|
If respuesta AndAlso ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual, 4) Then
|
|
If ObjConta.ValorPolizaDescuadre > 0 Then
|
|
Errores.AppendLine($"eFacturas/Compras-Guardar | Error{ObjConta.MensajePolizaDescuadre} Diferencia{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}.")
|
|
GuardaLogAD($"eFacturas/Compras-Guardar | Error{ObjConta.MensajePolizaDescuadre} Diferencia{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
|
|
respuesta = False
|
|
End If
|
|
End If
|
|
|
|
If respuesta AndAlso Me.CveFactura > 0 Then
|
|
If Not ObjCompras.UpdateCompraFactura(Me.CveCompra, Me.CveFactura, Me.Serie, Me.Folio) Then respuesta = False
|
|
End If
|
|
|
|
If transacccion Is Nothing Then 'SINO VIENE DE UNA TRANSACCIÓN
|
|
If respuesta Then
|
|
ObjCompras.Commit()
|
|
Else
|
|
ObjCompras.RollBack()
|
|
End If
|
|
ObjCompras.Dispose()
|
|
ObjConta.Dispose()
|
|
End If
|
|
|
|
Return respuesta
|
|
End Function
|
|
|
|
Private Function AddPrePolizaCabecera(ByRef ObjConta As ClsContabilidad) As Boolean
|
|
|
|
Dim respuesta As Boolean = False
|
|
|
|
Dim ConceptoPoliza As String = String.Format("{0} - {1} - {2}", NombreProveedor, SerieFolio, "")
|
|
Dim Modulo As String = "eFacturas/Registrar"
|
|
|
|
If Me.TipoDocto = "RNC" Then
|
|
ConceptoPoliza = String.Format("{0} - {1} - {2}", NombreProveedor, SerieFolio, "")
|
|
Modulo = "Compras/RNC"
|
|
End If
|
|
|
|
Me.CvePrePoliza = ObjConta.AddPrePolizas(Modulo, 1, Me.Total, Me.Total, Me.CveMoneda, Me.Fecha, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, "", CveTipoPoliza:=Me.CveTipoPoliza)
|
|
respuesta = If(Me.CvePrePoliza > 0, True, False)
|
|
|
|
Return respuesta
|
|
End Function
|
|
|
|
Private Function AddPrePolizaDetalles(ByRef ObjConta As ClsContabilidad, Optional ES_RNC As Boolean = False) As Boolean
|
|
Dim respuesta As Boolean = True
|
|
Dim Concepto As String = $"{Me.NombreProveedor} {Me.SerieFolio}"
|
|
Dim Referencia As String = Me.SerieFolio
|
|
|
|
If TipoDocto = "RNC" Then
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Me.Total, Me.Total, 370, Referencia, Concepto, CveCompra:=CveCompra, CveCompraAmortizacion:=Me.CveCompraAmortizacion, CveProveedor:=Me.CveProveedor, ImporteME:=If(TipoCambio = 1, 0, Me.Total), TipoCambio:=TipoCambio,
|
|
CveClasificacion:=-1, CveSubProyecto:=Me.CveSubProyecto, Contabilizable:=True) Then
|
|
respuesta = False
|
|
|
|
End If
|
|
|
|
If respuesta Then
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Me.Total, Me.Total, 372, Referencia, Concepto, CveCompra:=CveCompra, CveCompraAmortizacion:=Me.CveCompraAmortizacion, CveProveedor:=Me.CveProveedor, ImporteME:=If(TipoCambio = 1, 0, Me.Total), TipoCambio:=TipoCambio,
|
|
CveClasificacion:=-1, CveSubProyecto:=Me.CveSubProyecto, Contabilizable:=True) Then
|
|
respuesta = False
|
|
|
|
End If
|
|
End If
|
|
|
|
Else
|
|
|
|
Dim importeMovimiento As Decimal
|
|
Dim importeMN As Decimal
|
|
|
|
|
|
'6
|
|
For Each RowDetalle As DataRow In TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2", "", {"CveClasificacion", "CveSubProyecto"}).Rows
|
|
|
|
importeMovimiento = TmpDT.SUMD("Total", $" CveClasificacion = {RowDetalle("CveClasificacion").ToString} AND CveSubProyecto = {RowDetalle("CveSubProyecto").ToString}")
|
|
importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL
|
|
|
|
If importeMN <> 0 Then
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, importeMN, 6, Referencia, Concepto, CveCompra:=CveCompra, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=Me.CveCreditoDetalle, ImporteME:=If(TipoCambio = 1, 0, importeMovimiento), TipoCambio:=TipoCambio,
|
|
CveClasificacion:=RowDetalle("CveClasificacion").ToString().ToEntero(), CveSubProyecto:=RowDetalle("CveSubProyecto").ToString().ToEntero(), Contabilizable:=True) Then
|
|
respuesta = False
|
|
Exit For
|
|
End If
|
|
End If
|
|
Next
|
|
'14
|
|
If respuesta AndAlso Me.IVA > 0 Then
|
|
importeMovimiento = Me.IVA
|
|
importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, importeMN, 14, Referencia, Concepto, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=Me.PorcentajeIVA, Contabilizable:=True) Then
|
|
respuesta = False
|
|
End If
|
|
End If
|
|
'25
|
|
If respuesta AndAlso Me.IEPS > 0 Then
|
|
importeMovimiento = Me.IEPS
|
|
importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, importeMN, 25, Referencia, Concepto, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=0, Contabilizable:=True) Then
|
|
respuesta = False
|
|
End If
|
|
End If
|
|
'
|
|
If respuesta AndAlso Me.RetIVA > 0 Then
|
|
importeMovimiento = Me.RetIVA
|
|
importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL
|
|
Dim ret As ConceptosRetenciones = ConceptoPrePolizaRetIVA
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, importeMN, ret.CveConceptoxAcreditar, Referencia, Concepto, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=0, Contabilizable:=True) Then
|
|
respuesta = False
|
|
End If
|
|
End If
|
|
'
|
|
If respuesta AndAlso Me.RetISR > 0 Then
|
|
importeMovimiento = Me.RetISR
|
|
importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL
|
|
Dim ret As ConceptosRetenciones = ConceptoPrePolizaRetISR
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, importeMN, ret.CveConceptoxAcreditar, Referencia, Concepto, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=0, Contabilizable:=True) Then
|
|
respuesta = False
|
|
End If
|
|
End If
|
|
'5
|
|
If respuesta Then
|
|
importeMovimiento = Me.Total
|
|
importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL
|
|
Dim ConPreP As ConceptosTipoSaldo = ObtenerCveConceptoPrePoliza(1, Me.CveMoneda, False, Me.CveTipoConceptoProveedor)
|
|
Dim ImporteME As Decimal = importeMovimiento
|
|
Dim UsaComplementaria As Boolean = True
|
|
If Me.CveMoneda > 1 Then ImporteME = importeMovimiento
|
|
|
|
If UsuarioActual.CveEmpresa.Contiene(13, 83) Then 'caso excepcional de complementarias
|
|
UsaComplementaria = False
|
|
importeMN = importeMovimiento * Me.TipoCambio
|
|
Else
|
|
importeMN = importeMovimiento
|
|
End If
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, importeMN, ConPreP.CveConcepto, Referencia, Concepto, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=0, Contabilizable:=True) Then
|
|
respuesta = False
|
|
End If
|
|
If respuesta AndAlso Me.CveMoneda > 1 AndAlso UsaComplementaria Then
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, (importeMovimiento * Me.TipoCambio - importeMovimiento).RoundSQL, ConPreP.CveConceptoComplementario, Referencia, Concepto, CveCompra:=Me.CveCompra, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=Me.CvePersonal, CveCompraAmortizacion:=Me.CveCompraAmortizacion, TipoCambio:=Me.TipoCambio, TipoCambioPago:=1, ImporteME:=ImporteME, CveSubProyecto:=Me.CveSubProyecto) Then
|
|
respuesta = False
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
Return respuesta
|
|
|
|
End Function
|
|
|
|
End Class
|
|
|