diff --git a/Inventarios/TraspasoAlmacen.aspx.vb b/Inventarios/TraspasoAlmacen.aspx.vb
index 8b3f9aa69..3f4a50835 100644
--- a/Inventarios/TraspasoAlmacen.aspx.vb
+++ b/Inventarios/TraspasoAlmacen.aspx.vb
@@ -913,19 +913,41 @@ Partial Class Inventarios_TraspasoAlmacen
If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
Dim resultado As DataTable = ObjInventario.DtResultados
- Dim importe As Decimal = resultado.SUM("Total").ToDecimal
- Dim IdCtaContable As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenOrigen.SelectedValue.ToEntero)).ToEntero
+ Dim importe As Decimal = resultado.SUMD("Total")
+ Dim IdCtaContableSalida As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenOrigen.SelectedValue.ToEntero)).ToEntero
+ Dim IdCtaContableEntrada As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenDestino.SelectedValue.ToEntero)).ToEntero
+ Dim Contabilizable As Boolean = True
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoSalida) Then
+ If IdCtaContableSalida = IdCtaContableEntrada Then Contabilizable = False
+
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContableSalida, -1, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=Contabilizable) Then
ErrorMovInv = True
End If
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoEntrada) Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContableEntrada, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, Contabilizable:=Contabilizable) Then
ErrorMovInv = True
End If
End If
End If
End If
+ Else
+ If Not ErrorMovInv Then
+ Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/TraspasoAlmacen", 53, 0, 0, 1, Fecha, TxtObservaciones.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+ If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
+
+ Dim resultado As DataTable = ObjInventario.DtResultados
+ Dim importe As Decimal = resultado.SUM("Total").ToDecimal
+ Dim IdCtaContable As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenTransitorio.SelectedValue.ToEntero)).ToEntero
+
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoSalida) Then
+ ErrorMovInv = True
+ End If
+
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importe, TxtObservaciones.Text, 289, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoSalida) Then
+ ErrorMovInv = True
+ End If
+ End If
+ End If
End If
@@ -989,7 +1011,7 @@ Partial Class Inventarios_TraspasoAlmacen
If ErrorExistencia Then
CargaGvDatos()
End If
-
+ ObjConta.Dispose()
ObjInventario.Dispose()
End Sub
@@ -1573,6 +1595,7 @@ Partial Class Inventarios_TraspasoAlmacen
Dim Folio = 0
Dim ErrorMovInv As Boolean = False
Dim TextoError = ""
+ Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
'' verifica que no se halla recibido previamente, si ya se recibió da salida
If ObjInventario.GetMovimientosTransitorios(CveAlmacenDestino, -1, CveAlmacenTransitorio, -1, FolioBusqueda, UsuarioActual.CveEmpresa) Then
@@ -1644,7 +1667,23 @@ Partial Class Inventarios_TraspasoAlmacen
End If
Cont += 1
Next
-
+ If Not ErrorMovInv Then
+ Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/TraspasoAlmacen", 53, 0, 0, 1, Fecha, TxtObservacionesRecepcion.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+ If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
+
+ Dim resultado As DataTable = ObjInventario.DtResultados
+ Dim importe As Decimal = resultado.SUM("Total").ToDecimal
+ Dim IdCtaContable As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenTransitorioRecepcion.SelectedValue.ToEntero)).ToEntero
+
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, TxtObservaciones.Text, 289, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoSalida) Then
+ ErrorMovInv = True
+ End If
+
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoSalida) Then
+ ErrorMovInv = True
+ End If
+ End If
+ End If
End If
@@ -1773,6 +1812,7 @@ Partial Class Inventarios_TraspasoAlmacen
Alert(TextoError, TipoMensaje.MsgError)
End If
ObjInventario.Dispose()
+ ObjConta.Dispose()
CargaRecepcion()
Else
Alert("No hay movimientos para el traspaso", TipoMensaje.MsgAdvertencia)
diff --git a/OC/OC.aspx b/OC/OC.aspx
index edde3253c..695e0f215 100644
--- a/OC/OC.aspx
+++ b/OC/OC.aspx
@@ -591,7 +591,7 @@
-
+
<%-- --%>
diff --git a/Planeacion/CatSubProyectos.aspx.vb b/Planeacion/CatSubProyectos.aspx.vb
index 217c9a811..f2d679fd2 100644
--- a/Planeacion/CatSubProyectos.aspx.vb
+++ b/Planeacion/CatSubProyectos.aspx.vb
@@ -83,8 +83,8 @@ Partial Class CatSubProyectos
Private Sub RecargaGlobal()
Dim ObjSubProyectos As New ClsSubProyectos
- If ObjSubProyectos.GetSubProyectos() Then
- GlobalDTSubProyectos(-1) = ObjSubProyectos.DtResultados
+ If ObjSubProyectos.GetSubProyectos(UsuarioActual.CveEmpresa) Then
+ GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa) = ObjSubProyectos.DtResultados
End If
ObjSubProyectos.Dispose()
End Sub
@@ -400,6 +400,7 @@ Partial Class CatSubProyectos
RecargaGlobal()
Else
ObjSubproyectos.RollBack()
+ RecargaGlobal()
End If
'se regeneran los subproyectos
diff --git a/Ventas/ClientesAbonar.aspx b/Ventas/ClientesAbonar.aspx
index 2035e1abc..28a85c533 100644
--- a/Ventas/ClientesAbonar.aspx
+++ b/Ventas/ClientesAbonar.aspx
@@ -346,7 +346,7 @@
-
+
@@ -501,7 +501,7 @@
var Ventas = '';
function FnSuma(t, txt, importe) {
- debugger;
+
var chkPesosBancos = $get("ChkPagarPesos");
var chkDolaresBancos = $get("ChkPagarDolares");
@@ -526,7 +526,7 @@
}
function SumaValores(pagoMultiple, monedaPago) {
- debugger;
+
var Importe = 0;
var Comision = 0.00;
var topLevelElem = document.getElementById("form1");
@@ -614,8 +614,6 @@
}
function FnCambia(chk, txt, saldo, op, pagoMultiple, monedaPago) {
- debugger;
-
if (op == 1) {
if (txt.value != '') {
chk.checked = true;
@@ -650,9 +648,20 @@
$get('LbImporteMN').innerHTML = '$ ' + FormatoNumero(SumaConversion, 2) + ' MXN';
}
}
+ function FnSeleccionaNC(chk, chkNC)
+ {
+ if (chk.checked) {
+ chkNC.disabled = false;
+ chkNC.click();
+ } else {
+ chkNC.disabled = true;
+ if (chkNC.checked) {
+ chkNC.click();
+ }
+ }
+ }
function FnLimites(chk, txt, limiteInferior, limiteSuperior) {
- debugger;
if (ToDouble(txt.value) < limiteInferior) {
txt.value = limiteInferior;
alert("El Importe no debe de exceder a el saldo");
@@ -674,11 +683,8 @@
}
function CambiaPesosDolares() {
- debugger;
$get('TxtImporte').value = FormatoNumero(SumaValores(), 2);
$('#LtlTotalMXN').text(FormatoNumero(SumaValores(), 2))
-
- debugger;
if ($("#LbImporteME").length) {
$get('LbImporteME').innerHTML = '$ ' + FormatoNumero(SumaValores(), 2) + ' USD';
$get('TxtImporte').value = FormatoNumero(ToDouble($get('TxtImporte').value) * ToDouble($get('TxtTC').value), 2);
@@ -691,12 +697,12 @@
}
function CambiaDolaresPesos() {
- debugger;
+
$get('TxtImporte').value = FormatoNumero(SumaValores(), 2);
$('#LtlTotalMXN').text(FormatoNumero(SumaValores(), 2))
- debugger;
+
if ($("#LbImporteMN").length) {
$get('LbImporteMN').innerHTML = '$ ' + FormatoNumero(SumaValores(), 2) + ' MXN';
$get('TxtImporte').value = FormatoNumero(ToDouble($get('TxtImporte').value) / ToDouble($get('TxtTCDolares').value), 2);
@@ -743,7 +749,7 @@
for (var i = 0; i < textBoxes.length; i++) {
if (textBoxes[i].type == "checkbox") {
- debugger;
+
if (textBoxes[i].id == "ChkAll") {
check = !textBoxes[i].checked;
diff --git a/Ventas/ClientesAbonar.aspx.vb b/Ventas/ClientesAbonar.aspx.vb
index 4b8a485f2..a6a8b87f1 100644
--- a/Ventas/ClientesAbonar.aspx.vb
+++ b/Ventas/ClientesAbonar.aspx.vb
@@ -615,9 +615,12 @@ Partial Class Ventas_ClientesAbonar
End Select
-
- e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("FnSuma(this,{0},{1}); FnCambia({2},this,{1},0,{3},{4});", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo"), e.Row.FCCheckBox("Chk").ClientID, CveMonedaFiltro, moneda))
-
+ If e.Row.DBCampo("DescuentoProntoPago").ToDecimal() > 0 Then
+ e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("FnSuma(this,{0},{1}); FnCambia({2},this,{1},0,{3},{4}); FnSeleccionaNC({5},{6});", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo"), e.Row.FCCheckBox("Chk").ClientID, CveMonedaFiltro, moneda, e.Row.FCCheckBox("Chk").ClientID, e.Row.FCCheckBox("ChkGenerarNC").ClientID))
+ Else
+ e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("FnSuma(this,{0},{1}); FnCambia({2},this,{1},0,{3},{4});", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo"), e.Row.FCCheckBox("Chk").ClientID, CveMonedaFiltro, moneda))
+ End If
+
If Not UsuarioActual.Empresa.Funcionalidad(536) = "1" Then
If e.Row.DBCampo("TipoDocto") = "Rem" Then
e.Row.FCCheckBox("Chk").Visible = False ' que no se pueda pagar si es remisión
@@ -656,7 +659,17 @@ Partial Class Ventas_ClientesAbonar
End If
End Sub
- Protected Sub BtnIEGuardar_Click(sender As Object, e As EventArgs) Handles BtnIEGuardar.Click
+ Protected Sub BtnIEGuardar_Click(sender As Object, e As EventArgs) Handles BtnIEGuardar.Click
+
+ If Not TxtImporte.Text.ToDecimal > 0 Then
+ Alert("Debe de llevar un Importe", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ If Not (TxtFolio.Text.Trim <> "" Or RblTipoPago.SelectedValue = "2" Or RblTipoPago.SelectedValue = "3") Then
+ Alert("Debe de llevar un Folio", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
Dim Cuenta As String = ""
Dim CuentaDeposito As String = ""
@@ -671,8 +684,7 @@ Partial Class Ventas_ClientesAbonar
If seleccion = 0 Then
Alert("No ha seleccionado ninguna factura para abonar.", TipoMensaje.MsgAdvertencia)
Exit Sub
- End If
-
+ End If
Dim CvePrePoliza As Integer = 0
Dim IDPoliza As Integer = 0
@@ -681,702 +693,644 @@ Partial Class Ventas_ClientesAbonar
Dim CveVentasPago As New List(Of Integer)
Dim SeriesPago As New List(Of String)
- Dim filesgral As List(Of Archivo) = Anexo.getfiles().Archivos
- Dim filemove As String = ""
- Dim Comprobante As String = ""
- ComplementoSustitucionGenerado = False
-
- For Each fileItem As Archivo In filesgral
- Comprobante = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
- filemove = fileItem.filename
- Next
-
Dim MsgError As String = ""
Dim NCGeneradas As New List(Of Modelos.Factura.MMensajeFactura)
Dim ListaFacturasGenerarNC As New List(Of Modelos.Factura)
- 'comentada RMF 2018.09.28
- 'Dim Dep As New ClsGenerales
- 'If Dep.GetCuentasDepositos(CveCliente:=CveCliente) 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 ImporteSeleccionado As Decimal = 0
- 'If Not UsuarioActual.Empresa.Funcionalidad(529) = "1" Then
- ' Dim Validada As Boolean = False
- ' Dim MsgValidadas As New StringBuilder
-
-
-
- 'If Not UsuarioActual.Empresa.Funcionalidad(529) = "1" Then
-
-
- ' Dim Valida As New ClsValidaCFDi()
-
- ' 'veririco ante el SAT las ventas que voy a pagar
- ' For Each gvr As GridViewRow In GvCxC.Rows
- ' If gvr.FCCheckBox("Chk").Checked Then
- ' ImporteSeleccionado += gvr.FCTextBox("TxtAbonar").Text.ToDecimal
-
- ' If gvr.DataKey("UUID") <> "" Then
-
- ' Valida.Verificar(gvr.DataKey("UUID"), gvr.DataKey("RFC"), UsuarioActual.Empresa.RFC, gvr.DataKey("Original").ToDecimal)
-
- ' If Valida.EsValida > 0 Then
- ' If Valida.EsValida = 2 Then 'Cancelada
- ' MsgValidadas.AppendFormat("La factura está cancelada ante el SAT: {0} ", gvr.DataKey("SerieFolio"))
- ' Else
- ' Validada = True
- ' End If
- ' Else
- ' Validada = True
- ' End If
- ' End If
- ' End If
- ' Next
- ' Valida.Dispose()
-
- 'End If
-
- ' If MsgValidadas.Length > 0 Then
- ' Alert(String.Format(" Las Facturas presentan la siguiente situación ante el SAT. {0}", MsgValidadas.ToString), TipoMensaje.MsgAdvertencia)
- ' Exit Sub
- ' End If
- 'End If
-
+ Dim ImporteSeleccionado As Decimal = 0
+
+ '02-05-2018 MANDAMOS CANCELAR EL COMPLEMENTO A SUSTITUIR
+ Dim ErrorCancelarIE As Boolean = False
+
+ If CveIESustitucion > 0 Then
+ ErrorCancelarIE = CancelarIE()
+ If ErrorCancelarIE Then
+ Exit Sub
+ End If
+ End If
Dim ObjIE As New ClsBancos()
Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL)
- Dim ObjVentasSaldos As New ClsVentas(ObjIE.IniciaTransacSQL)
+ Dim ObjVentasSaldos As New ClsVentas(ObjIE.IniciaTransacSQL)
+ Dim ObjEvento As New ClsOIEventos(ObjIE.IniciaTransacSQL)
Dim ObjConta As ClsContPAQi = Nothing
- Dim ObjEvento As ClsOIEventos = New ClsOIEventos()
-
- If TxtImporte.Text.ToDecimal > 0 Then
-
- '02-05-2018 MANDAMOS CANCELAR EL COMPLEMENTO A SUSTITUIR
- Dim ErrorCancelarIE As Boolean = False
-
- If CveIESustitucion > 0 Then
- ErrorCancelarIE = CancelarIE()
- If ErrorCancelarIE Then
- 'Alert("Ocurrio un error al Cancelar el IE.", TipoMensaje.MsgError)
- Exit Sub
- End If
- End If
-
- If TxtFolio.Text.Trim <> "" Or RblTipoPago.SelectedValue = "2" Or RblTipoPago.SelectedValue = "3" Then
- Dim ConceptoPoliza As String = String.Format("{0} {1}", TxtAboneA.Text, TxtObservaciones.Text)
-
- If DdlCuenta.SelectedValue > 0 Then
- CveMoneda = GlobalDTBancosCuentas(-1).FiltroPrimeroValor("CveMoneda", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveCuenta = {DdlCuenta.SelectedValue.ToEntero}").ToEntero
- Else
- CveMoneda = If(Request("CveMoneda").ToString.ToEntero > 0, Request("CveMoneda").ToString.ToEntero, 1)
- End If
-
- CvePrePoliza = ObjMov.AddPrePolizas("Ventas/ClientesAbonar", 11, TxtImporte.Text.Trim.ToDecimal, TxtImporte.Text.Trim.ToDecimal, CveMoneda, TxtFechaDocumento.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
-
- If RblTipoPago.SelectedValue = "1" Then
- Dim CveCuentaDeposito As Integer = 0
- Dim TipoCambio As Decimal = 0
-
- If DdlCuentaDeposito.Items.Count > 0 Then
- CveCuentaDeposito = DdlCuentaDeposito.SelectedValue.ToEntero
- End If
-
- If CveMoneda = 2 Then
- If TxtTCDolares.Visible Then
- TipoCambio = TxtTCDolares.Text.ToDecimal
- Else
- TipoCambio = If(CveMonedaFiltro = -1, TxtTCDolares.Text.ToDecimal, TxtTCDolaresDolares.Text.ToDecimal) 'GlobalTipoCambio(TxtFechaDocumento.Text).ToString.ToDecimal
- End If
- Else
- If TxtTC.Visible Then
- TipoCambio = TxtTC.Text.ToDecimal
- End If
- End If
-
- Dim CveProvIntermediario As Integer
- If ChkProveedorIntermediario.Checked Then
- CveProvIntermediario = If(DdlProveedorIntermediario.SelectedValue.ToEntero <= 0, -1, DdlProveedorIntermediario.SelectedValue.ToEntero)
-
- End If
-
- CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFechaDocumento.Text.Trim.ToDate, TxtFolio.Text.Trim, TxtAboneA.Text.Trim, TxtImporte.Text.ToDecimal, GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimeroValor("CveMoneda", "CveCuenta = " & DdlCuenta.SelectedValue).ToEntero, TipoCambio, TxtObservaciones.Text.Trim, "", True, True, -1, CvePrePoliza, Comprobante, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCuentaDeposito:=CveCuentaDeposito, CveIESustitucion:=CveIESustitucion, CveProveedorIntermediario:=CveProvIntermediario)
- Else
- If RblTipoPago.SelectedValue.Contiene("3") Then
- CveIE = DdlIngreso.SelectedValue.ToEntero
- If CveMonedaPago = 2 And Not ChkPagarPesos.Checked Then CveMoneda = 2
- If ChkPagarDolares.Checked Then CveMoneda = 2
- If ChkPagarPesos.Checked Then CveMoneda = 1
- End If
-
- End If
-
- If CveIE > 0 OrElse RblTipoPago.SelectedValue.Contiene("2", "3") Then
-
- 'Guardar archivo
- If filemove <> "" Then
- filemove.FilesMove(CveIE.ToString, String.Format("Empresas\{0}\IE", UsuarioActual.CveEmpresa, UsuarioActual.Empresa.Ruta))
- End If
-
-
- 'inserto los movimientos de la conta para abonar al saldo
- If CvePrePoliza > 0 Then
-
- Dim PorcentajePago As Decimal = 100
- Dim CvePlantillaPoliza As Integer = 11
- Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:
"
- Dim idCuentaContabilizacion As Long = 1
- Dim CveCuentaContabilizacion As Long = 1
- Dim dtConceptos As DataTable = Nothing
- Dim tipoCambioVenta As Decimal
- Dim tipoCambioPago As Decimal
- Dim tipoCambioVentaValuacion As Decimal = 1
- Dim TipoCambioGeneral As Decimal = 1
- Dim CuentasContablesInvalidas As New StringBuilder
- Dim CuentasContablesInvalidasSIG As New StringBuilder
- Dim FuncionalidadFluctuacionImpuestos As Boolean = If(UsuarioActual.Empresa.Funcionalidad(159) = "1", True, False)
- Dim TipoCambioFluctuacion As Decimal = 1
- Dim FechaUltimaFluctuacion As Date = MinFecha
- If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then
- If ObjIE.DtResultados.Rows.Count > 0 Then
- Dim tFecha As Date = TxtFechaDocumento.Text.ToDate
- Dim Fecha As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day)
- Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & Fecha & "#", "Fecha DESC")
-
- If drr IsNot Nothing Then
- FechaUltimaFluctuacion = drr("Fecha").ToString.ToDate
- TipoCambioFluctuacion = drr("TipoCambio").ToString.ToDecimal
- End If
-
- End If
- End If
-
- If ObjMov.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPoliza) Then
- dtConceptos = ObjMov.DtResultados
- End If
-
- 'inserto las ventas que voy a pagar
- For Each gvr As GridViewRow In GvCxC.Rows
- If gvr.FCCheckBox("Chk").Checked Then
-
- If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then 'Si la venta viene en Pesos y se va a pagar en Pesos
- tipoCambioPago = 1
- tipoCambioVenta = 1
- PorcentajePago = gvr.FCTextBox("TxtAbonar").Text.ToDecimal / gvr.DataKey("Original").ToDecimal
- ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then 'Si la venta viene en Dolares y se va a pagar en Pesos
- tipoCambioPago = TxtTC.Text.ToDecimal
- tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
- tipoCambioVentaValuacion = If(gvr.DataKey("Fecha").ToDate < FechaUltimaFluctuacion, TipoCambioFluctuacion, gvr.DataKey("TipoCambio").ToDecimal)
- PorcentajePago = (gvr.FCTextBox("TxtAbonar").Text.ToDecimal) / gvr.DataKey("Original").ToDecimal
- ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then 'Si la venta viene en Dolares y se va a pagar en DOLARES
- tipoCambioPago = If(CveMonedaFiltro = -1, TxtTCDolares.Text.ToDecimal, TxtTCDolaresDolares.Text.ToDecimal)
- tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
- tipoCambioVentaValuacion = If(gvr.DataKey("Fecha").ToDate < FechaUltimaFluctuacion, TipoCambioFluctuacion, gvr.DataKey("TipoCambio").ToDecimal)
- PorcentajePago = gvr.FCTextBox("TxtAbonar").Text.ToDecimal / gvr.DataKey("Original").ToDecimal
- ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
- tipoCambioPago = TxtTCDolares.Text.ToDecimal
- tipoCambioVenta = 1
- PorcentajePago = gvr.FCTextBox("TxtAbonar").Text.ToDecimal / gvr.DataKey("Original").ToDecimal
- End If
-
- 'PARA EMITIR COMPLEMENTO PAGO
- CveVentasPago.Add(gvr.DataKey("CveVenta").ToEntero)
- SeriesPago.Add(gvr.DataKey("SerieFolio"))
-
- Dim tipoCambioVentaDiferenciaCambiaria As Double = 1
- Dim EsAnticipoEspecial As Boolean = False
-
- If gvr.DataKey("TipoDocto") = "Ant" AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) Then EsAnticipoEspecial = True
-
- If dtConceptos IsNot Nothing Then
- For Each Row As DataRow In dtConceptos.Rows
-
- Dim ConceptoContable = Row("CveConcepto").ToString.ToEntero
- Dim TipoMovimiento As Boolean = If(Row("TipoMovto").ToString = "True", True, False)
- Dim ImporteMovimiento As Decimal = 0
- Dim importeMX As Decimal
- Dim FechaMovimiento As Date = TxtFechaDocumento.Text
- Dim IdCtaContable As Integer = 0
- Dim CveCuenta As Integer = 0
- Dim ConceptoMovimiento As String = ObjMov.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, ConceptoContable, NombreComercial, gvr.DataKey("SerieFolio").ToString, TxtFolio.Text.Trim)
- Dim Referencia As String = gvr.DataKey("SerieFolio").ToString
- Dim CveSubProyecto As Integer = gvr.DataKey("CveSubProyecto").ToEntero
- Dim CveSubProyectoContabilizar As Integer = -1
- Dim PorcentajeImpuesto As Decimal = 0
-
- Select Case ConceptoContable
- Case 2 'Pago Cliente
- 'If gvr.DataKey("CveMoneda").ToEntero > 1 Then ConceptoContable = 292
- If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
- ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal
- importeMX = ImporteMovimiento
- ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal
- importeMX = gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioVentaValuacion
- ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
- ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal
- importeMX = gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioVentaValuacion
- ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal
- importeMX = ImporteMovimiento * tipoCambioVentaValuacion
- End If
- ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)
- importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero)
- TipoCambioGeneral = tipoCambioVentaValuacion
- CveSubProyectoContabilizar = CveSubProyecto
-
- If gvr.DataKey("CveMoneda").ToEntero = 1 Then
- IdCtaContable = If(EsAnticipoEspecial, IdCtaAnticipo, IdCuentaCliente)
- ConceptoContable = If(EsAnticipoEspecial, 3, ConceptoContable)
- CveCuenta = If(EsAnticipoEspecial, -1, CveCuentaCliente)
- Else
- ConceptoMovimiento += $" TC:{tipoCambioVentaValuacion} ${ImporteMovimiento.FormatoNumero(2)}"
- IdCtaContable = If(EsAnticipoEspecial, IdCtaContMonedaComplementariaAnticipo, IdCtaContComplementaria)
- CveCuenta = If(EsAnticipoEspecial, -1, CveCuentaComplementaria)
- If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then
- importeMX = ImporteMovimiento
- If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, Referencia, If(gvr.DataKey("TipoDocto") = "Ant" AndAlso UsuarioActual.CveEmpresa = 119, 226, 207), ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE, gvr.FCHyperLink("HplF2").Text.ToEntero, -1, CveSubProyectoContabilizar, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=Math.Round(ImporteMovimiento * tipoCambioVentaValuacion - ImporteMovimiento, 2, MidpointRounding.AwayFromZero), ImporteME:=ImporteMovimiento, CveCuenta:=CveCuenta, TipoCambio:=tipoCambioVentaValuacion) Then
- MsgError = "No se pudo insertar la póliza"
- End If
- End If
- IdCtaContable = If(EsAnticipoEspecial, IdCtaContMonedaExtranjeraAnticipo, IdCtaContMonedaExtranjera)
- CveCuenta = If(EsAnticipoEspecial, -1, CveCuentaMonedaExtranjera)
- ConceptoContable = If(EsAnticipoEspecial, 3, ConceptoContable)
- End If
-
- If EsAnticipoEspecial Then
- If ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, Referencia, 2, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE, gvr.FCHyperLink("HplF2").Text.ToEntero, -1, CveSubProyectoContabilizar, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=importeMX, CveCuenta:=CveCuenta, TipoCambio:=TipoCambioGeneral, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=PorcentajeImpuesto, Contabilizable:=False) Then
- If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, Referencia, 95, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE, gvr.FCHyperLink("HplF2").Text.ToEntero, -1, CveSubProyectoContabilizar, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=importeMX, CveCuenta:=CveCuenta, TipoCambio:=TipoCambioGeneral, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=PorcentajeImpuesto, Contabilizable:=False) Then
- MsgError = "No se pudo insertar la póliza"
- End If
- Else
- MsgError = "No se pudo insertar la póliza"
- End If
- End If
-
-
- Case 8 'Ret IVA x Trasladar
- If EsAnticipoEspecial Then Exit Select
- If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
- ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago
- importeMX = ImporteMovimiento
- ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
- ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago
- importeMX = ImporteMovimiento * tipoCambioVenta
- ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
- ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago)
- importeMX = ImporteMovimiento * tipoCambioVenta
- ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
- ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago
- importeMX = ImporteMovimiento * tipoCambioVenta
- End If
- ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)
- importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero)
- TipoCambioGeneral = tipoCambioVenta
- CveSubProyectoContabilizar = CveSubProyecto
-
- If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(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
- Case 9 'Ret ISR x Trasladar
- If EsAnticipoEspecial Then Exit Select
- If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
- ImporteMovimiento = gvr.DataKey("RetISR").ToDecimal * PorcentajePago
- importeMX = ImporteMovimiento
- ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
- ImporteMovimiento = gvr.DataKey("RetISR").ToDecimal * PorcentajePago
- importeMX = ImporteMovimiento * tipoCambioVenta
- ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
- ImporteMovimiento = (gvr.DataKey("RetISR").ToDecimal * PorcentajePago)
- importeMX = ImporteMovimiento * tipoCambioVenta
- ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
- ImporteMovimiento = gvr.DataKey("RetISR").ToDecimal * PorcentajePago
- importeMX = ImporteMovimiento * tipoCambioVenta
- End If
- ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)
- importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero)
- TipoCambioGeneral = tipoCambioVenta
- CveSubProyectoContabilizar = CveSubProyecto
-
- If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(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
- Case 13 'Iva por Trasladar
- If EsAnticipoEspecial Then Exit Select
- If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
- ImporteMovimiento = gvr.DataKey("IVA").ToDecimal * PorcentajePago
- importeMX = ImporteMovimiento
- ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
- ImporteMovimiento = gvr.DataKey("IVA").ToDecimal * PorcentajePago
- importeMX = ImporteMovimiento * tipoCambioVenta
- ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
- ImporteMovimiento = (gvr.DataKey("IVA").ToDecimal * PorcentajePago)
- importeMX = ImporteMovimiento * tipoCambioVenta
- ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
- ImporteMovimiento = gvr.DataKey("IVA").ToDecimal * PorcentajePago
- importeMX = ImporteMovimiento * tipoCambioVenta
- End If
- ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)
- importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero)
- TipoCambioGeneral = tipoCambioVenta
- CveSubProyectoContabilizar = CveSubProyecto
-
- PorcentajeImpuesto = gvr.DataKey("PorcentajeIVA").ToDecimal
- Dim IdCtaIVAXTrasladar As Integer = 0
- Dim CveCuentaIVAxTrasladar As Integer = 0
-
- If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then
- IdCtaIVAXTrasladar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAXTrasladar").ToString.ToEntero
- CveCuentaIVAxTrasladar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("CveCuentaIVAXTrasladar").ToString.ToEntero
- End If
-
- IdCtaContable = If(IdCtaIVAXTrasladar > 0, IdCtaIVAXTrasladar, UsuarioActual.Empresa.IdCuentaIVAxTrasladar)
- CveCuenta = If(CveCuentaIVAxTrasladar > 0, CveCuentaIVAxTrasladar, UsuarioActual.Empresa.CveCuentaIVAxTrasladar)
- If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(2)}"
- Case 62 'Ret IVA Trasladado
- If EsAnticipoEspecial Then Exit Select
- If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
- ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago
- importeMX = ImporteMovimiento
- ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
- ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago)
- importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
- ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
- ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago)
- importeMX = ImporteMovimiento * tipoCambioVenta
- ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
- ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago)
- importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
- End If
- ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)
- importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero)
-
- TipoCambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
- CveSubProyectoContabilizar = CveSubProyecto
-
- If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(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
- Case 63 'Ret ISR Trasladado
- If EsAnticipoEspecial Then Exit Select
- If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
- ImporteMovimiento = gvr.DataKey("RetISR").ToDecimal * PorcentajePago
- importeMX = ImporteMovimiento
- ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
- ImporteMovimiento = (gvr.DataKey("RetISR").ToDecimal * PorcentajePago)
- importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
- ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
- ImporteMovimiento = (gvr.DataKey("RetISR").ToDecimal * PorcentajePago)
- importeMX = ImporteMovimiento * tipoCambioVenta
- ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
- ImporteMovimiento = (gvr.DataKey("RetISR").ToDecimal * PorcentajePago)
- importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
- End If
- ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)
- importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero)
- TipoCambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
- CveSubProyectoContabilizar = CveSubProyecto
-
- If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(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
- Case 61 'Iva Trasladado
- If EsAnticipoEspecial Then Exit Select
- If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
- ImporteMovimiento = gvr.DataKey("IVA").ToDecimal * PorcentajePago
- importeMX = ImporteMovimiento
- ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
- ImporteMovimiento = (gvr.DataKey("IVA").ToDecimal * PorcentajePago)
- importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
- ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
- ImporteMovimiento = (gvr.DataKey("IVA").ToDecimal * PorcentajePago)
- importeMX = ImporteMovimiento
- ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
- ImporteMovimiento = gvr.DataKey("IVA").ToDecimal * PorcentajePago
- importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
- End If
- ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)
- importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero)
- TipoCambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
- CveSubProyectoContabilizar = CveSubProyecto
-
- PorcentajeImpuesto = gvr.DataKey("PorcentajeIVA").ToDecimal
- Dim IdCtaIVATrasladado As Integer = 0
- Dim CveCuentaIVATrasladado As Integer = 0
-
- If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then
- IdCtaIVATrasladado = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVATrasladado").ToString.ToEntero
- CveCuentaIVATrasladado = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("CveCuentaIVATrasladado").ToString.ToEntero
- End If
-
- IdCtaContable = If(IdCtaIVATrasladado > 0, IdCtaIVATrasladado, UsuarioActual.Empresa.IdCuentaIVATrasladado)
- CveCuenta = If(CveCuentaIVATrasladado > 0, CveCuentaIVATrasladado, UsuarioActual.Empresa.CveCuentaIVATrasladado)
- If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}"
- Case 38 'IEPS por trasladar
- If EsAnticipoEspecial Then Exit Select
- If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
- ImporteMovimiento = gvr.DataKey("IEPS").ToDecimal * PorcentajePago
- importeMX = ImporteMovimiento
- ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
- ImporteMovimiento = (gvr.DataKey("IEPS").ToDecimal * PorcentajePago)
- importeMX = ImporteMovimiento * tipoCambioVenta
- ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
- ImporteMovimiento = (gvr.DataKey("IEPS").ToDecimal * PorcentajePago)
- importeMX = ImporteMovimiento * tipoCambioVenta
- ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
- ImporteMovimiento = (gvr.DataKey("IEPS").ToDecimal * PorcentajePago)
- importeMX = ImporteMovimiento * tipoCambioVenta
- End If
- ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)
- importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero)
- TipoCambioGeneral = tipoCambioVenta
- CveSubProyectoContabilizar = CveSubProyecto
-
- IdCtaContable = UsuarioActual.Empresa.IdCuentaIEPSxTrasladar
- CveCuenta = UsuarioActual.Empresa.CveCuentaIEPSxTrasladar
- Case 39 'IEPS Trasladado
- If EsAnticipoEspecial Then Exit Select
- If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
- ImporteMovimiento = gvr.DataKey("IEPS").ToDecimal * PorcentajePago
- importeMX = ImporteMovimiento
- ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
- ImporteMovimiento = (gvr.DataKey("IEPS").ToDecimal * PorcentajePago)
- importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
- ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
- ImporteMovimiento = (gvr.DataKey("IEPS").ToDecimal * PorcentajePago)
- importeMX = ImporteMovimiento
- ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
- ImporteMovimiento = (gvr.DataKey("IEPS").ToDecimal * PorcentajePago)
- importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
- End If
- ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)
- importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero)
- TipoCambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
- CveSubProyectoContabilizar = CveSubProyecto
-
- IdCtaContable = UsuarioActual.Empresa.IdCuentaIEPSTrasladado
- CveCuenta = UsuarioActual.Empresa.CveCuentaIEPSTrasladado
- Case 64 'Ganancia
- If CveMoneda <> 1 OrElse gvr.DataKey("CveMoneda").ToEntero <> 1 Then
- IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria
- CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria
- tipoCambioVentaDiferenciaCambiaria = If(gvr.DataKey("Fecha").ToDate < FechaUltimaFluctuacion, TipoCambioFluctuacion, gvr.DataKey("TipoCambio").ToDecimal)
- Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
-
-
- Dim Diferencia As Decimal = ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * tipoCambioVentaValuacion) - ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * tipoCambioPago) 'Añadimos la diferencia de perdida en la venta
- Diferencia -= ((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * tipoCambioVenta) - ((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el IVA
- Diferencia += ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * tipoCambioVenta) - ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetIVA
- Diferencia += ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * tipoCambioVenta) - ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetISR
- Diferencia -= ((gvr.DataKey("IEPS").ToDecimal * PorcentajePago) * tipoCambioVenta) - ((gvr.DataKey("IEPS").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el IEPS
- Diferencia = Math.Round(Diferencia, 2)
-
- '' se considera, las diferencias, y no el tipo de cambio, por el caso de las fluctuaciones
-
- '' si tiene funcionalidad de flucturación con ivas, tomar tipocambioventa
- If Diferencia < 0 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- ImporteMovimiento = Math.Abs(Diferencia)
- importeMX = ImporteMovimiento
- End If
-
- '' si tiene funcionalidad de flucturación con ivas, tomar tipocambioventa
- 'If tipoCambioPago > tipoCambioVentaDiferenciaCambiaria AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- ' ImporteMovimiento = (gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioPago) - (gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioVentaDiferenciaCambiaria) 'Añadimos la diferencia de ganancia en la venta
- ' ImporteMovimiento -= ((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * TCImpuestos) - ((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * tipoCambioVentaDiferenciaCambiaria) 'Añadimos la diferencia de ganancia en el IVA
- ' ImporteMovimiento += ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * TCImpuestos) - ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * tipoCambioVentaDiferenciaCambiaria) 'Añadimos la diferencia de ganancia en el RetIVA
- ' ImporteMovimiento += ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * TCImpuestos) - ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * tipoCambioVentaDiferenciaCambiaria) 'Añadimos la diferencia de ganancia en el RetISR
- ' ImporteMovimiento -= ((gvr.DataKey("IEPS").ToDecimal * PorcentajePago) * TCImpuestos) - ((gvr.DataKey("IEPS").ToDecimal * PorcentajePago) * tipoCambioVentaDiferenciaCambiaria) 'Añadimos la diferencia de ganancia en el IEPS
- ' ImporteMovimiento = Math.Abs(Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero))
- ' importeMX = ImporteMovimiento
- 'End If
- CveSubProyectoContabilizar = CveSubProyecto
- Else
- ImporteMovimiento = 0
- End If
-
- Case 65 'Perdida
- If CveMoneda <> 1 OrElse gvr.DataKey("CveMoneda").ToEntero <> 1 Then
- IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria
- CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria
- tipoCambioVentaDiferenciaCambiaria = If(gvr.DataKey("Fecha").ToDate < FechaUltimaFluctuacion, TipoCambioFluctuacion, gvr.DataKey("TipoCambio").ToDecimal)
- Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
-
- Dim Diferencia As Decimal = ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * tipoCambioVentaValuacion) - ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * tipoCambioPago) 'Añadimos la diferencia de perdida en la venta
- Diferencia -= ((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * tipoCambioVenta) - ((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el IVA
- Diferencia += ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * tipoCambioVenta) - ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetIVA
- Diferencia += ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * tipoCambioVenta) - ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetISR
- Diferencia -= ((gvr.DataKey("IEPS").ToDecimal * PorcentajePago) * tipoCambioVenta) - ((gvr.DataKey("IEPS").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el IEPS
- Diferencia = Math.Round(Diferencia, 2)
- 'si la diferencia es negativa es pérdida, si es positiva es ganancia
- If Diferencia > 0 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- ImporteMovimiento = Math.Abs(Diferencia)
- importeMX = ImporteMovimiento
- End If
-
- '' si tiene funcionalidad de flucturación con ivas, tomar tipocambioventa
- 'If tipoCambioPago < tipoCambioVentaDiferenciaCambiaria AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- ' ImporteMovimiento = (gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioVentaDiferenciaCambiaria) - (gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioPago) 'Añadimos la diferencia de perdida en la venta
- ' ImporteMovimiento -= ((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * tipoCambioVentaDiferenciaCambiaria) - ((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el IVA
- ' ImporteMovimiento += ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * tipoCambioVentaDiferenciaCambiaria) - ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * TCImpuestos)
- ' ImporteMovimiento += ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * tipoCambioVentaDiferenciaCambiaria) - ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetISR
- ' ImporteMovimiento -= ((gvr.DataKey("IEPS").ToDecimal * PorcentajePago) * tipoCambioVentaDiferenciaCambiaria) - ((gvr.DataKey("IEPS").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el IEPS
- ' ImporteMovimiento = Math.Abs(Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero))
- ' importeMX = ImporteMovimiento
- ' 'ElseIf tipoCambioPago > tipoCambioVenta AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
- ' ' ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal - (Math.Abs(Math.Round(gvr.FCTextBox("TxtAbonar").Text.ToDecimal / tipoCambioPago, 2)) * tipoCambioPago)
- ' ' 'ImporteMovimiento -= Math.Abs(Math.Round(((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * TCImpuestos) - ((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * tipoCambioVenta))) 'Añadimos la diferencia de ganancia en el IVA
- ' ' 'ImporteMovimiento += Math.Abs(Math.Round(((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * TCImpuestos) - ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * tipoCambioVenta))) 'Añadimos la diferencia de ganancia en el RetIVA
- ' ' 'ImporteMovimiento += Math.Abs(Math.Round(((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * TCImpuestos) - ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * tipoCambioVenta))) 'Añadimos la diferencia de ganancia en el RetISR
- ' ' 'ImporteMovimiento -= Math.Abs(Math.Round(((gvr.DataKey("IEPS").ToDecimal * PorcentajePago) * TCImpuestos) - ((gvr.DataKey("IEPS").ToDecimal * PorcentajePago) * tipoCambioVenta))) 'Añadimos la diferencia de ganancia en el IEPS
- ' ' ImporteMovimiento = ImporteMovimiento
- ' ' importeMX = ImporteMovimiento
- 'End If
- CveSubProyectoContabilizar = CveSubProyecto
- Else
- ImporteMovimiento = 0
- End If
-
- Case 78 'Otros Ingresos
- If ChkAjusteOI.Checked Then
- ImporteMovimiento = gvr.FCTextBox("TxtComision").Text.ToDecimal
- importeMX = Math.Round(ImporteMovimiento * tipoCambioPago, 2)
-
- If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
- ImporteMovimiento = gvr.FCTextBox("TxtComision").Text.ToDecimal
- importeMX = ImporteMovimiento
- ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- ImporteMovimiento = gvr.FCTextBox("TxtComision").Text.ToDecimal
- importeMX = ImporteMovimiento * tipoCambioPago
- ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
- ImporteMovimiento = gvr.FCTextBox("TxtComision").Text.ToDecimal
- importeMX = ImporteMovimiento
- ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
- ImporteMovimiento = gvr.FCTextBox("TxtComision").Text.ToDecimal
- importeMX = ImporteMovimiento * tipoCambioPago
- End If
-
- If gvr.FCTextBox("TxtComision").Text.ToDecimal < 0 Then
- TipoMovimiento = False
- ImporteMovimiento = ImporteMovimiento * -1
- importeMX = importeMX * -1
- Else
- TipoMovimiento = True
- End If
-
- ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)
- importeMX = Math.Round(importeMX, 2)
- TipoCambioGeneral = tipoCambioPago
- CveSubProyectoContabilizar = CveSubProyecto
-
- IdCtaContable = UsuarioActual.Empresa.IdCuentaOtrosIngresos
-
- If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(2)}"
-
+ Try
+ Dim filesgral As List(Of Archivo) = Anexo.getfiles().Archivos
+ Dim filemove As String = ""
+ Dim Comprobante As String = ""
+ ComplementoSustitucionGenerado = False
+
+ For Each fileItem As Archivo In filesgral
+ Comprobante = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
+ filemove = fileItem.filename
+ Next
+
+ Dim ConceptoPoliza As String = String.Format("{0} {1}", TxtAboneA.Text, TxtObservaciones.Text)
+
+ If DdlCuenta.SelectedValue > 0 Then
+ CveMoneda = GlobalDTBancosCuentas(-1).FiltroPrimeroValor("CveMoneda", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveCuenta = {DdlCuenta.SelectedValue.ToEntero}").ToEntero
+ Else
+ CveMoneda = If(Request("CveMoneda").ToString.ToEntero > 0, Request("CveMoneda").ToString.ToEntero, 1)
+ End If
+
+ CvePrePoliza = ObjMov.AddPrePolizas("Ventas/ClientesAbonar", 11, TxtImporte.Text.Trim.ToDecimal, TxtImporte.Text.Trim.ToDecimal, CveMoneda, TxtFechaDocumento.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+
+ If RblTipoPago.SelectedValue = "1" Then
+ Dim CveCuentaDeposito As Integer = 0
+ Dim TipoCambio As Decimal = 0
+
+ If DdlCuentaDeposito.Items.Count > 0 Then
+ CveCuentaDeposito = DdlCuentaDeposito.SelectedValue.ToEntero
+ End If
+
+ If CveMoneda = 2 Then
+ If TxtTCDolares.Visible Then
+ TipoCambio = TxtTCDolares.Text.ToDecimal
+ Else
+ TipoCambio = If(CveMonedaFiltro = -1, TxtTCDolares.Text.ToDecimal, TxtTCDolaresDolares.Text.ToDecimal) 'GlobalTipoCambio(TxtFechaDocumento.Text).ToString.ToDecimal
+ End If
+ Else
+ If TxtTC.Visible Then
+ TipoCambio = TxtTC.Text.ToDecimal
+ End If
+ End If
+
+ Dim CveProvIntermediario As Integer
+ If ChkProveedorIntermediario.Checked Then
+ CveProvIntermediario = If(DdlProveedorIntermediario.SelectedValue.ToEntero <= 0, -1, DdlProveedorIntermediario.SelectedValue.ToEntero)
+
+ End If
+
+ CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFechaDocumento.Text.Trim.ToDate, TxtFolio.Text.Trim, TxtAboneA.Text.Trim, TxtImporte.Text.ToDecimal, GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimeroValor("CveMoneda", "CveCuenta = " & DdlCuenta.SelectedValue).ToEntero, TipoCambio, TxtObservaciones.Text.Trim, "", True, True, -1, CvePrePoliza, Comprobante, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCuentaDeposito:=CveCuentaDeposito, CveIESustitucion:=CveIESustitucion, CveProveedorIntermediario:=CveProvIntermediario)
+ Else
+ If RblTipoPago.SelectedValue.Contiene("3") Then
+ CveIE = DdlIngreso.SelectedValue.ToEntero
+ If CveMonedaPago = 2 And Not ChkPagarPesos.Checked Then CveMoneda = 2
+ If ChkPagarDolares.Checked Then CveMoneda = 2
+ If ChkPagarPesos.Checked Then CveMoneda = 1
+ End If
+
+ End If
+
+ If CveIE > 0 OrElse RblTipoPago.SelectedValue.Contiene("2", "3") Then
+
+ 'Guardar archivo
+ If filemove <> "" Then
+ filemove.FilesMove(CveIE.ToString, String.Format("Empresas\{0}\IE", UsuarioActual.CveEmpresa, UsuarioActual.Empresa.Ruta))
+ End If
+
+
+ 'inserto los movimientos de la conta para abonar al saldo
+ If CvePrePoliza > 0 Then
+
+ Dim PorcentajePago As Decimal = 100
+ Dim CvePlantillaPoliza As Integer = 11
+ Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:
"
+ Dim idCuentaContabilizacion As Long = 1
+ Dim CveCuentaContabilizacion As Long = 1
+ Dim dtConceptos As DataTable = Nothing
+ Dim tipoCambioVenta As Decimal
+ Dim tipoCambioPago As Decimal
+ Dim tipoCambioVentaValuacion As Decimal = 1
+ Dim TipoCambioGeneral As Decimal = 1
+ Dim CuentasContablesInvalidas As New StringBuilder
+ Dim CuentasContablesInvalidasSIG As New StringBuilder
+ Dim FuncionalidadFluctuacionImpuestos As Boolean = If(UsuarioActual.Empresa.Funcionalidad(159) = "1", True, False)
+ Dim TipoCambioFluctuacion As Decimal = 1
+ Dim FechaUltimaFluctuacion As Date = MinFecha
+ If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then
+ If ObjIE.DtResultados.Rows.Count > 0 Then
+ Dim tFecha As Date = TxtFechaDocumento.Text.ToDate
+ Dim Fecha As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day)
+ Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & Fecha & "#", "Fecha DESC")
+
+ If drr IsNot Nothing Then
+ FechaUltimaFluctuacion = drr("Fecha").ToString.ToDate
+ TipoCambioFluctuacion = drr("TipoCambio").ToString.ToDecimal
+ End If
+
+ End If
+ End If
+
+ If ObjMov.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPoliza) Then
+ dtConceptos = ObjMov.DtResultados
+ End If
+
+ 'inserto las ventas que voy a pagar
+ For Each gvr As GridViewRow In GvCxC.Rows
+ If gvr.FCCheckBox("Chk").Checked Then
+
+ If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then 'Si la venta viene en Pesos y se va a pagar en Pesos
+ tipoCambioPago = 1
+ tipoCambioVenta = 1
+ PorcentajePago = gvr.FCTextBox("TxtAbonar").Text.ToDecimal / gvr.DataKey("Original").ToDecimal
+ ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then 'Si la venta viene en Dolares y se va a pagar en Pesos
+ tipoCambioPago = TxtTC.Text.ToDecimal
+ tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
+ tipoCambioVentaValuacion = If(gvr.DataKey("Fecha").ToDate < FechaUltimaFluctuacion, TipoCambioFluctuacion, gvr.DataKey("TipoCambio").ToDecimal)
+ PorcentajePago = (gvr.FCTextBox("TxtAbonar").Text.ToDecimal) / gvr.DataKey("Original").ToDecimal
+ ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then 'Si la venta viene en Dolares y se va a pagar en DOLARES
+ tipoCambioPago = If(CveMonedaFiltro = -1, TxtTCDolares.Text.ToDecimal, TxtTCDolaresDolares.Text.ToDecimal)
+ tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
+ tipoCambioVentaValuacion = If(gvr.DataKey("Fecha").ToDate < FechaUltimaFluctuacion, TipoCambioFluctuacion, gvr.DataKey("TipoCambio").ToDecimal)
+ PorcentajePago = gvr.FCTextBox("TxtAbonar").Text.ToDecimal / gvr.DataKey("Original").ToDecimal
+ ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
+ tipoCambioPago = TxtTCDolares.Text.ToDecimal
+ tipoCambioVenta = 1
+ PorcentajePago = gvr.FCTextBox("TxtAbonar").Text.ToDecimal / gvr.DataKey("Original").ToDecimal
+ End If
+
+ 'PARA EMITIR COMPLEMENTO PAGO
+ CveVentasPago.Add(gvr.DataKey("CveVenta").ToEntero)
+ SeriesPago.Add(gvr.DataKey("SerieFolio"))
+
+ Dim tipoCambioVentaDiferenciaCambiaria As Double = 1
+ Dim EsAnticipoEspecial As Boolean = False
+
+ If gvr.DataKey("TipoDocto") = "Ant" AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) Then EsAnticipoEspecial = True
+
+ If dtConceptos IsNot Nothing Then
+ For Each Row As DataRow In dtConceptos.Rows
+
+ Dim ConceptoContable = Row("CveConcepto").ToString.ToEntero
+ Dim TipoMovimiento As Boolean = If(Row("TipoMovto").ToString = "True", True, False)
+ Dim ImporteMovimiento As Decimal = 0
+ Dim importeMX As Decimal
+ Dim FechaMovimiento As Date = TxtFechaDocumento.Text
+ Dim IdCtaContable As Integer = 0
+ Dim CveCuenta As Integer = 0
+ Dim ConceptoMovimiento As String = ObjMov.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, ConceptoContable, NombreComercial, gvr.DataKey("SerieFolio").ToString, TxtFolio.Text.Trim)
+ Dim Referencia As String = gvr.DataKey("SerieFolio").ToString
+ Dim CveSubProyecto As Integer = gvr.DataKey("CveSubProyecto").ToEntero
+ Dim CveSubProyectoContabilizar As Integer = -1
+ Dim PorcentajeImpuesto As Decimal = 0
+
+ Select Case ConceptoContable
+ Case 2 'Pago Cliente
+ 'If gvr.DataKey("CveMoneda").ToEntero > 1 Then ConceptoContable = 292
+ If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
+ ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal
+ importeMX = ImporteMovimiento
+ ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal
+ importeMX = gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioVentaValuacion
+ ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
+ ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal
+ importeMX = gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioVentaValuacion
+ ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal
+ importeMX = ImporteMovimiento * tipoCambioVentaValuacion
+ End If
+ ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)
+ importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero)
+ TipoCambioGeneral = tipoCambioVentaValuacion
+ CveSubProyectoContabilizar = CveSubProyecto
+
+ If gvr.DataKey("CveMoneda").ToEntero = 1 Then
+ IdCtaContable = If(EsAnticipoEspecial, IdCtaAnticipo, IdCuentaCliente)
+ ConceptoContable = If(EsAnticipoEspecial, 3, ConceptoContable)
+ CveCuenta = If(EsAnticipoEspecial, -1, CveCuentaCliente)
+ Else
+ ConceptoMovimiento += $" TC:{tipoCambioVentaValuacion} ${ImporteMovimiento.FormatoNumero(2)}"
+ IdCtaContable = If(EsAnticipoEspecial, IdCtaContMonedaComplementariaAnticipo, IdCtaContComplementaria)
+ CveCuenta = If(EsAnticipoEspecial, -1, CveCuentaComplementaria)
+ If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then
+ importeMX = ImporteMovimiento
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, Referencia, If(gvr.DataKey("TipoDocto") = "Ant" AndAlso UsuarioActual.CveEmpresa = 119, 226, 207), ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE, gvr.FCHyperLink("HplF2").Text.ToEntero, -1, CveSubProyectoContabilizar, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=Math.Round(ImporteMovimiento * tipoCambioVentaValuacion - ImporteMovimiento, 2, MidpointRounding.AwayFromZero), ImporteME:=ImporteMovimiento, CveCuenta:=CveCuenta, TipoCambio:=tipoCambioVentaValuacion) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
End If
+ IdCtaContable = If(EsAnticipoEspecial, IdCtaContMonedaExtranjeraAnticipo, IdCtaContMonedaExtranjera)
+ CveCuenta = If(EsAnticipoEspecial, -1, CveCuentaMonedaExtranjera)
+ ConceptoContable = If(EsAnticipoEspecial, 3, ConceptoContable)
+ End If
+
+ If EsAnticipoEspecial Then
+ If ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, Referencia, 2, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE, gvr.FCHyperLink("HplF2").Text.ToEntero, -1, CveSubProyectoContabilizar, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=importeMX, CveCuenta:=CveCuenta, TipoCambio:=TipoCambioGeneral, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=PorcentajeImpuesto, Contabilizable:=False) Then
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, Referencia, 95, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE, gvr.FCHyperLink("HplF2").Text.ToEntero, -1, CveSubProyectoContabilizar, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=importeMX, CveCuenta:=CveCuenta, TipoCambio:=TipoCambioGeneral, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=PorcentajeImpuesto, Contabilizable:=False) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
+ Else
+ MsgError = "No se pudo insertar la póliza"
+ End If
+ End If
+
+
+ Case 8 'Ret IVA x Trasladar
+ If EsAnticipoEspecial Then Exit Select
+ If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
+ ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago
+ importeMX = ImporteMovimiento
+ ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
+ ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago
+ importeMX = ImporteMovimiento * tipoCambioVenta
+ ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
+ ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago)
+ importeMX = ImporteMovimiento * tipoCambioVenta
+ ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
+ ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago
+ importeMX = ImporteMovimiento * tipoCambioVenta
+ End If
+ ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)
+ importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero)
+ TipoCambioGeneral = tipoCambioVenta
+ CveSubProyectoContabilizar = CveSubProyecto
+
+ If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(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
+ Case 9 'Ret ISR x Trasladar
+ If EsAnticipoEspecial Then Exit Select
+ If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
+ ImporteMovimiento = gvr.DataKey("RetISR").ToDecimal * PorcentajePago
+ importeMX = ImporteMovimiento
+ ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
+ ImporteMovimiento = gvr.DataKey("RetISR").ToDecimal * PorcentajePago
+ importeMX = ImporteMovimiento * tipoCambioVenta
+ ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
+ ImporteMovimiento = (gvr.DataKey("RetISR").ToDecimal * PorcentajePago)
+ importeMX = ImporteMovimiento * tipoCambioVenta
+ ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
+ ImporteMovimiento = gvr.DataKey("RetISR").ToDecimal * PorcentajePago
+ importeMX = ImporteMovimiento * tipoCambioVenta
+ End If
+ ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)
+ importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero)
+ TipoCambioGeneral = tipoCambioVenta
+ CveSubProyectoContabilizar = CveSubProyecto
+
+ If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(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
+ Case 13 'Iva por Trasladar
+ If EsAnticipoEspecial Then Exit Select
+ If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
+ ImporteMovimiento = gvr.DataKey("IVA").ToDecimal * PorcentajePago
+ importeMX = ImporteMovimiento
+ ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
+ ImporteMovimiento = gvr.DataKey("IVA").ToDecimal * PorcentajePago
+ importeMX = ImporteMovimiento * tipoCambioVenta
+ ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
+ ImporteMovimiento = (gvr.DataKey("IVA").ToDecimal * PorcentajePago)
+ importeMX = ImporteMovimiento * tipoCambioVenta
+ ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
+ ImporteMovimiento = gvr.DataKey("IVA").ToDecimal * PorcentajePago
+ importeMX = ImporteMovimiento * tipoCambioVenta
+ End If
+ ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)
+ importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero)
+ TipoCambioGeneral = tipoCambioVenta
+ CveSubProyectoContabilizar = CveSubProyecto
+
+ PorcentajeImpuesto = gvr.DataKey("PorcentajeIVA").ToDecimal
+ Dim IdCtaIVAXTrasladar As Integer = 0
+ Dim CveCuentaIVAxTrasladar As Integer = 0
+
+ If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then
+ IdCtaIVAXTrasladar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAXTrasladar").ToString.ToEntero
+ CveCuentaIVAxTrasladar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("CveCuentaIVAXTrasladar").ToString.ToEntero
+ End If
+
+ IdCtaContable = If(IdCtaIVAXTrasladar > 0, IdCtaIVAXTrasladar, UsuarioActual.Empresa.IdCuentaIVAxTrasladar)
+ CveCuenta = If(CveCuentaIVAxTrasladar > 0, CveCuentaIVAxTrasladar, UsuarioActual.Empresa.CveCuentaIVAxTrasladar)
+ If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(2)}"
+ Case 62 'Ret IVA Trasladado
+ If EsAnticipoEspecial Then Exit Select
+ If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
+ ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago
+ importeMX = ImporteMovimiento
+ ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
+ ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago)
+ importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
+ ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
+ ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago)
+ importeMX = ImporteMovimiento * tipoCambioVenta
+ ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
+ ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago)
+ importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
+ End If
+ ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)
+ importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero)
+
+ TipoCambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
+ CveSubProyectoContabilizar = CveSubProyecto
+
+ If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(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
+ Case 63 'Ret ISR Trasladado
+ If EsAnticipoEspecial Then Exit Select
+ If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
+ ImporteMovimiento = gvr.DataKey("RetISR").ToDecimal * PorcentajePago
+ importeMX = ImporteMovimiento
+ ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
+ ImporteMovimiento = (gvr.DataKey("RetISR").ToDecimal * PorcentajePago)
+ importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
+ ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
+ ImporteMovimiento = (gvr.DataKey("RetISR").ToDecimal * PorcentajePago)
+ importeMX = ImporteMovimiento * tipoCambioVenta
+ ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
+ ImporteMovimiento = (gvr.DataKey("RetISR").ToDecimal * PorcentajePago)
+ importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
+ End If
+ ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)
+ importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero)
+ TipoCambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
+ CveSubProyectoContabilizar = CveSubProyecto
+
+ If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(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
+ Case 61 'Iva Trasladado
+ If EsAnticipoEspecial Then Exit Select
+ If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
+ ImporteMovimiento = gvr.DataKey("IVA").ToDecimal * PorcentajePago
+ importeMX = ImporteMovimiento
+ ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
+ ImporteMovimiento = (gvr.DataKey("IVA").ToDecimal * PorcentajePago)
+ importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
+ ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
+ ImporteMovimiento = (gvr.DataKey("IVA").ToDecimal * PorcentajePago)
+ importeMX = ImporteMovimiento
+ ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
+ ImporteMovimiento = gvr.DataKey("IVA").ToDecimal * PorcentajePago
+ importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
+ End If
+ ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)
+ importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero)
+ TipoCambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
+ CveSubProyectoContabilizar = CveSubProyecto
+
+ PorcentajeImpuesto = gvr.DataKey("PorcentajeIVA").ToDecimal
+ Dim IdCtaIVATrasladado As Integer = 0
+ Dim CveCuentaIVATrasladado As Integer = 0
+
+ If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then
+ IdCtaIVATrasladado = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVATrasladado").ToString.ToEntero
+ CveCuentaIVATrasladado = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("CveCuentaIVATrasladado").ToString.ToEntero
+ End If
+
+ IdCtaContable = If(IdCtaIVATrasladado > 0, IdCtaIVATrasladado, UsuarioActual.Empresa.IdCuentaIVATrasladado)
+ CveCuenta = If(CveCuentaIVATrasladado > 0, CveCuentaIVATrasladado, UsuarioActual.Empresa.CveCuentaIVATrasladado)
+ If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}"
+ Case 38 'IEPS por trasladar
+ If EsAnticipoEspecial Then Exit Select
+ If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
+ ImporteMovimiento = gvr.DataKey("IEPS").ToDecimal * PorcentajePago
+ importeMX = ImporteMovimiento
+ ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
+ ImporteMovimiento = (gvr.DataKey("IEPS").ToDecimal * PorcentajePago)
+ importeMX = ImporteMovimiento * tipoCambioVenta
+ ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
+ ImporteMovimiento = (gvr.DataKey("IEPS").ToDecimal * PorcentajePago)
+ importeMX = ImporteMovimiento * tipoCambioVenta
+ ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
+ ImporteMovimiento = (gvr.DataKey("IEPS").ToDecimal * PorcentajePago)
+ importeMX = ImporteMovimiento * tipoCambioVenta
+ End If
+ ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)
+ importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero)
+ TipoCambioGeneral = tipoCambioVenta
+ CveSubProyectoContabilizar = CveSubProyecto
+
+ IdCtaContable = UsuarioActual.Empresa.IdCuentaIEPSxTrasladar
+ CveCuenta = UsuarioActual.Empresa.CveCuentaIEPSxTrasladar
+ Case 39 'IEPS Trasladado
+ If EsAnticipoEspecial Then Exit Select
+ If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
+ ImporteMovimiento = gvr.DataKey("IEPS").ToDecimal * PorcentajePago
+ importeMX = ImporteMovimiento
+ ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
+ ImporteMovimiento = (gvr.DataKey("IEPS").ToDecimal * PorcentajePago)
+ importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
+ ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
+ ImporteMovimiento = (gvr.DataKey("IEPS").ToDecimal * PorcentajePago)
+ importeMX = ImporteMovimiento
+ ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ tipoCambioVenta = gvr.DataKey("TipoCambio").ToDecimal
+ ImporteMovimiento = (gvr.DataKey("IEPS").ToDecimal * PorcentajePago)
+ importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
+ End If
+ ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)
+ importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero)
+ TipoCambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
+ CveSubProyectoContabilizar = CveSubProyecto
+
+ IdCtaContable = UsuarioActual.Empresa.IdCuentaIEPSTrasladado
+ CveCuenta = UsuarioActual.Empresa.CveCuentaIEPSTrasladado
+ Case 64 'Ganancia
+ If CveMoneda <> 1 OrElse gvr.DataKey("CveMoneda").ToEntero <> 1 Then
+ IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria
+ CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria
+ tipoCambioVentaDiferenciaCambiaria = If(gvr.DataKey("Fecha").ToDate < FechaUltimaFluctuacion, TipoCambioFluctuacion, gvr.DataKey("TipoCambio").ToDecimal)
+ Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
+
+
+ Dim Diferencia As Decimal = ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * tipoCambioVentaValuacion) - ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * tipoCambioPago) 'Añadimos la diferencia de perdida en la venta
+ Diferencia -= ((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * tipoCambioVenta) - ((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el IVA
+ Diferencia += ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * tipoCambioVenta) - ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetIVA
+ Diferencia += ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * tipoCambioVenta) - ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetISR
+ Diferencia -= ((gvr.DataKey("IEPS").ToDecimal * PorcentajePago) * tipoCambioVenta) - ((gvr.DataKey("IEPS").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el IEPS
+ Diferencia = Math.Round(Diferencia, 2)
+
+ '' se considera, las diferencias, y no el tipo de cambio, por el caso de las fluctuaciones
+
+ '' si tiene funcionalidad de flucturación con ivas, tomar tipocambioventa
+ If Diferencia < 0 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ ImporteMovimiento = Math.Abs(Diferencia)
+ importeMX = ImporteMovimiento
+ End If
+
+ '' si tiene funcionalidad de flucturación con ivas, tomar tipocambioventa
+ 'If tipoCambioPago > tipoCambioVentaDiferenciaCambiaria AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ ' ImporteMovimiento = (gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioPago) - (gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioVentaDiferenciaCambiaria) 'Añadimos la diferencia de ganancia en la venta
+ ' ImporteMovimiento -= ((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * TCImpuestos) - ((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * tipoCambioVentaDiferenciaCambiaria) 'Añadimos la diferencia de ganancia en el IVA
+ ' ImporteMovimiento += ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * TCImpuestos) - ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * tipoCambioVentaDiferenciaCambiaria) 'Añadimos la diferencia de ganancia en el RetIVA
+ ' ImporteMovimiento += ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * TCImpuestos) - ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * tipoCambioVentaDiferenciaCambiaria) 'Añadimos la diferencia de ganancia en el RetISR
+ ' ImporteMovimiento -= ((gvr.DataKey("IEPS").ToDecimal * PorcentajePago) * TCImpuestos) - ((gvr.DataKey("IEPS").ToDecimal * PorcentajePago) * tipoCambioVentaDiferenciaCambiaria) 'Añadimos la diferencia de ganancia en el IEPS
+ ' ImporteMovimiento = Math.Abs(Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero))
+ ' importeMX = ImporteMovimiento
+ 'End If
+ CveSubProyectoContabilizar = CveSubProyecto
+ Else
+ ImporteMovimiento = 0
+ End If
+
+ Case 65 'Perdida
+ If CveMoneda <> 1 OrElse gvr.DataKey("CveMoneda").ToEntero <> 1 Then
+ IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria
+ CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria
+ tipoCambioVentaDiferenciaCambiaria = If(gvr.DataKey("Fecha").ToDate < FechaUltimaFluctuacion, TipoCambioFluctuacion, gvr.DataKey("TipoCambio").ToDecimal)
+ Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta)
+
+ Dim Diferencia As Decimal = ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * tipoCambioVentaValuacion) - ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * tipoCambioPago) 'Añadimos la diferencia de perdida en la venta
+ Diferencia -= ((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * tipoCambioVenta) - ((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el IVA
+ Diferencia += ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * tipoCambioVenta) - ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetIVA
+ Diferencia += ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * tipoCambioVenta) - ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetISR
+ Diferencia -= ((gvr.DataKey("IEPS").ToDecimal * PorcentajePago) * tipoCambioVenta) - ((gvr.DataKey("IEPS").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el IEPS
+ Diferencia = Math.Round(Diferencia, 2)
+ 'si la diferencia es negativa es pérdida, si es positiva es ganancia
+ If Diferencia > 0 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ ImporteMovimiento = Math.Abs(Diferencia)
+ importeMX = ImporteMovimiento
+ End If
+
+ '' si tiene funcionalidad de flucturación con ivas, tomar tipocambioventa
+ 'If tipoCambioPago < tipoCambioVentaDiferenciaCambiaria AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ ' ImporteMovimiento = (gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioVentaDiferenciaCambiaria) - (gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioPago) 'Añadimos la diferencia de perdida en la venta
+ ' ImporteMovimiento -= ((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * tipoCambioVentaDiferenciaCambiaria) - ((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el IVA
+ ' ImporteMovimiento += ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * tipoCambioVentaDiferenciaCambiaria) - ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * TCImpuestos)
+ ' ImporteMovimiento += ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * tipoCambioVentaDiferenciaCambiaria) - ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetISR
+ ' ImporteMovimiento -= ((gvr.DataKey("IEPS").ToDecimal * PorcentajePago) * tipoCambioVentaDiferenciaCambiaria) - ((gvr.DataKey("IEPS").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el IEPS
+ ' ImporteMovimiento = Math.Abs(Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero))
+ ' importeMX = ImporteMovimiento
+ ' 'ElseIf tipoCambioPago > tipoCambioVenta AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
+ ' ' ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal - (Math.Abs(Math.Round(gvr.FCTextBox("TxtAbonar").Text.ToDecimal / tipoCambioPago, 2)) * tipoCambioPago)
+ ' ' 'ImporteMovimiento -= Math.Abs(Math.Round(((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * TCImpuestos) - ((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * tipoCambioVenta))) 'Añadimos la diferencia de ganancia en el IVA
+ ' ' 'ImporteMovimiento += Math.Abs(Math.Round(((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * TCImpuestos) - ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * tipoCambioVenta))) 'Añadimos la diferencia de ganancia en el RetIVA
+ ' ' 'ImporteMovimiento += Math.Abs(Math.Round(((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * TCImpuestos) - ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * tipoCambioVenta))) 'Añadimos la diferencia de ganancia en el RetISR
+ ' ' 'ImporteMovimiento -= Math.Abs(Math.Round(((gvr.DataKey("IEPS").ToDecimal * PorcentajePago) * TCImpuestos) - ((gvr.DataKey("IEPS").ToDecimal * PorcentajePago) * tipoCambioVenta))) 'Añadimos la diferencia de ganancia en el IEPS
+ ' ' ImporteMovimiento = ImporteMovimiento
+ ' ' importeMX = ImporteMovimiento
+ 'End If
+ CveSubProyectoContabilizar = CveSubProyecto
+ Else
+ ImporteMovimiento = 0
+ End If
+
+ Case 78 'Otros Ingresos
+ If ChkAjusteOI.Checked Then
+ ImporteMovimiento = gvr.FCTextBox("TxtComision").Text.ToDecimal
+ importeMX = Math.Round(ImporteMovimiento * tipoCambioPago, 2)
+
+ If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
+ ImporteMovimiento = gvr.FCTextBox("TxtComision").Text.ToDecimal
+ importeMX = ImporteMovimiento
+ ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ ImporteMovimiento = gvr.FCTextBox("TxtComision").Text.ToDecimal
+ importeMX = ImporteMovimiento * tipoCambioPago
+ ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
+ ImporteMovimiento = gvr.FCTextBox("TxtComision").Text.ToDecimal
+ importeMX = ImporteMovimiento
+ ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
+ ImporteMovimiento = gvr.FCTextBox("TxtComision").Text.ToDecimal
+ importeMX = ImporteMovimiento * tipoCambioPago
+ End If
+
+ If gvr.FCTextBox("TxtComision").Text.ToDecimal < 0 Then
+ TipoMovimiento = False
+ ImporteMovimiento = ImporteMovimiento * -1
+ importeMX = importeMX * -1
+ Else
+ TipoMovimiento = True
+ End If
+
+ ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)
+ importeMX = Math.Round(importeMX, 2)
+ TipoCambioGeneral = tipoCambioPago
+ CveSubProyectoContabilizar = CveSubProyecto
+
+ IdCtaContable = UsuarioActual.Empresa.IdCuentaOtrosIngresos
+
+ If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(2)}"
+
+ End If
'Case 92
' If RblTipoPago.SelectedValue = "3" Then ' cuando es ingreso por comprobar
' ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal
@@ -1413,343 +1367,314 @@ Partial Class Ventas_ClientesAbonar
' End If
' ImporteMovimiento = 0
- Case 134 'Pago Intermediario
- If RblTipoPago.SelectedValue = "2" Then
- ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal - gvr.FCTextBox("TxtComision").Text.ToDecimal
- importeMX = Math.Round(ImporteMovimiento * tipoCambioPago, 2)
- CveSubProyectoContabilizar = CveSubProyecto
-
- If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(2)}"
-
- If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, ConceptoMovimiento, ConceptoContable, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, -1, gvr.FCHyperLink("HplF2").Text.ToEntero, -1, CveSubProyectoContabilizar, CveProveedor:=DdlProveedorPagoInt.SelectedValue.ToEntero, ImporteMX:=importeMX, CveCuenta:=CveCuenta) Then
- MsgError = "No se pudo insertar la póliza"
- End If
- End If
- ImporteMovimiento = 0
- Case 30
- ImporteMovimiento = 0
- Case Else
- ImporteMovimiento = 0
- End Select
-
- If ImporteMovimiento <> 0 Then
- 'Conta ContPAQ
- If (IdCtaContable < 1 Or IdCuentaBancaria < 1) Then
- CuentasContablesInvalidas.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
- idCuentaContabilizacion = 0
- End If
-
- 'Conta SIG
- If (CveCuenta < 1 Or CveCuentaBancaria < 1) Then
- CuentasContablesInvalidasSIG.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
- CveCuentaContabilizacion = 0
- End If
-
- If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, Referencia, ConceptoContable, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE, gvr.FCHyperLink("HplF2").Text.ToEntero, -1, CveSubProyectoContabilizar, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=importeMX, CveCuenta:=CveCuenta, TipoCambio:=TipoCambioGeneral, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=PorcentajeImpuesto) Then
- MsgError = "No se pudo insertar la póliza"
- End If
-
- End If
- Next
- End If
- If gvr.FCCheckBox("ChkGenerarNC").Checked Then
- ListaFacturasGenerarNC.Add(New Modelos.Factura(UsuarioActual, gvr.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa) With {.DescuentoProntoPago = gvr.DataKey("DescuentoProntoPago").ToDecimal()})
+ Case 134 'Pago Intermediario
+ If RblTipoPago.SelectedValue = "2" Then
+ ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal - gvr.FCTextBox("TxtComision").Text.ToDecimal
+ importeMX = Math.Round(ImporteMovimiento * tipoCambioPago, 2)
+ CveSubProyectoContabilizar = CveSubProyecto
+
+ If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(2)}"
+
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, ConceptoMovimiento, ConceptoContable, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, -1, gvr.FCHyperLink("HplF2").Text.ToEntero, -1, CveSubProyectoContabilizar, CveProveedor:=DdlProveedorPagoInt.SelectedValue.ToEntero, ImporteMX:=importeMX, CveCuenta:=CveCuenta) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
+ End If
+ ImporteMovimiento = 0
+ Case 30
+ ImporteMovimiento = 0
+ Case Else
+ ImporteMovimiento = 0
+ End Select
+
+ If ImporteMovimiento <> 0 Then
+ 'Conta ContPAQ
+ If (IdCtaContable < 1 Or IdCuentaBancaria < 1) Then
+ CuentasContablesInvalidas.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
+ idCuentaContabilizacion = 0
+ End If
+
+ 'Conta SIG
+ If (CveCuenta < 1 Or CveCuentaBancaria < 1) Then
+ CuentasContablesInvalidasSIG.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
+ CveCuentaContabilizacion = 0
+ End If
+
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, Referencia, ConceptoContable, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE, gvr.FCHyperLink("HplF2").Text.ToEntero, -1, CveSubProyectoContabilizar, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=importeMX, CveCuenta:=CveCuenta, TipoCambio:=TipoCambioGeneral, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=PorcentajeImpuesto) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
+
+ End If
+ Next
+ End If
+ If gvr.FCCheckBox("ChkGenerarNC").Checked Then
+ ListaFacturasGenerarNC.Add(New Modelos.Factura(UsuarioActual, gvr.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa) With {.DescuentoProntoPago = gvr.DataKey("DescuentoProntoPago").ToDecimal()})
+ End If
+
+ End If
+ Next
+
+ If RblTipoPago.SelectedValue = "1" Then
+ If tipoCambioPago > 1 AndAlso CveMoneda = 2 Then
+ If IdCuentaBancariaComplementaria > 0 OrElse CveCuentaBancariaComplementaria > 0 Then
+ If CveMoneda = 2 AndAlso CveMonedaFiltro = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
+ tipoCambioPago = TxtTCDolares.Text.ToDecimal
+ ElseIf CveMoneda = 2 AndAlso CveMonedaFiltro = 2 Then
+ tipoCambioPago = TxtTCDolaresDolares.Text.ToDecimal
End If
- End If
- Next
-
- If RblTipoPago.SelectedValue = "1" Then
- If tipoCambioPago > 1 AndAlso CveMoneda = 2 Then
- If IdCuentaBancariaComplementaria > 0 OrElse CveCuentaBancariaComplementaria > 0 Then
- If CveMoneda = 2 AndAlso CveMonedaFiltro = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
- tipoCambioPago = TxtTCDolares.Text.ToDecimal
- ElseIf CveMoneda = 2 AndAlso CveMonedaFiltro = 2 Then
- tipoCambioPago = TxtTCDolaresDolares.Text.ToDecimal
- End If
-
- If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtImporte.Text.ToDecimal, ObjIE.Folio, 30, TxtObservaciones.Text + If(CveMoneda = 2, $" TC:{tipoCambioPago}", ""), TxtFechaDocumento.Text, IdCuentaBancaria, -1, CveIE, -1, -1, -1, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=TxtImporte.Text.Trim.ToDecimal, CveCuenta:=CveCuentaBancaria, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago) Then
- MsgError = "No se pudo insertar la póliza"
- End If
-
- If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, If(CveMoneda = 1 AndAlso TxtTC.Visible, TxtImporte.Text.ToDecimal / TxtTC.Text.ToDecimal, TxtImporte.Text.ToDecimal), TxtObservaciones.Text, 204, TxtObservaciones.Text + If(CveMoneda = 2, $" TC:{tipoCambioPago}", ""), TxtFechaDocumento.Text, IdCuentaBancariaComplementaria, -1, CveIE, -1, -1, -1, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=If(CveMoneda = 2, (TxtImporte.Text.Trim.ToDecimal * tipoCambioPago) - TxtImporte.Text.Trim.ToDecimal, TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(CveMoneda = 2, TxtImporte.Text.Trim.ToDecimal, 0), CveCuenta:=CveCuentaBancariaComplementaria, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago) Then
- MsgError = "No se pudo insertar la póliza"
- End If
- Else
- If CveMoneda = 2 AndAlso CveMonedaFiltro = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
- tipoCambioPago = TxtTCDolares.Text.ToDecimal
- ElseIf CveMoneda = 2 AndAlso CveMonedaFiltro = 2 Then
- tipoCambioPago = TxtTCDolaresDolares.Text.ToDecimal
- End If
-
- If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtImporte.Text.ToDecimal, ObjIE.Folio, 30, TxtObservaciones.Text + If(CveMoneda = 2, $" TC:{tipoCambioPago}", ""), TxtFechaDocumento.Text, IdCuentaBancaria, -1, CveIE, -1, -1, -1, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=If(CveMoneda = 2, TxtImporte.Text.Trim.ToDecimal * tipoCambioPago, TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(CveMoneda = 2, TxtImporte.Text.ToDecimal, 0), CveCuenta:=CveCuentaBancaria, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago) Then
- MsgError = "No se pudo insertar la póliza"
- End If
- End If
- Else
- If CveMoneda = 2 AndAlso CveMonedaFiltro = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
- tipoCambioPago = TxtTCDolares.Text.ToDecimal
- ElseIf CveMoneda = 2 AndAlso CveMonedaFiltro = 2 Then
- tipoCambioPago = TxtTCDolaresDolares.Text.ToDecimal
- End If
-
- If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtImporte.Text.ToDecimal, ObjIE.Folio, 30, TxtObservaciones.Text + If(CveMoneda = 2, $" TC:{tipoCambioPago}", ""), TxtFechaDocumento.Text, IdCuentaBancaria, -1, CveIE, -1, -1, -1, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=If(CveMoneda = 2, TxtImporte.Text.Trim.ToDecimal * tipoCambioPago, TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(CveMoneda = 2, TxtImporte.Text.ToDecimal, 0), CveCuenta:=CveCuentaBancaria, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago) Then
- MsgError = "No se pudo insertar la póliza"
- End If
- End If
- End If
-
- If RblTipoPago.SelectedValue = "3" Then
- If CveMonedaPago = 2 Then
- 'rmf faltan las cuentas
- If IdCtaContMonedaComplementariaAnticipo > 0 Then
- If CveMonedaPago = 2 AndAlso CveMonedaFiltro = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
- tipoCambioPago = TxtTCDolares.Text.ToDecimal
- ElseIf CveMonedaPago = 2 AndAlso CveMonedaFiltro = 2 Then
- tipoCambioPago = TxtTCDolaresDolares.Text.ToDecimal
- End If
-
- If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtImporte.Text.ToDecimal, TxtObservaciones.Text, 92, TxtObservaciones.Text + If(TxtTC.Visible, $" TC:{TxtTC.Text}", If(CveMoneda = 2, $" TC:{tipoCambioVenta}", "")), TxtFechaDocumento.Text, IdCtaContMonedaExtranjeraAnticipo, -1, CveIE, -1, -1, -1, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=TxtImporte.Text.Trim.ToDecimal, CveCuenta:=CveCuentaBancaria, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago) Then
- MsgError = "No se pudo insertar la póliza"
- End If
-
- If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, If(CveMoneda = 1 AndAlso TxtTC.Visible, TxtImporte.Text.ToDecimal / TxtTC.Text.ToDecimal, TxtImporte.Text.ToDecimal), TxtObservaciones.Text, 227, TxtObservaciones.Text + If(TxtTC.Visible, $" TC:{TxtTC.Text}", If(CveMoneda = 2, $" TC:{tipoCambioVenta}", "")), TxtFechaDocumento.Text, IdCtaContMonedaComplementariaAnticipo, -1, CveIE, -1, -1, -1, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=If(CveMoneda = 2, (TxtImporte.Text.Trim.ToDecimal * tipoCambioPago) - TxtImporte.Text.Trim.ToDecimal, TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(CveMoneda = 2, TxtImporte.Text.Trim.ToDecimal, 0), CveCuenta:=CveCuentaBancariaComplementaria, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago) Then
- MsgError = "No se pudo insertar la póliza"
- End If
- Else
- If CveMoneda = 2 AndAlso CveMonedaFiltro = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
- tipoCambioPago = TxtTCDolares.Text.ToDecimal
- ElseIf CveMoneda = 2 AndAlso CveMonedaFiltro = 2 Then
- tipoCambioPago = TxtTCDolaresDolares.Text.ToDecimal
- End If
-
- If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtImporte.Text.ToDecimal, TxtObservaciones.Text, 92, TxtObservaciones.Text + If(CveMoneda = 2, $" TC:{tipoCambioPago}", ""), TxtFechaDocumento.Text, IdCtaContMonedaExtranjeraAnticipo, -1, CveIE, -1, -1, -1, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=If(CveMoneda = 2, TxtImporte.Text.Trim.ToDecimal * tipoCambioPago, TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(CveMoneda = 2, TxtImporte.Text.ToDecimal, 0), CveCuenta:=CveCuentaBancaria, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago) Then
- MsgError = "No se pudo insertar la póliza"
- End If
- End If
- Else
- If CveMoneda = 2 AndAlso CveMonedaFiltro = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
- tipoCambioPago = TxtTCDolares.Text.ToDecimal
- ElseIf CveMoneda = 2 AndAlso CveMonedaFiltro = 2 Then
- tipoCambioPago = TxtTCDolaresDolares.Text.ToDecimal
- End If
-
- If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtImporte.Text.ToDecimal, TxtObservaciones.Text, 92, TxtObservaciones.Text + If(CveMoneda = 2, $" TC:{tipoCambioPago}", ""), TxtFechaDocumento.Text, IdCtaAnticipo, -1, CveIE, -1, -1, -1, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=If(CveMoneda = 2, TxtImporte.Text.Trim.ToDecimal * tipoCambioPago, TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(CveMoneda = 2, TxtImporte.Text.ToDecimal, 0), CveCuenta:=CveCuentaBancaria, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago) Then
- MsgError = "No se pudo insertar la póliza"
- End If
- End If
- End If
-
- If ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, 3) Then
- If ObjMov.ValorPolizaDescuadre > 0 Then
- MsgError = ObjMov.MensajePolizaDescuadre + " La diferencia es de: " + ObjMov.ValorDiferencia
- End If
- End If
-
- If EmpresaPrueba Then 'Empresa Prueba
- 'El movimiento 2 es el de Pago
- 'Conta SIG
- If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" AndAlso UsuarioActual.Empresa.UsaContabilidadSIG Then
- If CveCuentaContabilizacion > 0 Then
- If ObjMov.ContabilizarPrePolizaSIG(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then
- IDPoliza = ObjMov.ContaIdPoliza
- FolioPoliza = ObjMov.ContaFolio
- 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}", 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
- FolioPoliza = ObjMov.ContaFolio
- 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 'Empresa Prueba
- Else
- MsgError = "No se pudo insertar la póliza"
- End If
- Else
- MsgError = "No se insertó el encabezado"
- End If
-
- If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
- If MsgError = "" Then
- If ListaFacturasGenerarNC.Count > 0 Then
- Dim Resp = GenerarNC(ObjIE.IniciaTransacSQL(), ObjConta, ListaFacturasGenerarNC)
- If Resp.CveVenta > 0 Then
- NCGeneradas.Add(Resp)
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtImporte.Text.ToDecimal, ObjIE.Folio, 30, TxtObservaciones.Text + If(CveMoneda = 2, $" TC:{tipoCambioPago}", ""), TxtFechaDocumento.Text, IdCuentaBancaria, -1, CveIE, -1, -1, -1, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=TxtImporte.Text.Trim.ToDecimal, CveCuenta:=CveCuentaBancaria, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
+
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, If(CveMoneda = 1 AndAlso TxtTC.Visible, TxtImporte.Text.ToDecimal / TxtTC.Text.ToDecimal, TxtImporte.Text.ToDecimal), TxtObservaciones.Text, 204, TxtObservaciones.Text + If(CveMoneda = 2, $" TC:{tipoCambioPago}", ""), TxtFechaDocumento.Text, IdCuentaBancariaComplementaria, -1, CveIE, -1, -1, -1, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=If(CveMoneda = 2, (TxtImporte.Text.Trim.ToDecimal * tipoCambioPago) - TxtImporte.Text.Trim.ToDecimal, TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(CveMoneda = 2, TxtImporte.Text.Trim.ToDecimal, 0), CveCuenta:=CveCuentaBancariaComplementaria, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
Else
- MsgError = "No se pudo generar la nota de credito"
+ If CveMoneda = 2 AndAlso CveMonedaFiltro = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
+ tipoCambioPago = TxtTCDolares.Text.ToDecimal
+ ElseIf CveMoneda = 2 AndAlso CveMonedaFiltro = 2 Then
+ tipoCambioPago = TxtTCDolaresDolares.Text.ToDecimal
+ End If
+
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtImporte.Text.ToDecimal, ObjIE.Folio, 30, TxtObservaciones.Text + If(CveMoneda = 2, $" TC:{tipoCambioPago}", ""), TxtFechaDocumento.Text, IdCuentaBancaria, -1, CveIE, -1, -1, -1, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=If(CveMoneda = 2, TxtImporte.Text.Trim.ToDecimal * tipoCambioPago, TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(CveMoneda = 2, TxtImporte.Text.ToDecimal, 0), CveCuenta:=CveCuentaBancaria, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
+ End If
+ Else
+ If CveMoneda = 2 AndAlso CveMonedaFiltro = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
+ tipoCambioPago = TxtTCDolares.Text.ToDecimal
+ ElseIf CveMoneda = 2 AndAlso CveMonedaFiltro = 2 Then
+ tipoCambioPago = TxtTCDolaresDolares.Text.ToDecimal
+ End If
+
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtImporte.Text.ToDecimal, ObjIE.Folio, 30, TxtObservaciones.Text + If(CveMoneda = 2, $" TC:{tipoCambioPago}", ""), TxtFechaDocumento.Text, IdCuentaBancaria, -1, CveIE, -1, -1, -1, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=If(CveMoneda = 2, TxtImporte.Text.Trim.ToDecimal * tipoCambioPago, TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(CveMoneda = 2, TxtImporte.Text.ToDecimal, 0), CveCuenta:=CveCuentaBancaria, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago) Then
+ MsgError = "No se pudo insertar la póliza"
End If
End If
End If
- End If
-
- If MsgError = "" Then
- 'se agregan las pólizas de Armonización Contable
- If UsuarioActual.Empresa.UsaAC Then
- Dim Fecha As Date = TxtFechaDocumento.Text.Trim.ToDate
- Dim ErrorAC As Boolean = False
- ObjConta = New ClsContPAQi(UsuarioActual.Empresa)
- ObjConta.IniciaTransacSQL()
- Dim Facturas As New StringBuilder
-
- IDPoliza = ObjConta.AddPoliza(1, String.Format("Recaudado: {0}, {1}", TxtAboneA.Text, TxtObservaciones.Text), TxtImporte.Text.ToDecimal, TxtImporte.Text.ToDecimal, UsuarioActual.CveUsuario, Fecha)
- FolioPoliza = ObjConta.Folio.ToString
-
-
- Dim ConceptoRenglon As String
- If IDPoliza > 0 Then
- Dim PorcentajePago As Double = 1
- Dim Total As Double
- Dim ObjVentas As New ClsVentas
- Dim ImporteOP = 0.0
- Dim IdCuentaOP = -1
-
- For Each gvr As GridViewRow In GvCxC.Rows
- If gvr.FCCheckBox("Chk").Checked Then
- If gvr.DataKey("Original").ToDecimal > 0 Then PorcentajePago = gvr.FCTextBox("TxtAbonar").Text.ToDecimal / gvr.DataKey("Original").ToDecimal Else PorcentajePago = 1
-
- If ObjVentas.GetPresupuestosVentas(gvr.DataKey("CveVenta").ToEntero) Then
- For Each drt As DataRow In ObjVentas.DtResultados.Rows
- Total = drt("TotalPresupuesto").ToString.ToDecimal * PorcentajePago
- ConceptoRenglon = String.Format("{0} {1}", gvr.DataKey("SerieFolio"), drt("FuenteRecaudacionRubroIngreso").ToString)
- If Total > 0 Then
-
- '' NO DEBERIA
- 'If gvr.DataKey("TipoDocto").Contiene("Com") Then
- ' If Not ObjConta.AddMovimiento(IDPoliza, drt("IdCuentaPorEjecutar").ToString.ToEntero, False, Total, "", ConceptoRenglon, 0, Fecha, "") Then ErrorAC = True : Exit For
- ' If Not ObjConta.AddMovimiento(IDPoliza, drt("IdCuentaDevengado").ToString.ToEntero, True, Total, "", ConceptoRenglon, 0, Fecha, "") Then ErrorAC = True : Exit For
- ' If Not ObjConta.AddMovimiento(IDPoliza, drt("IdCuentaMatriz").ToString.ToEntero, True, Total, "", ConceptoRenglon, 0, Fecha, "") Then ErrorAC = True : Exit For
- 'End If
- '' NO DEBERIA
-
-
-
-
-
- If Not ObjConta.AddMovimiento(IDPoliza, drt("IdCuentaDevengado").ToString.ToEntero, False, Total, "", ConceptoRenglon, 0, Fecha, "") Then ErrorAC = True : Exit For : Exit For
-
- If Not ObjConta.AddMovimiento(IDPoliza, drt("IdCuentaRecaudado").ToString.ToEntero, True, Total, "", ConceptoRenglon, 0, Fecha, "") Then ErrorAC = True : Exit For : Exit For
-
- End If
-
- Next
- If ErrorAC Then Exit For
-
- Facturas.AppendFormat(" {0}", gvr.DataKey("SerieFolio"))
- End If
-
- End If
- Next
- ObjVentas.Dispose()
-
- 'AFECTAR MATRIZ EGRESOS
- ConceptoRenglon = String.Format("Recaudado: {0} - F.{1}", TxtAboneA.Text, Facturas.ToString)
- If ObjConta.AddMovimiento(IDPoliza, IdCuentaBancaria, False, TxtImporte.Text.ToDecimal, "", ConceptoRenglon, 0, Fecha, "") Then
- If TxtImporte.Text.ToDecimal - ImporteOP > 0 Then
- If Not ObjConta.AddMovimiento(IDPoliza, ViewState("CtaCliente").ToString.ToEntero, True, TxtImporte.Text.ToDecimal - ImporteOP, "", ConceptoRenglon, 0, Fecha, "") Then ErrorAC = True
- End If
- Else
- ErrorAC = True
- End If
-
- Else
- ErrorAC = True
- End If
-
- If Not ErrorAC Then
- ObjConta.AjustaPoliza(IDPoliza)
- ObjIE.UpdateIEPrePoliza(Fecha, FolioPoliza.ToString, IDPoliza, CvePrePoliza, CveIE, 0)
- ObjIE.Commit()
- ObjConta.Commit()
- UPVentas.Update()
-
-
- Dim TextoComplementoPago = EmitirComplementoPago(CveIE, CveVentasPago, SeriesPago)
- Dim SbMensaje As New StringBuilder
- SbMensaje.Append(String.Format("Abono Registrado Correctamente.
{2}", IDPoliza, FolioPoliza, TextoComplementoPago))
- For Each NC In NCGeneradas
- For Each msg In NC.Mensajes
- SbMensaje.Append(msg)
- Next
- SbMensaje.Append("")
- Next
-
- Alert(SbMensaje.ToString())
- Else
- ObjIE.RollBack()
- If ObjConta IsNot Nothing Then ObjConta.RollBack()
- Alert("Error al Agregar la Póliza de Armonización Contable.", TipoMensaje.MsgError)
- End If
- ObjConta.Dispose()
- Else
- ObjIE.Commit()
- If ObjConta IsNot Nothing Then ObjConta.Commit()
- UPVentas.Update()
-
- Dim StrMsg As New StringBuilder
- StrMsg.Append("Abono Registrado Correctamente. ")
-
-
- StrMsg.AppendFormat("Folio {1}", CveIE, ObjIE.Folio)
-
-
- If IDPoliza > 0 Then StrMsg.AppendFormat(" Poliza: {1}", IDPoliza, FolioPoliza)
-
- Dim TextoComplementoPago = EmitirComplementoPago(CveIE, CveVentasPago, SeriesPago)
+ If RblTipoPago.SelectedValue = "3" Then
+ If CveMonedaPago = 2 Then
+ 'rmf faltan las cuentas
+ If IdCtaContMonedaComplementariaAnticipo > 0 Then
+ If CveMonedaPago = 2 AndAlso CveMonedaFiltro = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
+ tipoCambioPago = TxtTCDolares.Text.ToDecimal
+ ElseIf CveMonedaPago = 2 AndAlso CveMonedaFiltro = 2 Then
+ tipoCambioPago = TxtTCDolaresDolares.Text.ToDecimal
+ End If
- Dim SbMensaje As New StringBuilder
- SbMensaje.Append(String.Format("Abono Registrado Correctamente.
{2}", IDPoliza, FolioPoliza, TextoComplementoPago))
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtImporte.Text.ToDecimal, TxtObservaciones.Text, 92, TxtObservaciones.Text + If(TxtTC.Visible, $" TC:{TxtTC.Text}", If(CveMoneda = 2, $" TC:{tipoCambioVenta}", "")), TxtFechaDocumento.Text, IdCtaContMonedaExtranjeraAnticipo, -1, CveIE, -1, -1, -1, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=TxtImporte.Text.Trim.ToDecimal, CveCuenta:=CveCuentaBancaria, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
+
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, If(CveMoneda = 1 AndAlso TxtTC.Visible, TxtImporte.Text.ToDecimal / TxtTC.Text.ToDecimal, TxtImporte.Text.ToDecimal), TxtObservaciones.Text, 227, TxtObservaciones.Text + If(TxtTC.Visible, $" TC:{TxtTC.Text}", If(CveMoneda = 2, $" TC:{tipoCambioVenta}", "")), TxtFechaDocumento.Text, IdCtaContMonedaComplementariaAnticipo, -1, CveIE, -1, -1, -1, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=If(CveMoneda = 2, (TxtImporte.Text.Trim.ToDecimal * tipoCambioPago) - TxtImporte.Text.Trim.ToDecimal, TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(CveMoneda = 2, TxtImporte.Text.Trim.ToDecimal, 0), CveCuenta:=CveCuentaBancariaComplementaria, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
+ Else
+ If CveMoneda = 2 AndAlso CveMonedaFiltro = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
+ tipoCambioPago = TxtTCDolares.Text.ToDecimal
+ ElseIf CveMoneda = 2 AndAlso CveMonedaFiltro = 2 Then
+ tipoCambioPago = TxtTCDolaresDolares.Text.ToDecimal
+ End If
+
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtImporte.Text.ToDecimal, TxtObservaciones.Text, 92, TxtObservaciones.Text + If(CveMoneda = 2, $" TC:{tipoCambioPago}", ""), TxtFechaDocumento.Text, IdCtaContMonedaExtranjeraAnticipo, -1, CveIE, -1, -1, -1, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=If(CveMoneda = 2, TxtImporte.Text.Trim.ToDecimal * tipoCambioPago, TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(CveMoneda = 2, TxtImporte.Text.ToDecimal, 0), CveCuenta:=CveCuentaBancaria, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
+ End If
+ Else
+ If CveMoneda = 2 AndAlso CveMonedaFiltro = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
+ tipoCambioPago = TxtTCDolares.Text.ToDecimal
+ ElseIf CveMoneda = 2 AndAlso CveMonedaFiltro = 2 Then
+ tipoCambioPago = TxtTCDolaresDolares.Text.ToDecimal
+ End If
+
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtImporte.Text.ToDecimal, TxtObservaciones.Text, 92, TxtObservaciones.Text + If(CveMoneda = 2, $" TC:{tipoCambioPago}", ""), TxtFechaDocumento.Text, IdCtaAnticipo, -1, CveIE, -1, -1, -1, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=If(CveMoneda = 2, TxtImporte.Text.Trim.ToDecimal * tipoCambioPago, TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(CveMoneda = 2, TxtImporte.Text.ToDecimal, 0), CveCuenta:=CveCuentaBancaria, TipoCambio:=tipoCambioPago, TipoCambioPago:=tipoCambioPago) Then
+ MsgError = "No se pudo insertar la póliza"
+ End If
+ End If
+ End If
+
+ If ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, 3) Then
+ If ObjMov.ValorPolizaDescuadre > 0 Then
+ MsgError = ObjMov.MensajePolizaDescuadre + " La diferencia es de: " + ObjMov.ValorDiferencia
+ End If
+ End If
+
+ If EmpresaPrueba Then 'Empresa Prueba
+ 'El movimiento 2 es el de Pago
+ 'Conta SIG
+ If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" AndAlso UsuarioActual.Empresa.UsaContabilidadSIG Then
+ If CveCuentaContabilizacion > 0 Then
+ If ObjMov.ContabilizarPrePolizaSIG(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then
+ IDPoliza = ObjMov.ContaIdPoliza
+ FolioPoliza = ObjMov.ContaFolio
+ 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}", 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
+ FolioPoliza = ObjMov.ContaFolio
+ 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 'Empresa Prueba
+ Else
+ MsgError = "No se pudo insertar la póliza"
+ End If
+ Else
+ MsgError = "No se insertó el encabezado"
+ End If
+
+ If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
+ If MsgError = "" Then
+ If ListaFacturasGenerarNC.Count > 0 Then
+ Dim Resp = GenerarNC(ObjIE.IniciaTransacSQL(), ObjConta, ListaFacturasGenerarNC)
+ If Resp.CveVenta > 0 Then
+ NCGeneradas.Add(Resp)
+ Else
+ MsgError = "No se pudo generar la nota de credito"
+ End If
+ End If
+ End If
+ End If
+
+ Dim ErrorAC As Boolean = False
+
+ If MsgError = "" Then
+ If UsuarioActual.Empresa.UsaAC Then
+ Dim Fecha As Date = TxtFechaDocumento.Text.Trim.ToDate
+ ObjConta = New ClsContPAQi(UsuarioActual.Empresa)
+ ObjConta.IniciaTransacSQL()
+ Dim Facturas As New StringBuilder
+
+ IDPoliza = ObjConta.AddPoliza(1, String.Format("Recaudado: {0}, {1}", TxtAboneA.Text, TxtObservaciones.Text), TxtImporte.Text.ToDecimal, TxtImporte.Text.ToDecimal, UsuarioActual.CveUsuario, Fecha)
+ FolioPoliza = ObjConta.Folio.ToString
+
+
+ Dim ConceptoRenglon As String
+ If IDPoliza > 0 Then
+ Dim PorcentajePago As Double = 1
+ Dim Total As Double
+ Dim ObjVentas As New ClsVentas
+ Dim ImporteOP = 0.0
+ Dim IdCuentaOP = -1
+
+ For Each gvr As GridViewRow In GvCxC.Rows
+ If gvr.FCCheckBox("Chk").Checked Then
+ If gvr.DataKey("Original").ToDecimal > 0 Then PorcentajePago = gvr.FCTextBox("TxtAbonar").Text.ToDecimal / gvr.DataKey("Original").ToDecimal Else PorcentajePago = 1
+
+ If ObjVentas.GetPresupuestosVentas(gvr.DataKey("CveVenta").ToEntero) Then
+ For Each drt As DataRow In ObjVentas.DtResultados.Rows
+ Total = drt("TotalPresupuesto").ToString.ToDecimal * PorcentajePago
+ ConceptoRenglon = String.Format("{0} {1}", gvr.DataKey("SerieFolio"), drt("FuenteRecaudacionRubroIngreso").ToString)
+ If Total > 0 Then
+ If Not ObjConta.AddMovimiento(IDPoliza, drt("IdCuentaDevengado").ToString.ToEntero, False, Total, "", ConceptoRenglon, 0, Fecha, "") Then ErrorAC = True : Exit For : Exit For
+
+ If Not ObjConta.AddMovimiento(IDPoliza, drt("IdCuentaRecaudado").ToString.ToEntero, True, Total, "", ConceptoRenglon, 0, Fecha, "") Then ErrorAC = True : Exit For : Exit For
+ End If
+
+ Next
+ If ErrorAC Then Exit For
+
+ Facturas.AppendFormat(" {0}", gvr.DataKey("SerieFolio"))
+ End If
+
+ End If
+ Next
+ ObjVentas.Dispose()
+
+ 'AFECTAR MATRIZ EGRESOS
+ ConceptoRenglon = String.Format("Recaudado: {0} - F.{1}", TxtAboneA.Text, Facturas.ToString)
+ If ObjConta.AddMovimiento(IDPoliza, IdCuentaBancaria, False, TxtImporte.Text.ToDecimal, "", ConceptoRenglon, 0, Fecha, "") Then
+ If TxtImporte.Text.ToDecimal - ImporteOP > 0 Then
+ If Not ObjConta.AddMovimiento(IDPoliza, ViewState("CtaCliente").ToString.ToEntero, True, TxtImporte.Text.ToDecimal - ImporteOP, "", ConceptoRenglon, 0, Fecha, "") Then ErrorAC = True
+ End If
+ Else
+ ErrorAC = True
+ End If
+
+ Else
+ ErrorAC = True
+ End If
+
+ ErrorAC = Not ObjConta.AjustaPoliza(IDPoliza)
+
+ ErrorAC = Not ObjIE.UpdateIEPrePoliza(Fecha, FolioPoliza.ToString, IDPoliza, CvePrePoliza, CveIE, 0)
+ End If
+ End If
+
+ If ErrorAC Then
+ MsgError = "Error al Agregar la Póliza de Armonización Contable"
+ End If
+
+ 'BITACORA
+ If MsgError = "" Then
+ If CveIESustitucion > 0 And ComplementoSustitucionGenerado Then
+ If Not ObjEvento.AddEventoBitacora($"Complemento de pago Cancelado por sustitución con Folio {TxtFolio.Text}", "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveIE:=CveIESustitucion) Then
+ MsgError = "Ocurrió un error al agregar la bitacora"
+ End If
+ If Not ObjEvento.AddEventoBitacora($"Complemento de pago Generado por Sustitución de {FolioIECancelado}", "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveIE:=CveIE) Then
+ MsgError = "Ocurrió un error al agregar la bitacora"
+ End If
+ End If
+ End If
+
+ Catch ex As Exception
+ MsgError = "Ocurrió un error al guardar el movimiento"
+ OnError("Ocurrió un error al guardar el movimiento", ex)
+ End Try
+
+ If MsgError = "" Then
+ ObjIE.Commit()
+ If ObjConta IsNot Nothing Then ObjConta.Commit()
+
+ Dim StrMsg As New StringBuilder
+ StrMsg.Append("Abono Registrado Correctamente. ")
+ StrMsg.AppendFormat("Folio {1}", CveIE, ObjIE.Folio)
+
+ If IDPoliza > 0 Then StrMsg.AppendFormat(" Poliza: {1}", IDPoliza, FolioPoliza)
+
+ Dim TextoComplementoPago = EmitirComplementoPago(CveIE, CveVentasPago, SeriesPago)
+
+ Dim SbMensaje As New StringBuilder
+ SbMensaje.Append(String.Format("Abono Registrado Correctamente.
{2}", IDPoliza, FolioPoliza, TextoComplementoPago))
+
+ For Each NC In NCGeneradas
+ For Each msg In NC.Mensajes
+ StrMsg.Append(msg)
+ Next
+ StrMsg.Append("")
+ Next
+
+ Alert($"{StrMsg.ToString}
{TextoComplementoPago}", TipoMensaje.MsgInformacion, If(ChkSeguirRegistrando.Checked, "location.href =""#""", "location.href =""/Bancos/RepCxCCliente.aspx"""))
+
+ Else
+ If ObjConta IsNot Nothing Then ObjConta.RollBack()
+ ObjIE.RollBack()
+ Alert(MsgError, TipoMensaje.MsgAdvertencia)
+ End If
- For Each NC In NCGeneradas
- For Each msg In NC.Mensajes
- StrMsg.Append(msg)
- Next
- StrMsg.Append("")
- Next
-
- Alert($"{StrMsg.ToString}
{TextoComplementoPago}", TipoMensaje.MsgInformacion, If(ChkSeguirRegistrando.Checked, "location.href =""#""", "location.href =""/Bancos/RepCxCCliente.aspx"""))
- End If
-
- Else
- ObjIE.RollBack()
- Alert(MsgError, TipoMensaje.MsgAdvertencia)
- End If
- Else
- Alert("Debe de llevar un Folio", TipoMensaje.MsgAdvertencia)
- End If
- Else
- Alert("Debe de llevar un Importe", TipoMensaje.MsgAdvertencia)
- End If
-
ObjIE.Dispose()
ObjVentasSaldos.Dispose()
ObjMov.Dispose()
-
- 'BITACORA
- If CveIESustitucion > 0 And ComplementoSustitucionGenerado Then
- If Not ObjEvento.AddEventoBitacora($"Complemento de pago Cancelado por sustitución con Folio {TxtFolio.Text}", "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveIE:=CveIESustitucion) Then
-
- End If
- If Not ObjEvento.AddEventoBitacora($"Complemento de pago Generado por Sustitución de {FolioIECancelado}", "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveIE:=CveIE) Then
-
- End If
- End If
+ If ObjConta IsNot Nothing Then ObjConta.Dispose()
ObjEvento.Dispose()
- LimpiaCampos()
+
+ LimpiaCampos()
+
+ UPVentas.Update()
End Sub
@@ -1761,31 +1686,42 @@ Partial Class Ventas_ClientesAbonar
ObjFacturaDevolucion.CveUsuario = UsuarioActual.CveUsuario
ObjFacturaDevolucion.UsuarioCreo = UsuarioActual.Usuario
- 'If CveVentaPadre > 0 Then
- ' ObjFacturaDevolucion.CveVentaPadre = CveVentaPadre
- ' ObjFacturaDevolucion.CveVentaRelacion = CveVentaPadre
- 'End If
+ Dim CveSubProyecto As Integer = Me.CveSubProyecto
+ Dim CveMoneda As Integer = Me.CveMoneda
+ Dim CveCliente As Integer = Me.CveCliente
- Dim Folio As String = ""
- Dim Serie As String = ""
-
- Dim ObjFolios As New ClsGralFolios()
- If ObjFolios.GetFolios("Egs", UsuarioActual.CveEmpresa) Then
- Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format(" Estado = 'Activo' AND CveSubProyecto = {0}", Me.CveSubProyecto))
- If DT.Rows.Count > 0 Then
- Serie = DT.Rows(0)("Serie").ToString()
- Folio = DT.Rows(0)("FActual").ToString()
- End If
- DT.Dispose()
+ If CveSubProyecto <= 0 Then
+ CveSubProyecto = ListaVentasGenerarNC(0).CveSubProyecto
End If
- ObjFolios.Dispose()
+
+ If CveMoneda <= 0 Then
+ CveMoneda = ListaVentasGenerarNC(0).CveMoneda
+ End If
+
+ If CveCliente <= 0 Then
+ CveCliente = ListaVentasGenerarNC(0).CveCliente
+ End If
+
+ Dim Folio As Integer = -1
+ Dim Serie As String = "-1"
+
+ 'Dim ObjFolios As New ClsGralFolios()
+ 'If ObjFolios.GetFolios("Egs", UsuarioActual.CveEmpresa) Then
+ ' Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format(" Estado = 'Activo' AND CveSubProyecto = {0}", Me.CveSubProyecto))
+ ' If DT.Rows.Count > 0 Then
+ ' Serie = DT.Rows(0)("Serie").ToString()
+ ' Folio = DT.Rows(0)("FActual").ToString()
+ ' End If
+ ' DT.Dispose()
+ 'End If
+ 'ObjFolios.Dispose()
ObjFacturaDevolucion.CveEmpresa = UsuarioActual.CveEmpresa
ObjFacturaDevolucion.TipoCambio = If(Me.CveMoneda = 1, 1, GlobalTipoCambio(Now).FormatoNumero(4).ToDecimal())
ObjFacturaDevolucion.ConvertirPesos = False
- ObjFacturaDevolucion.CveMoneda = Me.CveMoneda
- ObjFacturaDevolucion.Moneda = GlobalDTMonedas.FiltroPrimeroValor("Moneda", $"CveMoneda = {Me.CveMoneda}")
- ObjFacturaDevolucion.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", $"CveMoneda = {Me.CveMoneda}")
+ ObjFacturaDevolucion.CveMoneda = CveMoneda
+ ObjFacturaDevolucion.Moneda = GlobalDTMonedas.FiltroPrimeroValor("Moneda", $"CveMoneda = {CveMoneda}")
+ ObjFacturaDevolucion.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", $"CveMoneda = {CveMoneda}")
ObjFacturaDevolucion.Serie = Serie
ObjFacturaDevolucion.Folio = Folio
ObjFacturaDevolucion.Fecha = Now
@@ -1809,10 +1745,10 @@ Partial Class Ventas_ClientesAbonar
ObjFacturaDevolucion.MetodoPago = ""
ObjFacturaDevolucion.ClaveMetodoPagoSAT = GlobalDTMetodosPago.FiltroPrimeroValor("ClaveSAT", $"CveMetodoPago = {ObjFacturaDevolucion.CveMetodoPago33}")
- ObjFacturaDevolucion.CveSubProyecto = Me.CveSubProyecto
+ ObjFacturaDevolucion.CveSubProyecto = CveSubProyecto
ObjFacturaDevolucion.SetSubProyecto()
- ObjFacturaDevolucion.CveCliente = Me.CveCliente
+ ObjFacturaDevolucion.CveCliente = CveCliente
ObjFacturaDevolucion.SetCliente()
Dim ObjCliente As New ClsClientes
@@ -1863,10 +1799,6 @@ Partial Class Ventas_ClientesAbonar
ObjFacturaDevolucion.TipoDocumento = ""
End Select
- If ObjFacturaDevolucion.TipoDocto IsNot Nothing Then
- ViewState("TipoDoctoDevolucion") = ObjFacturaDevolucion.TipoDocto
- End If
-
ObjFacturaDevolucion.FechaPago = Now
ObjFacturaDevolucion.CveCorte = -1
@@ -1912,8 +1844,12 @@ Partial Class Ventas_ClientesAbonar
DtVentasNC.AcceptChanges()
ObjFacturaDevolucion.DtVentasNC = DtVentasNC
- ObjFacturaDevolucion.GenerarPDFFactura = True
+ 'ObjFacturaDevolucion.GenerarPDFFactura = True
Dim Resp = ObjFacturaDevolucion.EmitirFactura(False, Transac:=Trasac, ObjContPaqTransac:=ObjConta)
+
+ ObjFacturaDevolucion.Dispose()
+
+
Return Resp
End Function
@@ -2822,137 +2758,142 @@ Partial Class Ventas_ClientesAbonar
Dim IdPolizaNueva = -1
Dim FolioPolizaNueva = -1
- 'CANCELA IE CONTABILIZADO
- If IDPoliza > 0 Then
- If ObjAC Is Nothing Then
- ErrorCancelar = True
- End If
-
- If Not ErrorCancelar Then
- Dim dt As DataTable
- If ObjAC.GetPoliza(IDPoliza, -1, -1, -1, -1) AndAlso ObjAC.DtResultados.Rows.Count > 0 Then
- dt = ObjAC.DtResultados
-
- ' MES ANTERIOR, MOVIMIENTOS CONTRARIOS (NEGATIVOS)
- If dt.Rows(0)("FechaPol").ToString.ToDate.Month < TxtFechaDocumento.Text.ToDate.Month Or dt.Rows(0)("FechaPol").ToString.ToDate.Year < TxtFechaDocumento.Text.ToDate.Year Then
- IdPolizaNueva = ObjAC.AddPoliza(3, String.Format("Cancelacion: {0}", dt.Rows(0)("Concepto").ToString), 0, 0, UsuarioActual.CveUsuario, TxtFechaDocumento.Text.ToDate)
-
- If IdPolizaNueva > 0 Then
- FolioPolizaNueva = ObjAC.Folio
-
- 'CREA POLIZA NEGATIVA
- For Each dr As DataRow In dt.Rows
- If Not ObjAC.AddMovimiento(IdPolizaNueva, dr("IdCuenta").ToString.ToEntero, dr("TipoMovto").ToString = "True", dr("Importe").ToString.ToDecimal * -1, dr("Referencia").ToString, String.Format("Cancelacion: {0}", dt.Rows(0)("Concepto").ToString), dr("IdSegNeg").ToString.ToEntero, TxtFechaDocumento.Text.ToDate, "") Then
- ErrorCancelar = True : Exit For
- End If
- Next
-
- 'AJUSTA POLIZA
- If Not ErrorCancelar Then
- If Not ObjAC.AjustaPoliza(IdPolizaNueva) Then
- ErrorCancelar = True
- End If
- End If
-
- 'CANCELA IE
- If Not ErrorCancelar Then
- If Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIESustitucion, True, IdPolizaNueva, TxtFechaDocumento.Text.ToDate) Then
- ErrorCancelar = True
- End If
- End If
-
- Else
- ErrorCancelar = True
- End If
-
- Else
-
- 'LIMPIA POLIZA PONIENDO IMPORTE EN CEROS
- For Each dr As DataRow In dt.Rows
- If Not ObjAC.UpdateMovimiento(dr("Id").ToString.ToEntero, dr("IdCuenta").ToString.ToEntero, dr("TipoMovto").ToString = "1", 0, dr("Referencia").ToString, dr("Concepto").ToString, dr("IdSegNeg").ToString.ToEntero, dr("Fecha").ToString.ToDate) Then
- ErrorCancelar = True : Exit For
- End If
- Next
-
- 'AJUSTA POLIZA
- If Not ErrorCancelar Then
- If Not ObjAC.AjustaPoliza(IDPoliza) Then
- ErrorCancelar = True
- End If
- End If
-
- 'CANCELA IE
- If Not ErrorCancelar Then
- If Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIESustitucion, False, IdPolizaNueva, TxtFechaDocumento.Text.ToDate) Then
- ErrorCancelar = True
- End If
- End If
-
- End If
-
- End If
- End If
- Else
-
- If FechaCorteIE.Month < TxtFechaDocumento.Text.ToDate.Month Or FechaCorteIE.Year < TxtFechaDocumento.Text.ToDate.Year Then
- 'CANCELA IE MES ANTERIOR
- If Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIESustitucion, True, IdPolizaNueva, TxtFechaDocumento.Text.ToDate) Then
- ErrorCancelar = True
- End If
- Else
- 'CANCELA IE MES ACTUAL
- If Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIESustitucion, False, IdPolizaNueva, TxtFechaDocumento.Text.ToDate) Then
- ErrorCancelar = True
- End If
- End If
-
- End If
-
- If Not ErrorCancelar Then
- If Banc.GetComplementoPagos(-1, CveIESustitucion, -1, UsuarioActual.CveEmpresa) Then
-
- Dim CveComplementoPago As Integer = -1
-
- If Banc.DtResultados.Rows.Count > 0 Then
- 'OBTENEMOS EL UUID DEL COMPLEMENTO A CANCELAR POR SUSTITUCION
- CFDIRelacionadoSustitucion = Banc.DtResultados.Rows(0)("FolioFiscal")
- CveComplementoPago = Banc.DtResultados(0)("CveComplementoPago").ToString().ToEntero
- End If
-
- 'ACTUALIZA FOLIOS CANCELADOS
- If Banc.DtResultados.FiltraParametros("", DistinctColumns:={"CveComplementoPago", "SerieFolio", "Fecha", "CveIE"}).Rows.Count > 0 Then
- If Not Banc.GetFoliosCancelados(UsuarioActual.CveEmpresa) Then
- ErrorCancelar = True
- Else
- Dim FolioCancelado = $"{FolioIECancelado}_C_{Banc.DtResultados(0)("Cantidad").ToString().ToEntero + 1}"
-
- If Not Banc.UpdateFolioCancelado(CveIESustitucion.ToEntero, Folio:=FolioCancelado) Then
- ErrorCancelar = True
- End If
- End If
- End If
-
- 'ACTUALIZA ESTATUS DE COMPLEMENTO DE PAGO A CANCELADO = 2
- If Not ErrorCancelar And CveComplementoPago > 0 Then
- If Not Banc.UpdateComplementoPagoCancelado(CveComplementoPago, 2, UsuarioActual.Empresa.CvePAC, UsuarioActual.CveEmpresa, DateTime.Now) Then
- ErrorCancelar = True
- End If
- End If
- End If
- End If
-
- If Not ErrorCancelar Then
- If ObjAC IsNot Nothing Then ObjAC.Commit()
+ Try
+ 'CANCELA IE CONTABILIZADO
+ If IDPoliza > 0 Then
+ If ObjAC Is Nothing Then
+ ErrorCancelar = True
+ End If
+
+ If Not ErrorCancelar Then
+ Dim dt As DataTable
+ If ObjAC.GetPoliza(IDPoliza, -1, -1, -1, -1) AndAlso ObjAC.DtResultados.Rows.Count > 0 Then
+ dt = ObjAC.DtResultados
+
+ ' MES ANTERIOR, MOVIMIENTOS CONTRARIOS (NEGATIVOS)
+ If dt.Rows(0)("FechaPol").ToString.ToDate.Month < TxtFechaDocumento.Text.ToDate.Month Or dt.Rows(0)("FechaPol").ToString.ToDate.Year < TxtFechaDocumento.Text.ToDate.Year Then
+ IdPolizaNueva = ObjAC.AddPoliza(3, String.Format("Cancelacion: {0}", dt.Rows(0)("Concepto").ToString), 0, 0, UsuarioActual.CveUsuario, TxtFechaDocumento.Text.ToDate)
+
+ If IdPolizaNueva > 0 Then
+ FolioPolizaNueva = ObjAC.Folio
+
+ 'CREA POLIZA NEGATIVA
+ For Each dr As DataRow In dt.Rows
+ If Not ObjAC.AddMovimiento(IdPolizaNueva, dr("IdCuenta").ToString.ToEntero, dr("TipoMovto").ToString = "True", dr("Importe").ToString.ToDecimal * -1, dr("Referencia").ToString, String.Format("Cancelacion: {0}", dt.Rows(0)("Concepto").ToString), dr("IdSegNeg").ToString.ToEntero, TxtFechaDocumento.Text.ToDate, "") Then
+ ErrorCancelar = True : Exit For
+ End If
+ Next
+
+ 'AJUSTA POLIZA
+ If Not ErrorCancelar Then
+ If Not ObjAC.AjustaPoliza(IdPolizaNueva) Then
+ ErrorCancelar = True
+ End If
+ End If
+
+ 'CANCELA IE
+ If Not ErrorCancelar Then
+ If Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIESustitucion, True, IdPolizaNueva, TxtFechaDocumento.Text.ToDate) Then
+ ErrorCancelar = True
+ End If
+ End If
+
+ Else
+ ErrorCancelar = True
+ End If
+
+ Else
+
+ 'LIMPIA POLIZA PONIENDO IMPORTE EN CEROS
+ For Each dr As DataRow In dt.Rows
+ If Not ObjAC.UpdateMovimiento(dr("Id").ToString.ToEntero, dr("IdCuenta").ToString.ToEntero, dr("TipoMovto").ToString = "1", 0, dr("Referencia").ToString, dr("Concepto").ToString, dr("IdSegNeg").ToString.ToEntero, dr("Fecha").ToString.ToDate) Then
+ ErrorCancelar = True : Exit For
+ End If
+ Next
+
+ 'AJUSTA POLIZA
+ If Not ErrorCancelar Then
+ If Not ObjAC.AjustaPoliza(IDPoliza) Then
+ ErrorCancelar = True
+ End If
+ End If
+
+ 'CANCELA IE
+ If Not ErrorCancelar Then
+ If Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIESustitucion, False, IdPolizaNueva, TxtFechaDocumento.Text.ToDate) Then
+ ErrorCancelar = True
+ End If
+ End If
+
+ End If
+
+ End If
+ End If
+ Else
+
+ If FechaCorteIE.Month < TxtFechaDocumento.Text.ToDate.Month Or FechaCorteIE.Year < TxtFechaDocumento.Text.ToDate.Year Then
+ 'CANCELA IE MES ANTERIOR
+ If Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIESustitucion, True, IdPolizaNueva, TxtFechaDocumento.Text.ToDate) Then
+ ErrorCancelar = True
+ End If
+ Else
+ 'CANCELA IE MES ACTUAL
+ If Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIESustitucion, False, IdPolizaNueva, TxtFechaDocumento.Text.ToDate) Then
+ ErrorCancelar = True
+ End If
+ End If
+
+ End If
+
+ If Not ErrorCancelar Then
+ If Banc.GetComplementoPagos(-1, CveIESustitucion, -1, UsuarioActual.CveEmpresa) Then
+
+ Dim CveComplementoPago As Integer = -1
+
+ If Banc.DtResultados.Rows.Count > 0 Then
+ 'OBTENEMOS EL UUID DEL COMPLEMENTO A CANCELAR POR SUSTITUCION
+ CFDIRelacionadoSustitucion = Banc.DtResultados.Rows(0)("FolioFiscal")
+ CveComplementoPago = Banc.DtResultados(0)("CveComplementoPago").ToString().ToEntero
+ End If
+
+ 'ACTUALIZA FOLIOS CANCELADOS
+ If Banc.DtResultados.FiltraParametros("", DistinctColumns:={"CveComplementoPago", "SerieFolio", "Fecha", "CveIE"}).Rows.Count > 0 Then
+ If Not Banc.GetFoliosCancelados(UsuarioActual.CveEmpresa) Then
+ ErrorCancelar = True
+ Else
+ Dim FolioCancelado = $"{FolioIECancelado}_C_{Banc.DtResultados(0)("Cantidad").ToString().ToEntero + 1}"
+
+ If Not Banc.UpdateFolioCancelado(CveIESustitucion.ToEntero, Folio:=FolioCancelado) Then
+ ErrorCancelar = True
+ End If
+ End If
+ End If
+
+ 'ACTUALIZA ESTATUS DE COMPLEMENTO DE PAGO A CANCELADO = 2
+ If Not ErrorCancelar And CveComplementoPago > 0 Then
+ If Not Banc.UpdateComplementoPagoCancelado(CveComplementoPago, 2, UsuarioActual.Empresa.CvePAC, UsuarioActual.CveEmpresa, DateTime.Now) Then
+ ErrorCancelar = True
+ End If
+ End If
+ End If
+ End If
+ Catch ex As Exception
+ ErrorCancelar = True
+ OnError("Ocurrió un error al cancelar el IE", ex)
+ End Try
+
+ If Not ErrorCancelar Then
Banc.Commit()
+ If ObjAC IsNot Nothing Then ObjAC.Commit()
Dim Msg As New StringBuilder
Msg.Append("El movimiento bancario quedó cancelado exitosamente.")
If IdPolizaNueva > 0 Then Msg.AppendFormat("
Ver Póliza de cancelación", IdPolizaNueva)
Alert(Msg.ToString, TipoMensaje.MsgInformacion)
- Else
- If ObjAC IsNot Nothing Then ObjAC.RollBack()
+ Else
Banc.RollBack()
+ If ObjAC IsNot Nothing Then ObjAC.RollBack()
Alert("El movimiento bancario no se pudo cancelar. Por favor vuelva a intentar.", TipoMensaje.MsgError)
End If
diff --git a/Ventas/PV.aspx b/Ventas/PV.aspx
index 327dbb21f..594ad76f0 100644
--- a/Ventas/PV.aspx
+++ b/Ventas/PV.aspx
@@ -2830,6 +2830,7 @@
+