From 1244c0232032387131d30a3b6c9633a8e594d630 Mon Sep 17 00:00:00 2001 From: Rene Molina Date: Wed, 5 Feb 2020 18:03:41 -0700 Subject: [PATCH 01/25] - permiso que faltaban, que esta en elpadre --- Ventas/RepVentaDetalle.aspx.vb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Ventas/RepVentaDetalle.aspx.vb b/Ventas/RepVentaDetalle.aspx.vb index 99738744c..fb62c7439 100644 --- a/Ventas/RepVentaDetalle.aspx.vb +++ b/Ventas/RepVentaDetalle.aspx.vb @@ -228,9 +228,9 @@ Partial Class RepVentaDetalle If UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12) Then ImgExcelVSH.Visible = True ImgExcel.Visible = False - End If - - If UsuarioActual.CveVendedor > 0 Then + End If + + If UsuarioActual.CveVendedor > 0 AndAlso Not UsuarioActual.TienePermisoProceso(263) Then DdlVendedor.SelectedValuesIfExistM(UsuarioActual.CveVendedor.ToString) DdlVendedor.Attributes.Add("disabled", "") DdlVendedor.Enabled = False From 603dc6686694e267ba693ad8099b938614673401 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 5 Feb 2020 18:35:33 -0700 Subject: [PATCH 02/25] CREAR PUNTO DE INTERES EN RASTREO --- GPS/Rastreo.aspx | 2560 +++++++++++++++++++++++-------------------- GPS/Rastreo.aspx.vb | 44 + 2 files changed, 1403 insertions(+), 1201 deletions(-) diff --git a/GPS/Rastreo.aspx b/GPS/Rastreo.aspx index d09872508..79ce9cf80 100644 --- a/GPS/Rastreo.aspx +++ b/GPS/Rastreo.aspx @@ -255,7 +255,7 @@
  • - + @@ -274,6 +274,7 @@ + @@ -316,7 +317,7 @@ - + @@ -860,6 +861,48 @@ + + +
    + + + + + +
    diff --git a/Compras/ProveedoresAuxiliar.aspx.vb b/Compras/ProveedoresAuxiliar.aspx.vb index 9b727b010..926764dfe 100644 --- a/Compras/ProveedoresAuxiliar.aspx.vb +++ b/Compras/ProveedoresAuxiliar.aspx.vb @@ -81,7 +81,7 @@ Partial Class Compras_ProveedoresAuxiliar 'Falta PA If ObjConta.GetProveedoresAuxiliar(DdlProveeedores.SelectedValue.ToEntero, -1, txtFechaI.Text.ToDate, txtFechaF.Text.ToDate, UsuarioActual.CveEmpresa, - DdlOpcion.SelectedValue.ToEntero, DdlTipoProveedor.SelectedValue.ToEntero) Then + DdlOpcion.SelectedValue.ToEntero, DdlTipoProveedor.SelectedValue.ToEntero, DdlOpcionContabilizable.SelectedValue.ToEntero) Then If DdlOpcion.SelectedValue.ToEntero = 2 Then GvP.DataSource = ObjConta.DtResultados.FiltraParametros($" IIF(ISNULL(CveConceptoContable,0) = 5 AND Importe >= 0,0,1) = 1 ") Else diff --git a/Empresas/57/Formatos/Factura.rdlc b/Empresas/57/Formatos/Factura.rdlc index d09c31329..b7edb3bc0 100644 --- a/Empresas/57/Formatos/Factura.rdlc +++ b/Empresas/57/Formatos/Factura.rdlc @@ -816,8 +816,15 @@ Normal + + + + + - =Parameters!RFC.Value + GOTE811117236 @@ -1304,7 +1311,7 @@ Textbox19 1.53208in - 0.04514in + 0.05471in 0.23611in 0.85387in 17 @@ -1379,9 +1386,8 @@ - Cuidad + Ciudad @@ -1391,7 +1397,7 @@ Textbox19 1.7682in - 0.04514in + 0.05471in 0.25in 0.85387in 19 diff --git a/Inventarios/TraspasoAlmacen.aspx b/Inventarios/TraspasoAlmacen.aspx index ed7c76b25..fdb708148 100644 --- a/Inventarios/TraspasoAlmacen.aspx +++ b/Inventarios/TraspasoAlmacen.aspx @@ -470,7 +470,7 @@
    - +
    diff --git a/Inventarios/TraspasoAlmacen.aspx.vb b/Inventarios/TraspasoAlmacen.aspx.vb index 8b3f9aa69..f9323c604 100644 --- a/Inventarios/TraspasoAlmacen.aspx.vb +++ b/Inventarios/TraspasoAlmacen.aspx.vb @@ -926,6 +926,24 @@ Partial Class Inventarios_TraspasoAlmacen 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 +1007,7 @@ Partial Class Inventarios_TraspasoAlmacen If ErrorExistencia Then CargaGvDatos() End If - + ObjConta.Dispose() ObjInventario.Dispose() End Sub @@ -1573,6 +1591,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 +1663,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 +1808,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 @@
    - + <%-- --%>
    From eee54b888dfb02c7f87a1b941accca6b76c51ad6 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Thu, 6 Feb 2020 13:29:32 -0700 Subject: [PATCH 06/25] . --- GPS/Rastreo.aspx | 281 +++++++++++++++++------------------- GPS/Rastreo.aspx.vb | 255 ++++++++++++++++++++++---------- GPS/Rastreo/JS/Geocercas.js | 138 ++++++++++++++++++ 3 files changed, 442 insertions(+), 232 deletions(-) create mode 100644 GPS/Rastreo/JS/Geocercas.js diff --git a/GPS/Rastreo.aspx b/GPS/Rastreo.aspx index fdce52776..6da745add 100644 --- a/GPS/Rastreo.aspx +++ b/GPS/Rastreo.aspx @@ -405,7 +405,7 @@

    - +
    @@ -415,7 +415,14 @@
    -
    +
    +
    + +
    + +
    +
    +
    @@ -820,6 +827,49 @@
    + - + - + + + + - + - @@ -861,6 +913,45 @@
    +
  • - -
  • + <%--
  • diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 8f8f11141..28f8d9005 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -3544,7 +3544,6 @@ Partial Class Ventas If TienePermiso <> "" Then ' si tiene acceso en el subproyecto 'LkNotaCredito.Visible = UsuarioActual.TienePermisoProceso(175) If UsuarioActual.TienePermisoProceso(264) Then - LkDevolucion.Visible = True InicializaAplicaDevolucion() End If End If @@ -7694,7 +7693,9 @@ Partial Class Ventas 'ObjFactura.RefDocto = TxtDocto.Text.Trim - ObjFactura.Folio = If(EstablecioFolio Or VistaPrevia Or (CveVenta > 0 And (NuevaFactura.Contiene(0, 2))), TxtFolio.Text.Trim.ToEntero, -1) + 'si es cancelacion, debe de conservar el folio actual + If Not EsCancelacion Then ObjFactura.Folio = If(EstablecioFolio Or VistaPrevia Or (CveVenta > 0 And (NuevaFactura.Contiene(0, 2))), TxtFolio.Text.Trim.ToEntero, -1) + 'ObjFactura.Folio = If(ExFolioFactura, FolioXML.ToEntero, -1) ObjFactura.Serie = If(VistaPrevia, "VistaPrevia", LblSerie.Text) ObjFactura.Fecha = New Date(TxtFecha.Text.Trim.ToDate.Year, TxtFecha.Text.Trim.ToDate.Month, TxtFecha.Text.Trim.ToDate.Day, Now.Hour, Now.Minute, Now.Second) @@ -13876,6 +13877,12 @@ Partial Class Ventas If PU * If(DdlMoneda.SelectedValue.ToEntero = 1, 1, TxtTipoCambio.Text.ToDecimal) >= DtPromociones.FiltroPrimeroValor("PUPromocion", $"CvePS = {CvePS}").ToDecimal Then EsValido = True End If + Else + 'valida sino tiene promocion la clasificacion + If DtPromociones.FiltraParametros($"CveClasificacion = {DdlClasificacion.SelectedValue.ToEntero}").Rows.Count > 0 Then + ''falta aplicar si tiene promocion + End If + End If End If @@ -16264,12 +16271,7 @@ Partial Class Ventas Response.Redirect(url) End Sub - Private Sub BtnGenerarNC_Click(sender As Object, e As EventArgs) Handles LkDevolucion.Click - Dim url As String = String.Format("Ventas.aspx?CveDevolucion={0}&NuevaFactura=0", CveVenta) - Response.Redirect(url) - - End Sub 'Private Sub LkNotaCreditoC_Click(sender As Object, e As EventArgs) Handles LkNotaCredito.Click ' Dim url As String = String.Format("Ventas.aspx?CveDevolucion={0}&NuevaFactura=2", CveVenta) @@ -16405,6 +16407,7 @@ Partial Class Ventas DdlMetodoPago33.Enabled = True DdlFormaPago33.Enabled = True UPCondicionesPago.Update() + If Me.PermiteCredito Then RBLPago.Enabled = True ModalidadEdicion = True @@ -21410,7 +21413,6 @@ Partial Class Ventas 'LIMPIA ACCIONES HLOrdendeCompra.Visible = False - LkDevolucion.Visible = False LBAplicaDevolucion.Visible = False 'LkNotaCredito.Visible = False LkEliminarFactura.Visible = False @@ -21537,7 +21539,7 @@ Partial Class Ventas #Region " APLICA DEVOLUCION " Private Sub InicializaAplicaDevolucion() If Not UsuarioActual.CveUsuario = 100 Then - If Not UsuarioActual.CveEmpresa.Contiene(72, 80, 119) Then + If Not UsuarioActual.CveEmpresa.Contiene(72, 80, 119, 140, 141, 146) Then Exit Sub End If End If @@ -21547,7 +21549,6 @@ Partial Class Ventas Exit Sub End If - LkDevolucion.Visible = False LBAplicaDevolucion.Visible = True Dim SeEsconde As Boolean = False Dim ObjVenta As New ClsVentas @@ -21726,7 +21727,6 @@ Partial Class Ventas BtnEmitir.Visible = False 'REINICIALIZA ACCIONES - LkDevolucion.Visible = False 'LkNotaCredito.Visible = False LkEliminarFactura.Visible = False ImgDownCancelacion.Visible = False @@ -23372,7 +23372,6 @@ Partial Class Ventas BtnGenerarOS.Visible = False BtnsFacturar.Visible = False HLOrdendeCompra.Visible = False - LkDevolucion.Visible = False LBAplicaDevolucion.Visible = False 'LkNotaCredito.Visible = False LkEliminarFactura.Visible = False diff --git a/vwd.webinfo b/vwd.webinfo index 07746b18a..de9866feb 100644 --- a/vwd.webinfo +++ b/vwd.webinfo @@ -5,6 +5,10 @@ + + + + \ No newline at end of file From 258b8bf6c2d2a55cfc322ccc1da975b5e4c1e354 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Fri, 7 Feb 2020 11:18:46 -0700 Subject: [PATCH 13/25] DEVOLUCIONES, AGREGAR LOS USADOS DEPENDIENDO DE LOS SELECCIONADO --- Ventas/Ventas.aspx | 2 +- Ventas/Ventas.aspx.vb | 65 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 59 insertions(+), 8 deletions(-) diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index bab61a147..e9f4b52c4 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -6094,7 +6094,7 @@ diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index f5547b65b..1070d5714 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -21359,7 +21359,7 @@ Partial Class Ventas PorcentajeRetISR As Double, ImporteRetISR As Double, PorcentajeIEPS As Double, ImporteIEPS As Double, TipoDescuento As Integer, Descuento As Double, Total As Double, SerieLote As String, TiempoEntrega As String, CvePresupuestoIngreso As Integer, EntregaDirecta As Integer, SATClaveProdServ As String, SATClaveUM As String, CveContratoDetalle As Integer, CveVentaDetalle As Integer, CveMovimientoDetallePedido As Integer, CveOrdenCompraDetalle As Integer, - CveVentaDetalleRemision As Integer, CveVentaDetalleCotizacion As Integer) + CveVentaDetalleRemision As Integer, CveVentaDetalleCotizacion As Integer, Optional CveTamaño As Integer = -1) Dim Row As DataRow = Nothing Row = TmpDT.NewRow() @@ -21418,6 +21418,8 @@ Partial Class Ventas Row("CveVentaDetalleRemision") = CveVentaDetalleRemision Row("CveVentaDetalleCotizacion") = CveVentaDetalleCotizacion + Row("CveTamaño") = CveTamaño + TmpDT.Rows.Add(Row) End Sub @@ -21572,7 +21574,8 @@ Partial Class Ventas Dim ObjVenta As New ClsVentas If ObjVenta.GetVentaDetalle(CveVenta) Then If Not ObjVenta.DtResultados.SUM("CantSur").ToString.ToDecimal > 0 Then SeEsconde = True - GvAplicaDevolucion.DataSource = ObjVenta.DtResultados.FiltraParametros("CantRes > 0") + 'NO MOSTRAR LOS PRODUCTOS CON LA CLASIFICACION DE USADOS + GvAplicaDevolucion.DataSource = ObjVenta.DtResultados.FiltraParametros("CantRes > 0 AND CveClasificacion <> 20519") End If ObjVenta.Dispose() @@ -21621,6 +21624,8 @@ Partial Class Ventas Dim AplicaPUEditado As Boolean = UsuarioActual.TienePermisoProceso(253) + Dim DtUsados As DataTable = TmpDT.FiltraParametros("CveClasificacion = 20519") + TmpDT.Clear() For Each Gv As GridViewRow In GvAplicaDevolucion.Rows If Gv.FCCheckBox("Chk").Checked And Gv.FCTextBox("TxtCantidadAplicaDevolucion").Text.ToDecimal > 0 Then @@ -21643,9 +21648,48 @@ Partial Class Ventas Gv.DataKey("PorcentajeRetIVA").ToString.ToDecimal, ImporteRetIVA, Gv.DataKey("PorcentajeRetISR").ToString.ToDecimal, ImporteRetISR, Gv.DataKey("PorcentajeIEPS").ToString.ToDecimal, ImporteIEPS, -1, Descuento, Total, "", "", -1, -1, - Gv.DataKey("SATClaveProdServ").ToString, Gv.DataKey("SATClaveUM").ToString, -1, Gv.DataKey("CveVentaDetalle").ToString.ToEntero, -1, -1, -1, -1) + Gv.DataKey("SATClaveProdServ").ToString, Gv.DataKey("SATClaveUM").ToString, -1, Gv.DataKey("CveVentaDetalle").ToString.ToEntero, -1, -1, -1, -1, Gv.DataKey("CveTamaño").ToEntero()) End If Next + + 'AGREGAR LOS USADOS EN LA DEVOLUCION + CalculaUsados(DtUsados) + 'If DtUsados IsNot Nothing AndAlso DtUsados.Rows.Count > 0 Then + ' Dim DtPSVenta As DataTable = TmpDT.Copy() + ' For Each Row As DataRow In DtPSVenta.Rows + ' Dim RowCargo As DataRow = DTTamanios.FiltroPrimero($"CveTamaño = { Row("CveTamaño").ToString.ToEntero } ") + ' If RowCargo IsNot Nothing Then + ' Dim CvePSCargo As Integer = RowCargo("CvePSCargo").ToString.ToEntero + + ' For Each RowUsado As DataRow In DtUsados.FiltraParametros($"CvePS = {CvePSCargo}").Rows + ' 'If drow("CvePS").ToString.ToEntero = drow2("CvePSCargo").ToString.ToEntero Then + ' 'End If + ' Dim Cantidad As Decimal = RowUsado("Cantidad").ToString().ToDecimal() + ' Dim Descuento As Decimal = Cantidad * RowUsado("Descuento").ToString.ToDecimal / RowUsado("Cantidad").ToString.ToDecimal + ' Dim PU As Decimal = RowUsado("PU").ToString().ToDecimal() + ' Dim Total As Decimal = (Cantidad * PU) + ' Dim TotalImpuestos As Decimal = (Cantidad * PU) - Descuento + ' Dim ImporteIVA As Decimal = TotalImpuestos * RowUsado("PorcentajeIVA").ToString.ToDecimal + ' Dim ImporteRetIVA As Decimal = TotalImpuestos * RowUsado("PorcentajeRetIVA").ToString.ToDecimal + ' Dim ImporteRetISR As Decimal = TotalImpuestos * RowUsado("PorcentajeRetISR").ToString.ToDecimal + ' Dim ImporteIEPS As Decimal = TotalImpuestos * RowUsado("PorcentajeIEPS").ToString.ToDecimal + + ' AgregaTempDT(TmpDT, RowUsado("CvePS").ToString.ToEntero, RowUsado("PS").ToString, RowUsado("Codigo").ToString, RowUsado("CodigoPS").ToString, + ' RowUsado("CveTipoPS").ToString.ToEntero, RowUsado("CveTipoInvPS").ToString.ToEntero, + ' RowUsado("CveUM").ToString.ToEntero, RowUsado("UM").ToString, RowUsado("CveClasificacion").ToString.ToEntero, + ' RowUsado("Clasificacion").ToString, RowUsado("CveProyecto").ToString.ToEntero, RowUsado("Proyecto").ToString, + ' RowUsado("CveSubProyecto").ToString.ToEntero, RowUsado("SubProyecto").ToString, + ' RowUsado("Obs").ToString, Cantidad, PU, RowUsado("PorcentajeIVA").ToString.ToDecimal, ImporteIVA, + ' RowUsado("PorcentajeRetIVA").ToString.ToDecimal, ImporteRetIVA, + ' RowUsado("PorcentajeRetISR").ToString.ToDecimal, ImporteRetISR, RowUsado("PorcentajeIEPS").ToString.ToDecimal, + ' ImporteIEPS, -1, Descuento, Total, "", "", -1, -1, + ' RowUsado("SATClaveProdServ").ToString, RowUsado("SATClaveUM").ToString, -1, RowUsado("CveVentaDetalle").ToString.ToEntero, -1, -1, -1, -1) + ' Next + ' End If + + ' Next + 'End If + TrTipoRelacion.Visible = True DdlTiposRelacion.SelectedValueExist("3") @@ -23713,8 +23757,8 @@ Partial Class Ventas #Region "U S A D O S" - Private Sub CalculaUsados() - If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Cot") Then + Private Sub CalculaUsados(Optional DtUsadosDevolucion As DataTable = Nothing) + If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Cot", "Dev") Then Dim DTTamanios As DataTable = GlobalDTAcumTamaños() Dim DTCvePSCostos As DataTable @@ -23832,16 +23876,23 @@ Partial Class Ventas End If Next - For Each drowPsTamaños As DataRow In DTPSTemp.Rows Modalidad = "A" If drowPsTamaños("PU").ToString.ToDecimal > 0 Then + + Dim CveVentaDetalleDevolucion As Integer = -1 + + If DtUsadosDevolucion IsNot Nothing AndAlso DtUsadosDevolucion.Rows.Count > 0 Then + CveVentaDetalleDevolucion = DtUsadosDevolucion.FiltroPrimeroValor("CveVentaDetalle", $"CvePS = {drowPsTamaños("CvePS").ToString.ToEntero}").ToEntero() + End If + AgregarProductoServicio(drowPsTamaños("Cantidad").ToString.ToEntero, drowPsTamaños("CveUnidadMedida").ToString.ToEntero, drowPsTamaños("UnidadMedida").ToString, drowPsTamaños("CveClasificacion").ToString.ToEntero, drowPsTamaños("Clasificacion").ToString, drowPsTamaños("CvePS").ToString.ToEntero, drowPsTamaños("PS").ToString, "", drowPsTamaños("PU").ToString.ToDecimal, 0, -1, "", drowPsTamaños("CveSubProyecto").ToString.ToEntero, - drowPsTamaños("SubProyecto").ToString) + drowPsTamaños("SubProyecto").ToString, CveVentaDetalle:=CveVentaDetalleDevolucion) End If Next + End If End Sub From ef5ebd88dbefd29966e2d23acc49254d83b7697a Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Fri, 7 Feb 2020 15:05:15 -0700 Subject: [PATCH 14/25] FACTURAR ENTREGAS DIRECTA Y PRODUCTOS QUE NO VIENEN DE OC EN UNA MISMA FACTURA --- Ventas/Ventas.aspx.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 47522f923..c531510eb 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -6419,7 +6419,7 @@ Partial Class Ventas 'VALIDA EXISTENCIA CveProducto = dr("CvePS").ToString.ToEntero CveUnidad = dr("CveUM").ToString.ToEntero - Cantidad = TmpDT.SUM("Cantidad", $"CvePS = {CveProducto}") 'VALIDA CONTRA LA SUMA DEL MISMO PS + Cantidad = TmpDT.SUM("Cantidad", $"CvePS = {CveProducto} AND (EntregaDirecta IS NULL OR EntregaDirecta < 1)") 'VALIDA CONTRA LA SUMA DEL MISMO PS If UsuarioActual.Empresa.UsaInventarios AndAlso RemisionesLista.Count < 1 AndAlso dr("EntregaDirecta").ToString.ToEntero < 1 Then Existencia = ObjInventarios.GetExistenciasPS(CveProducto, CveUnidad, UsuarioActual.CveEmpresa, CveAlmacenExistenciasContrato, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero, CveVendedor:=DdlVendedor.SelectedValue.ToEntero, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeAdelantado:=1, PendientePorSurtir:=1, RestringirAlmacenes:=1, ExcluyeApartados:=-1) If Existencia < Cantidad Then @@ -13828,7 +13828,7 @@ Partial Class Ventas If DdlTipoComprobante.SelectedValue <> "Cot" And ChkSinExistencia.Checked = False Then 'VALIDA EXISTENCIA If UsuarioActual.CveEmpresa.Contiene({72, 80, 119}) Then - If Existencia - TmpDT.SUM("Cantidad", $"CvePS = {CvePS}") < TxtCantidad.Text.ToDouble Then + If Existencia - TmpDT.SUM("Cantidad", $"CvePS = {CvePS} AND (EntregaDirecta IS NULL OR EntregaDirecta < 1)") < TxtCantidad.Text.ToDouble Then Alert("No cuenta con la cantidad suficiente en inventario. Cuenta con " + Existencia.FormatoNumero(2) + ".", TipoMensaje.MsgAdvertencia) Return False End If From 1efa571920714dba9b5fe64c31a94e7229422e12 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Fri, 7 Feb 2020 15:05:30 -0700 Subject: [PATCH 15/25] AGREGAR MODULOS QUE FALTABAN EN CLSPAGINAS,COTIZACIONES,REP COTIZACIONES --- App_Code/ClsPaginas.vb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index ea02be437..b0d91b2b5 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -4562,8 +4562,10 @@ Public Class ClsPaginas PaginaDict.Add("/Ventas/Clientes.aspx".ToUpper(), 5) PaginaDict.Add("/Ventas/CatClientes.aspx".ToUpper(), 5) PaginaDict.Add("/Ventas/CatClientesClasificaciones.aspx".ToUpper(), 408) - PaginaDict.Add("/Ventas/Ventas.aspx".ToUpper(), 6) - PaginaDict.Add("/Ventas/RepVentas.aspx".ToUpper(), 9) + PaginaDict.Add("/Ventas/Ventas.aspx".ToUpper(), 6) + PaginaDict.Add("/Ventas/Ventas.aspx?Op=Cot".ToUpper(), 366) + PaginaDict.Add("/Ventas/RepVentas.aspx".ToUpper(), 9) + PaginaDict.Add("/Ventas/RepVentas.aspx?Op=Cot".ToUpper(), 367) PaginaDict.Add("/Ventas/RepRemisiones.aspx".ToUpper(), 430) PaginaDict.Add("/Ventas/RepRemisionesDetalle.aspx".ToUpper(), 430) PaginaDict.Add("/Ventas/RepCotizaciones.aspx".ToUpper(), 430) @@ -4641,7 +4643,7 @@ Public Class ClsPaginas 'PaginaDict.Add("/Ventas/Ventas.aspx".ToUpper(), 2016) 'PaginaDict.Add("/Ventas/Clientes.aspx".ToUpper(), 2017) PaginaDict.Add("/Ventas/Ventas.aspx?Op=Rem".ToUpper(), 2018) - PaginaDict.Add("/Ventas/Ventas.aspx?Op=Cot".ToUpper(), 2019) + 'PaginaDict.Add("/Ventas/Ventas.aspx?Op=Cot".ToUpper(), 2019) PaginaDict.Add("/Ventas/VentasH.aspx".ToUpper(), -1) PaginaDict.Add("/Ventas/ClientesAbonarH.aspx".ToUpper(), -1) PaginaDict.Add("/Ventas/PVRaul.aspx".ToUpper(), -1) From 21d7bcd0acd50e6df10341e40c7399ed68ddcc30 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Fri, 7 Feb 2020 19:34:09 -0700 Subject: [PATCH 16/25] AGREGAR AGRUPADOR POR SI ES DISTRIBUCION --- Acumuladores/RepEntradasUsadosClientes.aspx.vb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Acumuladores/RepEntradasUsadosClientes.aspx.vb b/Acumuladores/RepEntradasUsadosClientes.aspx.vb index f20abeef3..8925785f9 100644 --- a/Acumuladores/RepEntradasUsadosClientes.aspx.vb +++ b/Acumuladores/RepEntradasUsadosClientes.aspx.vb @@ -61,11 +61,18 @@ Partial Class Acumuladores_RepEntradasUsadosClientes Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.DBCampo("EsHeader").ToString = "-1" Or e.Row.DBCampo("Codigo").ToString = "" Then - e.Row.CssClass = "SubTotales2" - End If - + 'If e.Row.DBCampo("EsHeader").ToString = "-1" Or e.Row.DBCampo("Codigo").ToString = "" Then + ' e.Row.CssClass = "SubTotales2" + 'End If + If e.Row.DBCampo("TipoHeader").ToString = "1" Then + e.Row.CssClass = "Totales" + ElseIf e.Row.DBCampo("TipoHeader").ToString = "2" Then + e.Row.CssClass = "SubTotales" + ElseIf e.Row.DBCampo("TipoHeader").ToString = "3" Then + e.Row.CssClass = "SubTotales2" + End If End If + End Sub Protected Sub BtnImprimir_Click(sender As Object, e As EventArgs) From 5eacacd25a4171824ff5f3d52888622f4d91b8c9 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Fri, 7 Feb 2020 19:34:36 -0700 Subject: [PATCH 17/25] AGREGAR AGRUPADOR POR SI ES DISTRIBUCION --- Ventas/ClientesAbonar.aspx.vb | 2262 ++++++++++++++++----------------- 1 file changed, 1100 insertions(+), 1162 deletions(-) diff --git a/Ventas/ClientesAbonar.aspx.vb b/Ventas/ClientesAbonar.aspx.vb index 0dfcc09ad..a6a8b87f1 100644 --- a/Ventas/ClientesAbonar.aspx.vb +++ b/Ventas/ClientesAbonar.aspx.vb @@ -659,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 = "" @@ -674,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 @@ -684,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 @@ -1416,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.

    Poliza: {1}

    {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.

    Poliza: {1}

    {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.

    Poliza: {1}

    {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 @@ -1764,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 @@ -1812,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 @@ -1866,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 @@ -1915,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 @@ -2825,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 From f5b9e0354fcf235d8d1536ddedbdc0fea6b5ee1a Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Fri, 7 Feb 2020 19:34:56 -0700 Subject: [PATCH 18/25] VALIDACION DE SALDOS EN TEXTBOX AL SELECCIONAR REMISION DE NC --- Ventas/Ventas.aspx | 65 ++++++++++++++++++++++++++++--------------- Ventas/Ventas.aspx.vb | 6 ++++ 2 files changed, 48 insertions(+), 23 deletions(-) diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index b2d59ddde..0847b5a8f 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -211,7 +211,7 @@ <%--INICIA: CANCELAR - NC - DEVOLUCION [OLD]--%> - + <%--
  • @@ -355,7 +355,7 @@
  • Enviar Póliza Virtual
  • -<%--
  • + <%--
  • Descargar Factura Prueba
  • --%> @@ -364,7 +364,7 @@ - <%-- --%> + <%-- --%> <%-- --%> @@ -1303,7 +1303,7 @@
    - @@ -6506,6 +6506,25 @@ } } + function CalculaSaldoRNCChk(TxtImporte, Saldo, Chk) { + if (Chk.checked) { + TxtImporte.value = FormatoNumero(Saldo, 2); + } else { + TxtImporte.value = ""; + } + } + function LimitaSaldoRNCChk(TxtImporte, Saldo) { + var Importe = 0; + if (TxtImporte.value != '') { + Importe = parseFloat(TxtImporte.value); + } + + if (Importe > Saldo) { + TxtImporte.value = FormatoNumero(Saldo, 2); + } else { + TxtImporte.value = FormatoNumero(Importe, 2);; + } + } function CalculaTotalChk(Total, SubTotal, TxtTotalGv, TxtImporte, Saldo, Porcentaje, Chk) { var Importe = 0, ImporteSinPorcentaje = 0; @@ -6531,18 +6550,18 @@ } if ('<%= UsuarioActual.Empresa.Funcionalidad(344) %>' == '1') { - CompararNC(); - } - } + CompararNC(); + } + } - function CalculaTotalRNCChk(TxtImporte, Saldo, Chk) { - if (Chk.checked) { - TxtImporte.value = FormatoNumero(Saldo, 2); - } else { - TxtImporte.value = ""; - } + function CalculaTotalRNCChk(TxtImporte, Saldo, Chk) { + if (Chk.checked) { + TxtImporte.value = FormatoNumero(Saldo, 2); + } else { + TxtImporte.value = ""; + } - if ('<%= UsuarioActual.Empresa.Funcionalidad(344) %>' == '1') { + if ('<%= UsuarioActual.Empresa.Funcionalidad(344) %>' == '1') { CompararNC(); } } @@ -6981,17 +7000,17 @@ function SetDisabledTxtTotal(valor) { DisabledTxtTotal = valor; $('#<%= TxtTotal.ClientID %>').prop('readonly', DisabledTxtTotal); - } + } - function loadpage() { - $('.AjustaT').each(function () { - AjustaTotales($(this)); - }) - $('.AjustaT').change(function () { - AjustaTotales($(this)); - }); + function loadpage() { + $('.AjustaT').each(function () { + AjustaTotales($(this)); + }) + $('.AjustaT').change(function () { + AjustaTotales($(this)); + }); - $('#<%= TxtTotal.ClientID %>').prop('readonly', DisabledTxtTotal); + $('#<%= TxtTotal.ClientID %>').prop('readonly', DisabledTxtTotal); } diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index c531510eb..3699d95db 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -21074,6 +21074,12 @@ Partial Class Ventas UpDescNC.Update() End Sub + Protected Sub GvDescNC_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDescNC.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + e.Row.FCCheckBox("ChkAplicar").Attributes.Add("onclick", $"CalculaSaldoRNCChk({e.Row.FCTextBox("TxtImporte").ClientID},{e.Row.DBCampo("Saldo").ToDouble}, this);") + e.Row.FCTextBox("TxtImporte").Attributes.Add("onkeyup", $"LimitaSaldoRNCChk({e.Row.FCTextBox("TxtImporte").ClientID},{e.Row.DBCampo("Saldo").ToDouble});") + End If + End Sub Protected Sub GvCxC_RowDataBound(sender As Object, e As GridViewRowEventArgs) If e.Row.RowType = DataControlRowType.DataRow Then From 61899a38f6a7e6551a7abd753d43f1d548c72089 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Fri, 7 Feb 2020 19:49:30 -0700 Subject: [PATCH 19/25] AGREGAR CODICIONES NUEVAS A LOS CODIGOS DE INSPECCION,LINEA Y ENSAMBLE DEPENDIENDO DE LA CLASIFICACION --- Ventas/PV.aspx | 60 ++++++++++++++++++++++++++++++++++++++++------- Ventas/PV.aspx.vb | 5 +++- 2 files changed, 56 insertions(+), 9 deletions(-) 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 @@ +
    @@ -2916,6 +2917,7 @@
    + <%----%> <%----%> @@ -3011,23 +3013,65 @@