Files
SIG/Bancos/PopIECompras.aspx.vb
2019-11-25 18:37:37 -07:00

3287 lines
228 KiB
VB.net

Option Explicit On
Option Strict On
Imports System.Data
Imports Extensiones
Partial Class Bancos_PopIECompras
Inherits ClsPaginas
#Region "Propiedades"
Private Property DtDeudores As DataTable
Get
Return CType(ViewState("DtDeudores"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtDeudores") = value
End Set
End Property
Private Property DtAcreedores As DataTable
Get
Return CType(ViewState("DtAcreedores"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtAcreedores") = value
End Set
End Property
Private Property DtDeudoresDetalle As DataTable
Get
Return CType(ViewState("DtDeudoresDetalle"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtDeudoresDetalle") = value
End Set
End Property
'Configuración
Private Property CveIE As Integer
Get
Return ViewState("CveIE").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveIE") = value
End Set
End Property
Private Property CveCompra As Integer
Get
Return ViewState("CveCompra").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveCompra") = value
End Set
End Property
Private Property IdPoliza As Integer
Get
Return ViewState("IdPoliza").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("IdPoliza") = value
End Set
End Property
Private Property FechaCompra As Date
Get
Return ViewState("FechaCompra").ToString.ToDate
End Get
Set(value As Date)
ViewState("FechaCompra") = value
End Set
End Property
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 ReadOnly Property CtaProveedor As Integer
Get
Return ViewState("CtaProveedor").ToString.ToEntero
End Get
End Property
Private ReadOnly Property CtaProveedorDeudores As Integer
Get
Return ViewState("CtaProveedorDeudores").ToString.ToEntero
End Get
End Property
Private ReadOnly Property CtaProveedorAcreedores As Integer
Get
Return ViewState("CtaProveedorAcreedores").ToString.ToEntero
End Get
End Property
Private ReadOnly Property CveCuentaProveedorAcreedores As Integer
Get
Return ViewState("CveCuentaProveedorAcreedores").ToString.ToEntero
End Get
End Property
Private ReadOnly Property CveCuentaProveedor As Integer
Get
Return ViewState("CveCuentaProveedor").ToString.ToEntero
End Get
End Property
Private ReadOnly Property CveCuentaProveedorDeudores As Integer
Get
Return ViewState("CveCuentaProveedorDeudores").ToString.ToEntero
End Get
End Property
Private Property IdCuentaBancaria As Integer
Get
Return ViewState("IdCuentaBancaria").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("IdCuentaBancaria") = value
End Set
End Property
Private ReadOnly Property IdCtaContMonedaExtranjera As Integer
Get
Return ViewState("IdCtaContMonedaExtranjera").ToString.ToEntero
End Get
End Property
Private ReadOnly Property IdCtaContComplementaria As Integer
Get
Return ViewState("IdCtaContComplementaria").ToString.ToEntero
End Get
End Property
Private ReadOnly Property IdCtaProveedorExtranjera As Integer
Get
Return ViewState("IdCtaProveedorExtranjera").ToString.ToEntero
End Get
End Property
Private ReadOnly Property CveCuentaProveedorExtranjera As Integer
Get
Return ViewState("CveCuentaProveedorExtranjera").ToString.ToEntero
End Get
End Property
Private ReadOnly Property IdCtaContRetIVA As Integer
Get
Return ViewState("IdCtaContRetIVA").ToString.ToEntero
End Get
End Property
Private ReadOnly Property IdCtaContRetISR As Integer
Get
Return ViewState("IdCtaContRetISR").ToString.ToEntero
End Get
End Property
Private ReadOnly Property IdCtaAnticipo As Integer
Get
Return ViewState("IdCtaAnticipo").ToString.ToEntero
End Get
End Property
Private ReadOnly Property IdCtaContRetIVAAcreditable As Integer
Get
Return ViewState("IdCtaContRetIVAAcreditable").ToString.ToEntero
End Get
End Property
Private ReadOnly Property IdCtaContRetISRAcreditable As Integer
Get
Return ViewState("IdCtaContRetISRAcreditable").ToString.ToEntero
End Get
End Property
Private Property CveCuentaBancaria As Integer
Get
Return ViewState("CveCuentaBancaria").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveCuentaBancaria") = value
End Set
End Property
Private ReadOnly Property CveCuentaMonedaExtranjera As Integer
Get
Return ViewState("CveCuentaMonedaExtranjera").ToString.ToEntero
End Get
End Property
Private ReadOnly Property CveCuentaComplementaria As Integer
Get
Return ViewState("CveCuentaComplementaria").ToString.ToEntero
End Get
End Property
Private ReadOnly Property CveCuentaRetIVA As Integer
Get
Return ViewState("CveCuentaRetIVA").ToString.ToEntero
End Get
End Property
Private ReadOnly Property CveCuentaRetISR As Integer
Get
Return ViewState("CveCuentaRetISR").ToString.ToEntero
End Get
End Property
Private ReadOnly Property CveCuentaAnticipo As Integer
Get
Return ViewState("CveCuentaAnticipo").ToString.ToEntero
End Get
End Property
Private Property CveMoneda As Integer
Get
Return ViewState("CveMoneda").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveMoneda") = value
End Set
End Property
Private Property TipoTransaccion As String
Get
Return ViewState("TipoTransaccion").ToString
End Get
Set(value As String)
ViewState("TipoTransaccion") = value
End Set
End Property
Private Property SaldoVenta As Double
Get
Return ViewState("SaldoVenta").ToString.ToDouble
End Get
Set(value As Double)
ViewState("SaldoVenta") = value
End Set
End Property
Private Property MovimientoPagar As IEMovimiento
Get
Return CType(ViewState("MovimientoPagar"), IEMovimiento)
End Get
Set(value As IEMovimiento)
ViewState("MovimientoPagar") = value
End Set
End Property
Private Property ArrIE As ArrayList
Get
Return CType(ViewState("ArrIE"), ArrayList)
End Get
Set(value As ArrayList)
ViewState("ArrIE") = value
End Set
End Property
Private Property ArrIEFuncionariosEmpleados As ArrayList
Get
Return CType(ViewState("ArrIEFuncionariosEmpleados"), ArrayList)
End Get
Set(value As ArrayList)
ViewState("ArrIEFuncionariosEmpleados") = value
End Set
End Property
Private Property DTFuenteRecaudacion As DataTable
Get
Return CType(ViewState("DTFuenteRecaudacion"), DataTable)
End Get
Set(value As DataTable)
ViewState("DTFuenteRecaudacion") = value
End Set
End Property
Private Property DTFuncionarioEmpleado As DataTable
Get
Return CType(ViewState("DTFuncionarioEmpleado"), DataTable)
End Get
Set(value As DataTable)
ViewState("DTFuncionarioEmpleado") = value
End Set
End Property
Private Property EmpresaPrueba As Boolean
Get
Return CBool(ViewState("EmpresaPrueba"))
End Get
Set(value As Boolean)
ViewState("EmpresaPrueba") = value
End Set
End Property
Private Property NombreProveedor As String
Get
Return ViewState("NombreProveedor").ToString
End Get
Set(value As String)
ViewState("NombreProveedor") = value
End Set
End Property
Private Property SerieFolio As String
Get
Return ViewState("SerieFolio").ToString
End Get
Set(value As String)
ViewState("SerieFolio") = value
End Set
End Property
Private Property CveMonedaCompra As Integer
Get
Return ViewState("CveMonedaVenta").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveMonedaVenta") = value
End Set
End Property
Private Property TipoCambioOriginal As Decimal
Get
Return ViewState("TipoCambioOriginal").ToString.ToDecimal
End Get
Set(value As Decimal)
ViewState("TipoCambioOriginal") = value
End Set
End Property
<Serializable>
Public Class Anticipos
Public Property CveIE As Integer
Public Property Importe As Double
Public Property CvePersonal As Integer
End Class
<Serializable>
Public Class IEMovimiento
Public Property SubTotal As Decimal
Public Property IVA As Decimal
Public Property IVADeducible As Decimal
Public Property IVANoDeducible As Decimal
Public Property RetIVA As Decimal
Public Property RetISR As Decimal
Public Property Total As Decimal
Public Property Saldo As Decimal
Public Property IEPS As Decimal
Public Property ConceptoRetIVA As Integer
Public Property ConceptoRetISR As Integer
Public Property PorcentajeIVA As Decimal
End Class
Private Property CveMonedaFiltros As Integer
Get
Return ViewState("CveMonedaFiltros").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveMonedaFiltros") = value
End Set
End Property
Private Property RFCProveedor As String
Get
Return ViewState("RFCProveedor").ToString
End Get
Set(value As String)
ViewState("RFCProveedor") = value
End Set
End Property
Private Property IdCuentaCliente As Integer
Get
Return ViewState("IdCuentaCliente").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("IdCuentaCliente") = value
End Set
End Property
Private ReadOnly Property IdCtaContRetIVACliente As Integer
Get
Return ViewState("IdCtaContRetIVACliente").ToString.ToEntero
End Get
End Property
Private ReadOnly Property IdCtaContRetISRCliente As Integer
Get
Return ViewState("IdCtaContRetISRCliente").ToString.ToEntero
End Get
End Property
Private ReadOnly Property IdCtaContComplementariaCliente As Integer
Get
Return ViewState("IdCtaContComplementariaCliente").ToString.ToEntero
End Get
End Property
Private ReadOnly Property IdCtaContMonedaExtranjeraCliente As Integer
Get
Return ViewState("IdCtaContMonedaExtranjeraCliente").ToString.ToEntero
End Get
End Property
Private Property CveCuentaCliente As Integer
Get
Return ViewState("CveCuentaCliente").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveCuentaCliente") = value
End Set
End Property
Private ReadOnly Property CveCuentaRetIVACliente As Integer
Get
Return ViewState("CveCuentaRetIVACliente").ToString.ToEntero
End Get
End Property
Private ReadOnly Property CveCuentaRetISRCliente As Integer
Get
Return ViewState("CveCuentaRetISRCliente").ToString.ToEntero
End Get
End Property
Private ReadOnly Property CveCuentaComplementariaCliente As Integer
Get
Return ViewState("CveCuentaComplementariaCliente").ToString.ToEntero
End Get
End Property
Private ReadOnly Property CveCuentaMonedaExtranjeraCliente As Integer
Get
Return ViewState("CveCuentaMonedaExtranjeraCliente").ToString.ToEntero
End Get
End Property
#End Region
Private Sub Bancos_PopIECompras_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
If Not UsuarioActual.Empresa.UsaAC Then
EmpresaPrueba = True
ViewState("IdCtaContMonedaExtranjera") = 0
ViewState("IdCtaContComplementaria") = 0
ViewState("IdCtaContRetIVA") = 0
ViewState("IdCtaContRetISR") = 0
ViewState("IdCuentaBancaria") = 0
ViewState("IdCtaAnticipo") = 0
ViewState("CveCuentaMonedaExtranjera") = 0
ViewState("CveCuentaComplementaria") = 0
ViewState("CveCuentaRetIVA") = 0
ViewState("CveCuentaRetISR") = 0
ViewState("CveCuentaBancaria") = 0
ViewState("CveCuentaAnticipo") = 0
ViewState("CtaProveedorDeudores") = 0
ViewState("CtaProveedorAcreedores") = 0
ViewState("CveCuentaProveedorDeudores") = 0
ViewState("NombreProveedor") = ""
End If
CType(Me.Master, BaseMasterPage).EsPopup = True
CType(Me.Master, BaseMasterPage).PopupWidth = 750
RegistraScript("$get('tdContenido').style.height='350px'")
CveProveedor = -1
CveCompra = -1
IdPoliza = -1
CveMoneda = 0
TipoTransaccion = "Egs"
MovimientoPagar = Nothing
ArrIE = New ArrayList()
ArrIEFuncionariosEmpleados = New ArrayList()
RFCProveedor = ""
TxtFechaDocumento.Text = Now.ToShortDateString
If Request("CveProveedor") IsNot Nothing Then
HdnCveProveedor.Value = Request("CveProveedor").ToString
CveProveedor = Request("CveProveedor").ToString.ToEntero
End If
If Request("CveCompra") IsNot Nothing AndAlso IsNumeric(Request("CveCompra")) AndAlso Request("CveCompra").ToEntero > 0 Then
CveCompra = Request("CveCompra").ToEntero
CargaCompra(CveCompra)
End If
If UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12, 72, 80) Then
rowComisiones.Visible = True
End If
'SI USUARIO USA AMORTIZACIÓN CONTABLE
If UsuarioActual.Empresa.UsaAC Then
Dim AC As New ClsAC
If AC.GetPresupuestoIngresos(-1, -1, True, UsuarioActual.CveEmpresa) Then
DdlFuenteRecaudacion.DataSource = AC.DtResultados()
DdlFuenteRecaudacion.DataBind()
ViewState("DTFuenteRecaudacion") = AC.DtResultados()
End If
TrFR.Visible = True
AC.Dispose()
End If
CargaTipoTransaccion(TipoTransaccion)
CargaCuentas()
Dim ObjVentas As New ClsVentas
If ObjVentas.GetVentas(UsuarioActual.CveEmpresa, "-1", "-1", -1, "-1", -1, -1, -1, -1, "-1", "-1", "-1", ClienteRFC:=RFCProveedor, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then
RBLContado.Items(4).Enabled = True
End If
ObjVentas.Dispose()
If CveMoneda = 2 Then
ChkPagarPesos.Visible = True
TxtTipoCambio.Text = GlobalTipoCambio(Now).FormatoNumero(4)
Else
ChkPagarDolares.Visible = True
TxtTipoCambio.Text = GlobalTipoCambio(Now).FormatoNumero(4)
End If
UpDatos.Update()
End If
End Sub
#Region "C A M B I A R P A N E L"
Private Sub RBLContado_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RBLContado.SelectedIndexChanged
Select Case RBLContado.SelectedValue
Case "1" ' Bancos
PanelBancos.Visible = True
PanelFyE.Visible = False
PanelIngresos.Visible = False
PanelDeudores.Visible = False
PanelAcreedores.Visible = False
PanelVentas.Visible = False
TxtImporte.Text = SaldoVenta.FormatoNumero
Case "2" ' F y E
PanelBancos.Visible = False
PanelFyE.Visible = True
PanelIngresos.Visible = False
PanelDeudores.Visible = False
PanelAcreedores.Visible = False
PanelVentas.Visible = False
CargaFuncionariosEmpleados()
TxtImporte.Text = SaldoVenta.FormatoNumero
Case "3" 'Ingresos x Comprobar
PanelBancos.Visible = False
PanelFyE.Visible = False
PanelIngresos.Visible = True
PanelDeudores.Visible = False
PanelAcreedores.Visible = False
PanelVentas.Visible = False
CargaOtrosIngresos(CveMoneda)
TxtImporte.Text = "0.00"
Case "4" 'Deudores
PanelBancos.Visible = False
PanelFyE.Visible = False
PanelIngresos.Visible = False
PanelDeudores.Visible = True
PanelAcreedores.Visible = False
PanelVentas.Visible = False
CargaDeudores(CveMoneda)
TxtImporte.Text = "0.00"
Case "5" ' Acreedores
PanelBancos.Visible = False
PanelFyE.Visible = False
PanelIngresos.Visible = False
PanelDeudores.Visible = False
PanelAcreedores.Visible = True
PanelVentas.Visible = False
CargaAcreedores(CveMoneda)
Case "6" 'Ventas
PanelBancos.Visible = False
PanelFyE.Visible = False
PanelIngresos.Visible = False
PanelDeudores.Visible = False
PanelAcreedores.Visible = False
PanelVentas.Visible = True
CargaVentas(CveMoneda)
TxtImporte.Text = "0.00"
End Select
End Sub
#End Region
#Region "C A R G A R I N F O R M A C I O N"
Private Sub CargaCompra(pCveCompra As Integer)
Dim ObjCompra As New ClsCompras()
If ObjCompra.GetCompras(pCveCompra, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then
If ObjCompra.DtResultados IsNot Nothing AndAlso ObjCompra.DtResultados.Rows.Count > 0 Then
Dim dr As DataRow = ObjCompra.DtResultados.Rows(0)
If UsuarioActual.Empresa.Funcionalidad(306) = "1" And dr("AplicaNotaCredito").ToString = "True" Then
BtnGuardar.Enabled = False
LbNANota.Visible = True
End If
'Datos Generales de la Compra
FechaCompra = dr("Fecha").ToString.ToDate
Dim Validada As Boolean = False
If Not UsuarioActual.Empresa.Funcionalidad(529) = "1" Then
'verificacion doble, si no la han cancelado, ya tiene una validaci[on para que llegue aqui
Dim Valida As New ClsValidaCFDi(dr("UUID").ToString(), dr("RFC").ToString, UsuarioActual.Empresa.RFC, dr("Total").ToString.ToDecimal)
If Valida.EsValida > 0 Then
If Valida.EsValida = 2 Then
Validada = False
'Dim ObjDatos As New ClsCompras
'If ObjDatos.UpdateEstatus(Valida.EsValida, gvr.DataKey("CveFactura").ToEntero) Then
'End If
'ObjDatos.Dispose()
BtnGuardar.Enabled = False
If UsuarioActual.Empresa.UsaAC Then
RegistraScript("if (confirm('La factura está cancelada ante el SAT., ¿Desea eliminar la compra?')) { $get('BtnEliminarCompra').click();}")
Else
Alert("La factura está cancelada ante el SAT.")
End If
Else
Validada = True
End If
Else
'no se pudo validar, pero ya tuvo la primera vuelta de validacion
Validada = True
End If
Valida.Dispose()
Else
Validada = True
End If
If Validada Then
'CargaProveedor
CveProveedor = dr("CveProveedor").ToString.ToEntero
HdnCveProveedor.Value = CveProveedor.ToString
CargaProveedor(CveProveedor, "-1")
CveMoneda = dr("CveMoneda").ToString.ToEntero
CveMonedaCompra = dr("CveMoneda").ToString.ToEntero
CveMonedaFiltros = dr("CveMoneda").ToString.ToEntero
SerieFolio = dr("SerieFolio").ToString
TipoCambioOriginal = dr("TipoCambio").ToString.ToDecimal
NombreProveedor = GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltroPrimeroValor("RazonSocial", String.Format("CveProveedor = {0}", CveProveedor))
LtlTitulo.Text = "Cuentas por Pagar"
LtlTipo2.Text = "Folio de la Compra"
LtlTipo3.Text = "Fecha de la Compra"
LtlFechaVenta.Text = dr("Fecha").ToString.ToDate.ToShortDateString()
LtlFolio.Text = dr("SerieFolio").ToString
LtlSaldo.Text = If(CveMoneda = 1, $"{dr("Saldo").ToString.FormatoNumero}{" MXN"}", $"{dr("Saldo").ToString.FormatoNumero}{" USD"}")
'Configuración de Modalidad Update
MovimientoPagar = New IEMovimiento
MovimientoPagar.SubTotal = dr("SubTotal").ToString.ToDecimal
MovimientoPagar.IVA = dr("IVA").ToString.ToDecimal
MovimientoPagar.IVADeducible = dr("IVADeducible").ToString.ToDecimal
MovimientoPagar.IVANoDeducible = dr("IVANoDeducible").ToString.ToDecimal
MovimientoPagar.RetIVA = dr("RetIVA").ToString.ToDecimal
MovimientoPagar.RetISR = dr("RetISR").ToString.ToDecimal
MovimientoPagar.Total = dr("Total").ToString.ToDecimal
MovimientoPagar.Saldo = dr("Saldo").ToString.ToDecimal
MovimientoPagar.IEPS = dr("IEPS").ToString.ToDecimal
MovimientoPagar.ConceptoRetIVA = dr("CveRetIVAConcepto").ToString.ToEntero
MovimientoPagar.ConceptoRetISR = dr("CveRetISRConcepto").ToString.ToEntero
MovimientoPagar.PorcentajeIVA = dr("PorcentajeIVA").ToString.ToDecimal
TxtFolio.Enabled = True
TxtFechaDocumento.Enabled = True
Calendario.Enabled = True
TxtPagueseA.Enabled = False
TxtImporte.Enabled = True
DdlCuenta.Enabled = True
DdlTipoTransaccion.Enabled = True
TxtObservaciones.Enabled = True
BtnGuardar.Visible = True
RVImporte.Enabled = True
RVImporte.Enabled = True
RVImporte.MaximumValue = dr("Saldo").ToString.ToDouble.ToString.FormatoNumero
TxtImporte.Text = dr("Saldo").ToString.ToDouble.FormatoNumero
SaldoVenta = dr("Saldo").ToString.ToDouble
End If
End If
End If
ObjCompra.Dispose()
End Sub
Private Sub CargaProveedor(ByVal CveProveedor As Integer, RFC As String)
Dim ObjProveedor As New ClsCompProveedores()
If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, CveProveedor, "-1", "-1", "-1", "-1", RFC, "-1", "-1", -1, UsuarioActual.CveEmpresa) Then
If ObjProveedor.DtResultados.Rows.Count > 0 Then
TxtPagueseA.Text = ObjProveedor.RazonSocial
RFCProveedor = ObjProveedor.RFC
'Conta SIG
ViewState("CtaProveedor") = ObjProveedor.IdCtaContProveedores
ViewState("CtaProveedorDeudores") = ObjProveedor.IdCtaContDeudor
ViewState("CtaProveedorAcreedores") = ObjProveedor.IdCtaContAcreedor
ViewState("IdCtaContRetISR") = ObjProveedor.IdCtaContRetISR
ViewState("IdCtaContRetISRAcreditable") = ObjProveedor.IdCtaContRetISRAcreditable
ViewState("IdCtaContRetIVA") = ObjProveedor.IdCtaContRetIVA
ViewState("IdCtaContRetIVAAcreditable") = ObjProveedor.IdCtaContRetIVAAcreditable
ViewState("IdCtaProveedorExtranjera") = ObjProveedor.IdCtaContProveedoresExtranjera
ViewState("IdCtaContComplementaria") = ObjProveedor.IdCtaContProveedoresComplementaria
'Conta ContPAQ
ViewState("CveCuentaProveedor") = ObjProveedor.CveCuentaProveedores
ViewState("CveCuentaProveedorDeudores") = ObjProveedor.CveCuentaDeudor
ViewState("CveCuentaProveedorAcreedores") = ObjProveedor.CveCuentaAcreedor
ViewState("CveCuentaRetISR") = ObjProveedor.CveCuentaRetISR
ViewState("CveCuentaRetIVA") = ObjProveedor.CveCuentaRetIVA
ViewState("CveCuentaProveedorExtranjera") = ObjProveedor.CveCuentaProveedoresExtranjera
ViewState("CveCuentaComplementaria") = ObjProveedor.CveCuentaProveedoresComplementaria
Else
Alert("El Proveedor solicitado no existe, por favor intente de nuevo.", TipoMensaje.MsgAdvertencia)
End If
End If
ObjProveedor.Dispose()
End Sub
Private Sub CargaTipoTransaccion(Optional Tipo As String = "Egs")
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros(String.Format("Tipo = '{0}'", Tipo))
DdlTipoTransaccion.DataBind()
DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1"))
End Sub
Private Sub CargaCuentas()
DdlCuenta.Items.Clear()
Dim dt As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario)
'dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", CveMoneda))
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 CveMoneda > 0 Then
dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", CveMoneda))
End If
End If
DdlCuenta.DataSource = dt
DdlCuenta.DataBind()
DdlCuenta.Items.Insert(0, New ListItem("Seleccione cuenta", "-1"))
End Sub
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
Protected Sub CargaFuncionariosEmpleados()
If CveCompra > 0 Then
Dim objGastosXComprobar As New ClsMovimientos
If objGastosXComprobar.GetEgresosSinComprobarPersonal(UsuarioActual.CveEmpresa) Then
'TRATAR DE HACERLO CON LINQ
DTFuncionarioEmpleado = New DataTable
DTFuncionarioEmpleado.Columns.Add("CvePersonal", GetType(Integer))
DTFuncionarioEmpleado.Columns.Add("NombreCompleto", GetType(String))
DTFuncionarioEmpleado.Columns.Add("CveIE", GetType(String))
For Each Row As DataRow In objGastosXComprobar.DtResultados.FiltraParametros($"CvePersonal > 0 AND CveMoneda = {CveMoneda}", "NombreCompleto").Rows
Dim RowFE As DataRow = Nothing
RowFE = DTFuncionarioEmpleado.NewRow()
RowFE("CvePersonal") = Row("CvePersonal").ToString.ToEntero
RowFE("NombreCompleto") = String.Format("{0} - ${1}", Row("NombreCompleto").ToString.Trim, Row("Saldo").ToString.FormatoNumero(2))
RowFE("CveIE") = Row("CveIE").ToString
DTFuncionarioEmpleado.Rows.Add(RowFE)
Next
DdlFuncionarioEmpleado.DataSource = DTFuncionarioEmpleado
DdlFuncionarioEmpleado.DataBind()
DdlFuncionarioEmpleado.Items.Insert(0, New ListItem("Seleccione", "-1"))
End If
objGastosXComprobar.Dispose()
End If
End Sub
Protected Sub CargaOtrosIngresos(Optional CveMoneda As Integer = 1)
Dim IngresosXcomprobar As New ClsMovimientos
DdlIngreso.Items.Clear()
If IngresosXcomprobar.GetIngresosSaldos(-1, UsuarioActual.CveEmpresa) Then
DtDeudores = IngresosXcomprobar.DtResultados.FiltraParametros($"CveCliente > 0 AND Saldo > 0 AND CveMoneda = {CveMoneda}")
DdlIngreso.DataSource = DtDeudores
DdlIngreso.DataBind()
DdlIngreso.Items.Insert(0, New ListItem("Seleccione Ingreso", "-1"))
UpDatos.Update()
CambieIngreso()
End If
IngresosXcomprobar.Dispose()
End Sub
Protected Sub CargaDeudores(Optional CveMoneda As Integer = 1)
Dim Deudores As New ClsMovimientos
DdlDeudor.Items.Clear()
If CveCompra > 0 Then
If Deudores.GetDeudoresSaldos2(-1, UsuarioActual.CveEmpresa) Then
DtDeudores = Deudores.DtResultados.FiltraParametros($"CveProveedor > 0 AND Saldo > 0 AND CveMoneda = {CveMoneda}")
DdlDeudor.DataSource = DtDeudores
DdlDeudor.DataBind()
DdlDeudor.Items.Insert(0, New ListItem("Seleccione Deudor", "-1"))
UpDatos.Update()
CambieDeudor()
End If
End If
Deudores.Dispose()
End Sub
Protected Sub CargaAcreedores(Optional CveMoneda As Integer = 1)
Dim ObjMov As New ClsMovimientos
If ObjMov.GetAcreedoresSaldos(-1, UsuarioActual.CveEmpresa) Then
DtAcreedores = ObjMov.DtResultados.FiltraParametros($"CveProveedor > 0 AND CveMoneda = {CveMoneda}")
DdlAcreedor.DataSource = DtAcreedores
DdlAcreedor.DataBind()
DdlAcreedor.Items.Insert(0, New ListItem("Seleccione Acreedor", "-1"))
UpDatos.Update()
CambieAcreedor()
End If
ObjMov.Dispose()
End Sub
Protected Sub CargaVentas(Optional CveMoneda As Integer = 1)
Dim ObjVentas As New ClsVentas
Dim ObjCliente As New ClsClientes
Dim CveCliente As Integer = -1
If ObjVentas.GetVentas(UsuarioActual.CveEmpresa, "-1", "-1", -1, "-1", -1, -1, -1, -1, "-1", "-1", "-1", ClienteRFC:=RFCProveedor, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then
If ObjVentas.DtResultados.FiltraParametros("Saldo > 0").Rows.Count > 0 Then
CveCliente = ObjVentas.DtResultados(0)("CveCliente").ToString.ToEntero
GvVentas.DataSource = ObjVentas.DtResultados.FiltraParametros($"Saldo > 0 AND CveMoneda = {CveMoneda}")
GvVentas.DataBind()
End If
End If
If CveCliente > 0 Then
If ObjCliente.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then
ViewState("IdCuentaCliente") = ObjCliente.IdCtaContClientes
ViewState("IdCtaContRetIVACliente") = ObjCliente.IdCtaContRetIVA
ViewState("IdCtaContRetISRCliente") = ObjCliente.IdCtaContRetISR
ViewState("IdCtaContComplementariaCliente") = ObjCliente.IdCtaContComplementaria
ViewState("IdCtaContMonedaExtranjeraCliente") = ObjCliente.IdCtaContMonedaExtranjera
ViewState("CveCuentaCliente") = ObjCliente.CveCuentaClientes
ViewState("CveCuentaRetIVACliente") = ObjCliente.CveCuentaRetIVA
ViewState("CveCuentaRetISRCliente") = ObjCliente.CveCuentaRetISR
ViewState("CveCuentaComplementariaCliente") = ObjCliente.CveCuentaComplementaria
ViewState("CveCuentaMonedaExtranjeraCliente") = ObjCliente.CveCuentaMonedaExtranjera
End If
End If
ObjVentas.Dispose()
ObjCliente.Dispose()
UpDatos.Update()
End Sub
Private Sub CambieIngreso()
Dim stringDeudor As String = DdlIngreso.SelectedItem.ToString
Dim SaldoD As Decimal = stringDeudor.Substring(stringDeudor.IndexOf("$") + 1, stringDeudor.Length - (stringDeudor.IndexOf("$") + 1)).ToDecimal
If DdlIngreso.SelectedValue.ToEntero > 0 Then
Dim Deudores As New ClsMovimientos
If Deudores.GetIngresosSaldosDetalle(DdlIngreso.SelectedValue.ToEntero, CveMonedaFiltros, UsuarioActual.CveEmpresa) Then
DtDeudoresDetalle = Deudores.DtResultados.FiltraParametros("CveCliente > 0 AND Saldo > 0")
GvIngresos.DataSource = DtDeudoresDetalle
GvIngresos.DataBind()
End If
Deudores.Dispose()
Else
GvIngresos.DataSource = Nothing
GvIngresos.DataBind()
End If
UpIngresos.Update()
End Sub
Private Sub CambieDeudor()
Dim stringDeudor As String = DdlDeudor.SelectedItem.ToString
Dim SaldoD As Decimal = stringDeudor.Substring(stringDeudor.IndexOf("$") + 1, stringDeudor.Length - (stringDeudor.IndexOf("$") + 1)).ToDecimal
If DdlDeudor.SelectedValue.ToEntero > 0 Then
Dim Deudores As New ClsMovimientos
Dim OpcionSaldo As Integer = 1
If Deudores.GetDeudoresSaldosDetalle(DdlDeudor.SelectedValue.ToEntero, CveMonedaFiltros, UsuarioActual.CveEmpresa) Then
DtDeudoresDetalle = Deudores.DtResultados.FiltraParametros("CveProveedor > 0 AND Saldo > 0")
GvDeudores.DataSource = DtDeudoresDetalle
GvDeudores.DataBind()
End If
Deudores.Dispose()
Else
GvDeudores.DataSource = Nothing
GvDeudores.DataBind()
End If
UpDeudores.Update()
End Sub
Private Sub CambieAcreedor()
If DdlAcreedor.SelectedValue.ToEntero > 0 Then
Dim dr As DataRow
dr = DtAcreedores.FiltroPrimero(String.Format("CveProveedor = {0}", DdlAcreedor.SelectedValue))
If dr IsNot Nothing Then
Dim tSaldo As Double = dr("Saldo").ToString.ToDouble
'si el saldo es mayor de la compra poner el valor de la compra sino el valor del saldo
TxtImporte.Text = If(tSaldo > TxtTotal.Text.ToDouble, TxtTotal.Text, tSaldo.ToString).FormatoNumero
Dim ObjMov As New ClsMovimientos
If ObjMov.GetAcreedoresSaldosDetalles(-1, CveMonedaFiltros, UsuarioActual.CveEmpresa) Then
GvAcreedores.DataSource = ObjMov.DtResultados.FiltraParametros(String.Format("CveProveedor = {0}", DdlAcreedor.SelectedValue))
GvAcreedores.DataBind()
End If
ObjMov.Dispose()
End If
Else
GvAcreedores.DataSource = Nothing
GvAcreedores.DataBind()
End If
UpAcreedores.Update()
End Sub
Private Sub CargaCuentasDepositos()
DdlCuentaDeposito.Items.Clear()
If DdlTipoTransaccion.SelectedValue.Contiene("2", "9") Then ' transferencias y layout
trCuentaDeposito.Visible = False
Dim Dep As New ClsGenerales
If Dep.GetCuentasDepositos(CveProveedor:=CveProveedor) Then
If DdlTipoTransaccion.SelectedValue = "9" Then
DdlCuentaDeposito.DataSource = Dep.DtResultados.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'")
If Dep.DtResultados.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'").Rows.Count > 0 Then
trCuentaDeposito.Visible = True
DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
Else
BtnGuardar.Enabled = False
Alert("El proveedor no tiene ninguna cuenta deposito registrada ante el sistema BBVA BANCOMER", TipoMensaje.MsgAdvertencia)
End If
Else
DdlCuentaDeposito.DataSource = Dep.DtResultados.FiltraParametros("Estatus ='True'")
If Dep.DtResultados.Rows.Count > 0 Then
trCuentaDeposito.Visible = True
DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
End If
End If
End If
Dep.Dispose()
DdlCuentaDeposito.DataBind()
Else
trCuentaDeposito.Visible = False
DdlCuentaDeposito.Items.Clear()
End If
'RecargaGlobalCuentasBancarias()
UpCuentaDeposito.Update()
End Sub
#End Region
#Region "DDL'S CHANGED"
Protected Sub DdlTipoTransaccion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoTransaccion.SelectedIndexChanged
Dim valor As Integer = DirectCast(sender, DropDownList).SelectedValue.ToEntero
Dim dr As DataRow = GlobalDTTipoTransacciones.FiltroPrimero(String.Format("CveTipoTransaccion = {0}", DdlTipoTransaccion.SelectedValue)) 'Egs o Ing
Select Case valor
Case 1
LblPagueseA.Text = "Páguese a"
Case 2
LblPagueseA.Text = "Beneficiario"
End Select
CargaCuentas()
CargaCuentasDepositos()
UpDatos.Update()
End Sub
Protected Sub DdlCuenta_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuenta.SelectedIndexChanged
Dim Folio As Long
Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero("CveCuenta = " & DdlCuenta.SelectedValue)
Dim TCveMoneda = -1
If dr IsNot Nothing Then
If ChkPagarPesos.Checked Then
CveMoneda = 1
RegistraScript("CambiaPesosDolares();")
Else
CveMoneda = dr("CveMoneda").ToString.ToEntero
RegistraScript("CambiaDolaresPesos();")
End If
IdCuentaBancaria = dr("IdCtaContable").ToString.ToEntero
CveCuentaBancaria = dr("IdCtaContableSIG").ToString.ToEntero
If dr("UsaTarjeta").ToString = "True" Then
CargaGridTarjetas()
Else
DivTarjeta.Visible = False
End If
End If
If UsuarioActual.Empresa.Funcionalidad(505) <> "1" Then
Dim Banco As New ClsBancos
Folio = Banco.GetNextFolio(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero)
TxtFolio.Text = Folio.ToString
Banco.Dispose()
End If
End Sub
Private Sub DdlOtrosPagos_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlOtrosPagos.SelectedIndexChanged
Dim EsOtrosEgresos As Boolean = (DdlOtrosPagos.SelectedValue.Equals("2"))
rowComision.Visible = EsOtrosEgresos
rowTotal.Visible = EsOtrosEgresos
TxtComision.Text = "0.00"
TxtTotal.Text = TxtImporte.Text
End Sub
Protected Sub DdlFuncionarioEmpleado_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlFuncionarioEmpleado.SelectedIndexChanged
ArrIEFuncionariosEmpleados = New ArrayList()
Dim CvePersonal As Integer = DdlFuncionarioEmpleado.SelectedValue.ToEntero
If CveCompra > 0 Then
For Each Ant As Anticipos In ArrIE
If Ant.CvePersonal = CvePersonal Then
ArrIEFuncionariosEmpleados.Add(New Anticipos With {.CveIE = Ant.CveIE, .Importe = Ant.Importe, .CvePersonal = Ant.CvePersonal})
End If
Next
'actualizo el monto maximo a pagar en el movimiento bancario
Dim tSaldo As Double = DdlFuncionarioEmpleado.SelectedItem.Text.Split(CChar("-"))(1).ToDouble
If tSaldo < MovimientoPagar.Saldo Then
TxtImporte.Text = tSaldo.FormatoNumero()
End If
End If
End Sub
Private Sub DdlIngreso_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlIngreso.SelectedIndexChanged
CambieIngreso()
End Sub
Private Sub DdlDeudor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlDeudor.SelectedIndexChanged
CambieDeudor()
End Sub
Private Sub DdlAcreedor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlAcreedor.SelectedIndexChanged
CambieAcreedor()
End Sub
#End Region
#Region "CHK TIPO CAMBIO"
#Region "PAGAR CON PESOS"
Protected Sub ChkPagarPesos_CheckedChanged(sender As Object, e As EventArgs)
If ChkPagarPesos.Checked Then
DivTipoCambio.Visible = True
CargaCuentas()
CargaOtrosIngresos(1)
CargaDeudores(1)
CargaAcreedores(1)
CargaVentas(1)
CveMonedaFiltros = 1
TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);")
TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4)
GvIngresos.Columns(5).Visible = True
GvIngresos.Columns(6).Visible = True
GvDeudores.Columns(5).Visible = True
GvDeudores.Columns(6).Visible = True
RVImporte.Enabled = False
RVImporte.MaximumValue = "0.00"
CVImporteDolares.Enabled = True
Else
DivTipoCambio.Visible = False
CargaCuentas()
CargaOtrosIngresos(2)
CargaDeudores(2)
CargaAcreedores(2)
CargaVentas(2)
CveMonedaFiltros = 2
TxtFechaDocumento.Attributes.Remove("onchange")
GvIngresos.Columns(5).Visible = False
GvIngresos.Columns(6).Visible = False
GvDeudores.Columns(5).Visible = False
GvDeudores.Columns(6).Visible = False
RVImporte.Enabled = True
RVImporte.MaximumValue = LtlSaldo.Text.ToDouble.ToString
CVImporteDolares.Enabled = False
CVImportePesos.Enabled = False
End If
UpDatos.Update()
RegistraScript("CambiaPesosDolares();")
End Sub
Protected Sub CVImporteDolares_ServerValidate(source As Object, args As ServerValidateEventArgs)
If args.Value.ToString.Substring(0, args.Value.Length - 3).ToDouble <= LtlSaldo.Text.Substring(0, LtlSaldo.Text.Length - 3).ToDouble Then
args.IsValid = True
Else
args.IsValid = False
End If
End Sub
#End Region
#Region "PAGAR CON DOLARES"
Protected Sub ChkPagarDolares_CheckedChanged(sender As Object, e As EventArgs)
If ChkPagarDolares.Checked Then
DivTipoCambio.Visible = True
CargaCuentas()
CargaOtrosIngresos(2)
CargaDeudores(2)
CargaAcreedores(2)
CargaVentas(2)
CveMonedaFiltros = 2
TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);")
TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4)
GvIngresos.Columns(5).Visible = True
GvIngresos.Columns(6).Visible = True
GvDeudores.Columns(5).Visible = True
GvDeudores.Columns(6).Visible = True
RVImporte.Enabled = False
RVImporte.MaximumValue = "0.00"
CVImportePesos.Enabled = True
Else
DivTipoCambio.Visible = False
CargaCuentas()
CargaOtrosIngresos(1)
CargaDeudores(1)
CargaAcreedores(1)
CargaVentas(1)
CveMonedaFiltros = 1
TxtFechaDocumento.Attributes.Remove("onchange")
GvIngresos.Columns(5).Visible = False
GvIngresos.Columns(6).Visible = False
GvDeudores.Columns(5).Visible = False
GvDeudores.Columns(6).Visible = False
RVImporte.Enabled = True
RVImporte.MaximumValue = LtlSaldo.Text.ToDouble.ToString
CVImporteDolares.Enabled = False
CVImportePesos.Enabled = False
End If
UpDatos.Update()
RegistraScript("CambiaDolaresPesos();")
End Sub
Protected Sub CVImportePesos_ServerValidate(source As Object, args As ServerValidateEventArgs)
If args.Value.ToString.Substring(0, args.Value.Length - 3).ToDouble <= LtlSaldo.Text.Substring(0, LtlSaldo.Text.Length - 3).ToDouble Then
args.IsValid = True
Else
args.IsValid = False
End If
End Sub
#End Region
Protected Sub BtnCambiaTipoMoneda_Click(sender As Object, e As EventArgs)
CambiaTipoMoneda()
End Sub
Private Sub CambiaTipoMoneda()
If ChkPagarPesos.Visible Then
TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4)
RegistraScript("CambiaPesosDolares();")
End If
If ChkPagarDolares.Visible Then
TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4)
RegistraScript("CambiaDolaresPesos();")
End If
UpDatos.Update()
End Sub
#End Region
#Region "GV ROW DATA BOUND"
Private Sub GvIngresos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvIngresos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim total As Double
Dim saldo As Double
saldo = e.Row.DataKey("Saldo").ToDouble
total = SaldoVenta
e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("ClickDeudorChk(this, ""{0}"", ""{1}"", ""{2}"")", e.Row.FCTextBox("TxtSaldoDeudor").ClientID, total, saldo))
e.Row.FCTextBox("TxtSaldoDeudor").Attributes.Add("onKeyUp", "AjustaTextboxDeudores();")
e.Row.FCTextBox("LbTipoMoneda").Text = If(e.Row.DataKey("CveMoneda").ToString.ToEntero = 1, "USD", " MXN")
Dim rv As RangeValidator = CType(e.Row.FindControl("RVSaldoDeudor"), RangeValidator)
End If
End Sub
Private Sub GvDeudores_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDeudores.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim total As Double
Dim saldo As Double
saldo = e.Row.DataKey("Saldo").ToDouble
total = SaldoVenta
e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("ClickDeudorChk(this, ""{0}"", ""{1}"", ""{2}"")", e.Row.FCTextBox("TxtSaldoDeudor").ClientID, total, saldo))
e.Row.FCTextBox("TxtSaldoDeudor").Attributes.Add("onKeyUp", "AjustaTextboxDeudores();")
e.Row.FCTextBox("LbTipoMoneda").Text = If(e.Row.DataKey("CveMoneda").ToString.ToEntero = 1, "USD", " MXN")
Dim rv As RangeValidator = CType(e.Row.FindControl("RVSaldoDeudor"), RangeValidator)
End If
End Sub
Private Sub GvAcreedores_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvAcreedores.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim total As Double
Dim saldo As Double
saldo = e.Row.DataKey("Saldo").ToDouble
total = SaldoVenta
e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("ClickDeudorChk(this, ""{0}"", ""{1}"", ""{2}"")", e.Row.FCTextBox("TxtSaldoDeudor").ClientID, total, saldo))
e.Row.FCTextBox("TxtSaldoDeudor").Attributes.Add("onKeyUp", "AjustaTextboxDeudores();")
e.Row.FCTextBox("LbTipoMoneda").Text = If(e.Row.DataKey("CveMoneda").ToString.ToEntero = 1, "USD", " MXN")
Dim rv As RangeValidator = CType(e.Row.FindControl("RVSaldoDeudor"), RangeValidator)
End If
End Sub
Private Sub GvVentas_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvVentas.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim total As Double
Dim saldo As Double
saldo = e.Row.DataKey("Saldo").ToDouble
total = SaldoVenta
e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("ClickDeudorChk(this, ""{0}"", ""{1}"", ""{2}"")", e.Row.FCTextBox("TxtSaldoDeudor").ClientID, total, saldo))
e.Row.FCTextBox("TxtSaldoDeudor").Attributes.Add("onKeyUp", "AjustaTextboxDeudores();")
e.Row.FCTextBox("LbTipoMoneda").Text = If(e.Row.DataKey("CveMoneda").ToString.ToEntero = 1, "USD", " MXN")
Dim rv As RangeValidator = CType(e.Row.FindControl("RVSaldoDeudor"), RangeValidator)
End If
End Sub
#End Region
#Region "G U A R D A R"
Private Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
'VALIDACION PARA LOS IMPORTES CUANDO SE QUIERE PAGAR EN DIFERENTE MONEDA
If Not Page.IsValid Then
Exit Sub
End If
Dim Dep As New ClsGenerales
If Dep.GetCuentasDepositos(CveProveedor:=CveProveedor) Then
Dim Row = Dep.DtResultados.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)
Dep.Dispose()
Exit Sub
End If
End If
Dep.Dispose()
Dim MsgError As String = ""
Dim CveConcepto As Integer = -1
Dim CveConcepto2 As Integer = -1
Dim CvePersonal As Integer = -1
Dim Inserta As Boolean = True
Dim ImportePagado As Decimal = 0
Dim TipoMovimiento As Boolean = False
Dim PorcentajePago As Decimal = 0
Dim CveProveedor2 As Integer = CveProveedor
Dim Fecha As Date = TxtFechaDocumento.Text.Trim.ToDate
Dim CompraSaldo As Decimal = 0
If Not EmpresaPrueba Then CveIE = -1
Select Case RBLContado.SelectedValue
Case "1" ' Bancos
ImportePagado = TxtImporte.Text.Trim.ToDecimal
Fecha = TxtFechaDocumento.Text.Trim.ToDate
TipoMovimiento = True
Case "2" 'FyE
ImportePagado = TxtImporte.Text.Trim.ToDecimal
Fecha = TxtFechaDocumento.Text.Trim.ToDate
CveConcepto = 29
CveIE = -1
TipoMovimiento = True
Dim stringPersonal As String = DdlFuncionarioEmpleado.SelectedItem.ToString
CvePersonal = DdlFuncionarioEmpleado.SelectedValue.ToEntero
Case "3" 'Ingresos X Comprobar
ImportePagado = TxtImporte.Text.Trim.ToDecimal
Case "4" 'Deudores Diversos
ImportePagado = TxtImporte.Text.Trim.ToDecimal
CveConcepto = 17
CveConcepto2 = 37
CveIE = -1
CveProveedor2 = DdlDeudor.SelectedValue.ToEntero
Case "5" 'Acreedores Diversos
ImportePagado = TxtImporte.Text.Trim.ToDecimal
CveConcepto = 17
CveConcepto2 = 41
CveProveedor2 = DdlAcreedor.SelectedValue.ToEntero
CveIE = -1
Case "6" 'Ventas
ImportePagado = TxtImporte.Text.Trim.ToDecimal
CveProveedor2 = CveProveedor
CveIE = -1
Case Else
ImportePagado = 0
End Select
If ImportePagado <= 0 Then
Inserta = False
Alert("Debe ingresar un importe.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If CveCompra > 0 Then
If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then
Dim ObjCompra As New ClsCompras()
If ObjCompra.GetComprasSaldos(CveCompra) Then
CompraSaldo = ObjCompra.DtResultados(0)("Saldo").ToString.ToDecimal
End If
ObjCompra.Dispose()
End If
End If
Dim ObjIE As New ClsBancos()
Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL)
Dim CvePlantillaPoliza As Integer = 2
Dim ConceptoPoliza As String = String.Format("{0} {1}", NombreProveedor, SerieFolio)
Dim CveCuentaDeposito As Integer = If(DdlCuentaDeposito.Items.Count > 0, DdlCuentaDeposito.SelectedValue.ToEntero, 0)
Dim FechaDocumento = FechaCompra
'Saca moneda en que se va a pagar segun metodo de pago
Select Case RBLContado.SelectedValue
Case "1" ' Banco
If DdlCuenta.SelectedValue.ToEntero > 0 Then
CveMoneda = GlobalDTBancosCuentas(-1).FiltroPrimeroValor("CveMoneda", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveCuenta = {DdlCuenta.SelectedValue.ToEntero}").ToEntero
End If
Case "2", "3", "4", "5", "6" 'FyE, Ingresos, Deudores, Acreedores
If ChkPagarDolares.Checked Then
CveMoneda = 2
ElseIf ChkPagarPesos.Checked Then
CveMoneda = 1
End If
End Select
'cuando es pago con ventas, debe de ser de Diario
Dim CveTipoPoliza As Integer = ObjMov.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, "-1", UsuarioActual.CveEmpresa)
If RBLContado.SelectedValue = "6" Then CveTipoPoliza = 3
Dim CvePrePoliza As Integer = ObjMov.AddPrePolizas("Bancos/PopIECompras", CvePlantillaPoliza, ImportePagado, ImportePagado, CveMoneda, Fecha, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=CveTipoPoliza)
If Inserta Then
If CvePrePoliza > 0 Then
'SE AGREGA DETALLE DE UNA COMPRA
If CveCompra > 0 Then
If EmpresaPrueba Then
PorcentajePago = 100
'SE AGREGA DETALLE CUANDO ES UNA COMPRA
If MovimientoPagar IsNot Nothing Then
Dim tipoCambioPago As Decimal = 1
Dim tipoCambioCompra As Decimal = 1
Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:<br><br>"
Dim idCuentaContabilizacion As Long = 1
Dim CuentasContablesInvalidas As New StringBuilder
Dim CveCuentaContabilizacion As Long = 1
Dim CuentasContablesInvalidasSIG As New StringBuilder
'Tipos de cambio segun metodo de pago
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then 'Si la venta viene en Pesos y se va a pagar en Pesos
tipoCambioPago = 1
tipoCambioCompra = 1
PorcentajePago = ImportePagado.ToString.ToDecimal / MovimientoPagar.Total
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then 'Si la venta viene en Dolares y se va a pagar en Pesos
tipoCambioPago = TxtTipoCambio.Text.ToDecimal
tipoCambioCompra = TipoCambioOriginal
PorcentajePago = (ImportePagado.ToString.ToDecimal / tipoCambioPago) / MovimientoPagar.Total
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then 'Si la venta viene en Dolares y se va a pagar en DOLARES
tipoCambioPago = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).ToString.ToDecimal
tipoCambioCompra = TipoCambioOriginal
PorcentajePago = ImportePagado.ToString.ToDecimal / MovimientoPagar.Total
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
tipoCambioPago = TxtTipoCambio.Text.ToDecimal
tipoCambioCompra = 1
PorcentajePago = ImportePagado.ToString.ToDecimal / MovimientoPagar.Total
End If
Select Case RBLContado.SelectedValue
Case "1" ' Banco
CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, Fecha, TxtFolio.Text.Trim, TxtPagueseA.Text.Trim, ImportePagado, CveMoneda, tipoCambioPago, TxtObservaciones.Text.Trim, "", True, True, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCuentaTarjeta:=If(DivTarjeta.Visible, DdlTarjeta.SelectedValue.ToEntero, -1), CveCuentaDeposito:=CveCuentaDeposito, Referencia:=If(TxtReferenciaCIE.Visible, TxtReferenciaCIE.Text, "-1"))
If CveIE > 0 Then
CveConcepto = 17
Else
MsgError = "Ocurrio un Error al registrarse el movimiento bancario."
Inserta = False
End If
Case Else
CveIE = -1
End Select
If DdlOtrosPagos.SelectedValue = "2" AndAlso TxtComision.Text.ToDouble > 0 Then
'Agrego el movimiento a Comisiones
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtComision.Text.ToDecimal, TxtObservaciones.Text, 78, TxtObservaciones.Text, Fecha, 0, -1, CveIE, CveCompra, -1, -1, If(ViewState("CveCliente") IsNot Nothing, ViewState("CveCliente").ToString.ToEntero, -1)) Then
MsgError = "Detalle"
End If
End If
'inserto las compras que voy a pagar
If ObjMov.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPoliza) Then
For Each Row As DataRow In ObjMov.DtResultados.Rows
Dim ConceptoContable = Row("CveConcepto").ToString.ToEntero
TipoMovimiento = If(Row("TipoMovto").ToString = "True", True, False)
Dim ImporteMovimiento As Decimal = 0
Dim ImporteMX As Decimal = 0
Dim ImporteMovimientoNoDeducible As Decimal = 0
Dim ImporteMXNoDeducible As Decimal = 0
Dim IdCtaContable As Integer = 0
Dim CveCuenta As Integer = 0
Dim ConceptoMovimiento = ObjMov.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, ConceptoContable, NombreProveedor, TxtObservaciones.Text, TxtFolio.Text.Trim)
Dim FuncionalidadFluctuacionImpuestos As Boolean = If(UsuarioActual.Empresa.Funcionalidad(159) = "1", True, False)
Dim TimpocambioGeneral As Decimal = 1
Dim PorcentajeImpuesto As Decimal = 0
Select Case ConceptoContable
Case 17 'Pago Proveedores
If RBLContado.SelectedValue.Contiene("3", "4", "5", "6") Then
For Each rw As GridViewRow In GvIngresos.Rows
If rw.FCCheckBox("Chk").Checked Then
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / tipoCambioPago
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal * tipoCambioPago
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento * tipoCambioCompra
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
TimpocambioGeneral = tipoCambioCompra
CveIE = rw.DataKey("CveIE").ToString.ToEntero
If CveMonedaCompra <> 1 Then
'si la factura es en dólares y trae complementaria, el importemn debe ser igual al importe
If IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119 Then
ImporteMX = ImporteMovimiento
End If
IdCtaContable = IdCtaProveedorExtranjera
CveCuenta = CveCuentaMonedaExtranjera
Else
IdCtaContable = CtaProveedor
CveCuenta = CveCuentaProveedor
End If
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, -1, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, CveCuenta:=CveCuenta, TipoCambio:=tipoCambioCompra) Then
MsgError = "No se pudo insertar la póliza"
End If
If CveMonedaCompra <> 1 AndAlso (IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119) Then
IdCtaContable = IdCtaContComplementaria
CveCuenta = CveCuentaComplementaria
If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, 206, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * tipoCambioCompra - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioCompra, CveCuenta:=CveCuenta) Then
MsgError = "No se pudo insertar la póliza"
End If
End If
ImporteMX = ImporteMovimiento
IdCtaContable = IdCtaProveedorExtranjera
CveCuenta = CveCuentaMonedaExtranjera
End If
End If
Next
For Each rw As GridViewRow In GvDeudores.Rows
If rw.FCCheckBox("Chk").Checked Then
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / tipoCambioPago
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal * tipoCambioPago
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento * tipoCambioCompra
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
TimpocambioGeneral = tipoCambioCompra
CveIE = rw.DataKey("CveIE").ToString.ToEntero
If CveMonedaCompra <> 1 Then
'si la factura es en dólares y trae complementaria, el importemn debe ser igual al importe
If IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119 Then
ImporteMX = ImporteMovimiento
End If
IdCtaContable = IdCtaProveedorExtranjera
CveCuenta = CveCuentaMonedaExtranjera
Else
IdCtaContable = CtaProveedor
CveCuenta = CveCuentaProveedor
End If
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, -1, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, CveCuenta:=CveCuenta, TipoCambio:=tipoCambioCompra) Then
MsgError = "No se pudo insertar la póliza"
End If
If CveMonedaCompra <> 1 AndAlso (IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119) Then
IdCtaContable = IdCtaContComplementaria
CveCuenta = CveCuentaComplementaria
If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, 206, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * tipoCambioCompra - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioCompra, CveCuenta:=CveCuenta) Then
MsgError = "No se pudo insertar la póliza"
End If
End If
ImporteMX = ImporteMovimiento
IdCtaContable = IdCtaProveedorExtranjera
CveCuenta = CveCuentaMonedaExtranjera
End If
End If
Next
For Each rw As GridViewRow In GvAcreedores.Rows
If rw.FCCheckBox("Chk").Checked Then
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / tipoCambioPago
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal * tipoCambioPago
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento * tipoCambioCompra
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
CveIE = rw.DataKey("CveIE").ToString.ToEntero
If CveMonedaCompra <> 1 Then
'si la factura es en dólares y trae complementaria, el importemn debe ser igual al importe
If IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119 Then
ImporteMX = ImporteMovimiento
End If
IdCtaContable = IdCtaProveedorExtranjera
CveCuenta = CveCuentaMonedaExtranjera
Else
IdCtaContable = CtaProveedor
CveCuenta = CveCuentaProveedor
End If
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, -1, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, CveCuenta:=CveCuenta, TipoCambio:=tipoCambioCompra) Then
MsgError = "No se pudo insertar la póliza"
End If
If CveMonedaCompra <> 1 AndAlso (IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119) Then
IdCtaContable = IdCtaContComplementaria
CveCuenta = CveCuentaComplementaria
If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, 206, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * tipoCambioCompra - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioCompra, CveCuenta:=CveCuenta) Then
MsgError = "No se pudo insertar la póliza"
End If
End If
ImporteMX = ImporteMovimiento
IdCtaContable = IdCtaProveedorExtranjera
CveCuenta = CveCuentaMonedaExtranjera
End If
End If
Next
For Each rw As GridViewRow In GvVentas.Rows
If rw.FCCheckBox("Chk").Checked Then
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / tipoCambioPago
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal * tipoCambioPago
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento * tipoCambioCompra
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
If CveMonedaCompra <> 1 Then
'si la factura es en dólares y trae complementaria, el importemn debe ser igual al importe
If IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119 Then
ImporteMX = ImporteMovimiento
End If
IdCtaContable = IdCtaProveedorExtranjera
CveCuenta = CveCuentaMonedaExtranjera
Else
IdCtaContable = CtaProveedor
CveCuenta = CveCuentaProveedor
End If
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, 275, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, rw.DataKey("CveVenta").ToEntero, CveCompra, -1, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, CveCuenta:=CveCuenta, TipoCambio:=tipoCambioCompra) Then
MsgError = "No se pudo insertar la póliza"
End If
If CveMonedaCompra = 2 Then
IdCtaContable = IdCtaContComplementaria
CveCuenta = CveCuentaComplementaria
If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, 206, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, rw.DataKey("CveVenta").ToEntero, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * tipoCambioCompra - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioCompra, CveCuenta:=CveCuenta) Then
MsgError = "No se pudo insertar la póliza"
End If
End If
ImporteMX = ImporteMovimiento
IdCtaContable = IdCtaProveedorExtranjera
CveCuenta = CveCuentaMonedaExtranjera
End If
End If
Next
ImporteMovimiento = 0
Else
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = ImportePagado.ToString.ToDecimal
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = ImportePagado.ToString.ToDecimal / tipoCambioPago
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = ImportePagado.ToString.ToDecimal * tipoCambioPago
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = ImportePagado.ToString.ToDecimal
ImporteMX = ImporteMovimiento * tipoCambioCompra
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
TimpocambioGeneral = tipoCambioCompra
End If
If CveMonedaCompra = 1 Then
IdCtaContable = CtaProveedor
CveCuenta = CveCuentaProveedor
Else
IdCtaContable = IdCtaContComplementaria
CveCuenta = CveCuentaComplementaria
If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, 206, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * tipoCambioCompra - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioCompra, CveCuenta:=CveCuenta) Then
MsgError = "No se pudo insertar la póliza"
End If
ImporteMX = ImporteMovimiento
IdCtaContable = IdCtaProveedorExtranjera
CveCuenta = CveCuentaMonedaExtranjera
End If
End If
Case 15 'Ret IVA X Acreditar Honorarios/Serv. Prof.
If MovimientoPagar.ConceptoRetIVA = 1 Then
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = MovimientoPagar.RetIVA * PorcentajePago
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * tipoCambioCompra
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
TimpocambioGeneral = tipoCambioCompra
If tipoCambioCompra > 1 Then ConceptoMovimiento += $" TC:{tipoCambioCompra} ${ImporteMovimiento.FormatoNumero(2)}"
If IdCtaContRetIVA > 0 Then
IdCtaContable = IdCtaContRetIVA
ElseIf UsuarioActual.Empresa.Funcionalidad(307).ToEntero > 0 Then
IdCtaContable = UsuarioActual.Empresa.Funcionalidad(307).ToEntero
Else
If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
End If
End If
End If
'Conta SIG
If CveCuentaRetIVA <> 0 Then
CveCuenta = CveCuentaRetIVA
Else
If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
End If
End If
End If
End If
Case 22 'Ret IVA Acreditable Honorarios/Serv. Prof.
If MovimientoPagar.ConceptoRetIVA = 1 Then
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = MovimientoPagar.RetIVA * PorcentajePago
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}"
'Conta ContPAQ
If IdCtaContRetIVAAcreditable > 0 Then
IdCtaContable = IdCtaContRetIVAAcreditable
ElseIf UsuarioActual.Empresa.Funcionalidad(308).ToEntero > 0 Then
IdCtaContable = UsuarioActual.Empresa.Funcionalidad(308).ToEntero
Else
If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
End If
End If
End If
End If
Case 183 'Ret IVA X Acreditar Fletes P.F.
If MovimientoPagar.ConceptoRetIVA = 2 Then
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = MovimientoPagar.RetIVA * PorcentajePago
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * tipoCambioCompra
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
TimpocambioGeneral = tipoCambioCompra
If tipoCambioCompra > 1 Then ConceptoMovimiento += $" TC:{tipoCambioCompra} ${ImporteMovimiento.FormatoNumero(2)}"
'Conta ContPAQ
If IdCtaContRetIVA > 0 Then
IdCtaContable = IdCtaContRetIVA
ElseIf UsuarioActual.Empresa.Funcionalidad(309).ToEntero > 0 Then
IdCtaContable = UsuarioActual.Empresa.Funcionalidad(309).ToEntero
Else
If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
End If
End If
End If
'Conta SIG
If CveCuentaRetIVA <> 0 Then
CveCuenta = CveCuentaRetIVA
Else
If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
End If
End If
End If
End If
Case 184 'Ret IVA Acreditable Fletes P.F.
If MovimientoPagar.ConceptoRetIVA = 2 Then
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = MovimientoPagar.RetIVA * PorcentajePago
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}"
If IdCtaContRetIVAAcreditable > 0 Then
IdCtaContable = IdCtaContRetIVAAcreditable
ElseIf UsuarioActual.Empresa.Funcionalidad(310).ToEntero > 0 Then
IdCtaContable = UsuarioActual.Empresa.Funcionalidad(310).ToEntero
Else
If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
End If
End If
End If
End If
Case 185 'Ret IVA X Acreditar Fletes P.M.
If MovimientoPagar.ConceptoRetIVA = 3 Then
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = MovimientoPagar.RetIVA * PorcentajePago
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * tipoCambioCompra
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
TimpocambioGeneral = tipoCambioCompra
If tipoCambioCompra > 1 Then ConceptoMovimiento += $" TC:{tipoCambioCompra} ${ImporteMovimiento.FormatoNumero(2)}"
'Conta ContPAQ
If IdCtaContRetIVA > 0 Then
IdCtaContable = IdCtaContRetIVA
ElseIf UsuarioActual.Empresa.Funcionalidad(311).ToEntero > 0 Then
IdCtaContable = UsuarioActual.Empresa.Funcionalidad(311).ToEntero
Else
If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
End If
End If
End If
'Conta SIG
If CveCuentaRetIVA <> 0 Then
CveCuenta = CveCuentaRetIVA
Else
If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
End If
End If
End If
End If
Case 186 'Ret IVA Acreditable Fletes P.M.
If MovimientoPagar.ConceptoRetIVA = 3 Then
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = MovimientoPagar.RetIVA * PorcentajePago
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}"
'Conta ContPAQ
If IdCtaContRetIVAAcreditable > 0 Then
IdCtaContable = IdCtaContRetIVAAcreditable
ElseIf UsuarioActual.Empresa.Funcionalidad(312).ToEntero > 0 Then
IdCtaContable = UsuarioActual.Empresa.Funcionalidad(312).ToEntero
Else
If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
End If
End If
End If
End If
Case 248 'Ret IVA x Acreditar Acreditable Arrendamiento
If MovimientoPagar.ConceptoRetIVA = 4 Then
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = MovimientoPagar.RetIVA * PorcentajePago
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}"
'Conta ContPAQ
If IdCtaContRetIVA > 0 Then
IdCtaContable = IdCtaContRetIVA
ElseIf UsuarioActual.Empresa.Funcionalidad(313).ToEntero > 0 Then
IdCtaContable = UsuarioActual.Empresa.Funcionalidad(313).ToEntero
Else
If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
End If
End If
End If
End If
Case 249 'Ret IVA Acreditable Arrendamiento
If MovimientoPagar.ConceptoRetIVA = 4 Then
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = MovimientoPagar.RetIVA * PorcentajePago
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago)
ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}"
'Conta ContPAQ
If IdCtaContRetIVAAcreditable > 0 Then
IdCtaContable = IdCtaContRetIVAAcreditable
ElseIf UsuarioActual.Empresa.Funcionalidad(314).ToEntero > 0 Then
IdCtaContable = UsuarioActual.Empresa.Funcionalidad(314).ToEntero
Else
If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
End If
End If
End If
End If
'Case 16 'Ret ISR X Acreditar
' If MovimientoPagar.ConceptoRetISR = 1 Then
' If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
' ImporteMovimiento = MovimientoPagar.RetISR * PorcentajePago
' ImporteMX = ImporteMovimiento
' ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
' ImporteMovimiento = (MovimientoPagar.RetISR * PorcentajePago)
' ImporteMX = ImporteMovimiento * tipoCambioCompra
' ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
' ImporteMovimiento = (MovimientoPagar.RetISR * PorcentajePago)
' ImporteMX = ImporteMovimiento * tipoCambioCompra
' ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
' ImporteMovimiento = (MovimientoPagar.RetISR * PorcentajePago)
' ImporteMX = ImporteMovimiento * tipoCambioCompra
' End If
' ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
' ImporteMX = Math.Round(ImporteMX, 2)
' TimpocambioGeneral = tipoCambioCompra
' If tipoCambioCompra > 1 Then ConceptoMovimiento += $" TC:{tipoCambioCompra} ${ImporteMovimiento.FormatoNumero(2)}"
' 'Conta ContPAQ
' If IdCtaContRetISR > 0 Then
' IdCtaContable = IdCtaContRetISR
' ElseIf UsuarioActual.Empresa.Funcionalidad(315).ToEntero > 0 Then
' IdCtaContable = UsuarioActual.Empresa.Funcionalidad(315).ToEntero
' Else
' If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
' If ObjMov.DtResultados.Rows.Count > 0 Then
' IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero
' End If
' End If
' End If
' 'Conta SIG
' If CveCuentaRetISR <> 0 Then
' CveCuenta = CveCuentaRetISR
' Else
' If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
' If ObjMov.DtResultados.Rows.Count > 0 Then
' CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero
' End If
' End If
' End If
' End If
'Case 23 'Ret ISR Acreditable
' If MovimientoPagar.ConceptoRetISR = 1 Then
' If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
' ImporteMovimiento = MovimientoPagar.RetISR * PorcentajePago
' ImporteMX = ImporteMovimiento
' ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
' ImporteMovimiento = (MovimientoPagar.RetISR * PorcentajePago)
' ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioCompra, tipoCambioPago)
' ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
' ImporteMovimiento = (MovimientoPagar.RetISR * PorcentajePago)
' ImporteMX = ImporteMovimiento * tipoCambioCompra
' ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
' ImporteMovimiento = (MovimientoPagar.RetISR * PorcentajePago)
' ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioCompra, tipoCambioPago)
' End If
' ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
' ImporteMX = Math.Round(ImporteMX, 2)
' TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioCompra, tipoCambioPago)
' If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}"
' 'Conta ContPAQ
' If IdCtaContRetISRAcreditable > 0 Then
' IdCtaContable = IdCtaContRetISRAcreditable
' ElseIf UsuarioActual.Empresa.Funcionalidad(316).ToEntero > 0 Then
' IdCtaContable = UsuarioActual.Empresa.Funcionalidad(316).ToEntero
' Else
' If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
' If ObjMov.DtResultados.Rows.Count > 0 Then
' IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero
' End If
' End If
' End If
' 'Conta SIG
' If CveCuentaRetISR <> 0 Then
' CveCuenta = CveCuentaRetISR
' Else
' If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
' If ObjMov.DtResultados.Rows.Count > 0 Then
' CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero
' End If
' End If
' End If
' End If
'Case 243 'Ret ISR X Acreditar Terceros y Arrendamiento
' If MovimientoPagar.ConceptoRetISR = 2 Then
' If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
' ImporteMovimiento = MovimientoPagar.RetISR * PorcentajePago
' ImporteMX = ImporteMovimiento
' ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
' ImporteMovimiento = (MovimientoPagar.RetISR * PorcentajePago)
' ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioCompra, tipoCambioPago)
' ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
' ImporteMovimiento = (MovimientoPagar.RetISR * PorcentajePago)
' ImporteMX = ImporteMovimiento * tipoCambioCompra
' ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
' ImporteMovimiento = (MovimientoPagar.RetISR * PorcentajePago)
' ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioCompra, tipoCambioPago)
' End If
' ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
' ImporteMX = Math.Round(ImporteMX, 2)
' TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioCompra, tipoCambioPago)
' If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}"
' 'Conta ContPAQ
' If IdCtaContRetISR > 0 Then
' IdCtaContable = IdCtaContRetISR
' ElseIf UsuarioActual.Empresa.Funcionalidad(317).ToEntero > 0 Then
' IdCtaContable = UsuarioActual.Empresa.Funcionalidad(317).ToEntero
' Else
' If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
' If ObjMov.DtResultados.Rows.Count > 0 Then
' IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero
' End If
' End If
' End If
' 'Conta SIG
' If CveCuentaRetISR <> 0 Then
' CveCuenta = CveCuentaRetISR
' Else
' If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
' If ObjMov.DtResultados.Rows.Count > 0 Then
' CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero
' End If
' End If
' End If
' End If
'Case 244 'Ret ISR Acreditable Terceros y Arrendamiento
' If MovimientoPagar.ConceptoRetISR = 2 Then
' If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
' ImporteMovimiento = MovimientoPagar.RetISR * PorcentajePago
' ImporteMX = ImporteMovimiento
' ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
' ImporteMovimiento = (MovimientoPagar.RetISR * PorcentajePago)
' ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioCompra, tipoCambioPago)
' ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
' ImporteMovimiento = (MovimientoPagar.RetISR * PorcentajePago)
' ImporteMX = ImporteMovimiento * tipoCambioCompra
' ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
' ImporteMovimiento = (MovimientoPagar.RetISR * PorcentajePago)
' ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioCompra, tipoCambioPago)
' End If
' ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
' ImporteMX = Math.Round(ImporteMX, 2)
' TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioCompra, tipoCambioPago)
' If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}"
' 'Conta ContPAQ
' If IdCtaContRetISRAcreditable > 0 Then
' IdCtaContable = IdCtaContRetISRAcreditable
' ElseIf UsuarioActual.Empresa.Funcionalidad(318).ToEntero > 0 Then
' IdCtaContable = UsuarioActual.Empresa.Funcionalidad(318).ToEntero
' Else
' If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
' If ObjMov.DtResultados.Rows.Count > 0 Then
' IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero
' End If
' End If
' End If
' 'Conta SIG
' If CveCuentaRetISR <> 0 Then
' CveCuenta = CveCuentaRetISR
' Else
' If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
' If ObjMov.DtResultados.Rows.Count > 0 Then
' CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero
' End If
' End If
' End If
' End If
Case 14 'Iva por Acreditar
If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then
'funcionalidad que toma el 100% del pago para acreditamiento de iva
Dim TotalImporte As Decimal
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
TotalImporte = ImportePagado.ToString.ToDecimal
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal / tipoCambioPago, 2)
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal * tipoCambioPago, 2)
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
TotalImporte = ImportePagado.ToString.ToDecimal
End If
If TotalImporte = CompraSaldo Then
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = MovimientoPagar.IVA
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = MovimientoPagar.IVA
ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = MovimientoPagar.IVA
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = MovimientoPagar.IVA
ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
TimpocambioGeneral = tipoCambioCompra
If tipoCambioCompra > 1 Then ConceptoMovimiento += $" TC:{tipoCambioCompra} ${ImporteMovimiento.FormatoNumero(2)}"
Else
ImporteMovimiento = 0
ImporteMX = 0
End If
Else
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = MovimientoPagar.IVA * PorcentajePago
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.IVA * PorcentajePago)
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = (MovimientoPagar.IVA * PorcentajePago)
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.IVA * PorcentajePago)
ImporteMX = ImporteMovimiento * tipoCambioCompra
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
If tipoCambioCompra > 1 Then ConceptoMovimiento += $" TC:{tipoCambioCompra} ${ImporteMovimiento.FormatoNumero(2)}"
End If
PorcentajeImpuesto = MovimientoPagar.PorcentajeIVA
Dim IdCtaIVAXAcreditar As Integer = 0
Dim IdCtaIVAAcreditable As Integer = 0
If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then
IdCtaIVAXAcreditar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAXAcreditar").ToString.ToEntero
IdCtaIVAAcreditable = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAAcreditable").ToString.ToEntero
End If
IdCtaContable = If(IdCtaIVAXAcreditar > 0, IdCtaIVAXAcreditar, 0)
If ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then
If ObjMov.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaIVAxAcreditar").ToString.ToEntero
CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaIVAxAcreditarSIG").ToString.ToEntero
End If
End If
Case 19 'Iva Acreditable
If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then
'funcionalidad que toma el 100% del pago para acreditamiento de iva
Dim TotalImporte As Decimal
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
TotalImporte = ImportePagado.ToString.ToDecimal
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal / tipoCambioPago, 2)
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal * tipoCambioPago, 2)
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
TotalImporte = ImportePagado.ToString.ToDecimal
End If
If TotalImporte = CompraSaldo Then
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = MovimientoPagar.IVADeducible
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.IVADeducible)
ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = (MovimientoPagar.IVADeducible)
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.IVADeducible)
ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}"
Else
ImporteMovimiento = 0
ImporteMX = 0
End If
Else
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = MovimientoPagar.IVADeducible * PorcentajePago
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.IVADeducible * PorcentajePago)
ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = (MovimientoPagar.IVADeducible * PorcentajePago)
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.IVADeducible * PorcentajePago)
ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}"
End If
If MovimientoPagar.IVANoDeducible.ToString.ToDecimal > 0 Then
If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then
'funcionalidad que toma el 100% del pago para acreditamiento de iva
Dim TotalImporte As Decimal
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
TotalImporte = ImportePagado.ToString.ToDecimal
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal / tipoCambioPago, 2)
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal * tipoCambioPago, 2)
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
TotalImporte = ImportePagado.ToString.ToDecimal
End If
If TotalImporte = CompraSaldo Then
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimientoNoDeducible = MovimientoPagar.IVANoDeducible
ImporteMXNoDeducible = ImporteMovimientoNoDeducible
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimientoNoDeducible = (MovimientoPagar.IVANoDeducible)
ImporteMXNoDeducible = ImporteMovimientoNoDeducible * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimientoNoDeducible = (MovimientoPagar.IVANoDeducible)
ImporteMXNoDeducible = ImporteMovimientoNoDeducible * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimientoNoDeducible = (MovimientoPagar.IVANoDeducible)
ImporteMXNoDeducible = ImporteMovimientoNoDeducible * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
End If
ImporteMovimientoNoDeducible = Math.Round(ImporteMovimientoNoDeducible, 2)
ImporteMXNoDeducible = Math.Round(ImporteMX, 2)
TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimientoNoDeducible.FormatoNumero(2)}"
Else
ImporteMovimientoNoDeducible = 0
ImporteMXNoDeducible = 0
End If
Else
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimientoNoDeducible = MovimientoPagar.IVANoDeducible * PorcentajePago
ImporteMXNoDeducible = ImporteMovimientoNoDeducible
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimientoNoDeducible = (MovimientoPagar.IVANoDeducible * PorcentajePago)
ImporteMXNoDeducible = ImporteMovimientoNoDeducible * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimientoNoDeducible = (MovimientoPagar.IVANoDeducible * PorcentajePago)
ImporteMXNoDeducible = ImporteMovimientoNoDeducible * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimientoNoDeducible = (MovimientoPagar.IVANoDeducible * PorcentajePago)
ImporteMXNoDeducible = ImporteMovimientoNoDeducible * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
End If
ImporteMovimientoNoDeducible = Math.Round(ImporteMovimientoNoDeducible, 2)
ImporteMXNoDeducible = Math.Round(ImporteMXNoDeducible, 2)
TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimientoNoDeducible.FormatoNumero(2)}"
End If
End If
PorcentajeImpuesto = MovimientoPagar.PorcentajeIVA
Dim IdCtaIVAXAcreditar As Integer = 0
Dim IdCtaIVAAcreditable As Integer = 0
Dim IdCtaContableNoIVA As Integer = 0
If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then
IdCtaIVAXAcreditar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAXAcreditar").ToString.ToEntero
IdCtaIVAAcreditable = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAAcreditable").ToString.ToEntero
IdCtaContableNoIVA = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVANoAcreditable").ToString.ToEntero
End If
IdCtaContable = If(IdCtaIVAAcreditable > 0, IdCtaIVAAcreditable, 0)
If ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then
If ObjMov.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero
CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaIVAAcreditableSIG").ToString.ToEntero
End If
End If
If MovimientoPagar.IVANoDeducible > 0 Then
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, If(ConceptoContable = 30, TxtFolio.Text.Trim, TxtObservaciones.Text), 280, ConceptoMovimiento, Fecha, IdCtaContableNoIVA, -1, CveIE, -1, CveCompra, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMXNoDeducible, CveCuenta:=CveCuenta, TipoCambio:=TimpocambioGeneral, CvePersonal:=CvePersonal, PorcentajeImpuesto:=PorcentajeImpuesto) Then
MsgError = "No se pudo insertar la póliza"
End If
End If
'Case 280 'Iva Acreditable No Deducible
' If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then
' 'funcionalidad que toma el 100% del pago para acreditamiento de iva
' Dim TotalImporte As Decimal
' If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
' TotalImporte = ImportePagado.ToString.ToDecimal
' ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
' TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal / tipoCambioPago, 2)
' ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
' TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal * tipoCambioPago, 2)
' ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
' TotalImporte = ImportePagado.ToString.ToDecimal
' End If
' If TotalImporte = CompraSaldo Then
' If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
' ImporteMovimiento = MovimientoPagar.IVANoDeducible
' ImporteMX = ImporteMovimiento
' ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
' ImporteMovimiento = (MovimientoPagar.IVANoDeducible)
' ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
' ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
' ImporteMovimiento = (MovimientoPagar.IVANoDeducible)
' ImporteMX = ImporteMovimiento * tipoCambioCompra
' ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
' ImporteMovimiento = (MovimientoPagar.IVANoDeducible)
' ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
' End If
' ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
' ImporteMX = Math.Round(ImporteMX, 2)
' TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
' If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}"
' Else
' ImporteMovimiento = 0
' ImporteMX = 0
' End If
' Else
' If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
' ImporteMovimiento = MovimientoPagar.IVANoDeducible * PorcentajePago
' ImporteMX = ImporteMovimiento
' ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
' ImporteMovimiento = (MovimientoPagar.IVANoDeducible * PorcentajePago)
' ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
' ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
' ImporteMovimiento = (MovimientoPagar.IVANoDeducible * PorcentajePago)
' ImporteMX = ImporteMovimiento * tipoCambioCompra
' ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
' ImporteMovimiento = (MovimientoPagar.IVANoDeducible * PorcentajePago)
' ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
' End If
' ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
' ImporteMX = Math.Round(ImporteMX, 2)
' TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
' If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}"
' End If
' PorcentajeImpuesto = MovimientoPagar.PorcentajeIVA
' Dim IdCtaIVAXAcreditar As Integer = 0
' Dim IdCtaIVAAcreditable As Integer = 0
' If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then
' IdCtaIVAXAcreditar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAXAcreditar").ToString.ToEntero
' IdCtaIVAAcreditable = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAAcreditable").ToString.ToEntero
' End If
' IdCtaContable = If(IdCtaIVAAcreditable > 0, IdCtaIVAAcreditable, 0)
' If ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then
' If ObjMov.DtResultados.Rows.Count > 0 Then
' IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero
' CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaIVAAcreditableSIG").ToString.ToEntero
' End If
' End If
Case 25 'IEPS por Acreditar
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = MovimientoPagar.IEPS * PorcentajePago
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.IEPS * PorcentajePago)
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = (MovimientoPagar.IEPS * PorcentajePago)
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.IEPS * PorcentajePago)
ImporteMX = ImporteMovimiento * tipoCambioCompra
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
TimpocambioGeneral = tipoCambioCompra
If ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaIEPSxAcreditar").ToString.ToEntero
CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaIEPSxAcreditarSIG").ToString.ToEntero
End If
End If
Case 26 'IEPS Acreditable
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = MovimientoPagar.IEPS * PorcentajePago
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.IEPS * PorcentajePago)
ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = (MovimientoPagar.IEPS * PorcentajePago)
ImporteMX = ImporteMovimiento * tipoCambioCompra
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = (MovimientoPagar.IEPS * PorcentajePago)
ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
If ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaIEPSAcreditable").ToString.ToEntero
CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaIEPSAcreditableSIG").ToString.ToEntero
End If
End If
Case 64 'Ganancia
If CveMoneda <> 1 OrElse CveMonedaCompra <> 1 Then
IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria
CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria
Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
TimpocambioGeneral = TCImpuestos
'' si tiene funcionalidad de flucturación con ivas, tomar tipocambioCompra
If tipoCambioPago < tipoCambioCompra AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = ((MovimientoPagar.Total * PorcentajePago) * tipoCambioPago) - ((MovimientoPagar.Total * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en la venta
ImporteMovimiento -= ((MovimientoPagar.IVA * PorcentajePago) * TCImpuestos) - ((MovimientoPagar.IVA * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el IVA
ImporteMovimiento += ((MovimientoPagar.RetIVA * PorcentajePago) * TCImpuestos) - ((MovimientoPagar.RetIVA * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el RetIVA
ImporteMovimiento += ((MovimientoPagar.RetISR * PorcentajePago) * TCImpuestos) - ((MovimientoPagar.RetISR * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el RetISR
ImporteMovimiento -= ((MovimientoPagar.IEPS * PorcentajePago) * TCImpuestos) - ((MovimientoPagar.IEPS * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el IEPS
ImporteMovimiento = Math.Abs(Math.Round(ImporteMovimiento, 2))
ImporteMX = ImporteMovimiento
End If
Else
ImporteMovimiento = 0
End If
Case 65 'Perdida
If CveMoneda <> 1 OrElse CveMonedaCompra <> 1 Then
IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria
CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria
Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra)
'' si tiene funcionalidad de flucturación con ivas, tomar tipocambioCompra
If tipoCambioPago > tipoCambioCompra AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = ((MovimientoPagar.Total * PorcentajePago) * tipoCambioCompra) - ((MovimientoPagar.Total * PorcentajePago) * tipoCambioPago) 'Añadimos la diferencia de perdida en la venta
ImporteMovimiento -= ((MovimientoPagar.IVA * PorcentajePago) * tipoCambioCompra) - ((MovimientoPagar.IVA * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el IVA
ImporteMovimiento += ((MovimientoPagar.RetIVA * PorcentajePago) * tipoCambioCompra) - ((MovimientoPagar.RetIVA * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetIVA
ImporteMovimiento += ((MovimientoPagar.RetISR * PorcentajePago) * tipoCambioCompra) - ((MovimientoPagar.RetISR * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetISR
ImporteMovimiento -= ((MovimientoPagar.IEPS * PorcentajePago) * tipoCambioCompra) - ((MovimientoPagar.IEPS * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el IEPS
ImporteMovimiento = Math.Abs(Math.Round(ImporteMovimiento, 2))
ImporteMX = ImporteMovimiento
End If
Else
ImporteMovimiento = 0
End If
Case 30 'Bancos
If RBLContado.SelectedValue = "1" Then
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = ImportePagado.ToString.ToDecimal
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = ImportePagado.ToString.ToDecimal
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = ImportePagado.ToString.ToDecimal
ImporteMX = ImporteMovimiento * tipoCambioPago
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = ImportePagado.ToString.ToDecimal
ImporteMX = ImporteMovimiento * tipoCambioPago
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
TimpocambioGeneral = tipoCambioPago
If CveMoneda = 1 Then
If DivTarjeta.Visible AndAlso DdlTarjeta.SelectedValue.ToEntero > 0 Then
Dim ObjCreditos As New ClsBancos
ObjCreditos.GetTarjetasCreditos(DdlCuenta.SelectedValue.ToEntero, DdlTarjeta.SelectedValue.ToEntero)
If ObjCreditos.DtResultados.Rows.Count > 0 AndAlso (ObjCreditos.DtResultados.Rows(0)("IdCtaContableTarjeta").ToString.ToEntero > 0 Or ObjCreditos.DtResultados.Rows(0)("IdCtaContableTarjetaSIG").ToString.ToEntero > 0) Then
IdCtaContable = ObjCreditos.DtResultados.Rows(0)("IdCtaContableTarjeta").ToString.ToEntero
CveCuenta = ObjCreditos.DtResultados.Rows(0)("IdCtaContableTarjetaSIG").ToString.ToEntero
Else
IdCtaContable = CtaProveedor
CveCuenta = CveCuentaProveedor
End If
ObjCreditos.Dispose()
Else
IdCtaContable = CtaProveedor
CveCuenta = CveCuentaProveedor
End If
Else
IdCtaContable = IdCtaContComplementaria
CveCuenta = CveCuentaComplementaria
If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, 204, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, -1, -1, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * tipoCambioPago - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioPago, CveCuenta:=CveCuenta) Then
MsgError = "No se pudo insertar la póliza"
End If
ImporteMX = ImporteMovimiento
IdCtaContable = IdCtaContMonedaExtranjera
CveCuenta = CveCuentaMonedaExtranjera
End If
End If
End If
Case 92 'Ingresos X Comprobar
If RBLContado.SelectedValue = "3" Then
For Each rw As GridViewRow In GvIngresos.Rows
If rw.FCCheckBox("Chk").Checked Then
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento * tipoCambioPago
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento * tipoCambioPago
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
CveIE = rw.DataKey("CveIE").ToString.ToEntero
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, -1, CveCliente:=rw.DataKey("CveProveedor").ToString.ToEntero, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, CveCuenta:=CveCuenta, TipoCambio:=tipoCambioPago) Then
MsgError = "No se pudo insertar la póliza"
End If
End If
Next
End If
ImporteMovimiento = 0
Case 41 'Acreedores
If RBLContado.SelectedValue = "5" Then
For Each rw As GridViewRow In GvAcreedores.Rows
If rw.FCCheckBox("Chk").Checked Then
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento * tipoCambioPago
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento * tipoCambioPago
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
CveIE = rw.DataKey("CveIE").ToString.ToEntero
IdCtaContable = CtaProveedorAcreedores
CveCuenta = CveCuentaProveedorAcreedores
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMX, CveCuenta:=CveCuenta, TipoCambio:=tipoCambioPago) Then
MsgError = "No se pudo insertar la póliza"
End If
End If
Next
End If
ImporteMovimiento = 0
Case 29 'Funcionario y Empleados
If RBLContado.SelectedValue = "2" Then
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = ImportePagado.ToString.ToDecimal
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = ImportePagado.ToString.ToDecimal
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = ImportePagado.ToString.ToDecimal
ImporteMX = ImporteMovimiento * tipoCambioPago
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = ImportePagado.ToString.ToDecimal
ImporteMX = ImporteMovimiento * tipoCambioPago
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
TimpocambioGeneral = tipoCambioPago
Else
ImporteMovimiento = 0
End If
Case 37 'Deudores
If RBLContado.SelectedValue = "4" Then
For Each rw As GridViewRow In GvDeudores.Rows
If rw.FCCheckBox("Chk").Checked Then
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento * tipoCambioPago
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento * tipoCambioPago
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
CveIE = rw.DataKey("CveIE").ToString.ToEntero
IdCtaContable = CtaProveedorDeudores
CveCuenta = CveCuentaProveedorDeudores
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMX, CveCuenta:=CveCuenta, TipoCambio:=tipoCambioPago) Then
MsgError = "No se pudo insertar la póliza"
End If
End If
Next
End If
ImporteMovimiento = 0
Case 2 'Pago Cliente
If RBLContado.SelectedValue = "6" Then
For Each rw As GridViewRow In GvVentas.Rows
If rw.FCCheckBox("Chk").Checked Then
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento * tipoCambioPago
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
ImporteMX = ImporteMovimiento * tipoCambioPago
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
If rw.DataKey("CveMoneda").ToEntero = 1 Then
IdCtaContable = IdCuentaCliente
CveCuenta = CveCuentaCliente
Else
ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}"
IdCtaContable = IdCtaContComplementariaCliente
CveCuenta = CveCuentaComplementariaCliente
If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then
ImporteMX = ImporteMovimiento
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, 207, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, rw.DataKey("CveVenta").ToString.ToEntero, CveCompra, CveCliente:=rw.DataKey("CveCliente").ToString.ToEntero, ImporteMX:=Math.Round(ImporteMovimiento * tipoCambioPago - ImporteMovimiento, 2, MidpointRounding.AwayFromZero), ImporteME:=ImporteMovimiento, CveCuenta:=CveCuenta, TipoCambio:=tipoCambioPago) Then
MsgError = "No se pudo insertar la póliza"
End If
End If
IdCtaContable = IdCtaContMonedaExtranjeraCliente
CveCuenta = CveCuentaMonedaExtranjeraCliente
End If
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, CveCompra:=CveCompra, CveVenta:=rw.DataKey("CveVenta").ToString.ToEntero, CveCliente:=rw.DataKey("CveCliente").ToString.ToEntero, CvePersonal:=CvePersonal, ImporteMX:=ImporteMX, CveCuenta:=CveCuenta, TipoCambio:=tipoCambioPago) Then
MsgError = "No se pudo insertar la póliza"
End If
End If
Next
End If
ImporteMovimiento = 0
Case 8 'Ret IVA VENTA
If RBLContado.SelectedValue = "6" Then
For Each rw As GridViewRow In GvVentas.Rows
If rw.FCCheckBox("Chk").Checked Then
Dim PorcentajePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / rw.DataKey("Total").ToString.ToDecimal
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.DataKey("RetIVA").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.DataKey("RetIVA").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento * rw.DataKey("TipoCambio").ToString.ToDecimal
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.DataKey("RetIVA").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.DataKey("RetIVA").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento * rw.DataKey("TipoCambio").ToString.ToDecimal
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
'Conta ContPAQ
If IdCtaContRetIVACliente <> 0 Then
IdCtaContable = IdCtaContRetIVACliente
Else
If ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
End If
End If
End If
'Conta SIG
If CveCuentaRetIVACliente <> 0 Then
CveCuenta = CveCuentaRetIVACliente
Else
If ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
End If
End If
End If
If ImporteMovimiento > 0 Then
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, CveCompra:=CveCompra, CveVenta:=rw.DataKey("CveVenta").ToString.ToEntero, CveCliente:=rw.DataKey("CveCliente").ToString.ToEntero, CvePersonal:=CvePersonal, ImporteMX:=ImporteMX, CveCuenta:=CveCuenta, TipoCambio:=rw.DataKey("TipoCambio").ToString.ToDecimal) Then
MsgError = "No se pudo insertar la póliza"
End If
End If
End If
Next
ImporteMovimiento = 0
End If
Case 9 'Ret ISR VENTA
If RBLContado.SelectedValue = "6" Then
For Each rw As GridViewRow In GvVentas.Rows
If rw.FCCheckBox("Chk").Checked Then
Dim PorcentajePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / rw.DataKey("Total").ToString.ToDecimal
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.DataKey("RetISR").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.DataKey("RetISR").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento * rw.DataKey("TipoCambio").ToString.ToDecimal
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.DataKey("RetISR").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.DataKey("RetISR").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento * rw.DataKey("TipoCambio").ToString.ToDecimal
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
'Conta ContPAQ
If IdCtaContRetISR <> 0 Then
IdCtaContable = IdCtaContRetISR
Else
If ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero
End If
End If
End If
'Conta SIG
If CveCuentaRetISR <> 0 Then
CveCuenta = CveCuentaRetISR
Else
If ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero
End If
End If
End If
If ImporteMovimiento > 0 Then
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, CveCompra:=CveCompra, CveVenta:=rw.DataKey("CveVenta").ToString.ToEntero, CveCliente:=rw.DataKey("CveCliente").ToString.ToEntero, CvePersonal:=CvePersonal, ImporteMX:=ImporteMX, CveCuenta:=CveCuenta, TipoCambio:=rw.DataKey("TipoCambio").ToString.ToDecimal) Then
MsgError = "No se pudo insertar la póliza"
End If
End If
End If
Next
ImporteMovimiento = 0
End If
Case 13 'IVA VENTA
If RBLContado.SelectedValue = "6" Then
For Each rw As GridViewRow In GvVentas.Rows
If rw.FCCheckBox("Chk").Checked Then
Dim PorcentajePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / rw.DataKey("Total").ToString.ToDecimal
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.DataKey("IVA").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.DataKey("IVA").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento * rw.DataKey("TipoCambio").ToString.ToDecimal
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.DataKey("IVA").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.DataKey("IVA").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento * rw.DataKey("TipoCambio").ToString.ToDecimal
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
PorcentajeImpuesto = rw.DataKey("PorcentajeIVA").ToDecimal
Dim IdCtaIVAXTrasladar As Integer = 0
Dim IdCtaIVATrasladado As Integer = 0
If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then
IdCtaIVAXTrasladar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAXTrasladar").ToString.ToEntero
IdCtaIVATrasladado = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVATrasladado").ToString.ToEntero
End If
IdCtaContable = If(IdCtaIVAXTrasladar > 0, IdCtaIVAXTrasladar, UsuarioActual.Empresa.IdCuentaIVAxTrasladar)
CveCuenta = UsuarioActual.Empresa.CveCuentaIVAxTrasladar
If ImporteMovimiento > 0 Then
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, CveCompra:=CveCompra, CveVenta:=rw.DataKey("CveVenta").ToString.ToEntero, CveCliente:=rw.DataKey("CveCliente").ToString.ToEntero, CvePersonal:=CvePersonal, ImporteMX:=ImporteMX, CveCuenta:=CveCuenta, TipoCambio:=rw.DataKey("TipoCambio").ToString.ToDecimal, PorcentajeImpuesto:=PorcentajeImpuesto) Then
MsgError = "No se pudo insertar la póliza"
End If
End If
End If
Next
ImporteMovimiento = 0
End If
Case 61 'Iva Trasladado VENTA
If RBLContado.SelectedValue = "6" Then
For Each rw As GridViewRow In GvVentas.Rows
If rw.FCCheckBox("Chk").Checked Then
Dim PorcentajePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / rw.DataKey("Total").ToString.ToDecimal
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.DataKey("IVA").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.DataKey("IVA").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, rw.DataKey("TipoCambio").ToString.ToDecimal)
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.DataKey("IVA").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.DataKey("IVA").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, rw.DataKey("TipoCambio").ToString.ToDecimal)
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
PorcentajeImpuesto = rw.DataKey("PorcentajeIVA").ToDecimal
Dim IdCtaIVAXTrasladar As Integer = 0
Dim IdCtaIVATrasladado As Integer = 0
If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then
IdCtaIVAXTrasladar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAXTrasladar").ToString.ToEntero
IdCtaIVATrasladado = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVATrasladado").ToString.ToEntero
End If
IdCtaContable = If(IdCtaIVATrasladado > 0, IdCtaIVATrasladado, UsuarioActual.Empresa.IdCuentaIVATrasladado)
CveCuenta = UsuarioActual.Empresa.CveCuentaIVATrasladado
If ImporteMovimiento > 0 Then
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, CveCompra:=CveCompra, CveVenta:=rw.DataKey("CveVenta").ToString.ToEntero, CveCliente:=rw.DataKey("CveCliente").ToString.ToEntero, CvePersonal:=CvePersonal, ImporteMX:=ImporteMX, CveCuenta:=CveCuenta, TipoCambio:=If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, rw.DataKey("TipoCambio").ToString.ToDecimal), PorcentajeImpuesto:=PorcentajeImpuesto) Then
MsgError = "No se pudo insertar la póliza"
End If
End If
End If
Next
ImporteMovimiento = 0
End If
Case 38 'IEPS por trasladar VENTA
If RBLContado.SelectedValue = "6" Then
For Each rw As GridViewRow In GvVentas.Rows
If rw.FCCheckBox("Chk").Checked Then
Dim PorcentajePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / rw.DataKey("Total").ToString.ToDecimal
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.DataKey("IEPS").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.DataKey("IEPS").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento * rw.DataKey("TipoCambio").ToString.ToDecimal
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.DataKey("IEPS").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.DataKey("IEPS").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento * rw.DataKey("TipoCambio").ToString.ToDecimal
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
IdCtaContable = UsuarioActual.Empresa.IdCuentaIEPSxTrasladar
CveCuenta = UsuarioActual.Empresa.CveCuentaIEPSxTrasladar
If ImporteMovimiento > 0 Then
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, CveCompra:=CveCompra, CveVenta:=rw.DataKey("CveVenta").ToString.ToEntero, CveCliente:=rw.DataKey("CveCliente").ToString.ToEntero, CvePersonal:=CvePersonal, ImporteMX:=ImporteMX, CveCuenta:=CveCuenta, TipoCambio:=rw.DataKey("TipoCambio").ToString.ToDecimal) Then
MsgError = "No se pudo insertar la póliza"
End If
End If
End If
Next
ImporteMovimiento = 0
End If
Case 39 'IEPS Trasladado VENTA
If RBLContado.SelectedValue = "6" Then
For Each rw As GridViewRow In GvVentas.Rows
If rw.FCCheckBox("Chk").Checked Then
Dim PorcentajePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / rw.DataKey("Total").ToString.ToDecimal
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.DataKey("IEPS").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.DataKey("IEPS").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento * tipoCambioPago
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.DataKey("IEPS").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.DataKey("IEPS").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento * tipoCambioPago
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
IdCtaContable = UsuarioActual.Empresa.IdCuentaIEPSTrasladado
CveCuenta = UsuarioActual.Empresa.CveCuentaIEPSTrasladado
If ImporteMovimiento > 0 Then
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, CveCompra:=CveCompra, CveVenta:=rw.DataKey("CveVenta").ToString.ToEntero, CveCliente:=rw.DataKey("CveCliente").ToString.ToEntero, CvePersonal:=CvePersonal, ImporteMX:=ImporteMX, CveCuenta:=CveCuenta, TipoCambio:=rw.DataKey("TipoCambio").ToString.ToDecimal) Then
MsgError = "No se pudo insertar la póliza"
End If
End If
End If
Next
ImporteMovimiento = 0
End If
Case 62 'Ret IVA Trasladado VENTA
If RBLContado.SelectedValue = "6" Then
For Each rw As GridViewRow In GvVentas.Rows
If rw.FCCheckBox("Chk").Checked Then
Dim PorcentajePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / rw.DataKey("Total").ToString.ToDecimal
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.DataKey("RetIVA").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.DataKey("RetIVA").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento * tipoCambioPago
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.DataKey("RetIVA").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.DataKey("RetIVA").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento * tipoCambioPago
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
'Conta ContPAQ
If IdCtaContRetIVA <> 0 Then
IdCtaContable = IdCtaContRetIVA
Else
If ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
End If
End If
End If
'Conta SIG
If CveCuentaRetIVA <> 0 Then
CveCuenta = CveCuentaRetIVA
Else
If ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
End If
End If
End If
If ImporteMovimiento > 0 Then
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, CveCompra:=CveCompra, CveVenta:=rw.DataKey("CveVenta").ToString.ToEntero, CveCliente:=rw.DataKey("CveCliente").ToString.ToEntero, CvePersonal:=CvePersonal, ImporteMX:=ImporteMX, CveCuenta:=CveCuenta, TipoCambio:=rw.DataKey("TipoCambio").ToString.ToDecimal) Then
MsgError = "No se pudo insertar la póliza"
End If
End If
End If
Next
ImporteMovimiento = 0
End If
Case 63 'Ret ISR Trasladado VENTA
If RBLContado.SelectedValue = "6" Then
For Each rw As GridViewRow In GvVentas.Rows
If rw.FCCheckBox("Chk").Checked Then
Dim PorcentajePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / rw.DataKey("Total").ToString.ToDecimal
If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.DataKey("RetISR").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.DataKey("RetISR").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento * tipoCambioPago
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then
ImporteMovimiento = rw.DataKey("RetISR").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento
ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then
ImporteMovimiento = rw.DataKey("RetISR").ToString.ToDecimal * PorcentajePagoVenta
ImporteMX = ImporteMovimiento * tipoCambioPago
End If
ImporteMovimiento = Math.Round(ImporteMovimiento, 2)
ImporteMX = Math.Round(ImporteMX, 2)
'Conta ContPAQ
If IdCtaContRetISR <> 0 Then
IdCtaContable = IdCtaContRetISR
Else
If ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero
End If
End If
End If
'Conta SIG
If CveCuentaRetISR <> 0 Then
CveCuenta = CveCuentaRetISR
Else
If ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjMov.DtResultados.Rows.Count > 0 Then
CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero
End If
End If
End If
If ImporteMovimiento > 0 Then
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, CveCompra:=CveCompra, CveVenta:=rw.DataKey("CveVenta").ToString.ToEntero, CveCliente:=rw.DataKey("CveCliente").ToString.ToEntero, CvePersonal:=CvePersonal, ImporteMX:=ImporteMX, CveCuenta:=CveCuenta, TipoCambio:=rw.DataKey("TipoCambio").ToString.ToDecimal) Then
MsgError = "No se pudo insertar la póliza"
End If
End If
End If
Next
ImporteMovimiento = 0
End If
Case Else
ImporteMovimiento = 0
End Select
If ImporteMovimiento <> 0 Then
'Conta ContPAQ
If IdCtaContable = 0 Then
CuentasContablesInvalidas.Append("<br>" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
idCuentaContabilizacion = 0
End If
'Conta SIG
If CveCuenta = 0 Then
CuentasContablesInvalidasSIG.Append("<br>" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
CveCuentaContabilizacion = 0
End If
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, If(ConceptoContable = 30, TxtFolio.Text.Trim, TxtObservaciones.Text), ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, CveCuenta:=CveCuenta, TipoCambio:=TimpocambioGeneral, CvePersonal:=CvePersonal, PorcentajeImpuesto:=PorcentajeImpuesto) Then
MsgError = "No se pudo insertar la póliza"
End If
End If
Next
If ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, 5) Then
If ObjMov.ValorPolizaDescuadre > 0 Then
'MsgError = ObjMov.MensajePolizaDescuadre
GuardaLogAD($"Bancos/PopIECompras | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
End If
End If
If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso MsgError = "" AndAlso UsuarioActual.Empresa.UsaContabilidadSIG Then
If CveCuentaContabilizacion > 0 Then
If ObjMov.ContabilizarPrePolizaSIG(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then
Alert(alertaContabilizacion, ModExtensiones.TipoMensaje.MsgInformacion)
Else
Alert("Ocurrio un error al contabilizar en SIG, pongase en contacto con Soporte Técnico")
End If
Else
Alert(String.Format("No se puede contabilizar la Prepoliza en SIG debido a que las siguientes cuentas son invalidas: {0}", CuentasContablesInvalidasSIG))
End If
End If
'Conta ContPAQ
If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso MsgError = "" Then
If idCuentaContabilizacion > 0 Then
If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then
IdPoliza = ObjMov.ContaIdPoliza
Else
Alert("Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico")
End If
Else
Alert(String.Format("No se puede contabilizar la Prepoliza debido a que las siguientes cuentas son invalidas: {0}", CuentasContablesInvalidas))
End If
End If
End If
End If
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
ObjIE.Commit()
Dim StrMsg As New StringBuilder
StrMsg.Append("El Documento se guardó correctamente.<br/>")
If TipoTransaccion = "Egs" AndAlso CveIE > 0 Then GeneraChequePDF(CveIE, UsuarioActual.Empresa)
If IdPoliza > 0 Then
StrMsg.AppendFormat("<br/><a Class=""Texto"" target='_blank' href=""/Contabilidad/RegPoliza.aspx?IdPoliza={0}"">Ver Póliza</a>", IdPoliza)
End If
If RBLContado.SelectedValue.ToEntero = 6 And ChkEmitirComplementoPago.Checked Then GeneraTimbre(CvePrePoliza) Else Alert(StrMsg.ToString, TipoMensaje.MsgInformacion, "self.parent.tb_remove();self.parent.location.reload();")
Else
ObjIE.RollBack()
Alert(MsgError, TipoMensaje.MsgError)
End If
ObjIE.Dispose()
ObjMov.Dispose()
End Sub
#End Region
#Region "COMPLEMENTO DE PAGO"
Private Sub GeneraTimbre(CvePrePoliza As Integer)
Dim Str As New StringBuilder
Dim Banco As New ClsBancos
Banco.IniciaTransacSQL()
If Banco.GeneraTimbrePago(CveIE, -1, UsuarioActual, CvePrePoliza:=CvePrePoliza) Then
If Banco.Mensaje = "" Then
Banco.Commit()
PDFReciboDePagos(-1, -1, Banco.CveComplementoPago, False)
Str.AppendFormat("Folio: <b>{0}</b> &nbsp;", Banco.ComplementoSerieFolio)
Str.AppendFormat("<a class=""texto"" style='color:#337ab7' href=""/Compras/PopUpVerFactura.aspx?P={0}"" target=""_blank"">XML &nbsp;<i class=""fa fa-file""></i></i></a>&nbsp;&nbsp;", Encripta(String.Format("OP=CompP&EXT=xml&SerieFolio={0}&CveComplementoPago={1}", Banco.ComplementoSerieFolio, Banco.CveComplementoPago)))
Str.AppendFormat("<a class=""texto"" style='color:#337ab7' href=""/Compras/PopUpVerFactura.aspx?P={0}"" target=""_blank"">PDF &nbsp;<i class=""fa fa-ad-pdf""></i></i></i></a>&nbsp;", Encripta(String.Format("OP=CompP&EXT=pdf&SerieFolio={0}&CveComplementoPago={1}", Banco.ComplementoSerieFolio, Banco.CveComplementoPago)))
'Str.AppendFormat("<a style='color:#337ab7' target='_blank' href='./IE.aspx?CveIE={0}'>{1}</a> &nbsp; {2}<br>", CveIE, SerieFolio, NombreProveedor)
MandaCorreo(Banco.ComplementoSerieFolio, Banco.CobranzaCorreo)
End If
Else
Str.AppendFormat("No se genero complemento del Folio {0} por el siguiente motivo: {1}", SerieFolio, Banco.Mensaje)
Banco.RollBack()
End If
Banco.Dispose()
Alert(Str.ToString, TipoMensaje.MsgInformacion, "self.parent.tb_remove();self.parent.location.reload();")
End Sub
Private Sub MandaCorreo(NombreArchivo As String, Correo As String, Optional ConAlerta As Boolean = True)
Try
Dim Msg As String = ""
If NombreArchivo <> "-1" Then '
Dim ObjMail As New ClsSisMail()
Dim RutaXML As String = String.Format("{0}\XML\Pag\{1}.xml", UsuarioActual.Empresa.Ruta, NombreArchivo)
Dim RutaPDF As String = String.Format("{0}\PDF\Pag\{1}.pdf", UsuarioActual.Empresa.Ruta, NombreArchivo)
Dim Cuerpo As String = "Se hace entrega del comprobante de pago"
Dim Asunto As String = "Entrega de comprobante de pago"
If IO.File.Exists(RutaPDF) AndAlso IO.File.Exists(RutaXML) Then
Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail)
LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaPDF})
LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaXML})
If ObjMail.SendMail(UsuarioActual.Empresa, Correo, Asunto, Cuerpo, "", LSRutasMail) Then
If ConAlerta Then
RegistraScript("$('#ModalDivMail').modal('hide');")
Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion)
End If
Else
Msg = "No se pudo enviar el correo electrónico."
End If
Else
Msg = "No se pudo adjuntar el correo electrónico."
End If
End If
If ConAlerta AndAlso Msg <> "" Then
Alert(Msg, TipoMensaje.MsgError)
End If
Catch ex As Exception
OnError("Ocurrió error al mandar MAIL", ex)
End Try
End Sub
#End Region
End Class